From 19c7e3e777490f401462368d3ff5c949d6b68224 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 5 Feb 2021 14:39:36 +0100 Subject: [PATCH 1/6] Set zend.exception_ignore_args=0 for PHP >=7.4 --- phpunit.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index b4f71331..33c1937d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -15,7 +15,10 @@ ensuring that your copy of PHPTAL works correctly. convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true"> - + + + + tests From 1dd200d17d9dc36558c89d29f1a5eab2c6fc0b42 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 5 Feb 2021 14:42:16 +0100 Subject: [PATCH 2/6] Handle PHP 7.4 error-to-exception --- classes/PHPTAL/FileSource.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/PHPTAL/FileSource.php b/classes/PHPTAL/FileSource.php index 84d8719e..f9d8cfc8 100644 --- a/classes/PHPTAL/FileSource.php +++ b/classes/PHPTAL/FileSource.php @@ -40,7 +40,11 @@ public function getLastModifiedTime() public function getData() { - $content = file_get_contents($this->_path); + try { + $content = file_get_contents($this->_path); + } catch (Throwable $throwable) { + $content = false; + } // file_get_contents returns "" when loading directory!? if (false === $content || ("" === $content && is_dir($this->_path))) { From a7aac5a0a15737d491d72174615a48e144050b36 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 5 Feb 2021 14:42:52 +0100 Subject: [PATCH 3/6] CI: do not allow PHP 7.4 to fail --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33db934a..faeddf5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,11 @@ php: - 7.1 - 7.2 - 7.3 - - 7.4snapshot + - 7.4 - nightly matrix: allow_failures: - - php: 7.4snapshot - php: nightly before_script: From bcfed41322eb68263bd45183a113a7a75836aee3 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 5 Feb 2021 15:19:35 +0100 Subject: [PATCH 4/6] Allow PHP 8.0 --- .travis.yml | 8 ++------ classes/PHPTAL.php | 2 +- composer.json | 7 +++---- tests/AutoloadTest1.php | 2 +- tests/AutoloadTest2.php | 2 +- tests/TalRepeatTest.php | 4 ++-- tests/TalesRegistryTest.php | 3 +-- tests/config.php | 2 +- 8 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index faeddf5e..19e79733 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,7 @@ php: - 7.2 - 7.3 - 7.4 - - nightly - -matrix: - allow_failures: - - php: nightly + - 8.0 before_script: # Make sure the locales used in the tests are installed @@ -21,5 +17,5 @@ before_script: - sudo locale-gen fr_FR.utf8 script: - - vendor/phpunit/phpunit/phpunit + - tools/phpunit - tools/phptal_lint.php -e html tests/input/phptal*.html diff --git a/classes/PHPTAL.php b/classes/PHPTAL.php index 164a94ad..26de8188 100644 --- a/classes/PHPTAL.php +++ b/classes/PHPTAL.php @@ -1223,7 +1223,7 @@ final public static function autoloadRegister() // Prepending PHPTAL's autoloader helps if there are other autoloaders // that throw/die when file is not found. Only >5.3 though. if (version_compare(PHP_VERSION, '5.3', '>=')) { - spl_autoload_register(array(__CLASS__,'autoload'), false, true); + @spl_autoload_register(array(__CLASS__,'autoload'), false, true); } else { spl_autoload_register(array(__CLASS__,'autoload')); } diff --git a/composer.json b/composer.json index bdd7ecc8..0b75438e 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,11 @@ } ], "require": { - "php": "^7.1.0" + "php": "^7.1 || ^8.0" }, "require-dev": { - "php": ">=5.3.3", - "phpunit/phpunit": "^4.8.36", - "phpdocumentor/phpdocumentor": "~2.8" + "phpunit/phpunit": "^7.5", + "phpdocumentor/phpdocumentor": "^2.9" }, "autoload": { "psr-0": { diff --git a/tests/AutoloadTest1.php b/tests/AutoloadTest1.php index 660f47ee..4663f14b 100644 --- a/tests/AutoloadTest1.php +++ b/tests/AutoloadTest1.php @@ -20,7 +20,7 @@ function __autoload($class) } } -class AutoloadTest1 extends PHPUnit_Framework_TestCase +class AutoloadTest1 extends \PHPUnit\Framework\TestCase { protected $backupGlobals = false; diff --git a/tests/AutoloadTest2.php b/tests/AutoloadTest2.php index 693dfaf2..13fc9b0c 100644 --- a/tests/AutoloadTest2.php +++ b/tests/AutoloadTest2.php @@ -12,7 +12,7 @@ * @link http://phptal.org/ */ -class AutoloadTest2 extends PHPUnit_Framework_TestCase +class AutoloadTest2 extends \PHPUnit\Framework\TestCase { protected $backupGlobals = false; diff --git a/tests/TalRepeatTest.php b/tests/TalRepeatTest.php index f538551e..a6fdb5e3 100644 --- a/tests/TalRepeatTest.php +++ b/tests/TalRepeatTest.php @@ -143,8 +143,8 @@ function testTraversableRepeat() $doc->loadXML(''); $tpl = $this->newPHPTAL(); - $tpl->setSource('(len=${repeat/node/length})${repeat/node/key}${node/tagName}'); - $tpl->nodes = $doc->getElementsByTagName('*'); + $tpl->setSource('(len=${nodes/length})${repeat/node/key}${node/tagName}'); + $tpl->nodes = $a = $doc->getElementsByTagName('*'); $this->assertEquals('0a1b2c3d(len=7)4e5f6g', $tpl->execute()); diff --git a/tests/TalesRegistryTest.php b/tests/TalesRegistryTest.php index 9ef49a43..ecab6a94 100644 --- a/tests/TalesRegistryTest.php +++ b/tests/TalesRegistryTest.php @@ -42,12 +42,11 @@ public function prepareTemplate( Text_Template $template ) { } /** - * @runInSeparateProcess * @expectedException PHPTAL_UnknownModifierException */ function testUnregisterFunction() { - $test_prefix = 'testprefix'; + $test_prefix = uniqid('testprefix_'); PHPTAL_TalesRegistry::getInstance()->registerPrefix($test_prefix, 'registry_test_callback3'); PHPTAL_TalesRegistry::getInstance()->unregisterPrefix($test_prefix); $this->newPHPTAL()->setSource('

')->execute(); diff --git a/tests/config.php b/tests/config.php index 30658481..a0845c4e 100644 --- a/tests/config.php +++ b/tests/config.php @@ -35,7 +35,7 @@ } } -abstract class PHPTAL_TestCase extends PHPUnit_Framework_TestCase +abstract class PHPTAL_TestCase extends \PHPUnit\Framework\TestCase { private $cwd_backup, $buffer_level; From 5b06071cc8b38073d073de7baaaf11f3708dafac Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 5 Feb 2021 15:27:33 +0100 Subject: [PATCH 5/6] CI: --ignore-platform-req=php --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 19e79733..09c2229f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ php: before_script: # Make sure the locales used in the tests are installed - - composer install + - composer update --ignore-platform-req=php - sudo locale-gen en_GB - sudo locale-gen en_GB.utf8 - sudo locale-gen fr_FR From 44dfe4cc37d5462c1b3077f09621bc5a4612466a Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 5 Feb 2021 15:31:07 +0100 Subject: [PATCH 6/6] Removed a leftover from debug --- tests/TalRepeatTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TalRepeatTest.php b/tests/TalRepeatTest.php index a6fdb5e3..7f6d34c6 100644 --- a/tests/TalRepeatTest.php +++ b/tests/TalRepeatTest.php @@ -144,7 +144,7 @@ function testTraversableRepeat() $tpl = $this->newPHPTAL(); $tpl->setSource('(len=${nodes/length})${repeat/node/key}${node/tagName}'); - $tpl->nodes = $a = $doc->getElementsByTagName('*'); + $tpl->nodes = $doc->getElementsByTagName('*'); $this->assertEquals('0a1b2c3d(len=7)4e5f6g', $tpl->execute());