Skip to content

Argument of an invalid type list<string>|false supplied for foreach, only iterables are supported. in IsEqualIgnoringWhiteSpace:66 #98

@pscheit

Description

@pscheit
    private function _stripSpace(string $string): string
    {
        $parts = preg_split("/[\r\n\t ]+/", $string);
        foreach ($parts as $i => $part) {
            $parts[$i] = trim($part, " \r\n\t");
        }

        return trim(implode(' ', $parts), " \r\n\t");
    }

This error is detected by phpstan and was written to the baseline in #88

 ------ ----------------------------------------------------------------------------------------------------
  Line   hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php
 ------ ----------------------------------------------------------------------------------------------------
  66     Argument of an invalid type list<string>|false supplied for foreach, only iterables are supported.
         🪪  foreach.nonIterable
         ✏️  hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php
  67     Cannot access offset int<0, max> on non-empty-array<int<0, max>, string>|false.
         🪪  offsetAccess.nonOffsetAccessible
         ✏️  hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php
 ------ ----------------------------------------------------------------------------------------------------

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