laravel-ide-helper: Model when use Carbon, auto generate docblock not pass by phpstan.

this is my User Model diff after run php artisan ide-helper:models -WR

image

it will remove \Carbon\Carbon in docblock, would lead to result by phpstan: (https://github.com/nunomaduro/larastan)

 ------ -----------------------------------------------------------------------
  Line   User.php
 ------ -----------------------------------------------------------------------
  385    Property App\User::$vip_end (Illuminate\Support\Carbon|null) does not
         accept Carbon\Carbon.
  388    Property App\User::$vip_end (Illuminate\Support\Carbon|null) does not
         accept Carbon\Carbon.
  394    Property App\User::$vip_end (Illuminate\Support\Carbon|null) does not
         accept Carbon\Carbon.
 ------ -----------------------------------------------------------------------

Is there something I’m doing wrong? Please advise, thank you very much!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I am sorry, but I fail to see how this has been solved. I am still experiencing this exact issue, where the the generated docblocks state Illuminate\Support\Carbon|null and not Carbon\Carbon. I am on nesbot/carbon 2.40.1 and barryvdh/laravel-ide-helper 2.8.1.

Maybe the helper should rather generate \Carbon\CarbonInterface which is the wider requirement while Carbon, CarbonImmutable, Illuminate\Carbon are possible specific implementations.