Skip to content

Commit 23aeadb

Browse files
committed
remove comments from undocumented globals
1 parent d796ecc commit 23aeadb

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/NodeVisitor.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,16 @@ function (\PhpParser\Node\Const_ $const) {
423423
if ($this->needsDocumentedGlobals && $hasValidComment) {
424424
$this->count('globals', $node->expr->var->name);
425425
return $this->needsDocumentedGlobals;
426-
} elseif ($this->needsUndocumentedGlobals && !$hasValidComment) {
426+
}
427+
428+
if ($this->needsUndocumentedGlobals && !$hasValidComment) {
427429
$this->count('globals', $node->expr->var->name);
430+
431+
// remove useless comments
432+
if ($node->getComments() !== []) {
433+
$node->setAttribute('comments', []);
434+
}
435+
428436
return $this->needsUndocumentedGlobals;
429437
}
430438
}

test/files/globals.all.out.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
$d = 'd' . 'd';
1111

12-
/** doc */
1312
$x = 'x' . 'x';
1413

15-
/** @doc */
1614
$y = 'y' . 'y';

test/files/globals.no-doc.out.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
$d = 'd' . 'd';
55

6-
/** doc */
76
$x = 'x' . 'x';
87

9-
/** @doc */
108
$y = 'y' . 'y';

test/files/globals.nullified.out.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
$d = \null;
1111

12-
/** doc */
1312
$x = \null;
1413

15-
/** @doc */
1614
$y = \null;

0 commit comments

Comments
 (0)