Re: [PHP-DEV] Re: Should hash comments be deprecated?

  111677
August 21, 2020 21:13 tovilo.ilija@gmail.com (Ilija Tovilo)
Hi Andrea

> There is a critical use-case for comments beginning with the hash > symbol, namely UNIX shebang lines. In theory we could special-case those > and disallow the symbol in every other use, but… well, that seems like a > bit of a shame.
Correct me if I'm wrong, but the shebang goes before the PHP opening tag https://github.com/php/php-src/blob/f32653accc0fc2401aca91f9590272b8d95ef426/Zend/zend_language_scanner.l#L2155 Ilija
  111708
August 29, 2020 17:22 tysonandre775@hotmail.com (tyson andre)
Hi internals,

If it turns out that the impact on legacy applications, legacy libraries, or holding back upgrades is a concern for others
(I'm not sure what the most common opinion is),
another option would be a system ini setting

`hash_comment = 0|1|2`
0 - disable `#comment` support completely when parsing/lexing - throw a ParseError while lexing and return T_ERROR in token_get_all
1 - (default) emit a compilation warning or deprecation notice when parsing files mentioning that hash comments will be removed in a future major release. Do this only for the first comment.
2 - allow it silently (possibly an unnecessary option to provide)

Then, this could be gradually strictened

- Forbid option 2 in php 8.x
- change the default ini setting value to 0 in 8.x or 9.0
- Add a configuration setting in php 8.x or 9.x to always disable hash comments
- Remove support 

> Correct me if I'm wrong, but the shebang goes before the PHP opening > tag special case.
Yes, shebang can only be parsed on the first line of a script - before `
  111709
August 29, 2020 19:25 david.proweb@gmail.com (David Rodrigues)
I have suggested on past a declare() to help in cases like that:

declare(php_version = "8.0");

It could be declared to new PHP files, so old files could supports # as
comments and new files will not.

Other option is supports tysonandre775@hotmail.com>
escreveu:

> Hi internals, > > If it turns out that the impact on legacy applications, legacy libraries, > or holding back upgrades is a concern for others > (I'm not sure what the most common opinion is), > another option would be a system ini setting > > `hash_comment = 0|1|2` > 0 - disable `#comment` support completely when parsing/lexing - throw a > ParseError while lexing and return T_ERROR in token_get_all > 1 - (default) emit a compilation warning or deprecation notice when > parsing files mentioning that hash comments will be removed in a future > major release. Do this only for the first comment. > 2 - allow it silently (possibly an unnecessary option to provide) > > Then, this could be gradually strictened > > - Forbid option 2 in php 8.x > - change the default ini setting value to 0 in 8.x or 9.0 > - Add a configuration setting in php 8.x or 9.x to always disable hash > comments > - Remove support > > > Correct me if I'm wrong, but the shebang goes before the PHP opening > > tag > special case. > > Yes, shebang can only be parsed on the first line of a script - before > ` > Thanks, > - Tyson > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >
  111710
August 29, 2020 19:50 tysonandre775@hotmail.com (tyson andre)
Hi David,

> Other option is supports That doesn't work when php-src is compiled with support for short_open_tags.. It's treated as `https://externals.io/message/108699 Revisiting my earlier suggestion, starting off by just deprecating them without configuration options in 8.1 might be the most straightforward to start off with proposing, and the migration path for removal can be revisited years from that. Regards, - Tyson