1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

add documentation for pure-callable (#4329)

This commit is contained in:
Marco Perone 2020-10-15 01:59:44 +02:00 committed by Daniil Gentili
parent e3bb43641c
commit 91e8e26937
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -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.