mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #4615 - ensure promoted properties are not treated as uninitialized
This commit is contained in:
parent
2fff4eb5c1
commit
dc9a2a48e9
@ -1033,6 +1033,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
$property_type = clone $property_storage->type;
|
$property_type = clone $property_storage->type;
|
||||||
|
|
||||||
if (!$property_type->isMixed()
|
if (!$property_type->isMixed()
|
||||||
|
&& !$property_storage->is_promoted
|
||||||
&& !$property_storage->has_default
|
&& !$property_storage->has_default
|
||||||
&& !($property_type->isNullable() && $property_type->from_docblock)
|
&& !($property_type->isNullable() && $property_type->from_docblock)
|
||||||
) {
|
) {
|
||||||
@ -1041,7 +1042,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
} else {
|
} else {
|
||||||
$property_type = Type::getMixed();
|
$property_type = Type::getMixed();
|
||||||
|
|
||||||
if (!$property_storage->has_default) {
|
if (!$property_storage->has_default && !$property_storage->is_promoted) {
|
||||||
$property_type->initialized = false;
|
$property_type->initialized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -728,6 +728,7 @@ class FunctionLikeNodeScanner
|
|||||||
$property_storage->stmt_location = new CodeLocation($this->file_scanner, $param);
|
$property_storage->stmt_location = new CodeLocation($this->file_scanner, $param);
|
||||||
$property_storage->has_default = $param->default ? true : false;
|
$property_storage->has_default = $param->default ? true : false;
|
||||||
$param_storage->promoted_property = true;
|
$param_storage->promoted_property = true;
|
||||||
|
$property_storage->is_promoted = true;
|
||||||
|
|
||||||
$property_id = $fq_classlike_name . '::$' . $param_storage->name;
|
$property_id = $fq_classlike_name . '::$' . $param_storage->name;
|
||||||
|
|
||||||
|
@ -86,6 +86,11 @@ class PropertyStorage
|
|||||||
*/
|
*/
|
||||||
public $getter_method = null;
|
public $getter_method = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $is_promoted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var list<AttributeStorage>
|
* @var list<AttributeStorage>
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user