Skip to content

Fix no facade aliased classes with macroable #1709

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

Closed
wants to merge 1 commit into from

Conversation

erikn69
Copy link
Contributor

@erikn69 erikn69 commented May 14, 2025

Summary

Aliases can be used with classes that are not Illuminate\Support\Facades\Facade and they can be Macroable.
This PR allows classes alias that do not extend Facade to be added to the list of macroables.

To explain myself better, an example:
'Arr' => \Illuminate\Support\Arr::class Facades/Facade.php#L276@defaultAliases()
Arr alias for \Illuminate\Support\Arr::class is not a Facade but uses Macroable: Illuminate/Collections/Arr.php#L16-L18

If you look at the code below, before adding the list of macroables it is filtered by Facade, which is why aliases like Arr would not work

$aliases = $this->getValidAliases()->filter(static function (Alias $alias) {
return is_subclass_of($alias->getExtends(), Facade::class);
});
$this->addMacroableClasses($aliases);

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Misc. change (internal, infrastructure, maintenance, etc.)

Checklist

  • Existing tests have been adapted and/or new tests have been added
  • Update the README.md
  • Code style has been fixed via composer fix-style

@erikn69 erikn69 closed this May 14, 2025
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.

1 participant