summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Wisselink <wisskid@users.noreply.github.com>2022-04-26 22:09:10 +0200
committerGitHub <noreply@github.com>2022-04-26 22:09:10 +0200
commit8b96efad45ee9ef1f7b75296833b9d2ca9e3c9f6 (patch)
tree3e03d96a3756a54b5dd3aa79dcc98c4e38d72729
parentbfa02f3b919a071a4a141819579084ce119f2bae (diff)
parent962f266483f7843c2187dcf571332a0bfa4ea2d7 (diff)
downloadsmarty-8b96efad45ee9ef1f7b75296833b9d2ca9e3c9f6.tar.gz
smarty-8b96efad45ee9ef1f7b75296833b9d2ca9e3c9f6.tar.bz2
smarty-8b96efad45ee9ef1f7b75296833b9d2ca9e3c9f6.zip
Merge pull request #743 from xorti/fix-php81-rtrim-calls
Fix PHP 8.1 deprecated warning when calling rtrim
-rw-r--r--libs/Smarty.class.php6
-rw-r--r--libs/sysplugins/smarty_internal_compile_insert.php2
-rw-r--r--tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php2
3 files changed, 5 insertions, 5 deletions
diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php
index 0abbe6a7..ae14ab50 100644
--- a/libs/Smarty.class.php
+++ b/libs/Smarty.class.php
@@ -867,7 +867,7 @@ class Smarty extends Smarty_Internal_TemplateBase
$this->plugins_dir = (array)$this->plugins_dir;
}
foreach ($this->plugins_dir as $k => $v) {
- $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, '/\\') . DIRECTORY_SEPARATOR, true);
+ $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v ?? '', '/\\') . DIRECTORY_SEPARATOR, true);
}
$this->_cache[ 'plugin_files' ] = array();
$this->_pluginsDirNormalized = true;
@@ -1345,7 +1345,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
private function _normalizeDir($dirName, $dir)
{
- $this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
+ $this->{$dirName} = $this->_realpath(rtrim($dir ?? '', "/\\") . DIRECTORY_SEPARATOR, true);
}
/**
@@ -1367,7 +1367,7 @@ class Smarty extends Smarty_Internal_TemplateBase
}
foreach ($dir as $k => $v) {
if (!isset($processed[ $k ])) {
- $dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DIRECTORY_SEPARATOR, true);
+ $dir[ $k ] = $v = $this->_realpath(rtrim($v ?? '', "/\\") . DIRECTORY_SEPARATOR, true);
$processed[ $k ] = true;
}
}
diff --git a/libs/sysplugins/smarty_internal_compile_insert.php b/libs/sysplugins/smarty_internal_compile_insert.php
index c91ff62c..29031d91 100644
--- a/libs/sysplugins/smarty_internal_compile_insert.php
+++ b/libs/sysplugins/smarty_internal_compile_insert.php
@@ -93,7 +93,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
}
if (!empty($_dir)) {
foreach ((array)$_dir as $_script_dir) {
- $_script_dir = rtrim($_script_dir, '/\\') . DIRECTORY_SEPARATOR;
+ $_script_dir = rtrim($_script_dir ?? '', '/\\') . DIRECTORY_SEPARATOR;
if (file_exists($_script_dir . $_script)) {
$_filepath = $_script_dir . $_script;
break;
diff --git a/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php
index f161844a..934b8aa0 100644
--- a/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php
+++ b/tests/UnitTests/ResourceTests/Custom/Ambiguous/PHPunitplugins/resource.ambiguous.php
@@ -13,7 +13,7 @@ class Smarty_Resource_Ambiguous extends Smarty_Internal_Resource_File
public function __construct($directory)
{
- $this->directory = rtrim($directory, "/\\") . DIRECTORY_SEPARATOR;
+ $this->directory = rtrim($directory ?? '', "/\\") . DIRECTORY_SEPARATOR;
// parent::__construct();
}