diff --git a/src/Ast/Comment.php b/src/Ast/Comment.php index 79e24eb..7147f39 100644 --- a/src/Ast/Comment.php +++ b/src/Ast/Comment.php @@ -25,4 +25,12 @@ public function getReformattedText(): string return trim($this->text); } + /** + * @param array $properties + */ + public static function __set_state(array $properties): self + { + return new self($properties['text'], $properties['startLine'], $properties['startIndex']); + } + } diff --git a/src/Ast/ConstExpr/ConstExprArrayItemNode.php b/src/Ast/ConstExpr/ConstExprArrayItemNode.php index 4da4177..b8e7c0a 100644 --- a/src/Ast/ConstExpr/ConstExprArrayItemNode.php +++ b/src/Ast/ConstExpr/ConstExprArrayItemNode.php @@ -30,4 +30,18 @@ public function __toString(): string return (string) $this->value; } + /** + * @param array $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/src/Ast/ConstExpr/ConstExprArrayNode.php b/src/Ast/ConstExpr/ConstExprArrayNode.php index c6e4628..ae83c39 100644 --- a/src/Ast/ConstExpr/ConstExprArrayNode.php +++ b/src/Ast/ConstExpr/ConstExprArrayNode.php @@ -26,4 +26,18 @@ public function __toString(): string return '[' . implode(', ', $this->items) . ']'; } + /** + * @param array $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/src/Ast/ConstExpr/ConstExprFalseNode.php b/src/Ast/ConstExpr/ConstExprFalseNode.php index e681127..310ff10 100644 --- a/src/Ast/ConstExpr/ConstExprFalseNode.php +++ b/src/Ast/ConstExpr/ConstExprFalseNode.php @@ -14,4 +14,18 @@ public function __toString(): string return 'false'; } + /** + * @param array $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/src/Ast/ConstExpr/ConstExprFloatNode.php b/src/Ast/ConstExpr/ConstExprFloatNode.php index a2e5e54..badb1cf 100644 --- a/src/Ast/ConstExpr/ConstExprFloatNode.php +++ b/src/Ast/ConstExpr/ConstExprFloatNode.php @@ -21,4 +21,18 @@ public function __toString(): string return $this->value; } + /** + * @param array $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/src/Ast/ConstExpr/ConstExprIntegerNode.php b/src/Ast/ConstExpr/ConstExprIntegerNode.php index 6e9a5fa..5bed6ed 100644 --- a/src/Ast/ConstExpr/ConstExprIntegerNode.php +++ b/src/Ast/ConstExpr/ConstExprIntegerNode.php @@ -21,4 +21,18 @@ public function __toString(): string return $this->value; } + /** + * @param array $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/src/Ast/ConstExpr/ConstExprNullNode.php b/src/Ast/ConstExpr/ConstExprNullNode.php index b6e2277..b0f9165 100644 --- a/src/Ast/ConstExpr/ConstExprNullNode.php +++ b/src/Ast/ConstExpr/ConstExprNullNode.php @@ -14,4 +14,18 @@ public function __toString(): string return 'null'; } + /** + * @param array $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/src/Ast/ConstExpr/ConstExprStringNode.php b/src/Ast/ConstExpr/ConstExprStringNode.php index 5613635..5ac662a 100644 --- a/src/Ast/ConstExpr/ConstExprStringNode.php +++ b/src/Ast/ConstExpr/ConstExprStringNode.php @@ -76,4 +76,18 @@ private function escapeDoubleQuotedString(): string }, $escaped); } + /** + * @param array $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/src/Ast/ConstExpr/ConstExprTrueNode.php b/src/Ast/ConstExpr/ConstExprTrueNode.php index ec98032..a7e172b 100644 --- a/src/Ast/ConstExpr/ConstExprTrueNode.php +++ b/src/Ast/ConstExpr/ConstExprTrueNode.php @@ -14,4 +14,18 @@ public function __toString(): string return 'true'; } + /** + * @param array $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/src/Ast/ConstExpr/ConstFetchNode.php b/src/Ast/ConstExpr/ConstFetchNode.php index 983f1e4..65ba489 100644 --- a/src/Ast/ConstExpr/ConstFetchNode.php +++ b/src/Ast/ConstExpr/ConstFetchNode.php @@ -30,4 +30,18 @@ public function __toString(): string return "{$this->className}::{$this->name}"; } + /** + * @param array $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/src/Ast/ConstExpr/DoctrineConstExprStringNode.php b/src/Ast/ConstExpr/DoctrineConstExprStringNode.php index 4515e89..5cfb071 100644 --- a/src/Ast/ConstExpr/DoctrineConstExprStringNode.php +++ b/src/Ast/ConstExpr/DoctrineConstExprStringNode.php @@ -38,4 +38,18 @@ private static function escape(string $value): string return sprintf('"%s"', str_replace('"', '""', $value)); } + /** + * @param array $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/src/Ast/PhpDoc/AssertTagMethodValueNode.php b/src/Ast/PhpDoc/AssertTagMethodValueNode.php index 0d1be8a..d51327a 100644 --- a/src/Ast/PhpDoc/AssertTagMethodValueNode.php +++ b/src/Ast/PhpDoc/AssertTagMethodValueNode.php @@ -41,4 +41,18 @@ public function __toString(): string return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter}->{$this->method}() {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/AssertTagPropertyValueNode.php b/src/Ast/PhpDoc/AssertTagPropertyValueNode.php index 493405c..56e23cf 100644 --- a/src/Ast/PhpDoc/AssertTagPropertyValueNode.php +++ b/src/Ast/PhpDoc/AssertTagPropertyValueNode.php @@ -41,4 +41,18 @@ public function __toString(): string return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter}->{$this->property} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/AssertTagValueNode.php b/src/Ast/PhpDoc/AssertTagValueNode.php index 45280f6..34bbcb0 100644 --- a/src/Ast/PhpDoc/AssertTagValueNode.php +++ b/src/Ast/PhpDoc/AssertTagValueNode.php @@ -38,4 +38,18 @@ public function __toString(): string return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/DeprecatedTagValueNode.php b/src/Ast/PhpDoc/DeprecatedTagValueNode.php index 82f67b2..3831a67 100644 --- a/src/Ast/PhpDoc/DeprecatedTagValueNode.php +++ b/src/Ast/PhpDoc/DeprecatedTagValueNode.php @@ -23,4 +23,18 @@ public function __toString(): string return trim($this->description); } + /** + * @param array $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/src/Ast/PhpDoc/Doctrine/DoctrineAnnotation.php b/src/Ast/PhpDoc/Doctrine/DoctrineAnnotation.php index 778b21f..5ffdf31 100644 --- a/src/Ast/PhpDoc/Doctrine/DoctrineAnnotation.php +++ b/src/Ast/PhpDoc/Doctrine/DoctrineAnnotation.php @@ -31,4 +31,18 @@ public function __toString(): string return $this->name . '(' . $arguments . ')'; } + /** + * @param array $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/src/Ast/PhpDoc/Doctrine/DoctrineArgument.php b/src/Ast/PhpDoc/Doctrine/DoctrineArgument.php index 3728dc9..8ff4626 100644 --- a/src/Ast/PhpDoc/Doctrine/DoctrineArgument.php +++ b/src/Ast/PhpDoc/Doctrine/DoctrineArgument.php @@ -38,4 +38,18 @@ public function __toString(): string return $this->key . '=' . $this->value; } + /** + * @param array $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/src/Ast/PhpDoc/Doctrine/DoctrineArray.php b/src/Ast/PhpDoc/Doctrine/DoctrineArray.php index 06686a5..ee52a25 100644 --- a/src/Ast/PhpDoc/Doctrine/DoctrineArray.php +++ b/src/Ast/PhpDoc/Doctrine/DoctrineArray.php @@ -29,4 +29,18 @@ public function __toString(): string return '{' . $items . '}'; } + /** + * @param array $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/src/Ast/PhpDoc/Doctrine/DoctrineArrayItem.php b/src/Ast/PhpDoc/Doctrine/DoctrineArrayItem.php index 5324601..ff1bd37 100644 --- a/src/Ast/PhpDoc/Doctrine/DoctrineArrayItem.php +++ b/src/Ast/PhpDoc/Doctrine/DoctrineArrayItem.php @@ -43,4 +43,18 @@ public function __toString(): string return $this->key . '=' . $this->value; } + /** + * @param array $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/src/Ast/PhpDoc/Doctrine/DoctrineTagValueNode.php b/src/Ast/PhpDoc/Doctrine/DoctrineTagValueNode.php index f06976f..29f3e0d 100644 --- a/src/Ast/PhpDoc/Doctrine/DoctrineTagValueNode.php +++ b/src/Ast/PhpDoc/Doctrine/DoctrineTagValueNode.php @@ -30,4 +30,18 @@ public function __toString(): string return trim("{$this->annotation} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ExtendsTagValueNode.php b/src/Ast/PhpDoc/ExtendsTagValueNode.php index c719481..7ce88ca 100644 --- a/src/Ast/PhpDoc/ExtendsTagValueNode.php +++ b/src/Ast/PhpDoc/ExtendsTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/GenericTagValueNode.php b/src/Ast/PhpDoc/GenericTagValueNode.php index 78a7588..a59ff7f 100644 --- a/src/Ast/PhpDoc/GenericTagValueNode.php +++ b/src/Ast/PhpDoc/GenericTagValueNode.php @@ -22,4 +22,18 @@ public function __toString(): string return $this->value; } + /** + * @param array $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/src/Ast/PhpDoc/ImplementsTagValueNode.php b/src/Ast/PhpDoc/ImplementsTagValueNode.php index 9ab67e3..01d84da 100644 --- a/src/Ast/PhpDoc/ImplementsTagValueNode.php +++ b/src/Ast/PhpDoc/ImplementsTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/InvalidTagValueNode.php b/src/Ast/PhpDoc/InvalidTagValueNode.php index 7bb20b2..2fb6f79 100644 --- a/src/Ast/PhpDoc/InvalidTagValueNode.php +++ b/src/Ast/PhpDoc/InvalidTagValueNode.php @@ -50,4 +50,19 @@ public function __toString(): string return $this->value; } + /** + * @param array $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/src/Ast/PhpDoc/MethodTagValueNode.php b/src/Ast/PhpDoc/MethodTagValueNode.php index 96fecdc..53b1a98 100644 --- a/src/Ast/PhpDoc/MethodTagValueNode.php +++ b/src/Ast/PhpDoc/MethodTagValueNode.php @@ -51,4 +51,18 @@ public function __toString(): string return "{$static}{$returnType}{$this->methodName}{$templateTypes}({$parameters}){$description}"; } + /** + * @param array $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/src/Ast/PhpDoc/MethodTagValueParameterNode.php b/src/Ast/PhpDoc/MethodTagValueParameterNode.php index 3a4c9cc..6342558 100644 --- a/src/Ast/PhpDoc/MethodTagValueParameterNode.php +++ b/src/Ast/PhpDoc/MethodTagValueParameterNode.php @@ -40,4 +40,18 @@ public function __toString(): string return "{$type}{$isReference}{$isVariadic}{$this->parameterName}{$default}"; } + /** + * @param array $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/src/Ast/PhpDoc/MixinTagValueNode.php b/src/Ast/PhpDoc/MixinTagValueNode.php index 087f57d..f88f8bb 100644 --- a/src/Ast/PhpDoc/MixinTagValueNode.php +++ b/src/Ast/PhpDoc/MixinTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php b/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php index 54feff9..5e41b78 100644 --- a/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php +++ b/src/Ast/PhpDoc/ParamClosureThisTagValueNode.php @@ -30,4 +30,18 @@ public function __toString(): string return trim("{$this->type} {$this->parameterName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php b/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php index 9a6761f..2c21c5e 100644 --- a/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php +++ b/src/Ast/PhpDoc/ParamImmediatelyInvokedCallableTagValueNode.php @@ -26,4 +26,18 @@ public function __toString(): string return trim("{$this->parameterName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php b/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php index 84db67a..a058f45 100644 --- a/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php +++ b/src/Ast/PhpDoc/ParamLaterInvokedCallableTagValueNode.php @@ -26,4 +26,18 @@ public function __toString(): string return trim("{$this->parameterName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ParamOutTagValueNode.php b/src/Ast/PhpDoc/ParamOutTagValueNode.php index 3e89f9d..9cd0975 100644 --- a/src/Ast/PhpDoc/ParamOutTagValueNode.php +++ b/src/Ast/PhpDoc/ParamOutTagValueNode.php @@ -30,4 +30,18 @@ public function __toString(): string return trim("{$this->type} {$this->parameterName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ParamTagValueNode.php b/src/Ast/PhpDoc/ParamTagValueNode.php index 427b8a6..73b9b74 100644 --- a/src/Ast/PhpDoc/ParamTagValueNode.php +++ b/src/Ast/PhpDoc/ParamTagValueNode.php @@ -38,4 +38,18 @@ public function __toString(): string return trim("{$this->type} {$reference}{$variadic}{$this->parameterName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/PhpDocNode.php b/src/Ast/PhpDoc/PhpDocNode.php index a1fdbd8..084e5ab 100644 --- a/src/Ast/PhpDoc/PhpDocNode.php +++ b/src/Ast/PhpDoc/PhpDocNode.php @@ -372,4 +372,18 @@ static function (PhpDocChildNode $child): string { return "/**\n *" . implode("\n *", $children) . "\n */"; } + /** + * @param array $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/src/Ast/PhpDoc/PhpDocTagNode.php b/src/Ast/PhpDoc/PhpDocTagNode.php index f11d01a..104aba3 100644 --- a/src/Ast/PhpDoc/PhpDocTagNode.php +++ b/src/Ast/PhpDoc/PhpDocTagNode.php @@ -30,4 +30,18 @@ public function __toString(): string return trim("{$this->name} {$this->value}"); } + /** + * @param array $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/src/Ast/PhpDoc/PhpDocTextNode.php b/src/Ast/PhpDoc/PhpDocTextNode.php index ac2905e..4a48522 100644 --- a/src/Ast/PhpDoc/PhpDocTextNode.php +++ b/src/Ast/PhpDoc/PhpDocTextNode.php @@ -21,4 +21,18 @@ public function __toString(): string return $this->text; } + /** + * @param array $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/src/Ast/PhpDoc/PropertyTagValueNode.php b/src/Ast/PhpDoc/PropertyTagValueNode.php index 50e2ea6..6230b87 100644 --- a/src/Ast/PhpDoc/PropertyTagValueNode.php +++ b/src/Ast/PhpDoc/PropertyTagValueNode.php @@ -30,4 +30,18 @@ public function __toString(): string return trim("{$this->type} {$this->propertyName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/PureUnlessCallableIsImpureTagValueNode.php b/src/Ast/PhpDoc/PureUnlessCallableIsImpureTagValueNode.php index 1a0cff8..08422b7 100644 --- a/src/Ast/PhpDoc/PureUnlessCallableIsImpureTagValueNode.php +++ b/src/Ast/PhpDoc/PureUnlessCallableIsImpureTagValueNode.php @@ -26,4 +26,18 @@ public function __toString(): string return trim("{$this->parameterName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/RequireExtendsTagValueNode.php b/src/Ast/PhpDoc/RequireExtendsTagValueNode.php index 7435dda..4cc81cc 100644 --- a/src/Ast/PhpDoc/RequireExtendsTagValueNode.php +++ b/src/Ast/PhpDoc/RequireExtendsTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/RequireImplementsTagValueNode.php b/src/Ast/PhpDoc/RequireImplementsTagValueNode.php index 1407c1b..7952bff 100644 --- a/src/Ast/PhpDoc/RequireImplementsTagValueNode.php +++ b/src/Ast/PhpDoc/RequireImplementsTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ReturnTagValueNode.php b/src/Ast/PhpDoc/ReturnTagValueNode.php index c1f6a92..a37f30e 100644 --- a/src/Ast/PhpDoc/ReturnTagValueNode.php +++ b/src/Ast/PhpDoc/ReturnTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/SealedTagValueNode.php b/src/Ast/PhpDoc/SealedTagValueNode.php index 2279086..1b6784c 100644 --- a/src/Ast/PhpDoc/SealedTagValueNode.php +++ b/src/Ast/PhpDoc/SealedTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/SelfOutTagValueNode.php b/src/Ast/PhpDoc/SelfOutTagValueNode.php index 642f7b8..36d4d63 100644 --- a/src/Ast/PhpDoc/SelfOutTagValueNode.php +++ b/src/Ast/PhpDoc/SelfOutTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim($this->type . ' ' . $this->description); } + /** + * @param array $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/src/Ast/PhpDoc/TemplateTagValueNode.php b/src/Ast/PhpDoc/TemplateTagValueNode.php index 7e2adfc..0b1a16a 100644 --- a/src/Ast/PhpDoc/TemplateTagValueNode.php +++ b/src/Ast/PhpDoc/TemplateTagValueNode.php @@ -43,4 +43,18 @@ public function __toString(): string return trim("{$this->name}{$upperBound}{$lowerBound}{$default} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/ThrowsTagValueNode.php b/src/Ast/PhpDoc/ThrowsTagValueNode.php index a13e606..41a12e0 100644 --- a/src/Ast/PhpDoc/ThrowsTagValueNode.php +++ b/src/Ast/PhpDoc/ThrowsTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php b/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php index d0f945d..147513d 100644 --- a/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php +++ b/src/Ast/PhpDoc/TypeAliasImportTagValueNode.php @@ -32,4 +32,18 @@ public function __toString(): string ); } + /** + * @param array $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/src/Ast/PhpDoc/TypeAliasTagValueNode.php b/src/Ast/PhpDoc/TypeAliasTagValueNode.php index 8967cd6..e80037d 100644 --- a/src/Ast/PhpDoc/TypeAliasTagValueNode.php +++ b/src/Ast/PhpDoc/TypeAliasTagValueNode.php @@ -26,4 +26,18 @@ public function __toString(): string return trim("{$this->alias} {$this->type}"); } + /** + * @param array $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/src/Ast/PhpDoc/TypelessParamTagValueNode.php b/src/Ast/PhpDoc/TypelessParamTagValueNode.php index df50938..108616a 100644 --- a/src/Ast/PhpDoc/TypelessParamTagValueNode.php +++ b/src/Ast/PhpDoc/TypelessParamTagValueNode.php @@ -34,4 +34,18 @@ public function __toString(): string return trim("{$reference}{$variadic}{$this->parameterName} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/UsesTagValueNode.php b/src/Ast/PhpDoc/UsesTagValueNode.php index 8570c41..02141c0 100644 --- a/src/Ast/PhpDoc/UsesTagValueNode.php +++ b/src/Ast/PhpDoc/UsesTagValueNode.php @@ -27,4 +27,18 @@ public function __toString(): string return trim("{$this->type} {$this->description}"); } + /** + * @param array $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/src/Ast/PhpDoc/VarTagValueNode.php b/src/Ast/PhpDoc/VarTagValueNode.php index b761aeb..8affe48 100644 --- a/src/Ast/PhpDoc/VarTagValueNode.php +++ b/src/Ast/PhpDoc/VarTagValueNode.php @@ -31,4 +31,18 @@ public function __toString(): string return trim("$this->type " . trim("{$this->variableName} {$this->description}")); } + /** + * @param array $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/src/Ast/Type/ArrayShapeItemNode.php b/src/Ast/Type/ArrayShapeItemNode.php index 43586bd..f6276cd 100644 --- a/src/Ast/Type/ArrayShapeItemNode.php +++ b/src/Ast/Type/ArrayShapeItemNode.php @@ -45,4 +45,18 @@ public function __toString(): string return (string) $this->valueType; } + /** + * @param array $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/src/Ast/Type/ArrayShapeNode.php b/src/Ast/Type/ArrayShapeNode.php index bfb7638..a49f827 100644 --- a/src/Ast/Type/ArrayShapeNode.php +++ b/src/Ast/Type/ArrayShapeNode.php @@ -71,4 +71,18 @@ public function __toString(): string return $this->kind . '{' . implode(', ', $items) . '}'; } + /** + * @param array $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/src/Ast/Type/ArrayShapeUnsealedTypeNode.php b/src/Ast/Type/ArrayShapeUnsealedTypeNode.php index 68d6b36..b6c36bb 100644 --- a/src/Ast/Type/ArrayShapeUnsealedTypeNode.php +++ b/src/Ast/Type/ArrayShapeUnsealedTypeNode.php @@ -29,4 +29,18 @@ public function __toString(): string return sprintf('<%s>', $this->valueType); } + /** + * @param array $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/src/Ast/Type/ArrayTypeNode.php b/src/Ast/Type/ArrayTypeNode.php index 84e5c2a..c9d6041 100644 --- a/src/Ast/Type/ArrayTypeNode.php +++ b/src/Ast/Type/ArrayTypeNode.php @@ -29,4 +29,18 @@ public function __toString(): string return $this->type . '[]'; } + /** + * @param array $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/src/Ast/Type/CallableTypeNode.php b/src/Ast/Type/CallableTypeNode.php index 7855b3b..ea34a55 100644 --- a/src/Ast/Type/CallableTypeNode.php +++ b/src/Ast/Type/CallableTypeNode.php @@ -46,4 +46,18 @@ public function __toString(): string return "{$this->identifier}{$template}({$parameters}): {$returnType}"; } + /** + * @param array $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/src/Ast/Type/CallableTypeParameterNode.php b/src/Ast/Type/CallableTypeParameterNode.php index f90a767..37c34ce 100644 --- a/src/Ast/Type/CallableTypeParameterNode.php +++ b/src/Ast/Type/CallableTypeParameterNode.php @@ -40,4 +40,18 @@ public function __toString(): string return trim("{$type}{$isReference}{$isVariadic}{$this->parameterName}") . $isOptional; } + /** + * @param array $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/src/Ast/Type/ConditionalTypeForParameterNode.php b/src/Ast/Type/ConditionalTypeForParameterNode.php index 4c120d2..32bcc53 100644 --- a/src/Ast/Type/ConditionalTypeForParameterNode.php +++ b/src/Ast/Type/ConditionalTypeForParameterNode.php @@ -41,4 +41,18 @@ public function __toString(): string ); } + /** + * @param array $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/src/Ast/Type/ConditionalTypeNode.php b/src/Ast/Type/ConditionalTypeNode.php index 89c1c63..7970a70 100644 --- a/src/Ast/Type/ConditionalTypeNode.php +++ b/src/Ast/Type/ConditionalTypeNode.php @@ -41,4 +41,18 @@ public function __toString(): string ); } + /** + * @param array $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/src/Ast/Type/ConstTypeNode.php b/src/Ast/Type/ConstTypeNode.php index 22823e5..79f2eed 100644 --- a/src/Ast/Type/ConstTypeNode.php +++ b/src/Ast/Type/ConstTypeNode.php @@ -22,4 +22,18 @@ public function __toString(): string return $this->constExpr->__toString(); } + /** + * @param array $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/src/Ast/Type/GenericTypeNode.php b/src/Ast/Type/GenericTypeNode.php index 1163723..0069aa4 100644 --- a/src/Ast/Type/GenericTypeNode.php +++ b/src/Ast/Type/GenericTypeNode.php @@ -53,4 +53,18 @@ public function __toString(): string return $this->type . '<' . implode(', ', $genericTypes) . '>'; } + /** + * @param array $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/src/Ast/Type/IdentifierTypeNode.php b/src/Ast/Type/IdentifierTypeNode.php index aaef59f..591edca 100644 --- a/src/Ast/Type/IdentifierTypeNode.php +++ b/src/Ast/Type/IdentifierTypeNode.php @@ -21,4 +21,18 @@ public function __toString(): string return $this->name; } + /** + * @param array $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/src/Ast/Type/IntersectionTypeNode.php b/src/Ast/Type/IntersectionTypeNode.php index b389d36..6dbc3ff 100644 --- a/src/Ast/Type/IntersectionTypeNode.php +++ b/src/Ast/Type/IntersectionTypeNode.php @@ -33,4 +33,18 @@ public function __toString(): string }, $this->types)) . ')'; } + /** + * @param array $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/src/Ast/Type/InvalidTypeNode.php b/src/Ast/Type/InvalidTypeNode.php index 318176e..a03fc18 100644 --- a/src/Ast/Type/InvalidTypeNode.php +++ b/src/Ast/Type/InvalidTypeNode.php @@ -35,4 +35,19 @@ public function __toString(): string return '*Invalid type*'; } + /** + * @param array $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/src/Ast/Type/NullableTypeNode.php b/src/Ast/Type/NullableTypeNode.php index 12c017c..f79bad0 100644 --- a/src/Ast/Type/NullableTypeNode.php +++ b/src/Ast/Type/NullableTypeNode.php @@ -21,4 +21,18 @@ public function __toString(): string return '?' . $this->type; } + /** + * @param array $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/src/Ast/Type/ObjectShapeItemNode.php b/src/Ast/Type/ObjectShapeItemNode.php index ed373ec..7ce0622 100644 --- a/src/Ast/Type/ObjectShapeItemNode.php +++ b/src/Ast/Type/ObjectShapeItemNode.php @@ -43,4 +43,18 @@ public function __toString(): string return (string) $this->valueType; } + /** + * @param array $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/src/Ast/Type/ObjectShapeNode.php b/src/Ast/Type/ObjectShapeNode.php index 41dc68c..2e00382 100644 --- a/src/Ast/Type/ObjectShapeNode.php +++ b/src/Ast/Type/ObjectShapeNode.php @@ -28,4 +28,18 @@ public function __toString(): string return 'object{' . implode(', ', $items) . '}'; } + /** + * @param array $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/src/Ast/Type/OffsetAccessTypeNode.php b/src/Ast/Type/OffsetAccessTypeNode.php index 4bd67d8..fa8bde6 100644 --- a/src/Ast/Type/OffsetAccessTypeNode.php +++ b/src/Ast/Type/OffsetAccessTypeNode.php @@ -31,4 +31,18 @@ public function __toString(): string return $this->type . '[' . $this->offset . ']'; } + /** + * @param array $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/src/Ast/Type/ThisTypeNode.php b/src/Ast/Type/ThisTypeNode.php index d94e6f8..b0ccf3b 100644 --- a/src/Ast/Type/ThisTypeNode.php +++ b/src/Ast/Type/ThisTypeNode.php @@ -14,4 +14,18 @@ public function __toString(): string return '$this'; } + /** + * @param array $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/src/Ast/Type/UnionTypeNode.php b/src/Ast/Type/UnionTypeNode.php index 4640513..30c37bd 100644 --- a/src/Ast/Type/UnionTypeNode.php +++ b/src/Ast/Type/UnionTypeNode.php @@ -33,4 +33,18 @@ public function __toString(): string }, $this->types)) . ')'; } + /** + * @param array $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/tests/PHPStan/Parser/PhpDocParserTest.php b/tests/PHPStan/Parser/PhpDocParserTest.php index 287e69a..12a2c40 100644 --- a/tests/PHPStan/Parser/PhpDocParserTest.php +++ b/tests/PHPStan/Parser/PhpDocParserTest.php @@ -73,6 +73,7 @@ use PHPUnit\Framework\TestCase; use function count; use function sprintf; +use function var_export; use const DIRECTORY_SEPARATOR; use const PHP_EOL; @@ -151,6 +152,10 @@ private function executeTestParse(PhpDocParser $phpDocParser, string $label, str $this->assertEquals($expectedPhpDocNode, $actualPhpDocNode, $label); $this->assertSame((string) $expectedPhpDocNode, (string) $actualPhpDocNode, $label); $this->assertSame(Lexer::TOKEN_END, $tokens->currentTokenType(), $label); + + $serialized = var_export($actualPhpDocNode, true); + $readData = eval('return ' . $serialized . ';'); + $this->assertEquals($actualPhpDocNode, $readData); } public function provideParamTagsData(): Iterator @@ -7618,6 +7623,14 @@ public function testLinesAndIndexes(string $phpDoc, array $childrenLines): void $this->assertSame($childrenLines[$i][2], $child->getAttribute(Attribute::START_INDEX)); $this->assertSame($childrenLines[$i][3], $child->getAttribute(Attribute::END_INDEX)); } + + $serialized = var_export($phpDocNode, true); + $readData = eval('return ' . $serialized . ';'); + $this->assertEquals($phpDocNode, $readData); + + $serialized = var_export($phpDocNode, true); + $readData = eval('return ' . $serialized . ';'); + $this->assertEquals($phpDocNode, $readData); } /** @@ -7818,7 +7831,9 @@ public function testVerifyAttributes(string $label, string $input): void $visitor = new NodeCollectingVisitor(); $traverser = new NodeTraverser([$visitor]); - $traverser->traverse([$phpDocParser->parse($tokens)]); + + $phpDocNode = $phpDocParser->parse($tokens); + $traverser->traverse([$phpDocNode]); foreach ($visitor->nodes as $node) { $this->assertNotNull($node->getAttribute(Attribute::START_LINE), sprintf('%s: %s', $label, $node)); @@ -7826,6 +7841,10 @@ public function testVerifyAttributes(string $label, string $input): void $this->assertNotNull($node->getAttribute(Attribute::START_INDEX), sprintf('%s: %s', $label, $node)); $this->assertNotNull($node->getAttribute(Attribute::END_INDEX), sprintf('%s: %s', $label, $node)); } + + $serialized = var_export($phpDocNode, true); + $readData = eval('return ' . $serialized . ';'); + $this->assertEquals($phpDocNode, $readData); } /** @@ -7841,7 +7860,9 @@ public function testDoctrine( { $parser = new DocParser(); $parser->addNamespace('PHPStan\PhpDocParser\Parser\Doctrine'); - $this->assertEquals($expectedAnnotations, $parser->parse($input, $label), $label); + + $phpDocNode = $parser->parse($input, $label); + $this->assertEquals($expectedAnnotations, $phpDocNode, $label); } /** diff --git a/tests/PHPStan/Parser/TypeParserTest.php b/tests/PHPStan/Parser/TypeParserTest.php index 3ff7a86..b0123ef 100644 --- a/tests/PHPStan/Parser/TypeParserTest.php +++ b/tests/PHPStan/Parser/TypeParserTest.php @@ -40,6 +40,7 @@ use PHPUnit\Framework\TestCase; use function get_class; use function strpos; +use function var_export; use const PHP_EOL; class TypeParserTest extends TestCase @@ -84,6 +85,10 @@ public function testParse(string $input, $expectedResult, int $nextTokenType = L $this->assertPrintedNodeViaToString($typeNode); $this->assertPrintedNodeViaPrinter($typeNode); + + $serialized = var_export($typeNode, true); + $readData = eval('return ' . $serialized . ';'); + $this->assertEquals($typeNode, $readData); } private function assertPrintedNodeViaToString(TypeNode $typeNode): void @@ -139,6 +144,10 @@ public function testVerifyAttributes(string $input, $expectedResult): void $this->unsetAllAttributesButComments($expectedResult), $this->unsetAllAttributesButComments($typeNode), ); + + $serialized = var_export($typeNode, true); + $readData = eval('return ' . $serialized . ';'); + $this->assertEquals($typeNode, $readData); } private function unsetAllAttributes(Node $node): Node @@ -3443,6 +3452,10 @@ public function testLinesAndIndexes(string $input, array $assertions): void } $this->assertSame($expectedContent, $content); } + + $serialized = var_export($typeNode, true); + $readData = eval('return ' . $serialized . ';'); + $this->assertEquals($typeNode, $readData); } }