diff options
Diffstat (limited to 'vendor/phpstan/phpdoc-parser/src/Ast')
79 files changed, 4254 insertions, 0 deletions
diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/AbstractNodeVisitor.php b/vendor/phpstan/phpdoc-parser/src/Ast/AbstractNodeVisitor.php new file mode 100644 index 0000000..2b9c10e --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/AbstractNodeVisitor.php @@ -0,0 +1,34 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast; + +/** + * Inspired by https://github.com/nikic/PHP-Parser/tree/36a6dcd04e7b0285e8f0868f44bd4927802f7df1 + * + * Copyright (c) 2011, Nikita Popov + * All rights reserved. + */ +abstract class AbstractNodeVisitor implements NodeVisitor // phpcs:ignore SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix +{ + + public function beforeTraverse(array $nodes): ?array + { + return null; + } + + public function enterNode(Node $node) + { + return null; + } + + public function leaveNode(Node $node) + { + return null; + } + + public function afterTraverse(array $nodes): ?array + { + return null; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Attribute.php b/vendor/phpstan/phpdoc-parser/src/Ast/Attribute.php new file mode 100644 index 0000000..1f770de --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Attribute.php @@ -0,0 +1,18 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast; + +final class Attribute +{ + + public const START_LINE = 'startLine'; + public const END_LINE = 'endLine'; + + public const START_INDEX = 'startIndex'; + public const END_INDEX = 'endIndex'; + + public const ORIGINAL_NODE = 'originalNode'; + + public const COMMENTS = 'comments'; + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Comment.php b/vendor/phpstan/phpdoc-parser/src/Ast/Comment.php new file mode 100644 index 0000000..7147f39 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Comment.php @@ -0,0 +1,36 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast; + +use function trim; + +class Comment +{ + + public string $text; + + public int $startLine; + + public int $startIndex; + + public function __construct(string $text, int $startLine = -1, int $startIndex = -1) + { + $this->text = $text; + $this->startLine = $startLine; + $this->startIndex = $startIndex; + } + + public function getReformattedText(): string + { + return trim($this->text); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + return new self($properties['text'], $properties['startLine'], $properties['startIndex']); + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayItemNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayItemNode.php new file mode 100644 index 0000000..b8e7c0a --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayItemNode.php @@ -0,0 +1,47 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; + +class ConstExprArrayItemNode implements ConstExprNode +{ + + use NodeAttributes; + + public ?ConstExprNode $key = null; + + public ConstExprNode $value; + + public function __construct(?ConstExprNode $key, ConstExprNode $value) + { + $this->key = $key; + $this->value = $value; + } + + public function __toString(): string + { + if ($this->key !== null) { + return sprintf('%s => %s', $this->key, $this->value); + + } + + return (string) $this->value; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['key'], $properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php new file mode 100644 index 0000000..ae83c39 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php @@ -0,0 +1,43 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; + +class ConstExprArrayNode implements ConstExprNode +{ + + use NodeAttributes; + + /** @var ConstExprArrayItemNode[] */ + public array $items; + + /** + * @param ConstExprArrayItemNode[] $items + */ + public function __construct(array $items) + { + $this->items = $items; + } + + public function __toString(): string + { + return '[' . implode(', ', $this->items) . ']'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['items']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFalseNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFalseNode.php new file mode 100644 index 0000000..310ff10 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFalseNode.php @@ -0,0 +1,31 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ConstExprFalseNode implements ConstExprNode +{ + + use NodeAttributes; + + public function __toString(): string + { + return 'false'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self(); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFloatNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFloatNode.php new file mode 100644 index 0000000..badb1cf --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFloatNode.php @@ -0,0 +1,38 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ConstExprFloatNode implements ConstExprNode +{ + + use NodeAttributes; + + public string $value; + + public function __construct(string $value) + { + $this->value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprIntegerNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprIntegerNode.php new file mode 100644 index 0000000..5bed6ed --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprIntegerNode.php @@ -0,0 +1,38 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ConstExprIntegerNode implements ConstExprNode +{ + + use NodeAttributes; + + public string $value; + + public function __construct(string $value) + { + $this->value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php new file mode 100644 index 0000000..1859f03 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php @@ -0,0 +1,10 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\Node; + +interface ConstExprNode extends Node +{ + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNullNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNullNode.php new file mode 100644 index 0000000..b0f9165 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNullNode.php @@ -0,0 +1,31 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ConstExprNullNode implements ConstExprNode +{ + + use NodeAttributes; + + public function __toString(): string + { + return 'null'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self(); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprStringNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprStringNode.php new file mode 100644 index 0000000..5ac662a --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprStringNode.php @@ -0,0 +1,93 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function addcslashes; +use function assert; +use function dechex; +use function ord; +use function preg_replace_callback; +use function sprintf; +use function str_pad; +use function strlen; +use const STR_PAD_LEFT; + +class ConstExprStringNode implements ConstExprNode +{ + + public const SINGLE_QUOTED = 1; + public const DOUBLE_QUOTED = 2; + + use NodeAttributes; + + public string $value; + + /** @var self::SINGLE_QUOTED|self::DOUBLE_QUOTED */ + public $quoteType; + + /** + * @param self::SINGLE_QUOTED|self::DOUBLE_QUOTED $quoteType + */ + public function __construct(string $value, int $quoteType) + { + $this->value = $value; + $this->quoteType = $quoteType; + } + + public function __toString(): string + { + if ($this->quoteType === self::SINGLE_QUOTED) { + // from https://github.com/nikic/PHP-Parser/blob/0ffddce52d816f72d0efc4d9b02e276d3309ef01/lib/PhpParser/PrettyPrinter/Standard.php#L1007 + return sprintf("'%s'", addcslashes($this->value, '\'\\')); + } + + // from https://github.com/nikic/PHP-Parser/blob/0ffddce52d816f72d0efc4d9b02e276d3309ef01/lib/PhpParser/PrettyPrinter/Standard.php#L1010-L1040 + return sprintf('"%s"', $this->escapeDoubleQuotedString()); + } + + private function escapeDoubleQuotedString(): string + { + $quote = '"'; + $escaped = addcslashes($this->value, "\n\r\t\f\v$" . $quote . '\\'); + + // Escape control characters and non-UTF-8 characters. + // Regex based on https://stackoverflow.com/a/11709412/385378. + $regex = '/( + [\x00-\x08\x0E-\x1F] # Control characters + | [\xC0-\xC1] # Invalid UTF-8 Bytes + | [\xF5-\xFF] # Invalid UTF-8 Bytes + | \xE0(?=[\x80-\x9F]) # Overlong encoding of prior code point + | \xF0(?=[\x80-\x8F]) # Overlong encoding of prior code point + | [\xC2-\xDF](?![\x80-\xBF]) # Invalid UTF-8 Sequence Start + | [\xE0-\xEF](?![\x80-\xBF]{2}) # Invalid UTF-8 Sequence Start + | [\xF0-\xF4](?![\x80-\xBF]{3}) # Invalid UTF-8 Sequence Start + | (?<=[\x00-\x7F\xF5-\xFF])[\x80-\xBF] # Invalid UTF-8 Sequence Middle + | (?<![\xC2-\xDF]|[\xE0-\xEF]|[\xE0-\xEF][\x80-\xBF]|[\xF0-\xF4]|[\xF0-\xF4][\x80-\xBF]|[\xF0-\xF4][\x80-\xBF]{2})[\x80-\xBF] # Overlong Sequence + | (?<=[\xE0-\xEF])[\x80-\xBF](?![\x80-\xBF]) # Short 3 byte sequence + | (?<=[\xF0-\xF4])[\x80-\xBF](?![\x80-\xBF]{2}) # Short 4 byte sequence + | (?<=[\xF0-\xF4][\x80-\xBF])[\x80-\xBF](?![\x80-\xBF]) # Short 4 byte sequence (2) + )/x'; + return preg_replace_callback($regex, static function ($matches) { + assert(strlen($matches[0]) === 1); + $hex = dechex(ord($matches[0])); + + return '\\x' . str_pad($hex, 2, '0', STR_PAD_LEFT); + }, $escaped); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['value'], $properties['quoteType']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprTrueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprTrueNode.php new file mode 100644 index 0000000..a7e172b --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprTrueNode.php @@ -0,0 +1,31 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ConstExprTrueNode implements ConstExprNode +{ + + use NodeAttributes; + + public function __toString(): string + { + return 'true'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self(); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstFetchNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstFetchNode.php new file mode 100644 index 0000000..65ba489 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstFetchNode.php @@ -0,0 +1,47 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ConstFetchNode implements ConstExprNode +{ + + use NodeAttributes; + + /** @var string class name for class constants or empty string for non-class constants */ + public string $className; + + public string $name; + + public function __construct(string $className, string $name) + { + $this->className = $className; + $this->name = $name; + } + + public function __toString(): string + { + if ($this->className === '') { + return $this->name; + + } + + return "{$this->className}::{$this->name}"; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['className'], $properties['name']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/DoctrineConstExprStringNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/DoctrineConstExprStringNode.php new file mode 100644 index 0000000..5cfb071 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/DoctrineConstExprStringNode.php @@ -0,0 +1,55 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\ConstExpr; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; +use function str_replace; +use function strlen; +use function substr; + +class DoctrineConstExprStringNode extends ConstExprStringNode +{ + + use NodeAttributes; + + public string $value; + + public function __construct(string $value) + { + parent::__construct($value, self::DOUBLE_QUOTED); + $this->value = $value; + } + + public function __toString(): string + { + return self::escape($this->value); + } + + public static function unescape(string $value): string + { + // from https://github.com/doctrine/annotations/blob/a9ec7af212302a75d1f92fa65d3abfbd16245a2a/lib/Doctrine/Common/Annotations/DocLexer.php#L103-L107 + return str_replace('""', '"', substr($value, 1, strlen($value) - 2)); + } + + private static function escape(string $value): string + { + // from https://github.com/phpstan/phpdoc-parser/issues/205#issuecomment-1662323656 + return sprintf('"%s"', str_replace('"', '""', $value)); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Node.php b/vendor/phpstan/phpdoc-parser/src/Ast/Node.php new file mode 100644 index 0000000..51a1a19 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Node.php @@ -0,0 +1,22 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast; + +interface Node +{ + + public function __toString(): string; + + /** + * @param mixed $value + */ + public function setAttribute(string $key, $value): void; + + public function hasAttribute(string $key): bool; + + /** + * @return mixed + */ + public function getAttribute(string $key); + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php b/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php new file mode 100644 index 0000000..4f2ca76 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php @@ -0,0 +1,42 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast; + +use function array_key_exists; + +trait NodeAttributes +{ + + /** @var array<string, mixed> */ + private array $attributes = []; + + /** + * @param mixed $value + */ + public function setAttribute(string $key, $value): void + { + if ($value === null) { + unset($this->attributes[$key]); + return; + } + $this->attributes[$key] = $value; + } + + public function hasAttribute(string $key): bool + { + return array_key_exists($key, $this->attributes); + } + + /** + * @return mixed + */ + public function getAttribute(string $key) + { + if ($this->hasAttribute($key)) { + return $this->attributes[$key]; + } + + return null; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/NodeTraverser.php b/vendor/phpstan/phpdoc-parser/src/Ast/NodeTraverser.php new file mode 100644 index 0000000..76c88f0 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/NodeTraverser.php @@ -0,0 +1,312 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast; + +use LogicException; +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function array_keys; +use function array_pop; +use function array_splice; +use function count; +use function get_class; +use function get_object_vars; +use function gettype; +use function is_array; +use function sprintf; + +/** + * Inspired by https://github.com/nikic/PHP-Parser/tree/36a6dcd04e7b0285e8f0868f44bd4927802f7df1 + * + * Copyright (c) 2011, Nikita Popov + * All rights reserved. + */ +final class NodeTraverser +{ + + /** + * If NodeVisitor::enterNode() returns DONT_TRAVERSE_CHILDREN, child nodes + * of the current node will not be traversed for any visitors. + * + * For subsequent visitors enterNode() will still be called on the current + * node and leaveNode() will also be invoked for the current node. + */ + public const DONT_TRAVERSE_CHILDREN = 1; + + /** + * If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns + * STOP_TRAVERSAL, traversal is aborted. + * + * The afterTraverse() method will still be invoked. + */ + public const STOP_TRAVERSAL = 2; + + /** + * If NodeVisitor::leaveNode() returns REMOVE_NODE for a node that occurs + * in an array, it will be removed from the array. + * + * For subsequent visitors leaveNode() will still be invoked for the + * removed node. + */ + public const REMOVE_NODE = 3; + + /** + * If NodeVisitor::enterNode() returns DONT_TRAVERSE_CURRENT_AND_CHILDREN, child nodes + * of the current node will not be traversed for any visitors. + * + * For subsequent visitors enterNode() will not be called as well. + * leaveNode() will be invoked for visitors that has enterNode() method invoked. + */ + public const DONT_TRAVERSE_CURRENT_AND_CHILDREN = 4; + + /** @var list<NodeVisitor> Visitors */ + private array $visitors = []; + + /** @var bool Whether traversal should be stopped */ + private bool $stopTraversal; + + /** + * @param list<NodeVisitor> $visitors + */ + public function __construct(array $visitors) + { + $this->visitors = $visitors; + } + + /** + * Traverses an array of nodes using the registered visitors. + * + * @param Node[] $nodes Array of nodes + * + * @return Node[] Traversed array of nodes + */ + public function traverse(array $nodes): array + { + $this->stopTraversal = false; + + foreach ($this->visitors as $visitor) { + $return = $visitor->beforeTraverse($nodes); + if ($return === null) { + continue; + } + + $nodes = $return; + } + + $nodes = $this->traverseArray($nodes); + + foreach ($this->visitors as $visitor) { + $return = $visitor->afterTraverse($nodes); + if ($return === null) { + continue; + } + + $nodes = $return; + } + + return $nodes; + } + + /** + * Recursively traverse a node. + * + * @param Node $node Node to traverse. + * + * @return Node Result of traversal (may be original node or new one) + */ + private function traverseNode(Node $node): Node + { + $subNodeNames = array_keys(get_object_vars($node)); + foreach ($subNodeNames as $name) { + $subNode =& $node->$name; + + if (is_array($subNode)) { + $subNode = $this->traverseArray($subNode); + if ($this->stopTraversal) { + break; + } + } elseif ($subNode instanceof Node) { + $traverseChildren = true; + $breakVisitorIndex = null; + + foreach ($this->visitors as $visitorIndex => $visitor) { + $return = $visitor->enterNode($subNode); + if ($return === null) { + continue; + } + + if ($return instanceof Node) { + $this->ensureReplacementReasonable($subNode, $return); + $subNode = $return; + } elseif ($return === self::DONT_TRAVERSE_CHILDREN) { + $traverseChildren = false; + } elseif ($return === self::DONT_TRAVERSE_CURRENT_AND_CHILDREN) { + $traverseChildren = false; + $breakVisitorIndex = $visitorIndex; + break; + } elseif ($return === self::STOP_TRAVERSAL) { + $this->stopTraversal = true; + break 2; + } else { + throw new LogicException( + 'enterNode() returned invalid value of type ' . gettype($return), + ); + } + } + + if ($traverseChildren) { + $subNode = $this->traverseNode($subNode); + if ($this->stopTraversal) { + break; + } + } + + foreach ($this->visitors as $visitorIndex => $visitor) { + $return = $visitor->leaveNode($subNode); + + if ($return !== null) { + if ($return instanceof Node) { + $this->ensureReplacementReasonable($subNode, $return); + $subNode = $return; + } elseif ($return === self::STOP_TRAVERSAL) { + $this->stopTraversal = true; + break 2; + } elseif (is_array($return)) { + throw new LogicException( + 'leaveNode() may only return an array ' . + 'if the parent structure is an array', + ); + } else { + throw new LogicException( + 'leaveNode() returned invalid value of type ' . gettype($return), + ); + } + } + + if ($breakVisitorIndex === $visitorIndex) { + break; + } + } + } + } + + return $node; + } + + /** + * Recursively traverse array (usually of nodes). + * + * @param mixed[] $nodes Array to traverse + * + * @return mixed[] Result of traversal (may be original array or changed one) + */ + private function traverseArray(array $nodes): array + { + $doNodes = []; + + foreach ($nodes as $i => &$node) { + if ($node instanceof Node) { + $traverseChildren = true; + $breakVisitorIndex = null; + + foreach ($this->visitors as $visitorIndex => $visitor) { + $return = $visitor->enterNode($node); + if ($return === null) { + continue; + } + + if ($return instanceof Node) { + $this->ensureReplacementReasonable($node, $return); + $node = $return; + } elseif (is_array($return)) { + $doNodes[] = [$i, $return]; + continue 2; + } elseif ($return === self::REMOVE_NODE) { + $doNodes[] = [$i, []]; + continue 2; + } elseif ($return === self::DONT_TRAVERSE_CHILDREN) { + $traverseChildren = false; + } elseif ($return === self::DONT_TRAVERSE_CURRENT_AND_CHILDREN) { + $traverseChildren = false; + $breakVisitorIndex = $visitorIndex; + break; + } elseif ($return === self::STOP_TRAVERSAL) { + $this->stopTraversal = true; + break 2; + } else { + throw new LogicException( + 'enterNode() returned invalid value of type ' . gettype($return), + ); + } + } + + if ($traverseChildren) { + $node = $this->traverseNode($node); + if ($this->stopTraversal) { + break; + } + } + + foreach ($this->visitors as $visitorIndex => $visitor) { + $return = $visitor->leaveNode($node); + + if ($return !== null) { + if ($return instanceof Node) { + $this->ensureReplacementReasonable($node, $return); + $node = $return; + } elseif (is_array($return)) { + $doNodes[] = [$i, $return]; + break; + } elseif ($return === self::REMOVE_NODE) { + $doNodes[] = [$i, []]; + break; + } elseif ($return === self::STOP_TRAVERSAL) { + $this->stopTraversal = true; + break 2; + } else { + throw new LogicException( + 'leaveNode() returned invalid value of type ' . gettype($return), + ); + } + } + + if ($breakVisitorIndex === $visitorIndex) { + break; + } + } + } elseif (is_array($node)) { + throw new LogicException('Invalid node structure: Contains nested arrays'); + } + } + + if (count($doNodes) > 0) { + while ([$i, $replace] = array_pop($doNodes)) { + array_splice($nodes, $i, 1, $replace); + } + } + + return $nodes; + } + + private function ensureReplacementReasonable(Node $old, Node $new): void + { + if ($old instanceof TypeNode && !$new instanceof TypeNode) { + throw new LogicException(sprintf('Trying to replace TypeNode with %s', get_class($new))); + } + + if ($old instanceof ConstExprNode && !$new instanceof ConstExprNode) { + throw new LogicException(sprintf('Trying to replace ConstExprNode with %s', get_class($new))); + } + + if ($old instanceof PhpDocChildNode && !$new instanceof PhpDocChildNode) { + throw new LogicException(sprintf('Trying to replace PhpDocChildNode with %s', get_class($new))); + } + + if ($old instanceof PhpDocTagValueNode && !$new instanceof PhpDocTagValueNode) { + throw new LogicException(sprintf('Trying to replace PhpDocTagValueNode with %s', get_class($new))); + } + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/NodeVisitor.php b/vendor/phpstan/phpdoc-parser/src/Ast/NodeVisitor.php new file mode 100644 index 0000000..bf7d784 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/NodeVisitor.php @@ -0,0 +1,87 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast; + +/** + * Inspired by https://github.com/nikic/PHP-Parser/tree/36a6dcd04e7b0285e8f0868f44bd4927802f7df1 + * + * Copyright (c) 2011, Nikita Popov + * All rights reserved. + */ +interface NodeVisitor +{ + + /** + * Called once before traversal. + * + * Return value semantics: + * * null: $nodes stays as-is + * * otherwise: $nodes is set to the return value + * + * @param Node[] $nodes Array of nodes + * + * @return Node[]|null Array of nodes + */ + public function beforeTraverse(array $nodes): ?array; + + /** + * Called when entering a node. + * + * Return value semantics: + * * null + * => $node stays as-is + * * array (of Nodes) + * => The return value is merged into the parent array (at the position of the $node) + * * NodeTraverser::REMOVE_NODE + * => $node is removed from the parent array + * * NodeTraverser::DONT_TRAVERSE_CHILDREN + * => Children of $node are not traversed. $node stays as-is + * * NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN + * => Further visitors for the current node are skipped, and its children are not + * traversed. $node stays as-is. + * * NodeTraverser::STOP_TRAVERSAL + * => Traversal is aborted. $node stays as-is + * * otherwise + * => $node is set to the return value + * + * @param Node $node Node + * + * @return Node|Node[]|NodeTraverser::*|null Replacement node (or special return value) + */ + public function enterNode(Node $node); + + /** + * Called when leaving a node. + * + * Return value semantics: + * * null + * => $node stays as-is + * * NodeTraverser::REMOVE_NODE + * => $node is removed from the parent array + * * NodeTraverser::STOP_TRAVERSAL + * => Traversal is aborted. $node stays as-is + * * array (of Nodes) + * => The return value is merged into the parent array (at the position of the $node) + * * otherwise + * => $node is set to the return value + * + * @param Node $node Node + * + * @return Node|Node[]|NodeTraverser::REMOVE_NODE|NodeTraverser::STOP_TRAVERSAL|null Replacement node (or special return value) + */ + public function leaveNode(Node $node); + + /** + * Called once after traversal. + * + * Return value semantics: + * * null: $nodes stays as-is + * * otherwise: $nodes is set to the return value + * + * @param Node[] $nodes Array of nodes + * + * @return Node[]|null Array of nodes + */ + public function afterTraverse(array $nodes): ?array; + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/NodeVisitor/CloningVisitor.php b/vendor/phpstan/phpdoc-parser/src/Ast/NodeVisitor/CloningVisitor.php new file mode 100644 index 0000000..486e2aa --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/NodeVisitor/CloningVisitor.php @@ -0,0 +1,20 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\NodeVisitor; + +use PHPStan\PhpDocParser\Ast\AbstractNodeVisitor; +use PHPStan\PhpDocParser\Ast\Attribute; +use PHPStan\PhpDocParser\Ast\Node; + +final class CloningVisitor extends AbstractNodeVisitor +{ + + public function enterNode(Node $originalNode): Node + { + $node = clone $originalNode; + $node->setAttribute(Attribute::ORIGINAL_NODE, $originalNode); + + return $node; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagMethodValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagMethodValueNode.php new file mode 100644 index 0000000..d51327a --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagMethodValueNode.php @@ -0,0 +1,58 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class AssertTagMethodValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public string $parameter; + + public string $method; + + public bool $isNegated; + + public bool $isEquality; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $parameter, string $method, bool $isNegated, string $description, bool $isEquality) + { + $this->type = $type; + $this->parameter = $parameter; + $this->method = $method; + $this->isNegated = $isNegated; + $this->isEquality = $isEquality; + $this->description = $description; + } + + public function __toString(): string + { + $isNegated = $this->isNegated ? '!' : ''; + $isEquality = $this->isEquality ? '=' : ''; + return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter}->{$this->method}() {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['parameter'], $properties['method'], $properties['isNegated'], $properties['description'], $properties['isEquality']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagPropertyValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagPropertyValueNode.php new file mode 100644 index 0000000..56e23cf --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagPropertyValueNode.php @@ -0,0 +1,58 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class AssertTagPropertyValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public string $parameter; + + public string $property; + + public bool $isNegated; + + public bool $isEquality; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $parameter, string $property, bool $isNegated, string $description, bool $isEquality) + { + $this->type = $type; + $this->parameter = $parameter; + $this->property = $property; + $this->isNegated = $isNegated; + $this->isEquality = $isEquality; + $this->description = $description; + } + + public function __toString(): string + { + $isNegated = $this->isNegated ? '!' : ''; + $isEquality = $this->isEquality ? '=' : ''; + return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter}->{$this->property} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['parameter'], $properties['property'], $properties['isNegated'], $properties['description'], $properties['isEquality']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagValueNode.php new file mode 100644 index 0000000..34bbcb0 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/AssertTagValueNode.php @@ -0,0 +1,55 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class AssertTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public string $parameter; + + public bool $isNegated; + + public bool $isEquality; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $parameter, bool $isNegated, string $description, bool $isEquality) + { + $this->type = $type; + $this->parameter = $parameter; + $this->isNegated = $isNegated; + $this->isEquality = $isEquality; + $this->description = $description; + } + + public function __toString(): string + { + $isNegated = $this->isNegated ? '!' : ''; + $isEquality = $this->isEquality ? '=' : ''; + return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['parameter'], $properties['isNegated'], $properties['description'], $properties['isEquality']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/DeprecatedTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/DeprecatedTagValueNode.php new file mode 100644 index 0000000..3831a67 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/DeprecatedTagValueNode.php @@ -0,0 +1,40 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; + +class DeprecatedTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(string $description) + { + $this->description = $description; + } + + public function __toString(): string + { + return trim($this->description); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineAnnotation.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineAnnotation.php new file mode 100644 index 0000000..5ffdf31 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineAnnotation.php @@ -0,0 +1,48 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; + +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; + +class DoctrineAnnotation implements Node +{ + + use NodeAttributes; + + public string $name; + + /** @var list<DoctrineArgument> */ + public array $arguments; + + /** + * @param list<DoctrineArgument> $arguments + */ + public function __construct(string $name, array $arguments) + { + $this->name = $name; + $this->arguments = $arguments; + } + + public function __toString(): string + { + $arguments = implode(', ', $this->arguments); + return $this->name . '(' . $arguments . ')'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['name'], $properties['arguments']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArgument.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArgument.php new file mode 100644 index 0000000..8ff4626 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArgument.php @@ -0,0 +1,55 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; + +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; + +/** + * @phpstan-type ValueType = DoctrineAnnotation|IdentifierTypeNode|DoctrineArray|ConstExprNode + */ +class DoctrineArgument implements Node +{ + + use NodeAttributes; + + public ?IdentifierTypeNode $key = null; + + /** @var ValueType */ + public $value; + + /** + * @param ValueType $value + */ + public function __construct(?IdentifierTypeNode $key, $value) + { + $this->key = $key; + $this->value = $value; + } + + public function __toString(): string + { + if ($this->key === null) { + return (string) $this->value; + } + + return $this->key . '=' . $this->value; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['key'], $properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArray.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArray.php new file mode 100644 index 0000000..ee52a25 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArray.php @@ -0,0 +1,46 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; + +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; + +class DoctrineArray implements Node +{ + + use NodeAttributes; + + /** @var list<DoctrineArrayItem> */ + public array $items; + + /** + * @param list<DoctrineArrayItem> $items + */ + public function __construct(array $items) + { + $this->items = $items; + } + + public function __toString(): string + { + $items = implode(', ', $this->items); + + return '{' . $items . '}'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['items']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArrayItem.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArrayItem.php new file mode 100644 index 0000000..ff1bd37 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineArrayItem.php @@ -0,0 +1,60 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; + +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode; +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode; +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; + +/** + * @phpstan-import-type ValueType from DoctrineArgument + * @phpstan-type KeyType = ConstExprIntegerNode|ConstExprStringNode|IdentifierTypeNode|ConstFetchNode|null + */ +class DoctrineArrayItem implements Node +{ + + use NodeAttributes; + + /** @var KeyType */ + public $key; + + /** @var ValueType */ + public $value; + + /** + * @param KeyType $key + * @param ValueType $value + */ + public function __construct($key, $value) + { + $this->key = $key; + $this->value = $value; + } + + public function __toString(): string + { + if ($this->key === null) { + return (string) $this->value; + } + + return $this->key . '=' . $this->value; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['key'], $properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineTagValueNode.php new file mode 100644 index 0000000..29f3e0d --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/Doctrine/DoctrineTagValueNode.php @@ -0,0 +1,47 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode; +use function trim; + +class DoctrineTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public DoctrineAnnotation $annotation; + + /** @var string (may be empty) */ + public string $description; + + public function __construct( + DoctrineAnnotation $annotation, + string $description + ) + { + $this->annotation = $annotation; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->annotation} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['annotation'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ExtendsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ExtendsTagValueNode.php new file mode 100644 index 0000000..7ce88ca --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ExtendsTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use function trim; + +class ExtendsTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public GenericTypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(GenericTypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/GenericTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/GenericTagValueNode.php new file mode 100644 index 0000000..a59ff7f --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/GenericTagValueNode.php @@ -0,0 +1,39 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class GenericTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + /** @var string (may be empty) */ + public string $value; + + public function __construct(string $value) + { + $this->value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ImplementsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ImplementsTagValueNode.php new file mode 100644 index 0000000..01d84da --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ImplementsTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use function trim; + +class ImplementsTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public GenericTypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(GenericTypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagValueNode.php new file mode 100644 index 0000000..2fb6f79 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/InvalidTagValueNode.php @@ -0,0 +1,68 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Parser\ParserException; +use function sprintf; +use function trigger_error; +use const E_USER_WARNING; + +/** + * @property ParserException $exception + */ +class InvalidTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + /** @var string (may be empty) */ + public string $value; + + /** @var mixed[] */ + private array $exceptionArgs; + + public function __construct(string $value, ParserException $exception) + { + $this->value = $value; + $this->exceptionArgs = [ + $exception->getCurrentTokenValue(), + $exception->getCurrentTokenType(), + $exception->getCurrentOffset(), + $exception->getExpectedTokenType(), + $exception->getExpectedTokenValue(), + $exception->getCurrentTokenLine(), + ]; + } + + public function __get(string $name): ?ParserException + { + if ($name !== 'exception') { + trigger_error(sprintf('Undefined property: %s::$%s', self::class, $name), E_USER_WARNING); + return null; + } + + return new ParserException(...$this->exceptionArgs); + } + + public function __toString(): string + { + return $this->value; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $exception = new ParserException(...$properties['exceptionArgs']); + $instance = new self($properties['value'], $exception); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php new file mode 100644 index 0000000..53b1a98 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php @@ -0,0 +1,68 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function count; +use function implode; + +class MethodTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public bool $isStatic; + + public ?TypeNode $returnType = null; + + public string $methodName; + + /** @var TemplateTagValueNode[] */ + public array $templateTypes; + + /** @var MethodTagValueParameterNode[] */ + public array $parameters; + + /** @var string (may be empty) */ + public string $description; + + /** + * @param MethodTagValueParameterNode[] $parameters + * @param TemplateTagValueNode[] $templateTypes + */ + public function __construct(bool $isStatic, ?TypeNode $returnType, string $methodName, array $parameters, string $description, array $templateTypes) + { + $this->isStatic = $isStatic; + $this->returnType = $returnType; + $this->methodName = $methodName; + $this->parameters = $parameters; + $this->description = $description; + $this->templateTypes = $templateTypes; + } + + public function __toString(): string + { + $static = $this->isStatic ? 'static ' : ''; + $returnType = $this->returnType !== null ? "{$this->returnType} " : ''; + $parameters = implode(', ', $this->parameters); + $description = $this->description !== '' ? " {$this->description}" : ''; + $templateTypes = count($this->templateTypes) > 0 ? '<' . implode(', ', $this->templateTypes) . '>' : ''; + return "{$static}{$returnType}{$this->methodName}{$templateTypes}({$parameters}){$description}"; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['isStatic'], $properties['returnType'], $properties['methodName'], $properties['parameters'], $properties['description'], $properties['templateTypes']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php new file mode 100644 index 0000000..6342558 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php @@ -0,0 +1,57 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; + +class MethodTagValueParameterNode implements Node +{ + + use NodeAttributes; + + public ?TypeNode $type = null; + + public bool $isReference; + + public bool $isVariadic; + + public string $parameterName; + + public ?ConstExprNode $defaultValue = null; + + public function __construct(?TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, ?ConstExprNode $defaultValue) + { + $this->type = $type; + $this->isReference = $isReference; + $this->isVariadic = $isVariadic; + $this->parameterName = $parameterName; + $this->defaultValue = $defaultValue; + } + + public function __toString(): string + { + $type = $this->type !== null ? "{$this->type} " : ''; + $isReference = $this->isReference ? '&' : ''; + $isVariadic = $this->isVariadic ? '...' : ''; + $default = $this->defaultValue !== null ? " = {$this->defaultValue}" : ''; + return "{$type}{$isReference}{$isVariadic}{$this->parameterName}{$default}"; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['isReference'], $properties['isVariadic'], $properties['parameterName'], $properties['defaultValue']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php new file mode 100644 index 0000000..f88f8bb --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class MixinTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php new file mode 100644 index 0000000..5e41b78 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php @@ -0,0 +1,47 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class ParamClosureThisTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public string $parameterName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $parameterName, string $description) + { + $this->type = $type; + $this->parameterName = $parameterName; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->parameterName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['parameterName'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php new file mode 100644 index 0000000..2c21c5e --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php @@ -0,0 +1,43 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; + +class ParamImmediatelyInvokedCallableTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public string $parameterName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(string $parameterName, string $description) + { + $this->parameterName = $parameterName; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->parameterName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['parameterName'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php new file mode 100644 index 0000000..a058f45 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php @@ -0,0 +1,43 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; + +class ParamLaterInvokedCallableTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public string $parameterName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(string $parameterName, string $description) + { + $this->parameterName = $parameterName; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->parameterName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['parameterName'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamOutTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamOutTagValueNode.php new file mode 100644 index 0000000..9cd0975 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamOutTagValueNode.php @@ -0,0 +1,47 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class ParamOutTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public string $parameterName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $parameterName, string $description) + { + $this->type = $type; + $this->parameterName = $parameterName; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->parameterName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['parameterName'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php new file mode 100644 index 0000000..73b9b74 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php @@ -0,0 +1,55 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class ParamTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public bool $isReference; + + public bool $isVariadic; + + public string $parameterName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, bool $isVariadic, string $parameterName, string $description, bool $isReference) + { + $this->type = $type; + $this->isReference = $isReference; + $this->isVariadic = $isVariadic; + $this->parameterName = $parameterName; + $this->description = $description; + } + + public function __toString(): string + { + $reference = $this->isReference ? '&' : ''; + $variadic = $this->isVariadic ? '...' : ''; + return trim("{$this->type} {$reference}{$variadic}{$this->parameterName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['isVariadic'], $properties['parameterName'], $properties['description'], $properties['isReference']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php new file mode 100644 index 0000000..6162f92 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php @@ -0,0 +1,10 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\Node; + +interface PhpDocChildNode extends Node +{ + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php new file mode 100644 index 0000000..084e5ab --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php @@ -0,0 +1,389 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function array_column; +use function array_filter; +use function array_map; +use function implode; + +class PhpDocNode implements Node +{ + + use NodeAttributes; + + /** @var PhpDocChildNode[] */ + public array $children; + + /** + * @param PhpDocChildNode[] $children + */ + public function __construct(array $children) + { + $this->children = $children; + } + + /** + * @return PhpDocTagNode[] + */ + public function getTags(): array + { + return array_filter($this->children, static fn (PhpDocChildNode $child): bool => $child instanceof PhpDocTagNode); + } + + /** + * @return PhpDocTagNode[] + */ + public function getTagsByName(string $tagName): array + { + return array_filter($this->getTags(), static fn (PhpDocTagNode $tag): bool => $tag->name === $tagName); + } + + /** + * @return VarTagValueNode[] + */ + public function getVarTagValues(string $tagName = '@var'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof VarTagValueNode, + ); + } + + /** + * @return ParamTagValueNode[] + */ + public function getParamTagValues(string $tagName = '@param'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamTagValueNode, + ); + } + + /** + * @return TypelessParamTagValueNode[] + */ + public function getTypelessParamTagValues(string $tagName = '@param'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof TypelessParamTagValueNode, + ); + } + + /** + * @return ParamImmediatelyInvokedCallableTagValueNode[] + */ + public function getParamImmediatelyInvokedCallableTagValues(string $tagName = '@param-immediately-invoked-callable'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamImmediatelyInvokedCallableTagValueNode, + ); + } + + /** + * @return ParamLaterInvokedCallableTagValueNode[] + */ + public function getParamLaterInvokedCallableTagValues(string $tagName = '@param-later-invoked-callable'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamLaterInvokedCallableTagValueNode, + ); + } + + /** + * @return ParamClosureThisTagValueNode[] + */ + public function getParamClosureThisTagValues(string $tagName = '@param-closure-this'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamClosureThisTagValueNode, + ); + } + + /** + * @return PureUnlessCallableIsImpureTagValueNode[] + */ + public function getPureUnlessCallableIsImpureTagValues(string $tagName = '@pure-unless-callable-is-impure'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof PureUnlessCallableIsImpureTagValueNode, + ); + } + + /** + * @return TemplateTagValueNode[] + */ + public function getTemplateTagValues(string $tagName = '@template'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof TemplateTagValueNode, + ); + } + + /** + * @return ExtendsTagValueNode[] + */ + public function getExtendsTagValues(string $tagName = '@extends'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ExtendsTagValueNode, + ); + } + + /** + * @return ImplementsTagValueNode[] + */ + public function getImplementsTagValues(string $tagName = '@implements'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ImplementsTagValueNode, + ); + } + + /** + * @return UsesTagValueNode[] + */ + public function getUsesTagValues(string $tagName = '@use'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof UsesTagValueNode, + ); + } + + /** + * @return ReturnTagValueNode[] + */ + public function getReturnTagValues(string $tagName = '@return'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ReturnTagValueNode, + ); + } + + /** + * @return ThrowsTagValueNode[] + */ + public function getThrowsTagValues(string $tagName = '@throws'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ThrowsTagValueNode, + ); + } + + /** + * @return MixinTagValueNode[] + */ + public function getMixinTagValues(string $tagName = '@mixin'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof MixinTagValueNode, + ); + } + + /** + * @return RequireExtendsTagValueNode[] + */ + public function getRequireExtendsTagValues(string $tagName = '@phpstan-require-extends'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof RequireExtendsTagValueNode, + ); + } + + /** + * @return RequireImplementsTagValueNode[] + */ + public function getRequireImplementsTagValues(string $tagName = '@phpstan-require-implements'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof RequireImplementsTagValueNode, + ); + } + + /** + * @return SealedTagValueNode[] + */ + public function getSealedTagValues(string $tagName = '@phpstan-sealed'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof SealedTagValueNode, + ); + } + + /** + * @return DeprecatedTagValueNode[] + */ + public function getDeprecatedTagValues(): array + { + return array_filter( + array_column($this->getTagsByName('@deprecated'), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof DeprecatedTagValueNode, + ); + } + + /** + * @return PropertyTagValueNode[] + */ + public function getPropertyTagValues(string $tagName = '@property'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof PropertyTagValueNode, + ); + } + + /** + * @return PropertyTagValueNode[] + */ + public function getPropertyReadTagValues(string $tagName = '@property-read'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof PropertyTagValueNode, + ); + } + + /** + * @return PropertyTagValueNode[] + */ + public function getPropertyWriteTagValues(string $tagName = '@property-write'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof PropertyTagValueNode, + ); + } + + /** + * @return MethodTagValueNode[] + */ + public function getMethodTagValues(string $tagName = '@method'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof MethodTagValueNode, + ); + } + + /** + * @return TypeAliasTagValueNode[] + */ + public function getTypeAliasTagValues(string $tagName = '@phpstan-type'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof TypeAliasTagValueNode, + ); + } + + /** + * @return TypeAliasImportTagValueNode[] + */ + public function getTypeAliasImportTagValues(string $tagName = '@phpstan-import-type'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof TypeAliasImportTagValueNode, + ); + } + + /** + * @return AssertTagValueNode[] + */ + public function getAssertTagValues(string $tagName = '@phpstan-assert'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof AssertTagValueNode, + ); + } + + /** + * @return AssertTagPropertyValueNode[] + */ + public function getAssertPropertyTagValues(string $tagName = '@phpstan-assert'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof AssertTagPropertyValueNode, + ); + } + + /** + * @return AssertTagMethodValueNode[] + */ + public function getAssertMethodTagValues(string $tagName = '@phpstan-assert'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof AssertTagMethodValueNode, + ); + } + + /** + * @return SelfOutTagValueNode[] + */ + public function getSelfOutTypeTagValues(string $tagName = '@phpstan-this-out'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof SelfOutTagValueNode, + ); + } + + /** + * @return ParamOutTagValueNode[] + */ + public function getParamOutTypeTagValues(string $tagName = '@param-out'): array + { + return array_filter( + array_column($this->getTagsByName($tagName), 'value'), + static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamOutTagValueNode, + ); + } + + public function __toString(): string + { + $children = array_map( + static function (PhpDocChildNode $child): string { + $s = (string) $child; + return $s === '' ? '' : ' ' . $s; + }, + $this->children, + ); + return "/**\n *" . implode("\n *", $children) . "\n */"; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['children']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagNode.php new file mode 100644 index 0000000..104aba3 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagNode.php @@ -0,0 +1,47 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine\DoctrineTagValueNode; +use function trim; + +class PhpDocTagNode implements PhpDocChildNode +{ + + use NodeAttributes; + + public string $name; + + public PhpDocTagValueNode $value; + + public function __construct(string $name, PhpDocTagValueNode $value) + { + $this->name = $name; + $this->value = $value; + } + + public function __toString(): string + { + if ($this->value instanceof DoctrineTagValueNode) { + return (string) $this->value; + } + + return trim("{$this->name} {$this->value}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['name'], $properties['value']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php new file mode 100644 index 0000000..7723fa0 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php @@ -0,0 +1,10 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\Node; + +interface PhpDocTagValueNode extends Node +{ + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTextNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTextNode.php new file mode 100644 index 0000000..4a48522 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTextNode.php @@ -0,0 +1,38 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class PhpDocTextNode implements PhpDocChildNode +{ + + use NodeAttributes; + + public string $text; + + public function __construct(string $text) + { + $this->text = $text; + } + + public function __toString(): string + { + return $this->text; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['text']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PropertyTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PropertyTagValueNode.php new file mode 100644 index 0000000..6230b87 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PropertyTagValueNode.php @@ -0,0 +1,47 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class PropertyTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public string $propertyName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $propertyName, string $description) + { + $this->type = $type; + $this->propertyName = $propertyName; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->propertyName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['propertyName'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PureUnlessCallableIsImpureTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PureUnlessCallableIsImpureTagValueNode.php new file mode 100644 index 0000000..08422b7 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PureUnlessCallableIsImpureTagValueNode.php @@ -0,0 +1,43 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; + +class PureUnlessCallableIsImpureTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public string $parameterName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(string $parameterName, string $description) + { + $this->parameterName = $parameterName; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->parameterName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['parameterName'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/RequireExtendsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/RequireExtendsTagValueNode.php new file mode 100644 index 0000000..4cc81cc --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/RequireExtendsTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class RequireExtendsTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/RequireImplementsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/RequireImplementsTagValueNode.php new file mode 100644 index 0000000..7952bff --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/RequireImplementsTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class RequireImplementsTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ReturnTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ReturnTagValueNode.php new file mode 100644 index 0000000..a37f30e --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ReturnTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class ReturnTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/SealedTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/SealedTagValueNode.php new file mode 100644 index 0000000..1b6784c --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/SealedTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class SealedTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/SelfOutTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/SelfOutTagValueNode.php new file mode 100644 index 0000000..36d4d63 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/SelfOutTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class SelfOutTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim($this->type . ' ' . $this->description); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TemplateTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TemplateTagValueNode.php new file mode 100644 index 0000000..0b1a16a --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TemplateTagValueNode.php @@ -0,0 +1,60 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class TemplateTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + /** @var non-empty-string */ + public string $name; + + public ?TypeNode $bound; + + public ?TypeNode $default; + + public ?TypeNode $lowerBound; + + /** @var string (may be empty) */ + public string $description; + + /** + * @param non-empty-string $name + */ + public function __construct(string $name, ?TypeNode $bound, string $description, ?TypeNode $default = null, ?TypeNode $lowerBound = null) + { + $this->name = $name; + $this->bound = $bound; + $this->lowerBound = $lowerBound; + $this->default = $default; + $this->description = $description; + } + + public function __toString(): string + { + $upperBound = $this->bound !== null ? " of {$this->bound}" : ''; + $lowerBound = $this->lowerBound !== null ? " super {$this->lowerBound}" : ''; + $default = $this->default !== null ? " = {$this->default}" : ''; + return trim("{$this->name}{$upperBound}{$lowerBound}{$default} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['name'], $properties['bound'], $properties['description'], $properties['default'] ?? null, $properties['lowerBound'] ?? null); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ThrowsTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ThrowsTagValueNode.php new file mode 100644 index 0000000..41a12e0 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/ThrowsTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class ThrowsTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php new file mode 100644 index 0000000..147513d --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php @@ -0,0 +1,49 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; +use function trim; + +class TypeAliasImportTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public string $importedAlias; + + public IdentifierTypeNode $importedFrom; + + public ?string $importedAs = null; + + public function __construct(string $importedAlias, IdentifierTypeNode $importedFrom, ?string $importedAs) + { + $this->importedAlias = $importedAlias; + $this->importedFrom = $importedFrom; + $this->importedAs = $importedAs; + } + + public function __toString(): string + { + return trim( + "{$this->importedAlias} from {$this->importedFrom}" + . ($this->importedAs !== null ? " as {$this->importedAs}" : ''), + ); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['importedAlias'], $properties['importedFrom'], $properties['importedAs']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasTagValueNode.php new file mode 100644 index 0000000..e80037d --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypeAliasTagValueNode.php @@ -0,0 +1,43 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class TypeAliasTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public string $alias; + + public TypeNode $type; + + public function __construct(string $alias, TypeNode $type) + { + $this->alias = $alias; + $this->type = $type; + } + + public function __toString(): string + { + return trim("{$this->alias} {$this->type}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['alias'], $properties['type']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypelessParamTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypelessParamTagValueNode.php new file mode 100644 index 0000000..108616a --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/TypelessParamTagValueNode.php @@ -0,0 +1,51 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; + +class TypelessParamTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public bool $isReference; + + public bool $isVariadic; + + public string $parameterName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(bool $isVariadic, string $parameterName, string $description, bool $isReference) + { + $this->isReference = $isReference; + $this->isVariadic = $isVariadic; + $this->parameterName = $parameterName; + $this->description = $description; + } + + public function __toString(): string + { + $reference = $this->isReference ? '&' : ''; + $variadic = $this->isVariadic ? '...' : ''; + return trim("{$reference}{$variadic}{$this->parameterName} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['isVariadic'], $properties['parameterName'], $properties['description'], $properties['isReference']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/UsesTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/UsesTagValueNode.php new file mode 100644 index 0000000..02141c0 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/UsesTagValueNode.php @@ -0,0 +1,44 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; +use function trim; + +class UsesTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public GenericTypeNode $type; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(GenericTypeNode $type, string $description) + { + $this->type = $type; + $this->description = $description; + } + + public function __toString(): string + { + return trim("{$this->type} {$this->description}"); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/VarTagValueNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/VarTagValueNode.php new file mode 100644 index 0000000..8affe48 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/VarTagValueNode.php @@ -0,0 +1,48 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\PhpDoc; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\Type\TypeNode; +use function trim; + +class VarTagValueNode implements PhpDocTagValueNode +{ + + use NodeAttributes; + + public TypeNode $type; + + /** @var string (may be empty) */ + public string $variableName; + + /** @var string (may be empty) */ + public string $description; + + public function __construct(TypeNode $type, string $variableName, string $description) + { + $this->type = $type; + $this->variableName = $variableName; + $this->description = $description; + } + + public function __toString(): string + { + return trim("$this->type " . trim("{$this->variableName} {$this->description}")); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['variableName'], $properties['description']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeItemNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeItemNode.php new file mode 100644 index 0000000..f6276cd --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeItemNode.php @@ -0,0 +1,62 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode; +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode; +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; + +class ArrayShapeItemNode implements Node +{ + + use NodeAttributes; + + /** @var ConstExprIntegerNode|ConstExprStringNode|ConstFetchNode|IdentifierTypeNode|null */ + public $keyName; + + public bool $optional; + + public TypeNode $valueType; + + /** + * @param ConstExprIntegerNode|ConstExprStringNode|ConstFetchNode|IdentifierTypeNode|null $keyName + */ + public function __construct($keyName, bool $optional, TypeNode $valueType) + { + $this->keyName = $keyName; + $this->optional = $optional; + $this->valueType = $valueType; + } + + public function __toString(): string + { + if ($this->keyName !== null) { + return sprintf( + '%s%s: %s', + (string) $this->keyName, + $this->optional ? '?' : '', + (string) $this->valueType, + ); + } + + return (string) $this->valueType; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['keyName'], $properties['optional'], $properties['valueType']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeNode.php new file mode 100644 index 0000000..a49f827 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeNode.php @@ -0,0 +1,88 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; + +class ArrayShapeNode implements TypeNode +{ + + public const KIND_ARRAY = 'array'; + public const KIND_LIST = 'list'; + public const KIND_NON_EMPTY_ARRAY = 'non-empty-array'; + public const KIND_NON_EMPTY_LIST = 'non-empty-list'; + + use NodeAttributes; + + /** @var ArrayShapeItemNode[] */ + public array $items; + + public bool $sealed; + + /** @var self::KIND_* */ + public $kind; + + public ?ArrayShapeUnsealedTypeNode $unsealedType = null; + + /** + * @param ArrayShapeItemNode[] $items + * @param self::KIND_* $kind + */ + private function __construct( + array $items, + bool $sealed = true, + ?ArrayShapeUnsealedTypeNode $unsealedType = null, + string $kind = self::KIND_ARRAY + ) + { + $this->items = $items; + $this->sealed = $sealed; + $this->unsealedType = $unsealedType; + $this->kind = $kind; + } + + /** + * @param ArrayShapeItemNode[] $items + * @param self::KIND_* $kind + */ + public static function createSealed(array $items, string $kind = self::KIND_ARRAY): self + { + return new self($items, true, null, $kind); + } + + /** + * @param ArrayShapeItemNode[] $items + * @param self::KIND_* $kind + */ + public static function createUnsealed(array $items, ?ArrayShapeUnsealedTypeNode $unsealedType, string $kind = self::KIND_ARRAY): self + { + return new self($items, false, $unsealedType, $kind); + } + + public function __toString(): string + { + $items = $this->items; + + if (! $this->sealed) { + $items[] = '...' . $this->unsealedType; + } + + return $this->kind . '{' . implode(', ', $items) . '}'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['items'], $properties['sealed'], $properties['unsealedType'], $properties['kind']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeUnsealedTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeUnsealedTypeNode.php new file mode 100644 index 0000000..b6c36bb --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayShapeUnsealedTypeNode.php @@ -0,0 +1,46 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; + +class ArrayShapeUnsealedTypeNode implements Node +{ + + use NodeAttributes; + + public TypeNode $valueType; + + public ?TypeNode $keyType = null; + + public function __construct(TypeNode $valueType, ?TypeNode $keyType) + { + $this->valueType = $valueType; + $this->keyType = $keyType; + } + + public function __toString(): string + { + if ($this->keyType !== null) { + return sprintf('<%s, %s>', $this->keyType, $this->valueType); + } + return sprintf('<%s>', $this->valueType); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['valueType'], $properties['keyType']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayTypeNode.php new file mode 100644 index 0000000..c9d6041 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ArrayTypeNode.php @@ -0,0 +1,46 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ArrayTypeNode implements TypeNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public function __construct(TypeNode $type) + { + $this->type = $type; + } + + public function __toString(): string + { + if ( + $this->type instanceof CallableTypeNode + || $this->type instanceof ConstTypeNode + || $this->type instanceof NullableTypeNode + ) { + return '(' . $this->type . ')[]'; + } + + return $this->type . '[]'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeNode.php new file mode 100644 index 0000000..ea34a55 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeNode.php @@ -0,0 +1,63 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; +use function implode; + +class CallableTypeNode implements TypeNode +{ + + use NodeAttributes; + + public IdentifierTypeNode $identifier; + + /** @var TemplateTagValueNode[] */ + public array $templateTypes; + + /** @var CallableTypeParameterNode[] */ + public array $parameters; + + public TypeNode $returnType; + + /** + * @param CallableTypeParameterNode[] $parameters + * @param TemplateTagValueNode[] $templateTypes + */ + public function __construct(IdentifierTypeNode $identifier, array $parameters, TypeNode $returnType, array $templateTypes) + { + $this->identifier = $identifier; + $this->parameters = $parameters; + $this->returnType = $returnType; + $this->templateTypes = $templateTypes; + } + + public function __toString(): string + { + $returnType = $this->returnType; + if ($returnType instanceof self) { + $returnType = "({$returnType})"; + } + $template = $this->templateTypes !== [] + ? '<' . implode(', ', $this->templateTypes) . '>' + : ''; + $parameters = implode(', ', $this->parameters); + return "{$this->identifier}{$template}({$parameters}): {$returnType}"; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['identifier'], $properties['parameters'], $properties['returnType'], $properties['templateTypes']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeParameterNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeParameterNode.php new file mode 100644 index 0000000..37c34ce --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/CallableTypeParameterNode.php @@ -0,0 +1,57 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function trim; + +class CallableTypeParameterNode implements Node +{ + + use NodeAttributes; + + public TypeNode $type; + + public bool $isReference; + + public bool $isVariadic; + + /** @var string (may be empty) */ + public string $parameterName; + + public bool $isOptional; + + public function __construct(TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, bool $isOptional) + { + $this->type = $type; + $this->isReference = $isReference; + $this->isVariadic = $isVariadic; + $this->parameterName = $parameterName; + $this->isOptional = $isOptional; + } + + public function __toString(): string + { + $type = "{$this->type} "; + $isReference = $this->isReference ? '&' : ''; + $isVariadic = $this->isVariadic ? '...' : ''; + $isOptional = $this->isOptional ? '=' : ''; + return trim("{$type}{$isReference}{$isVariadic}{$this->parameterName}") . $isOptional; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['isReference'], $properties['isVariadic'], $properties['parameterName'], $properties['isOptional']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeForParameterNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeForParameterNode.php new file mode 100644 index 0000000..32bcc53 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeForParameterNode.php @@ -0,0 +1,58 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; + +class ConditionalTypeForParameterNode implements TypeNode +{ + + use NodeAttributes; + + public string $parameterName; + + public TypeNode $targetType; + + public TypeNode $if; + + public TypeNode $else; + + public bool $negated; + + public function __construct(string $parameterName, TypeNode $targetType, TypeNode $if, TypeNode $else, bool $negated) + { + $this->parameterName = $parameterName; + $this->targetType = $targetType; + $this->if = $if; + $this->else = $else; + $this->negated = $negated; + } + + public function __toString(): string + { + return sprintf( + '(%s %s %s ? %s : %s)', + $this->parameterName, + $this->negated ? 'is not' : 'is', + $this->targetType, + $this->if, + $this->else, + ); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['parameterName'], $properties['targetType'], $properties['if'], $properties['else'], $properties['negated']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeNode.php new file mode 100644 index 0000000..7970a70 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConditionalTypeNode.php @@ -0,0 +1,58 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; + +class ConditionalTypeNode implements TypeNode +{ + + use NodeAttributes; + + public TypeNode $subjectType; + + public TypeNode $targetType; + + public TypeNode $if; + + public TypeNode $else; + + public bool $negated; + + public function __construct(TypeNode $subjectType, TypeNode $targetType, TypeNode $if, TypeNode $else, bool $negated) + { + $this->subjectType = $subjectType; + $this->targetType = $targetType; + $this->if = $if; + $this->else = $else; + $this->negated = $negated; + } + + public function __toString(): string + { + return sprintf( + '(%s %s %s ? %s : %s)', + $this->subjectType, + $this->negated ? 'is not' : 'is', + $this->targetType, + $this->if, + $this->else, + ); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['subjectType'], $properties['targetType'], $properties['if'], $properties['else'], $properties['negated']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConstTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConstTypeNode.php new file mode 100644 index 0000000..79f2eed --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ConstTypeNode.php @@ -0,0 +1,39 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ConstTypeNode implements TypeNode +{ + + use NodeAttributes; + + public ConstExprNode $constExpr; + + public function __construct(ConstExprNode $constExpr) + { + $this->constExpr = $constExpr; + } + + public function __toString(): string + { + return $this->constExpr->__toString(); + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['constExpr']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php new file mode 100644 index 0000000..0069aa4 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php @@ -0,0 +1,70 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; +use function sprintf; + +class GenericTypeNode implements TypeNode +{ + + public const VARIANCE_INVARIANT = 'invariant'; + public const VARIANCE_COVARIANT = 'covariant'; + public const VARIANCE_CONTRAVARIANT = 'contravariant'; + public const VARIANCE_BIVARIANT = 'bivariant'; + + use NodeAttributes; + + public IdentifierTypeNode $type; + + /** @var TypeNode[] */ + public array $genericTypes; + + /** @var (self::VARIANCE_*)[] */ + public array $variances; + + /** + * @param TypeNode[] $genericTypes + * @param (self::VARIANCE_*)[] $variances + */ + public function __construct(IdentifierTypeNode $type, array $genericTypes, array $variances = []) + { + $this->type = $type; + $this->genericTypes = $genericTypes; + $this->variances = $variances; + } + + public function __toString(): string + { + $genericTypes = []; + + foreach ($this->genericTypes as $index => $type) { + $variance = $this->variances[$index] ?? self::VARIANCE_INVARIANT; + if ($variance === self::VARIANCE_INVARIANT) { + $genericTypes[] = (string) $type; + } elseif ($variance === self::VARIANCE_BIVARIANT) { + $genericTypes[] = '*'; + } else { + $genericTypes[] = sprintf('%s %s', $variance, $type); + } + } + + return $this->type . '<' . implode(', ', $genericTypes) . '>'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['genericTypes'], $properties['variances'] ?? []); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/IdentifierTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/IdentifierTypeNode.php new file mode 100644 index 0000000..591edca --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/IdentifierTypeNode.php @@ -0,0 +1,38 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class IdentifierTypeNode implements TypeNode +{ + + use NodeAttributes; + + public string $name; + + public function __construct(string $name) + { + $this->name = $name; + } + + public function __toString(): string + { + return $this->name; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['name']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php new file mode 100644 index 0000000..6dbc3ff --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php @@ -0,0 +1,50 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function array_map; +use function implode; + +class IntersectionTypeNode implements TypeNode +{ + + use NodeAttributes; + + /** @var TypeNode[] */ + public array $types; + + /** + * @param TypeNode[] $types + */ + public function __construct(array $types) + { + $this->types = $types; + } + + public function __toString(): string + { + return '(' . implode(' & ', array_map(static function (TypeNode $type): string { + if ($type instanceof NullableTypeNode) { + return '(' . $type . ')'; + } + + return (string) $type; + }, $this->types)) . ')'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['types']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/InvalidTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/InvalidTypeNode.php new file mode 100644 index 0000000..a03fc18 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/InvalidTypeNode.php @@ -0,0 +1,53 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use PHPStan\PhpDocParser\Parser\ParserException; + +class InvalidTypeNode implements TypeNode +{ + + use NodeAttributes; + + /** @var mixed[] */ + private array $exceptionArgs; + + public function __construct(ParserException $exception) + { + $this->exceptionArgs = [ + $exception->getCurrentTokenValue(), + $exception->getCurrentTokenType(), + $exception->getCurrentOffset(), + $exception->getExpectedTokenType(), + $exception->getExpectedTokenValue(), + $exception->getCurrentTokenLine(), + ]; + } + + public function getException(): ParserException + { + return new ParserException(...$this->exceptionArgs); + } + + public function __toString(): string + { + return '*Invalid type*'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $exception = new ParserException(...$properties['exceptionArgs']); + $instance = new self($exception); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/NullableTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/NullableTypeNode.php new file mode 100644 index 0000000..f79bad0 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/NullableTypeNode.php @@ -0,0 +1,38 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class NullableTypeNode implements TypeNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public function __construct(TypeNode $type) + { + $this->type = $type; + } + + public function __toString(): string + { + return '?' . $this->type; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ObjectShapeItemNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ObjectShapeItemNode.php new file mode 100644 index 0000000..7ce0622 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ObjectShapeItemNode.php @@ -0,0 +1,60 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; +use PHPStan\PhpDocParser\Ast\Node; +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function sprintf; + +class ObjectShapeItemNode implements Node +{ + + use NodeAttributes; + + /** @var ConstExprStringNode|IdentifierTypeNode */ + public $keyName; + + public bool $optional; + + public TypeNode $valueType; + + /** + * @param ConstExprStringNode|IdentifierTypeNode $keyName + */ + public function __construct($keyName, bool $optional, TypeNode $valueType) + { + $this->keyName = $keyName; + $this->optional = $optional; + $this->valueType = $valueType; + } + + public function __toString(): string + { + if ($this->keyName !== null) { + return sprintf( + '%s%s: %s', + (string) $this->keyName, + $this->optional ? '?' : '', + (string) $this->valueType, + ); + } + + return (string) $this->valueType; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['keyName'], $properties['optional'], $properties['valueType']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ObjectShapeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ObjectShapeNode.php new file mode 100644 index 0000000..2e00382 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ObjectShapeNode.php @@ -0,0 +1,45 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function implode; + +class ObjectShapeNode implements TypeNode +{ + + use NodeAttributes; + + /** @var ObjectShapeItemNode[] */ + public array $items; + + /** + * @param ObjectShapeItemNode[] $items + */ + public function __construct(array $items) + { + $this->items = $items; + } + + public function __toString(): string + { + $items = $this->items; + + return 'object{' . implode(', ', $items) . '}'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['items']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/OffsetAccessTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/OffsetAccessTypeNode.php new file mode 100644 index 0000000..fa8bde6 --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/OffsetAccessTypeNode.php @@ -0,0 +1,48 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class OffsetAccessTypeNode implements TypeNode +{ + + use NodeAttributes; + + public TypeNode $type; + + public TypeNode $offset; + + public function __construct(TypeNode $type, TypeNode $offset) + { + $this->type = $type; + $this->offset = $offset; + } + + public function __toString(): string + { + if ( + $this->type instanceof CallableTypeNode + || $this->type instanceof NullableTypeNode + ) { + return '(' . $this->type . ')[' . $this->offset . ']'; + } + + return $this->type . '[' . $this->offset . ']'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['type'], $properties['offset']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/ThisTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ThisTypeNode.php new file mode 100644 index 0000000..b0ccf3b --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/ThisTypeNode.php @@ -0,0 +1,31 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; + +class ThisTypeNode implements TypeNode +{ + + use NodeAttributes; + + public function __toString(): string + { + return '$this'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self(); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/TypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/TypeNode.php new file mode 100644 index 0000000..849e04e --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/TypeNode.php @@ -0,0 +1,10 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\Node; + +interface TypeNode extends Node +{ + +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Type/UnionTypeNode.php b/vendor/phpstan/phpdoc-parser/src/Ast/Type/UnionTypeNode.php new file mode 100644 index 0000000..30c37bd --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Type/UnionTypeNode.php @@ -0,0 +1,50 @@ +<?php declare(strict_types = 1); + +namespace PHPStan\PhpDocParser\Ast\Type; + +use PHPStan\PhpDocParser\Ast\NodeAttributes; +use function array_map; +use function implode; + +class UnionTypeNode implements TypeNode +{ + + use NodeAttributes; + + /** @var TypeNode[] */ + public array $types; + + /** + * @param TypeNode[] $types + */ + public function __construct(array $types) + { + $this->types = $types; + } + + public function __toString(): string + { + return '(' . implode(' | ', array_map(static function (TypeNode $type): string { + if ($type instanceof NullableTypeNode) { + return '(' . $type . ')'; + } + + return (string) $type; + }, $this->types)) . ')'; + } + + /** + * @param array<string, mixed> $properties + */ + public static function __set_state(array $properties): self + { + $instance = new self($properties['types']); + if (isset($properties['attributes'])) { + foreach ($properties['attributes'] as $key => $value) { + $instance->setAttribute($key, $value); + } + } + return $instance; + } + +} |
