Server IP : 127.0.0.2 / Your IP : 3.144.112.72 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/laravel/framework/src/Illuminate/Console/ |
Upload File : |
<?php namespace Illuminate\Console; use Illuminate\Support\Str; use InvalidArgumentException; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class Parser { /** * Parse the given console command definition into an array. * * @param string $expression * @return array * * @throws \InvalidArgumentException */ public static function parse($expression) { if (trim($expression) === '') { throw new InvalidArgumentException('Console command definition is empty.'); } if (! preg_match('/[^\s]+/', $expression, $matches)) { throw new InvalidArgumentException('Unable to determine command name from signature.'); } $name = $matches[0]; if (preg_match_all('/\{\s*(.*?)\s*\}/', $expression, $matches)) { $tokens = $matches[1]; if (count($tokens)) { return array_merge([$name], static::parameters($tokens)); } } return [$name, [], []]; } /** * Extract all of the parameters from the tokens. * * @param array $tokens * @return array */ protected static function parameters(array $tokens) { $arguments = []; $options = []; foreach ($tokens as $token) { if (preg_match('/-{2,}(.*)/', $token, $matches)) { $options[] = static::parseOption($matches[1]); } else { $arguments[] = static::parseArgument($token); } } return [$arguments, $options]; } /** * Parse an argument expression. * * @param string $token * @return \Symfony\Component\Console\Input\InputArgument */ protected static function parseArgument($token) { list($token, $description) = static::parseToken($token); switch (true) { case Str::endsWith($token, '?*'): return new InputArgument(trim($token, '?*'), InputArgument::IS_ARRAY, $description); case Str::endsWith($token, '*'): return new InputArgument(trim($token, '*'), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description); case Str::endsWith($token, '?'): return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description); case preg_match('/(.+)\=(.+)/', $token, $matches): return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]); default: return new InputArgument($token, InputArgument::REQUIRED, $description); } } /** * Parse an option expression. * * @param string $token * @return \Symfony\Component\Console\Input\InputOption */ protected static function parseOption($token) { list($token, $description) = static::parseToken($token); $matches = preg_split('/\s*\|\s*/', $token, 2); if (isset($matches[1])) { $shortcut = $matches[0]; $token = $matches[1]; } else { $shortcut = null; } switch (true) { case Str::endsWith($token, '='): return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description); case Str::endsWith($token, '=*'): return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description); case preg_match('/(.+)\=(.+)/', $token, $matches): return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]); default: return new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description); } } /** * Parse the token into its token and description segments. * * @param string $token * @return array */ protected static function parseToken($token) { $parts = preg_split('/\s+:\s+/', trim($token), 2); return count($parts) === 2 ? $parts : [$token, null]; } }