Skip to content

[12.x] Fix group imports in Blade @use directive #55461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2025

Conversation

osbre
Copy link
Contributor

@osbre osbre commented Apr 17, 2025

PHP natively supports group imports since PHP 7.0:

use MySpace\{Foo, Bar};

Currently, the @use directive mistakenly treats these as aliases. For example,

@use(MySpace\{Foo, Bar})

Results in:

use MySpace\Foo as Bar.

This PR fixes it so that the blade code above, produces output equal to PHP's original feature:

use MySpace\{Foo, Bar};

@osbre osbre marked this pull request as draft April 17, 2025 21:22
@osbre
Copy link
Contributor Author

osbre commented Apr 17, 2025

Marking as draft since this PR currently breaks some behaviour that wasn't covered by tests. I have made a fix to the tests to document the behaviour that this PR would've broken: #55462

@osbre osbre force-pushed the fix/blade-@use-grouping branch from 0c06ba3 to 1865edd Compare April 18, 2025 19:37
@osbre osbre force-pushed the fix/blade-@use-grouping branch from 1865edd to db8f790 Compare April 18, 2025 19:39
@osbre
Copy link
Contributor Author

osbre commented Apr 18, 2025

Alright. Updated, now nothing breaks.

@osbre osbre marked this pull request as ready for review April 18, 2025 19:43
@taylorotwell taylorotwell merged commit c01bb8d into laravel:12.x Apr 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants