PEAR2_Console_CommandLine-0.1.0 › PEAR2_Console_CommandLine-0.1.0/php/PEAR2/Console/CommandLine/Argument.php
- PEAR2_Console_CommandLine-0.1.0/
- data/
- PEAR2_Console_CommandLine/
- pear2.php.net/
- PEAR2_Console_CommandLine/
- doc/
- php/
- PEAR2/
- Autoload.php
- Console/
- CommandLine/
- Action/
- Action.php
- Argument.php
- Command.php
- CustomMessageProvider.php
- Element.php
- Exception.php
- MessageProvider/
- MessageProvider.php
- Option.php
- Outputter/
- Outputter.php
- Renderer/
- Renderer.php
- Result.php
- XmlParser.php
- CommandLine.php
- CommandLine/
- Exception.php
- MultiErrors/
- MultiErrors.php
- PEAR2/
- test/
- PEAR2_Console_CommandLine/
- pear2.php.net/
- AllTests.php
- console_commandline_accept.phpt
- console_commandline_addargument.phpt
- console_commandline_addcommand.phpt
- console_commandline_addoption.phpt
- console_commandline_addoption_errors_1.phpt
- console_commandline_addoption_errors_2.phpt
- console_commandline_addoption_errors_3.phpt
- console_commandline_addoption_errors_4.phpt
- console_commandline_addoption_errors_5.phpt
- console_commandline_addoption_errors_6.phpt
- console_commandline_addoption_errors_7.phpt
- console_commandline_fromxmlfile.phpt
- console_commandline_fromxmlfile_error.phpt
- console_commandline_fromxmlstring.phpt
- console_commandline_options_defaults.phpt
- console_commandline_parse_1.phpt
- console_commandline_parse_10.phpt
- console_commandline_parse_11.phpt
- console_commandline_parse_12.phpt
- console_commandline_parse_13.phpt
- console_commandline_parse_14.phpt
- console_commandline_parse_15.phpt
- console_commandline_parse_16.phpt
- console_commandline_parse_17.phpt
- console_commandline_parse_18.phpt
- console_commandline_parse_19.phpt
- console_commandline_parse_2.phpt
- console_commandline_parse_20.phpt
- console_commandline_parse_21.phpt
- console_commandline_parse_22.phpt
- console_commandline_parse_23.phpt
- console_commandline_parse_24.phpt
- console_commandline_parse_25.phpt
- console_commandline_parse_26.phpt
- console_commandline_parse_27.phpt
- console_commandline_parse_28.phpt
- console_commandline_parse_29.phpt
- console_commandline_parse_3.phpt
- console_commandline_parse_4.phpt
- console_commandline_parse_5.phpt
- console_commandline_parse_6.phpt
- console_commandline_parse_7.phpt
- console_commandline_parse_8.phpt
- console_commandline_parse_9.phpt
- console_commandline_webrequest_1.phpt
- console_commandline_webrequest_2.phpt
- console_commandline_webrequest_3.phpt
- test.xml
- tests.inc.php
- pear2.php.net/
- PEAR2_Console_CommandLine/
- data/
- package.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* This file is part of the PEAR2\Console\CommandLine package.
*
* PHP version 5
*
* LICENSE: This source file is subject to the MIT license that is available
* through the world-wide-web at the following URI:
* http://opensource.org/licenses/mit-license.php
*
* @category Console
* @package PEAR2\Console\CommandLine
* @author David JEAN LOUIS <izimobil@gmail.com>
* @copyright 2007-2009 David JEAN LOUIS
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version SVN: $Id$
* @link http://pear.php.net/package/Console_CommandLine
* @since File available since release 0.1.0
* @filesource
*/
/**
* Class that represent a command line argument.
*
* @category Console
* @package PEAR2\Console\CommandLine
* @author David JEAN LOUIS <izimobil@gmail.com>
* @copyright 2007-2009 David JEAN LOUIS
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version Release: @package_version@
* @link http://pear.php.net/package/Console_CommandLine
* @since Class available since release 0.1.0
*/
namespace PEAR2\Console\CommandLine;
class Argument extends Element
{
// Public properties {{{
/**
* Setting this to true will tell the parser that the argument expects more
* than one argument and that argument values should be stored in an array.
*
* @var boolean $multiple Whether the argument expects multiple values
*/
public $multiple = false;
/**
* Setting this to true will tell the parser that the argument is optional
* and can be ommited.
* Note that it is not a good practice to make arguments optional, it is
* the role of the options to be optional, by essence.
*
* @var boolean $optional Whether the argument is optional or not.
*/
public $optional = false;
// }}}
// validate() {{{
/**
* Validates the argument instance.
*
* @return void
* @throws PEAR2\Console\CommandLine_Exception
* @todo use exceptions
*/
public function validate()
{
// check if the argument name is valid
if (!preg_match('/^[a-zA-Z_\x7f-\xff]+[a-zA-Z0-9_\x7f-\xff]*$/',
$this->name)) {
\PEAR2\Console\CommandLine::triggerError(
'argument_bad_name',
E_USER_ERROR,
array('{$name}' => $this->name)
);
}
parent::validate();
}
// }}}
}
EOF
