@@ -101,54 +101,60 @@ private static function describeCallLike(
101101 }
102102
103103 if ($ node instanceof Node \Expr \MethodCall) {
104- /** @var Node\Identifier $methodName */
105104 $ methodName = $ node ->name ;
106105
107- $ objectType = $ scope ->getType ($ node ->var );
106+ if ($ methodName instanceof Node \Identifier) {
107+ $ objectType = $ scope ->getType ($ node ->var );
108108
109- $ methodReflection = $ scope ->getMethodReflection (
110- $ objectType ,
111- $ methodName ->name ,
112- );
109+ $ methodReflection = $ scope ->getMethodReflection (
110+ $ objectType ,
111+ $ methodName ->name ,
112+ );
113113
114- if (null === $ methodReflection ) {
115- throw new ShouldNotHappenException ();
116- }
114+ if (null === $ methodReflection ) {
115+ throw new ShouldNotHappenException ();
116+ }
117117
118- $ declaringClass = $ methodReflection ->getDeclaringClass ();
118+ $ declaringClass = $ methodReflection ->getDeclaringClass ();
119+
120+ if ($ declaringClass ->isAnonymous ()) {
121+ return \sprintf (
122+ 'Method %s() of anonymous class ' ,
123+ $ methodName ->toString (),
124+ );
125+ }
119126
120- if ($ declaringClass ->isAnonymous ()) {
121127 return \sprintf (
122- 'Method %s() of anonymous class ' ,
123- $ methodName ,
128+ 'Method %s::%s() ' ,
129+ $ declaringClass ->getName (),
130+ $ methodName ->toString (),
124131 );
125132 }
126133
127- return \sprintf (
128- 'Method %s::%s() ' ,
129- $ declaringClass ->getName (),
130- $ methodName ,
131- );
134+ return 'Method ' ;
132135 }
133136
134137 if ($ node instanceof Node \Expr \StaticCall) {
135- $ className = $ node ->class ;
136-
137- /** @var Node\Identifier $methodName */
138138 $ methodName = $ node ->name ;
139139
140- if ($ className instanceof Node \Expr \Variable) {
140+ if ($ methodName instanceof Node \Identifier) {
141+ $ className = $ node ->class ;
142+
143+ if ($ className instanceof Node \Name) {
144+ return \sprintf (
145+ 'Method %s::%s() ' ,
146+ $ className ->toString (),
147+ $ methodName ->toString (),
148+ );
149+ }
150+
141151 return \sprintf (
142152 'Method %s() ' ,
143- $ methodName ,
153+ $ methodName-> toString () ,
144154 );
145155 }
146156
147- return \sprintf (
148- 'Method %s::%s() ' ,
149- $ className ,
150- $ methodName ,
151- );
157+ return 'Method ' ;
152158 }
153159
154160 if ($ node instanceof Node \Expr \New_) {
0 commit comments