diff --git a/src/Node/Expression/ObjectCreationExpression.php b/src/Node/Expression/ObjectCreationExpression.php index 9d39be57..061a3137 100644 --- a/src/Node/Expression/ObjectCreationExpression.php +++ b/src/Node/Expression/ObjectCreationExpression.php @@ -6,6 +6,7 @@ namespace Microsoft\PhpParser\Node\Expression; +use Microsoft\PhpParser\Node\AttributeGroup; use Microsoft\PhpParser\Node\ClassBaseClause; use Microsoft\PhpParser\Node\ClassInterfaceClause; use Microsoft\PhpParser\Node\ClassMembersNode; @@ -19,6 +20,9 @@ class ObjectCreationExpression extends Expression { /** @var Token */ public $newKeword; + /** @var AttributeGroup[]|null optional attributes of an anonymous class. */ + public $attributes; + /** @var QualifiedName|Variable|Token */ public $classTypeDesignator; @@ -41,7 +45,8 @@ class ObjectCreationExpression extends Expression { public $classMembers; const CHILD_NAMES = [ - 'newKeword', // TODO + 'newKeword', + 'attributes', 'classTypeDesignator', 'openParen', 'argumentExpressionList', diff --git a/src/Node/Statement/InterfaceDeclaration.php b/src/Node/Statement/InterfaceDeclaration.php index e11261f5..4a33de01 100644 --- a/src/Node/Statement/InterfaceDeclaration.php +++ b/src/Node/Statement/InterfaceDeclaration.php @@ -9,6 +9,7 @@ use Microsoft\PhpParser\ClassLike; use Microsoft\PhpParser\NamespacedNameInterface; use Microsoft\PhpParser\NamespacedNameTrait; +use Microsoft\PhpParser\Node\AttributeGroup; use Microsoft\PhpParser\Node\InterfaceBaseClause; use Microsoft\PhpParser\Node\InterfaceMembers; use Microsoft\PhpParser\Node\StatementNode; @@ -17,6 +18,9 @@ class InterfaceDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike { use NamespacedNameTrait; + /** @var AttributeGroup[]|null */ + public $attributes; + /** @var Token */ public $interfaceKeyword; @@ -30,6 +34,7 @@ class InterfaceDeclaration extends StatementNode implements NamespacedNameInterf public $interfaceMembers; const CHILD_NAMES = [ + 'attributes', 'interfaceKeyword', 'name', 'interfaceBaseClause', diff --git a/src/Node/Statement/TraitDeclaration.php b/src/Node/Statement/TraitDeclaration.php index 9583faf4..05a73264 100644 --- a/src/Node/Statement/TraitDeclaration.php +++ b/src/Node/Statement/TraitDeclaration.php @@ -9,6 +9,7 @@ use Microsoft\PhpParser\ClassLike; use Microsoft\PhpParser\NamespacedNameInterface; use Microsoft\PhpParser\NamespacedNameTrait; +use Microsoft\PhpParser\Node\AttributeGroup; use Microsoft\PhpParser\Node\StatementNode; use Microsoft\PhpParser\Node\TraitMembers; use Microsoft\PhpParser\Token; @@ -16,6 +17,9 @@ class TraitDeclaration extends StatementNode implements NamespacedNameInterface, ClassLike { use NamespacedNameTrait; + /** @var AttributeGroup[]|null */ + public $attributes; + /** @var Token */ public $traitKeyword; @@ -26,6 +30,7 @@ class TraitDeclaration extends StatementNode implements NamespacedNameInterface, public $traitMembers; const CHILD_NAMES = [ + 'attributes', 'traitKeyword', 'name', 'traitMembers' diff --git a/src/Parser.php b/src/Parser.php index 5bbb8719..c318c69f 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -711,6 +711,12 @@ private function parseAttributeStatement($parentNode) { if ($parentNode instanceof ClassMembersNode) { // Create a class element or a MissingMemberDeclaration $statement = $this->parseClassElementFn()($parentNode); + } elseif ($parentNode instanceof TraitMembers) { + // Create a trait element or a MissingMemberDeclaration + $statement = $this->parseTraitElementFn()($parentNode); + } elseif ($parentNode instanceof InterfaceMembers) { + // Create an interface element or a MissingMemberDeclaration + $statement = $this->parseInterfaceElementFn()($parentNode); } else { // Classlikes, anonymous functions, global functions, and arrow functions can have attributes. Global constants cannot. if (in_array($this->token->kind, [TokenKind::ClassKeyword, TokenKind::TraitKeyword, TokenKind::InterfaceKeyword, TokenKind::AbstractKeyword, TokenKind::FinalKeyword, TokenKind::FunctionKeyword, TokenKind::FnKeyword], true) || @@ -726,6 +732,8 @@ private function parseAttributeStatement($parentNode) { if ($statement instanceof FunctionLike || $statement instanceof ClassDeclaration || + $statement instanceof TraitDeclaration || + $statement instanceof InterfaceDeclaration || $statement instanceof ClassConstDeclaration || $statement instanceof PropertyDeclaration || $statement instanceof MissingDeclaration || @@ -3088,6 +3096,12 @@ private function parseObjectCreationExpression($parentNode) { // TODO - add tests for this scenario $oldIsParsingObjectCreationExpression = $this->isParsingObjectCreationExpression; $this->isParsingObjectCreationExpression = true; + + if ($this->getCurrentToken()->kind === TokenKind::AttributeToken) { + // Attributes such as `new #[MyAttr] class` can only be used with anonymous class declarations. + // But handle this like $objectCreationExpression->classMembers and leave it up to the applications to detect the invalid combination. + $objectCreationExpression->attributes = $this->parseAttributeGroups($objectCreationExpression); + } $objectCreationExpression->classTypeDesignator = $this->eatOptional1(TokenKind::ClassKeyword) ?? $this->parseExpression($objectCreationExpression); @@ -3311,6 +3325,9 @@ private function parseInterfaceElementFn() { case TokenKind::FunctionKeyword: return $this->parseMethodDeclaration($parentNode, $modifiers); + case TokenKind::AttributeToken: + return $this->parseAttributeStatement($parentNode); + default: $missingInterfaceMemberDeclaration = new MissingMemberDeclaration(); $missingInterfaceMemberDeclaration->parent = $parentNode; @@ -3491,6 +3508,9 @@ private function parseTraitElementFn() { case TokenKind::UseKeyword: return $this->parseTraitUseClause($parentNode); + case TokenKind::AttributeToken: + return $this->parseAttributeStatement($parentNode); + default: return $this->parseRemainingPropertyDeclarationOrMissingMemberDeclaration($parentNode, $modifiers); } diff --git a/tests/cases/parser/callExpression14.php.tree b/tests/cases/parser/callExpression14.php.tree index 690a4456..a7b92daa 100644 --- a/tests/cases/parser/callExpression14.php.tree +++ b/tests/cases/parser/callExpression14.php.tree @@ -27,6 +27,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/interfaceDeclaration1.php.tree b/tests/cases/parser/interfaceDeclaration1.php.tree index 01061e11..7bbb622d 100644 --- a/tests/cases/parser/interfaceDeclaration1.php.tree +++ b/tests/cases/parser/interfaceDeclaration1.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration10.php.tree b/tests/cases/parser/interfaceDeclaration10.php.tree index f874ef4a..73d3248a 100644 --- a/tests/cases/parser/interfaceDeclaration10.php.tree +++ b/tests/cases/parser/interfaceDeclaration10.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration11.php.tree b/tests/cases/parser/interfaceDeclaration11.php.tree index 490688eb..af91234d 100644 --- a/tests/cases/parser/interfaceDeclaration11.php.tree +++ b/tests/cases/parser/interfaceDeclaration11.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration12.php.tree b/tests/cases/parser/interfaceDeclaration12.php.tree index 9b3df05d..2660976d 100644 --- a/tests/cases/parser/interfaceDeclaration12.php.tree +++ b/tests/cases/parser/interfaceDeclaration12.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration13.php.tree b/tests/cases/parser/interfaceDeclaration13.php.tree index 4626be5a..bc9988d2 100644 --- a/tests/cases/parser/interfaceDeclaration13.php.tree +++ b/tests/cases/parser/interfaceDeclaration13.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration14.php.tree b/tests/cases/parser/interfaceDeclaration14.php.tree index 60fb48ff..5820afac 100644 --- a/tests/cases/parser/interfaceDeclaration14.php.tree +++ b/tests/cases/parser/interfaceDeclaration14.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration15.php.tree b/tests/cases/parser/interfaceDeclaration15.php.tree index 8d1ac378..71c49c78 100644 --- a/tests/cases/parser/interfaceDeclaration15.php.tree +++ b/tests/cases/parser/interfaceDeclaration15.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration16.php.tree b/tests/cases/parser/interfaceDeclaration16.php.tree index 09c94bdb..436abcdf 100644 --- a/tests/cases/parser/interfaceDeclaration16.php.tree +++ b/tests/cases/parser/interfaceDeclaration16.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration2.php.tree b/tests/cases/parser/interfaceDeclaration2.php.tree index ea6155ee..d992273d 100644 --- a/tests/cases/parser/interfaceDeclaration2.php.tree +++ b/tests/cases/parser/interfaceDeclaration2.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration3.php.tree b/tests/cases/parser/interfaceDeclaration3.php.tree index ce5723c7..16146be5 100644 --- a/tests/cases/parser/interfaceDeclaration3.php.tree +++ b/tests/cases/parser/interfaceDeclaration3.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration4.php.tree b/tests/cases/parser/interfaceDeclaration4.php.tree index 4746966c..1894ce2f 100644 --- a/tests/cases/parser/interfaceDeclaration4.php.tree +++ b/tests/cases/parser/interfaceDeclaration4.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration5.php.tree b/tests/cases/parser/interfaceDeclaration5.php.tree index 126feb61..4c523c43 100644 --- a/tests/cases/parser/interfaceDeclaration5.php.tree +++ b/tests/cases/parser/interfaceDeclaration5.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration7.php.tree b/tests/cases/parser/interfaceDeclaration7.php.tree index 6b9ad3cc..2fa52201 100644 --- a/tests/cases/parser/interfaceDeclaration7.php.tree +++ b/tests/cases/parser/interfaceDeclaration7.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration8.php.tree b/tests/cases/parser/interfaceDeclaration8.php.tree index c7371d0d..bc9e1ce8 100644 --- a/tests/cases/parser/interfaceDeclaration8.php.tree +++ b/tests/cases/parser/interfaceDeclaration8.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/interfaceDeclaration9.php.tree b/tests/cases/parser/interfaceDeclaration9.php.tree index fa9b2b50..02faee75 100644 --- a/tests/cases/parser/interfaceDeclaration9.php.tree +++ b/tests/cases/parser/interfaceDeclaration9.php.tree @@ -13,6 +13,7 @@ }, { "InterfaceDeclaration": { + "attributes": null, "interfaceKeyword": { "kind": "InterfaceKeyword", "textLength": 9 diff --git a/tests/cases/parser/listExpression9.php.tree b/tests/cases/parser/listExpression9.php.tree index d7f561df..ba4418e5 100644 --- a/tests/cases/parser/listExpression9.php.tree +++ b/tests/cases/parser/listExpression9.php.tree @@ -128,6 +128,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression1.php.tree b/tests/cases/parser/objectCreationExpression1.php.tree index cb6a3944..00ca4152 100644 --- a/tests/cases/parser/objectCreationExpression1.php.tree +++ b/tests/cases/parser/objectCreationExpression1.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression10.php.tree b/tests/cases/parser/objectCreationExpression10.php.tree index d7f3808c..42d18bc9 100644 --- a/tests/cases/parser/objectCreationExpression10.php.tree +++ b/tests/cases/parser/objectCreationExpression10.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "kind": "ClassKeyword", "textLength": 5 diff --git a/tests/cases/parser/objectCreationExpression11.php.tree b/tests/cases/parser/objectCreationExpression11.php.tree index d93ec036..1954f9f4 100644 --- a/tests/cases/parser/objectCreationExpression11.php.tree +++ b/tests/cases/parser/objectCreationExpression11.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "kind": "ClassKeyword", "textLength": 5 diff --git a/tests/cases/parser/objectCreationExpression12.php.tree b/tests/cases/parser/objectCreationExpression12.php.tree index d7bae397..baf917af 100644 --- a/tests/cases/parser/objectCreationExpression12.php.tree +++ b/tests/cases/parser/objectCreationExpression12.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "kind": "ClassKeyword", "textLength": 5 diff --git a/tests/cases/parser/objectCreationExpression13.php.tree b/tests/cases/parser/objectCreationExpression13.php.tree index 438d856c..58c78dd1 100644 --- a/tests/cases/parser/objectCreationExpression13.php.tree +++ b/tests/cases/parser/objectCreationExpression13.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression14.php.tree b/tests/cases/parser/objectCreationExpression14.php.tree index 17312b59..383e96de 100644 --- a/tests/cases/parser/objectCreationExpression14.php.tree +++ b/tests/cases/parser/objectCreationExpression14.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression15.php.tree b/tests/cases/parser/objectCreationExpression15.php.tree index 02f238c3..e76b933f 100644 --- a/tests/cases/parser/objectCreationExpression15.php.tree +++ b/tests/cases/parser/objectCreationExpression15.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "ScopedPropertyAccessExpression": { "scopeResolutionQualifier": { diff --git a/tests/cases/parser/objectCreationExpression16.php.tree b/tests/cases/parser/objectCreationExpression16.php.tree index 8ba2b71f..96c97be4 100644 --- a/tests/cases/parser/objectCreationExpression16.php.tree +++ b/tests/cases/parser/objectCreationExpression16.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression17.php.tree b/tests/cases/parser/objectCreationExpression17.php.tree index 85666616..44cbfbfa 100644 --- a/tests/cases/parser/objectCreationExpression17.php.tree +++ b/tests/cases/parser/objectCreationExpression17.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression18.php.tree b/tests/cases/parser/objectCreationExpression18.php.tree index b9762c02..24a69562 100644 --- a/tests/cases/parser/objectCreationExpression18.php.tree +++ b/tests/cases/parser/objectCreationExpression18.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "ScopedPropertyAccessExpression": { "scopeResolutionQualifier": { diff --git a/tests/cases/parser/objectCreationExpression19.php.tree b/tests/cases/parser/objectCreationExpression19.php.tree index 479d36fa..8879d481 100644 --- a/tests/cases/parser/objectCreationExpression19.php.tree +++ b/tests/cases/parser/objectCreationExpression19.php.tree @@ -35,6 +35,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "ParenthesizedExpression": { "openParen": { diff --git a/tests/cases/parser/objectCreationExpression2.php.tree b/tests/cases/parser/objectCreationExpression2.php.tree index 0314c16b..5c05c257 100644 --- a/tests/cases/parser/objectCreationExpression2.php.tree +++ b/tests/cases/parser/objectCreationExpression2.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression20.php.tree b/tests/cases/parser/objectCreationExpression20.php.tree index c8a1d73c..3a26db48 100644 --- a/tests/cases/parser/objectCreationExpression20.php.tree +++ b/tests/cases/parser/objectCreationExpression20.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "ParenthesizedExpression": { "openParen": { @@ -31,6 +32,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "ParenthesizedExpression": { "openParen": { @@ -43,6 +45,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/objectCreationExpression3.php.tree b/tests/cases/parser/objectCreationExpression3.php.tree index c7d14b91..ce60efc9 100644 --- a/tests/cases/parser/objectCreationExpression3.php.tree +++ b/tests/cases/parser/objectCreationExpression3.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "Variable": { "dollar": null, diff --git a/tests/cases/parser/objectCreationExpression4.php.tree b/tests/cases/parser/objectCreationExpression4.php.tree index ddc30c14..4e52ea49 100644 --- a/tests/cases/parser/objectCreationExpression4.php.tree +++ b/tests/cases/parser/objectCreationExpression4.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "ParenthesizedExpression": { "openParen": { diff --git a/tests/cases/parser/objectCreationExpression5.php.tree b/tests/cases/parser/objectCreationExpression5.php.tree index 83300827..f7b20102 100644 --- a/tests/cases/parser/objectCreationExpression5.php.tree +++ b/tests/cases/parser/objectCreationExpression5.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "Variable": { "dollar": { diff --git a/tests/cases/parser/objectCreationExpression6.php.tree b/tests/cases/parser/objectCreationExpression6.php.tree index 7b9f0cd4..56fbbec5 100644 --- a/tests/cases/parser/objectCreationExpression6.php.tree +++ b/tests/cases/parser/objectCreationExpression6.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "Variable": { "dollar": { diff --git a/tests/cases/parser/objectCreationExpression7.php.tree b/tests/cases/parser/objectCreationExpression7.php.tree index 64bd69e7..fe293459 100644 --- a/tests/cases/parser/objectCreationExpression7.php.tree +++ b/tests/cases/parser/objectCreationExpression7.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "kind": "ClassKeyword", "textLength": 5 diff --git a/tests/cases/parser/objectCreationExpression8.php.tree b/tests/cases/parser/objectCreationExpression8.php.tree index 9985edc3..139fff8c 100644 --- a/tests/cases/parser/objectCreationExpression8.php.tree +++ b/tests/cases/parser/objectCreationExpression8.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "kind": "ClassKeyword", "textLength": 5 diff --git a/tests/cases/parser/objectCreationExpression9.php.tree b/tests/cases/parser/objectCreationExpression9.php.tree index 4202d39a..6d4efb26 100644 --- a/tests/cases/parser/objectCreationExpression9.php.tree +++ b/tests/cases/parser/objectCreationExpression9.php.tree @@ -19,6 +19,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "kind": "ClassKeyword", "textLength": 5 diff --git a/tests/cases/parser/throwStatement6.php.tree b/tests/cases/parser/throwStatement6.php.tree index 91834210..4bc9ddcc 100644 --- a/tests/cases/parser/throwStatement6.php.tree +++ b/tests/cases/parser/throwStatement6.php.tree @@ -25,6 +25,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/throwStatement7.php.tree b/tests/cases/parser/throwStatement7.php.tree index b45f4fcc..c7b3109e 100644 --- a/tests/cases/parser/throwStatement7.php.tree +++ b/tests/cases/parser/throwStatement7.php.tree @@ -56,6 +56,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, @@ -144,6 +145,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser/traits1.php.tree b/tests/cases/parser/traits1.php.tree index 2547d84f..ed44d2e8 100644 --- a/tests/cases/parser/traits1.php.tree +++ b/tests/cases/parser/traits1.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits10.php.tree b/tests/cases/parser/traits10.php.tree index 5e3d35fa..d732c154 100644 --- a/tests/cases/parser/traits10.php.tree +++ b/tests/cases/parser/traits10.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits12.php.tree b/tests/cases/parser/traits12.php.tree index f1540d68..b65e6221 100644 --- a/tests/cases/parser/traits12.php.tree +++ b/tests/cases/parser/traits12.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits13.php.tree b/tests/cases/parser/traits13.php.tree index b0a450bb..193cf44c 100644 --- a/tests/cases/parser/traits13.php.tree +++ b/tests/cases/parser/traits13.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits14.php.tree b/tests/cases/parser/traits14.php.tree index 77204b89..2ba899aa 100644 --- a/tests/cases/parser/traits14.php.tree +++ b/tests/cases/parser/traits14.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits15.php.tree b/tests/cases/parser/traits15.php.tree index 64d1f220..d16612f9 100644 --- a/tests/cases/parser/traits15.php.tree +++ b/tests/cases/parser/traits15.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits16.php.tree b/tests/cases/parser/traits16.php.tree index 87b08fdc..05ca0147 100644 --- a/tests/cases/parser/traits16.php.tree +++ b/tests/cases/parser/traits16.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits17.php.tree b/tests/cases/parser/traits17.php.tree index c8d98619..638eea31 100644 --- a/tests/cases/parser/traits17.php.tree +++ b/tests/cases/parser/traits17.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits19.php.tree b/tests/cases/parser/traits19.php.tree index 93791ccd..d4514050 100644 --- a/tests/cases/parser/traits19.php.tree +++ b/tests/cases/parser/traits19.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits2.php.tree b/tests/cases/parser/traits2.php.tree index f007a39d..0ef680a6 100644 --- a/tests/cases/parser/traits2.php.tree +++ b/tests/cases/parser/traits2.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits20.php.tree b/tests/cases/parser/traits20.php.tree index 9d2a8c16..a7877fa2 100644 --- a/tests/cases/parser/traits20.php.tree +++ b/tests/cases/parser/traits20.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits3.php.tree b/tests/cases/parser/traits3.php.tree index 5a3b2f22..cddb6f7c 100644 --- a/tests/cases/parser/traits3.php.tree +++ b/tests/cases/parser/traits3.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits4.php.tree b/tests/cases/parser/traits4.php.tree index e1cc93d1..8eb4631f 100644 --- a/tests/cases/parser/traits4.php.tree +++ b/tests/cases/parser/traits4.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits5.php.tree b/tests/cases/parser/traits5.php.tree index 0473b6df..637ff4d7 100644 --- a/tests/cases/parser/traits5.php.tree +++ b/tests/cases/parser/traits5.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits6.php.tree b/tests/cases/parser/traits6.php.tree index 428d6c3b..fe9b274a 100644 --- a/tests/cases/parser/traits6.php.tree +++ b/tests/cases/parser/traits6.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits7.php.tree b/tests/cases/parser/traits7.php.tree index 58b458a8..0b3711f6 100644 --- a/tests/cases/parser/traits7.php.tree +++ b/tests/cases/parser/traits7.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser/traits9.php.tree b/tests/cases/parser/traits9.php.tree index 5294afc1..f92f6734 100644 --- a/tests/cases/parser/traits9.php.tree +++ b/tests/cases/parser/traits9.php.tree @@ -13,6 +13,7 @@ }, { "TraitDeclaration": { + "attributes": null, "traitKeyword": { "kind": "TraitKeyword", "textLength": 5 diff --git a/tests/cases/parser74/throwStatement1.php.tree b/tests/cases/parser74/throwStatement1.php.tree index 0c6710dc..c4cee65b 100644 --- a/tests/cases/parser74/throwStatement1.php.tree +++ b/tests/cases/parser74/throwStatement1.php.tree @@ -68,6 +68,7 @@ "kind": "NewKeyword", "textLength": 3 }, + "attributes": null, "classTypeDesignator": { "QualifiedName": { "globalSpecifier": null, diff --git a/tests/cases/parser80/attributes13.php b/tests/cases/parser80/attributes13.php new file mode 100644 index 00000000..da133e33 --- /dev/null +++ b/tests/cases/parser80/attributes13.php @@ -0,0 +1,3 @@ +' expected.", + "start": 11, + "length": 0 + }, + { + "kind": 0, + "message": "'Expression' expected.", + "start": 11, + "length": 0 + }, + { + "kind": 0, + "message": "';' expected.", + "start": 11, + "length": 0 + } +] \ No newline at end of file diff --git a/tests/cases/parser80/attributes18.php.tree b/tests/cases/parser80/attributes18.php.tree new file mode 100644 index 00000000..d7a8baa2 --- /dev/null +++ b/tests/cases/parser80/attributes18.php.tree @@ -0,0 +1,104 @@ +{ + "SourceFileNode": { + "statementList": [ + { + "InlineHtml": { + "scriptSectionEndTag": null, + "text": null, + "scriptSectionStartTag": { + "kind": "ScriptSectionStartTag", + "textLength": 6 + } + } + }, + { + "ExpressionStatement": { + "expression": { + "ArrowFunctionCreationExpression": { + "attributes": null, + "staticModifier": null, + "functionKeyword": { + "kind": "FnKeyword", + "textLength": 2 + }, + "byRefToken": null, + "name": null, + "openParen": { + "error": "MissingToken", + "kind": "OpenParenToken", + "textLength": 0 + }, + "parameters": { + "ParameterDeclarationList": { + "children": [ + { + "Parameter": { + "attributes": [ + { + "AttributeGroup": { + "startToken": { + "kind": "AttributeToken", + "textLength": 2 + }, + "attributes": null, + "endToken": { + "error": "MissingToken", + "kind": "CloseBracketToken", + "textLength": 0 + } + } + } + ], + "visibilityToken": null, + "questionToken": null, + "typeDeclaration": null, + "otherTypeDeclarations": null, + "byRefToken": null, + "dotDotDotToken": null, + "variableName": { + "error": "MissingToken", + "kind": "VariableName", + "textLength": 0 + }, + "equalsToken": null, + "default": null + } + } + ] + } + }, + "closeParen": { + "error": "MissingToken", + "kind": "CloseParenToken", + "textLength": 0 + }, + "colonToken": null, + "questionToken": null, + "returnType": null, + "otherReturnTypes": null, + "arrowToken": { + "error": "MissingToken", + "kind": "DoubleArrowToken", + "textLength": 0 + }, + "resultExpression": { + "error": "MissingToken", + "kind": "Expression", + "textLength": 0 + } + } + }, + "semicolon": { + "error": "MissingToken", + "kind": "SemicolonToken", + "textLength": 0 + } + } + } + ], + "endOfFileToken": { + "kind": "EndOfFileToken", + "textLength": 0 + } + } +} \ No newline at end of file