4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
14 use Symfony\Component\Console\Input\InputArgument;
17 * An input argument for code.
19 * A CodeArgument must be the final argument of the command. Once all options
20 * and other arguments are used, any remaining input until the end of the string
21 * is considered part of a single CodeArgument, regardless of spaces, quoting,
24 * This means commands can support crazy input like
26 * parse function() { return "wheee\n"; }
28 * ... without having to put the code in a quoted string and escape everything.
30 class CodeArgument extends InputArgument
35 * @param string $name The argument name
36 * @param int $mode The argument mode: self::REQUIRED or self::OPTIONAL
37 * @param string $description A description text
38 * @param mixed $default The default value (for self::OPTIONAL mode only)
40 * @throws \InvalidArgumentException When argument mode is not valid
42 public function __construct($name, $mode = null, $description = '', $default = null)
44 if ($mode & InputArgument::IS_ARRAY) {
45 throw new \InvalidArgumentException('Argument mode IS_ARRAY is not valid.');
48 parent::__construct($name, $mode, $description, $default);