|
18 | 18 | use PHPStan\Analyser\SpecifiedTypes;
|
19 | 19 | use PHPStan\Analyser\TypeSpecifier;
|
20 | 20 | use PHPStan\Analyser\TypeSpecifierContext;
|
21 |
| -use PHPStan\Type\Constant\ConstantStringType; |
22 | 21 | use ReflectionObject;
|
23 | 22 | use function array_key_exists;
|
24 | 23 | use function count;
|
@@ -125,14 +124,15 @@ private static function getExpressionResolvers(): array
|
125 | 124 | if (self::$resolvers === null) {
|
126 | 125 | self::$resolvers = [
|
127 | 126 | 'InstanceOf' => static function (Scope $scope, Arg $class, Arg $object): ?Instanceof_ {
|
128 |
| - $classType = $scope->getType($class->value); |
129 |
| - if (!$classType instanceof ConstantStringType) { |
| 127 | + $classType = $scope->getType($class->value)->getClassStringObjectType(); |
| 128 | + $classNames = $classType->getObjectClassNames(); |
| 129 | + if (count($classNames) !== 1) { |
130 | 130 | return null;
|
131 | 131 | }
|
132 | 132 |
|
133 | 133 | return new Instanceof_(
|
134 | 134 | $object->value,
|
135 |
| - new Name($classType->getValue()) |
| 135 | + new Name($classNames[0]) |
136 | 136 | );
|
137 | 137 | },
|
138 | 138 | 'Same' => static function (Scope $scope, Arg $expected, Arg $actual): Identical {
|
@@ -205,12 +205,12 @@ private static function getExpressionResolvers(): array
|
205 | 205 | return new FuncCall(new Name('is_scalar'), [$actual]);
|
206 | 206 | },
|
207 | 207 | 'InternalType' => static function (Scope $scope, Arg $type, Arg $value): ?FuncCall {
|
208 |
| - $typeType = $scope->getType($type->value); |
209 |
| - if (!$typeType instanceof ConstantStringType) { |
| 208 | + $typeNames = $scope->getType($type->value)->getConstantStrings(); |
| 209 | + if (count($typeNames) !== 1) { |
210 | 210 | return null;
|
211 | 211 | }
|
212 | 212 |
|
213 |
| - switch ($typeType->getValue()) { |
| 213 | + switch ($typeNames[0]->getValue()) { |
214 | 214 | case 'numeric':
|
215 | 215 | $functionName = 'is_numeric';
|
216 | 216 | break;
|
|
0 commit comments