1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
Thomas Landauer 2022-11-10 20:19:02 +01:00 committed by GitHub
parent 4d53d26f00
commit c51d3665eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,17 +24,18 @@ This fails since it's not guaranteed that subsequent calls to `$cat->getName()`
#### Possible Solutions
* Use a variable:
```php
<?php
$catName = $cat->getName();
if (is_string($catName) {
foo($catName);
}
unset($catName);
```
* Add [`@psalm-mutation-free`](../../annotating_code/supported_annotations.md#psalm-mutation-free) to the declaration of the function
Use a variable:
```php
<?php
$catName = $cat->getName();
if (is_string($catName) {
foo($catName);
}
unset($catName);
```
Or add [`@psalm-mutation-free`](../../annotating_code/supported_annotations.md#psalm-mutation-free) to the declaration of the function
### Calling Another Function After `if`