diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12758b838..b842c53fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" compiler: - default @@ -50,6 +51,9 @@ jobs: - os: ubuntu-latest php-version: "8.3" compiler: jit + - os: ubuntu-latest + php-version: "8.4" + compiler: jit steps: - name: Checkout diff --git a/README.md b/README.md index f73647e59..755d73ea0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Smarty is a template engine for PHP, facilitating the separation of presentation Read the [documentation](https://smarty-php.github.io/smarty/) to find out how to use it. ## Requirements -Smarty v5 can be run with PHP 7.2 to PHP 8.3. +Smarty v5 can be run with PHP 7.2 to PHP 8.4. ## Installation Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/). diff --git a/docker-compose.yml b/docker-compose.yml index 7ecd8b436..de519b2ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,6 +42,11 @@ services: service: base build: dockerfile: ./utilities/testrunners/php83/Dockerfile + php84: + extends: + service: base + build: + dockerfile: ./utilities/testrunners/php84/Dockerfile volumes: smarty-code: diff --git a/run-tests-for-all-php-versions.sh b/run-tests-for-all-php-versions.sh index 494b127b5..efff5713d 100755 --- a/run-tests-for-all-php-versions.sh +++ b/run-tests-for-all-php-versions.sh @@ -14,3 +14,4 @@ $COMPOSE_CMD run --rm php80 ./run-tests.sh $@ && \ $COMPOSE_CMD run --rm php81 ./run-tests.sh $@ && \ $COMPOSE_CMD run --rm php82 ./run-tests.sh $@ $COMPOSE_CMD run --rm php83 ./run-tests.sh $@ +$COMPOSE_CMD run --rm php84 ./run-tests.sh $@ diff --git a/src/Cacheresource/Base.php b/src/Cacheresource/Base.php index 54a141921..41c4f6bc6 100644 --- a/src/Cacheresource/Base.php +++ b/src/Cacheresource/Base.php @@ -44,7 +44,7 @@ abstract public function populateTimestamp(Cached $cached); */ abstract public function process( Template $_template, - Cached $cached = null, + ?Cached $cached = null, $update = false ); diff --git a/src/Cacheresource/Custom.php b/src/Cacheresource/Custom.php index c049246c8..f9eb858e4 100644 --- a/src/Cacheresource/Custom.php +++ b/src/Cacheresource/Custom.php @@ -139,7 +139,7 @@ public function populateTimestamp(\Smarty\Template\Cached $cached) */ public function process( Template $_smarty_tpl, - \Smarty\Template\Cached $cached = null, + ?\Smarty\Template\Cached $cached = null, $update = false ) { if (!$cached) { diff --git a/src/Cacheresource/File.php b/src/Cacheresource/File.php index 538f01034..4b4198ec2 100644 --- a/src/Cacheresource/File.php +++ b/src/Cacheresource/File.php @@ -99,7 +99,7 @@ public function populateTimestamp(Cached $cached) */ public function process( Template $_smarty_tpl, - Cached $cached = null, + ?Cached $cached = null, $update = false ) { $_smarty_tpl->getCached()->setValid(false); diff --git a/src/Cacheresource/KeyValueStore.php b/src/Cacheresource/KeyValueStore.php index 733d27765..1953bb20f 100644 --- a/src/Cacheresource/KeyValueStore.php +++ b/src/Cacheresource/KeyValueStore.php @@ -103,7 +103,7 @@ public function populateTimestamp(Cached $cached) */ public function process( Template $_smarty_tpl, - Cached $cached = null, + ?Cached $cached = null, $update = false ) { if (!$cached) { diff --git a/src/Compiler/CodeFrame.php b/src/Compiler/CodeFrame.php index 5e7821509..d0e1cc120 100644 --- a/src/Compiler/CodeFrame.php +++ b/src/Compiler/CodeFrame.php @@ -41,7 +41,7 @@ public function create( $content = '', $functions = '', $cache = false, - \Smarty\Compiler\Template $compiler = null + ?\Smarty\Compiler\Template $compiler = null ) { // build property code $properties[ 'version' ] = \Smarty\Smarty::SMARTY_VERSION; diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php index 9b2c1a1f2..de802e1cc 100644 --- a/src/Compiler/Template.php +++ b/src/Compiler/Template.php @@ -374,7 +374,7 @@ public function compileTemplate(\Smarty\Template $template) { * @throws CompilerException * @throws Exception */ - public function compileTemplateSource(\Smarty\Template $template, \Smarty\Compiler\Template $parent_compiler = null) { + public function compileTemplateSource(\Smarty\Template $template, ?\Smarty\Compiler\Template $parent_compiler = null) { try { // save template object in compiler class $this->template = $template; diff --git a/src/CompilerException.php b/src/CompilerException.php index e3d67b46c..60af9db7c 100644 --- a/src/CompilerException.php +++ b/src/CompilerException.php @@ -16,14 +16,14 @@ class CompilerException extends Exception { * @param int $code The Exception code. * @param string|null $filename The filename where the exception is thrown. * @param int|null $line The line number where the exception is thrown. - * @param Throwable|null $previous The previous exception used for the exception chaining. + * @param \Throwable|null $previous The previous exception used for the exception chaining. */ public function __construct( string $message = "", int $code = 0, ?string $filename = null, ?int $line = null, - Throwable $previous = null + ?\Throwable $previous = null ) { parent::__construct($message, $code, $previous); diff --git a/src/Resource/BasePlugin.php b/src/Resource/BasePlugin.php index 56f7dfa05..6d2222237 100644 --- a/src/Resource/BasePlugin.php +++ b/src/Resource/BasePlugin.php @@ -112,7 +112,7 @@ abstract public function getContent(Source $source); * @param Source $source source object * @param Template|null $_template template object */ - abstract public function populate(Source $source, \Smarty\Template $_template = null); + abstract public function populate(Source $source, ?\Smarty\Template $_template = null); /** * populate Source Object with timestamp and exists from Resource diff --git a/src/Resource/CustomPlugin.php b/src/Resource/CustomPlugin.php index b50ef7aaf..895e97108 100644 --- a/src/Resource/CustomPlugin.php +++ b/src/Resource/CustomPlugin.php @@ -50,7 +50,7 @@ protected function fetchTimestamp($name) { * @param Source $source source object * @param Template|null $_template template object */ - public function populate(Source $source, Template $_template = null) { + public function populate(Source $source, ?Template $_template = null) { $source->uid = sha1($source->type . ':' . $source->name); $mtime = $this->fetchTimestamp($source->name); if ($mtime !== null) { diff --git a/src/Resource/ExtendsPlugin.php b/src/Resource/ExtendsPlugin.php index 0f9c9de25..960e37971 100644 --- a/src/Resource/ExtendsPlugin.php +++ b/src/Resource/ExtendsPlugin.php @@ -23,7 +23,7 @@ class ExtendsPlugin extends BasePlugin * * @throws Exception */ - public function populate(Source $source, Template $_template = null) + public function populate(Source $source, ?Template $_template = null) { $uid = ''; $sources = array(); diff --git a/src/Resource/FilePlugin.php b/src/Resource/FilePlugin.php index c59595783..0033c8348 100644 --- a/src/Resource/FilePlugin.php +++ b/src/Resource/FilePlugin.php @@ -32,7 +32,7 @@ class FilePlugin extends BasePlugin { * * @throws Exception */ - public function populate(Source $source, Template $_template = null) { + public function populate(Source $source, ?Template $_template = null) { $source->uid = sha1( $source->name . ($source->isConfig ? $source->getSmarty()->_joined_config_dir : diff --git a/src/Resource/StreamPlugin.php b/src/Resource/StreamPlugin.php index 91afffdcd..9b5b3f579 100644 --- a/src/Resource/StreamPlugin.php +++ b/src/Resource/StreamPlugin.php @@ -33,7 +33,7 @@ class StreamPlugin extends RecompiledPlugin { * * @return void */ - public function populate(Source $source, Template $_template = null) { + public function populate(Source $source, ?Template $_template = null) { $source->uid = false; $source->content = $this->getContent($source); $source->timestamp = $source->exists = !!$source->content; diff --git a/src/Resource/StringPlugin.php b/src/Resource/StringPlugin.php index 6b5bee4dd..fb3692c73 100644 --- a/src/Resource/StringPlugin.php +++ b/src/Resource/StringPlugin.php @@ -31,7 +31,7 @@ class StringPlugin extends BasePlugin { * * @return void */ - public function populate(Source $source, Template $_template = null) { + public function populate(Source $source, ?Template $_template = null) { $source->uid = sha1($source->name); $source->timestamp = $source->exists = true; } diff --git a/src/Runtime/InheritanceRuntime.php b/src/Runtime/InheritanceRuntime.php index ffd7aae66..74ea85440 100644 --- a/src/Runtime/InheritanceRuntime.php +++ b/src/Runtime/InheritanceRuntime.php @@ -162,7 +162,7 @@ public function instanceBlock(Template $tpl, $className, $name, $tplIndex = null private function processBlock( Template $tpl, \Smarty\Runtime\Block $block, - \Smarty\Runtime\Block $parent = null + ?\Smarty\Runtime\Block $parent = null ) { if ($block->hide && !isset($block->child)) { return; diff --git a/src/Template.php b/src/Template.php index fcb0f58d2..242fb2388 100644 --- a/src/Template.php +++ b/src/Template.php @@ -115,7 +115,7 @@ class Template extends TemplateBase { public function __construct( $template_resource, Smarty $smarty, - \Smarty\Data $_parent = null, + ?\Smarty\Data $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, @@ -248,7 +248,7 @@ public function renderSubTemplate( $caching, $cache_lifetime, array $extra_vars = [], - int $scope = null, + ?int $scope = null, ?string $currentDir = null ) { @@ -462,7 +462,7 @@ public function getCompiler() { * @return string * @throws Exception */ - public function createCodeFrame($content = '', $functions = '', $cache = false, \Smarty\Compiler\Template $compiler = null) { + public function createCodeFrame($content = '', $functions = '', $cache = false, ?\Smarty\Compiler\Template $compiler = null) { return $this->getCodeFrameCompiler()->create($content, $functions, $cache, $compiler); } diff --git a/src/Template/Source.php b/src/Template/Source.php index 382e710a7..2ef13a48c 100644 --- a/src/Template/Source.php +++ b/src/Template/Source.php @@ -134,9 +134,9 @@ public function __construct(Smarty $smarty, $type, $name) { * @throws Exception */ public static function load( - Template $_template = null, - Smarty $smarty = null, - $template_resource = null + ?Template $_template = null, + ?Smarty $smarty = null, + $template_resource = null ) { if ($_template) { $smarty = $_template->getSmarty(); diff --git a/src/TemplateBase.php b/src/TemplateBase.php index 3674edf7c..f01d11076 100644 --- a/src/TemplateBase.php +++ b/src/TemplateBase.php @@ -179,7 +179,7 @@ public function setCacheId($cache_id) { * @api Smarty::createData() * */ - public function createData(Data $parent = null, $name = null) { + public function createData(?Data $parent = null, $name = null) { /* @var Smarty $smarty */ $smarty = $this->getSmarty(); $dataObj = new Data($parent, $smarty, $name); diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index 18b4112fb..029c8f901 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -64,7 +64,7 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase */ public static function setUpBeforeClass(): void { - error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_USER_DEPRECATED); + error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED); self::$init = true; self::$pluginsdir =self::getSmartyPluginsDir(); } diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php index 0aa280c4e..40995a61e 100644 --- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/resource.filetest.php @@ -12,7 +12,7 @@ class Smarty_Resource_FiletestPlugin extends FilePlugin * @param Source $source source object * @param Template $_template template object */ - public function populate(Source $source, Template $_template = null) + public function populate(Source $source, ?Template $_template = null) { parent::populate($source, $_template); if ($source->exists) { diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php index 85ffadd5c..0e5d173de 100644 --- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php +++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php @@ -34,7 +34,7 @@ public function setSegment($segment) * @param Source $source source object * @param Template $_template template object */ - public function populate(Source $source, Template $_template = null) + public function populate(Source $source, ?Template $_template = null) { $segment = ''; if ($this->segment) { diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php index 593155043..9f983912c 100644 --- a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db.php @@ -16,7 +16,7 @@ class Smarty_Resource_Db extends RecompiledPlugin { - public function populate(Source $source, Template $_template = null) { + public function populate(Source $source, ?Template $_template = null) { $source->uid = sha1($source->resource); $source->timestamp = 1000000000; $source->exists = true; diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db2.php b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db2.php index a4f654026..2eefc6c95 100644 --- a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db2.php +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db2.php @@ -16,7 +16,7 @@ class Smarty_Resource_Db2 extends RecompiledPlugin { - public function populate(Source $source, Template $_template = null) + public function populate(Source $source, ?Template $_template = null) { $source->uid = sha1($source->resource); $source->timestamp = 0; diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php index 455255e24..7bd904e25 100644 --- a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db3.php @@ -15,7 +15,7 @@ class Smarty_Resource_Db3 extends Smarty\Resource\BasePlugin { - public function populate(Source $source, Template $_template = null) + public function populate(Source $source, ?Template $_template = null) { $source->uid = sha1($source->resource); $source->timestamp = 0; diff --git a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php index 571df0d82..51162a0bf 100644 --- a/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php +++ b/tests/UnitTests/ResourceTests/ResourcePlugins/PHPunitplugins/resource.db4.php @@ -16,7 +16,7 @@ class Smarty_Resource_Db4 extends Smarty\Resource\BasePlugin { - public function populate(Source $source, Template $_template = null) + public function populate(Source $source, ?Template $_template = null) { $source->uid = sha1($source->resource); $source->timestamp = 0; diff --git a/tests/UnitTests/__shared/resources/resource.extendsall.php b/tests/UnitTests/__shared/resources/resource.extendsall.php index 9ffddc05e..14d37908f 100644 --- a/tests/UnitTests/__shared/resources/resource.extendsall.php +++ b/tests/UnitTests/__shared/resources/resource.extendsall.php @@ -22,7 +22,7 @@ class My_Resource_Extendsall extends \Smarty\Resource\ExtendsPlugin * * @return void */ - public function populate(Source $source, Template $_template = null) + public function populate(Source $source, ?Template $_template = null) { $uid = ''; $sources = array(); diff --git a/utilities/testrunners/php84/Dockerfile b/utilities/testrunners/php84/Dockerfile new file mode 100644 index 000000000..6050a3db0 --- /dev/null +++ b/utilities/testrunners/php84/Dockerfile @@ -0,0 +1,10 @@ +FROM php:8.4-rc-cli-bullseye + +## Basic utilities +RUN apt-get update -yqq && apt-get install -y curl apt-utils git zip unzip + +## Composer +COPY ./utilities/testrunners/shared/install-composer.sh /root/install-composer.sh +WORKDIR /root +RUN sh ./install-composer.sh +RUN mv ./composer.phar /usr/local/bin/composer