/** * Initializes redundant exception. * * @param Behat\Behat\Definition\Definition $step2 duplicate step definition * @param Behat\Behat\Definition\Definition $step1 firstly matched step definition */ public function __construct(Definition $step2, Definition $step1) { $message = sprintf("Step \"%s\" is already defined in %s:%d\n\n%s:%d\n%s:%d", $step2->getRegex(), $step1->getFile(), $step1->getLine(), $step1->getFile(), $step1->getLine(), $step2->getFile(), $step2->getLine()); parent::__construct($message); }
/** * {@inheritdoc} */ protected function colorizeDefinitionArguments($text, Definition $definition, $color) { $regex = $definition->getRegex(); $paramColor = $color . '_param'; // Find arguments with offsets $matches = array(); preg_match($regex, $text, $matches, PREG_OFFSET_CAPTURE); array_shift($matches); // Replace arguments with colorized ones $shift = 0; foreach ($matches as $key => $match) { if (!is_numeric($key) || -1 === $match[1]) { continue; } $offset = $match[1] + $shift; $value = $match[0]; $begin = substr($text, 0, $offset); $end = substr($text, $offset + strlen($value)); // Keep track of how many extra characters are added $shift += strlen($format = "{+strong class=\"{$paramColor}\"-}%s{+/strong-}") - 2; $text = sprintf('%s' . $format . '%s', $begin, $value, $end); } // Replace "<", ">" with colorized ones $text = preg_replace('/(<[^>]+>)/', "<strong class=\"{$paramColor}\">\$1</strong>", $text); $text = strtr($text, array('{+' => '<', '-}' => '>')); return $text; }