Skip to content

Commit

Permalink
Behat#117 phpdoc and some rewording
Browse files Browse the repository at this point in the history
  • Loading branch information
stukalin committed Dec 23, 2016
1 parent 10468a5 commit cbc6c00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
9 changes: 8 additions & 1 deletion src/Behat/Gherkin/Filter/TagFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ public function __construct($filterString)
{
$this->filterString = trim($filterString);
}


/**
* Filters feature according to the filter.
*
* @param FeatureNode $feature
*
* @return FeatureNode
*/
public function filterFeature(FeatureNode $feature)
{
$scenarios = array();
Expand Down
19 changes: 10 additions & 9 deletions src/Behat/Gherkin/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Parser
private $tags = array();
private $languageSpecifierLine;

private $stack = array();
private $passedNodesStack = array();

/**
* Initializes parser.
Expand Down Expand Up @@ -238,7 +238,7 @@ protected function parseFeature()
$file = $this->file;
$line = $token['line'];

array_push($this->stack, 'Feature');
array_push($this->passedNodesStack, 'Feature');

// Parse description, background, scenarios & outlines
while ('EOS' !== $this->predictTokenType()) {
Expand Down Expand Up @@ -373,7 +373,7 @@ protected function parseScenario()
$keyword = $token['keyword'];
$line = $token['line'];

array_push($this->stack, 'Scenario');
array_push($this->passedNodesStack, 'Scenario');

// Parse description and steps
$steps = array();
Expand Down Expand Up @@ -413,7 +413,7 @@ protected function parseScenario()
}
}

array_pop($this->stack);
array_pop($this->passedNodesStack);

return new ScenarioNode(rtrim($title) ?: null, $tags, $steps, $keyword, $line);
}
Expand All @@ -440,7 +440,7 @@ protected function parseOutline()
// Parse description, steps and examples
$steps = array();

array_push($this->stack, 'Outline');
array_push($this->passedNodesStack, 'Outline');

while (in_array($this->predictTokenType(), array('Step', 'Examples', 'Newline', 'Text', 'Comment', 'Tag'))) {
$node = $this->parseExpression();
Expand Down Expand Up @@ -510,7 +510,7 @@ protected function parseStep()
$text = trim($token['text']);
$line = $token['line'];

array_push($this->stack, 'Step');
array_push($this->passedNodesStack, 'Step');

$arguments = array();
while (in_array($predicted = $this->predictTokenType(), array('PyStringOp', 'TableRow', 'Newline', 'Comment'))) {
Expand All @@ -526,7 +526,7 @@ protected function parseStep()
}
}

array_pop($this->stack);
array_pop($this->passedNodesStack);

return new StepNode($keyword, $text, $arguments, $line, $keywordType);
}
Expand Down Expand Up @@ -599,9 +599,10 @@ protected function parseTags()

$currentType = '-1';
// check if that is ok to go inside:
if (!empty($this->stack)) {
$currentType = $this->stack[count($this->stack) - 1];
if (!empty($this->passedNodesStack)) {
$currentType = $this->passedNodesStack[count($this->passedNodesStack) - 1];
}

$nextType = $this->predictTokenType();
if (!isset($possibleTransitions[$currentType]) || in_array($nextType, $possibleTransitions[$currentType])) {
return $this->parseExpression();
Expand Down

0 comments on commit cbc6c00

Please sign in to comment.