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

Feature/php8 support #629

Merged
merged 29 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
277a11a
See if we can get travis to run unit tests on actual php8
wisskid Jan 5, 2021
e71481a
Dropped suppport for php<7.2 to enable unit testing for php8, using p…
wisskid Jan 6, 2021
d01f9cd
Added unit test to confirm #605 was actually fixed
wisskid Jan 8, 2021
7e0d639
Test Github CI
wisskid Jan 8, 2021
0bca092
switch to default composer
wisskid Jan 8, 2021
7050ff7
Unit test improvements:
wisskid Jan 8, 2021
24dbbef
Remove all references to travis
wisskid Jan 8, 2021
c665217
Fix phpunit.sh to use phpunit.xml
wisskid Jan 8, 2021
8444ff7
Improved php7-style default modifier that does not trigger custom err…
wisskid Jan 8, 2021
9e394a5
Removed all PHP_VERSION_ID and compare_version checks and conditional…
wisskid Jan 8, 2021
886c57d
Merge branch 'master' into feature/php8-support
wisskid Jan 8, 2021
09bbab8
Somehow I managed to miss testing on php7.1 in CI
wisskid Jan 8, 2021
fc4437e
Merge branch 'feature/php8-support' of github.com:smarty-php/smarty i…
wisskid Jan 8, 2021
0be482d
Allow PHPUnit 7.5 for PHP7.1
wisskid Jan 8, 2021
34bb308
differ composer cache for php version to support php7.1 testing
wisskid Jan 8, 2021
f50a573
differ composer cache for php version to support php7.1 testing
wisskid Jan 8, 2021
bdf7122
Fixed composer.json at PHP<9, removed IRC channel and added one autho…
wisskid Jan 8, 2021
0f858fb
Removed BC code. WIP
wisskid Jan 9, 2021
0911e5f
removed unused variable from CacheResourceTestCommon
wisskid Jan 9, 2021
834959c
Changelog
wisskid Jan 9, 2021
170db9b
Dropped deprecated constants, an API method and an API argument type
wisskid Jan 15, 2021
1430f61
Fixed unit tests for removed deprecated code in previous commit
wisskid Jan 15, 2021
5983f97
Fixed unit tests for removed deprecated code in previous commit
wisskid Jan 15, 2021
992ba3d
Removed compatibility code for older PHPUnit versions
wisskid Jan 15, 2021
1a052b6
Added a ->setPHP7CompatMode() that will fix undefined array keys etc …
wisskid Jan 15, 2021
c5cc763
Fix comments and indentation (#637)
sapics Aug 18, 2021
867154c
Rename setPHP7CompatMode/getPHP7CompatMode for clarity
wisskid Aug 18, 2021
492c05b
Updated info PHP version support in README, dropped installation inst…
wisskid Oct 13, 2021
0cb91c2
Merge branch 'master' into feature/php8-support
wisskid Oct 13, 2021
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: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/make-release.sh export-ignore
/phpunit.sh export-ignore
/phpunit.xml export-ignore
/TODO.md export-ignore
/travis.ini export-ignore
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

on:
- pull_request
- push

name: CI

jobs:
tests:
name: Tests

runs-on: ${{ matrix.os }}

env:
PHP_EXTENSIONS: dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
PHP_INI_VALUES: assert.exception=1, zend.assertions=1

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest

php-version:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"

compiler:
- default

include:
- os: ubuntu-latest
php-version: "8.0"
compiler: jit

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Override PHP ini values for JIT compiler
if: matrix.compiler == 'jit'
run: echo "PHP_INI_VALUES::assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit=1255, opcache.jit_buffer_size=32M" >> $GITHUB_ENV

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
extensions: ${{ env.PHP_EXTENSIONS }}
ini-values: ${{ env.PHP_INI_VALUES }}

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run tests with phpunit
run: ./phpunit.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ utilies/*.php

# Dev
phpunit*
.phpunit.result.cache
vendor/*
composer.lock
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- You can now use `$smarty->muteUndefinedOrNullWarnings()` to activate convert warnings about undefined or null template vars to notices when running PHP8

### Changed
- Switch CI from Travis to Github CI
- Updated unit tests to avoid skipped and risky test warnings

### Removed
- Dropped support for PHP7.0 and below, so Smarty now requires PHP >=7.1
- Dropped support for php asp tags in templates (removed from php since php7.0)
- Dropped deprecated API calls that where only accessible through SmartyBC
- Dropped support for {php} and {include_php} tags and embedded PHP in templates. Embedded PHP will now be passed through as is.
- Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required
- Dropped deprecated SMARTY_RESOURCE_CHAR_SET and SMARTY_RESOURCE_DATE_FORMAT constants
- Dropped deprecated Smarty::muteExpectedErrors and Smarty::unmuteExpectedErrors API methods
- Dropped deprecated $smarty->getVariable() method. Use $smarty->getTemplateVars() instead.
- $smarty->registerResource() no longer accepts an array of callback functions

## [3.1.40] - 2021-10-13

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $smarty->unregisterFilter(...)

Please refer to the online documentation for all specific changes:

http://www.smarty.net/documentation
https://www.smarty.net/documentation

----

Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Smarty 3 template engine
[smarty.net](https://www.smarty.net/)

[![Build Status](https://travis-ci.org/smarty-php/smarty.svg?branch=master)](https://travis-ci.org/smarty-php/smarty)
![CI](https://github.com/smarty-php/smarty/workflows/CI/badge.svg)

## Documentation

For documentation see
[www.smarty.net/docs/en/](https://www.smarty.net/docs/en/)

## Requirements

Smarty can be run with PHP 5.2 to PHP 7.4.
Smarty can be run with PHP 7.1 to PHP 8.0.

## Distribution repository

Expand Down Expand Up @@ -74,5 +73,3 @@ Or you could use:
```

Which is a wrapper to install all 3 packages.

Composer can also be used for Smarty2 versions 2.6.24 to 2.6.30.
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": [
"templating"
],
"homepage": "http://www.smarty.net",
"homepage": "https://www.smarty.net",
"license": "LGPL-3.0",
"authors": [
{
Expand All @@ -19,15 +19,18 @@
{
"name": "Rodney Rehm",
"email": "[email protected]"
},
{
"name": "Simon Wisselink",
"homepage": "https://www.iwink.nl/"
}
],
"support": {
"irc": "irc://irc.freenode.org/smarty",
"issues": "https://github.com/smarty-php/smarty/issues",
"forum": "http://www.smarty.net/forums/"
"forum": "https://www.smarty.net/forums/"
},
"require": {
"php": ">=5.2"
"php": "^7.1 || ^8.0"
},
"autoload": {
"classmap": [
Expand All @@ -36,11 +39,11 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
"dev-master": "4.0.x-dev"
}
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^6.5 || ^5.7 || ^4.8",
"phpunit/phpunit": "^8.5 || ^7.5",
"smarty/smarty-lexer": "^3.1"
}
}
10 changes: 1 addition & 9 deletions lexer/smarty_internal_templatelexer.plex
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ class Smarty_Internal_Templatelexer
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=((SMARTYldel)SMARTYal|\$|`\$|"SMARTYliteral))~
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
emptyjava = ~[{][}]~
phptag = ~(SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[/]phpSMARTYrdel~
phpstart = ~[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>]|[?][>]|[%][>]~
slash = ~[/]~
ldel = ~(SMARTYldel)SMARTYal~
rdel = ~\s*SMARTYrdel~
Expand Down Expand Up @@ -362,9 +360,6 @@ class Smarty_Internal_Templatelexer
$this->value = substr($this->data,$this->counter,$to-$this->counter);
return false;
}
phptag {
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
userliteral {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
Expand All @@ -380,12 +375,9 @@ class Smarty_Internal_Templatelexer
$this->yypushstate(self::TAG);
return true;
}
phpstart {
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
char {
if (!isset($this->yy_global_text)) {
$this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal|[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*[>]|[?][>]|[%][>]SMARTYliteral/isS');
$this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal/isS');
}
$to = $this->dataLength;
preg_match($this->yy_global_text, $this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
Expand Down
11 changes: 0 additions & 11 deletions lexer/smarty_internal_templateparser.y
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Smarty_Internal_Templateparser
{
const ERR1 = 'Security error: Call to private object member not allowed';
const ERR2 = 'Security error: Call to dynamic object member not allowed';
const ERR3 = 'PHP in template not allowed. Use SmartyBC to enable it';

/**
* result status
Expand Down Expand Up @@ -237,16 +236,6 @@ start(res) ::= template. {
res = $this->root_buffer->to_smarty_php($this);
}


// php tags
template ::= template PHP(B). {
$code = $this->compiler->compileTag('private_php',array(array('code' => B), array('type' => $this->lex->phpType )),array());
if ($this->compiler->has_code && !empty($code)) {
$tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array();
$this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.$code,true)));
}
}

// template text
template ::= template TEXT(B). {
$text = $this->yystack[ $this->yyidx + 0 ]->minor;
Expand Down
8 changes: 2 additions & 6 deletions libs/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Smarty_Autoloader
*
* @var array
*/
public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
public static $rootClasses = array('smarty' => 'Smarty.class.php');

/**
* Registers Smarty_Autoloader backward compatible to older installations.
Expand Down Expand Up @@ -76,11 +76,7 @@ public static function register($prepend = false)
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
} else {
spl_autoload_register(array(__CLASS__, 'autoload'));
}
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
}

/**
Expand Down
Loading
Loading