src/Application/ConsoleApplication.php
/**
     * Parses the command line parameters given to the console application.
     *
     * @param string[]               $parameters   The command line parameters.
     * @param ParseContextInterface  $parseContext The parse context.
     * @param FilePathInterface|null $testfilePath The parsed path to the webunit testfile or null if parsing failed.
     * @param string|null            $error        The error if parsing failed.
     *
     * @return bool True if parsing was successful, false otherwise.
     */
Parses the command line parameters given to the console application.
@param string[]               $parameters   The command line parameters.
@param ParseContextInterface  $parseContext The parse context.
@param FilePathInterface|null $testfilePath The parsed path to the webunit testfile or null if parsing failed.
@param string|null            $error        The error if parsing failed.

@return bool True if parsing was successful, false otherwise.
Parses the command line parameters given to the console application . @param string [] $parameters The command line parameters . @param ParseContextInterface $parseContext The parse context . @param FilePathInterface|null $testfilePath The parsed path to the webunit testfile or null if parsing failed . @param string|null $error The error if parsing failed . @return bool True if parsing was successful false otherwise .
private function parseCommandLineParameters(array $parameters, ParseContextInterface $parseContext, FilePathInterface &$testfilePath = null, string &$error = null): bool
    {
        array_shift($parameters);
        $testfilePath = null;
        $error = null;
        foreach ($parameters as $parameter) {
            $parameter = trim($parameter);
            if (substr($parameter, 0, 2) === '--') {
                $optionParts = explode('=', $parameter, 2);
                $optionName = trim($optionParts[0]);
                $optionValue = count($optionParts) > 1 ? trim($optionParts[1]) : null;
                switch ($optionName) {
                    case '--set':
                        if ($optionValue === null) {
                            $error = 'Missing value for option "' . $parameter . '".';
                            return false;
                        }
                        if (!$this->parseSetCommandLineParameter($optionValue, $parseContext, $error)) {
                            $error = 'Invalid value for option "' . $parameter . '": ' . $error;
                            return false;
                        }
                        break;
                    default:
                        $error = 'Invalid option "' . $parameter . '".';
                        return false;
                }
                continue;
            }
            if (!$this->parseTestfilePathCommandLineParameter($parameter, $testfilePath, $error)) {
                return false;
            }
        }
        if ($testfilePath === null) {
            $error = 'Missing testfile parameter.';
            return false;
        }
        return true;
    }
private function parseCommandLineParameters ( array $ parameters , ParseContextInterface $ parseContext , FilePathInterface & $ testfilePath = null , string & $ error = null ) : bool { array_shift ( $ parameters ) ; $ testfilePath = null ; $ error = null ; foreach ( $ parameters as $ parameter ) { $ parameter = trim ( $ parameter ) ; if ( substr ( $ parameter , 0 , 2 ) === '--' ) { $ optionParts = explode ( '=' , $ parameter , 2 ) ; $ optionName = trim ( $ optionParts [ 0 ] ) ; $ optionValue = count ( $ optionParts ) > 1 ? trim ( $ optionParts [ 1 ] ) : null ; switch ( $ optionName ) { case '--set' : if ( $ optionValue === null ) { $ error = 'Missing value for option "' . $ parameter . '".' ; return false ; } if ( ! $ this -> parseSetCommandLineParameter ( $ optionValue , $ parseContext , $ error ) ) { $ error = 'Invalid value for option "' . $ parameter . '": ' . $ error ; return false ; } break ; default : $ error = 'Invalid option "' . $ parameter . '".' ; return false ; } continue ; } if ( ! $ this -> parseTestfilePathCommandLineParameter ( $ parameter , $ testfilePath , $ error ) ) { return false ; } } if ( $ testfilePath === null ) { $ error = 'Missing testfile parameter.' ; return false ; } return true ; }
Parses the command line parameters given to the console application.
Parses the command line parameters given to the console application .