@@ -90,7 +90,7 @@ public function getChainType($node, Index $index, Scope $scope)
9090 $ chain = $ this ->createChain ($ node );
9191 $ block = $ chain ;
9292 while ($ block instanceof Chain) {
93- $ this ->logger ->addDebug ('looking for type of ' . $ block ->getName ());
93+ $ this ->logger ->debug ('looking for type of ' . $ block ->getName ());
9494 $ event = new TypeResolveEvent ($ block , $ type );
9595 $ this ->dispatcher ->dispatch (self ::BLOCK_START , $ event );
9696 if ($ block ->getType () === 'var ' ) {
@@ -109,12 +109,18 @@ public function getChainType($node, Index $index, Scope $scope)
109109 $ type = $ this ->getPropertyType ($ block ->getName (), $ type , $ index );
110110 } elseif ($ block ->getType () === 'class ' ) {
111111 $ type = $ block ->getName ();
112- if ($ type ->getClassName () === 'self '
113- || $ type ->getClassName () === 'static '
114- ) {
115- $ type = $ scope ->getFQCN ();
116- } elseif ($ type ->getClassName () === 'parent ' ) {
117- $ type = $ this ->getParentType ($ scope ->getFQCN (), $ index );
112+ if ($ type instanceof FQCN ) {
113+ if ($ type instanceof FQCN && (
114+ $ type ->getClassName () === 'self '
115+ || $ type ->getClassName () === 'static '
116+ )
117+ ) {
118+ $ type = $ scope ->getFQCN ();
119+ } elseif ($ type ->getClassName () === 'parent '
120+ && $ scope ->getFQCN () instanceof FQCN
121+ ) {
122+ $ type = $ this ->getParentType ($ scope ->getFQCN (), $ index );
123+ }
118124 }
119125 }
120126 $ event = new TypeResolveEvent ($ block , $ type );
@@ -170,38 +176,41 @@ protected function getVarType($name, Scope $scope)
170176 }
171177 return $ var ->getType ();
172178 }
173- protected function getMethodType ($ name , FQCN $ type , Index $ index ){
179+ protected function getMethodType ($ name , FQCN $ type , Index $ index )
180+ {
174181 $ class = $ index ->findClassByFQCN ($ type );
175- if (empty ($ class )){
182+ if (empty ($ class )) {
176183 $ class = $ index ->findInterfaceByFQCN ($ type );
177184 }
178- if (empty ($ class )){
185+ if (empty ($ class )) {
179186 return null ;
180187 }
181188 $ method = $ class ->methods ->get ($ name );
182- if (empty ($ method )){
189+ if (empty ($ method )) {
183190 return null ;
184191 }
185192 return $ method ->getReturn ();
186193 }
187- protected function getPropertyType ($ name , FQCN $ type , Index $ index ){
194+ protected function getPropertyType ($ name , FQCN $ type , Index $ index )
195+ {
188196 $ class = $ index ->findClassByFQCN ($ type );
189- if (empty ($ class )){
197+ if (empty ($ class )) {
190198 return null ;
191199 }
192200 $ prop = $ class ->properties ->get ($ name );
193- if (empty ($ prop )){
201+ if (empty ($ prop )) {
194202 return null ;
195203 }
196204 return $ prop ->getType ();
197205 }
198- protected function getParentType (FQCN $ type , Index $ index ){
206+ protected function getParentType (FQCN $ type , Index $ index )
207+ {
199208 $ class = $ index ->findClassByFQCN ($ type );
200- if (empty ($ class )){
209+ if (empty ($ class )) {
201210 return null ;
202211 }
203212 $ parent = $ class ->getParent ();
204- if (empty ($ parent )){
213+ if (empty ($ parent )) {
205214 return null ;
206215 }
207216 return $ parent ->fqcn ;
0 commit comments