1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

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

This commit is contained in:
Brown 2019-11-11 14:59:05 -05:00
parent fbd1cf0a71
commit 658f86c277
2 changed files with 23 additions and 1 deletions

View File

@ -1740,7 +1740,6 @@ class TypeAnalyzer
return null;
}
$lhs = $input_type_part->properties[0];
$method_name = $rhs->getSingleStringLiteral()->value;
$class_name = null;
@ -1755,6 +1754,13 @@ class TypeAnalyzer
}
}
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(

View File

@ -957,6 +957,22 @@ class CallableTest extends TestCase
);
}'
],
'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;
}
}',
],
];
}