@@ -50,7 +50,7 @@ final class FixerFactory
5050 'no_useless_else ' => true ,
5151 'no_useless_return ' => true ,
5252 'non_printable_character ' => ['use_escape_sequences_in_strings ' => true ],
53- 'ordered_class_elements ' => true ,
53+ 'ordered_class_elements ' => false ,
5454 'ordered_imports ' => false ,
5555 'php_unit_strict ' => false ,
5656 'php_unit_method_casing ' => false ,
@@ -76,6 +76,7 @@ final class FixerFactory
7676 public static function createFor (string $ launchFile ): Config
7777 {
7878 $ workingDir = dirname ($ launchFile );
79+ $ testsPath = $ workingDir . DIRECTORY_SEPARATOR . 'tests ' . DIRECTORY_SEPARATOR ;
7980
8081 self ::setHeaderFrom ($ launchFile );
8182
@@ -84,9 +85,28 @@ public static function createFor(string $launchFile): Config
8485 'square_brace_block ' , 'curly_brace_block '
8586 ];
8687
88+ $ srcOrder = [
89+ 'use_trait ' , 'case ' , 'constant_public ' , 'constant_protected ' , 'constant_private ' ,
90+ 'property_public_static ' , 'property_protected_static ' , 'property_private_static ' ,
91+ 'method_public_static ' , 'method_protected_static ' , 'method_private_static ' ,
92+ 'property_public ' , 'property_protected ' , 'property_private ' ,
93+ 'construct ' , 'magic ' , 'method_public ' , 'destruct ' , 'method_protected ' , 'method_private '
94+ ];
95+
96+ $ testOrder = [
97+ 'use_trait ' , 'constant_public ' , 'constant_protected ' , 'constant_private ' ,
98+ 'property_public_static ' , 'property_protected_static ' , 'property_private_static ' ,
99+ 'property_public ' , 'property_protected ' , 'property_private ' ,
100+ 'construct ' , 'phpunit ' , 'magic ' , 'destruct ' ,
101+ 'method_public ' , 'method_public_static ' ,
102+ 'method_protected ' , 'method_protected_static ' ,
103+ 'method_private ' , 'method_private_static '
104+ ];
105+
87106 self ::$ rules ['Polymorphine/double_line_before_class_definition ' ] = true ;
88107 self ::$ rules ['Polymorphine/no_trailing_comma_after_multiline_array ' ] = true ;
89- self ::$ rules ['Polymorphine/constructors_first ' ] = true ;
108+ self ::$ rules ['Polymorphine/multi_ordered_class_elements ' ] = true ;
109+ self ::$ rules ['Polymorphine/named_constructors_first_static ' ] = true ;
90110 self ::$ rules ['Polymorphine/aligned_method_chain ' ] = true ;
91111 self ::$ rules ['Polymorphine/aligned_assignments ' ] = true ;
92112 self ::$ rules ['Polymorphine/aligned_array_values ' ] = true ;
@@ -95,9 +115,8 @@ public static function createFor(string $launchFile): Config
95115 self ::$ rules ['Polymorphine/declare_strict_first_line ' ] = true ;
96116 self ::$ rules ['Polymorphine/brace_after_multiline_param_method ' ] = true ;
97117
98- $ excludeSamples = function (SplFileInfo $ file ) use ($ workingDir ) {
118+ $ excludeSamples = function (SplFileInfo $ file ) use ($ testsPath ) {
99119 $ filePath = $ file ->getPath ();
100- $ testsPath = $ workingDir . DIRECTORY_SEPARATOR . 'tests ' . DIRECTORY_SEPARATOR ;
101120 $ samplesDir = DIRECTORY_SEPARATOR . 'code-samples ' . DIRECTORY_SEPARATOR ;
102121 return strpos ($ filePath , $ testsPath ) !== 0 || strpos ($ filePath , $ samplesDir ) === false ;
103122 };
@@ -111,7 +130,8 @@ public static function createFor(string $launchFile): Config
111130 ->registerCustomFixers ([
112131 new Fixer \DoubleLineBeforeClassDefinitionFixer (),
113132 new Fixer \NoTrailingCommaInMultilineArrayFixer (),
114- new Fixer \ConstructorsFirstFixer (),
133+ new Fixer \MultiOrderedClassElementsFixer ($ testsPath , $ srcOrder , $ testOrder ),
134+ new Fixer \NamedConstructorsFirstStaticFixer (),
115135 new Fixer \AlignedMethodChainFixer (),
116136 new Fixer \AlignedAssignmentsFixer (),
117137 new Fixer \AlignedArrayValuesFixer (),
0 commit comments