Skip to content

Commit

Permalink
Merge pull request #743 from xorti/fix-php81-rtrim-calls
Browse files Browse the repository at this point in the history
Fix PHP 8.1 deprecated warning when calling rtrim
  • Loading branch information
wisskid authored Apr 26, 2022
2 parents bfa02f3 + 962f266 commit 8b96efa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ public function getPluginsDir()
$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;
Expand Down Expand Up @@ -1345,7 +1345,7 @@ public function __set($name, $value)
*/
private function _normalizeDir($dirName, $dir)
{
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
$this->{$dirName} = $this->_realpath(rtrim($dir ?? '', "/\\") . DIRECTORY_SEPARATOR, true);
}

/**
Expand All @@ -1367,7 +1367,7 @@ private function _normalizeTemplateConfig($isConfig)
}
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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/sysplugins/smarty_internal_compile_insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
}
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 8b96efa

Please sign in to comment.