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

Mink's use of stripos leads to some empty string behaviors in PHP 8 #823

Open
neclimdul opened this issue Feb 21, 2022 · 3 comments
Open

Comments

@neclimdul
Copy link

In PHP 8 empty strings are present in every string. This means that depending on which version of PHP you're using, assertions like assertContains and assertNotContains can behave different.

I thought this was a bug but it seems to be an intentional but fairly undocumented change in PHP8
https://3v4l.org/VGB5j
https://php.watch/versions/8.0/string-function-empty-needles

This may not be a bug, but because it will always pass (or fail) it does not seem like the intended functionality. Also personally it seems like passing an empty string to these assertions means something went wrong in the code calling the assertion and its more useful result is to fail then to treat it as passing.

@aik099
Copy link
Member

aik099 commented Feb 23, 2022

I agree that searching for an empty string looks like a bug. If test suite passes on PHP 8, then we're good for now :)

@neclimdul
Copy link
Author

Yeah I ran into this because Drupal’s test suite passed when it shouldn't and then failed when 7.x tests ran on the commit.

If you agree it looks buggy I'll get a pr together and see what it looks like.

@aik099
Copy link
Member

aik099 commented Feb 24, 2022

PR, that does what exactly?

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

No branches or pull requests

2 participants