Skip to content

Cannot call method matches() on Hamcrest\Matcher|null in SeriesMatchingOnce:82 #96

@pscheit

Description

@pscheit
    private function _isMatched($item): bool
    {
        $this->_nextMatchKey = array_shift($this->_keys);
        $nextMatcher = array_shift($this->_elementMatchers);

        if (!$nextMatcher->matches($item)) {
            $this->_describeMismatch($nextMatcher, $item);

            return false;
        }

        return true;
    }

$this->_elementMatchers might have 0 elements when this method is called.

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

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------
  Line   hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.php
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------
  82     Cannot call method matches() on Hamcrest\Matcher|null.
         🪪  method.nonObject
         ✏️  hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.php
  83     Parameter #1 $matcher of method Hamcrest\Arrays\SeriesMatchingOnce::_describeMismatch() expects Hamcrest\Matcher, Hamcrest\Matcher|null given.
         🪪  argument.type
         ✏️  hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.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