mirror of
https://github.com/danog/psalm.git
synced 2024-12-03 10:07:52 +01:00
Don’t complain about untyped properties missing constructors
This commit is contained in:
parent
b5614d03f8
commit
3ff2a64e16
@ -1036,6 +1036,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
|
|
||||||
$uninitialized_variables = [];
|
$uninitialized_variables = [];
|
||||||
$uninitialized_properties = [];
|
$uninitialized_properties = [];
|
||||||
|
$uninitialized_typed_properties = [];
|
||||||
|
|
||||||
foreach ($storage->appearing_property_ids as $property_name => $appearing_property_id) {
|
foreach ($storage->appearing_property_ids as $property_name => $appearing_property_id) {
|
||||||
$property_class_name = (string) $codebase->properties->getDeclaringClassForProperty(
|
$property_class_name = (string) $codebase->properties->getDeclaringClassForProperty(
|
||||||
@ -1083,6 +1084,10 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
|
|
||||||
$uninitialized_variables[] = '$this->' . $property_name;
|
$uninitialized_variables[] = '$this->' . $property_name;
|
||||||
$uninitialized_properties[$property_class_name . '::$' . $property_name] = $property;
|
$uninitialized_properties[$property_class_name . '::$' . $property_name] = $property;
|
||||||
|
|
||||||
|
if ($property->type && !$property->type->isMixed()) {
|
||||||
|
$uninitialized_typed_properties[$property_class_name . '::$' . $property_name] = $property;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$uninitialized_properties) {
|
if (!$uninitialized_properties) {
|
||||||
@ -1194,7 +1199,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
|
|
||||||
$constructor_analyzer->analyze($method_context, $global_context, true);
|
$constructor_analyzer->analyze($method_context, $global_context, true);
|
||||||
|
|
||||||
foreach ($uninitialized_properties as $property_id => $property_storage) {
|
foreach ($uninitialized_typed_properties as $property_id => $property_storage) {
|
||||||
list(,$property_name) = explode('::$', $property_id);
|
list(,$property_name) = explode('::$', $property_id);
|
||||||
|
|
||||||
if (!isset($method_context->vars_in_scope['$this->' . $property_name])) {
|
if (!isset($method_context->vars_in_scope['$this->' . $property_name])) {
|
||||||
@ -1256,8 +1261,8 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$storage->abstract) {
|
if (!$storage->abstract && $uninitialized_typed_properties) {
|
||||||
$first_uninitialized_property = array_shift($uninitialized_properties);
|
$first_uninitialized_property = array_shift($uninitialized_typed_properties);
|
||||||
|
|
||||||
if ($first_uninitialized_property->location) {
|
if ($first_uninitialized_property->location) {
|
||||||
if (IssueBuffer::accepts(
|
if (IssueBuffer::accepts(
|
||||||
|
Loading…
Reference in New Issue
Block a user