mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 21:31:48 +01:00
Feature/php8 support (#629)
Adds support for PHP8.0, dropping support for PHP7.0 and below.
Backwards incompatible changes:
- 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
See the changelog for more details.
Switched CI from Travis to Github CI.
This commit is contained in:
@@ -203,13 +203,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public $blockOrFunctionCode = '';
|
||||
|
||||
/**
|
||||
* php_handling setting either from Smarty or security
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $php_handling = 0;
|
||||
|
||||
/**
|
||||
* flags for used modifier plugins
|
||||
*
|
||||
@@ -438,11 +431,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
if (isset($this->template->smarty->security_policy)) {
|
||||
$this->php_handling = $this->template->smarty->security_policy->php_handling;
|
||||
} else {
|
||||
$this->php_handling = $this->template->smarty->php_handling;
|
||||
}
|
||||
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
|
||||
$nocache = isset($nocache) ? $nocache : false;
|
||||
if (empty($template->compiled->nocache_hash)) {
|
||||
@@ -627,11 +615,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->trigger_template_error('Illegal number of parameter in "isset()"');
|
||||
}
|
||||
|
||||
$pa = array();
|
||||
foreach ($parameter as $p) {
|
||||
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
|
||||
}
|
||||
return '(' . implode(' && ', $pa) . ')';
|
||||
$pa = array();
|
||||
foreach ($parameter as $p) {
|
||||
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
|
||||
}
|
||||
return '(' . implode(' && ', $pa) . ')';
|
||||
|
||||
} elseif (in_array(
|
||||
$func_name,
|
||||
@@ -649,12 +637,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
|
||||
}
|
||||
if ($func_name === 'empty') {
|
||||
if (!$this->syntaxMatchesVariable($parameter[0]) && version_compare(PHP_VERSION, '5.5.0', '<')) {
|
||||
return '(' . $parameter[ 0 ] . ' === false )';
|
||||
} else {
|
||||
return $func_name . '(' .
|
||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||
}
|
||||
return $func_name . '(' .
|
||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||
} else {
|
||||
return $func_name . '(' . $parameter[ 0 ] . ')';
|
||||
}
|
||||
@@ -667,16 +651,16 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the passed string represents a valid (PHP) variable.
|
||||
* This is important, because `isset()` only works on variables and `empty()` can only be passed
|
||||
* a variable prior to php5.5
|
||||
* @param $string
|
||||
* @return bool
|
||||
*/
|
||||
private function syntaxMatchesVariable($string) {
|
||||
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
|
||||
return 1 === preg_match($regex_pattern, trim($string));
|
||||
/**
|
||||
* Determines whether the passed string represents a valid (PHP) variable.
|
||||
* This is important, because `isset()` only works on variables and `empty()` can only be passed
|
||||
* a variable prior to php5.5
|
||||
* @param $string
|
||||
* @return bool
|
||||
*/
|
||||
private function syntaxMatchesVariable($string) {
|
||||
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
|
||||
return 1 === preg_match($regex_pattern, trim($string));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,11 +675,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
{
|
||||
|
||||
if (strpos($text, '<') === false) {
|
||||
return preg_replace($this->stripRegEx, '', $text);
|
||||
return preg_replace($this->stripRegEx, '', $text);
|
||||
}
|
||||
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
|
||||
Reference in New Issue
Block a user