Skip to content

Commit 97bd66f

Browse files
committed
PHP 8.1/8.2 | Squiz/InlineComment: allow for readonly classes and properties
Includes unit test. Ref: * https://wiki.php.net/rfc/readonly_properties_v2 * https://wiki.php.net/rfc/readonly_classes
1 parent b7604d7 commit 97bd66f

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function process(File $phpcsFile, $stackPtr)
8383
T_FINAL,
8484
T_STATIC,
8585
T_ABSTRACT,
86+
T_READONLY,
8687
T_CONST,
8788
T_PROPERTY,
8889
T_INCLUDE,

src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ enum MyEnum {
173173

174174
}
175175

176+
/**
177+
* Comment should be ignored.
178+
*
179+
*/
180+
readonly class MyClass
181+
{
182+
/**
183+
* Comment should be ignored.
184+
*
185+
*/
186+
readonly $property = 10;
187+
}
188+
176189
/*
177190
* N.B.: The below test line must be the last test in the file.
178191
* Testing that a new line after an inline comment when it's the last non-whitespace

src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc.fixed

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ enum MyEnum {
166166

167167
}
168168

169+
/**
170+
* Comment should be ignored.
171+
*
172+
*/
173+
readonly class MyClass
174+
{
175+
/**
176+
* Comment should be ignored.
177+
*
178+
*/
179+
readonly $property = 10;
180+
}
181+
169182
/*
170183
* N.B.: The below test line must be the last test in the file.
171184
* Testing that a new line after an inline comment when it's the last non-whitespace

0 commit comments

Comments
 (0)