-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New format computed property accessor not recognised #1315
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
Comments
We're open to PRs |
are there any progress/PR on this? |
If you make the function public, and provide a return type like so: |
That's true, but then it's no longer an accessor/mutator, which is the topic of this issue. |
What I mean is, if you do this: public function fullName(): Attribute
{
return Attribute::get(fn(): string => "$this->first_name $this->last_name");
} It will generate a That's all you want, isn't it? |
does it matter though using |
The Laravel docs makes them |
The PR was merged #1339 but there has been no release after that. You can try the |
True. That's what I do nowadays. That said, Laravel supports accessors without typehinting whereas IDE Helper doesn't. Hence my PR #1411. |
Any idea when this will be released on packagist? I'd prefer not to directly require |
We need to typehint mutator function return to let IDE Helper package know the type of the attribute. barryvdh/laravel-ide-helper#1315 (comment) Then PHPStan will not throw error on undefined profile_photo_url property.
I have given up on waiting for this and have stopped using this package in favour of the Laravel IDEA plugin. |
A new version was released an hour ago; https://github.com/barryvdh/laravel-ide-helper/releases/tag/v2.14.0 |
We need to typehint mutator function return to let IDE Helper package know the type of the attribute. barryvdh/laravel-ide-helper#1315 (comment) Then PHPStan will not throw error on undefined profile_photo_url property.
We need to typehint mutator function return to let IDE Helper package know the type of the attribute. barryvdh/laravel-ide-helper#1315 (comment) Then PHPStan will not throw error on undefined profile_photo_url property.
Versions:
Description:
PR #1289 added support for the new attribute mutator/accessor format, but calculated properties/attributes aren't recognised yet.
Steps To Reproduce:
This example calculated property results in
* @property-read string $full_name
:The following example is not recognised and does not add the same
@property
.It should also result in (only)$fullName
instead of$full_name
.The latter should also be
protected
instead ofpublic
of course, but that's a separate issue (#1293).The text was updated successfully, but these errors were encountered: