Skip to content

Commit 0231e03

Browse files
committed
Ignore order of non-public constructors in PedantryTest
1 parent c83efaa commit 0231e03

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/PedantryTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use function array_filter;
1414
use function array_map;
15+
use function array_values;
1516
use function in_array;
1617
use function realpath;
1718
use function str_contains;
@@ -39,11 +40,12 @@ public function testMethodsAreOrderedAlphabeticallyByVisibility($className): voi
3940
$class = new ReflectionClass($className);
4041
$methods = $class->getMethods();
4142

42-
$methods = array_filter(
43+
$methods = array_values(array_filter(
4344
$methods,
4445
fn (ReflectionMethod $method) => $method->getDeclaringClass() == $class // Exclude inherited methods
45-
&& $method->getFileName() === $class->getFileName(), // Exclude methods inherited from traits
46-
);
46+
&& $method->getFileName() === $class->getFileName() // Exclude methods inherited from traits
47+
&& ! ($method->isConstructor() && ! $method->isPublic()), // Exclude non-public constructors
48+
));
4749

4850
$getSortValue = function (ReflectionMethod $method) {
4951
$prefix = $method->isPrivate() ? '2' : ($method->isProtected() ? '1' : '0');

0 commit comments

Comments
 (0)