-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Generate cleaner model mixin classes #1268
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 110% sure about the effect but happy to give it a try 😄
We're using it atm and works like charm :) |
@mfn @georgeboot I added the write_mixin feature initially, and unfortunately this breaks auto-complete on builder methods such as To fix this, you need to add extends \Eloquent back or replace it with @mixin \Eloquent
Or to add the @mixin \Eloquent this needs to be modified.
|
Are you sure about that? A static analyser should combine the data from the mixing with the data inferred from the class itself (hence the name mixin). Practically this means that this package should only min-in attributes, relations and other magic methods into the existing definition, which should already contain |
@georgeboot I am pretty sure.
The package already mixes in |
Ah now I see what you mean. I personally always use Maybe related: didn't Laravel 9 change things related to the multiple types of query builders and their relation to model classes? |
Not that I am aware of, they added some dummy interfaces for the Builder and QueryBuilder classes to assist with code completion, but those only come into play if you do IMHO this introduced a breaking change, and it needs to be fixed. |
* Generate cleaner model mixin classes * Fix test
Summary
1. removed
@mixin
from mixin itself when using mixin modeThe generated mixin class, contained a
@mixin
phpdoc to itself. This breaks phpstan as it's a recursive reference.2. don't add
extends
andimplements
to generated class when using mixin modeIf you are using mixin mode, the mixin only needs to contain the properties and methods. The mixin does not need to extend the models classes, as the model already does that and the helper annotations are mixed in.
Type of change
Checklist
composer fix-style