src/Parser/Parser.php
/**
     * Parses a line.
     *
     * @param LocationInterface      $location        The location.
     * @param string                 $line            The line.
     * @param ParseContextInterface  $parseContext    The parse context.
     * @param TestSuiteInterface     $testSuite       The test suite.
     * @param TestCaseInterface|null $currentTestCase The current test case that is parsing or null if no test case is parsing.
     * @param ParseErrorInterface[]  $parseErrors     The current parse errors.
     */
Parses a line.
@param LocationInterface      $location        The location.
@param string                 $line            The line.
@param ParseContextInterface  $parseContext    The parse context.
@param TestSuiteInterface     $testSuite       The test suite.
@param TestCaseInterface|null $currentTestCase The current test case that is parsing or null if no test case is parsing.
@param ParseErrorInterface[]  $parseErrors     The current parse errors.
Parses a line . @param LocationInterface $location The location . @param string $line The line . @param ParseContextInterface $parseContext The parse context . @param TestSuiteInterface $testSuite The test suite . @param TestCaseInterface|null $currentTestCase The current test case that is parsing or null if no test case is parsing . @param ParseErrorInterface [] $parseErrors The current parse errors .
private static function parseLine(LocationInterface $location, string $line, ParseContextInterface $parseContext, TestSuiteInterface $testSuite, ?TestCaseInterface &$currentTestCase, array &$parseErrors): void
    {
        if (self::isEmptyOrComment($line)) {
            return;
        }
        $lineParts = preg_split('/\s+/', $line, 2);
        $command = strtolower(trim($lineParts[0]));
        $argument = count($lineParts) > 1 ? trim($lineParts[1]) : null;
        if ($argument !== null) {
            $argument = self::replaceVariables($location, $argument, $parseContext, $parseErrors);
            if ($argument === null) {
                return;
            }
        }
        if (self::tryParseSet($location, $command, $argument, $parseContext, $parseErrors)) {
            return;
        }
        if (self::tryParseTestCase($location, $command, $argument, $parseErrors, $testCase)) {
            if ($testCase !== null) {
                $testSuite->addTestCase($testCase);
                $currentTestCase = $testCase;
            }
            return;
        }
        if (self::tryParseAssert($location, $command, $argument, $parseErrors, $assert)) {
            if ($assert !== null) {
                if ($currentTestCase !== null) {
                    $currentTestCase->addAssert($assert);
                } else {
                    $parseErrors[] = new ParseError($location, 'Undefined test case: Test case is not defined for assert "' . $command . '".');
                }
            }
            return;
        }
        $parseErrors[] = new ParseError($location, 'Syntax error: Invalid command "' . $command . '".');
    }
private static function parseLine ( LocationInterface $ location , string $ line , ParseContextInterface $ parseContext , TestSuiteInterface $ testSuite , ? TestCaseInterface & $ currentTestCase , array & $ parseErrors ) : void { if ( self :: isEmptyOrComment ( $ line ) ) { return ; } $ lineParts = preg_split ( '/\s+/' , $ line , 2 ) ; $ command = strtolower ( trim ( $ lineParts [ 0 ] ) ) ; $ argument = count ( $ lineParts ) > 1 ? trim ( $ lineParts [ 1 ] ) : null ; if ( $ argument !== null ) { $ argument = self :: replaceVariables ( $ location , $ argument , $ parseContext , $ parseErrors ) ; if ( $ argument === null ) { return ; } } if ( self :: tryParseSet ( $ location , $ command , $ argument , $ parseContext , $ parseErrors ) ) { return ; } if ( self :: tryParseTestCase ( $ location , $ command , $ argument , $ parseErrors , $ testCase ) ) { if ( $ testCase !== null ) { $ testSuite -> addTestCase ( $ testCase ) ; $ currentTestCase = $ testCase ; } return ; } if ( self :: tryParseAssert ( $ location , $ command , $ argument , $ parseErrors , $ assert ) ) { if ( $ assert !== null ) { if ( $ currentTestCase !== null ) { $ currentTestCase -> addAssert ( $ assert ) ; } else { $ parseErrors [ ] = new ParseError ( $ location , 'Undefined test case: Test case is not defined for assert "' . $ command . '".' ) ; } } return ; } $ parseErrors [ ] = new ParseError ( $ location , 'Syntax error: Invalid command "' . $ command . '".' ) ; }
Parses a line.
Parses a line .