Skip to content

Commit 16d8ee6

Browse files
jrfnlkukulich
authored andcommitted
Generic/CamelCapsFunctionName: improve enum tests
Ensure that all aspects of the sniff are tested for enums. While these tests pass, if you look at the actual error message output, you will see some weirdness (declaration name for the `enum` set as `string`). This should be fixed once PR 3534 has been merged.
1 parent 024c47d commit 16d8ee6

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.inc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,20 @@ abstract class My_Class {
166166
public function _MY_CLASS() {}
167167
}
168168

169-
enum My_Enum {
170-
public function my_class() {}
171-
public function _MY_CLASS() {}
169+
enum Suit: string implements Colorful, CardGame {
170+
// Magic methods.
171+
function __call($name, $args) {}
172+
static function __callStatic($name, $args) {}
173+
function __invoke() {}
174+
175+
// Valid Method Name.
176+
public function getSomeValue() {}
177+
178+
// Double underscore non-magic methods not allowed.
179+
function __myFunction() {}
180+
function __my_function() {}
181+
182+
// Non-camelcase.
183+
public function parseMyDSN() {}
184+
public function get_some_value() {}
172185
}

src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ public function getErrorList()
6363
147 => 2,
6464
158 => 1,
6565
159 => 1,
66-
170 => 1,
67-
171 => 1,
66+
179 => 1,
67+
180 => 2,
68+
183 => 1,
69+
184 => 1,
6870
];
6971

7072
return $errors;

0 commit comments

Comments
 (0)