Skip to content

Commit

Permalink
Capture comments in Variable assignments #8
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed May 22, 2020
1 parent a554256 commit 10e1a70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/PhpNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function enterNode(Node $node)
case 'Stmt_Echo':
case 'Stmt_Return':
case 'Expr_Print':
case 'Expr_Assign':
$this->bufferComments = $node;
return null;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/PhpFunctionsScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ public function testPhpFunctionsExtractor()
$this->assertSame(30, $function->getLine());
$this->assertSame(30, $function->getLastLine());
$this->assertSame($file, $function->getFilename());
$this->assertCount(0, $function->getComments());
$this->assertCount(1, $function->getComments());
$comments = $function->getComments();
$this->assertSame('Related comment 5', array_shift($comments));
}

public function _testPhpFunctionsScannerWithDisabledComments()
Expand Down
4 changes: 2 additions & 2 deletions tests/assets/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
'arg12'
/* No Related comment 4 */
);

fn13("Translatable string","",["context"=>"Context string", 'foo']);
//Related comment 5
$bar = fn13("Translatable string","",["context"=>"Context string", 'foo']);

0 comments on commit 10e1a70

Please sign in to comment.