Hi internals,
It all started with a PR over doctrine/annotations (
https://github.com/doctrine/annotations/pull/69), where a contributor
decided to propose supporting group use support.
The issue starts with this, which it is perfectly supported:
use Foo\Bar, Foo\Woo;
While multiple group uses are not:
use Foo{Bar, Baz}, Qux{Corge, Grault};
Then I decided to see what is really supported by the newly introduced
group use. According to the grammar, these are the same lines:
use Foo\Bar, Foo\Baz;
use Foo{Bar, Baz};
use function Foo\Bar\baz, Foo\Bar\qux;
use function Foo\Bar{baz, qux};
use Foo\Bar{function baz, function qux};
However, this feature leads to an inconsistent behavior in the language.
Mixed group use types are supported:
use Foo\Bar{Baz, function qux};
While mixing use types are not:
use Foo\Bar\Baz, function Foo\Bar\qux;
This brings the question of whether we should continue this madness path of
inconsistency or we start addressing inconsistencies one by one in the
language.
I'd like to propose options that we could fix this:
- Remove mixed group use types support (this would become invalid: use
Foo{Bar, function baz};) - Add mixed use support, which would contradict the approach took by typed
properties (this would require this approach: use function Foo\Bar\baz,
function Foo\Bar\qux;)
One of the approaches needs to be taken in order to support multiple group
use, otherwise we have a reduce/reduce yacc error that can't be fixed
(well, my yacc/compiler's knowledge hit a dead end there, without doubling
all the grammar rules and taking an overly complex route). Ultimately, the
question comes around if we should consider support of multiple group use.
If positive, I'd suggest approach two (I already have a patch for that! =D).
I'd like to gather opinions around this, so I can properly implement and
propose a patch through an RFC process.
Regards,
--
Guilherme Blanco
Lead Architect at E-Block
I thought there was one already?
https://wiki.php.net/rfc/group_use_declarations
On Sat, Apr 16, 2016 at 9:01 AM, guilhermeblanco@gmail.com <
guilhermeblanco@gmail.com> wrote:
Hi internals,
It all started with a PR over doctrine/annotations (
https://github.com/doctrine/annotations/pull/69), where a contributor
decided to propose supporting group use support.The issue starts with this, which it is perfectly supported:
use Foo\Bar, Foo\Woo;
While multiple group uses are not:
use Foo{Bar, Baz}, Qux{Corge, Grault};
Then I decided to see what is really supported by the newly introduced
group use. According to the grammar, these are the same lines:use Foo\Bar, Foo\Baz;
use Foo{Bar, Baz};use function Foo\Bar\baz, Foo\Bar\qux;
use function Foo\Bar{baz, qux};
use Foo\Bar{function baz, function qux};However, this feature leads to an inconsistent behavior in the language.
Mixed group use types are supported:use Foo\Bar{Baz, function qux};
While mixing use types are not:
use Foo\Bar\Baz, function Foo\Bar\qux;
This brings the question of whether we should continue this madness path of
inconsistency or we start addressing inconsistencies one by one in the
language.
I'd like to propose options that we could fix this:
- Remove mixed group use types support (this would become invalid: use
Foo{Bar, function baz};)- Add mixed use support, which would contradict the approach took by typed
properties (this would require this approach: use function Foo\Bar\baz,
function Foo\Bar\qux;)One of the approaches needs to be taken in order to support multiple group
use, otherwise we have a reduce/reduce yacc error that can't be fixed
(well, my yacc/compiler's knowledge hit a dead end there, without doubling
all the grammar rules and taking an overly complex route). Ultimately, the
question comes around if we should consider support of multiple group use.
If positive, I'd suggest approach two (I already have a patch for that!
=D).I'd like to gather opinions around this, so I can properly implement and
propose a patch through an RFC process.Regards,
--
Guilherme Blanco
Lead Architect at E-Block
--
Best Regards,
Yo-An Lin
You missed what I said.
You can do multiple single class/function/constant in a single statement,
but you cannot do multiple group use in a single statement. This:
use Foo\Bar,
Foo\Baz{Qux, Corge};
Regards,
I thought there was one already?
https://wiki.php.net/rfc/group_use_declarationsOn Sat, Apr 16, 2016 at 9:01 AM, guilhermeblanco@gmail.com <
guilhermeblanco@gmail.com> wrote:Hi internals,
It all started with a PR over doctrine/annotations (
https://github.com/doctrine/annotations/pull/69), where a contributor
decided to propose supporting group use support.The issue starts with this, which it is perfectly supported:
use Foo\Bar, Foo\Woo;
While multiple group uses are not:
use Foo{Bar, Baz}, Qux{Corge, Grault};
Then I decided to see what is really supported by the newly introduced
group use. According to the grammar, these are the same lines:use Foo\Bar, Foo\Baz;
use Foo{Bar, Baz};use function Foo\Bar\baz, Foo\Bar\qux;
use function Foo\Bar{baz, qux};
use Foo\Bar{function baz, function qux};However, this feature leads to an inconsistent behavior in the language.
Mixed group use types are supported:use Foo\Bar{Baz, function qux};
While mixing use types are not:
use Foo\Bar\Baz, function Foo\Bar\qux;
This brings the question of whether we should continue this madness path
of
inconsistency or we start addressing inconsistencies one by one in the
language.
I'd like to propose options that we could fix this:
- Remove mixed group use types support (this would become invalid: use
Foo{Bar, function baz};)- Add mixed use support, which would contradict the approach took by typed
properties (this would require this approach: use function Foo\Bar\baz,
function Foo\Bar\qux;)One of the approaches needs to be taken in order to support multiple group
use, otherwise we have a reduce/reduce yacc error that can't be fixed
(well, my yacc/compiler's knowledge hit a dead end there, without doubling
all the grammar rules and taking an overly complex route). Ultimately, the
question comes around if we should consider support of multiple group use.
If positive, I'd suggest approach two (I already have a patch for that!
=D).I'd like to gather opinions around this, so I can properly implement and
propose a patch through an RFC process.Regards,
--
Guilherme Blanco
Lead Architect at E-Block--
Best Regards,Yo-An Lin
--
Guilherme Blanco
Lead Architect at E-Block