-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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] feat: improve Factory generics, add generics to HasFactory #52005
Conversation
Because I know, that PHP-CS-Fixer and Pint can have problems with formatting / ordering traits with comments in between, I wanted to ask, if the following is possible too: /** @use HasFactory<UserFactory> */
class User extends Authenticatable
{
use HasFactory;
} Great work!!! ❤️ |
@Jubeki, no it looks like placing
For what it's worth though, I've never had ordering issues with Pint (uses PHP-CS-Fixer) so that could be fixed. |
@calebdw I checked again, it seems I remembered incorrectly. It was a spacing issue and not an ordering issue: laravel/pint#278 |
Thanks @taylorotwell! |
- With the latest larastan and laravel changes such as laravel/framework#52005 we have a lot more errors. This commit generates a new baseline.
This does not work for me: /** @use HasFactory<UserFactory> */
class User extends Authenticatable
{
use HasFactory;
} But this works as expected: class User extends Authenticatable
{
/** @use HasFactory<UserFactory> */
use HasFactory;
} Am I missing something? |
I always place my |
Hello!
This PR updates the Factory generics to make the types more accurate. I also added generics to the
HasFactory
trait, as well as allow the user to define a static$factory
property in lieu of overriding thenewFactory
method which helps slim down models. Of course the method can still be overridden if desired.Thanks!