pho\Console\Console::parseArguments PHP Method

parseArguments() public method

Furthermore, if the arguments included a non-valid flag or option, or if any of the listed paths were invalid, error message is printed.
public parseArguments ( )
    public function parseArguments()
    {
        // Add the list of options to the OptionParser
        foreach ($this->availableOptions as $name => $desc) {
            $desc[3] = isset($desc[3]) ? $desc[3] : null;
            list($longName, $shortName, $description, $argumentName) = $desc;
            $this->optionParser->addOption($name, $longName, $shortName, $description, $argumentName);
        }
        // Parse the arguments, assign the options
        $this->optionParser->parseArguments($this->arguments);
        $this->options = $this->optionParser->getOptions();
        // Verify the paths, listing any invalid paths
        $paths = $this->optionParser->getPaths();
        if ($paths) {
            $this->paths = $paths;
            foreach ($this->paths as $path) {
                if (!file_exists($path)) {
                    $this->exitStatus = 1;
                    $this->writeLn("The file or path \"{$path}\" doesn't exist");
                }
            }
        }
        // Render help or version text if necessary, and display errors
        if ($this->options['help']) {
            $this->exitStatus = 0;
            $this->printHelp();
        } elseif ($this->options['version']) {
            $this->exitStatus = 0;
            $this->printVersion();
        } elseif ($this->optionParser->getInvalidArguments()) {
            $this->exitStatus = 1;
            foreach ($this->optionParser->getInvalidArguments() as $invalidArg) {
                $this->writeLn("{$invalidArg} is not a valid option");
            }
        }
    }

Usage Example

Ejemplo n.º 1
0
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     if ($result === null) {
         $result = $this->createResult();
     }
     ConciseReporter::$test = $this;
     ConciseReporter::$testCase = new IndependentTestCase();
     ConciseReporter::$result = $result;
     // Create a new Console and parse arguments
     $console = new Console(array('--reporter', 'concise'), 'php://stdout');
     $console->parseArguments();
     // Start the runner
     Runner::$console = $console;
     Runner::getInstance()->run();
     return $result;
 }
All Usage Examples Of pho\Console\Console::parseArguments