laravel-ide-helper
laravel-ide-helper copied to clipboard
Relation method with union return type
Versions:
- ide-helper Version: 2.12.3
- Laravel Version: 8.83.23
- PHP Version: 8.0.21
Description:
Relation methods that have a union return type will not be added as @property-read doc blocs.
User.php
// ...
public function sentMessages(): HasMany|MessageQueryBuilder
{
return $this->messages()->sent();
}
// ...
Message.php
// ...
public function newEloquentBuilder($query): MessageQueryBuilder
{
return new MessageQueryBuilder($query);
}
// ...
MessageQueryBuilder.php
// ...
public function sent(): self
{
return $this->whereNotNull('sent_at');
}
// ...
Steps To Reproduce:
- See code example above
- Create a model with it's own
EloquentQueryBuilder, This isMessageQueryBuilderfor theMessagemodel in my example - Use this builder for a union return type on a relation on another model that has a relation with
Message. In my example this is theUsermodel. - Run
php artisan ide-helper:models -W -r - The
$sentMessagesproperty is not added to the docblock
The order of the union return type does not matter: HasMany|MessageQueryBuilder as well als MessageQueryBuilder|HasMany does not work.