On 11.08.20 18:07, Sara Golemon wrote:
Writing this on PHP 7 (or any earlier version for that matter) would be
valid syntax (ignored as a comment):

#[SomeAttr(123)]
function someFunc() {}

That's what's meant by Forward Compatibility.  Library/Framework authors
could aggressively adopt attributes with the #[...] syntax, they can NOT do
so with any other syntax.

This would be a feature if libraries start parsing PHP token by token
and start supporting the #[] syntax for the 7.x versions of PHP - then
early adoption would be possible and it would be a real feature. But it
seems unclear if that will happen, as it will probably have a heavy
price on performance (and might have some complexity). And if some
libraries implement it but others don't, then it might get confusing for
users about why the new attribute syntax sometimes works and sometimes
silently does nothing.

It is also not perfect as multi-line attributes with #[ still break, or
code with #[] followed by more code instead of a newline and then more code.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to