Skip to content

Commit 4bba9a4

Browse files
authored
Merge pull request #7 from skylerkatz/bugfix/public-static-method
Fix enum usage error
2 parents b5504c8 + ed2b1c6 commit 4bba9a4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Linters/OrderClassMembers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ protected function matchers() : Collection
115115
->withChild(function(MethodDeclaration $node) {
116116
return $this->isPublic($node)
117117
&& $this->isStatic($node)
118+
&& property_exists($this->currentContext(), 'data_providers')
118119
&& ! $this->currentContext()->data_providers->contains($node->getName());
119120
}),
120121

tests/Linters/OrderClassMembersTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,26 @@ private function baz()
6969
->lintSource($source)
7070
->assertNoLintingResults();
7171
}
72-
72+
73+
public function test_it_allows_enums() : void
74+
{
75+
$source = <<<'END_SOURCE'
76+
enum Foo: string
77+
{
78+
case bar = 'bar';
79+
80+
public static function staticFoo()
81+
{
82+
return static::$static_foo;
83+
}
84+
}
85+
END_SOURCE;
86+
87+
$this->withLinter(OrderClassMembers::class)
88+
->lintSource($source)
89+
->assertNoLintingResults();
90+
}
91+
7392
public function test_it_gives_special_consideration_to_setUp_and_tearDown_methods_in_tests() : void
7493
{
7594
$source = <<<'END_SOURCE'

0 commit comments

Comments
 (0)