Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,11 @@ static function (Node $node, Scope $scope) use ($arrowScope, &$arrowFunctionImpu

foreach ($varScalars as $varValue) {
if ($node instanceof Expr\PreInc) {
if (!is_bool($varValue)) {
// until PHP 8.5 it was valid to increment an empty string.
// see https://github.com/php/php-src/issues/19597
if ($varValue === '') {
$varValue = '1';
Comment on lines +1739 to +1740
Copy link
Contributor Author

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

Copy link
Member

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.

} elseif (!is_bool($varValue)) {
++$varValue;
}
} elseif (is_numeric($varValue)) {
Expand Down
Loading