lib/Call/CallCenter.php
public function makeCall(NamespaceProphecy $prophecy, $name, array $arguments)
    {
        // For efficiency exclude 'args' from the generated backtrace
        // Limit backtrace to last 3 calls as we don't use the rest
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);

        $file = $line = null;
        if (isset($backtrace[3]) && isset($backtrace[3]['file'])) {
            $file = $backtrace[3]['file'];
            $line = $backtrace[3]['line'];
        }

        // There are method prophecies, so it's a fake/stub. Searching prophecy for this call
        $matches = [];
        foreach ($prophecy->getProphecies() as $methodProphecy) {
            if ($methodProphecy->getName() !== $name) {
                continue;
            }

            if (0 < $score = $methodProphecy->getArgumentsWildcard()->scoreArguments($arguments)) {
                $matches[] = [$score, $methodProphecy];
            }
        }

        // If fake/stub doesn't have method prophecy for this call - throw exception
        if (!count($matches)) {
            throw $this->createUnexpectedCallException($prophecy, $name, $arguments);
        }

        // Sort matches by their score value
        @usort($matches, function ($match1, $match2) {
            return $match2[0] - $match1[0];
        });

        // If Highest rated method prophecy has a promise - execute it or return null instead
        $returnValue = null;
        $exception = null;
        if ($promise = $matches[0][1]->getPromise()) {
            try {
                $returnValue = $promise->execute($arguments, $matches[0][1]);
            } catch (\Exception $e) {
                $exception = $e;
            }
        }

        $this->recordedCalls[] = new Call($name, $arguments, $returnValue, $exception, $file, $line);

        if (null !== $exception) {
            throw $exception;
        }

        return $returnValue;
    }
public function makeCall(NamespaceProphecy $prophecy, $name, array $arguments)
    {
        // For efficiency exclude 'args' from the generated backtrace
        // Limit backtrace to last 3 calls as we don't use the rest
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4);

        $file = $line = null;
        if (isset($backtrace[3]) && isset($backtrace[3]['file'])) {
            $file = $backtrace[3]['file'];
            $line = $backtrace[3]['line'];
        }

        // There are method prophecies, so it's a fake/stub. Searching prophecy for this call
        $matches = [];
        foreach ($prophecy->getProphecies() as $methodProphecy) {
            if ($methodProphecy->getName() !== $name) {
                continue;
            }

            if (0 < $score = $methodProphecy->getArgumentsWildcard()->scoreArguments($arguments)) {
                $matches[] = [$score, $methodProphecy];
            }
        }

        // If fake/stub doesn't have method prophecy for this call - throw exception
        if (!count($matches)) {
            throw $this->createUnexpectedCallException($prophecy, $name, $arguments);
        }

        // Sort matches by their score value
        @usort($matches, function ($match1, $match2) {
            return $match2[0] - $match1[0];
        });

        // If Highest rated method prophecy has a promise - execute it or return null instead
        $returnValue = null;
        $exception = null;
        if ($promise = $matches[0][1]->getPromise()) {
            try {
                $returnValue = $promise->execute($arguments, $matches[0][1]);
            } catch (\Exception $e) {
                $exception = $e;
            }
        }

        $this->recordedCalls[] = new Call($name, $arguments, $returnValue, $exception, $file, $line);

        if (null !== $exception) {
            throw $exception;
        }

        return $returnValue;
    }
Makes and records specific method call for object prophecy.

@param NamespaceProphecy $prophecy
@param string $name
@param array $arguments

@return mixed Returns null if no promise for prophecy found or promise return value.

@throws UnexpectedCallException If no appropriate method prophecy found
@throws \Exception