Loading model 'Cars\ItemsTrait'
Class Cars\ItemsTrait does not exist
trait code
<?php
namespace Cars;
trait ItemsTrait {
...
using in models
<?php
namespace Cars;
class Disc extends \MyEloquent {
use ItemsTrait;
...
Does it crash or just skip the trait? Traits are probably detected in the model dir but can't be analyzed, because they aren't real classes.
I've updated the message.
just skipped
may i ask: i.e. "notifyNow" is unknown:
$order->user->notifyNow(new ReservationCanceled($order));
but the parser should be able to see use Notifiable; inside the model and "could" add:
* @method notifyNow(Notification $notification, array $channels)
* @method notify(Notification $notification)
* @method routeNotificationFor($driver, Notification $notification)
because phpstorm still seems to have a problem with traits inside traits when it comes to code-completion,
this would be a nice help....
because phpstorm still seems to have a problem with traits inside traits when it comes to code-completion,
Never heard of this. Do you have a bug reference?
$order->user
Can you please share relevant parts from the Order model? phpdoc and relation definition.
IMHO this should work. Having the Notifiable on a model certainly correctly autocompletes ->notifyNow(), and all the others you mentioned, for me:

This using the latest PhpStorm (EAP, but pretty sure this worked regularly before already)
And in fact I would argue, this works unrelated to the ide-helper; this is just regular PHP.
@mfn sure, i have found this: https://youtrack.jetbrains.com/issue/WI-30885 - and because autocomplete (in latest EAP) is not working for me, i was sure that´s because of this old bug. but when it´s working for u, it´s great 😁 which version are u using ???
@mfn so i am doing something wrong accessing the user... maybe u can identify my problem within that screenshot:

but also not working with:

seems like something is buggy with my phpstorm 😢
@mfn can u please test something for me ?
when u go into the file: \vendor\laravel\framework\src\Illuminate\Notifications\Notifiable.php
are u able to show the usage of RoutesNotifications ??

i did a "invalidate cache / restart" and ....

okay... wow... shit... 😖
@mfn pardon, if i may ask: does this work for u without any phpdoc:

because for me it´s only working with /** @var kuchen_order $order */ and i am so confused right now, that i don´t know if that is "okay" or if phpstorm should be able to handle that, too - without any extras.
thanks!!
In your last case, without /** … */ I would assume you don't even get ->user autocomplete from $order because the IDE doesn't know that.
Interestingly, your code shows an anti-pattern:
mode::where()->with()->get()->first();
->get()will fetch _all_ matching results->first() will return the first from the _in memory collection_ ⬅️ not so good ❗ More idiomatic would be to simply do:
mode::where()->with()->first();
because then internally it will use limit.
Of course if you know that whereKoId() will only match one entry all the time, it probably does not matter.
However: when you use the second approach, the IDE _does know_ you will get back a post 😄
The issue is that the first call after ->with() is on the query builder related classes which have proper phpdoc that they return static, i.e. a version of the model itself:

If we look at the same for ->first() of the collection class, it's just "mixed" and that's why the IDE "looses" the information. From \Illuminate\Support\Collection::first:

Neither PhpStorm nor Laravel have much in place here to support Generics, so this is a fix for another time (PhpStorm will receive support for this in the next major version AFAIK).
Something else: your custom phpdoc it not _quite right_. Technically first() always returns your "fact or null", so it would be rather:
/** @var Model|null $yourModel */
HTH!
wow, many many thanks for this great explanation! I learned something 😊👍
Most helpful comment
In your last case, without
/** … */I would assume you don't even get->userautocomplete from$orderbecause the IDE doesn't know that.Interestingly, your code shows an anti-pattern:
->get()will fetch _all_ matching results->first()will return the first from the _in memory collection_ ⬅️ not so good ❗More idiomatic would be to simply do:
because then internally it will use
limit.Of course if you know that
whereKoId()will only match one entry all the time, it probably does not matter.However: when you use the second approach, the IDE _does know_ you will get back a post 😄
The issue is that the first call after

->with()is on the query builder related classes which have proper phpdoc that they returnstatic, i.e. a version of the model itself:If we look at the same for

->first()of the collection class, it's just "mixed" and that's why the IDE "looses" the information. From\Illuminate\Support\Collection::first:Neither PhpStorm nor Laravel have much in place here to support Generics, so this is a fix for another time (PhpStorm will receive support for this in the next major version AFAIK).
Something else: your custom phpdoc it not _quite right_. Technically
first()always returns your "fact or null", so it would be rather:HTH!