mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
Fixed that using count() would trigger a deprecation notice. (#1054)
This commit is contained in:
1
changelog/count.md
Normal file
1
changelog/count.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Fixed that using `count()` would trigger a deprecation notice. [#813](https://github.com/smarty-php/smarty/issues/813)
|
@@ -658,7 +658,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
if (
|
if (
|
||||||
!$this->smarty->loadPlugin('smarty_modifiercompiler_' . $name)
|
!$this->smarty->loadPlugin('smarty_modifiercompiler_' . $name)
|
||||||
&& !isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$name])
|
&& !isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$name])
|
||||||
&& !in_array($name, ['time', 'join', 'is_array', 'in_array'])
|
&& !in_array($name, ['time', 'join', 'is_array', 'in_array', 'count'])
|
||||||
) {
|
) {
|
||||||
trigger_error('Using unregistered function "' . $name . '" in a template is deprecated and will be ' .
|
trigger_error('Using unregistered function "' . $name . '" in a template is deprecated and will be ' .
|
||||||
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
||||||
|
@@ -247,6 +247,7 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign('f', 3.14);
|
$this->smarty->assign('f', 3.14);
|
||||||
|
|
||||||
$errorMessage = '';
|
$errorMessage = '';
|
||||||
|
$output = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$output = $this->smarty->fetch('string:' . $strTemplateSource);
|
$output = $this->smarty->fetch('string:' . $strTemplateSource);
|
||||||
@@ -282,6 +283,7 @@ class PhpFunctionTest extends PHPUnit_Smarty
|
|||||||
['{$a|substr:-1}', 'a', false],
|
['{$a|substr:-1}', 'a', false],
|
||||||
['{$f|substr:-1}', '4', false],
|
['{$f|substr:-1}', '4', false],
|
||||||
['{$ar|count}', '2', false],
|
['{$ar|count}', '2', false],
|
||||||
|
['{count($ar)}', '2', false],
|
||||||
['{foreach "."|explode:$f as $n}{$n}{/foreach}', '314', false],
|
['{foreach "."|explode:$f as $n}{$n}{/foreach}', '314', false],
|
||||||
['{"-"|implode:$ar}', '1-2', false],
|
['{"-"|implode:$ar}', '1-2', false],
|
||||||
['{"-"|join:$ar}', '1-2', false],
|
['{"-"|join:$ar}', '1-2', false],
|
||||||
|
Reference in New Issue
Block a user