/** * Construct this command line library * @param null|array $arguments */ public function __construct(array $arguments = null) { $this->isCli = php_sapi_name() == self::SAPI_CLI; if (!$this->isCli) { $this->arguments = array(); return; } if ($arguments === null) { $arguments = $_SERVER['argv']; } $this->arguments = ArgumentParser::parseArguments($arguments); }
/** * Construct this command line library * @param null|array $arguments */ public function __construct(array $arguments = null) { $this->isCli = php_sapi_name() == self::SAPI_CLI; if (!$this->isCli) { $this->arguments = array(); return; } if ($arguments === null) { $arguments = $_SERVER['argv']; array_shift($arguments); // remove first element, always the script name } $this->arguments = ArgumentParser::parseArguments($arguments); }