mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
parent
97f4cdb7f5
commit
8b9de8bba6
@ -2296,7 +2296,18 @@ class AssertionFinder
|
||||
if ($stmt->name instanceof PhpParser\Node\Name
|
||||
&& strtolower($stmt->name->parts[0]) === 'class_exists'
|
||||
) {
|
||||
return true;
|
||||
if (!isset($stmt->args[2])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$second_arg = $stmt->args[2]->value;
|
||||
|
||||
if ($second_arg instanceof PhpParser\Node\Expr\ConstFetch
|
||||
&& $second_arg->name instanceof PhpParser\Node\Name
|
||||
&& strtolower($second_arg->name->parts[0]) === 'true'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -391,6 +391,20 @@ class ClassTest extends TestCase
|
||||
if (class_exists($s) || interface_exists($s)) {}
|
||||
}'
|
||||
],
|
||||
'classExistsWithFalseArg' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param class-string $class
|
||||
* @return ?class-string
|
||||
*/
|
||||
function autoload(string $class) : string {
|
||||
if (class_exists($class, false)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return $class;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user