1616use PHPStan \Node \Property \PropertyWrite ;
1717use PHPStan \Reflection \MethodReflection ;
1818use PHPStan \Rules \Properties \ReadWritePropertiesExtension ;
19+ use PHPStan \Rules \Properties \ReadWritePropertiesExtensionProvider ;
1920use PHPStan \ShouldNotHappenException ;
2021use PHPStan \Type \MixedType ;
2122use PHPStan \Type \ObjectType ;
@@ -33,7 +34,13 @@ class ClassPropertiesNode extends NodeAbstract implements VirtualNode
3334 * @param array<int, PropertyRead|PropertyWrite> $propertyUsages
3435 * @param array<int, MethodCall> $methodCalls
3536 */
36- public function __construct (private ClassLike $ class , private array $ properties , private array $ propertyUsages , private array $ methodCalls )
37+ public function __construct (
38+ private ClassLike $ class ,
39+ private ReadWritePropertiesExtensionProvider $ readWritePropertiesExtensionProvider ,
40+ private array $ properties ,
41+ private array $ propertyUsages ,
42+ private array $ methodCalls ,
43+ )
3744 {
3845 parent ::__construct ($ class ->getAttributes ());
3946 }
@@ -74,13 +81,13 @@ public function getSubNodeNames(): array
7481
7582 /**
7683 * @param string[] $constructors
77- * @param ReadWritePropertiesExtension[] $extensions
84+ * @param ReadWritePropertiesExtension[]|null $extensions
7885 * @return array{array<string, ClassPropertyNode>, array<array{string, int, ClassPropertyNode}>, array<array{string, int, ClassPropertyNode}>}
7986 */
8087 public function getUninitializedProperties (
8188 Scope $ scope ,
8289 array $ constructors ,
83- array $ extensions ,
90+ ? array $ extensions = null ,
8491 ): array
8592 {
8693 if (!$ this ->getClass () instanceof Class_) {
@@ -105,6 +112,10 @@ public function getUninitializedProperties(
105112 $ properties [$ property ->getName ()] = $ property ;
106113 }
107114
115+ if ($ extensions === null ) {
116+ $ extensions = $ this ->readWritePropertiesExtensionProvider ->getExtensions ();
117+ }
118+
108119 foreach (array_keys ($ properties ) as $ name ) {
109120 foreach ($ extensions as $ extension ) {
110121 if (!$ classReflection ->hasNativeProperty ($ name )) {
0 commit comments