@@ -31,7 +31,7 @@ public function findPropertyReflectionsFromNode($propertyFetch, Scope $scope): a
3131 $ reflections = [];
3232 $ propertyHolderType = $ scope ->getType ($ propertyFetch ->var );
3333 foreach ($ names as $ name ) {
34- $ reflection = $ this ->findPropertyReflection (
34+ $ reflection = $ this ->findInstancePropertyReflection (
3535 $ propertyHolderType ,
3636 $ name ,
3737 $ propertyFetch ->name instanceof Expr ? $ scope ->filterByTruthyValue (new Expr \BinaryOp \Identical (
@@ -63,7 +63,7 @@ public function findPropertyReflectionsFromNode($propertyFetch, Scope $scope): a
6363
6464 $ reflections = [];
6565 foreach ($ names as $ name ) {
66- $ reflection = $ this ->findPropertyReflection (
66+ $ reflection = $ this ->findStaticPropertyReflection (
6767 $ propertyHolderType ,
6868 $ name ,
6969 $ propertyFetch ->name instanceof Expr ? $ scope ->filterByTruthyValue (new Expr \BinaryOp \Identical (
@@ -89,13 +89,13 @@ public function findPropertyReflectionFromNode($propertyFetch, Scope $scope): ?F
8989 if ($ propertyFetch instanceof Node \Expr \PropertyFetch) {
9090 $ propertyHolderType = $ scope ->getType ($ propertyFetch ->var );
9191 if ($ propertyFetch ->name instanceof Node \Identifier) {
92- return $ this ->findPropertyReflection ($ propertyHolderType , $ propertyFetch ->name ->name , $ scope );
92+ return $ this ->findInstancePropertyReflection ($ propertyHolderType , $ propertyFetch ->name ->name , $ scope );
9393 }
9494
9595 $ nameType = $ scope ->getType ($ propertyFetch ->name );
9696 $ nameTypeConstantStrings = $ nameType ->getConstantStrings ();
9797 if (count ($ nameTypeConstantStrings ) === 1 ) {
98- return $ this ->findPropertyReflection ($ propertyHolderType , $ nameTypeConstantStrings [0 ]->getValue (), $ scope );
98+ return $ this ->findInstancePropertyReflection ($ propertyHolderType , $ nameTypeConstantStrings [0 ]->getValue (), $ scope );
9999 }
100100
101101 return null ;
@@ -111,16 +111,33 @@ public function findPropertyReflectionFromNode($propertyFetch, Scope $scope): ?F
111111 $ propertyHolderType = $ scope ->getType ($ propertyFetch ->class );
112112 }
113113
114- return $ this ->findPropertyReflection ($ propertyHolderType , $ propertyFetch ->name ->name , $ scope );
114+ return $ this ->findStaticPropertyReflection ($ propertyHolderType , $ propertyFetch ->name ->name , $ scope );
115115 }
116116
117- private function findPropertyReflection (Type $ propertyHolderType , string $ propertyName , Scope $ scope ): ?FoundPropertyReflection
117+ private function findInstancePropertyReflection (Type $ propertyHolderType , string $ propertyName , Scope $ scope ): ?FoundPropertyReflection
118118 {
119- if (!$ propertyHolderType ->hasProperty ($ propertyName )->yes ()) {
119+ if (!$ propertyHolderType ->hasInstanceProperty ($ propertyName )->yes ()) {
120120 return null ;
121121 }
122122
123- $ originalProperty = $ propertyHolderType ->getProperty ($ propertyName , $ scope );
123+ $ originalProperty = $ propertyHolderType ->getInstanceProperty ($ propertyName , $ scope );
124+
125+ return new FoundPropertyReflection (
126+ $ originalProperty ,
127+ $ scope ,
128+ $ propertyName ,
129+ $ originalProperty ->getReadableType (),
130+ $ originalProperty ->getWritableType (),
131+ );
132+ }
133+
134+ private function findStaticPropertyReflection (Type $ propertyHolderType , string $ propertyName , Scope $ scope ): ?FoundPropertyReflection
135+ {
136+ if (!$ propertyHolderType ->hasStaticProperty ($ propertyName )->yes ()) {
137+ return null ;
138+ }
139+
140+ $ originalProperty = $ propertyHolderType ->getStaticProperty ($ propertyName , $ scope );
124141
125142 return new FoundPropertyReflection (
126143 $ originalProperty ,
0 commit comments