-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[11.x] Allow non-ContextualAttribute
attributes to have an after
callback
#52167
Conversation
Hmm, what would the be the use case of this? |
The same as before, except I don't register the binding in a service provider, but on the attribute itself. In an application I'm working on, specifications have changed, and more parts of the app need to use the "tenancy system", which I wanted to extract and make more generic. While doing so, I wanted to write the following #[Attribute(Attribute::TARGET_PARAMETER)]
final class OnTenant
{
public function __construct(public readonly Tenant $tenant)
{
}
public static function after(self $attribute, HasTenant $hasTenant)
{
$hasTenant->onTenant($attribute->tenant);
}
}
|
@taylorotwell I don't know if I'm sure about it, but when I upgraded one of my projects to Laravel 11.17 using a package created by me (TallStackUI) I started to get this error: When I go back to Laravel 11.16 the error doesn't occur anymore. I think this PR introduced a breaking change. This was originally reported here: tallstackui/tallstackui#567 |
I'm guessing this because according to my analysis this was the only attribute-related PR in v11.17 C/C @driesvints |
This has caused an issue for me also - I use In Laravel 11.16 this wasn't an issue, but this change in Laravel 11.17 means Laravel is now trying to find this attribute. use Knuckles\Scribe\Attributes\Group;
#[Group('Feeds', <<<'DESC'
Endpoints that return currently available listings that can be listed on other sites with permission.
DESC)]
class RoomController extends Controller
{
//
} |
This pull request is a follow-up of #51934.
It allows all attributes to have an
after
callback, not justContextualAttribute
ones. As a reminder, this callback is the equivalent of$this->app->afterResolvingAttribute
, but directly on the attribute.The restriction to have it only on
ContextualAttribute
was accidental due to it being implemented late in the previous pull request.EDIT: PR reverted because of: