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

Merge pull request #10615 from weirdan/10589-fix-missing-MissingConstructor-with-native-mixed-property

This commit is contained in:
Bruce Weirdan 2024-01-30 12:47:59 -04:00 committed by GitHub
commit baa866029e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -1127,8 +1127,11 @@ final class ClassAnalyzer extends ClassLikeAnalyzer
$uninitialized_variables[] = '$this->' . $property_name;
$uninitialized_properties[$property_class_name . '::$' . $property_name] = $property;
if ($property->type && !$property->type->isMixed()) {
$uninitialized_typed_properties[$property_class_name . '::$' . $property_name] = $property;
if ($property->type) {
// Complain about all natively typed properties and all non-mixed docblock typed properties
if (!$property->type->from_docblock || !$property->type->isMixed()) {
$uninitialized_typed_properties[$property_class_name . '::$' . $property_name] = $property;
}
}
}

View File

@ -3827,6 +3827,15 @@ class PropertyTypeTest extends TestCase
',
'error_message' => 'UndefinedPropertyAssignment',
],
'nativeMixedPropertyWithNoConstructor' => [
'code' => <<< 'PHP'
<?php
class A {
public mixed $foo;
}
PHP,
'error_message' => 'MissingConstructor',
],
];
}
}