mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix incorrect issue type emitted for static properties
This commit is contained in:
parent
69479f9f6e
commit
f47012823e
@ -721,18 +721,34 @@ class PropertyAssignmentChecker
|
||||
$assignment_value_type,
|
||||
$class_property_type
|
||||
)) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidPropertyAssignment(
|
||||
$var_id . ' with declared type \'' . $class_property_type . '\' cannot be assigned type \'' .
|
||||
$assignment_value_type . '\'',
|
||||
new CodeLocation(
|
||||
$statements_checker->getSource(),
|
||||
$assignment_value ?: $stmt
|
||||
)
|
||||
),
|
||||
$statements_checker->getSuppressedIssues()
|
||||
)) {
|
||||
return false;
|
||||
if (TypeChecker::canBeIdenticalTo($codebase, $assignment_value_type, $class_property_type)) {
|
||||
if (IssueBuffer::accepts(
|
||||
new PossiblyInvalidPropertyAssignmentValue(
|
||||
$var_id . ' with declared type \'' . $class_property_type . '\' cannot be assigned type \'' .
|
||||
$assignment_value_type . '\'',
|
||||
new CodeLocation(
|
||||
$statements_checker->getSource(),
|
||||
$assignment_value ?: $stmt
|
||||
)
|
||||
),
|
||||
$statements_checker->getSuppressedIssues()
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidPropertyAssignmentValue(
|
||||
$var_id . ' with declared type \'' . $class_property_type . '\' cannot be assigned type \'' .
|
||||
$assignment_value_type . '\'',
|
||||
new CodeLocation(
|
||||
$statements_checker->getSource(),
|
||||
$assignment_value ?: $stmt
|
||||
)
|
||||
),
|
||||
$statements_checker->getSuppressedIssues()
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class FileReferenceProvider
|
||||
|
||||
/**
|
||||
* @param array<string, array<string,bool>> $references
|
||||
* @psalm-suppress InvalidPropertyAssignment
|
||||
* @psalm-suppress PossiblyInvalidPropertyAssignmentValue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -200,7 +200,7 @@ class FileReferenceProvider
|
||||
/**
|
||||
* @return bool
|
||||
* @psalm-suppress MixedAssignment
|
||||
* @psalm-suppress InvalidPropertyAssignment
|
||||
* @psalm-suppress PossiblyInvalidPropertyAssignmentValue
|
||||
*/
|
||||
public static function loadReferenceCache()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user