Token.php
47 lines
| 1 | <?php |
| 2 | declare (strict_types=1); |
| 3 | namespace MailPoetVendor\Doctrine\Common\Lexer; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use ArrayAccess; |
| 6 | use MailPoetVendor\Doctrine\Deprecations\Deprecation; |
| 7 | use ReturnTypeWillChange; |
| 8 | use UnitEnum; |
| 9 | use function in_array; |
| 10 | final class Token implements ArrayAccess |
| 11 | { |
| 12 | public $value; |
| 13 | public $type; |
| 14 | public $position; |
| 15 | public function __construct($value, $type, int $position) |
| 16 | { |
| 17 | $this->value = $value; |
| 18 | $this->type = $type; |
| 19 | $this->position = $position; |
| 20 | } |
| 21 | public function isA(...$types) : bool |
| 22 | { |
| 23 | return in_array($this->type, $types, \true); |
| 24 | } |
| 25 | public function offsetExists($offset) : bool |
| 26 | { |
| 27 | Deprecation::trigger('doctrine/lexer', 'https://github.com/doctrine/lexer/pull/79', 'Accessing %s properties via ArrayAccess is deprecated, use the value, type or position property instead', self::class); |
| 28 | return in_array($offset, ['value', 'type', 'position'], \true); |
| 29 | } |
| 30 | #[\ReturnTypeWillChange] |
| 31 | public function offsetGet($offset) |
| 32 | { |
| 33 | Deprecation::trigger('doctrine/lexer', 'https://github.com/doctrine/lexer/pull/79', 'Accessing %s properties via ArrayAccess is deprecated, use the value, type or position property instead', self::class); |
| 34 | return $this->{$offset}; |
| 35 | } |
| 36 | public function offsetSet($offset, $value) : void |
| 37 | { |
| 38 | Deprecation::trigger('doctrine/lexer', 'https://github.com/doctrine/lexer/pull/79', 'Setting %s properties via ArrayAccess is deprecated', self::class); |
| 39 | $this->{$offset} = $value; |
| 40 | } |
| 41 | public function offsetUnset($offset) : void |
| 42 | { |
| 43 | Deprecation::trigger('doctrine/lexer', 'https://github.com/doctrine/lexer/pull/79', 'Setting %s properties via ArrayAccess is deprecated', self::class); |
| 44 | $this->{$offset} = null; |
| 45 | } |
| 46 | } |
| 47 |