/** * Scalar is constructed with its value * * @param $scalarValue */ public function __construct(\Closure $closure = null) { if (!is_null($closure)) { $this->_closure = $closure; try { $result = $closure(); $this->setActualValue($result); } catch (\PHPSpec\Exception $e) { if (!\PHPSpec\PHPSpec::testingPHPSpec()) { throw $e; } $this->_composedActual = true; $this->setActualValue(array(get_class($e), $e->getMessage())); } catch (\Exception $e) { $this->_composedActual = true; $this->setActualValue(array(get_class($e), $e->getMessage())); } } }
<?php require_once 'Mockery/Loader.php'; require_once 'Hamcrest/Hamcrest.php'; $loader = new \Mockery\Loader(); $loader->register(); \PHPSpec\PHPSpec::setTestingPHPSpec(true); defined('THIS_REQUIRED_ATTRIBUTE_IS_IGNORED_BY_CONSTRUCTOR') or define('THIS_REQUIRED_ATTRIBUTE_IS_IGNORED_BY_CONSTRUCTOR', 'ignored');
/** * Returns nicely formatted backtrace * * @param array $trace * @param integer $limit * @return string */ public static function pretty($trace, $limit = self::NUMBER_OF_LINES) { $formatted = ''; foreach ($trace as $line) { if ($limit !== null && $limit === 0) { return $formatted; } $prettyLine = ''; if (isset($line['file'])) { $file = self::shortenRelativePath($line['file']); $prettyLine = self::prettyLine($file, $line['line']); } if ($formatted && $prettyLine && strpos($formatted, $prettyLine) !== false) { continue; } if ($limit !== null && !PHPSpec::testingPHPSpec()) { if (stristr($prettyLine, 'phpspec')) { continue; } } $formatted .= $prettyLine; if ($limit !== null && $prettyLine) { $limit--; } } return $formatted; }