Skip to content
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

Replace substr usage with Compatibility::substr() #604

Open
JoosuaKoskinen opened this issue Aug 4, 2021 · 0 comments
Open

Replace substr usage with Compatibility::substr() #604

JoosuaKoskinen opened this issue Aug 4, 2021 · 0 comments
Labels
bug codebase Refactoring and overall codebase health-related topics.

Comments

@JoosuaKoskinen
Copy link
Contributor

Describe the bug

Up to PHP 8.0, substr used to return empty string on failure. Since PHP 8.0, it returns false. We have a function (coming in #602) which can handle both of the 2 different cases.

Currently we don't check our substr for failures at all. Eg:
$diff_txt = file_get_contents(substr($screenshot, 0, -4) . '.diff.txt');
will evaluate to:
$diff_txt = file_get_contents('false.diff.txt');
on PHP 8.0 failure and to
$diff_txt = file_get_contents('.diff.txt');
on failure on versions before 8.0.

The compatibility function forces us to check if we had a failure or not.

The error was found by PHPStan but it doesn't complain about it anymore as it thinks we want to have false.diff.txt etc.

@JoosuaKoskinen JoosuaKoskinen added the codebase Refactoring and overall codebase health-related topics. label Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug codebase Refactoring and overall codebase health-related topics.
Projects
None yet
Development

No branches or pull requests

1 participant