PHP Класс Behat\Gherkin\Parser

$lexer = new Behat\Gherkin\Lexer($keywords); $parser = new Behat\Gherkin\Parser($lexer); $featuresArray = $parser->parse('/path/to/feature.feature');
Автор: Konstantin Kudryashov ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( Lexer $lexer ) Initializes parser.
parse ( string $input, string $file = null ) : Behat\Gherkin\Node\FeatureNode | null Parses input & returns features array.

Защищенные методы

Метод Описание
acceptTokenType ( string $type ) : null | array Returns next token if it's type equals to expected.
expectTokenType ( string $type ) : array Returns next token if it's type equals to expected.
parseBackground ( ) : Behat\Gherkin\Node\BackgroundNode Parses background token & returns it's node.
parseComment ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string Parses next comment token & returns it's string content.
parseExamples ( ) : Behat\Gherkin\Node\ExampleTableNode Parses examples table node.
parseExpression ( ) : string | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\TableNode | Behat\Gherkin\Node\StepNode Parses current expression & returns Node.
parseFeature ( ) : Behat\Gherkin\Node\FeatureNode Parses feature token & returns it's node.
parseLanguage ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string Parses language block and updates lexer configuration based on it.
parseNewline ( ) : string Parses next newline & returns \n.
parseOutline ( ) : Behat\Gherkin\Node\OutlineNode Parses scenario outline token & returns it's node.
parsePyString ( ) : Behat\Gherkin\Node\PyStringNode Parses PyString token & returns it's node.
parseScenario ( ) : Behat\Gherkin\Node\ScenarioNode Parses scenario token & returns it's node.
parseStep ( ) : Behat\Gherkin\Node\StepNode Parses step token & returns it's node.
parseTable ( ) : Behat\Gherkin\Node\TableNode Parses table token & returns it's node.
parseTags ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string Parses tags.
parseText ( ) : string Parses next text line & returns it.
popTags ( ) : array Returns current set of tags and clears tag buffer.
predictTokenType ( ) : string Returns next token type without real input reading (prediction).

Приватные методы

Метод Описание
normalizeStepNodeKeywordType ( Behat\Gherkin\Node\StepNode $node, array $steps = [] ) : Behat\Gherkin\Node\StepNode Changes step node type for types But, And to type of previous step if it exists else sets to Given
parseTableRows ( ) : string[][] Parses the rows of a table

Описание методов

__construct() публичный Метод

Initializes parser.
public __construct ( Lexer $lexer )
$lexer Lexer Lexer instance

acceptTokenType() защищенный Метод

Returns next token if it's type equals to expected.
protected acceptTokenType ( string $type ) : null | array
$type string Token type
Результат null | array

expectTokenType() защищенный Метод

Returns next token if it's type equals to expected.
protected expectTokenType ( string $type ) : array
$type string Token type
Результат array

parse() публичный Метод

Parses input & returns features array.
public parse ( string $input, string $file = null ) : Behat\Gherkin\Node\FeatureNode | null
$input string Gherkin string document
$file string File name
Результат Behat\Gherkin\Node\FeatureNode | null

parseBackground() защищенный Метод

Parses background token & returns it's node.
protected parseBackground ( ) : Behat\Gherkin\Node\BackgroundNode
Результат Behat\Gherkin\Node\BackgroundNode

parseComment() защищенный Метод

Parses next comment token & returns it's string content.
protected parseComment ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string
Результат Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string

parseExamples() защищенный Метод

Parses examples table node.
protected parseExamples ( ) : Behat\Gherkin\Node\ExampleTableNode
Результат Behat\Gherkin\Node\ExampleTableNode

parseExpression() защищенный Метод

Parses current expression & returns Node.
protected parseExpression ( ) : string | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\TableNode | Behat\Gherkin\Node\StepNode
Результат string | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\TableNode | Behat\Gherkin\Node\StepNode

parseFeature() защищенный Метод

Parses feature token & returns it's node.
protected parseFeature ( ) : Behat\Gherkin\Node\FeatureNode
Результат Behat\Gherkin\Node\FeatureNode

parseLanguage() защищенный Метод

Parses language block and updates lexer configuration based on it.
protected parseLanguage ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string
Результат Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string

parseNewline() защищенный Метод

Parses next newline & returns \n.
protected parseNewline ( ) : string
Результат string

parseOutline() защищенный Метод

Parses scenario outline token & returns it's node.
protected parseOutline ( ) : Behat\Gherkin\Node\OutlineNode
Результат Behat\Gherkin\Node\OutlineNode

parsePyString() защищенный Метод

Parses PyString token & returns it's node.
protected parsePyString ( ) : Behat\Gherkin\Node\PyStringNode
Результат Behat\Gherkin\Node\PyStringNode

parseScenario() защищенный Метод

Parses scenario token & returns it's node.
protected parseScenario ( ) : Behat\Gherkin\Node\ScenarioNode
Результат Behat\Gherkin\Node\ScenarioNode

parseStep() защищенный Метод

Parses step token & returns it's node.
protected parseStep ( ) : Behat\Gherkin\Node\StepNode
Результат Behat\Gherkin\Node\StepNode

parseTable() защищенный Метод

Parses table token & returns it's node.
protected parseTable ( ) : Behat\Gherkin\Node\TableNode
Результат Behat\Gherkin\Node\TableNode

parseTags() защищенный Метод

Parses tags.
protected parseTags ( ) : Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string
Результат Behat\Gherkin\Node\BackgroundNode | Behat\Gherkin\Node\FeatureNode | Behat\Gherkin\Node\OutlineNode | Behat\Gherkin\Node\ScenarioNode | Behat\Gherkin\Node\StepNode | Behat\Gherkin\Node\TableNode | string

parseText() защищенный Метод

Parses next text line & returns it.
protected parseText ( ) : string
Результат string

popTags() защищенный Метод

Returns current set of tags and clears tag buffer.
protected popTags ( ) : array
Результат array

predictTokenType() защищенный Метод

Returns next token type without real input reading (prediction).
protected predictTokenType ( ) : string
Результат string