Fix PHP 8.5 deprecations: roman_year nullable + (double)→(float) cast#2
Open
luca9692 wants to merge 2 commits into
Open
Fix PHP 8.5 deprecations: roman_year nullable + (double)→(float) cast#2luca9692 wants to merge 2 commits into
luca9692 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses PHP 8.5 deprecation notices by updating two helper functions in the support library to use canonical/explicit typing and casting syntax.
Changes:
- Update
roman_year()to explicitly accept nullable input (?int $year = null) to avoid deprecation for non-nullable typed params withnulldefaults. - Replace deprecated
(double)$valuecast with canonical(float)$valueinisIntegerFloatingPoint().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/datetime.php | Makes roman_year() parameter explicitly nullable to avoid PHP 8.4+ deprecation notices. |
| src/validation.php | Switches (double) to (float) cast in integer-floating-point validation logic for PHP 8.5 compatibility. |
Comments suppressed due to low confidence (1)
src/datetime.php:216
- Now that the parameter is typed as
?int, theis_numeric($year)check is effectively just a null check (ints are always numeric). Using$year === null(or renaming the condition/comment) would make the intent clearer and avoid implying non-int inputs are expected.
function roman_year(?int $year = null): string
{
if (!is_numeric($year)) {
$year = (int)date('Y');
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+130
to
131
| && ((int)((float)$value) == $value || (int)$value == $value || strpos(strtoupper((string)$value), | ||
| 'E') === false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two PHP 8.5 deprecation fixes:
src/datetime.php:212—roman_year(int $year = null)→roman_year(?int $year = null)(PHP 8.4+ requires explicit nullable on non-nullable type with defaultnull)src/validation.php:130—(double)$valuecast →(float)$value(PHP 8.5 deprecates non-canonical(double)cast)Why
Used by gescat-laravel on PHP 8.5 — these surface as runtime
Deprecatednotices and will become fatal in PHP 8.6+.Compatibility
Both changes are semantic no-ops (same behavior, explicit syntax). No breaking changes.
Patches