smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.23k stars 703 forks source link

Wrong implode/join use? #981

Closed Ninjinka closed 4 months ago

Ninjinka commented 4 months ago

Hello as php.net state implode (or join since it's an alias) should be

implode([string] $separator, [array] $array): [string]

Why smarty send a deprecation notice if used correctly? also the deprecation suggest to use join and with as parameters first array than separator (as in legacy mode for php 7.4)

Is not best to be php compilant?

scottchiefbaker commented 4 months ago

@Ninjinka can you post an example test case of how you're calling this?

scottchiefbaker commented 4 months ago
// https://github.com/smarty-php/smarty/issues/561
function smarty_modifier_join($array, $glue = '') {
    return join($glue, $array);
}

That is my join modifier which works without warnings.

wisskid commented 4 months ago

Is not best to be php compilant?

Smarty is Smarty and PHP is PHP. Smarty has no intention to mimic the syntax of PHP.

In my opinion, using implode as follows looks rather funny:

{","|implode:$array} {* <- this is weird *}

And this is much better:

{$array|join:","}