|
17 | 17 | use PhpParser\Node\Scalar\String_; |
18 | 18 | use PhpParser\Node\VarLikeIdentifier; |
19 | 19 | use PHPStan\Type\ArrayType; |
| 20 | +use PHPStan\Type\ClassStringType; |
20 | 21 | use PHPStan\Type\Constant\ConstantBooleanType; |
| 22 | +use PHPStan\Type\Generic\GenericClassStringType; |
21 | 23 | use PHPStan\Type\MixedType; |
22 | 24 | use PHPStan\Type\NullType; |
23 | 25 | use PHPStan\Type\ObjectType; |
@@ -57,6 +59,8 @@ protected function setUp(): void |
57 | 59 | $this->scope = $this->scope->assignVariable('stringOrFalse', new UnionType([new StringType(), new ConstantBooleanType(false)])); |
58 | 60 | $this->scope = $this->scope->assignVariable('array', new ArrayType(new MixedType(), new MixedType())); |
59 | 61 | $this->scope = $this->scope->assignVariable('foo', new MixedType()); |
| 62 | + $this->scope = $this->scope->assignVariable('classString', new ClassStringType()); |
| 63 | + $this->scope = $this->scope->assignVariable('genericClassString', new GenericClassStringType(new ObjectType('Bar'))); |
60 | 64 | } |
61 | 65 |
|
62 | 66 | /** |
@@ -437,6 +441,22 @@ public function dataCondition(): array |
437 | 441 | ['$foo' => 'static(DateTime)'], |
438 | 442 | ['$foo' => '~static(DateTime)'], |
439 | 443 | ], |
| 444 | + [ |
| 445 | + new FuncCall(new Name('is_a'), [ |
| 446 | + new Arg(new Variable('foo')), |
| 447 | + new Arg(new Variable('classString')), |
| 448 | + ]), |
| 449 | + ['$foo' => 'object'], |
| 450 | + [], |
| 451 | + ], |
| 452 | + [ |
| 453 | + new FuncCall(new Name('is_a'), [ |
| 454 | + new Arg(new Variable('foo')), |
| 455 | + new Arg(new Variable('genericClassString')), |
| 456 | + ]), |
| 457 | + ['$foo' => 'Bar'], |
| 458 | + ['$foo' => '~Bar'], |
| 459 | + ], |
440 | 460 | [ |
441 | 461 | new FuncCall(new Name('is_a'), [ |
442 | 462 | new Arg(new Variable('foo')), |
|
0 commit comments