Skip to content

Commit be95ba0

Browse files
committed
Custom annotations @type changed into @var
1 parent 919e0c6 commit be95ba0

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

src/Fixer/Phpdoc/GeneralPhpdocTagRenameFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
172172

173173
if ($this->configuration['fix_annotation']) {
174174
if ($this->configuration['fix_inline']) {
175-
$regex = '/\b(?<=@)(%s)\b/';
175+
$regex = '/"[^"]*"(*SKIP)(*FAIL)|\b(?<=@)(%s)\b/';
176176
} else {
177-
$regex = '/(?<!\{@)(?<=@)(%s)(?!\})/';
177+
$regex = '/"[^"]*"(*SKIP)(*FAIL)|(?<!\{@)(?<=@)(%s)(?!\})/';
178178
}
179179
} else {
180180
$regex = '/(?<={@)(%s)(?=[ \t}])/';

tests/Fixer/Phpdoc/GeneralPhpdocTagRenameFixerTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,44 @@ public function provideFixCases()
198198
],
199199
],
200200
],
201+
[
202+
'<?php
203+
/**
204+
* @var int $foo
205+
* @Annotation("@type")
206+
*/',
207+
'<?php
208+
/**
209+
* @type int $foo
210+
* @Annotation("@type")
211+
*/',
212+
[
213+
'fix_annotation' => true,
214+
'fix_inline' => true,
215+
'replacements' => [
216+
'type' => 'var',
217+
],
218+
],
219+
],
220+
[
221+
'<?php
222+
/**
223+
* @var int $foo
224+
* @Annotation("@type")
225+
*/',
226+
'<?php
227+
/**
228+
* @type int $foo
229+
* @Annotation("@type")
230+
*/',
231+
[
232+
'fix_annotation' => true,
233+
'fix_inline' => false,
234+
'replacements' => [
235+
'type' => 'var',
236+
],
237+
],
238+
],
201239
];
202240
}
203241

0 commit comments

Comments
 (0)