diff --git a/src/Behat/Gherkin/Parser.php b/src/Behat/Gherkin/Parser.php index 7dba38ad..490ec624 100644 --- a/src/Behat/Gherkin/Parser.php +++ b/src/Behat/Gherkin/Parser.php @@ -72,7 +72,11 @@ public function parse($input, $file = null) try { $this->lexer->analyse($this->input, 'en'); } catch (LexerException $e) { - throw new ParserException(sprintf('Lexer exception "%s" thrown for file %s', $e->getMessage(), $file), 0, $e); + throw new ParserException( + sprintf('Lexer exception "%s" thrown for file %s', $e->getMessage(), $file), + 0, + $e + ); } $feature = null; @@ -89,15 +93,27 @@ public function parse($input, $file = null) } if ($feature && $node instanceof FeatureNode) { - throw new ParserException(sprintf('Only one feature is allowed per feature file. But %s got multiple.', $this->file)); + throw new ParserException(sprintf( + 'Only one feature is allowed per feature file. But %s got multiple.', + $this->file + )); } if (is_string($node)) { - throw new ParserException(sprintf('Expected Feature, but got text: "%s"%s', $node, $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Feature, but got text: "%s"%s', + $node, + $this->file ? ' in file: ' . $this->file : '' + )); } if (!$node instanceof FeatureNode) { - throw new ParserException(sprintf('Expected Feature, but got %s on line: %d%s', $node->getKeyword(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Feature, but got %s on line: %d%s', + $node->getKeyword(), + $node->getLine(), + $this->file ? ' in file: ' . $this->file : '' + )); } } @@ -122,7 +138,13 @@ protected function expectTokenType($type) $token = $this->lexer->predictToken(); - throw new ParserException(sprintf('Expected %s token, but got %s on line: %d%s', implode(' or ', $types), $this->predictTokenType(), $token['line'], $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected %s token, but got %s on line: %d%s', + implode(' or ', $types), + $this->predictTokenType(), + $token['line'], + $this->file ? ' in file: ' . $this->file : '' + )); } /** @@ -308,11 +330,20 @@ protected function parseBackground() } if (is_string($node)) { - throw new ParserException(sprintf('Expected Step, but got text: "%s"%s', $node, $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Step, but got text: "%s"%s', + $node, + $this->file ? ' in file: ' . $this->file : '' + )); } if (!$node instanceof StepNode) { - throw new ParserException(sprintf('Expected Step, but got %s on line: %d%s', $node->getNodeType(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Step, but got %s on line: %d%s', + $node->getNodeType(), + $node->getLine(), + $this->file ? ' in file: ' . $this->file : '' + )); } } @@ -358,11 +389,20 @@ protected function parseScenario() } if (is_string($node)) { - throw new ParserException(sprintf('Expected Step, but got text: "%s"%s', $node, $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Step, but got text: "%s"%s', + $node, + $this->file ? ' in file: ' . $this->file : '' + )); } if (!$node instanceof StepNode) { - throw new ParserException(sprintf('Expected Step, but got %s on line: %d%s', $node->getNodeType(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Step, but got %s on line: %d%s', + $node->getNodeType(), + $node->getLine(), + $this->file ? ' in file: ' . $this->file : '' + )); } } @@ -425,16 +465,30 @@ protected function parseOutline() } if (is_string($node)) { - throw new ParserException(sprintf('Expected Step or Examples table, but got text: "%s"%s', $node, $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Step or Examples table, but got text: "%s"%s', + $node, + $this->file ? ' in file: ' . $this->file : '' + )); } if (!$node instanceof StepNode) { - throw new ParserException(sprintf('Expected Step or Examples table, but got %s on line: %d%s', $node->getNodeType(), $node->getLine(), $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Expected Step or Examples table, but got %s on line: %d%s', + $node->getNodeType(), + $node->getLine(), + $this->file ? ' in file: ' . $this->file : '' + )); } } if (empty($examples)) { - throw new ParserException(sprintf('Outline should have examples table, but got none for outline "%s" on line: %d%s', rtrim($title), $line, $this->file ? ' in file: ' . $this->file : '')); + throw new ParserException(sprintf( + 'Outline should have examples table, but got none for outline "%s" on line: %d%s', + rtrim($title), + $line, + $this->file ? ' in file: ' . $this->file : '' + )); } return new OutlineNode(rtrim($title) ?: null, $tags, $steps, $examples, $keyword, $line);