File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
src/Psalm/Internal/Analyzer Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1127,8 +1127,11 @@ private function checkPropertyInitialization(
11271127 $ uninitialized_variables [] = '$this-> ' . $ property_name ;
11281128 $ uninitialized_properties [$ property_class_name . '::$ ' . $ property_name ] = $ property ;
11291129
1130- if ($ property ->type && !$ property ->type ->isMixed ()) {
1131- $ uninitialized_typed_properties [$ property_class_name . '::$ ' . $ property_name ] = $ property ;
1130+ if ($ property ->type ) {
1131+ // Complain about all natively typed properties and all non-mixed docblock typed properties
1132+ if (!$ property ->type ->from_docblock || !$ property ->type ->isMixed ()) {
1133+ $ uninitialized_typed_properties [$ property_class_name . '::$ ' . $ property_name ] = $ property ;
1134+ }
11321135 }
11331136 }
11341137
Original file line number Diff line number Diff line change @@ -3827,6 +3827,15 @@ class A {
38273827 ' ,
38283828 'error_message ' => 'UndefinedPropertyAssignment ' ,
38293829 ],
3830+ 'nativeMixedPropertyWithNoConstructor ' => [
3831+ 'code ' => <<< 'PHP'
3832+ <?php
3833+ class A {
3834+ public mixed $foo;
3835+ }
3836+ PHP,
3837+ 'error_message ' => 'MissingConstructor ' ,
3838+ ],
38303839 ];
38313840 }
38323841}
You can’t perform that action at this time.
0 commit comments