Skip to content

Commit 9b4fcae

Browse files
committed
PHP 8.4 | Squiz/VariableComment: add support for abstract properties
If a property uses the `abstract` modifier keyword, the property docblock (providing there is one) would never be found, leading to false positives. Fixed now. Includes tests.
1 parent 916eb08 commit 9b4fcae

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
3636
T_STATIC => T_STATIC,
3737
T_READONLY => T_READONLY,
3838
T_FINAL => T_FINAL,
39+
T_ABSTRACT => T_ABSTRACT,
3940
T_WHITESPACE => T_WHITESPACE,
4041
T_STRING => T_STRING,
4142
T_NS_SEPARATOR => T_NS_SEPARATOR,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,10 @@ class AsymVisibility {
486486
*/
487487
private(set) protected int $hasDocblockC;
488488
}
489+
490+
abstract class PHP84AbstractProperties {
491+
/**
492+
* @var Type
493+
*/
494+
abstract Type $hasDocblock {get;}
495+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,10 @@ class AsymVisibility {
486486
*/
487487
private(set) protected int $hasDocblockC;
488488
}
489+
490+
abstract class PHP84AbstractProperties {
491+
/**
492+
* @var Type
493+
*/
494+
abstract Type $hasDocblock {get;}
495+
}

0 commit comments

Comments
 (0)