romanzipp / Laravel-Model-Doc

📝 Generate PHPDoc comments for Laravel Models
MIT License
22 stars 6 forks source link

Get custom date class name set with Date::use #8

Closed joelvh closed 2 years ago

joelvh commented 2 years ago

We use Date::use(\Carbon\CarbonImmutable::class) and that makes now() and casting use CarbonImmutable. It's not clear how to get the class from the Date facade, so we get it by using now().

Laravel provides this feature to customize the date class, but virtually all phpdoc generators don't realize Carbon isn't always the date class.

romanzipp commented 2 years ago

Good spot! Haven't run into a scenario where I needed to change the default date class but I'd like to add support for this. The PHP 7.4 test are failing, should it rather be get_class(now()) instead of dynamic class name access? (Haven't tried it out yet)

joelvh commented 2 years ago

@romanzipp good catch - updated it to php 7 syntax

romanzipp commented 2 years ago

Awesome, thanks!