Skip to content

[dead-code] Skip substr casting removal on PHP 7.x, as can return false|string#7449

Merged
TomasVotruba merged 2 commits intomainfrom
tv-string-cast
Oct 8, 2025
Merged

[dead-code] Skip substr casting removal on PHP 7.x, as can return false|string#7449
TomasVotruba merged 2 commits intomainfrom
tv-string-cast

Conversation

@TomasVotruba
Copy link
Member

No description provided.

return false;
}

return ! $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersion::PHP_80);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPStan already detect it clearly when run on php 7.x

see https://phpstan.org/r/853f59a6-22ad-48ac-af93-66606b569613

on PHP 7.2 - 7.4 tab.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not on PHP 8.0+. This also allow to add our test with PHP 7.4 version.

*/
$subClassName = (string) substr(

$subClassName = substr(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cast is needed here as downgrade rule is not yet created.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed with incorrect input instead. This structure is clearly wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will create separate PR target your branch for different logic to handle this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 👍 We'll need to understand what values are going in any why it returns false.
It should be fixed to return always string instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #7450

@TomasVotruba TomasVotruba merged commit 9a95b6b into main Oct 8, 2025
50 checks passed
@TomasVotruba TomasVotruba deleted the tv-string-cast branch October 8, 2025 07:20
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants