@@ -62,15 +62,15 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
6262 }
6363
6464 $ originalDocContent = $ token ->getContent ();
65- $ sortedDocContent = $ this -> sortPropertiesInDocBlock ($ originalDocContent );
65+ $ sortedDocContent = self :: sortPropertiesInDocBlock ($ originalDocContent );
6666
6767 if ($ originalDocContent !== $ sortedDocContent ) {
6868 $ tokens [$ index ] = new Token ([\T_DOC_COMMENT , $ sortedDocContent ]);
6969 }
7070 }
7171 }
7272
73- private function sortPropertiesInDocBlock (string $ docContent ): string
73+ private static function sortPropertiesInDocBlock (string $ docContent ): string
7474 {
7575 $ docLines = \explode ("\n" , $ docContent );
7676 $ processedLines = [];
@@ -80,7 +80,7 @@ private function sortPropertiesInDocBlock(string $docContent): string
8080 if (self ::isPropertyAnnotation ($ line )) {
8181 $ currentPropertyGroup [] = $ line ;
8282 } else {
83- $ this -> flushPropertyGroup ($ currentPropertyGroup , $ processedLines );
83+ self :: flushPropertyGroup ($ currentPropertyGroup , $ processedLines );
8484 $ processedLines [] = $ line ;
8585 }
8686 }
@@ -99,31 +99,31 @@ private static function isPropertyAnnotation(string $line): bool
9999 * @param list<string> $propertyGroup
100100 * @param list<string> $processedLines
101101 */
102- private function flushPropertyGroup (array &$ propertyGroup , array &$ processedLines ): void
102+ private static function flushPropertyGroup (array &$ propertyGroup , array &$ processedLines ): void
103103 {
104104 if (\count ($ propertyGroup ) === 0 ) {
105105 return ;
106106 }
107107
108- $ this -> sortPropertiesByName ($ propertyGroup );
108+ self :: sortPropertiesByName ($ propertyGroup );
109109 $ processedLines = \array_merge ($ processedLines , $ propertyGroup );
110110 $ propertyGroup = [];
111111 }
112112
113113 /**
114114 * @param list<string> $properties
115115 */
116- private function sortPropertiesByName (array &$ properties ): void
116+ private static function sortPropertiesByName (array &$ properties ): void
117117 {
118118 \usort ($ properties , static function (string $ propertyA , string $ propertyB ): int {
119119 $ nameA = self ::extractPropertyName ($ propertyA );
120120 $ nameB = self ::extractPropertyName ($ propertyB );
121121
122- return \strcmp ($ nameA , $ nameB );
122+ return \strcmp ($ nameA ?? '' , $ nameB ?? '' );
123123 });
124124 }
125125
126- private static function extractPropertyName (string $ propertyLine ): string
126+ private static function extractPropertyName (string $ propertyLine ): ? string
127127 {
128128 $ matches = [];
129129 Preg::match ('/@property \\s+[^ \\s]+ \\s+ \\$( \\w+)/ ' , $ propertyLine , $ matches );
@@ -132,6 +132,6 @@ private static function extractPropertyName(string $propertyLine): string
132132 return $ matches [1 ];
133133 }
134134
135- return $ propertyLine ;
135+ return null ;
136136 }
137137}
0 commit comments