Skip to content

Commit d2c86ab

Browse files
jrfnlkukulich
authored andcommitted
Generic/ValidFunctionName: 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 16d8ee6 commit d2c86ab

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,23 @@ abstract class My_Class {
221221
public function _MY_CLASS() {}
222222
}
223223

224-
enum My_Enum {
225-
public function my_class() {}
226-
public function _MY_CLASS() {}
224+
enum Suit: string implements Colorful, CardGame {
225+
// Magic methods.
226+
function __call($name, $args) {}
227+
static function __callStatic($name, $args) {}
228+
function __invoke() {}
229+
230+
// Valid Method Name.
231+
public function parseMyDSN() {}
232+
private function _getAnotherValue() {}
233+
234+
// Double underscore non-magic methods not allowed.
235+
function __myFunction() {}
236+
function __my_function() {}
237+
238+
// Non-camelcase.
239+
public function get_some_value() {}
240+
241+
// Private without underscore prefix.
242+
private function getMe() {}
227243
}

src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ public function getErrorList()
122122
212 => 1,
123123
213 => 1,
124124
214 => 1,
125-
225 => 1,
126-
226 => 2,
125+
235 => 1,
126+
236 => 2,
127+
239 => 1,
128+
242 => 1,
127129
];
128130

129131
}//end getErrorList()

0 commit comments

Comments
 (0)