Skip to content

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

@neclimdul

Description

@neclimdul

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions