-
Notifications
You must be signed in to change notification settings - Fork 269
Fix PHP 8.5 deprecations of (integer)
, (long)
and (boolean)
casts
#1758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses PHP 8.5 deprecation warnings by replacing non-canonical cast syntax with modern canonical equivalents. The PR updates cast expressions from (integer)
, (boolean)
, and (double)
to their canonical forms (int)
, (bool)
, and (float)
respectively, and modernizes string function usage by replacing strpos()
checks with str_contains()
.
- Updates all cast expressions to use canonical PHP syntax
- Modernizes string containment checks using
str_contains()
- Updates rector/rector dependency and configuration to enable automated fixes
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
composer.json | Updates rector/rector dependency to ^2.1.4 |
rector.php | Modernizes rector configuration and adds RenameCastRector rule |
src/functions.php | Fixes deprecated (integer) casts to (int) |
src/Operation/*.php | Updates deprecated cast expressions in operation classes |
src/Model/*.php | Replaces deprecated casts in model classes |
src/GridFS/*.php | Updates cast expressions in GridFS components |
src/MapReduceResult.php | Fixes deprecated cast in MapReduceResult |
tests/**/*.php | Updates deprecated casts in test files |
tools/*.php | Modernizes string containment checks using str_contains() |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
$rectorConfig->rule(StaticDataProviderClassMethodRector::class); | ||
|
||
]) | ||
->withPhpSets(php74: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
php74: true
could be dropped in order to automatically upgrade the code to the PHP version defined in composer.json
, 8.1 in this case. Doing this changes over 250 files.
34e07d0
to
602fc2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these early fixes.
I think we'll abandon the 1.21 branch before the release of PHP 8.5, but there's no reason not to apply this simple changes to this branch.
(integer)
, (long)
and (boolean)
casts
My goal was to fix the following deprecations when using this library on PHP 8.5(-rc):
In order to do this, I updated
rector/rector
to^2.1.4
so that I could make use of theRenameCastRector
-rule. In the meantime, I also modernized the rector configuration.I opted to fix this on the v1.21 branch, I could rebase this on any other branch if deemed required.