@param string $what     The name of the expected resource.
@param string $expected The expected return value type.
@param mixed  $actual   The actual return value.

@return \UnexpectedValueException
974238
private function invalidReturnValue(string $what, string $expected, $actual) : \UnexpectedValueException
    {
        $message = 'Invalid return value from %s: expected %s, got %s.';
        $actual  = is_object($actual) ? get_class($actual) : gettype($actual);

        return new \UnexpectedValueException(sprintf($message, $what, $expected, $actual));
    }
943691
public static function assertArrayHasKeyValuePair(
        $expectedKey, $expectedValue, $actual, $message='') {
          Assert::assertThat(
            $actual,
            new ArrayHasKeyValuePair($expectedKey, $expectedValue),
            $message);
    }
905531
public function compareString($expected,$actual)
	{
		$expected.="\0";
		$actual.="\0";
		$expectedLength=$this->strlen($expected);
		$actualLength=$this->strlen($actual);
		$diff=$expectedLength-$actualLength;
		for($i=0;$i<$actualLength;$i++)
			$diff|=(ord($actual[$i])^ord($expected[$i%$expectedLength]));
		return $diff===0;
	}
378758
public function notStrictEqual($actual, $expected, $message = '')
    {
        $this->assertion->setActual($actual);

        return $this->assertion->to->not->equal($expected, $message);
    }
1249789
public function evaluate($actual)
    {
        $matcherResult = $this->matcher->match($actual);
        $expected = $this->negated ? false : true;

        $result = $matcherResult === $expected;

        return new Result($actual, $this->negated, $this->matcher, $result);
    }
1006596
public static function invalidType(string $expected, $parameter) : InvalidArgumentException
    {
        $message = sprintf(
            'Invalid Argument type: "%s" expected, "%s" given',
            $expected,
            is_object($parameter) ? get_class($parameter) : gettype($parameter)
        );

        return new self($message);
    }
299006
public static function invalidEntityType($expected, $actual)
    {
        return new self(sprintf(
            'Entity must be an instance of "%s"; got "%s".',
            $expected,
            is_object($actual) ? get_class($actual) : gettype($actual)
        ));
    }
1028423
public static void assertEquals(Object expected, Object actual) {
        assertEquals(expected, actual, "Expected value " + expected + " but got " + actual);
    }
365756
public static function match($actual, $expected, $precision = 2)
    {
        static::_buildDescription($actual, $expected, $precision);

        if (!is_numeric($actual) || !is_numeric($expected)) {
            return false;
        }
        return abs($expected - $actual) < (pow(10, -$precision) / 2);
    }
457139
public function expect($type, $value = null)
    {
        if (!$this->match($type, $value)) {
            $msg = "Unexpected token {$this->current()->type} '{$this->current()->value}', expected {$type}";
            throw new \UnexpectedValueException($msg);
        }
        $current = $this->current();
        $this->next();
        return $current;
    }
844267
public function compareString($expected, $actual)
    {
        $expected .= "\0";
        $actual .= "\0";
        $expectedLength = StringHelper::byteLength($expected);
        $actualLength = StringHelper::byteLength($actual);
        $diff = $expectedLength - $actualLength;
        for ($i = 0; $i < $actualLength; $i++) {
            $diff |= (ord($actual[$i]) ^ ord($expected[$i % $expectedLength]));
        }
        return $diff === 0;
    }
816974
public static function match($actual, $expected = null)
    {
        $a = static::actual($actual);
        static::_buildDescription($a, $expected);

        return $a === $expected;
    }
779851
protected function __isValueMatchAsExpected($value, $expectedString)
    {
        $match = false;

        if ($expectedString === null)
            ## undefined expected values must not be NULL
            ## except when it write down on docblock "@return void"
            return $value === null;

        $valueType = strtolower(gettype($value));

        /**
         * @return string|null|object|\Stdclass|void
         */
        $expectedString = explode('|', $expectedString);
        foreach($expectedString as $ext) {
            $ext = strtolower(trim($ext));
            if ($ext == '') continue;

            if ($value === VOID && $ext == 'void')
                $match = true;
            elseif ($valueType === $ext && $value != null)
                $match = true;
            elseif ($valueType === 'object') {
                if (is_a($value, $ext))
                    $match = true;
            }

            if ($match) break;
        }

        return $match;
    }
578893
public function readValue($token = null, $expectedType = null)
    {
        if ($token === null) {
            $token = $this->tokenizer->getNextToken();
        }

        if ($token === false) {
            if ($expectedType !== null) {
                throw new Type\PdfTypeException('Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE);
            }
            return false;
        }

        switch ($token) {
            case '(':
                $this->ensureExpectedType($token, $expectedType);
                return PdfString::parse($this->streamReader);

            case '<':
                if ($this->streamReader->getByte() === '<') {
                    $this->ensureExpectedType('<<', $expectedType);
                    $this->streamReader->addOffset(1);
                    return PdfDictionary::parse($this->tokenizer, $this->streamReader, $this);
                }

                $this->ensureExpectedType($token, $expectedType);
                return PdfHexString::parse($this->streamReader);

            case '/':
                $this->ensureExpectedType($token, $expectedType);
                return PdfName::parse($this->tokenizer, $this->streamReader);

            case '[':
                $this->ensureExpectedType($token, $expectedType);
                return PdfArray::parse($this->tokenizer, $this);

            default:
                if (\is_numeric($token)) {
                    if (($token2 = $this->tokenizer->getNextToken()) !== false) {
                        if (\is_numeric($token2)) {
                            if (($token3 = $this->tokenizer->getNextToken()) !== false) {
                                switch ($token3) {
                                    case 'obj':
                                        if ($expectedType !== null && $expectedType !== PdfIndirectObject::class) {
                                            throw new Type\PdfTypeException(
                                                'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                                            );
                                        }

                                        return PdfIndirectObject::parse(
                                            $token,
                                            $token2,
                                            $this,
                                            $this->tokenizer,
                                            $this->streamReader
                                        );
                                    case 'R':
                                        if ($expectedType !== null &&
                                            $expectedType !== PdfIndirectObjectReference::class
                                        ) {
                                            throw new Type\PdfTypeException(
                                                'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                                            );
                                        }

                                        return PdfIndirectObjectReference::create($token, $token2);
                                }

                                $this->tokenizer->pushStack($token3);
                            }
                        }

                        $this->tokenizer->pushStack($token2);
                    }

                    if ($expectedType !== null && $expectedType !== PdfNumeric::class) {
                        throw new Type\PdfTypeException(
                            'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                        );
                    }
                    return PdfNumeric::create($token);
                }

                if ($token === 'true' || $token === 'false') {
                    $this->ensureExpectedType($token, $expectedType);
                    return PdfBoolean::create($token === 'true');
                }

                if ($token === 'null') {
                    $this->ensureExpectedType($token, $expectedType);
                    return new PdfNull();
                }

                if ($expectedType !== null && $expectedType !== PdfToken::class) {
                    throw new Type\PdfTypeException(
                        'Got unexpected token type.', Type\PdfTypeException::INVALID_DATA_TYPE
                    );
                }

                $v = new PdfToken();
                $v->value = $token;

                return $v;
        }
    }
595041
public static function invalidAssociation(ClassMetadata $targetClass, AssociationMetadata $association, $actualValue)
    {
        $expectedType = $targetClass->getClassName();

        return new self(sprintf(
            'Expected value of type "%s" for association field "%s#$%s", got "%s" instead.',
            $expectedType,
            $association->getSourceEntity(),
            $association->getName(),
            is_object($actualValue) ? get_class($actualValue) : gettype($actualValue)
        ));
    }
52471
public static function invalidAssociation(ClassMetadata $targetClass, $assoc, $actualValue)
    {
        $expectedType = 'Doctrine\Common\Collections\Collection|array';

        if (($assoc['type'] & ClassMetadata::TO_ONE) > 0) {
            $expectedType = $targetClass->getName();
        }

        return new self(sprintf(
            'Expected value of type "%s" for association field "%s#$%s", got "%s" instead.',
            $expectedType,
            $assoc['sourceEntity'],
            $assoc['fieldName'],
            is_object($actualValue) ? get_class($actualValue) : gettype($actualValue)
        ));
    }
481250
private function checkDefaultType(\Closure $isCorrectType, string $expectedType)
    {
        if (!$isCorrectType()) {
            throw new \LogicException(
                    'Default value is not of type ' . $expectedType
                    . ' but of type ' . typeOf($this->default)
            );
        }
    }