Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
php: ['8.1', '8.2', '8.3', '8.4']
php: ['8.3', '8.4', '8.5']
steps:
- name: Set locales
run: |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
],
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
"ext-dom": "*",
"ext-gettext": "*",
"ext-simplexml": "*",
Expand Down Expand Up @@ -59,7 +59,7 @@
},
"config": {
"platform": {
"php": "8.1"
"php": "8.3"
},
"bin-dir": "bin",
"sort-packages": true
Expand Down
824 changes: 502 additions & 322 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ parameters:
count: 1
path: src/Php/Attribute/I18N/Translate.php

-
message: "#^PHPDoc tag @var with type PhpTal\\\\Dom\\\\Node is not subtype of native type mixed\\.$#"
count: 1
path: src/Php/Attribute/METAL/FillSlot.php

-
message: "#^Parameter \\#1 \\$condition of method PhpTal\\\\Php\\\\CodeWriter\\:\\:doIf\\(\\) expects string, string\\|null given\\.$#"
count: 1
Expand Down
4 changes: 3 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;

return RectorConfig::configure()
->withPaths([
Expand All @@ -19,8 +20,9 @@
StringClassNameToClassConstantRector::class,
FirstClassCallableRector::class,
MixedTypeRector::class,
AddOverrideAttributeToOverriddenMethodsRector::class,
])
->withPhpSets(php81: true)
->withPhpSets(php83: true)
->withPreparedSets(deadCode: true)
->withRules([
AddLiteralSeparatorToNumberRector::class,
Expand Down
8 changes: 4 additions & 4 deletions src/Dom/Attr.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*/
class Attr
{
final public const HIDDEN = -1;
final public const NOT_REPLACED = 0;
final public const VALUE_REPLACED = 1;
final public const FULLY_REPLACED = 2;
final public const int HIDDEN = -1;
final public const int NOT_REPLACED = 0;
final public const int VALUE_REPLACED = 1;
final public const int FULLY_REPLACED = 2;

/**
* attribute's value can be overriden with a variable
Expand Down
36 changes: 18 additions & 18 deletions src/Dom/SaxXmlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@
class SaxXmlParser
{
// available parser states
final public const ST_ROOT = 0;
final public const ST_TEXT = 1;
final public const ST_LT = 2;
final public const ST_TAG_NAME = 3;
final public const ST_TAG_CLOSE = 4;
final public const ST_TAG_SINGLE = 5;
final public const ST_TAG_ATTRIBUTES = 6;
final public const ST_TAG_BETWEEN_ATTRIBUTE = 7;
final public const ST_CDATA = 8;
final public const ST_COMMENT = 9;
final public const ST_DOCTYPE = 10;
final public const ST_XMLDEC = 11;
final public const ST_PREPROC = 12;
final public const ST_ATTR_KEY = 13;
final public const ST_ATTR_EQ = 14;
final public const ST_ATTR_QUOTE = 15;
final public const ST_ATTR_VALUE = 16;
final public const BOM_STR = "\xef\xbb\xbf";
final public const int ST_ROOT = 0;
final public const int ST_TEXT = 1;
final public const int ST_LT = 2;
final public const int ST_TAG_NAME = 3;
final public const int ST_TAG_CLOSE = 4;
final public const int ST_TAG_SINGLE = 5;
final public const int ST_TAG_ATTRIBUTES = 6;
final public const int ST_TAG_BETWEEN_ATTRIBUTE = 7;
final public const int ST_CDATA = 8;
final public const int ST_COMMENT = 9;
final public const int ST_DOCTYPE = 10;
final public const int ST_XMLDEC = 11;
final public const int ST_PREPROC = 12;
final public const int ST_ATTR_KEY = 13;
final public const int ST_ATTR_EQ = 14;
final public const int ST_ATTR_QUOTE = 15;
final public const int ST_ATTR_VALUE = 16;
final public const string BOM_STR = "\xef\xbb\xbf";

/**
* @var array<int, string>
Expand Down
8 changes: 4 additions & 4 deletions src/PHPTAL.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
*/
class PHPTAL implements PhpTalInterface
{
final public const PHPTAL_VERSION = '3_0_2';
final public const string PHPTAL_VERSION = '4_2_0';

/**
* constants for output mode
* @see setOutputMode()
*/
final public const XHTML = 11;
final public const XML = 22;
final public const HTML5 = 55;
final public const int XHTML = 11;
final public const int XML = 22;
final public const int HTML5 = 55;

/**
* @see getPreFilters()
Expand Down
2 changes: 1 addition & 1 deletion src/Php/Attribute/METAL/FillSlot.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
*/
class FillSlot extends Attribute
{
final public const CALLBACK_THRESHOLD = 10000;
final public const int CALLBACK_THRESHOLD = 10000;

private static int $uid = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/Php/TalesChainExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/
class TalesChainExecutor
{
final public const CHAIN_BREAK = 1;
final public const CHAIN_CONT = 2;
final public const int CHAIN_BREAK = 1;
final public const int CHAIN_CONT = 2;

private int $state = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/Php/TalesInternal.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
*/
class TalesInternal implements TalesInterface
{
final public const DEFAULT_KEYWORD = 'new \PhpTal\DefaultKeyword';
final public const NOTHING_KEYWORD = 'new \PhpTal\NothingKeyword';
final public const string DEFAULT_KEYWORD = 'new \PhpTal\DefaultKeyword';
final public const string NOTHING_KEYWORD = 'new \PhpTal\NothingKeyword';

private static bool $phpModifierAllowed = false;

Expand Down
20 changes: 10 additions & 10 deletions src/Php/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@
*/
class Transformer
{
final public const ST_WHITE = -1; // start of string or whitespace
final public const ST_NONE = 0; // pass through (operators, parens, etc.)
final public const ST_STR = 1; // 'foo'
final public const ST_ESTR = 2; // "foo ${x} bar"
final public const ST_VAR = 3; // abcd
final public const ST_NUM = 4; // 123.02
final public const ST_EVAL = 5; // $somevar
final public const ST_MEMBER = 6; // abcd.x
final public const ST_STATIC = 7; // class::[$]static|const
final public const ST_DEFINE = 8; // @MY_DEFINE
final public const int ST_WHITE = -1; // start of string or whitespace
final public const int ST_NONE = 0; // pass through (operators, parens, etc.)
final public const int ST_STR = 1; // 'foo'
final public const int ST_ESTR = 2; // "foo ${x} bar"
final public const int ST_VAR = 3; // abcd
final public const int ST_NUM = 4; // 123.02
final public const int ST_EVAL = 5; // $somevar
final public const int ST_MEMBER = 6; // abcd.x
final public const int ST_STATIC = 7; // class::[$]static|const
final public const int ST_DEFINE = 8; // @MY_DEFINE

/**
* @var array<string, string>
Expand Down
2 changes: 1 addition & 1 deletion src/StringSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class StringSource implements SourceInterface
{
final public const NO_PATH_PREFIX = '<string ';
final public const string NO_PATH_PREFIX = '<string ';

private readonly string $realpath;

Expand Down
12 changes: 6 additions & 6 deletions src/TalNamespace/Builtin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
*/
class Builtin extends TalNamespace
{
final public const NS_METAL = 'http://xml.zope.org/namespaces/metal';
final public const NS_TAL = 'http://xml.zope.org/namespaces/tal';
final public const NS_I18N = 'http://xml.zope.org/namespaces/i18n';
final public const NS_XML = 'http://www.w3.org/XML/1998/namespace';
final public const NS_XMLNS = 'http://www.w3.org/2000/xmlns/';
final public const NS_XHTML = 'http://www.w3.org/1999/xhtml';
final public const string NS_METAL = 'http://xml.zope.org/namespaces/metal';
final public const string NS_TAL = 'http://xml.zope.org/namespaces/tal';
final public const string NS_I18N = 'http://xml.zope.org/namespaces/i18n';
final public const string NS_XML = 'http://www.w3.org/XML/1998/namespace';
final public const string NS_XMLNS = 'http://www.w3.org/2000/xmlns/';
final public const string NS_XHTML = 'http://www.w3.org/1999/xhtml';

/**
* @param mixed $expression
Expand Down
2 changes: 2 additions & 0 deletions tests/TalTestCaseRepeatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Tests;

use DOMDocument;
use PHPUnit\Framework\Attributes\RequiresPhp;
use SimpleXMLElement;
use Tests\Testcase\PhpTalTestCase;
use Tests\Testhelper\Helper;
Expand Down Expand Up @@ -92,6 +93,7 @@ public function testArrayObjectZeroElements(): void
static::assertSame('<div></div>', $tpl->execute());
}

#[RequiresPhp('<8.5')]
public function testArrayObjectAggregated(): void
{
$tpl = $this->newPHPTAL();
Expand Down
5 changes: 4 additions & 1 deletion tests/Testhelper/DummyTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public function setTranslation(string $key, string $translation): void

public function translate(?string $key, bool $escape = true): string
{
if (array_key_exists($key, $this->translations)) {
if (
$key !== null
&& array_key_exists($key, $this->translations)
) {
$v = $this->translations[$key];
} else {
$v = $key;
Expand Down