laravel-6 support
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
@@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Runner\PhptTestCase;
|
||||
use PHPUnit\Util\Test;
|
||||
use SebastianBergmann\CodeCoverage\Driver\Driver;
|
||||
use SebastianBergmann\CodeCoverage\Driver\PCOV;
|
||||
use SebastianBergmann\CodeCoverage\Driver\PHPDBG;
|
||||
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
|
||||
use SebastianBergmann\CodeCoverage\Node\Builder;
|
||||
@@ -158,9 +159,7 @@ final class CodeCoverage
|
||||
public function getReport(): Directory
|
||||
{
|
||||
if ($this->report === null) {
|
||||
$builder = new Builder;
|
||||
|
||||
$this->report = $builder->build($this);
|
||||
$this->report = (new Builder)->build($this);
|
||||
}
|
||||
|
||||
return $this->report;
|
||||
@@ -662,8 +661,7 @@ final class CodeCoverage
|
||||
|
||||
$firstMethod = \array_shift($classOrTrait['methods']);
|
||||
$firstMethodStartLine = $firstMethod['startLine'];
|
||||
$firstMethodEndLine = $firstMethod['endLine'];
|
||||
$lastMethodEndLine = $firstMethodEndLine;
|
||||
$lastMethodEndLine = $firstMethod['endLine'];
|
||||
|
||||
do {
|
||||
$lastMethod = \array_pop($classOrTrait['methods']);
|
||||
@@ -696,7 +694,7 @@ final class CodeCoverage
|
||||
switch (\get_class($token)) {
|
||||
case \PHP_Token_COMMENT::class:
|
||||
case \PHP_Token_DOC_COMMENT::class:
|
||||
$_token = \trim($token);
|
||||
$_token = \trim((string) $token);
|
||||
$_line = \trim($lines[$token->getLine() - 1]);
|
||||
|
||||
if ($_token === '// @codeCoverageIgnore' ||
|
||||
@@ -713,7 +711,7 @@ final class CodeCoverage
|
||||
|
||||
if (!$ignore) {
|
||||
$start = $token->getLine();
|
||||
$end = $start + \substr_count($token, "\n");
|
||||
$end = $start + \substr_count((string) $token, "\n");
|
||||
|
||||
// Do not ignore the first line when there is a token
|
||||
// before the comment
|
||||
@@ -740,7 +738,7 @@ final class CodeCoverage
|
||||
case \PHP_Token_FUNCTION::class:
|
||||
/* @var \PHP_Token_Interface $token */
|
||||
|
||||
$docblock = $token->getDocblock();
|
||||
$docblock = (string) $token->getDocblock();
|
||||
|
||||
$this->ignoredLines[$fileName][] = $token->getLine();
|
||||
|
||||
@@ -763,6 +761,7 @@ final class CodeCoverage
|
||||
case \PHP_Token_OPEN_TAG::class:
|
||||
case \PHP_Token_CLOSE_TAG::class:
|
||||
case \PHP_Token_USE::class:
|
||||
case \PHP_Token_USE_FUNCTION::class:
|
||||
$this->ignoredLines[$fileName][] = $token->getLine();
|
||||
|
||||
break;
|
||||
@@ -893,12 +892,12 @@ final class CodeCoverage
|
||||
{
|
||||
$runtime = new Runtime;
|
||||
|
||||
if (!$runtime->canCollectCodeCoverage()) {
|
||||
throw new RuntimeException('No code coverage driver available');
|
||||
if ($runtime->hasPHPDBGCodeCoverage()) {
|
||||
return new PHPDBG;
|
||||
}
|
||||
|
||||
if ($runtime->isPHPDBG()) {
|
||||
return new PHPDBG;
|
||||
if ($runtime->hasPCOV()) {
|
||||
return new PCOV;
|
||||
}
|
||||
|
||||
if ($runtime->hasXdebug()) {
|
||||
@@ -957,10 +956,9 @@ final class CodeCoverage
|
||||
}
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$coverage = $this->driver->stop();
|
||||
$data = [];
|
||||
|
||||
foreach ($coverage as $file => $fileCoverage) {
|
||||
foreach ($this->driver->stop() as $file => $fileCoverage) {
|
||||
if ($this->filter->isFiltered($file)) {
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user