hekmatinasser / verta

تبدیل تاریخ میلادی به شمسی برای لاراول و کار با تاریخ جلالی و اعتبارسنجی تاریخ

Home Page:https://hekmatinasser.github.io/verta/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php 8.1 DateTime's method return types

mziraki opened this issue · comments

php 8.1 DateTime class method signatures has been changed:
https://www.php.net/manual/en/class.datetime
there are now strict return types for DateTime methods.

warning examples:
Return type of Hekmatinasser\Verta\Traits\Date::setDate($year, $month, $day) should either be compatible with DateTime::setDate(int $year, int $month, int $day): DateTime, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/hekmatinasser/verta/src/Traits/Accessor.php on line 245

Return type of Hekmatinasser\Verta\Traits\Date::format($format) should either be compatible with DateTime::format(string $format): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/hekmatinasser/verta/src/Traits/Formatting.php on line 328

fix bug new version

@hekmatinasser
issue still exists in v2.0.2

Return type of Hekmatinasser\Verta\Traits\Date::setDate($year, $month, $day) should either be compatible with DateTime::setDate(int $year, int $month, int $day): DateTime, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/hekmatinasser/verta/src/Traits/Accessor.php on line 245

php 8.1 DateTime return types are not compatible with older versions of PHP, in general there are lots of breaking changes in php 8.1, at some point you must drop support for earlier versions of php or like some packages create 2 separate branches for php < 8.1 and >= 8.1

setDate function replace with setDateJalali

return type not compatible with DateTime php ,

@hekmatinasser
hi, thanks for the fix but:

Return type of Hekmatinasser\Verta\Traits\Date::format($format) should either be compatible with DateTime::format(string $format): string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /vendor/hekmatinasser/verta/src/Traits/Formatting.php on line 328

you reverted back the format method signature and caused the warning above.

one more thing, plz release new versions of package with new versioning, packagist does not update automatically already created tag, and it's not a good practice overall.

thanks.

@hekmatinasser
PR #119 for this issue & few more improvements