Skip to content

Commit d83ebe5

Browse files
author
dereuromark
committed
At least allow replacing if identical in inline doc block.
1 parent 72a901a commit d83ebe5

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/Annotator/AbstractAnnotator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ protected function _report() {
614614
return;
615615
}
616616

617-
$this->_io->success(' -> ' . implode(', ', $out));
617+
$this->_io->success(' -> ' . implode(', ', $out) . '.');
618618
}
619619

620620
/**

src/Annotator/TemplateAnnotator.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,20 @@ protected function _addNewTemplateDocBlock(File $file, array $annotations, $phpO
137137
$fixer->addContent($phpOpenTagIndex, $docBlock);
138138
}
139139

140+
$this->_counter[static::COUNT_ADDED] = count($annotations);
141+
140142
if ($docBlockCloseIndex && $this->_isInlineDocBlockRedundant($file, $annotations, $docBlockCloseIndex)) {
141143
$tokens = $file->getTokens();
142144
$docBlockOpenIndex = $tokens[$docBlockCloseIndex]['comment_opener'];
143145
for ($i = $docBlockCloseIndex + 1; $i >= $docBlockOpenIndex; $i--) {
144146
$fixer->replaceToken($i, '');
145147
}
146-
$this->_counter[static::COUNT_REMOVED]++;
148+
149+
$this->_counter[static::COUNT_ADDED]--;
147150
}
148151

149152
$newContent = $fixer->getContents();
150153

151-
$this->_counter[static::COUNT_ADDED] = count($annotations);
152-
153154
return $newContent;
154155
}
155156

tests/TestCase/Annotator/TemplateAnnotatorTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function testAnnotate() {
121121

122122
$output = (string)$this->out->output();
123123

124-
$this->assertTextContains(' -> 2 annotations added', $output);
124+
$this->assertTextContains(' -> 2 annotations added.', $output);
125125
}
126126

127127
/**
@@ -147,7 +147,7 @@ public function testAnnotateLoop() {
147147

148148
$output = (string)$this->out->output();
149149

150-
$this->assertTextContains(' -> 3 annotations added', $output);
150+
$this->assertTextContains(' -> 3 annotations added.', $output);
151151
}
152152

153153
/**
@@ -173,7 +173,7 @@ public function testAnnotatePhpLine() {
173173

174174
$output = (string)$this->out->output();
175175

176-
$this->assertTextContains(' -> 3 annotations added', $output);
176+
$this->assertTextContains(' -> 3 annotations added.', $output);
177177
}
178178

179179
/**
@@ -199,7 +199,7 @@ public function testAnnotateExisting() {
199199

200200
$output = (string)$this->out->output();
201201

202-
$this->assertTextContains(' -> 2 annotations added', $output);
202+
$this->assertTextContains(' -> 2 annotations added.', $output);
203203
}
204204

205205
/**
@@ -225,7 +225,7 @@ public function testAnnotateExistingOutdated() {
225225

226226
$output = (string)$this->out->output();
227227

228-
$this->assertTextContains(' -> 2 annotations updated', $output);
228+
$this->assertTextContains(' -> 2 annotations updated, 1 annotation removed, 1 annotation skipped.', $output);
229229
}
230230

231231
/**
@@ -251,7 +251,7 @@ public function testAnnotateEmptyPreemptive() {
251251

252252
$output = (string)$this->out->output();
253253

254-
$this->assertTextContains(' -> 1 annotation added', $output);
254+
$this->assertTextContains(' -> 1 annotation added.', $output);
255255
}
256256

257257
/**
@@ -299,7 +299,7 @@ public function testAnnotateInline() {
299299

300300
$output = (string)$this->out->output();
301301

302-
$this->assertTextContains(' -> 2 annotations added', $output);
302+
$this->assertTextContains(' -> 1 annotation added.', $output);
303303
}
304304

305305
/**

tests/test_app/src/Template/Foos/inline.ctp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
/** @var \App\Lib\DocumentManager\DataFactory $DataFactory */
2+
/** @var \App\Model\Entity\Wheel $wheel */
33
?>
44
<div>
55
<?php echo h($wheel->id); ?>

tests/test_files/Template/inline.ctp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @var \App\View\AppView $this
44
* @var \App\Model\Entity\Wheel $wheel
55
*/
6-
/** @var \App\Lib\DocumentManager\DataFactory $DataFactory */
76
?>
87
<div>
98
<?php echo h($wheel->id); ?>

0 commit comments

Comments
 (0)