Skip to content

Commit

Permalink
add documentation for pure-callable (#4329)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosh committed Oct 14, 2020
1 parent ece18cd commit 641e7d7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/annotating_code/supported_annotations.md
Expand Up @@ -336,6 +336,23 @@ echo Arithmetic::addCumulative(3); // outputs 3
echo Arithmetic::addCumulative(3); // outputs 6
```

### `@pure-callable`

On the other hand, `pure-callable` can be used to denote a callable which needs to be pure.

```php
/**
* @param pure-callable(mixed): int $callback
*/
function foo(callable $callback) {...}

// this fails since random_int is not pure
foo(
/** @param mixed $p */
fn($p) => random_int(1, 2)
);
```

### `@psalm-allow-private-mutation`

Used to annotate readonly properties that can be mutated in a private context. With this, public properties can be read from another class but only be mutated within a method of its own class.
Expand Down

0 comments on commit 641e7d7

Please sign in to comment.