-
Notifications
You must be signed in to change notification settings - Fork 529
Increment on non-numeric string is deprecated, use str_increment() instead #4262
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
src/Analyser/MutatingScope.php
Outdated
@@ -1733,10 +1736,18 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu | |||
foreach ($varScalars as $varValue) { | |||
if ($node instanceof Expr\PreInc) { | |||
if (!is_bool($varValue)) { | |||
++$varValue; | |||
if (function_exists('str_increment')) { | |||
$varValue = str_increment($varValue); |
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.
Only for strings though
I think there is room for improvement for PHP 8.5.x |
Awesome 👍 |
1ad1b73
to
4d86d46
Compare
This pull request has been marked as ready for review. |
if ($varValue === '') { | ||
$varValue = '1'; |
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.
neither ++$varValue
nor str_increment($varValue)
is allowed on PHP 8.5 when $varValue
is a empty string.
therefore we hardcode the value which this operation lead to when PHP < 8.5
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.
And what about non-empty strings? This PR initially handled that but does not anymore.
Thank you! |
fixes PHP 8.5 deprecations like