diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..410fc598 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.php] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab +indent_size = 4 diff --git a/build-cs/composer.json b/build-cs/composer.json index 7a3d4e64..4e95b395 100644 --- a/build-cs/composer.json +++ b/build-cs/composer.json @@ -3,8 +3,9 @@ "php": "^7.1 || ^8.0" }, "require-dev": { - "consistence/coding-standard": "^3.10", + "consistence-community/coding-standard": "^3.10", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", + "squizlabs/php_codesniffer": "^3.5", "slevomat/coding-standard": "^6.4.1" } } diff --git a/build.xml b/build.xml index 04716105..7d72b164 100644 --- a/build.xml +++ b/build.xml @@ -60,7 +60,6 @@ - - + diff --git a/src/Ast/BaseNode.php b/src/Ast/BaseNode.php new file mode 100644 index 00000000..f14ca0b7 --- /dev/null +++ b/src/Ast/BaseNode.php @@ -0,0 +1,37 @@ + */ + private $attributes = []; + + /** + * @param string $key + * @param mixed $value + */ + public function setAttribute(string $key, $value): void + { + $this->attributes[$key] = $value; + } + + public function hasAttribute(string $key): bool + { + return array_key_exists($key, $this->attributes); + } + + /** + * @return mixed|null + */ + public function getAttribute(string $key) + { + if ($this->hasAttribute($key)) { + return $this->attributes[$key]; + } + + return null; + } + +} diff --git a/src/Ast/ConstExpr/ConstExprArrayItemNode.php b/src/Ast/ConstExpr/ConstExprArrayItemNode.php index 9456e95d..16662026 100644 --- a/src/Ast/ConstExpr/ConstExprArrayItemNode.php +++ b/src/Ast/ConstExpr/ConstExprArrayItemNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprArrayItemNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprArrayItemNode extends BaseNode implements ConstExprNode { /** @var ConstExprNode|null */ diff --git a/src/Ast/ConstExpr/ConstExprArrayNode.php b/src/Ast/ConstExpr/ConstExprArrayNode.php index 215c5a37..ec5de3a4 100644 --- a/src/Ast/ConstExpr/ConstExprArrayNode.php +++ b/src/Ast/ConstExpr/ConstExprArrayNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprArrayNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprArrayNode extends BaseNode implements ConstExprNode { /** @var ConstExprArrayItemNode[] */ diff --git a/src/Ast/ConstExpr/ConstExprFalseNode.php b/src/Ast/ConstExpr/ConstExprFalseNode.php index fae8af1b..496d11bc 100644 --- a/src/Ast/ConstExpr/ConstExprFalseNode.php +++ b/src/Ast/ConstExpr/ConstExprFalseNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprFalseNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprFalseNode extends BaseNode implements ConstExprNode { public function __toString(): string diff --git a/src/Ast/ConstExpr/ConstExprFloatNode.php b/src/Ast/ConstExpr/ConstExprFloatNode.php index 0f81c418..96a3081d 100644 --- a/src/Ast/ConstExpr/ConstExprFloatNode.php +++ b/src/Ast/ConstExpr/ConstExprFloatNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprFloatNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprFloatNode extends BaseNode implements ConstExprNode { /** @var string */ diff --git a/src/Ast/ConstExpr/ConstExprIntegerNode.php b/src/Ast/ConstExpr/ConstExprIntegerNode.php index 949ba5cb..bcae3b3f 100644 --- a/src/Ast/ConstExpr/ConstExprIntegerNode.php +++ b/src/Ast/ConstExpr/ConstExprIntegerNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprIntegerNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprIntegerNode extends BaseNode implements ConstExprNode { /** @var string */ diff --git a/src/Ast/ConstExpr/ConstExprNullNode.php b/src/Ast/ConstExpr/ConstExprNullNode.php index 1d51eb80..38c13999 100644 --- a/src/Ast/ConstExpr/ConstExprNullNode.php +++ b/src/Ast/ConstExpr/ConstExprNullNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprNullNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprNullNode extends BaseNode implements ConstExprNode { public function __toString(): string diff --git a/src/Ast/ConstExpr/ConstExprStringNode.php b/src/Ast/ConstExpr/ConstExprStringNode.php index d9c720a0..14c459bc 100644 --- a/src/Ast/ConstExpr/ConstExprStringNode.php +++ b/src/Ast/ConstExpr/ConstExprStringNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprStringNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprStringNode extends BaseNode implements ConstExprNode { /** @var string */ diff --git a/src/Ast/ConstExpr/ConstExprTrueNode.php b/src/Ast/ConstExpr/ConstExprTrueNode.php index b0e3c003..99d3d0d6 100644 --- a/src/Ast/ConstExpr/ConstExprTrueNode.php +++ b/src/Ast/ConstExpr/ConstExprTrueNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstExprTrueNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstExprTrueNode extends BaseNode implements ConstExprNode { public function __toString(): string diff --git a/src/Ast/ConstExpr/ConstFetchNode.php b/src/Ast/ConstExpr/ConstFetchNode.php index a432741d..3fe161ce 100644 --- a/src/Ast/ConstExpr/ConstFetchNode.php +++ b/src/Ast/ConstExpr/ConstFetchNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\ConstExpr; -class ConstFetchNode implements ConstExprNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ConstFetchNode extends BaseNode implements ConstExprNode { /** @var string class name for class constants or empty string for non-class constants */ diff --git a/src/Ast/PhpDoc/DeprecatedTagValueNode.php b/src/Ast/PhpDoc/DeprecatedTagValueNode.php index 315d902b..02509b60 100644 --- a/src/Ast/PhpDoc/DeprecatedTagValueNode.php +++ b/src/Ast/PhpDoc/DeprecatedTagValueNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; -class DeprecatedTagValueNode implements PhpDocTagValueNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class DeprecatedTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var string (may be empty) */ diff --git a/src/Ast/PhpDoc/ExtendsTagValueNode.php b/src/Ast/PhpDoc/ExtendsTagValueNode.php index 513f2975..f938407f 100644 --- a/src/Ast/PhpDoc/ExtendsTagValueNode.php +++ b/src/Ast/PhpDoc/ExtendsTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; -class ExtendsTagValueNode implements PhpDocTagValueNode +class ExtendsTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var GenericTypeNode */ diff --git a/src/Ast/PhpDoc/GenericTagValueNode.php b/src/Ast/PhpDoc/GenericTagValueNode.php index 97518ab6..eaf681fa 100644 --- a/src/Ast/PhpDoc/GenericTagValueNode.php +++ b/src/Ast/PhpDoc/GenericTagValueNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; -class GenericTagValueNode implements PhpDocTagValueNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class GenericTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var string (may be empty) */ diff --git a/src/Ast/PhpDoc/ImplementsTagValueNode.php b/src/Ast/PhpDoc/ImplementsTagValueNode.php index 7691d93a..3fb88055 100644 --- a/src/Ast/PhpDoc/ImplementsTagValueNode.php +++ b/src/Ast/PhpDoc/ImplementsTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; -class ImplementsTagValueNode implements PhpDocTagValueNode +class ImplementsTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var GenericTypeNode */ diff --git a/src/Ast/PhpDoc/InvalidTagValueNode.php b/src/Ast/PhpDoc/InvalidTagValueNode.php index 150acae5..bd52f106 100644 --- a/src/Ast/PhpDoc/InvalidTagValueNode.php +++ b/src/Ast/PhpDoc/InvalidTagValueNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; -class InvalidTagValueNode implements PhpDocTagValueNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class InvalidTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var string (may be empty) */ diff --git a/src/Ast/PhpDoc/MethodTagValueNode.php b/src/Ast/PhpDoc/MethodTagValueNode.php index 8f5035c3..401b2482 100644 --- a/src/Ast/PhpDoc/MethodTagValueNode.php +++ b/src/Ast/PhpDoc/MethodTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class MethodTagValueNode implements PhpDocTagValueNode +class MethodTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var bool */ diff --git a/src/Ast/PhpDoc/MethodTagValueParameterNode.php b/src/Ast/PhpDoc/MethodTagValueParameterNode.php index f7409f3e..c399db7e 100644 --- a/src/Ast/PhpDoc/MethodTagValueParameterNode.php +++ b/src/Ast/PhpDoc/MethodTagValueParameterNode.php @@ -2,11 +2,12 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class MethodTagValueParameterNode implements Node +class MethodTagValueParameterNode extends BaseNode implements Node { /** @var TypeNode|null */ diff --git a/src/Ast/PhpDoc/MixinTagValueNode.php b/src/Ast/PhpDoc/MixinTagValueNode.php index 8290181d..14c9c925 100644 --- a/src/Ast/PhpDoc/MixinTagValueNode.php +++ b/src/Ast/PhpDoc/MixinTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class MixinTagValueNode implements PhpDocTagValueNode +class MixinTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var TypeNode */ diff --git a/src/Ast/PhpDoc/ParamTagValueNode.php b/src/Ast/PhpDoc/ParamTagValueNode.php index 04710a7b..78f3233c 100644 --- a/src/Ast/PhpDoc/ParamTagValueNode.php +++ b/src/Ast/PhpDoc/ParamTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class ParamTagValueNode implements PhpDocTagValueNode +class ParamTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var TypeNode */ diff --git a/src/Ast/PhpDoc/PhpDocNode.php b/src/Ast/PhpDoc/PhpDocNode.php index ace03b1f..2cfbe6fd 100644 --- a/src/Ast/PhpDoc/PhpDocNode.php +++ b/src/Ast/PhpDoc/PhpDocNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Node; -class PhpDocNode implements Node +class PhpDocNode extends BaseNode implements Node { /** @var PhpDocChildNode[] */ diff --git a/src/Ast/PhpDoc/PhpDocTagNode.php b/src/Ast/PhpDoc/PhpDocTagNode.php index be3043bf..169d669b 100644 --- a/src/Ast/PhpDoc/PhpDocTagNode.php +++ b/src/Ast/PhpDoc/PhpDocTagNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; -class PhpDocTagNode implements PhpDocChildNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class PhpDocTagNode extends BaseNode implements PhpDocChildNode { /** @var string */ diff --git a/src/Ast/PhpDoc/PhpDocTextNode.php b/src/Ast/PhpDoc/PhpDocTextNode.php index 2a4f8a4c..a52ffdaf 100644 --- a/src/Ast/PhpDoc/PhpDocTextNode.php +++ b/src/Ast/PhpDoc/PhpDocTextNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; -class PhpDocTextNode implements PhpDocChildNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class PhpDocTextNode extends BaseNode implements PhpDocChildNode { /** @var string */ diff --git a/src/Ast/PhpDoc/PropertyTagValueNode.php b/src/Ast/PhpDoc/PropertyTagValueNode.php index bca55a7e..12e9ef4a 100644 --- a/src/Ast/PhpDoc/PropertyTagValueNode.php +++ b/src/Ast/PhpDoc/PropertyTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class PropertyTagValueNode implements PhpDocTagValueNode +class PropertyTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var TypeNode */ diff --git a/src/Ast/PhpDoc/ReturnTagValueNode.php b/src/Ast/PhpDoc/ReturnTagValueNode.php index 254d3f87..34cfad4f 100644 --- a/src/Ast/PhpDoc/ReturnTagValueNode.php +++ b/src/Ast/PhpDoc/ReturnTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class ReturnTagValueNode implements PhpDocTagValueNode +class ReturnTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var TypeNode */ diff --git a/src/Ast/PhpDoc/TemplateTagValueNode.php b/src/Ast/PhpDoc/TemplateTagValueNode.php index 5847df22..addfc453 100644 --- a/src/Ast/PhpDoc/TemplateTagValueNode.php +++ b/src/Ast/PhpDoc/TemplateTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class TemplateTagValueNode implements PhpDocTagValueNode +class TemplateTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var string */ diff --git a/src/Ast/PhpDoc/ThrowsTagValueNode.php b/src/Ast/PhpDoc/ThrowsTagValueNode.php index 32ae12d2..f05d82f7 100644 --- a/src/Ast/PhpDoc/ThrowsTagValueNode.php +++ b/src/Ast/PhpDoc/ThrowsTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class ThrowsTagValueNode implements PhpDocTagValueNode +class ThrowsTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var TypeNode */ diff --git a/src/Ast/PhpDoc/UsesTagValueNode.php b/src/Ast/PhpDoc/UsesTagValueNode.php index 20b19390..ee4b290c 100644 --- a/src/Ast/PhpDoc/UsesTagValueNode.php +++ b/src/Ast/PhpDoc/UsesTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; -class UsesTagValueNode implements PhpDocTagValueNode +class UsesTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var GenericTypeNode */ diff --git a/src/Ast/PhpDoc/VarTagValueNode.php b/src/Ast/PhpDoc/VarTagValueNode.php index 2965ce7c..54b74692 100644 --- a/src/Ast/PhpDoc/VarTagValueNode.php +++ b/src/Ast/PhpDoc/VarTagValueNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\PhpDoc; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; -class VarTagValueNode implements PhpDocTagValueNode +class VarTagValueNode extends BaseNode implements PhpDocTagValueNode { /** @var TypeNode */ diff --git a/src/Ast/Type/ArrayShapeItemNode.php b/src/Ast/Type/ArrayShapeItemNode.php index b4996e90..58444873 100644 --- a/src/Ast/Type/ArrayShapeItemNode.php +++ b/src/Ast/Type/ArrayShapeItemNode.php @@ -2,10 +2,11 @@ namespace PHPStan\PhpDocParser\Ast\Type; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; -class ArrayShapeItemNode implements TypeNode +class ArrayShapeItemNode extends BaseNode implements TypeNode { /** @var ConstExprIntegerNode|ConstExprStringNode|IdentifierTypeNode|null */ diff --git a/src/Ast/Type/ArrayShapeNode.php b/src/Ast/Type/ArrayShapeNode.php index 74df4ab3..23590ec6 100644 --- a/src/Ast/Type/ArrayShapeNode.php +++ b/src/Ast/Type/ArrayShapeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class ArrayShapeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ArrayShapeNode extends BaseNode implements TypeNode { /** @var ArrayShapeItemNode[] */ diff --git a/src/Ast/Type/ArrayTypeNode.php b/src/Ast/Type/ArrayTypeNode.php index b01d083c..97e0834e 100644 --- a/src/Ast/Type/ArrayTypeNode.php +++ b/src/Ast/Type/ArrayTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class ArrayTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ArrayTypeNode extends BaseNode implements TypeNode { /** @var TypeNode */ diff --git a/src/Ast/Type/CallableTypeNode.php b/src/Ast/Type/CallableTypeNode.php index 2f4bf7c5..10313806 100644 --- a/src/Ast/Type/CallableTypeNode.php +++ b/src/Ast/Type/CallableTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class CallableTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class CallableTypeNode extends BaseNode implements TypeNode { /** @var IdentifierTypeNode */ diff --git a/src/Ast/Type/CallableTypeParameterNode.php b/src/Ast/Type/CallableTypeParameterNode.php index 3503318d..c17420d7 100644 --- a/src/Ast/Type/CallableTypeParameterNode.php +++ b/src/Ast/Type/CallableTypeParameterNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\Type; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\Node; -class CallableTypeParameterNode implements Node +class CallableTypeParameterNode extends BaseNode implements Node { /** @var TypeNode */ diff --git a/src/Ast/Type/ConstTypeNode.php b/src/Ast/Type/ConstTypeNode.php index ee9f14da..4333bdac 100644 --- a/src/Ast/Type/ConstTypeNode.php +++ b/src/Ast/Type/ConstTypeNode.php @@ -2,9 +2,10 @@ namespace PHPStan\PhpDocParser\Ast\Type; +use PHPStan\PhpDocParser\Ast\BaseNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; -class ConstTypeNode implements TypeNode +class ConstTypeNode extends BaseNode implements TypeNode { /** @var ConstExprNode */ diff --git a/src/Ast/Type/GenericTypeNode.php b/src/Ast/Type/GenericTypeNode.php index 4dcc9c8f..39aa49c0 100644 --- a/src/Ast/Type/GenericTypeNode.php +++ b/src/Ast/Type/GenericTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class GenericTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class GenericTypeNode extends BaseNode implements TypeNode { /** @var IdentifierTypeNode */ diff --git a/src/Ast/Type/IdentifierTypeNode.php b/src/Ast/Type/IdentifierTypeNode.php index 9ca389cc..903e6796 100644 --- a/src/Ast/Type/IdentifierTypeNode.php +++ b/src/Ast/Type/IdentifierTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class IdentifierTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class IdentifierTypeNode extends BaseNode implements TypeNode { /** @var string */ diff --git a/src/Ast/Type/IntersectionTypeNode.php b/src/Ast/Type/IntersectionTypeNode.php index 60341187..cdac1b19 100644 --- a/src/Ast/Type/IntersectionTypeNode.php +++ b/src/Ast/Type/IntersectionTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class IntersectionTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class IntersectionTypeNode extends BaseNode implements TypeNode { /** @var TypeNode[] */ diff --git a/src/Ast/Type/NullableTypeNode.php b/src/Ast/Type/NullableTypeNode.php index 98c73647..c384fca5 100644 --- a/src/Ast/Type/NullableTypeNode.php +++ b/src/Ast/Type/NullableTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class NullableTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class NullableTypeNode extends BaseNode implements TypeNode { /** @var TypeNode */ diff --git a/src/Ast/Type/ThisTypeNode.php b/src/Ast/Type/ThisTypeNode.php index 06a3537e..c026f76a 100644 --- a/src/Ast/Type/ThisTypeNode.php +++ b/src/Ast/Type/ThisTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class ThisTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class ThisTypeNode extends BaseNode implements TypeNode { public function __toString(): string diff --git a/src/Ast/Type/UnionTypeNode.php b/src/Ast/Type/UnionTypeNode.php index 235b6d5a..76bb07c9 100644 --- a/src/Ast/Type/UnionTypeNode.php +++ b/src/Ast/Type/UnionTypeNode.php @@ -2,7 +2,9 @@ namespace PHPStan\PhpDocParser\Ast\Type; -class UnionTypeNode implements TypeNode +use PHPStan\PhpDocParser\Ast\BaseNode; + +class UnionTypeNode extends BaseNode implements TypeNode { /** @var TypeNode[] */ diff --git a/tests/PHPStan/Ast/Attributes/AttributesTest.php b/tests/PHPStan/Ast/Attributes/AttributesTest.php new file mode 100644 index 00000000..a20747ec --- /dev/null +++ b/tests/PHPStan/Ast/Attributes/AttributesTest.php @@ -0,0 +1,45 @@ +tokenize($input)); + $this->phpDocNode = $phpDocParser->parse($tokens); + } + + public function testGetAttribute(): void + { + $unKnownValue = $this->phpDocNode->getAttribute('unknown'); + $this->assertNull($unKnownValue); + } + + public function testSetAttribute(): void + { + $this->phpDocNode->setAttribute('key', 'value'); + + $attributeValue = $this->phpDocNode->getAttribute('key'); + $this->assertSame('value', $attributeValue); + } + +}