| 1: | <?php declare(strict_types = 1); |
| 2: | |
| 3: | namespace PHPStan\PhpDocParser\Ast\Type; |
| 4: | |
| 5: | use PHPStan\PhpDocParser\Ast\NodeAttributes; |
| 6: | use PHPStan\PhpDocParser\Parser\ParserException; |
| 7: | |
| 8: | class InvalidTypeNode implements TypeNode |
| 9: | { |
| 10: | |
| 11: | use NodeAttributes; |
| 12: | |
| 13: | |
| 14: | private array $exceptionArgs; |
| 15: | |
| 16: | public function __construct(ParserException $exception) |
| 17: | { |
| 18: | $this->exceptionArgs = [ |
| 19: | $exception->getCurrentTokenValue(), |
| 20: | $exception->getCurrentTokenType(), |
| 21: | $exception->getCurrentOffset(), |
| 22: | $exception->getExpectedTokenType(), |
| 23: | $exception->getExpectedTokenValue(), |
| 24: | $exception->getCurrentTokenLine(), |
| 25: | ]; |
| 26: | } |
| 27: | |
| 28: | public function getException(): ParserException |
| 29: | { |
| 30: | return new ParserException(...$this->exceptionArgs); |
| 31: | } |
| 32: | |
| 33: | public function __toString(): string |
| 34: | { |
| 35: | return '*Invalid type*'; |
| 36: | } |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | public static function __set_state(array $properties): self |
| 42: | { |
| 43: | $exception = new ParserException(...$properties['exceptionArgs']); |
| 44: | $instance = new self($exception); |
| 45: | if (isset($properties['attributes'])) { |
| 46: | foreach ($properties['attributes'] as $key => $value) { |
| 47: | $instance->setAttribute($key, $value); |
| 48: | } |
| 49: | } |
| 50: | return $instance; |
| 51: | } |
| 52: | |
| 53: | } |
| 54: | |