mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Allow compounding method_exists types with ||
This commit is contained in:
parent
17e7fe70c1
commit
73f245f91d
@ -848,7 +848,7 @@ class AssertionReconciler extends \Psalm\Type\Reconciler
|
||||
}
|
||||
}
|
||||
|
||||
if (!$object_types || !$did_remove_type) {
|
||||
if (!$object_types) {
|
||||
if ($key && $code_location) {
|
||||
self::triggerIssueForImpossible(
|
||||
$existing_var_type,
|
||||
|
@ -379,6 +379,15 @@ class MethodCallTest extends TestCase
|
||||
$object->bar();
|
||||
}'
|
||||
],
|
||||
'callManyMethodsAfterCheckingExistenceChained' => [
|
||||
'<?php
|
||||
function foo(object $object) : void {
|
||||
if (method_exists($object, "foo") && method_exists($object, "bar")) {
|
||||
$object->foo();
|
||||
$object->bar();
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -651,6 +660,19 @@ class MethodCallTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'UndefinedThisPropertyFetch',
|
||||
],
|
||||
'alreadyHasmethod' => [
|
||||
'<?php
|
||||
class A {
|
||||
public function foo() : void {}
|
||||
}
|
||||
|
||||
function foo(A $a) : void {
|
||||
if (method_exists($a, "foo")) {
|
||||
$object->foo();
|
||||
}
|
||||
}',
|
||||
'error_message' => 'RedundantCondition',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user