mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-04 19:54:14 +02: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:
+29
-56
@@ -20,7 +20,7 @@
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @link https://www.smarty.net/
|
||||
* @copyright 2018 New Digital Group, Inc.
|
||||
* @copyright 2018 Uwe Tews
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
@@ -60,19 +60,6 @@ if (!defined('SMARTY_MBSTRING')) {
|
||||
*/
|
||||
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
|
||||
// UTF-8 can only be done properly when mbstring is available!
|
||||
/**
|
||||
* @deprecated in favor of Smarty::$_CHARSET
|
||||
*/
|
||||
define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
|
||||
/**
|
||||
* @deprecated in favor of Smarty::$_DATE_FORMAT
|
||||
*/
|
||||
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
|
||||
}
|
||||
/**
|
||||
* Load Smarty_Autoloader
|
||||
*/
|
||||
@@ -143,13 +130,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
const DEBUG_OFF = 0;
|
||||
const DEBUG_ON = 1;
|
||||
const DEBUG_INDIVIDUAL = 2;
|
||||
/**
|
||||
* modes for handling of "<?php ... ?>" tags in templates.
|
||||
*/
|
||||
const PHP_PASSTHRU = 0; //-> print tags as plain text
|
||||
const PHP_QUOTE = 1; //-> escape tags as entities
|
||||
const PHP_REMOVE = 2; //-> escape tags as entities
|
||||
const PHP_ALLOW = 3; //-> escape tags as entities
|
||||
|
||||
/**
|
||||
* filter types
|
||||
*/
|
||||
@@ -179,13 +160,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* The character set to adhere to (e.g. "UTF-8")
|
||||
*/
|
||||
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
|
||||
public static $_CHARSET = SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1';
|
||||
|
||||
/**
|
||||
* The date format to be used internally
|
||||
* (accepts date() and strftime())
|
||||
*/
|
||||
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
|
||||
public static $_DATE_FORMAT = '%b %e, %Y';
|
||||
|
||||
/**
|
||||
* Flag denoting if PCRE should run in UTF-8 mode
|
||||
@@ -369,13 +350,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public $security_policy = null;
|
||||
|
||||
/**
|
||||
* controls handling of PHP-blocks
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $php_handling = self::PHP_PASSTHRU;
|
||||
|
||||
/**
|
||||
* controls if the php template file resource is allowed
|
||||
*
|
||||
@@ -666,6 +640,12 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
'cache_dir' => 'CacheDir',
|
||||
);
|
||||
|
||||
/**
|
||||
* PHP7 Compatibility mode
|
||||
* @var bool
|
||||
*/
|
||||
private $isMutingUndefinedOrNullWarnings = false;
|
||||
|
||||
/**
|
||||
* Initialize new Smarty object
|
||||
*/
|
||||
@@ -688,27 +668,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable error handler to mute expected messages
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated
|
||||
*/
|
||||
public static function muteExpectedErrors()
|
||||
{
|
||||
return Smarty_Internal_ErrorHandler::muteExpectedErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable error handler muting expected messages
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public static function unmuteExpectedErrors()
|
||||
{
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a template resource exists
|
||||
*
|
||||
@@ -1387,11 +1346,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
private function _normalizeDir($dirName, $dir)
|
||||
{
|
||||
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
|
||||
if (class_exists('Smarty_Internal_ErrorHandler', false)) {
|
||||
if (!isset(Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ])) {
|
||||
Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1421,4 +1375,23 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) :
|
||||
$this->_joined_template_dir = join('#', $this->template_dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates PHP7 compatibility mode:
|
||||
* - converts E_WARNINGS for "undefined array key" and "trying to read property of null" errors to E_NOTICE
|
||||
*
|
||||
* @void
|
||||
*/
|
||||
public function muteUndefinedOrNullWarnings(): void {
|
||||
$this->isMutingUndefinedOrNullWarnings = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if PHP7 compatibility mode is set.
|
||||
* @bool
|
||||
*/
|
||||
public function isMutingUndefinedOrNullWarnings(): bool {
|
||||
return $this->isMutingUndefinedOrNullWarnings;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user