Skip to content

Commit b520d4b

Browse files
committed
PHP 8.1: Squiz/StaticThisUsage - Added support for enums
1 parent 718f390 commit b520d4b

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class StaticThisUsageSniff extends AbstractScopeSniff
2222
*/
2323
public function __construct()
2424
{
25-
parent::__construct([T_CLASS, T_TRAIT, T_ANON_CLASS], [T_FUNCTION]);
25+
parent::__construct([T_CLASS, T_TRAIT, T_ENUM, T_ANON_CLASS], [T_FUNCTION]);
2626

2727
}//end __construct()
2828

src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,9 @@ $b = new class()
115115
return $This;
116116
}
117117
}
118+
119+
enum MyEnum {
120+
public static function myFunc() {
121+
$this->doSomething();
122+
}
123+
}

src/Standards/Squiz/Tests/Scope/StaticThisUsageUnitTest.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@ class StaticThisUsageUnitTest extends AbstractSniffUnitTest
2626
public function getErrorList()
2727
{
2828
return [
29-
7 => 1,
30-
8 => 1,
31-
9 => 1,
32-
14 => 1,
33-
20 => 1,
34-
41 => 1,
35-
61 => 1,
36-
69 => 1,
37-
76 => 1,
38-
80 => 1,
39-
84 => 1,
40-
99 => 1,
29+
7 => 1,
30+
8 => 1,
31+
9 => 1,
32+
14 => 1,
33+
20 => 1,
34+
41 => 1,
35+
61 => 1,
36+
69 => 1,
37+
76 => 1,
38+
80 => 1,
39+
84 => 1,
40+
99 => 1,
41+
121 => 1,
4142
];
4243

4344
}//end getErrorList()

0 commit comments

Comments
 (0)