mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #2324 - avoid fatal error on self string in callable
This commit is contained in:
parent
fbd1cf0a71
commit
658f86c277
@ -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(
|
||||
|
@ -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;
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user