Skip to content

Commit d7ea272

Browse files
committed
PHP 8.3 | PSR12/AnonClassDeclaration: add tests with readonly anonymous 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.
1 parent a65d0f3 commit d7ea272

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,9 @@ $instance = new class() extends SomeClass implements
8888
SomeInterface{
8989
public function __construct() {}
9090
};
91+
92+
// PHP 8.3 readonly anonymous classes.
93+
$anon = new readonly class {};
94+
$anon = new readonly class {};
95+
$anon = new readonly
96+
class {};

src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.inc.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,8 @@ $instance = new class () extends SomeClass implements
9191
{
9292
public function __construct() {}
9393
};
94+
95+
// PHP 8.3 readonly anonymous classes.
96+
$anon = new readonly class {};
97+
$anon = new readonly class {};
98+
$anon = new readonly class {};

src/Standards/PSR12/Tests/Classes/AnonClassDeclarationUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public function getErrorList()
5555
75 => 1,
5656
87 => 1,
5757
88 => 1,
58+
94 => 1,
59+
96 => 1,
5860
];
5961

6062
}//end getErrorList()

0 commit comments

Comments
 (0)