You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using concatenation exponentially increases the memory PHP uses. While in a lot of cases, there is no alternative, there are some specific situations, where there is, most notably when using echo where comma's or interpolation can be used instead.
Question: Would there be interest in a sniff to detect (and possibly auto-fix) this ?
I image a sniff like this could go into the Generic.CodeAnalysis category.
Detect:
echo"Hello " . $name . "! Welcome!"; // Use comma's or interpolation instead.echo'<div><span>' . function_call($foo) . '</span>' . function_call($bar) . '</div>'; // Use comma's instead.
Inspired by this Twitter thread and this article.
Using concatenation exponentially increases the memory PHP uses. While in a lot of cases, there is no alternative, there are some specific situations, where there is, most notably when using
echo
where comma's or interpolation can be used instead.Question: Would there be interest in a sniff to detect (and possibly auto-fix) this ?
I image a sniff like this could go into the
Generic.CodeAnalysis
category.Detect:
Recommended alternative way of writing this code:
For more code examples, see the ClearPHP article.
The text was updated successfully, but these errors were encountered: