|
24 | 24 | use SlevomatCodingStandard\Helpers\AnnotationHelper; |
25 | 25 | use SlevomatCodingStandard\Helpers\AnnotationTypeHelper; |
26 | 26 | use SlevomatCodingStandard\Helpers\DocCommentHelper; |
27 | | -use SlevomatCodingStandard\Helpers\FixerHelper; |
28 | 27 | use SlevomatCodingStandard\Helpers\FunctionHelper; |
29 | 28 | use SlevomatCodingStandard\Helpers\NamespaceHelper; |
30 | 29 | use SlevomatCodingStandard\Helpers\SniffSettingsHelper; |
@@ -143,23 +142,46 @@ public function process(File $phpcsFile, $pointer): void |
143 | 142 | new IdentifierTypeNode($genericIdentifier), |
144 | 143 | [$this->fixArrayNode($arrayTypeNode->type)], |
145 | 144 | ); |
146 | | - $this->fixAnnotation($phpcsFile, $annotation, $genericTypeNode); |
| 145 | + $this->fixAnnotation($phpcsFile, $annotation, AnnotationTypeHelper::print($genericTypeNode)); |
147 | 146 |
|
148 | 147 | continue; |
149 | 148 | } |
150 | 149 |
|
151 | | - $phpcsFile->fixer->beginChangeset(); |
152 | | - FixerHelper::change( |
| 150 | + $this->applyFixWithoutTabConversion( |
153 | 151 | $phpcsFile, |
154 | 152 | $parsedDocComment->getOpenPointer(), |
155 | 153 | $parsedDocComment->getClosePointer(), |
156 | 154 | $fixedDocComment, |
157 | 155 | ); |
158 | | - $phpcsFile->fixer->endChangeset(); |
159 | 156 | } |
160 | 157 | } |
161 | 158 | } |
162 | 159 |
|
| 160 | + /** |
| 161 | + * Apply a fix without converting spaces to tabs |
| 162 | + * |
| 163 | + * @param \PHP_CodeSniffer\Files\File $phpcsFile |
| 164 | + * @param int $startPointer |
| 165 | + * @param int $endPointer |
| 166 | + * @param string $content |
| 167 | + * |
| 168 | + * @return void |
| 169 | + */ |
| 170 | + protected function applyFixWithoutTabConversion(File $phpcsFile, int $startPointer, int $endPointer, string $content): void |
| 171 | + { |
| 172 | + $phpcsFile->fixer->beginChangeset(); |
| 173 | + |
| 174 | + // Remove all tokens between start and end |
| 175 | + for ($i = $startPointer; $i <= $endPointer; $i++) { |
| 176 | + $phpcsFile->fixer->replaceToken($i, ''); |
| 177 | + } |
| 178 | + |
| 179 | + // Add the new content without tab conversion |
| 180 | + $phpcsFile->fixer->replaceToken($startPointer, $content); |
| 181 | + |
| 182 | + $phpcsFile->fixer->endChangeset(); |
| 183 | + } |
| 184 | + |
163 | 185 | /** |
164 | 186 | * @param \PHP_CodeSniffer\Files\File $phpcsFile |
165 | 187 | * @param \SlevomatCodingStandard\Helpers\Annotation $annotation |
|
0 commit comments