77use Entity \FQN ;
88use Entity \Completion \Scope ;
99use Parser \UseParser ;
10+ use PhpParser \Node \Name ;
1011use PhpParser \Node \Expr \Variable ;
1112use PhpParser \Node \Expr \PropertyFetch ;
13+ use PhpParser \Node \Expr \StaticPropertyFetch ;
14+ use PhpParser \Node \Expr \StaticCall ;
1215use PhpParser \Node \Expr \MethodCall ;
1316use PhpParser \Node \Expr \New_ ;
1417use Psr \Log \LoggerInterface ;
@@ -34,7 +37,9 @@ public function __construct(
3437 public function getType ($ node , Index $ index , Scope $ scope ){
3538 if ($ node instanceof Variable
3639 || $ node instanceof PropertyFetch
40+ || $ node instanceof StaticPropertyFetch
3741 || $ node instanceof MethodCall
42+ || $ node instanceof StaticCall
3843 ){
3944 return $ this ->getChainType ($ node , $ index , $ scope );
4045 }
@@ -43,9 +48,6 @@ public function getType($node, Index $index, Scope $scope){
4348 }
4449 return null ;
4550 }
46- public function getNewType ($ node , Index $ index , Scope $ scope ){
47-
48- }
4951
5052 /**
5153 * Calculates type of the passed chained node
@@ -75,19 +77,28 @@ public function getChainType($node, Index $index, Scope $scope){
7577 }
7678 $ type = $ this ->getPropertyType ($ block ['name ' ], $ type , $ index );
7779 }
80+ elseif ($ block ['type ' ] === 'class ' ){
81+ $ type = $ block ['name ' ];
82+ }
7883 }
7984 return $ type ;
8085 }
8186 protected function createChain ($ node ){
8287 $ chain = [];
8388 while (!($ node instanceof Variable)){
84- if ($ node instanceof PropertyFetch){
89+ if (
90+ $ node instanceof PropertyFetch
91+ || $ node instanceof StaticPropertyFetch
92+ ){
8593 $ chain [] = [
8694 'type ' => 'property ' ,
8795 'name ' => $ node ->name
8896 ];
8997 }
90- elseif ($ node instanceof MethodCall){
98+ elseif (
99+ $ node instanceof MethodCall
100+ || $ node instanceof StaticCall
101+ ){
91102 $ chain [] = [
92103 'type ' => 'method ' ,
93104 'name ' => $ node ->name
@@ -98,12 +109,21 @@ protected function createChain($node){
98109 }
99110 $ node = $ node ->var ;
100111 }
112+ if (property_exists ($ node , 'class ' )){
113+ $ node = $ node ->class ;
114+ }
101115 if ($ node instanceof Variable){
102116 $ chain [] = [
103117 'type ' => 'var ' ,
104118 'name ' => $ node ->name
105119 ];
106120 }
121+ elseif ($ node instanceof Name){
122+ $ chain [] = [
123+ 'type ' => 'class ' ,
124+ 'name ' => $ this ->useParser ->getFQCN ($ node )
125+ ];
126+ }
107127 return array_reverse ($ chain );
108128 }
109129 protected function getVarType ($ name , Scope $ scope ){
0 commit comments