Skip to content

Unable to use aliased String namespace since 8.2 #11152

Closed

Description

@InvisibleSmiley

Description

The following code:

<?php
use Foo\Bar\String as MyString;

Resulted in this output:

Fatal error: Cannot alias 'Foo\Bar\String' as it is a built-in type in ... on line 3

But I expected this output instead:

Note that Foo\Bar\String is just a namespace (part), not a class/interface/trait/enum.

I checked the 8.2 documentation (migration guide, backward incompatible changes, changelog) and it seems to me this was not really intended. Worked fine up until 8.1.x.

PHP Version

8.2.0

Operating System

No response

Activity

  1. InvisibleSmiley commented on Apr 28, 2023

    @InvisibleSmiley
    Author

    I was told the issue was caused by this:
    #9402

  2. iluuu1994 commented on Apr 28, 2023

    @iluuu1994
    Member

    Hi @InvisibleSmiley! What's the use case for this? This would've failed before as well, just in a different location.

    https://3v4l.org/QM5mP

  3. InvisibleSmiley commented on Apr 28, 2023

    @InvisibleSmiley
    Author

    As I said, my case is about namespaces only. Example (actual things / inheritance etc. in the NS are irrelevant):
    https://3v4l.org/Q9Fbi

  4. iluuu1994 commented on Apr 28, 2023

    @iluuu1994
    Member

    Hmm, I think this is an oversight of #9402.
    @Girgias The use-case above looks valid as long as we support these keywords in namespaces, so I'm thinking we should revert the PR.

  5. Girgias commented on Apr 28, 2023

    @Girgias
    Member

    Fine with me, this only came up because someone on Room 11 was doing some weird stuff and not understanding the weird error message that resulted later.

    Feel free to revert now or I'll do this next week when I get back from holiday. :)

  6. added 2 commits that reference this issue on Apr 28, 2023
    3ad0334
    5ad6571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions