| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <[email protected]> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace Symfony\Component\TypeInfo; |
| 13 |
|
| 14 |
/** |
| 15 |
* Identifier of a PHP native type. |
| 16 |
* |
| 17 |
* @author Mathias Arlaud <[email protected]> |
| 18 |
* @author Baptiste Leduc <[email protected]> |
| 19 |
*/ |
| 20 |
enum TypeIdentifier: string |
| 21 |
{ |
| 22 |
case ARRAY = 'array'; |
| 23 |
case BOOL = 'bool'; |
| 24 |
case CALLABLE = 'callable'; |
| 25 |
case FALSE = 'false'; |
| 26 |
case FLOAT = 'float'; |
| 27 |
case INT = 'int'; |
| 28 |
case ITERABLE = 'iterable'; |
| 29 |
case MIXED = 'mixed'; |
| 30 |
case NULL = 'null'; |
| 31 |
case OBJECT = 'object'; |
| 32 |
case RESOURCE = 'resource'; |
| 33 |
case STRING = 'string'; |
| 34 |
case TRUE = 'true'; |
| 35 |
case NEVER = 'never'; |
| 36 |
case VOID = 'void'; |
| 37 |
|
| 38 |
/** |
| 39 |
* @return list<string> |
| 40 |
*/ |
| 41 |
public static function values(): array |
| 42 |
{ |
| 43 |
return array_column(self::cases(), 'value'); |
| 44 |
} |
| 45 |
|
| 46 |
public function isStandalone(): bool |
| 47 |
{ |
| 48 |
return \in_array($this, [self::MIXED, self::NEVER, self::VOID], true); |
| 49 |
} |
| 50 |
|
| 51 |
public function isScalar(): bool |
| 52 |
{ |
| 53 |
return \in_array($this, [self::STRING, self::FLOAT, self::INT, self::BOOL, self::FALSE, self::TRUE], true); |
| 54 |
} |
| 55 |
|
| 56 |
public function isBool(): bool |
| 57 |
{ |
| 58 |
return \in_array($this, [self::BOOL, self::FALSE, self::TRUE], true); |
| 59 |
} |
| 60 |
} |