Skip to content

Commit

Permalink
PHP 8.3 | PSR12/AnonClassDeclaration: add tests with readonly anonymo…
Browse files Browse the repository at this point in the history
…us classes

The underlying `PSR2.Classes.ClassDeclaration` sniff, which does the actual checking of the space between a potential modifier keyword and the `class` keyword, already handles this correctly (after squizlabs/PHP_CodeSniffer 3826 and 307).

Note: tests were only added to the PSR12 sniffs as that sniffs registers the `T_ANON_CLASS` token.
The `PEAR.Classes.ClassDeclaration` sniff and the `PSR2` and `Squiz` versions, which both extend the `PEAR` class, don't need tests as none of those listen for the `T_ANON_CLASS` token.
  • Loading branch information
jrfnl committed Feb 2, 2024
1 parent 10ede77 commit a096b87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ $instance = new class() extends SomeClass implements
SomeInterface{
public function __construct() {}
};

// PHP 8.3 readonly anonymous classes.
$anon = new readonly class {};
$anon = new readonly class {};
$anon = new readonly
class {};
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ $instance = new class () extends SomeClass implements
{
public function __construct() {}
};

// PHP 8.3 readonly anonymous classes.
$anon = new readonly class {};
$anon = new readonly class {};
$anon = new readonly class {};
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function getErrorList()
75 => 1,
87 => 1,
88 => 1,
94 => 1,
96 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit a096b87

Please sign in to comment.