Skip to content

Commit 71cbcdb

Browse files
authored
Include parent keyword as static reference (#44)
* Tests: add test for `parent::` variable reference * Include T_PARENT in list of static references
1 parent 6441486 commit 71cbcdb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

VariableAnalysis/Sniffs/CodeAnalysis/VariableAnalysisSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ protected function checkForStaticMember(File $phpcsFile, $stackPtr, $varName, $c
364364
$staticReferences = [
365365
T_STRING,
366366
T_SELF,
367+
T_PARENT,
367368
T_STATIC,
368369
];
369370
if (! in_array($tokens[$classNamePtr]['code'], $staticReferences, true)) {

VariableAnalysis/Tests/CodeAnalysis/fixtures/ClassWithMembersFixture.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ static function method_with_late_static_binding($param) {
6363
static::some_method(static::CONSTANT, $param);
6464
}
6565
}
66+
67+
class ChildClassWithMembers extends ClassWithMembers {
68+
function method_with_parent_reference() {
69+
echo self::$static_member_var;
70+
echo parent::$no_such_static_member_var;
71+
}
72+
}

0 commit comments

Comments
 (0)