Skip to content

Strings::indexOf() ends with ValueError for empty $haystack for negative $nth #271

Description

@KacerCZ

Version: 3.2.5
PHP: 8.0.12

Bug Description

Calling method Strings::indexOf() with parameter $haystack being empty string and negative parameter $nth will end with ValueError "strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)".

Steps To Reproduce

Execute following code

$position = \Nette\Utils\Strings::indexOf( '', 'a', -1 );
var_dump( $position );

ValueError is thrown

Expected Behavior

Variable $position contains NULL.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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