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:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -17,7 +17,7 @@ use SebastianBergmann\CodeCoverage\RuntimeException;
/**
* Generates an HTML report from a code coverage object.
*/
class Facade
final class Facade
{
/**
* @var string
@@ -39,14 +39,7 @@ class Facade
*/
private $highLowerBound;
/**
* Constructor.
*
* @param int $lowUpperBound
* @param int $highLowerBound
* @param string $generator
*/
public function __construct($lowUpperBound = 50, $highLowerBound = 90, $generator = '')
public function __construct(int $lowUpperBound = 50, int $highLowerBound = 90, string $generator = '')
{
$this->generator = $generator;
$this->highLowerBound = $highLowerBound;
@@ -55,14 +48,14 @@ class Facade
}
/**
* @param CodeCoverage $coverage
* @param string $target
* @throws RuntimeException
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function process(CodeCoverage $coverage, $target)
public function process(CodeCoverage $coverage, string $target): void
{
$target = $this->getDirectory($target);
$report = $coverage->getReport();
unset($coverage);
if (!isset($_SERVER['REQUEST_TIME'])) {
$_SERVER['REQUEST_TIME'] = \time();
@@ -101,8 +94,8 @@ class Facade
$id = $node->getId();
if ($node instanceof DirectoryNode) {
if (!\file_exists($target . $id)) {
\mkdir($target . $id, 0777, true);
if (!$this->createDirectory($target . $id)) {
throw new \RuntimeException(\sprintf('Directory "%s" was not created', $target . $id));
}
$directory->render($node, $target . $id . '/index.html');
@@ -110,8 +103,8 @@ class Facade
} else {
$dir = \dirname($target . $id);
if (!\file_exists($dir)) {
\mkdir($dir, 0777, true);
if (!$this->createDirectory($dir)) {
throw new \RuntimeException(\sprintf('Directory "%s" was not created', $dir));
}
$file->render($node, $target . $id . '.html');
@@ -122,9 +115,9 @@ class Facade
}
/**
* @param string $target
* @throws RuntimeException
*/
private function copyFiles($target)
private function copyFiles(string $target): void
{
$dir = $this->getDirectory($target . '.css');
@@ -140,6 +133,7 @@ class Facade
\copy($this->templatePath . 'css/nv.d3.min.css', $dir . 'nv.d3.min.css');
\copy($this->templatePath . 'css/style.css', $dir . 'style.css');
\copy($this->templatePath . 'css/custom.css', $dir . 'custom.css');
$dir = $this->getDirectory($target . '.fonts');
\copy($this->templatePath . 'fonts/glyphicons-halflings-regular.eot', $dir . 'glyphicons-halflings-regular.eot');
@@ -160,31 +154,28 @@ class Facade
}
/**
* @param string $directory
*
* @return string
*
* @throws RuntimeException
*/
private function getDirectory($directory)
private function getDirectory(string $directory): string
{
if (\substr($directory, -1, 1) != DIRECTORY_SEPARATOR) {
$directory .= DIRECTORY_SEPARATOR;
}
if (\is_dir($directory)) {
return $directory;
if (!$this->createDirectory($directory)) {
throw new RuntimeException(
\sprintf(
'Directory "%s" does not exist.',
$directory
)
);
}
if (@\mkdir($directory, 0777, true)) {
return $directory;
}
return $directory;
}
throw new RuntimeException(
\sprintf(
'Directory "%s" does not exist.',
$directory
)
);
private function createDirectory(string $directory): bool
{
return !(!\is_dir($directory) && !@\mkdir($directory, 0777, true) && !\is_dir($directory));
}
}

View File

@@ -51,16 +51,7 @@ abstract class Renderer
*/
protected $version;
/**
* Constructor.
*
* @param string $templatePath
* @param string $generator
* @param string $date
* @param int $lowUpperBound
* @param int $highLowerBound
*/
public function __construct($templatePath, $generator, $date, $lowUpperBound, $highLowerBound)
public function __construct(string $templatePath, string $generator, string $date, int $lowUpperBound, int $highLowerBound)
{
$this->templatePath = $templatePath;
$this->generator = $generator;
@@ -70,13 +61,7 @@ abstract class Renderer
$this->version = Version::id();
}
/**
* @param \Text_Template $template
* @param array $data
*
* @return string
*/
protected function renderItemTemplate(\Text_Template $template, array $data)
protected function renderItemTemplate(\Text_Template $template, array $data): string
{
$numSeparator = ' / ';
@@ -130,8 +115,8 @@ abstract class Renderer
$template->setVar(
[
'icon' => isset($data['icon']) ? $data['icon'] : '',
'crap' => isset($data['crap']) ? $data['crap'] : '',
'icon' => $data['icon'] ?? '',
'crap' => $data['crap'] ?? '',
'name' => $data['name'],
'lines_bar' => $linesBar,
'lines_executed_percent' => $data['linesExecutedPercentAsString'],
@@ -142,7 +127,7 @@ abstract class Renderer
'methods_level' => $methodsLevel,
'methods_number' => $methodsNumber,
'classes_bar' => $classesBar,
'classes_tested_percent' => isset($data['testedClassesPercentAsString']) ? $data['testedClassesPercentAsString'] : '',
'classes_tested_percent' => $data['testedClassesPercentAsString'] ?? '',
'classes_level' => $classesLevel,
'classes_number' => $classesNumber
]
@@ -151,11 +136,7 @@ abstract class Renderer
return $template->render();
}
/**
* @param \Text_Template $template
* @param AbstractNode $node
*/
protected function setCommonTemplateVariables(\Text_Template $template, AbstractNode $node)
protected function setCommonTemplateVariables(\Text_Template $template, AbstractNode $node): void
{
$template->setVar(
[
@@ -173,7 +154,7 @@ abstract class Renderer
);
}
protected function getBreadcrumbs(AbstractNode $node)
protected function getBreadcrumbs(AbstractNode $node): string
{
$breadcrumbs = '';
$path = $node->getPathAsArray();
@@ -202,7 +183,7 @@ abstract class Renderer
return $breadcrumbs;
}
protected function getActiveBreadcrumb(AbstractNode $node)
protected function getActiveBreadcrumb(AbstractNode $node): string
{
$buffer = \sprintf(
' <li class="active">%s</li>' . "\n",
@@ -216,7 +197,7 @@ abstract class Renderer
return $buffer;
}
protected function getInactiveBreadcrumb(AbstractNode $node, $pathToRoot)
protected function getInactiveBreadcrumb(AbstractNode $node, string $pathToRoot): string
{
return \sprintf(
' <li><a href="%sindex.html">%s</a></li>' . "\n",
@@ -225,12 +206,12 @@ abstract class Renderer
);
}
protected function getPathToRoot(AbstractNode $node)
protected function getPathToRoot(AbstractNode $node): string
{
$id = $node->getId();
$depth = \substr_count($id, '/');
if ($id != 'index' &&
if ($id !== 'index' &&
$node instanceof DirectoryNode) {
$depth++;
}
@@ -238,7 +219,7 @@ abstract class Renderer
return \str_repeat('../', $depth);
}
protected function getCoverageBar($percent)
protected function getCoverageBar(float $percent): string
{
$level = $this->getColorLevel($percent);
@@ -253,27 +234,21 @@ abstract class Renderer
return $template->render();
}
/**
* @param int $percent
*
* @return string
*/
protected function getColorLevel($percent)
protected function getColorLevel(float $percent): string
{
if ($percent <= $this->lowUpperBound) {
return 'danger';
} elseif ($percent > $this->lowUpperBound &&
}
if ($percent > $this->lowUpperBound &&
$percent < $this->highLowerBound) {
return 'warning';
} else {
return 'success';
}
return 'success';
}
/**
* @return string
*/
private function getRuntimeString()
private function getRuntimeString(): string
{
$runtime = new Runtime;

View File

@@ -16,15 +16,13 @@ use SebastianBergmann\CodeCoverage\Node\Directory as DirectoryNode;
/**
* Renders the dashboard for a directory node.
*/
class Dashboard extends Renderer
final class Dashboard extends Renderer
{
/**
* @param DirectoryNode $node
* @param string $file
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function render(DirectoryNode $node, $file)
public function render(DirectoryNode $node, string $file)
{
$classes = $node->getClassesAndTraits();
$template = new \Text_Template(
@@ -59,13 +57,8 @@ class Dashboard extends Renderer
/**
* Returns the data for the Class/Method Complexity charts.
*
* @param array $classes
* @param string $baseLink
*
* @return array
*/
protected function complexity(array $classes, $baseLink)
protected function complexity(array $classes, string $baseLink): array
{
$result = ['class' => [], 'method' => []];
@@ -105,12 +98,8 @@ class Dashboard extends Renderer
/**
* Returns the data for the Class / Method Coverage Distribution chart.
*
* @param array $classes
*
* @return array
*/
protected function coverageDistribution(array $classes)
protected function coverageDistribution(array $classes): array
{
$result = [
'class' => [
@@ -175,13 +164,8 @@ class Dashboard extends Renderer
/**
* Returns the classes / methods with insufficient coverage.
*
* @param array $classes
* @param string $baseLink
*
* @return array
*/
protected function insufficientCoverage(array $classes, $baseLink)
protected function insufficientCoverage(array $classes, string $baseLink): array
{
$leastTestedClasses = [];
$leastTestedMethods = [];
@@ -218,7 +202,7 @@ class Dashboard extends Renderer
}
foreach ($leastTestedMethods as $methodName => $coverage) {
list($class, $method) = \explode('::', $methodName);
[$class, $method] = \explode('::', $methodName);
$result['method'] .= \sprintf(
' <tr><td><a href="%s"><abbr title="%s">%s</abbr></a></td><td class="text-right">%d%%</td></tr>' . "\n",
@@ -234,13 +218,8 @@ class Dashboard extends Renderer
/**
* Returns the project risks according to the CRAP index.
*
* @param array $classes
* @param string $baseLink
*
* @return array
*/
protected function projectRisks(array $classes, $baseLink)
protected function projectRisks(array $classes, string $baseLink): array
{
$classRisks = [];
$methodRisks = [];
@@ -248,12 +227,11 @@ class Dashboard extends Renderer
foreach ($classes as $className => $class) {
foreach ($class['methods'] as $methodName => $method) {
if ($method['coverage'] < $this->highLowerBound &&
$method['ccn'] > 1) {
if ($method['coverage'] < $this->highLowerBound && $method['ccn'] > 1) {
$key = $methodName;
if ($className !== '*') {
$key = $className . '::' . $methodName;
} else {
$key = $methodName;
}
$methodRisks[$key] = $method['crap'];
@@ -279,7 +257,7 @@ class Dashboard extends Renderer
}
foreach ($methodRisks as $methodName => $crap) {
list($class, $method) = \explode('::', $methodName);
[$class, $method] = \explode('::', $methodName);
$result['method'] .= \sprintf(
' <tr><td><a href="%s"><abbr title="%s">%s</abbr></a></td><td class="text-right">%d</td></tr>' . "\n",
@@ -293,7 +271,7 @@ class Dashboard extends Renderer
return $result;
}
protected function getActiveBreadcrumb(AbstractNode $node)
protected function getActiveBreadcrumb(AbstractNode $node): string
{
return \sprintf(
' <li><a href="index.html">%s</a></li>' . "\n" .

View File

@@ -16,13 +16,13 @@ use SebastianBergmann\CodeCoverage\Node\Directory as DirectoryNode;
/**
* Renders a directory node.
*/
class Directory extends Renderer
final class Directory extends Renderer
{
/**
* @param DirectoryNode $node
* @param string $file
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function render(DirectoryNode $node, $file)
public function render(DirectoryNode $node, string $file): void
{
$template = new \Text_Template($this->templatePath . 'directory.html', '{{', '}}');
@@ -48,13 +48,7 @@ class Directory extends Renderer
$template->renderTo($file);
}
/**
* @param Node $node
* @param bool $total
*
* @return string
*/
protected function renderItem(Node $node, $total = false)
protected function renderItem(Node $node, bool $total = false): string
{
$data = [
'numClasses' => $node->getNumClassesAndTraits(),

View File

@@ -16,42 +16,17 @@ use SebastianBergmann\CodeCoverage\Util;
/**
* Renders a file node.
*/
class File extends Renderer
final class File extends Renderer
{
/**
* @var int
*/
private $htmlspecialcharsFlags;
private $htmlSpecialCharsFlags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE;
/**
* Constructor.
*
* @param string $templatePath
* @param string $generator
* @param string $date
* @param int $lowUpperBound
* @param int $highLowerBound
* @throws \RuntimeException
*/
public function __construct($templatePath, $generator, $date, $lowUpperBound, $highLowerBound)
{
parent::__construct(
$templatePath,
$generator,
$date,
$lowUpperBound,
$highLowerBound
);
$this->htmlspecialcharsFlags = ENT_COMPAT;
$this->htmlspecialcharsFlags = $this->htmlspecialcharsFlags | ENT_HTML401 | ENT_SUBSTITUTE;
}
/**
* @param FileNode $node
* @param string $file
*/
public function render(FileNode $node, $file)
public function render(FileNode $node, string $file): void
{
$template = new \Text_Template($this->templatePath . 'file.html', '{{', '}}');
@@ -67,12 +42,7 @@ class File extends Renderer
$template->renderTo($file);
}
/**
* @param FileNode $node
*
* @return string
*/
protected function renderItems(FileNode $node)
protected function renderItems(FileNode $node): string
{
$template = new \Text_Template($this->templatePath . 'file_item.html', '{{', '}}');
@@ -122,14 +92,7 @@ class File extends Renderer
return $items;
}
/**
* @param array $items
* @param \Text_Template $template
* @param \Text_Template $methodItemTemplate
*
* @return string
*/
protected function renderTraitOrClassItems(array $items, \Text_Template $template, \Text_Template $methodItemTemplate)
protected function renderTraitOrClassItems(array $items, \Text_Template $template, \Text_Template $methodItemTemplate): string
{
$buffer = '';
@@ -183,8 +146,7 @@ class File extends Renderer
'numExecutableLines' => $item['executableLines'],
'testedMethodsPercent' => Util::percent(
$numTestedMethods,
$numMethods,
false
$numMethods
),
'testedMethodsPercentAsString' => Util::percent(
$numTestedMethods,
@@ -193,8 +155,7 @@ class File extends Renderer
),
'testedClassesPercent' => Util::percent(
$numTestedMethods == $numMethods ? 1 : 0,
1,
false
1
),
'testedClassesPercentAsString' => Util::percent(
$numTestedMethods == $numMethods ? 1 : 0,
@@ -217,13 +178,7 @@ class File extends Renderer
return $buffer;
}
/**
* @param array $functions
* @param \Text_Template $template
*
* @return string
*/
protected function renderFunctionItems(array $functions, \Text_Template $template)
protected function renderFunctionItems(array $functions, \Text_Template $template): string
{
if (empty($functions)) {
return '';
@@ -241,12 +196,7 @@ class File extends Renderer
return $buffer;
}
/**
* @param \Text_Template $template
*
* @return string
*/
protected function renderFunctionOrMethodItem(\Text_Template $template, array $item, $indent = '')
protected function renderFunctionOrMethodItem(\Text_Template $template, array $item, string $indent = ''): string
{
$numMethods = 0;
$numTestedMethods = 0;
@@ -266,15 +216,14 @@ class File extends Renderer
'%s<a href="#%d"><abbr title="%s">%s</abbr></a>',
$indent,
$item['startLine'],
\htmlspecialchars($item['signature']),
isset($item['functionName']) ? $item['functionName'] : $item['methodName']
\htmlspecialchars($item['signature'], $this->htmlSpecialCharsFlags),
$item['functionName'] ?? $item['methodName']
),
'numMethods' => $numMethods,
'numTestedMethods' => $numTestedMethods,
'linesExecutedPercent' => Util::percent(
$item['executedLines'],
$item['executableLines'],
false
$item['executableLines']
),
'linesExecutedPercentAsString' => Util::percent(
$item['executedLines'],
@@ -285,8 +234,7 @@ class File extends Renderer
'numExecutableLines' => $item['executableLines'],
'testedMethodsPercent' => Util::percent(
$numTestedMethods,
1,
false
1
),
'testedMethodsPercentAsString' => Util::percent(
$numTestedMethods,
@@ -303,7 +251,7 @@ class File extends Renderer
*
* @return string
*/
protected function renderSource(FileNode $node)
protected function renderSource(FileNode $node): string
{
$coverageData = $node->getCoverageData();
$testData = $node->getTestData();
@@ -384,7 +332,7 @@ class File extends Renderer
$popoverContent .= \sprintf(
'<li%s>%s</li>',
$testCSS,
\htmlspecialchars($test)
\htmlspecialchars($test, $this->htmlSpecialCharsFlags)
);
}
@@ -393,14 +341,14 @@ class File extends Renderer
}
}
$popover = '';
if (!empty($popoverTitle)) {
$popover = \sprintf(
' data-title="%s" data-content="%s" data-placement="bottom" data-html="true"',
$popoverTitle,
\htmlspecialchars($popoverContent)
\htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags)
);
} else {
$popover = '';
}
$lines .= \sprintf(
@@ -424,7 +372,7 @@ class File extends Renderer
*
* @return array
*/
protected function loadFile($file)
protected function loadFile($file): array
{
$buffer = \file_get_contents($file);
$tokens = \token_get_all($buffer);
@@ -440,26 +388,26 @@ class File extends Renderer
if ($token === '"' && $tokens[$j - 1] !== '\\') {
$result[$i] .= \sprintf(
'<span class="string">%s</span>',
\htmlspecialchars($token)
\htmlspecialchars($token, $this->htmlSpecialCharsFlags)
);
$stringFlag = !$stringFlag;
} else {
$result[$i] .= \sprintf(
'<span class="keyword">%s</span>',
\htmlspecialchars($token)
\htmlspecialchars($token, $this->htmlSpecialCharsFlags)
);
}
continue;
}
list($token, $value) = $token;
[$token, $value] = $token;
$value = \str_replace(
["\t", ' '],
['&nbsp;&nbsp;&nbsp;&nbsp;', '&nbsp;'],
\htmlspecialchars($value, $this->htmlspecialcharsFlags)
\htmlspecialchars($value, $this->htmlSpecialCharsFlags)
);
if ($value === "\n") {

View File

@@ -7,6 +7,7 @@
<link href="{{path_to_root}}.css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="{{path_to_root}}.css/nv.d3.min.css" rel="stylesheet" type="text/css">
<link href="{{path_to_root}}.css/style.css" rel="stylesheet" type="text/css">
<link href="{{path_to_root}}.css/custom.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="{{path_to_root}}.js/html5shiv.min.js"></script>
<script src="{{path_to_root}}.js/respond.min.js"></script>

View File

@@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{{path_to_root}}.css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="{{path_to_root}}.css/style.css" rel="stylesheet" type="text/css">
<link href="{{path_to_root}}.css/custom.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="{{path_to_root}}.js/html5shiv.min.js"></script>
<script src="{{path_to_root}}.js/respond.min.js"></script>

View File

@@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="{{path_to_root}}.css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="{{path_to_root}}.css/style.css" rel="stylesheet" type="text/css">
<link href="{{path_to_root}}.css/custom.css" rel="stylesheet" type="text/css">
<!--[if lt IE 9]>
<script src="{{path_to_root}}.js/html5shiv.min.js"></script>
<script src="{{path_to_root}}.js/respond.min.js"></script>