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

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
- Fix #1004 Auto-generate PHPDoc for Illuminate\Support\Carbon from Carbon\Carbon — committed to kylekatarnls/laravel-ide-helper by kylekatarnls 4 years ago
- Fix #1004 Auto-generate PHPDoc for Illuminate\Support\Carbon from Carbon\Carbon — committed to kylekatarnls/laravel-ide-helper by kylekatarnls 4 years ago
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 notCarbon\Carbon
. I am onnesbot/carbon 2.40.1
andbarryvdh/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.