You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating Eloquent annotations on a model that uses a factory, the tool generates an incorrect $use_factory property with the following annotation: @property-read \App\Models\TFactory|null $use_factory
Then, when running a static analysis tool (like Larastan), it fails: PHPDoc tag @property-read for property App\Models\User::$use_factory contains unknown class App\Models\User\TFactory.
The model is defined as follows:
class User extends Model
{
/** @use HasFactory<\Database\Factories\UserFactory>*/use HasFactory;
...
}
Steps To Reproduce:
Create a model with a factory
Apply the HasFactory trait to the model, and the corresponding @use
Generate the model's annotations
Run a static analysis tool (e.g.: Larastan)
The text was updated successfully, but these errors were encountered:
or simply \Illuminate\Database\Eloquent\Factories\Factory.
or through the new #UseFactory attribute in Laravel 11.39
By stepping through the models code, it seems the getReturnTypeFromDocBlock method fails to find the type parsing the docblock, and defaults to the current namespace.
Would it be possible to add this method to the blacklisted methods in getPropertiesFromMethods untill we potentially can evaluate the generics?
I think the generics parsing is broken as it expects the @template tag to be present on the method docblock, but it is infact present in the traits docblock instead.
@LauJosefsen we don't need to evalutate the generic. This method should be skipped and not added as an attribute, it is a protected static method used internally by HasFactory, it is not an attribute.
Versions:
Description:
When generating Eloquent annotations on a model that uses a factory, the tool generates an incorrect
$use_factory
property with the following annotation:@property-read \App\Models\TFactory|null $use_factory
Then, when running a static analysis tool (like Larastan), it fails:
PHPDoc tag @property-read for property App\Models\User::$use_factory contains unknown class App\Models\User\TFactory.
The model is defined as follows:
Steps To Reproduce:
HasFactory
trait to the model, and the corresponding@use
The text was updated successfully, but these errors were encountered: