File tree 2 files changed +54
-0
lines changed
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,40 @@ public function specifyTypesInCondition(
277
277
$ context
278
278
);
279
279
}
280
+
281
+ if (
282
+ $ expr ->left instanceof FuncCall
283
+ && $ expr ->left ->name instanceof Name
284
+ && strtolower ($ expr ->left ->name ->toString ()) === 'get_class '
285
+ && isset ($ expr ->left ->args [0 ])
286
+ && $ rightType instanceof ConstantStringType
287
+ ) {
288
+ return $ this ->specifyTypesInCondition (
289
+ $ scope ,
290
+ new Instanceof_ (
291
+ $ expr ->left ->args [0 ]->value ,
292
+ new Name ($ rightType ->getValue ())
293
+ ),
294
+ $ context
295
+ );
296
+ }
297
+
298
+ if (
299
+ $ expr ->right instanceof FuncCall
300
+ && $ expr ->right ->name instanceof Name
301
+ && strtolower ($ expr ->right ->name ->toString ()) === 'get_class '
302
+ && isset ($ expr ->right ->args [0 ])
303
+ && $ leftType instanceof ConstantStringType
304
+ ) {
305
+ return $ this ->specifyTypesInCondition (
306
+ $ scope ,
307
+ new Instanceof_ (
308
+ $ expr ->right ->args [0 ]->value ,
309
+ new Name ($ leftType ->getValue ())
310
+ ),
311
+ $ context
312
+ );
313
+ }
280
314
} elseif ($ expr instanceof Node \Expr \BinaryOp \NotEqual) {
281
315
return $ this ->specifyTypesInCondition (
282
316
$ scope ,
Original file line number Diff line number Diff line change @@ -162,6 +162,26 @@ public function dataCondition(): array
162
162
['$foo ' => 'object ' ],
163
163
[],
164
164
],
165
+ [
166
+ new Equal (
167
+ new FuncCall (new Name ('get_class ' ), [
168
+ new Arg (new Variable ('foo ' )),
169
+ ]),
170
+ new String_ ('Foo ' )
171
+ ),
172
+ ['$foo ' => 'Foo ' ],
173
+ ['$foo ' => '~Foo ' ],
174
+ ],
175
+ [
176
+ new Equal (
177
+ new String_ ('Foo ' ),
178
+ new FuncCall (new Name ('get_class ' ), [
179
+ new Arg (new Variable ('foo ' )),
180
+ ])
181
+ ),
182
+ ['$foo ' => 'Foo ' ],
183
+ ['$foo ' => '~Foo ' ],
184
+ ],
165
185
[
166
186
new BooleanNot (
167
187
new Expr \Instanceof_ (
You can’t perform that action at this time.
0 commit comments