Closed faytekin closed 1 year ago
Is it always on Collection
s?
yes, it is always on Collection
Same issue. However, I found out, that use_generics_annotations
set to true
will produce duplicates like this
I ran it three times with this setting and it always seem to duplicate the @property-read
from HasApiTokens
and Notifiable
in my default User model. Switching the generics annotations off fixes this issue (requires deleting the previous model docBlock)
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
+* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
+* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
+* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
+* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
Related block:
Both mentioned traits indeed extend from Relation
, so maybe it just can't match the correct type for collections of those relations.
+1 on this issue
FYI I needed to fix this because it caused my CI to fail every time. How I fixed is by changing the command to php artisan ide-helper:models --no-interaction --write --reset
. The --reset
flag resets the lookup and re-populates the models.
+1, having the same issue
+1 on this issue
I acknowledge this seems buggy, so we definitely appreciate if someone steps up and looks into fixing this.
Btw, for those affected: can you use --reset
?
(I realized I'm not affected by this bug, because my pipeline uses ide-helper:models --write --reset
)
I acknowledge this seems buggy, so we definitely appreciate if someone steps up and looks into fixing this.
Btw, for those affected: can you use
--reset
?(I realized I'm not affected by this bug, because my pipeline uses
ide-helper:models --write --reset
)
I can't use --reset
because I've defined some model getters using Laravel's Attribute, and when I add --reset
, it deletes the manually added properties.
+1 on this, using the reset switch helps but it's quite annoying
Not work with generic types?
In latest version phpDocumentor/ReflectionDocBlock generic type parsed correctly, but this package use fork barryvdh/ReflectionDocBlock and this fork can't parse generic type in DocBlock correcly. So need update fork package, maybe).
https://github.com/barryvdh/laravel-ide-helper/blob/master/src/Console/ModelsCommand.php#L939 This line ($tag->getVariableName()) - get empty string for generic type.
I create PR to fork repository
@barryvdh can you help please?)
Running into this issue too:
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Laravel\Sanctum\PersonalAccessToken> $tokens
*/
class User extends Authenticatable {
}
Same problem here. Just a bit of knowledge since it's not mentioned in this thread. In my case, it only happens if there was something "irregular" with the naming convention.
For example the model is User but the relation is called admins. Or if it's two words like payment_logs. Or if it's 1 word, but you're not using standard column naming like user_id for a foreign key on users
Hello @mfn,
The bug located here: https://github.com/barryvdh/ReflectionDocBlock/pull/14, has been successfully corrected with this pull request. If possible, I kindly request you to release a new version incorporating these fixes.
Still encountered this error even though I upgraded to dev:master.
Still encountered this error even though I upgraded to dev:master.
The issue was resolved in the barryvdh/ReflectionDocBlock
package to which this package is linked. If this package updates its dependencies and releases a new version, the problem will be solved.
+1 can we get that dependency updated?
Tagged
https://github.com/barryvdh/ReflectionDocBlock/compare/v2.1.0...v2.1.1 fixed here if running composer update
command
Versions:
Description:
After updating to the latest version, every time I run the
php artisan ide-helper:models --write
command, theproperty-read
in the model is added again, causing duplicate values in the model.The
activeQrMenus
andadmins
values here are repeating.There are many models in the project, but this error only occurs in 5 models.