Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 7.4 & 8.0 support #74

Merged
merged 6 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- nightly

matrix:
allow_failures:
- php: 7.4snapshot
- php: nightly
- 7.4
- 8.0

before_script:
# Make sure the locales used in the tests are installed
- composer install
- composer update --ignore-platform-req=php
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
- sudo locale-gen en_GB
- sudo locale-gen en_GB.utf8
- sudo locale-gen fr_FR
- sudo locale-gen fr_FR@euro
- sudo locale-gen fr_FR.utf8

script:
- vendor/phpunit/phpunit/phpunit
- tools/phpunit
- tools/phptal_lint.php -e html tests/input/phptal*.html
2 changes: 1 addition & 1 deletion classes/PHPTAL.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
} else {
spl_autoload_register(array(__CLASS__,'autoload'));
}
Expand Down
6 changes: 5 additions & 1 deletion classes/PHPTAL/FileSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
$content = false;
}

// file_get_contents returns "" when loading directory!?
if (false === $content || ("" === $content && is_dir($this->_path))) {
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 4 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ ensuring that your copy of PHPTAL works correctly.
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">
<php><ini name="display_errors" value="1"/></php>
<php>
<ini name="display_errors" value="1"/>
<ini name="zend.exception_ignore_args" value="0"/>
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
</php>
<testsuites>
<testsuite name="PHPTALtests">
<directory>tests</directory>
Expand Down
2 changes: 1 addition & 1 deletion tests/AutoloadTest1.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function __autoload($class)
}
}

class AutoloadTest1 extends PHPUnit_Framework_TestCase
class AutoloadTest1 extends \PHPUnit\Framework\TestCase
{
protected $backupGlobals = false;

Expand Down
2 changes: 1 addition & 1 deletion tests/AutoloadTest2.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @link http://phptal.org/
*/

class AutoloadTest2 extends PHPUnit_Framework_TestCase
class AutoloadTest2 extends \PHPUnit\Framework\TestCase
{
protected $backupGlobals = false;

Expand Down
2 changes: 1 addition & 1 deletion tests/TalRepeatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function testTraversableRepeat()
$doc->loadXML('<a><b/><c/><d/><e/><f/><g/></a>');

$tpl = $this->newPHPTAL();
$tpl->setSource('<tal:block tal:repeat="node nodes"><tal:block tal:condition="php:repeat.node.index==4">(len=${repeat/node/length})</tal:block>${repeat/node/key}${node/tagName}</tal:block>');
$tpl->setSource('<tal:block tal:repeat="node nodes"><tal:block tal:condition="php:repeat.node.index==4">(len=${nodes/length})</tal:block>${repeat/node/key}${node/tagName}</tal:block>');
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
$tpl->nodes = $doc->getElementsByTagName('*');

$this->assertEquals('0a1b2c3d(len=7)4e5f6g', $tpl->execute());
Expand Down
3 changes: 1 addition & 2 deletions tests/TalesRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ public function prepareTemplate( Text_Template $template ) {
}

/**
* @runInSeparateProcess
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
* @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('<p tal:content="'.$test_prefix.':"/>')->execute();
Expand Down
2 changes: 1 addition & 1 deletion tests/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down