Skip to content

Commit

Permalink
Fixed that using count() would trigger a deprecation notice.
Browse files Browse the repository at this point in the history
  • Loading branch information
wisskid committed Aug 13, 2024
1 parent 9fc96a1 commit ad364d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed that using `count()` would trigger a deprecation notice. [#813](https://github.com/smarty-php/smarty/issues/813)
2 changes: 1 addition & 1 deletion libs/sysplugins/smarty_internal_templatecompilerbase.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ public function compilePHPFunctionCall($name, $parameter)
if (
!$this->smarty->loadPlugin('smarty_modifiercompiler_' . $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 ' .
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ public function testDeprecationNoticesForSmarty5($strTemplateSource, $expected =
$this->smarty->assign('f', 3.14);

$errorMessage = '';
$output = '';

try {
$output = $this->smarty->fetch('string:' . $strTemplateSource);
Expand Down Expand Up @@ -282,6 +283,7 @@ public function dataDeprecationNoticesForSmarty5()
['{$a|substr:-1}', 'a', false],
['{$f|substr:-1}', '4', false],
['{$ar|count}', '2', false],
['{count($ar)}', '2', false],
['{foreach "."|explode:$f as $n}{$n}{/foreach}', '314', false],
['{"-"|implode:$ar}', '1-2', false],
['{"-"|join:$ar}', '1-2', false],
Expand Down

0 comments on commit ad364d3

Please sign in to comment.