/** * @param Exception $exception * @return array */ private function getExceptionExamplePosition(Exception $exception) { $cause = $exception->getCause(); foreach ($exception->getTrace() as $call) { if (!isset($call['file'])) { continue; } if (!empty($cause) && $cause->getFilename() === $call['file']) { return array($call['file'], $call['line']); } } return array($exception->getFile(), $exception->getLine()); }
/** * @param string $message * @param string $keyword * @param mixed $subject * @param array $arguments */ public function __construct($message, $keyword, $subject, array $arguments) { parent::__construct($message); $this->keyword = $keyword; $this->subject = $subject; $this->arguments = $arguments; }
/** * @param PhpSpecException $exception * * @return array */ protected function getExceptionExamplePosition(PhpSpecException $exception) { $refl = $exception->getCause(); foreach ($exception->getTrace() as $call) { if (!isset($call['file'])) { continue; } if (!empty($refl) && $refl->getFilename() === $call['file']) { return array($call['file'], $call['line']); } } return array($exception->getFile(), $exception->getLine()); }
function it_presents_the_code_around_where_exception_was_thrown(Exception $e) { $e->getCause()->willReturn(new \ReflectionClass($this)); $this->presentException($e, true); }