Fix Too many shorthand attributes error when using a modifier as a function with more than 3 parameters in an expression

Fixes #949
This commit is contained in:
Simon Wisselink
2024-03-15 10:22:29 +01:00
parent 293bc20db0
commit 32be22b3e9
15 changed files with 80 additions and 144 deletions
@@ -0,0 +1,19 @@
<?php
namespace Smarty\Compile\Modifier;
use Smarty\CompilerException;
/**
* Smarty is_array modifier plugin
*/
class IsArrayModifierCompiler extends Base {
public function compile($params, \Smarty\Compiler\Template $compiler) {
if (count($params) !== 1) {
throw new CompilerException("Invalid number of arguments for is_array. is_array expects exactly 1 parameter.");
}
return 'is_array(' . $params[0] . ')';
}
}