News for hackers. Stuff that matters.
Re:Go with PHP by jusssi on Thursday May 11, 2023 @01:10PM (#35905102)
https://symfony.com/doc/current/page_creation.html

Apparently there's now something called annotation routes. Which appear to be inferring functionality from comments.

You made me look though. I suppose I had it coming.

Re:Go with PHP by Arkounay on Thursday May 11, 2023 @02:29PM (#35906244)
They are not comments they are php8 attributes
Re:Go with PHP by jusssi on Thursday May 11, 2023 @03:20PM (#35907078)
PHP8 attributes are comments with a special format.
Re:Go with PHP by hazn on Thursday May 11, 2023 @05:08PM (#35908409)
They are not. Attributes are metadata that can reflected/accessed at runtime: https://php.watch/versions/8.0/attributes
Re:Go with PHP by zeroimpl on Thursday May 11, 2023 @09:30PM (#35910755)
Comments can also be accessed at runtime :)
Re:Go with PHP by psychoslave on Wednesday May 24, 2023 @09:05AM (#36057448)
And a program can generally read its source code and make fancy adhoc interpretation, sure. That’s nowhere close to specified facilities that you are guarantied to be able to use with a fair amount of trust in the resulting outcome with the regular toolbox.
Re:Go with PHP by Nullabillity on Friday May 12, 2023 @07:12AM (#35914582)
# is a PHP comment syntax. #[foo] is as much of a comment as #foo is.
Re:Go with PHP by pfsalter on Friday May 12, 2023 @08:15AM (#35915076)
Not since PHP8 it's not [0], it's a real part of the language that you can read and view using reflection

[0] https://www.php.net/manual/en/language.attributes.overview.p...

Re:Go with PHP by Nullabillity on Friday May 12, 2023 @10:21AM (#35916759)
It's still using a subset of the comment syntax, and will still be ignored as comments rather than hard-fail in earlier versions.

Unknown attributes are also ignored silently, which isn't really a good sign.

Re:Go with PHP by tored on Friday May 12, 2023 @12:55PM (#35918835)
This is one of the reasons I like PHP, in newer PHP versions it is an attribute but in older versions it is just a comment. Clever and backwards compatible.
Re:Go with PHP by Nullabillity on Friday May 12, 2023 @01:17PM (#35919079)
It isn't backwards compatible (`#[foo` used to be legal PHP 7, but is illegal in PHP 8).

It may technically be forwards compatible syntactically (`#[foo]` will, as you say, just be ignored by PHP 7), but that's an anti-feature (assuming that the attribute isn't a no-op, it'll presumably break something else).

Re:Go with PHP by tored on Friday May 12, 2023 @01:21PM (#35919144)
Okay, forward compatible. It makes it easier for framework and library maintainers to support multiple versions of PHP, which is nice.

> `#[foo` used to be legal PHP 7, but is illegal in PHP 8).

So it is not a comment in PHP8 then.