diff options
author | Andrew Dolgov <[email protected]> | 2023-12-02 17:45:25 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2023-12-02 18:03:06 +0300 |
commit | 09898ccbc87b5e297bcfab4527a3705bd3b4d5a4 (patch) | |
tree | ebb1e6ebe21782f4c1a757a00af1316ca645b69e /vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php | |
parent | 2b8e34453234b8b31ebc9e7020f8677bf3889898 (diff) |
add phpunit code coverage driver
Diffstat (limited to 'vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php')
-rw-r--r-- | vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php b/vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php index ebb879e84..3c0b2373c 100644 --- a/vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php +++ b/vendor/phpunit/php-code-coverage/src/StaticAnalysis/IgnoredLinesFindingVisitor.php @@ -10,9 +10,11 @@ namespace SebastianBergmann\CodeCoverage\StaticAnalysis; use function array_merge; +use function assert; use function range; use function strpos; use PhpParser\Node; +use PhpParser\Node\Attribute; use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; @@ -52,7 +54,8 @@ final class IgnoredLinesFindingVisitor extends NodeVisitorAbstract !$node instanceof Trait_ && !$node instanceof Interface_ && !$node instanceof ClassMethod && - !$node instanceof Function_) { + !$node instanceof Function_ && + !$node instanceof Attribute) { return; } @@ -60,11 +63,16 @@ final class IgnoredLinesFindingVisitor extends NodeVisitorAbstract return; } - // Workaround for https://bugs.xdebug.org/view.php?id=1798 if ($node instanceof Class_ || $node instanceof Trait_ || - $node instanceof Interface_) { + $node instanceof Interface_ || + $node instanceof Attribute) { $this->ignoredLines[] = $node->getStartLine(); + + assert($node->name !== null); + + // Workaround for https://github.com/nikic/PHP-Parser/issues/886 + $this->ignoredLines[] = $node->name->getStartLine(); } if (!$this->useAnnotationsForIgnoringCode) { @@ -75,6 +83,19 @@ final class IgnoredLinesFindingVisitor extends NodeVisitorAbstract return; } + $this->processDocComment($node); + } + + /** + * @psalm-return list<int> + */ + public function ignoredLines(): array + { + return $this->ignoredLines; + } + + private function processDocComment(Node $node): void + { $docComment = $node->getDocComment(); if ($docComment === null) { @@ -95,12 +116,4 @@ final class IgnoredLinesFindingVisitor extends NodeVisitorAbstract ); } } - - /** - * @psalm-return list<int> - */ - public function ignoredLines(): array - { - return $this->ignoredLines; - } } |