Skip to content
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

[8.x] Improves Support\Reflector to support checking interfaces #40822

Merged
merged 2 commits into from
Feb 5, 2022
Merged

[8.x] Improves Support\Reflector to support checking interfaces #40822

merged 2 commits into from
Feb 5, 2022

Conversation

hassanhe
Copy link
Contributor

@hassanhe hassanhe commented Feb 5, 2022

Since ReflectionClass already may represent an interface, we may check for interface existence as part of checking parameter subclass.

isParameterSubclassOf is used in two places for model route binding:

  • Routing\RouteSignatureParameters
  • Broadcasting\Broadcasters\Broadcaster

This improvement helps with implicit binding when the parameter is an interface served from the container

use Illuminate\Contracts\Routing\UrlRoutable;

interface MyUrlRoutableModel extends UrlRoutable {
 //
}

Route::get('/{model}', function (MyUrlRoutableModel $model) {
   // $model binds correctly
});

Fixes #11791

@hassanhe hassanhe changed the title Improves Support\Reflector to support checking interfaces [8.x] Improves Support\Reflector to support checking interfaces Feb 5, 2022
@taylorotwell taylorotwell merged commit d47153d into laravel:8.x Feb 5, 2022
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.

[5.2] Implicit route model binding a binded interface
2 participants