Hi everyone,
while playing around with the new group use syntax, I stumbled upon an
inconsistency of which I'm not sure whether or not it is expected.
For the "classic" syntax, while technically pointless, a leading \ for
the name is considered valid and works identical to a line without it:
<?php
namespace foo;
use \some\bar;
use some\baz;
With the new group syntax, the version with a leading \ is considered
invalid - a lint will PHP Parse error: syntax error, unexpected '{',
expecting identifier (T_STRING):
<?php
namespace foo;
use some{ bar, baz };
use \some{ bar, baz };
Is this a bug or feature?
Regards,
Arne
--
Those who do not understand Unix
are condemned to reinvent it, poorly (Henry Spencer,1987)
Hi,
2015-08-18 17:47 GMT-03:00 Arne Blankerts theseer@netpirates.net:
Hi everyone,
while playing around with the new group use syntax, I stumbled upon an
inconsistency of which I'm not sure whether or not it is expected.
For the "classic" syntax, while technically pointless, a leading \ for
the name is considered valid and works identical to a line without it:<?php
namespace foo;
use \some\bar;
use some\baz;With the new group syntax, the version with a leading \ is considered
invalid - a lint will PHP Parse error: syntax error, unexpected '{',
expecting identifier (T_STRING):<?php
namespace foo;
use some{ bar, baz };
use \some{ bar, baz };Is this a bug or feature?
Regards,
Arne--
Those who do not understand Unix
are condemned to reinvent it, poorly (Henry Spencer,1987)
This is definitely a bug. The leading slash is part of the main
namespace spec and therefore should be respected. This should have
been more explicit in the RFC.
I'll send a pull request with a fix.
Thanks,
Márcio Almada
while playing around with the new group use syntax, I stumbled upon an
inconsistency of which I'm not sure whether or not it is expected.
For the "classic" syntax, while technically pointless, a leading \ for
the name is considered valid and works identical to a line without it:<?php
namespace foo;
use \some\bar;
use some\baz;With the new group syntax, the version with a leading \ is considered
invalid - a lint will PHP Parse error: syntax error, unexpected '{',
expecting identifier (T_STRING):<?php
namespace foo;
use some{ bar, baz };
use \some{ bar, baz };Is this a bug or feature?
It seems to me that is an oversight. The resolution would be rather
simple, cf.
https://github.com/php/php-src/blob/php-7.0.0beta3/Zend/zend_language_parser.y#L366-L375.
However, while looking at the grammar, I've noticed that the entities
inside the braces may start with a backslash, what I consider rather
strange (particularly as there has to be a backslash immediately before
the opening brace).
--
Christoph M. Becker
Hi,
2015-08-18 19:18 GMT-03:00 Christoph Becker cmbecker69@gmx.de:
while playing around with the new group use syntax, I stumbled upon an
inconsistency of which I'm not sure whether or not it is expected.
For the "classic" syntax, while technically pointless, a leading \ for
the name is considered valid and works identical to a line without it:<?php
namespace foo;
use \some\bar;
use some\baz;With the new group syntax, the version with a leading \ is considered
invalid - a lint will PHP Parse error: syntax error, unexpected '{',
expecting identifier (T_STRING):<?php
namespace foo;
use some{ bar, baz };
use \some{ bar, baz };Is this a bug or feature?
It seems to me that is an oversight. The resolution would be rather
simple, cf.
https://github.com/php/php-src/blob/php-7.0.0beta3/Zend/zend_language_parser.y#L366-L375.
This one was fixed via PR ^
However, while looking at the grammar, I've noticed that the entities
inside the braces may start with a backslash, what I consider rather
strange (particularly as there has to be a backslash immediately before
the opening brace).
Someone beat me to it, all fixed now. Thank you!
--
Christoph M. Becker
Marcio