Skip to content

Commit 10e1a70

Browse files
committed
Capture comments in Variable assignments #8
1 parent a554256 commit 10e1a70

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/PhpNodeVisitor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function enterNode(Node $node)
4545
case 'Stmt_Echo':
4646
case 'Stmt_Return':
4747
case 'Expr_Print':
48+
case 'Expr_Assign':
4849
$this->bufferComments = $node;
4950
return null;
5051
}

tests/PhpFunctionsScannerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ public function testPhpFunctionsExtractor()
164164
$this->assertSame(30, $function->getLine());
165165
$this->assertSame(30, $function->getLastLine());
166166
$this->assertSame($file, $function->getFilename());
167-
$this->assertCount(0, $function->getComments());
167+
$this->assertCount(1, $function->getComments());
168+
$comments = $function->getComments();
169+
$this->assertSame('Related comment 5', array_shift($comments));
168170
}
169171

170172
public function _testPhpFunctionsScannerWithDisabledComments()

tests/assets/functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
'arg12'
2727
/* No Related comment 4 */
2828
);
29-
30-
fn13("Translatable string","",["context"=>"Context string", 'foo']);
29+
//Related comment 5
30+
$bar = fn13("Translatable string","",["context"=>"Context string", 'foo']);

0 commit comments

Comments
 (0)