|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Console GetoptPlus/Exception |
|
5
|
|
|
* |
|
6
|
|
|
* All rights reserved. |
|
7
|
|
|
* Redistribution and use in source and binary forms, with or without modification, |
|
8
|
|
|
* are permitted provided that the following conditions are met: |
|
9
|
|
|
* + Redistributions of source code must retain the above copyright notice, |
|
10
|
|
|
* this list of conditions and the following disclaimer. |
|
11
|
|
|
* + Redistributions in binary form must reproduce the above copyright notice, |
|
12
|
|
|
* this list of conditions and the following disclaimer in the documentation and/or |
|
13
|
|
|
* other materials provided with the distribution. |
|
14
|
|
|
* + The names of its contributors may not be used to endorse or promote |
|
15
|
|
|
* products derived from this software without specific prior written permission. |
|
16
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
17
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
18
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
19
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
20
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
21
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
22
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
23
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
24
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
25
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
26
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
27
|
|
|
* |
|
28
|
|
|
* @category Console |
|
29
|
|
|
* @package Console_GetoptPlus |
|
30
|
|
|
* @author Michel Corne <[email protected]> |
|
31
|
|
|
* @copyright 2008 Michel Corne |
|
32
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License |
|
33
|
|
|
* @version SVN: $Id: Exception.php 47 2008-01-10 11:03:38Z mcorne $ |
|
34
|
|
|
* @link http://pear.php.net/package/Console_GetoptPlus |
|
35
|
|
|
*/ |
|
36
|
|
|
require_once __DIR__ . '/PEAR/Exception.php'; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Handling of error messages and exceptions. |
|
40
|
|
|
* |
|
41
|
|
|
* @category Console |
|
42
|
|
|
* @package Console_GetoptPlus |
|
43
|
|
|
* @author Michel Corne <[email protected]> |
|
44
|
|
|
* @copyright 2008 Michel Corne |
|
45
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License |
|
46
|
|
|
* @version Release: @package_version@ |
|
47
|
|
|
* @link http://pear.php.net/package/Console_GetoptPlus |
|
48
|
|
|
* @see PEAR_Exception |
|
49
|
|
|
*/ |
|
50
|
|
|
class Console_GetoptPlus_Exception extends PEAR_Exception |
|
|
|
|
|
|
51
|
|
|
{ |
|
52
|
|
|
/** |
|
53
|
|
|
* The error messages |
|
54
|
|
|
* |
|
55
|
|
|
* @var array |
|
56
|
|
|
* @access private |
|
57
|
|
|
*/ |
|
58
|
|
|
private $messages = [// / |
|
59
|
|
|
'unknow' => [1, 'Console_Getopt: unknown error ID (%s)'], |
|
60
|
|
|
// original Console_Getopt error messages |
|
61
|
|
|
'ambigous' => [10, 'Console_Getopt: option --%s is ambiguous'], |
|
62
|
|
|
'mandatory' => [11, 'Console_Getopt: option requires an argument --%s'], |
|
63
|
|
|
'noargument' => [12, 'Console_Getopt: option --%s doesn\'t allow an argument'], |
|
64
|
|
|
'noargs' => [13, 'Console_Getopt: Could not read cmd args (register_argc_argv=Off?)'], |
|
65
|
|
|
'unrecognized' => [14, 'Console_Getopt: unrecognized option --%s'], |
|
66
|
|
|
// additional Console_GetoptPlus_Getopt error messages |
|
67
|
|
|
'duplicate' => [20, 'Console_Getopt: duplicate option name definition --%s'], |
|
68
|
|
|
'invalid' => [21, 'Console_Getopt: invalid long option definition %s'], |
|
69
|
|
|
'string' => [22, 'Console_Getopt: short options definition must be a string'], |
|
70
|
|
|
'syntax' => [23, 'Console_Getopt: short options definition syntax error %s'], |
|
71
|
|
|
// additional Console_GetoptPlus error messages |
|
72
|
|
|
'missing' => [30, 'Console_GetoptPlus: unknown option name #%s'], |
|
73
|
|
|
'type' => [31, 'Console_GetoptPlus: unknown option type %s'], |
|
74
|
|
|
'convert' => [32, 'Console_GetoptPlus: wrong option name conversion %s'], |
|
75
|
|
|
]; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Triggers the exception. |
|
79
|
|
|
* |
|
80
|
|
|
* @param mixed $exception the exception ID and optional message part, |
|
81
|
|
|
* e.g. "string" or array("invalid", '--foo') |
|
82
|
|
|
* @throws \PEAR_Exception |
|
83
|
|
|
* @access public |
|
84
|
|
|
*/ |
|
85
|
|
|
public function __construct($exception) |
|
86
|
|
|
{ |
|
87
|
|
|
// extracts the exception ID and message parameters |
|
88
|
|
|
$exception = (array)$exception; |
|
89
|
|
|
$id = current($exception); |
|
90
|
|
|
// resets the exception ID if no corresponding message (programmatic error!) |
|
91
|
|
|
isset($this->messages[$id]) or $exception = [null, $id] and $id = 'unknow'; |
|
92
|
|
|
// extracts the exception code and pattern |
|
93
|
|
|
[$code, $format] = $this->messages[$id]; |
|
94
|
|
|
$exception[0] = $format; |
|
95
|
|
|
// completes the message, throws the exception |
|
96
|
|
|
$message = call_user_func_array('\sprintf', $exception); |
|
97
|
|
|
parent::__construct($message, $code); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths