#Is it possible to get proper Intellisense for Event::dispatch(...) parameters?

20 messages · Page 1 of 1 (latest)

shy oxide
#

Classes that use the Dispatchable trait can be dispatched with a set of parameters that will be passed to their constructor function. But there's no Intellisense for this in PhpStorm at least. It feels like there must be a way to explicitly construct the event or something to always have proper intellisense?

#

Is it possible to get proper Intellisense for Event::dispatch(...) parameters?

upbeat glade
#

event(new MyEvent("some argument"))?

#

just construct the object and then send it out

shy oxide
#

event() is a global function?

upbeat glade
#

yes

shy oxide
#

yes this looks like it does it!

#

Thanks @upbeat glade !

upbeat glade
#

np

shy oxide
#

"Evan" do you specialize in "Event" based answers?

upbeat glade
#

no huhh

#

I just happen to know stuff about laravel

shy oxide
#

And be named Evan

#

Evant

upbeat glade
#

that is the wildest stretch I've ever seen

shy oxide
#

I specialize in answers related to lost connectivity

#

...

#

But no this was great, thanks so much

swift birch
#

There is, you need to add phpdoc style documentation within your event before the class starts. You can define something like

/*
@method void dispatch(type $variable)
*/

When calling MyEvent::dispatch in the editor intellisense will kick in. I do that for all my job classes.

prisma perch