Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8.4 support to Smarty #1043

Merged
merged 6 commits into from
Nov 20, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"

compiler:
- default
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions run-tests-for-all-php-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
2 changes: 1 addition & 1 deletion src/Cacheresource/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract public function populateTimestamp(Cached $cached);
*/
abstract public function process(
Template $_template,
Cached $cached = null,
?Cached $cached = null,
$update = false
);

Expand Down
2 changes: 1 addition & 1 deletion src/Cacheresource/Custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Cacheresource/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Cacheresource/KeyValueStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/CodeFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/CompilerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/Resource/BasePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Resource/CustomPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Resource/ExtendsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Resource/FilePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
2 changes: 1 addition & 1 deletion src/Resource/StreamPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Resource/StringPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/InheritanceRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -248,7 +248,7 @@ public function renderSubTemplate(
$caching,
$cache_lifetime,
array $extra_vars = [],
int $scope = null,
?int $scope = null,
?string $currentDir = null
) {

Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Template/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/TemplateBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit_Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/UnitTests/__shared/resources/resource.extendsall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions utilities/testrunners/php84/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Loading