Skip to content
Permalink
Browse files

Fix #2324 - avoid fatal error on self string in callable

  • Loading branch information
muglug committed Nov 11, 2019
1 parent fbd1cf0 commit 658f86c277200ef9617539713e096a81c49f3885
Showing with 23 additions and 1 deletion.
  1. +7 −1 src/Psalm/Internal/Analyzer/TypeAnalyzer.php
  2. +16 −0 tests/CallableTest.php
@@ -1740,7 +1740,6 @@ public static function getCallableMethodIdFromObjectLike(
return null;
}
$lhs = $input_type_part->properties[0];
$method_name = $rhs->getSingleStringLiteral()->value;
$class_name = null;
@@ -1755,6 +1754,13 @@ public static function getCallableMethodIdFromObjectLike(
}
}
if ($class_name === 'self'
|| $class_name === 'static'
|| $class_name === 'parent'
) {
return null;
}
if (!$class_name) {
if ($codebase && ($calling_method_id || $file_name)) {
$codebase->analyzer->addMixedMemberName(
@@ -957,6 +957,22 @@ function($a) {
);
}'
],
'noExceptionOnSelfString' => [
'<?php
class Fish {
public static function example(array $vals): void {
usort($vals, ["self", "compare"]);
}
/**
* @param mixed $a
* @param mixed $b
*/
public static function compare($a, $b): int {
return -1;
}
}',
],
];
}

0 comments on commit 658f86c

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