Skip to content

Commit

Permalink
PHP 8.1: Squiz/StaticThisUsage - Added support for enums
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Dec 17, 2021
1 parent d2708d4 commit 7fa55f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class StaticThisUsageSniff extends AbstractScopeSniff
*/
public function __construct()
{
parent::__construct([T_CLASS, T_TRAIT, T_ANON_CLASS], [T_FUNCTION]);
parent::__construct([T_CLASS, T_TRAIT, T_ENUM, T_ANON_CLASS], [T_FUNCTION]);

}//end __construct()

Expand Down
6 changes: 6 additions & 0 deletions src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,9 @@ $b = new class()
return $This;
}
}

enum MyEnum {
public static function myFunc() {
$this->doSomething();
}
}
25 changes: 13 additions & 12 deletions src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ class StaticThisUsageUnitTest extends AbstractSniffUnitTest
public function getErrorList()
{
return [
7 => 1,
8 => 1,
9 => 1,
14 => 1,
20 => 1,
41 => 1,
61 => 1,
69 => 1,
76 => 1,
80 => 1,
84 => 1,
99 => 1,
7 => 1,
8 => 1,
9 => 1,
14 => 1,
20 => 1,
41 => 1,
61 => 1,
69 => 1,
76 => 1,
80 => 1,
84 => 1,
99 => 1,
121 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 7fa55f9

Please sign in to comment.