1) { array_shift($argv); } $flags = implode(' ', $argv); } $configs = array(); preg_match_all(self::$Regex, $flags, $matches, PREG_SET_ORDER); foreach ($matches as $index => $match) { if (isset($match['value']) && $match['value'] !== '') { $value = $match['value']; } else if (isset($match['string']) && $match['string'] !== '') { // fix escaped quotes $value = str_replace("\\\"", "\"", $match['string']); $value = str_replace("\\'", "'", $value); } else { $value = true; } if (isset($match['bigflag']) && $match['bigflag'] !== '') { $configs[$match['bigflag']] = $value; } if (isset($match['smallflag']) && $match['smallflag'] !== '') { $configs[$match['smallflag']] = $value; } if (isset($match['unmatched']) && $match['unmatched'] !== '') { $configs[$match['unmatched']] = true; } if ($index >= $max_arguments) break; } return $configs; } /** * Returns the arguments from the command line * * @return array */ public static function getArguments(): array { if(self::$ArgsCache == null) { if(isset($argv)) { self::$ArgsCache = self::parseArgument($argv); } else { self::$ArgsCache = []; } } return self::$ArgsCache; } }