Skip to content

Commit af87457

Browse files
committed
PHP 8.2 | PEAR/FileComment: allow for readonly classes
Includes unit test. Ref: * https://wiki.php.net/rfc/readonly_classes
1 parent 39b1956 commit af87457

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
10771077
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.1.inc" role="test" />
10781078
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.2.inc" role="test" />
10791079
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.3.inc" role="test" />
1080+
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.4.inc" role="test" />
10801081
<file baseinstalldir="PHP/CodeSniffer" name="FileCommentUnitTest.php" role="test" />
10811082
<file baseinstalldir="PHP/CodeSniffer" name="FunctionCommentUnitTest.inc" role="test" />
10821083
<file baseinstalldir="PHP/CodeSniffer" name="FunctionCommentUnitTest.inc.fixed" role="test" />

src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public function process(File $phpcsFile, $stackPtr)
170170
T_FINAL,
171171
T_STATIC,
172172
T_ABSTRACT,
173+
T_READONLY,
173174
T_CONST,
174175
T_PROPERTY,
175176
];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
/**
3+
* This should not be recognized as a file comment, but as a class comment.
4+
*/
5+
6+
readonly class Foo {
7+
}

src/Standards/PEAR/Tests/Commenting/FileCommentUnitTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public function getErrorList($testFile='FileCommentUnitTest.inc')
4848
];
4949

5050
case 'FileCommentUnitTest.2.inc':
51-
return [1 => 1];
52-
5351
case 'FileCommentUnitTest.3.inc':
52+
case 'FileCommentUnitTest.4.inc':
5453
return [1 => 1];
5554

5655
default:

0 commit comments

Comments
 (0)