-
-
Notifications
You must be signed in to change notification settings - Fork 932
Closed
Labels
Milestone
Description
Summary
Phpstan ignores method_exists == false and throws error on "call to undefined method".
Code snippet that reproduces the problem
if (method_exists(get_called_class(), 'prepareFields')) {
$data[$key] = static::prepareFields($data[$key]);
}
Expected output
No error is expected.
The class AddonSelections has no method prepareFields.
But following errors are thrown:
------ ---------------------------------------------------------------------------
Line Traits/StaticIndex.php (in context of class Boka10\Tours\AddonSelections)
------ ---------------------------------------------------------------------------
339 Call to function method_exists() with string and 'prepareFields' will
always evaluate to false.
340 Call to an undefined static method
Boka10\Tours\AddonSelections::prepareFields().
------ ---------------------------------------------------------------------------
339 is the first line in the sample above. The error is correct, the method does not exist, but the line should not be evaluated due to the method_exists before.
see also
#1482 - for the first error, might be related or a cascade