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