File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 66
77namespace Microsoft \PhpParser \Node ;
88
9+ use Microsoft \PhpParser \ModifiedTypeInterface ;
10+ use Microsoft \PhpParser \ModifiedTypeTrait ;
911use Microsoft \PhpParser \Node ;
1012use Microsoft \PhpParser \Node \DelimitedList \ParameterDeclarationList ;
1113use Microsoft \PhpParser \Node \Statement \CompoundStatementNode ;
1214use Microsoft \PhpParser \Token ;
1315
14- class PropertyHook extends Node {
16+ class PropertyHook extends Node implements ModifiedTypeInterface {
17+ use ModifiedTypeTrait;
1518 /** @var AttributeGroup[]|null */
1619 public $ attributes ;
1720
@@ -41,6 +44,7 @@ class PropertyHook extends Node {
4144
4245 const CHILD_NAMES = [
4346 'attributes ' ,
47+ 'modifiers ' ,
4448 'hookKeyword ' ,
4549 'openParen ' ,
4650 'parameterList ' ,
Original file line number Diff line number Diff line change @@ -1614,6 +1614,30 @@ private function parseModifiers(): array {
16141614 return $ modifiers ;
16151615 }
16161616
1617+ /**
1618+ * Parse modifiers that are allowed on property hooks (visibility, static, final).
1619+ *
1620+ * @return Token[]
1621+ */
1622+ private function parsePropertyHookModifiers (): array {
1623+ $ modifiers = [];
1624+ while (true ) {
1625+ $ token = $ this ->getCurrentToken ();
1626+ switch ($ token ->kind ) {
1627+ case TokenKind::PublicKeyword:
1628+ case TokenKind::ProtectedKeyword:
1629+ case TokenKind::PrivateKeyword:
1630+ case TokenKind::StaticKeyword:
1631+ case TokenKind::FinalKeyword:
1632+ $ modifiers [] = $ token ;
1633+ $ this ->advanceToken ();
1634+ continue 2 ;
1635+ }
1636+ break ;
1637+ }
1638+ return $ modifiers ;
1639+ }
1640+
16171641 private function isParameterStartFn () {
16181642 return function ($ token ) {
16191643 switch ($ token ->kind ) {
@@ -3527,6 +3551,8 @@ private function parsePropertyHook(PropertyHookList $parentNode): ?PropertyHook
35273551 $ hook ->attributes = $ this ->parseAttributeGroups ($ hook );
35283552 }
35293553
3554+ $ hook ->modifiers = $ this ->parsePropertyHookModifiers ();
3555+
35303556 $ token = $ this ->getCurrentToken ();
35313557 if ($ token ->kind === TokenKind::Name) {
35323558 $ text = \strtolower (\trim ($ token ->getText ($ this ->sourceFile ->fileContents )));
You can’t perform that action at this time.
0 commit comments