Make IDE aware of Carbon macros

The Carbon library allows creating custom methods:

Carbon::macro(
    'isDayOff',
    static fn (WorkingWeek $workingWeek) => $workingWeek->isWeekend(self::this())
);

Is there a way to make PhpStorm aware of them?

0
3 comments

Here's a request for this to be implemented in Laravel IDE Helper: https://github.com/barryvdh/laravel-ide-helper/issues/1162

In general, it should be possible to create helpers manually, but I am not sure if it's the way you want to go.

0

I use Symfony and I don't fully grasp what a Laravel IDE Helper is (project README pretty much assumes you already know what it is). I get it's some kind of stub?

I was hoping for some obscure phpdoc annotation or PhpStorm Meta. Since it's unlikely that our project needs a lot of macros, I don't think it's worth to add stubs or dependencies. Thank you for your suggestion anyway.

0

Please never mind; somehow I was under impression that Carbon is a Laravel thing, but it's not.
I've extracted this as a feature request: https://youtrack.jetbrains.com/issue/WI-75038/Carbon-macros-support

Unfortunately, using the advanced metadata here isn't possible because you can't add methods using it.

0

Please sign in to leave a comment.