Skip to content

Commit

Permalink
Merge pull request #68 from phptal/fix/#64-php-7.3-compatibility
Browse files Browse the repository at this point in the history
PHP 7.3 compatibility and testing
  • Loading branch information
Ocramius authored Mar 22, 2019
2 parents 7f12c8f + 51f5a9b commit 37cf3cc
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 16 deletions.
19 changes: 9 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
language: php

php:
- 5.2
- 5.4
- 5.5
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- nightly

matrix:
include:
- php: 5.3
dist: precise
- php: 5.3.3
dist: precise
allow_failures:
- php: 5.2
- php: 7.4snapshot
- php: nightly

before_script:
# Make sure the locales used in the tests are installed
- composer install
- 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:
- phpunit -c phpunit.xml
- vendor/phpunit/phpunit/phpunit
9 changes: 9 additions & 0 deletions classes/PHPTAL.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,15 @@ public function prepare()
try {
eval("?>\n".$result);
}
catch(ParseError $parseError) {
ob_end_clean();
throw new PHPTAL_TemplateException(
'Parse error: ' . $parseError->getMessage(),
$this->getCodePath(),
$parseError->getLine(),
$parseError
);
}
catch(Exception $e) {
ob_end_clean();
throw $e;
Expand Down
2 changes: 1 addition & 1 deletion classes/PHPTAL/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function fillSlot($key, $content)

public function fillSlotCallback($key, $callback, $_thistpl, $tpl)
{
assert('is_callable($callback)');
assert(is_callable($callback));
$this->_slots[$key] = array($callback, $_thistpl, $tpl);
if ($this->_parentContext) {
// Works around bug with tal:define popping context after fillslot
Expand Down
2 changes: 1 addition & 1 deletion classes/PHPTAL/Php/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function transform($str, $prefix='$')
{
$result .= $prefix;
$state = self::ST_NONE;
continue;
break;
}
/* NO BREAK - ST_WHITE is almost the same as ST_NONE */

Expand Down
10 changes: 8 additions & 2 deletions classes/PHPTAL/TemplateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ class PHPTAL_TemplateException extends PHPTAL_Exception
public $srcLine;
private $is_src_accurate;

public function __construct($msg, $srcFile='', $srcLine=0)
/**
* @param string $msg
* @param string $srcFile
* @param int $srcLine
* @param Throwable $previous
*/
public function __construct($msg, $srcFile='', $srcLine=0, $previous = null)
{
parent::__construct($msg);
parent::__construct($msg, 0, $previous);

if ($srcFile && $srcLine) {
$this->srcFile = $srcFile;
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
}
],
"require": {
"php": ">=5.1.2"
"php": "^7.1.0"
},
"autoload": {
"psr-0": {
"PHPTAL": "classes/"
}
},
"require-dev": {
"phpunit/phpunit": "^4.8.36"
},
"config": {
"bin-dir": "tools"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TalDefineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function testEmpty()
{
$tal = $this->newPHPTAL();
$tal->setSource('<div class="blank_bg" tal:define="book relative/book" tal:condition="php: count(book)>0"></div>');
$tal->relative = array('book'=>1);
$tal->relative = array('book'=>array('foo'));

$this->assertEquals($tal->execute(), '<div class="blank_bg"></div>');
}
Expand Down

0 comments on commit 37cf3cc

Please sign in to comment.