Hi,
On 28.01.18 03:51, Christian Schneider wrote:
2) More importantly: It hides the variable being used: 'src' instead of $src
which makes it harder to search for the variable or statically analyse the code.
I'm not sure about that argument.
compact() been around basically since forecer. Modern PHP IDEs do
support this already and I'm pretty sure static analyzers do too (I now
for a fact that both PhpStorm and phpstan support it).
In contrast, I've this argument:
With compact() you have a clear call acting as a boundary when such a
behaviour is used. Use the direct-variable syntax doesn't give you that
because you would at least know the name of a variable or apply regular
expression for such but I bet you can't easily use any tool at hand like
you could with compact.
Is this _more_ relevant than your arguments? I'm not to judge :)
But I too believe compact() serves well and covers everything and the
proposal is one more thing to put alternative syntax for something
already possible.
I also weight that it's practical impact is much more less then compared
to e.g. the coalesce operator. That ons is also just syntax sugar but it
really made an impact to the language because that pattern is very very
common.
I don't think this applies to compact(); it only has very special
use-cases (and it's not only templating…), I see it in almost every
project I work and (and use it myself) and I never felt something
"fix-worthy" with it.
- Markus
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php