Skip to content

Commit

Permalink
Merge pull request #74 from Slamdunk/php_80
Browse files Browse the repository at this point in the history
Add PHP 7.4 & 8.0 support
  • Loading branch information
Ocramius committed Mar 27, 2021
2 parents 6eae5d8 + 44dfe4c commit 9cd6bce
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
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
- 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);
} 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) {
$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"/>
</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>');
$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
* @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

0 comments on commit 9cd6bce

Please sign in to comment.