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

[CodeQuality] Skip fopen() or die() on LogicalToBooleanRector on assign #6635

Merged
merged 5 commits into from
Dec 30, 2024

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Dec 30, 2024

Hi @lvanstrijland

I finally found a real use case when or should be kept, on fopen() or die() when assigned:

        $file = fopen($fileLocation, 'w') or die('Unable to open file!');
        fwrite($file, "John Doe\nJane Doe\n");
        fclose($file);

with ||, $file become bool instead of resource when file opened.

Ref rectorphp/rector#7604

@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @lvanstrijland

@samsonasik samsonasik changed the title [CodeQuality] Skip fopen() or die() on LogicalToBooleanRector [CodeQuality] Skip fopen() or die() on LogicalToBooleanRector on assign Dec 30, 2024
@samsonasik
Copy link
Member Author

I added assign check to ensure this patch on this specific condition :)

ad2defd

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

@samsonasik samsonasik merged commit 17d266f into main Dec 30, 2024
41 checks passed
@samsonasik samsonasik deleted the skip-fopen branch December 30, 2024 11:19
@lvanstrijland
Copy link

@samsonasik ah yeah this a much better example now that I read my post from 2022 haha.

This use case is a better example for the difference between or and ||.

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants