Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
@@ -20,33 +20,29 @@ interface Driver
|
||||
*
|
||||
* @see http://xdebug.org/docs/code_coverage
|
||||
*/
|
||||
const LINE_EXECUTED = 1;
|
||||
public const LINE_EXECUTED = 1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @see http://xdebug.org/docs/code_coverage
|
||||
*/
|
||||
const LINE_NOT_EXECUTED = -1;
|
||||
public const LINE_NOT_EXECUTED = -1;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @see http://xdebug.org/docs/code_coverage
|
||||
*/
|
||||
const LINE_NOT_EXECUTABLE = -2;
|
||||
public const LINE_NOT_EXECUTABLE = -2;
|
||||
|
||||
/**
|
||||
* Start collection of code coverage information.
|
||||
*
|
||||
* @param bool $determineUnusedAndDead
|
||||
*/
|
||||
public function start($determineUnusedAndDead = true);
|
||||
public function start(bool $determineUnusedAndDead = true): void;
|
||||
|
||||
/**
|
||||
* Stop collection of code coverage information.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function stop();
|
||||
public function stop(): array;
|
||||
}
|
||||
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the php-code-coverage package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\CodeCoverage\Driver;
|
||||
|
||||
/**
|
||||
* Driver for HHVM's code coverage functionality.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class HHVM extends Xdebug
|
||||
{
|
||||
/**
|
||||
* Start collection of code coverage information.
|
||||
*
|
||||
* @param bool $determineUnusedAndDead
|
||||
*/
|
||||
public function start($determineUnusedAndDead = true)
|
||||
{
|
||||
\xdebug_start_code_coverage();
|
||||
}
|
||||
}
|
@@ -17,10 +17,10 @@ use SebastianBergmann\CodeCoverage\RuntimeException;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class PHPDBG implements Driver
|
||||
final class PHPDBG implements Driver
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -39,39 +39,30 @@ class PHPDBG implements Driver
|
||||
|
||||
/**
|
||||
* Start collection of code coverage information.
|
||||
*
|
||||
* @param bool $determineUnusedAndDead
|
||||
*/
|
||||
public function start($determineUnusedAndDead = true)
|
||||
public function start(bool $determineUnusedAndDead = true): void
|
||||
{
|
||||
phpdbg_start_oplog();
|
||||
\phpdbg_start_oplog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop collection of code coverage information.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function stop()
|
||||
public function stop(): array
|
||||
{
|
||||
static $fetchedLines = [];
|
||||
|
||||
$dbgData = phpdbg_end_oplog();
|
||||
$dbgData = \phpdbg_end_oplog();
|
||||
|
||||
if ($fetchedLines == []) {
|
||||
$sourceLines = phpdbg_get_executable();
|
||||
$sourceLines = \phpdbg_get_executable();
|
||||
} else {
|
||||
$newFiles = \array_diff(
|
||||
\get_included_files(),
|
||||
\array_keys($fetchedLines)
|
||||
);
|
||||
$newFiles = \array_diff(\get_included_files(), \array_keys($fetchedLines));
|
||||
|
||||
$sourceLines = [];
|
||||
|
||||
if ($newFiles) {
|
||||
$sourceLines = phpdbg_get_executable(
|
||||
['files' => $newFiles]
|
||||
);
|
||||
} else {
|
||||
$sourceLines = [];
|
||||
$sourceLines = phpdbg_get_executable(['files' => $newFiles]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,13 +79,8 @@ class PHPDBG implements Driver
|
||||
|
||||
/**
|
||||
* Convert phpdbg based data into the format CodeCoverage expects
|
||||
*
|
||||
* @param array $sourceLines
|
||||
* @param array $dbgData
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function detectExecutedLines(array $sourceLines, array $dbgData)
|
||||
private function detectExecutedLines(array $sourceLines, array $dbgData): array
|
||||
{
|
||||
foreach ($dbgData as $file => $coveredLines) {
|
||||
foreach ($coveredLines as $lineNo => $numExecuted) {
|
||||
|
@@ -17,17 +17,15 @@ use SebastianBergmann\CodeCoverage\RuntimeException;
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Xdebug implements Driver
|
||||
final class Xdebug implements Driver
|
||||
{
|
||||
/**
|
||||
* Cache the number of lines for each file
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $cacheNumLines = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -35,20 +33,15 @@ class Xdebug implements Driver
|
||||
throw new RuntimeException('This driver requires Xdebug');
|
||||
}
|
||||
|
||||
if (\version_compare(\phpversion('xdebug'), '2.2.1', '>=') &&
|
||||
!\ini_get('xdebug.coverage_enable')) {
|
||||
throw new RuntimeException(
|
||||
'xdebug.coverage_enable=On has to be set in php.ini'
|
||||
);
|
||||
if (!\ini_get('xdebug.coverage_enable')) {
|
||||
throw new RuntimeException('xdebug.coverage_enable=On has to be set in php.ini');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start collection of code coverage information.
|
||||
*
|
||||
* @param bool $determineUnusedAndDead
|
||||
*/
|
||||
public function start($determineUnusedAndDead = true)
|
||||
public function start(bool $determineUnusedAndDead = true): void
|
||||
{
|
||||
if ($determineUnusedAndDead) {
|
||||
\xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
|
||||
@@ -59,23 +52,17 @@ class Xdebug implements Driver
|
||||
|
||||
/**
|
||||
* Stop collection of code coverage information.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function stop()
|
||||
public function stop(): array
|
||||
{
|
||||
$data = \xdebug_get_code_coverage();
|
||||
|
||||
\xdebug_stop_code_coverage();
|
||||
|
||||
return $this->cleanup($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function cleanup(array $data)
|
||||
private function cleanup(array $data): array
|
||||
{
|
||||
foreach (\array_keys($data) as $file) {
|
||||
unset($data[$file][0]);
|
||||
@@ -94,24 +81,19 @@ class Xdebug implements Driver
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getNumberOfLinesInFile($file)
|
||||
private function getNumberOfLinesInFile(string $fileName): int
|
||||
{
|
||||
if (!isset($this->cacheNumLines[$file])) {
|
||||
$buffer = \file_get_contents($file);
|
||||
if (!isset($this->cacheNumLines[$fileName])) {
|
||||
$buffer = \file_get_contents($fileName);
|
||||
$lines = \substr_count($buffer, "\n");
|
||||
|
||||
if (\substr($buffer, -1) !== "\n") {
|
||||
$lines++;
|
||||
}
|
||||
|
||||
$this->cacheNumLines[$file] = $lines;
|
||||
$this->cacheNumLines[$fileName] = $lines;
|
||||
}
|
||||
|
||||
return $this->cacheNumLines[$file];
|
||||
return $this->cacheNumLines[$fileName];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user