Skip to content
Permalink
Browse files

Allow compounding method_exists types with ||

  • Loading branch information...
muglug committed Aug 20, 2019
1 parent 17e7fe7 commit 73f245f91dc4d58696dc1de0cf7883d1a9aa3e4f
Showing with 23 additions and 1 deletion.
  1. +1 −1 src/Psalm/Internal/Type/AssertionReconciler.php
  2. +22 −0 tests/MethodCallTest.php
@@ -848,7 +848,7 @@ private static function reconcileHasMethod(
}
}
if (!$object_types || !$did_remove_type) {
if (!$object_types) {
if ($key && $code_location) {
self::triggerIssueForImpossible(
$existing_var_type,
@@ -379,6 +379,15 @@ function foo(object $object) : void {
$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 @@ public function foo(object $a) : void {
}',
'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',
],
];
}
}

0 comments on commit 73f245f

Please sign in to comment.
You can’t perform that action at this time.