1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge pull request #8696 from ThomasLandauer/patch-1

This commit is contained in:
Bruce Weirdan 2022-11-10 12:38:03 -04:00 committed by GitHub
commit e2e9d824e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,8 @@ foo(rand(0, 1) ? "hello" : null);
### Using a Function Call inside `if`
```php
<?php
if (is_string($cat->getName()) {
foo($cat->getName());
}
@ -24,6 +26,8 @@ This fails since it's not guaranteed that subsequent calls to `$cat->getName()`
* Use a variable:
```php
<?php
$catName = $cat->getName();
if (is_string($catName) {
foo($catName);
@ -35,6 +39,8 @@ This fails since it's not guaranteed that subsequent calls to `$cat->getName()`
### Calling Another Function After `if`
```php
<?php
if (is_string($cat->getName()) {
changeCat();
foo($cat->getName());