mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Removing list
see https://github.com/vimeo/psalm/pull/8696#issuecomment-1310677110
This commit is contained in:
parent
4d53d26f00
commit
c51d3665eb
@ -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`
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user