Skip to content

Commit

Permalink
PHP8.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jul 25, 2022
1 parent 20a8026 commit 5cd8562
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- "7.4"
- "8.0"
- "8.1"
- "8.2"

compiler:
- default
Expand All @@ -40,6 +41,9 @@ jobs:
- os: ubuntu-latest
php-version: "8.1"
compiler: jit
- os: ubuntu-latest
php-version: "8.2"
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 can be run with PHP 7.1 to PHP 8.1.
Smarty can be run with PHP 7.1 to PHP 8.2.

## 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 @@ -37,3 +37,8 @@ services:
service: base
build:
dockerfile: ./utilities/testrunners/php81/Dockerfile
php82:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php82/Dockerfile
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ What is Smarty?
==============

## Requirements
Smarty can be run with PHP 7.1 to PHP 8.1.
Smarty can be run with PHP 7.1 to PHP 8.2.

## Installation
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
Expand Down
4 changes: 2 additions & 2 deletions libs/plugins/modifiercompiler.escape.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
if (Smarty::$_MBSTRING) {
if ($_double_encode) {
// php >=5.2.3 - go native
return 'mb_convert_encoding(htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
return 'htmlspecialchars_decode(mb_convert_encoding(htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
var_export($char_set, true) . ', ' . var_export($double_encode, true) .
'), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
} elseif ($double_encode) {
// php <5.2.3 - only handle double encoding
return 'mb_convert_encoding(htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
return 'htmlspecialchars_decode(mb_convert_encoding(htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
} else {
// fall back to modifier.escape.php
Expand Down
1 change: 1 addition & 0 deletions libs/sysplugins/smarty_internal_extension_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
* @property mixed|\Smarty_Template_Cached configLoad
*/
#[\AllowDynamicProperties]
class Smarty_Internal_Extension_Handler
{
public $objType = null;
Expand Down
1 change: 1 addition & 0 deletions libs/sysplugins/smarty_internal_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*
* @method bool mustCompile()
*/
#[\AllowDynamicProperties]
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
{
/**
Expand Down
1 change: 1 addition & 0 deletions libs/sysplugins/smarty_security.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/**
* This class does contain the security settings
*/
#[\AllowDynamicProperties]
class Smarty_Security
{

Expand Down
1 change: 1 addition & 0 deletions libs/sysplugins/smarty_variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @package Smarty
* @subpackage Template
*/
#[\AllowDynamicProperties]
class Smarty_Variable
{
/**
Expand Down
10 changes: 10 additions & 0 deletions utilities/testrunners/php82/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM php:8.2-cli

## 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

0 comments on commit 5cd8562

Please sign in to comment.