From 24c457742935077dcd4576ec189555dea8a0847c Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 24 Feb 2019 14:52:24 +1100 Subject: [PATCH 1/3] add to CI, expected to break --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f5834e9..070dcca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ php: - 7.1 - 7.2 - 7.3 + - hhvm-3.21 + - hhvm-3.27 - nightly - hhvm-nightly From d2b2cd21ab13727d2dbda6a42f151d8443045d47 Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 24 Feb 2019 15:05:06 +1100 Subject: [PATCH 2/3] wrap error_get_last() and error_clear_last() for compatibility --- src/Mike42/GfxPhp/Image.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Mike42/GfxPhp/Image.php b/src/Mike42/GfxPhp/Image.php index 7af248f..6adcbd5 100644 --- a/src/Mike42/GfxPhp/Image.php +++ b/src/Mike42/GfxPhp/Image.php @@ -17,11 +17,10 @@ class Image public static function fromFile(string $filename) : RasterImage { // Attempt to catch the cause of any errors - error_clear_last(); + self::clearLastError(); $blob = @file_get_contents($filename); if ($blob === false) { - $e = error_get_last(); - $error = (isset($e) && isset($e['message']) && $e['message'] != "") ? $e['message'] : "Check that the file exists and can be read."; + $error = self::getLastErrorOrDefault("Check that the file exists and can be read."); throw new \Exception("Could not retrieve image data from '$filename'. $error"); } return self::fromBlob($blob, $filename); @@ -47,4 +46,29 @@ public static function create(int $width, int $height, int $impl = self::IMAGE_B { return BlackAndWhiteRasterImage::create($width, $height); } + + /** + * Call error_clear_last() if it exists. This is dependent on which PHP runtime is used. + */ + private static function clearLastError() + { + if (function_exists('error_clear_last')) { + error_clear_last(); + } + } + + /** + * Retrieve the message from error_get_last() if possible. This is very useful for debugging, but it will not + * always exist or return anything useful. + */ + private static function getLastErrorOrDefault(string $default) + { + if (function_exists('error_clear_last')) { + $e = error_get_last(); + if (isset($e) && isset($e['message']) && $e['message'] != "") { + return $e['message']; + } + } + return $default; + } } From 542211dd245192bae420fd2b09e77b0cc0052fe9 Mon Sep 17 00:00:00 2001 From: Michael Billington Date: Sun, 24 Feb 2019 15:08:35 +1100 Subject: [PATCH 3/3] configure HHVM to act as PHP7 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 070dcca..d2f4f8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ install: - composer install before_script: + - bash -c 'if [[ $TRAVIS_PHP_VERSION == hhvm* ]]; then echo "hhvm.php7.all = 1" | sudo tee -a /etc/hhvm/php.ini; fi' - mkdir -p build/logs/ script: