Composer installs update
This commit is contained in:
@@ -2,6 +2,20 @@
|
||||
|
||||
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [9.2.15] - 2022-03-07
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#885](https://github.com/sebastianbergmann/php-code-coverage/issues/885): Files that have only `\r` (CR, 0x0d) EOL characters are not handled correctly
|
||||
* [#907](https://github.com/sebastianbergmann/php-code-coverage/issues/907): Line with only `return [` is not recognized as executable
|
||||
|
||||
## [9.2.14] - 2022-02-28
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#904](https://github.com/sebastianbergmann/php-code-coverage/issues/904): Lines of code containing the `match` keyword were not recognized as executable correctly
|
||||
* [#905](https://github.com/sebastianbergmann/php-code-coverage/issues/905): Lines of code in constructors were not recognized as executable correctly when constructor property promotion is used
|
||||
|
||||
## [9.2.13] - 2022-02-23
|
||||
|
||||
### Changed
|
||||
@@ -384,6 +398,8 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
|
||||
|
||||
* This component is no longer supported on PHP 7.1
|
||||
|
||||
[9.2.15]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.14...9.2.15
|
||||
[9.2.14]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.13...9.2.14
|
||||
[9.2.13]: https://github.com/sebastianbergmann/php-code-coverage/compare/c011a0b6aaa4acd2f39b7f51fb4ad4442b6ec631...9.2.13
|
||||
[9.2.12]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.11...c011a0b6aaa4acd2f39b7f51fb4ad4442b6ec631
|
||||
[9.2.11]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.10...9.2.11
|
||||
|
||||
@@ -10,21 +10,27 @@
|
||||
namespace SebastianBergmann\CodeCoverage\StaticAnalysis;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\BinaryOp;
|
||||
use PhpParser\Node\Expr\CallLike;
|
||||
use PhpParser\Node\Expr\Cast;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Match_;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\NullsafePropertyFetch;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Expr\Ternary;
|
||||
use PhpParser\Node\MatchArm;
|
||||
use PhpParser\Node\Scalar\Encapsed;
|
||||
use PhpParser\Node\Stmt\Break_;
|
||||
use PhpParser\Node\Stmt\Case_;
|
||||
use PhpParser\Node\Stmt\Catch_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Continue_;
|
||||
use PhpParser\Node\Stmt\Do_;
|
||||
use PhpParser\Node\Stmt\Echo_;
|
||||
@@ -60,6 +66,11 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
*/
|
||||
private $propertyLines = [];
|
||||
|
||||
/**
|
||||
* @psalm-var array<int, Return_>
|
||||
*/
|
||||
private $returns = [];
|
||||
|
||||
public function enterNode(Node $node): void
|
||||
{
|
||||
$this->savePropertyLines($node);
|
||||
@@ -82,6 +93,8 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
*/
|
||||
public function executableLines(): array
|
||||
{
|
||||
$this->computeReturns();
|
||||
|
||||
sort($this->executableLines);
|
||||
|
||||
return $this->executableLines;
|
||||
@@ -98,6 +111,25 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
}
|
||||
}
|
||||
|
||||
private function computeReturns(): void
|
||||
{
|
||||
foreach ($this->returns as $return) {
|
||||
foreach (range($return->getStartLine(), $return->getEndLine()) as $loc) {
|
||||
if (isset($this->executableLines[$loc])) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$line = $return->getEndLine();
|
||||
|
||||
if ($return->expr !== null) {
|
||||
$line = $return->expr->getStartLine();
|
||||
}
|
||||
|
||||
$this->executableLines[$line] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
@@ -118,6 +150,46 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
return [$node->dim->getStartLine()];
|
||||
}
|
||||
|
||||
if ($node instanceof Array_) {
|
||||
$startLine = $node->getStartLine();
|
||||
|
||||
if (isset($this->executableLines[$startLine])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ([] === $node->items) {
|
||||
return [$node->getEndLine()];
|
||||
}
|
||||
|
||||
if ($node->items[0] instanceof ArrayItem) {
|
||||
return [$node->items[0]->getStartLine()];
|
||||
}
|
||||
}
|
||||
|
||||
if ($node instanceof ClassMethod) {
|
||||
if ($node->name->name !== '__construct') {
|
||||
return [];
|
||||
}
|
||||
|
||||
$existsAPromotedProperty = false;
|
||||
|
||||
foreach ($node->getParams() as $param) {
|
||||
if (0 !== ($param->flags & Class_::VISIBILITY_MODIFIER_MASK)) {
|
||||
$existsAPromotedProperty = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($existsAPromotedProperty) {
|
||||
// Only the line with `function` keyword should be listed here
|
||||
// but `nikic/php-parser` doesn't provide a way to fetch it
|
||||
return range($node->getStartLine(), $node->name->getEndLine());
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($node instanceof MethodCall) {
|
||||
return [$node->name->getStartLine()];
|
||||
}
|
||||
@@ -134,6 +206,28 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
return $lines;
|
||||
}
|
||||
|
||||
if ($node instanceof Match_) {
|
||||
return [$node->cond->getStartLine()];
|
||||
}
|
||||
|
||||
if ($node instanceof MatchArm) {
|
||||
return [$node->body->getStartLine()];
|
||||
}
|
||||
|
||||
if ($node instanceof Expression && (
|
||||
$node->expr instanceof Cast ||
|
||||
$node->expr instanceof Match_ ||
|
||||
$node->expr instanceof MethodCall
|
||||
)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($node instanceof Return_) {
|
||||
$this->returns[] = $node;
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
return [$node->getStartLine()];
|
||||
}
|
||||
|
||||
@@ -141,12 +235,14 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
{
|
||||
return $node instanceof Assign ||
|
||||
$node instanceof ArrayDimFetch ||
|
||||
$node instanceof Array_ ||
|
||||
$node instanceof BinaryOp ||
|
||||
$node instanceof Break_ ||
|
||||
$node instanceof CallLike ||
|
||||
$node instanceof Case_ ||
|
||||
$node instanceof Cast ||
|
||||
$node instanceof Catch_ ||
|
||||
$node instanceof ClassMethod ||
|
||||
$node instanceof Closure ||
|
||||
$node instanceof Continue_ ||
|
||||
$node instanceof Do_ ||
|
||||
@@ -160,6 +256,8 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
|
||||
$node instanceof Foreach_ ||
|
||||
$node instanceof Goto_ ||
|
||||
$node instanceof If_ ||
|
||||
$node instanceof Match_ ||
|
||||
$node instanceof MatchArm ||
|
||||
$node instanceof MethodCall ||
|
||||
$node instanceof NullsafePropertyFetch ||
|
||||
$node instanceof PropertyFetch ||
|
||||
|
||||
@@ -13,6 +13,7 @@ use function array_unique;
|
||||
use function assert;
|
||||
use function file_get_contents;
|
||||
use function is_array;
|
||||
use function max;
|
||||
use function sprintf;
|
||||
use function substr_count;
|
||||
use function token_get_all;
|
||||
@@ -132,7 +133,7 @@ final class ParsingFileAnalyser implements FileAnalyser
|
||||
}
|
||||
|
||||
$source = file_get_contents($filename);
|
||||
$linesOfCode = substr_count($source, "\n");
|
||||
$linesOfCode = max(substr_count($source, "\n") + 1, substr_count($source, "\r") + 1);
|
||||
|
||||
if ($linesOfCode === 0 && !empty($source)) {
|
||||
$linesOfCode = 1;
|
||||
|
||||
@@ -22,7 +22,7 @@ final class Version
|
||||
public static function id(): string
|
||||
{
|
||||
if (self::$version === null) {
|
||||
self::$version = (new VersionId('9.2.13', dirname(__DIR__)))->getVersion();
|
||||
self::$version = (new VersionId('9.2.15', dirname(__DIR__)))->getVersion();
|
||||
}
|
||||
|
||||
return self::$version;
|
||||
|
||||
Reference in New Issue
Block a user