Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPStan bleeding edge compatibility #98

Merged
merged 14 commits into from
May 2, 2022
Prev Previous commit
Next Next commit
Link the doc comment to the start line of the node.
  • Loading branch information
johnbillion committed Apr 26, 2022
commit 675b9555f907107acd0f68a9ccda31b2718b3c87
12 changes: 12 additions & 0 deletions src/HookDocsVisitor.php
Original file line number Diff line number Diff line change
@@ -12,20 +12,32 @@

final class HookDocsVisitor extends \PhpParser\NodeVisitorAbstract
{
/**
* @var int|null
*/
protected $latestStartLine = null;

/**
* @var \PhpParser\Comment\Doc|null
*/
protected $latestDocComment = null;

public function beforeTraverse(array $nodes): ?array
{
$this->latestStartLine = null;
$this->latestDocComment = null;

return null;
}

public function enterNode(Node $node): ?Node
{
if ($node->getStartLine() !== $this->latestStartLine) {
$this->latestDocComment = null;
}

$this->latestStartLine = $node->getStartLine();

$doc = $node->getDocComment();

if ($doc !== null) {