Skip to content

Commit efddaab

Browse files
authored
Merge pull request #89 from Slamdunk/php_81
Add PHP 8.1 support, drop PHP 7.3
2 parents 1f71424 + cc1020a commit efddaab

18 files changed

Lines changed: 110 additions & 75 deletions

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
- "highest"
1818
- "locked"
1919
php-version:
20-
- "7.3"
2120
- "7.4"
2221
- "8.0"
22+
- "8.1"
2323
operating-system:
2424
- "ubuntu-latest"
2525

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ build
22
/vendor/
33
/doc/temp/
44
/docs/
5+
.phpunit.result.cache

classes/PHPTAL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ public function getFunctionName()
981981
if (!$this->_functionName) {
982982

983983
// just to make tempalte name recognizable
984-
$basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath()));
984+
$basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath() ?? ''));
985985
$basename = substr(trim(preg_replace('/[^a-zA-Z0-9]+/', '_', $basename), "_"), 0, 20);
986986

987987
$hash = md5(PHPTAL_VERSION . PHP_VERSION

classes/PHPTAL/DefaultKeyword.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ public function __toString()
2626
return "''";
2727
}
2828

29+
#[\ReturnTypeWillChange]
2930
public function count()
3031
{
3132
return 1;
3233
}
3334

35+
#[\ReturnTypeWillChange]
3436
public function jsonSerialize()
3537
{
3638
return new stdClass;

classes/PHPTAL/Dom/SaxXmlParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private function checkEncoding($str)
370370
// $match expression below somehow triggers quite deep recurrency and stack overflow in preg
371371
// to avoid this, check string bit by bit, omitting ASCII fragments.
372372
if (strlen($str) > 200) {
373-
$chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/',$str,null,PREG_SPLIT_NO_EMPTY);
373+
$chunks = preg_split('/(?>[\x09\x0A\x0D\x20-\x7F]+)/',$str,0,PREG_SPLIT_NO_EMPTY);
374374
foreach ($chunks as $chunk) {
375375
if (strlen($chunk) < 200) {
376376
$this->checkEncoding($chunk);
@@ -392,7 +392,7 @@ private function checkEncoding($str)
392392
. '|\xF4[\x80-\x8F][\x80-\xBF]{2}'; // plane 16
393393

394394
if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) {
395-
$res = preg_split('/((?>'.$match.')+)/s',$str,null,PREG_SPLIT_DELIM_CAPTURE);
395+
$res = preg_split('/((?>'.$match.')+)/s',$str,0,PREG_SPLIT_DELIM_CAPTURE);
396396
for($i=0; $i < count($res); $i+=2)
397397
{
398398
$res[$i] = self::convertBytesToEntities(array(1=>$res[$i]));

classes/PHPTAL/NothingKeyword.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ public function __toString()
2626
return 'null';
2727
}
2828

29+
#[\ReturnTypeWillChange]
2930
public function count()
3031
{
3132
return 0;
3233
}
3334

35+
#[\ReturnTypeWillChange]
3436
public function jsonSerialize()
3537
{
3638
return null;

classes/PHPTAL/Php/Attribute/I18N/Attributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function before(PHPTAL_Php_CodeWriter $codewriter)
6868
list($qname, $key) = $this->parseSetExpression($exp);
6969

7070
// if the translation key is specified and not empty (but may be '0')
71-
if (strlen($key)) {
71+
if ($key !== null && strlen($key) > 0) {
7272
// we use it and replace the tag attribute with the result of the translation
7373
$code = $this->_getTranslationCode($codewriter, $key);
7474
} else {

classes/PHPTAL/Php/TalesInternal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ private static function convertExpressionsToExpression(array $array, $nothrow)
459459
*/
460460
public static function compileToPHPExpressions($expression, $nothrow=false)
461461
{
462-
$expression = trim($expression);
462+
$expression = trim($expression ?? '');
463463

464464
// Look for tales modifier (string:, exists:, Namespaced\Tale:, etc...)
465465
if (preg_match('/^([a-z](?:[a-z0-9._\\\\-]*[a-z0-9])?):(.*)$/si', $expression, $m)) {

classes/PHPTAL/RepeatController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function __construct($source)
8787
*
8888
* @return Mixed The current element value
8989
*/
90+
#[\ReturnTypeWillChange]
9091
public function current()
9192
{
9293
return $this->current;
@@ -97,6 +98,7 @@ public function current()
9798
*
9899
* @return String/Int The current element key
99100
*/
101+
#[\ReturnTypeWillChange]
100102
public function key()
101103
{
102104
return $this->key;
@@ -107,6 +109,7 @@ public function key()
107109
*
108110
* @return bool True if the iteration is not finished yet
109111
*/
112+
#[\ReturnTypeWillChange]
110113
public function valid()
111114
{
112115
$valid = $this->valid || $this->validOnNext;
@@ -142,6 +145,7 @@ public function length()
142145
* Restarts the iteration process going back to the first element
143146
*
144147
*/
148+
#[\ReturnTypeWillChange]
145149
public function rewind()
146150
{
147151
$this->index = 0;
@@ -168,6 +172,7 @@ public function rewind()
168172
* Fetches the next element in the iteration and advances the pointer
169173
*
170174
*/
175+
#[\ReturnTypeWillChange]
171176
public function next()
172177
{
173178
$this->index++;

classes/PHPTAL/Tokenizer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ function nextToken()
4747
}
4848

4949
//if (!preg_match_all($this->regex, $this->str, $m, PREG_SET_ORDER, $this->offset)) throw new Exception("FAIL {$this->regex} at {$this->offset}");
50-
if (!preg_match($this->regex, $this->str, $m, null, $this->offset)) throw new Exception("FAIL {$this->regex} didn't match '{$this->str}' at {$this->offset}");
50+
if (!preg_match($this->regex, $this->str, $m, 0, $this->offset)) {
51+
throw new Exception("FAIL {$this->regex} didn't match '{$this->str}' at {$this->offset}");
52+
}
5153

5254
$this->offset += strlen($m[0]); // in bytes
5355

0 commit comments

Comments
 (0)