diff --git a/.gitignore b/.gitignore
index 5c654a7ba..affd22ffb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,11 +9,6 @@
# Testing - created by test/setup_vendor.sh
/vendor/
-/Hamcrest*
-/Mockery*
-/Icinga
-/Zend
-/*.phar
# Exclude application log files
var/log/*
diff --git a/.travis.yml b/.travis.yml
index 7dd22e111..5a8902570 100644
--- a/.travis.yml
+++ b/.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'
diff --git a/library/Icinga/Chart/GridChart.php b/library/Icinga/Chart/GridChart.php
index df4a50ff4..a8cfca646 100644
--- a/library/Icinga/Chart/GridChart.php
+++ b/library/Icinga/Chart/GridChart.php
@@ -409,7 +409,7 @@ class GridChart extends Chart
);
break;
default:
- continue;
+ continue 2;
}
$el = $this->setupGraph($graphObj, $graph);
if ($el) {
diff --git a/library/vendor/JShrink/Minifier.php b/library/vendor/JShrink/Minifier.php
index 76f4ced69..ad8157f17 100644
--- a/library/vendor/JShrink/Minifier.php
+++ b/library/vendor/JShrink/Minifier.php
@@ -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
diff --git a/library/vendor/JShrink/SOURCE b/library/vendor/JShrink/SOURCE
index 46fe41d30..a236ec215 100644
--- a/library/vendor/JShrink/SOURCE
+++ b/library/vendor/JShrink/SOURCE
@@ -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
diff --git a/library/vendor/dompdf/SOURCE b/library/vendor/dompdf/SOURCE
index d39191933..1cebf923b 100644
--- a/library/vendor/dompdf/SOURCE
+++ b/library/vendor/dompdf/SOURCE
@@ -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
diff --git a/library/vendor/dompdf/lib/Cpdf.php b/library/vendor/dompdf/lib/Cpdf.php
index 4df67678a..55ac3d33d 100644
--- a/library/vendor/dompdf/lib/Cpdf.php
+++ b/library/vendor/dompdf/lib/Cpdf.php
@@ -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";
diff --git a/library/vendor/dompdf/src/Adapter/CPDF.php b/library/vendor/dompdf/src/Adapter/CPDF.php
index 6221ee1b7..889eb4da2 100644
--- a/library/vendor/dompdf/src/Adapter/CPDF.php
+++ b/library/vendor/dompdf/src/Adapter/CPDF.php
@@ -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;
}
}
diff --git a/library/vendor/dompdf/src/Adapter/GD.php b/library/vendor/dompdf/src/Adapter/GD.php
index 72f3c572d..92fbdbe11 100644
--- a/library/vendor/dompdf/src/Adapter/GD.php
+++ b/library/vendor/dompdf/src/Adapter/GD.php
@@ -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.
*
diff --git a/library/vendor/dompdf/src/Adapter/PDFLib.php b/library/vendor/dompdf/src/Adapter/PDFLib.php
index d002754fd..b07e91b1f 100644
--- a/library/vendor/dompdf/src/Adapter/PDFLib.php
+++ b/library/vendor/dompdf/src/Adapter/PDFLib.php
@@ -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;
+
}
}
diff --git a/library/vendor/dompdf/src/Css/Stylesheet.php b/library/vendor/dompdf/src/Css/Stylesheet.php
index 733d5b9b4..d981e2efd 100644
--- a/library/vendor/dompdf/src/Css/Stylesheet.php
+++ b/library/vendor/dompdf/src/Css/Stylesheet.php
@@ -1357,7 +1357,7 @@ class Stylesheet
$key = $page_selector;
default:
- continue;
+ continue 3;
}
// Store the style for later...
diff --git a/library/vendor/dompdf/src/Dompdf.php b/library/vendor/dompdf/src/Dompdf.php
index d03193826..af06fbeb5 100644
--- a/library/vendor/dompdf/src/Dompdf.php
+++ b/library/vendor/dompdf/src/Dompdf.php
@@ -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())
{
diff --git a/library/vendor/dompdf/src/FontMetrics.php b/library/vendor/dompdf/src/FontMetrics.php
index be835f04b..0266e589e 100644
--- a/library/vendor/dompdf/src/FontMetrics.php
+++ b/library/vendor/dompdf/src/FontMetrics.php
@@ -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));
diff --git a/library/vendor/dompdf/src/FrameDecorator/Page.php b/library/vendor/dompdf/src/FrameDecorator/Page.php
index 74d4284ad..8f4139075 100644
--- a/library/vendor/dompdf/src/FrameDecorator/Page.php
+++ b/library/vendor/dompdf/src/FrameDecorator/Page.php
@@ -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();
}
diff --git a/library/vendor/dompdf/src/Image/Cache.php b/library/vendor/dompdf/src/Image/Cache.php
index 8d073c22a..479d2e679 100644
--- a/library/vendor/dompdf/src/Image/Cache.php
+++ b/library/vendor/dompdf/src/Image/Cache.php
@@ -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) {
diff --git a/library/vendor/dompdf/src/Renderer/AbstractRenderer.php b/library/vendor/dompdf/src/Renderer/AbstractRenderer.php
index 9a3df2f84..502e78a02 100644
--- a/library/vendor/dompdf/src/Renderer/AbstractRenderer.php
+++ b/library/vendor/dompdf/src/Renderer/AbstractRenderer.php
@@ -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";
diff --git a/library/vendor/dompdf/src/Renderer/Text.php b/library/vendor/dompdf/src/Renderer/Text.php
index 149b3b683..059c27eae 100644
--- a/library/vendor/dompdf/src/Renderer/Text.php
+++ b/library/vendor/dompdf/src/Renderer/Text.php
@@ -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;
diff --git a/phpcs.xml b/phpcs.xml
index e04ad72f8..3a33b6e38 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -8,6 +8,7 @@
test/
vendor/*
+ test/*.php
application/fonts/fontello-ifont/*
diff --git a/test/check-syntax.php b/test/check-syntax.php
new file mode 100755
index 000000000..b8f4afd66
--- /dev/null
+++ b/test/check-syntax.php
@@ -0,0 +1,145 @@
+#!/usr/bin/env php
+&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']));
diff --git a/test/php/bootstrap.php b/test/php/bootstrap.php
index 6e3345c14..38c092fee 100644
--- a/test/php/bootstrap.php
+++ b/test/php/bootstrap.php
@@ -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;
diff --git a/test/setup_vendor.sh b/test/setup_vendor.sh
index cf77de3bf..a7e9f08f3 100755
--- a/test/setup_vendor.sh
+++ b/test/setup_vendor.sh
@@ -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