commit
af6d92aba0
|
@ -9,11 +9,6 @@
|
|||
|
||||
# Testing - created by test/setup_vendor.sh
|
||||
/vendor/
|
||||
/Hamcrest*
|
||||
/Mockery*
|
||||
/Icinga
|
||||
/Zend
|
||||
/*.phar
|
||||
|
||||
# Exclude application log files
|
||||
var/log/*
|
||||
|
|
30
.travis.yml
30
.travis.yml
|
@ -7,9 +7,28 @@ php:
|
|||
- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
- nightly
|
||||
|
||||
env:
|
||||
- CHECK=phpunit
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- env: CHECK=phpcs
|
||||
php: '7.3'
|
||||
- env: CHECK=phpcs
|
||||
php: '7.0'
|
||||
- env: CHECK=phpcs
|
||||
php: '5.6'
|
||||
- env: CHECK=syntax
|
||||
php: 'nightly'
|
||||
- env: CHECK=syntax
|
||||
php: '7.3'
|
||||
- env: CHECK=syntax
|
||||
php: '7.0'
|
||||
- env: CHECK=syntax
|
||||
php: '5.6'
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
|
||||
|
@ -32,12 +51,13 @@ notifications:
|
|||
# also see: test/setup_vendor.sh
|
||||
before_script:
|
||||
- php -m
|
||||
- sh -c '[ -z $LOCALE_GEN ] || sudo locale-gen en_US.UTF-8 de_DE.UTF-8 fr_FR.UTF-8'
|
||||
- sh -c '[ -z $ENABLE_LDAP ] || phpenv config-add test/travis-ldap.ini'
|
||||
- test/travis_database.sh
|
||||
- '[ -z $LOCALE_GEN ] || sudo locale-gen en_US.UTF-8 de_DE.UTF-8 fr_FR.UTF-8'
|
||||
- '[ -z $ENABLE_LDAP ] || phpenv config-add test/travis-ldap.ini'
|
||||
- test/setup_vendor.sh
|
||||
- 'if [ "$CHECK" = phpunit ]; then test/travis_database.sh; fi'
|
||||
|
||||
script:
|
||||
# also see: modules/test/application/clicommands/PhpCommand.php
|
||||
- php phpcs.phar
|
||||
- php phpunit.phar -c modules/test/phpunit.xml --verbose
|
||||
- 'if [ "$CHECK" = phpcs ]; then php vendor/phpcs.phar; fi'
|
||||
- 'if [ "$CHECK" = phpunit ]; then php vendor/phpunit.phar -c modules/test/phpunit.xml --verbose; fi'
|
||||
- 'if [ "$CHECK" = syntax ]; then php test/check-syntax.php -e "^(\./)?vendor/" -e Icinga/Util/String.php; fi'
|
||||
|
|
|
@ -409,7 +409,7 @@ class GridChart extends Chart
|
|||
);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$el = $this->setupGraph($graphObj, $graph);
|
||||
if ($el) {
|
||||
|
|
|
@ -183,7 +183,7 @@ class Minifier
|
|||
// new lines
|
||||
case "\n":
|
||||
// if the next line is something that can't stand alone preserve the newline
|
||||
if (strpos('(-+[@', $this->b) !== false) {
|
||||
if ($this->b !== false && strpos('(-+[@', $this->b) !== false) {
|
||||
echo $this->a;
|
||||
$this->saveString();
|
||||
break;
|
||||
|
@ -231,7 +231,7 @@ class Minifier
|
|||
// check for some regex that breaks stuff
|
||||
if ($this->a === '/' && ($this->b === '\'' || $this->b === '"')) {
|
||||
$this->saveRegex();
|
||||
continue;
|
||||
continue 3;
|
||||
}
|
||||
|
||||
echo $this->a;
|
||||
|
@ -274,9 +274,8 @@ class Minifier
|
|||
if (isset($this->c)) {
|
||||
$char = $this->c;
|
||||
unset($this->c);
|
||||
|
||||
// Otherwise we start pulling from the input.
|
||||
} else {
|
||||
// Otherwise we start pulling from the input.
|
||||
$char = substr($this->input, $this->index, 1);
|
||||
|
||||
// If the next character doesn't exist return false.
|
||||
|
@ -459,11 +458,8 @@ class Minifier
|
|||
echo $this->a;
|
||||
|
||||
// Loop until the string is done
|
||||
while (true) {
|
||||
|
||||
// Grab the very next character and load it into a
|
||||
$this->a = $this->getChar();
|
||||
|
||||
// Grab the very next character and load it into a
|
||||
while (($this->a = $this->getChar()) !== false) {
|
||||
switch ($this->a) {
|
||||
|
||||
// If the string opener (single or double quote) is used
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
curl https://codeload.github.com/tedious/JShrink/tar.gz/v1.3.0 -o JShrink-1.3.0.tar.gz
|
||||
tar xzf JShrink-1.3.0.tar.gz --strip-components 1 JShrink-1.3.0/LICENSE
|
||||
tar xzf JShrink-1.3.0.tar.gz --strip-components 3 JShrink-1.3.0/src/JShrink/Minifier.php
|
||||
rm JShrink-1.3.0.tar.gz
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
VERSION=1.3.1
|
||||
curl -LsS https://github.com/tedious/JShrink/archive/v"$VERSION".tar.gz -o /tmp/JShrink.tar.gz
|
||||
tar xzf /tmp/JShrink.tar.gz --strip-components 1 JShrink-"$VERSION"/LICENSE
|
||||
tar xzf /tmp/JShrink.tar.gz --strip-components 3 JShrink-"$VERSION"/src/JShrink/Minifier.php
|
||||
rm /tmp/JShrink.tar.gz
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
GLOBIGNORE=$0; rm -rf *
|
||||
#!/bin/bash
|
||||
set -eux
|
||||
#GLOBIGNORE=$0; rm -rf *
|
||||
|
||||
curl https://codeload.github.com/dompdf/dompdf/tar.gz/v0.8.2 -o dompdf-0.8.2.tar.gz
|
||||
tar xzf dompdf-0.8.2.tar.gz --strip-components 1 dompdf-0.8.2/{lib,src,LICENSE.LGPL}
|
||||
rm dompdf-0.8.2.tar.gz
|
||||
#DOMPDF_VERSION=0.8.2
|
||||
DOMPDF_VERSION=6a77a427984f97743018ace3e095fbf0edaaee29 # https://github.com/dompdf/dompdf/pull/1854
|
||||
|
||||
PHP_FONTLIB_VERSION=0.5.1
|
||||
PHP_SVGLIB_VERSION=0.3.2
|
||||
|
||||
rm -rf lib/ src/
|
||||
|
||||
curl -LsS https://github.com/dompdf/dompdf/archive/"$DOMPDF_VERSION".tar.gz -o /tmp/dompdf.tar.gz
|
||||
tar xf /tmp/dompdf.tar.gz --strip-components 1 dompdf-"$DOMPDF_VERSION"/{lib,src,LICENSE.LGPL}
|
||||
rm /tmp/dompdf.tar.gz
|
||||
mv LICENSE.LGPL LICENSE
|
||||
|
||||
curl https://codeload.github.com/PhenX/php-font-lib/tar.gz/0.5.1 -o php-font-lib-0.5.1.tar.gz
|
||||
mkdir -p lib/php-font-lib
|
||||
tar xzf php-font-lib-0.5.1.tar.gz --strip-components 1 -C lib/php-font-lib php-font-lib-0.5.1/{src,LICENSE}
|
||||
rm php-font-lib-0.5.1.tar.gz
|
||||
curl -LsS https://github.com/PhenX/php-font-lib/archive/"$PHP_FONTLIB_VERSION".tar.gz -o /tmp/php-font-lib.tar.gz
|
||||
[ -d lib/php-font-lib ] || mkdir -p lib/php-font-lib
|
||||
tar xf /tmp/php-font-lib.tar.gz --strip-components 1 -C lib/php-font-lib php-font-lib-"$PHP_FONTLIB_VERSION"/{src,LICENSE}
|
||||
rm /tmp/php-font-lib.tar.gz
|
||||
|
||||
curl https://codeload.github.com/PhenX/php-svg-lib/tar.gz/v0.3.2 -o php-svg-lib-0.3.2.tar.gz
|
||||
mkdir -p lib/php-svg-lib
|
||||
tar xzf php-svg-lib-0.3.2.tar.gz --strip-components 1 -C lib/php-svg-lib php-svg-lib-0.3.2/src
|
||||
rm php-svg-lib-0.3.2.tar.gz
|
||||
curl -LsS https://github.com/PhenX/php-svg-lib/archive/v"$PHP_SVGLIB_VERSION".tar.gz -o /tmp/php-svg-lib.tar.gz
|
||||
[ -d lib/php-svg-lib ] || mkdir -p lib/php-svg-lib
|
||||
tar xf /tmp/php-svg-lib.tar.gz --strip-components 1 -C lib/php-svg-lib php-svg-lib-"$PHP_SVGLIB_VERSION"/src
|
||||
rm /tmp/php-svg-lib.tar.gz
|
||||
|
|
|
@ -464,28 +464,28 @@ class Cpdf
|
|||
// Named with limited valid values
|
||||
case 'NonFullScreenPageMode':
|
||||
if (!in_array($v, array('UseNone', 'UseOutlines', 'UseThumbs', 'UseOC'))) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$o['info'][$k] = $v;
|
||||
break;
|
||||
|
||||
case 'Direction':
|
||||
if (!in_array($v, array('L2R', 'R2L'))) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$o['info'][$k] = $v;
|
||||
break;
|
||||
|
||||
case 'PrintScaling':
|
||||
if (!in_array($v, array('None', 'AppDefault'))) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$o['info'][$k] = $v;
|
||||
break;
|
||||
|
||||
case 'Duplex':
|
||||
if (!in_array($v, array('None', 'AppDefault'))) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$o['info'][$k] = $v;
|
||||
break;
|
||||
|
@ -4801,12 +4801,12 @@ EOT;
|
|||
imagesavealpha($img, false);
|
||||
|
||||
// create temp alpha file
|
||||
$tempfile_alpha = tempnam($this->tmp, "cpdf_img_");
|
||||
$tempfile_alpha = @tempnam($this->tmp, "cpdf_img_");
|
||||
@unlink($tempfile_alpha);
|
||||
$tempfile_alpha = "$tempfile_alpha.png";
|
||||
|
||||
// create temp plain file
|
||||
$tempfile_plain = tempnam($this->tmp, "cpdf_img_");
|
||||
$tempfile_plain = @tempnam($this->tmp, "cpdf_img_");
|
||||
@unlink($tempfile_plain);
|
||||
$tempfile_plain = "$tempfile_plain.png";
|
||||
|
||||
|
|
|
@ -561,6 +561,25 @@ class CPDF implements Canvas
|
|||
$this->_set_line_transparency("Normal", $this->_current_opacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw line at the specified coordinates on every page.
|
||||
*
|
||||
* See {@link Style::munge_color()} for the format of the colour array.
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param array $color
|
||||
* @param float $width
|
||||
* @param array $style optional
|
||||
*/
|
||||
public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = array())
|
||||
{
|
||||
$_t = 'line';
|
||||
$this->_page_text[] = compact('_t', 'x1', 'y1', 'x2', 'y2', 'color', 'width', 'style');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
|
@ -608,7 +627,7 @@ class CPDF implements Canvas
|
|||
imageinterlace($im, false);
|
||||
|
||||
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
|
||||
$tmp_name = tempnam($tmp_dir, "{$type}dompdf_img_");
|
||||
$tmp_name = @tempnam($tmp_dir, "{$type}dompdf_img_");
|
||||
@unlink($tmp_name);
|
||||
$filename = "$tmp_name.png";
|
||||
$this->_image_cache[] = $filename;
|
||||
|
@ -1092,6 +1111,10 @@ class CPDF implements Canvas
|
|||
}
|
||||
$eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
|
||||
break;
|
||||
|
||||
case 'line':
|
||||
$this->line( $x1, $y1, $x2, $y2, $color, $width, $style );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -729,7 +729,7 @@ class GD implements Canvas
|
|||
$func_name = "imagecreatefrom$img_type";
|
||||
if (!function_exists($func_name)) {
|
||||
if (!method_exists("Dompdf\Helpers", $func_name)) {
|
||||
throw new \Exception("Function $func_name() not found. Cannot convert $type image: $img_url. Please install the image PHP extension.");
|
||||
throw new \Exception("Function $func_name() not found. Cannot convert $img_type image: $img_url. Please install the image PHP extension.");
|
||||
}
|
||||
$func_name = "\\Dompdf\\Helpers::" . $func_name;
|
||||
}
|
||||
|
@ -978,6 +978,11 @@ class GD implements Canvas
|
|||
// N/A
|
||||
}
|
||||
|
||||
public function page_line()
|
||||
{
|
||||
// N/A
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams the image to the client.
|
||||
*
|
||||
|
|
|
@ -208,7 +208,7 @@ class PDFLib implements Canvas
|
|||
$this->_pdf->begin_document("", "");
|
||||
} else {
|
||||
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
|
||||
$tmp_name = tempnam($tmp_dir, "libdompdf_pdf_");
|
||||
$tmp_name = @tempnam($tmp_dir, "libdompdf_pdf_");
|
||||
@unlink($tmp_name);
|
||||
$this->_file = "$tmp_name.pdf";
|
||||
$this->_pdf->begin_document($this->_file, "");
|
||||
|
@ -762,6 +762,25 @@ class PDFLib implements Canvas
|
|||
$this->_set_line_transparency("Normal", $this->_current_opacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw line at the specified coordinates on every page.
|
||||
*
|
||||
* See {@link Style::munge_color()} for the format of the colour array.
|
||||
*
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param array $color
|
||||
* @param float $width
|
||||
* @param array $style optional
|
||||
*/
|
||||
public function page_line($x1, $y1, $x2, $y2, $color, $width, $style = array())
|
||||
{
|
||||
$_t = 'line';
|
||||
$this->_page_text[] = compact('_t', 'x1', 'y1', 'x2', 'y2', 'color', 'width', 'style');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $x1
|
||||
* @param float $y1
|
||||
|
@ -1259,6 +1278,11 @@ class PDFLib implements Canvas
|
|||
}
|
||||
$eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
|
||||
break;
|
||||
|
||||
case 'line':
|
||||
$this->line( $x1, $y1, $x2, $y2, $color, $width, $style );
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1357,7 +1357,7 @@ class Stylesheet
|
|||
$key = $page_selector;
|
||||
|
||||
default:
|
||||
continue;
|
||||
continue 3;
|
||||
}
|
||||
|
||||
// Store the style for later...
|
||||
|
|
|
@ -368,7 +368,7 @@ class Dompdf
|
|||
|
||||
$ext = strtolower(pathinfo($realfile, PATHINFO_EXTENSION));
|
||||
if (!in_array($ext, $this->allowedLocalFileExtensions)) {
|
||||
throw new Exception("Permission denied on $file.");
|
||||
throw new Exception("Permission denied on $file. This file extension is forbidden");
|
||||
}
|
||||
|
||||
if (!$realfile) {
|
||||
|
@ -607,7 +607,7 @@ class Dompdf
|
|||
if (!$accept) {
|
||||
//found at least one mediatype, but none of the accepted ones
|
||||
//Skip this css file.
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ class Dompdf
|
|||
($media = $tag->getAttribute("media")) &&
|
||||
!in_array($media, $acceptedmedia)
|
||||
) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
|
||||
$css = "";
|
||||
|
@ -945,7 +945,7 @@ class Dompdf
|
|||
*
|
||||
* @param array $options options (see above)
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function output($options = array())
|
||||
{
|
||||
|
|
|
@ -186,7 +186,7 @@ class FontMetrics
|
|||
$fontDir = $this->getOptions()->getFontDir();
|
||||
$remoteHash = md5($remoteFile);
|
||||
$localFile = $fontDir . DIRECTORY_SEPARATOR . $remoteHash;
|
||||
$localTempFile = tempnam($this->options->get("tempDir"), "dompdf-font-");
|
||||
$localTempFile = @tempnam($this->options->get("tempDir"), "dompdf-font-");
|
||||
|
||||
$cacheEntry = $localFile;
|
||||
$localFile .= ".".strtolower(pathinfo(parse_url($remoteFile, PHP_URL_PATH),PATHINFO_EXTENSION));
|
||||
|
|
|
@ -515,7 +515,7 @@ class Page extends AbstractFrameDecorator
|
|||
// parents of $frame must fit on the page as well:
|
||||
$p = $frame->get_parent();
|
||||
while ($p) {
|
||||
$max_y += $p->get_style()->computed_bottom_spacing();
|
||||
$max_y += (float) $p->get_style()->computed_bottom_spacing();
|
||||
$p = $p->get_parent();
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class Cache
|
|||
} // From remote
|
||||
else {
|
||||
$tmp_dir = $dompdf->getOptions()->getTempDir();
|
||||
$resolved_url = tempnam($tmp_dir, "ca_dompdf_img_");
|
||||
$resolved_url = @tempnam($tmp_dir, "ca_dompdf_img_");
|
||||
$image = "";
|
||||
|
||||
if ($data_uri) {
|
||||
|
|
|
@ -401,7 +401,7 @@ abstract class AbstractRenderer
|
|||
$this->_canvas->get_cpdf()->addImagePng($filedummy, $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg);
|
||||
} else {
|
||||
$tmp_dir = $this->_dompdf->getOptions()->getTempDir();
|
||||
$tmp_name = tempnam($tmp_dir, "bg_dompdf_img_");
|
||||
$tmp_name = @tempnam($tmp_dir, "bg_dompdf_img_");
|
||||
@unlink($tmp_name);
|
||||
$tmp_file = "$tmp_name.png";
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ class Text extends AbstractRenderer
|
|||
|
||||
switch ($text_deco) {
|
||||
default:
|
||||
continue;
|
||||
continue 2;
|
||||
|
||||
case "underline":
|
||||
$deco_y += $base - $descent + $underline_offset + $line_thickness / 2;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<file>test/</file>
|
||||
|
||||
<exclude-pattern>vendor/*</exclude-pattern>
|
||||
<exclude-pattern>test/*.php</exclude-pattern>
|
||||
<exclude-pattern>application/fonts/fontello-ifont/*</exclude-pattern>
|
||||
|
||||
<arg value="wps"/>
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
function findPhpFiles($dir, &$files = [])
|
||||
{
|
||||
if (substr($dir, -1, 1) !== DIRECTORY_SEPARATOR) {
|
||||
$dir .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($name = readdir($dh)) !== false) {
|
||||
$path = $dir . $name;
|
||||
|
||||
if (substr($name, 0, 1) === '.') {
|
||||
continue;
|
||||
} elseif (is_file($path) && preg_match('~\.ph(p|tml)$~i', $path)) {
|
||||
$files[] = $path;
|
||||
} elseif (is_dir($path)) {
|
||||
findPhpFiles($path, $files);
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
|
||||
return $files;
|
||||
} else {
|
||||
throw new Exception('Could not read directory: ' . $dir);
|
||||
}
|
||||
}
|
||||
|
||||
function stdout($t, $color = '32')
|
||||
{
|
||||
if (posix_isatty(STDOUT) && $color) {
|
||||
$t = "\e[${color}m" . $t . "\e[39m";
|
||||
}
|
||||
fwrite(STDOUT, $t);
|
||||
}
|
||||
|
||||
function stderr($t)
|
||||
{
|
||||
if (posix_isatty(STDERR)) {
|
||||
$t = "\e[91m" . $t . "\e[39m";
|
||||
}
|
||||
fwrite(STDERR, $t);
|
||||
}
|
||||
|
||||
function checkFile($path, &$errors)
|
||||
{
|
||||
$escapedPath = escapeshellarg($path);
|
||||
exec("php -l ${escapedPath} 2>&1 >/dev/null", $output, $rc);
|
||||
|
||||
if (! empty($output) || $rc != 0) {
|
||||
stdout('E', '91');
|
||||
|
||||
foreach ($output as $line) {
|
||||
// remove own name from text
|
||||
$line = preg_replace('~ in ' . preg_quote($path) . '~i', '', $line);
|
||||
|
||||
$errors[$path][] = $line;
|
||||
}
|
||||
} else {
|
||||
stdout('.');
|
||||
}
|
||||
}
|
||||
|
||||
function usage()
|
||||
{
|
||||
printf("Usage: %s [--verbose] [--exclude file-regex] [path]\n\n", $_SERVER['argv'][0]);
|
||||
}
|
||||
|
||||
function main($argv)
|
||||
{
|
||||
$fileCount = 0;
|
||||
$verbose = false;
|
||||
$errors = [];
|
||||
$excludes = [];
|
||||
$searchPaths = [];
|
||||
|
||||
for ($i = 1; $i < count($argv); $i++) {
|
||||
$arg = $argv[$i];
|
||||
switch ($arg) {
|
||||
case '-h':
|
||||
case '--help':
|
||||
usage();
|
||||
return 1;
|
||||
case '-v':
|
||||
case '--verbose':
|
||||
$verbose = true;
|
||||
break;
|
||||
case '-e':
|
||||
case '--exclude':
|
||||
$excludes[] = $argv[++$i];
|
||||
break;
|
||||
default:
|
||||
if (substr($arg, 0, 1) === '-') {
|
||||
stderr("Unknown argument: $arg");
|
||||
return 1;
|
||||
} else {
|
||||
$searchPaths[] = $arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($searchPaths)) {
|
||||
$searchPaths = ['.'];
|
||||
}
|
||||
|
||||
$files = [];
|
||||
foreach ($searchPaths as $basePath) {
|
||||
findPhpFiles($basePath, $files);
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
foreach ($excludes as $exclude) {
|
||||
if (preg_match("~$exclude~", $file)) {
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
$fileCount++;
|
||||
|
||||
if ($verbose) {
|
||||
printf("%s\n", $file);
|
||||
}
|
||||
checkFile($file, $errors);
|
||||
}
|
||||
|
||||
$errorCount = count($errors);
|
||||
if ($fileCount === 0) {
|
||||
stderr("error: No files found!\n");
|
||||
return 2;
|
||||
} elseif ($errorCount > 0) {
|
||||
stdout("\n");
|
||||
|
||||
foreach ($errors as $file => $errList) {
|
||||
stderr("\n$file\n " . join("\n ", $errList) . "\n");
|
||||
}
|
||||
|
||||
stderr(sprintf("\nFound syntax errors in %d of %d files! \n", $errorCount, $fileCount));
|
||||
return 1;
|
||||
} else {
|
||||
stdout(sprintf("\n\nChecked %d files successfully! \n", $fileCount));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
exit(main($_SERVER['argv']));
|
|
@ -18,7 +18,11 @@ if (!defined('ICINGA_LIBDIR')) {
|
|||
}
|
||||
|
||||
// This is needed to get the Zend Plugin loader working
|
||||
set_include_path(implode(PATH_SEPARATOR, array($libraryPath, get_include_path())));
|
||||
set_include_path(implode(PATH_SEPARATOR, [
|
||||
$libraryPath,
|
||||
$basePath . DIRECTORY_SEPARATOR . 'vendor',
|
||||
get_include_path()
|
||||
]));
|
||||
|
||||
require_once 'Mockery/Loader.php';
|
||||
$mockeryLoader = new \Mockery\Loader;
|
||||
|
|
|
@ -2,57 +2,72 @@
|
|||
|
||||
set -ex
|
||||
|
||||
ICINGAWEB_HOME=${ICINGAWEB_HOME:="$(dirname "$(readlink -f $(dirname "$0"))")"}
|
||||
PHPCS_VERSION=${PHPCS_VERSION:=3.0.2}
|
||||
ICINGAWEB_HOME=${ICINGAWEB_HOME:="$(dirname "$(readlink -f "$(dirname "$0")")")"}
|
||||
PHPCS_VERSION=${PHPCS_VERSION:=3.3.2}
|
||||
MOCKERY_VERSION=${MOCKERY_VERSION:=0.9.9}
|
||||
HAMCREST_VERSION=${HAMCREST_VERSION:=2.0.0}
|
||||
PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7}
|
||||
|
||||
cd ${ICINGAWEB_HOME}
|
||||
cd "${ICINGAWEB_HOME}"
|
||||
|
||||
test -d vendor || mkdir vendor
|
||||
cd vendor/
|
||||
|
||||
del_old_link() {
|
||||
if [ -L "$1" ]; then
|
||||
rm "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# phpunit
|
||||
phpunit_path="vendor/phpunit-${PHPUNIT_VERSION}"
|
||||
phpunit_path="phpunit-${PHPUNIT_VERSION}"
|
||||
if [ ! -e "${phpunit_path}".phar ]; then
|
||||
wget -O "${phpunit_path}".phar https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar
|
||||
fi
|
||||
ln -svf "${phpunit_path}".phar phpunit.phar
|
||||
del_old_link ../phpunit.phar
|
||||
|
||||
# phpcs
|
||||
phpcs_path="vendor/phpcs-${PHPCS_VERSION}"
|
||||
phpcs_path="phpcs-${PHPCS_VERSION}"
|
||||
if [ ! -e "${phpcs_path}".phar ]; then
|
||||
wget -O "${phpcs_path}".phar \
|
||||
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar
|
||||
fi
|
||||
ln -svf "${phpcs_path}".phar phpcs.phar
|
||||
phpcbf_path="vendor/phpcbf-${PHPCS_VERSION}"
|
||||
del_old_link ../phpcs.phar
|
||||
|
||||
phpcbf_path="phpcbf-${PHPCS_VERSION}"
|
||||
if [ ! -e "${phpcbf_path}".phar ]; then
|
||||
wget -O "${phpcbf_path}".phar \
|
||||
https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcbf.phar
|
||||
fi
|
||||
ln -svf "${phpcbf_path}".phar phpcbf.phar
|
||||
del_old_link ../phpcbf.phar
|
||||
|
||||
# mockery
|
||||
mockery_path="vendor/mockery-${MOCKERY_VERSION}"
|
||||
mockery_path="mockery-${MOCKERY_VERSION}"
|
||||
if [ ! -e "${mockery_path}".tar.gz ]; then
|
||||
wget -O "${mockery_path}".tar.gz \
|
||||
https://github.com/mockery/mockery/archive/${MOCKERY_VERSION}.tar.gz
|
||||
fi
|
||||
if [ ! -d "${mockery_path}" ]; then
|
||||
tar xf "${mockery_path}".tar.gz -C vendor/
|
||||
tar xf "${mockery_path}".tar.gz
|
||||
fi
|
||||
ln -svf "${mockery_path}"/library/Mockery
|
||||
ln -svf "${mockery_path}"/library/Mockery.php
|
||||
ln -svf "${mockery_path}"/library/Mockery Mockery
|
||||
ln -svf "${mockery_path}"/library/Mockery.php Mockery.php
|
||||
del_old_link ../Mockery
|
||||
del_old_link ../Mockery.php
|
||||
|
||||
# hamcrest
|
||||
hamcrest_path="vendor/hamcrest-php-${HAMCREST_VERSION}"
|
||||
hamcrest_path="hamcrest-php-${HAMCREST_VERSION}"
|
||||
if [ ! -e "${hamcrest_path}".tar.gz ]; then
|
||||
wget -O "${hamcrest_path}".tar.gz \
|
||||
https://github.com/hamcrest/hamcrest-php/archive/v${HAMCREST_VERSION}.tar.gz
|
||||
fi
|
||||
if [ ! -d "${hamcrest_path}" ]; then
|
||||
tar xf "${hamcrest_path}".tar.gz -C vendor/
|
||||
tar xf "${hamcrest_path}".tar.gz
|
||||
fi
|
||||
ln -svf "${hamcrest_path}"/hamcrest/Hamcrest
|
||||
ln -svf "${hamcrest_path}"/hamcrest/Hamcrest.php
|
||||
ln -svf "${hamcrest_path}"/hamcrest/Hamcrest Hamcrest
|
||||
ln -svf "${hamcrest_path}"/hamcrest/Hamcrest.php Hamcrest.php
|
||||
del_old_link ../Hamcrest
|
||||
del_old_link ../Hamcrest.php
|
||||
|
|
Loading…
Reference in New Issue