Skip to content

Commit

Permalink
PSR12/ClassInstantiation: fix regression for new parent
Browse files Browse the repository at this point in the history
Related to 3546 which fixed an inconsistency after 3484.

The change of the tokenization from `T_STRING` to `T_PARENT` for the `parent` keyword in `new parent` caused a regression in the `PSR12.Classes.ClassInstantiation` sniff.

Fixed now.

Includes unit tests.
  • Loading branch information
jrfnl authored and gsherwood committed Sep 22, 2022
1 parent e8176fd commit 7335f85
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function process(File $phpcsFile, $stackPtr)
T_NAME_RELATIVE => T_NAME_RELATIVE,
T_SELF => T_SELF,
T_STATIC => T_STATIC,
T_PARENT => T_PARENT,
T_VARIABLE => T_VARIABLE,
T_DOLLAR => T_DOLLAR,
T_OBJECT_OPERATOR => T_OBJECT_OPERATOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ $class = new ${$obj?->classname};
$anonWithAttribute = new #[SomeAttribute('summary')] class {
public const SOME_STUFF = 'foo';
};

$foo = new parent();
$foo = new parent;
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ $class = new ${$obj?->classname}();
$anonWithAttribute = new #[SomeAttribute('summary')] class {
public const SOME_STUFF = 'foo';
};

$foo = new parent();
$foo = new parent();
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function getErrorList()
34 => 1,
37 => 1,
38 => 1,
47 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 7335f85

Please sign in to comment.