Closed wisskid closed 5 months ago
There is a problem with implode. Using implode
(or join
) as a modifier in templates (prior to Smarty v5) (on PHP8), has to be done as follows: <td class="{' '|implode:$classes|escape}">
, since passing the separator after the array is no longer supported in PHP.
As a modifier, this seems silly. It would be more intuitive to flip the arguments, in the way Twig does it: {{ [1, 2, 3]|join('|') }}
. But we cannot just flip the arguments. We could detect argument types and throw a deprecation warning.
It seems Smarty v5 also supports strlen, time, count, is_array and in_array as functions. (They are implemented as FunctionHandlers.) This is undocumented.
Smarty also supports explode. It's undocumented, but it has been in the unit tests. However, the parameter order is weird and we cannot auto-fix it, since both parameters are strings. I propose to deprecate explode and promote split with the parameters reversed. For consistency, this would also mean we should implement join in favor of implode.
v4 deprecates and v5 drops support for many native php functions. implode, substr and json_encode are commonly used and it might be useful to support them.