Mink's use of stripos leads to some empty string behaviors in PHP 8
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.6k
- Forks
- 286
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating Mink's use of stripos in the implementations of assertContains and assertNotContains, then compare the behavior under PHP 8 with earlier PHP versions using the linked examples. Clarify the intended empty-string behavior and add or update regression coverage so the assertions have consistent, documented results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100