Skip to content
Permalink
Browse files

Fix #2027 - fix improperly retained callable check

  • Loading branch information...
muglug committed Aug 16, 2019
1 parent 8228a0f commit 236a7ffd15bba58c9be783f281802f7b7e589e03
Showing with 17 additions and 0 deletions.
  1. +6 −0 src/Psalm/Context.php
  2. +11 −0 tests/CallableTest.php
@@ -537,6 +537,12 @@ public static function filterClauses(
// if the clause contains any possibilities that would be altered
// by the new type
foreach ($clause->possibilities[$remove_var_id] as $type) {
// if we're negating a type, we generally don't need the clause anymore
if ($type[0] === '!' && $type !== '!falsy' && $type !== '!empty') {
$type_changed = true;
break;
}
// empty and !empty are not definitive for arrays and scalar types
if (($type === '!falsy' || $type === 'falsy') &&
($new_type->hasArray() || $new_type->hasPossiblyNumericType())
@@ -935,6 +935,17 @@ function f($p): array {
}
f("#b::a");'
],
'removeCallableAssertionAfterReassignment' => [
'<?php
function foo(string $key) : void {
$setter = "a" . $key;
if (is_callable($setter)) {
return;
}
$setter = "b" . $key;
if (is_callable($setter)) {}
}'
],
];
}

0 comments on commit 236a7ff

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