| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\Type; |
| 4: | |
| 5: | use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; |
| 6: | use PHPStan\PhpDocParser\Ast\Type\TypeNode; |
| 7: | use PHPStan\TrinaryLogic; |
| 8: | use PHPStan\Turbo\ShadowedByTurboExtension; |
| 9: | |
| 10: | |
| 11: | #[InstanceofDeprecated(insteadUse: 'Type::isClassStringType()')] |
| 12: | #[ShadowedByTurboExtension(implementation: __DIR__ . '/../../turbo-ext/src/ClassStringType.cpp')] |
| 13: | class ClassStringType extends StringType |
| 14: | { |
| 15: | |
| 16: | |
| 17: | public function __construct() |
| 18: | { |
| 19: | parent::__construct(); |
| 20: | } |
| 21: | |
| 22: | public function describe(VerbosityLevel $level): string |
| 23: | { |
| 24: | return 'class-string'; |
| 25: | } |
| 26: | |
| 27: | public function accepts(Type $type, bool $strictTypes): AcceptsResult |
| 28: | { |
| 29: | if ($type instanceof CompoundType) { |
| 30: | return $type->isAcceptedBy($this, $strictTypes); |
| 31: | } |
| 32: | |
| 33: | return new AcceptsResult($type->isClassString(), []); |
| 34: | } |
| 35: | |
| 36: | public function isSuperTypeOf(Type $type): IsSuperTypeOfResult |
| 37: | { |
| 38: | if ($type instanceof CompoundType) { |
| 39: | return $type->isSubTypeOf($this); |
| 40: | } |
| 41: | |
| 42: | return new IsSuperTypeOfResult($type->isClassString(), []); |
| 43: | } |
| 44: | |
| 45: | public function isString(): TrinaryLogic |
| 46: | { |
| 47: | return TrinaryLogic::createYes(); |
| 48: | } |
| 49: | |
| 50: | public function isNumericString(): TrinaryLogic |
| 51: | { |
| 52: | return TrinaryLogic::createNo(); |
| 53: | } |
| 54: | |
| 55: | public function isDecimalIntegerString(): TrinaryLogic |
| 56: | { |
| 57: | return TrinaryLogic::createNo(); |
| 58: | } |
| 59: | |
| 60: | public function isNonEmptyString(): TrinaryLogic |
| 61: | { |
| 62: | return TrinaryLogic::createYes(); |
| 63: | } |
| 64: | |
| 65: | public function isNonFalsyString(): TrinaryLogic |
| 66: | { |
| 67: | return TrinaryLogic::createYes(); |
| 68: | } |
| 69: | |
| 70: | public function isLiteralString(): TrinaryLogic |
| 71: | { |
| 72: | return TrinaryLogic::createMaybe(); |
| 73: | } |
| 74: | |
| 75: | public function isLowercaseString(): TrinaryLogic |
| 76: | { |
| 77: | return TrinaryLogic::createMaybe(); |
| 78: | } |
| 79: | |
| 80: | public function isUppercaseString(): TrinaryLogic |
| 81: | { |
| 82: | return TrinaryLogic::createMaybe(); |
| 83: | } |
| 84: | |
| 85: | public function isClassString(): TrinaryLogic |
| 86: | { |
| 87: | return TrinaryLogic::createYes(); |
| 88: | } |
| 89: | |
| 90: | public function getClassStringObjectType(): Type |
| 91: | { |
| 92: | return new ObjectWithoutClassType(); |
| 93: | } |
| 94: | |
| 95: | public function getObjectTypeOrClassStringObjectType(): Type |
| 96: | { |
| 97: | return new ObjectWithoutClassType(); |
| 98: | } |
| 99: | |
| 100: | public function toPhpDocNode(): TypeNode |
| 101: | { |
| 102: | return new IdentifierTypeNode('class-string'); |
| 103: | } |
| 104: | |
| 105: | } |
| 106: | |