@@ -158,11 +158,15 @@ discard block |
||
158 | 158 | //echo "* MATCHED $count \$argv elements *\n"; |
159 | 159 | |
160 | 160 | // Empty $argsL; prevent this inner foreach loop from continuing |
161 | - for($i=0; $i<$count; $i++) array_shift($argsL); |
|
161 | + for($i=0; $i<$count; $i++) { |
|
162 | + array_shift($argsL); |
|
163 | + } |
|
162 | 164 | |
163 | 165 | // Remove (shift) matching elements from $args |
164 | 166 | // These arguments have been consumed by the parser and are no longer needed |
165 | - for($i=0; $i<$count; $i++) array_shift($args); |
|
167 | + for($i=0; $i<$count; $i++) { |
|
168 | + array_shift($args); |
|
169 | + } |
|
166 | 170 | |
167 | 171 | // |
168 | 172 | // Try yielding Arguments from this Rule |
@@ -176,7 +180,9 @@ discard block |
||
176 | 180 | //? TODO: Validate Arguments before adding them to the Arguments array? |
177 | 181 | |
178 | 182 | // Add the new Arguments yielded from this Rule |
179 | - foreach($yield as $y) $arguments[] = $y; |
|
183 | + foreach($yield as $y) { |
|
184 | + $arguments[] = $y; |
|
185 | + } |
|
180 | 186 | |
181 | 187 | // !IMPORTANT! Stop checking Rules |
182 | 188 | break; |
@@ -260,9 +266,10 @@ discard block |
||
260 | 266 | if( $this->parameterCollection->exists($token) ) |
261 | 267 | { |
262 | 268 | // This Rule will create a single Argument |
263 | - if(count($argument)==0) $argument[0] = new Argument($token); |
|
264 | - } |
|
265 | - else |
|
269 | + if(count($argument)==0) { |
|
270 | + $argument[0] = new Argument($token); |
|
271 | + } |
|
272 | + } else |
|
266 | 273 | { |
267 | 274 | // This token does NOT match the flag of any defined parameter |
268 | 275 | // This Rule will NOT yield any arguments |
@@ -282,10 +289,11 @@ discard block |
||
282 | 289 | if( ARGH_TYPE_BOOLEAN == $this->parameterCollection->get($token{$j})->getParameterType() ) |
283 | 290 | { |
284 | 291 | // Create new Argument for each flag |
285 | - if( !array_key_exists($j, $argument) ) $argument[$j] = new Argument($token{$j}); |
|
292 | + if( !array_key_exists($j, $argument) ) { |
|
293 | + $argument[$j] = new Argument($token{$j}); |
|
294 | + } |
|
286 | 295 | } |
287 | - } |
|
288 | - else |
|
296 | + } else |
|
289 | 297 | { |
290 | 298 | // A character in $token, does not match a defined Parameter flag |
291 | 299 | // This Rule will NOT yield any arguments |
@@ -304,9 +312,10 @@ discard block |
||
304 | 312 | if( $this->parameterCollection->exists($token) ) |
305 | 313 | { |
306 | 314 | // This Rule will create a single Argument |
307 | - if(count($argument)==0) $argument[0] = new Argument($token); |
|
308 | - } |
|
309 | - else |
|
315 | + if(count($argument)==0) { |
|
316 | + $argument[0] = new Argument($token); |
|
317 | + } |
|
318 | + } else |
|
310 | 319 | { |
311 | 320 | // This token does NOT match the flag of any defined parameter |
312 | 321 | // This Rule will NOT yield any arguments |
@@ -320,7 +329,9 @@ discard block |
||
320 | 329 | // Usually, the Argument will have already been created by another token in this Rule |
321 | 330 | |
322 | 331 | // If no new Argument created by this Rule yet, create one now |
323 | - if(count($argument)==0) $argument[0] = new Argument(); |
|
332 | + if(count($argument)==0) { |
|
333 | + $argument[0] = new Argument(); |
|
334 | + } |
|
324 | 335 | |
325 | 336 | // The new Argument's 'key' should be set by another token in this Rule |
326 | 337 | $argument[0]->setValue($token); |
@@ -332,7 +343,9 @@ discard block |
||
332 | 343 | // Usually, the Argument will have already been created by another token in this Rule |
333 | 344 | |
334 | 345 | // If no new Argument created by this Rule yet, create one now |
335 | - if(count($argument)==0) $argument[0] = new Argument(); |
|
346 | + if(count($argument)==0) { |
|
347 | + $argument[0] = new Argument(); |
|
348 | + } |
|
336 | 349 | |
337 | 350 | // Trim brackets from the $token (list) |
338 | 351 | $token = trim($token, "[]"); |
@@ -342,7 +355,9 @@ discard block |
||
342 | 355 | |
343 | 356 | // Use the $elements array as the 'value' for all new Argument created by this Rule |
344 | 357 | // Usually, this will only apply to a single Argument, unless this Rule contains ARGH_SEMANTICS_FLAGS |
345 | - foreach($argument as &$a) $a->setValue($elements); |
|
358 | + foreach($argument as &$a) { |
|
359 | + $a->setValue($elements); |
|
360 | + } |
|
346 | 361 | |
347 | 362 | break; |
348 | 363 | |
@@ -363,7 +378,9 @@ discard block |
||
363 | 378 | // $token matches an option of this ARGH_TYPE_COMMAND Parameter |
364 | 379 | |
365 | 380 | // If no new Argument created by this Rule yet, create one now |
366 | - if(count($argument)==0) $argument[0] = new Argument($p->getName(), $token); |
|
381 | + if(count($argument)==0) { |
|
382 | + $argument[0] = new Argument($p->getName(), $token); |
|
383 | + } |
|
367 | 384 | |
368 | 385 | // Stop searching this Parameters options |
369 | 386 | break; |
@@ -80,10 +80,18 @@ discard block |
||
80 | 80 | $syntax = null; |
81 | 81 | $semantics = null; |
82 | 82 | |
83 | - if( array_key_exists('name', $attributes) ) $name = $attributes['name']; |
|
84 | - if( array_key_exists('example', $attributes) ) $example = $attributes['example']; |
|
85 | - if( array_key_exists('syntax', $attributes) ) $syntax = $attributes['syntax']; |
|
86 | - if( array_key_exists('semantics', $attributes) ) $semantics = $attributes['semantics']; |
|
83 | + if( array_key_exists('name', $attributes) ) { |
|
84 | + $name = $attributes['name']; |
|
85 | + } |
|
86 | + if( array_key_exists('example', $attributes) ) { |
|
87 | + $example = $attributes['example']; |
|
88 | + } |
|
89 | + if( array_key_exists('syntax', $attributes) ) { |
|
90 | + $syntax = $attributes['syntax']; |
|
91 | + } |
|
92 | + if( array_key_exists('semantics', $attributes) ) { |
|
93 | + $semantics = $attributes['semantics']; |
|
94 | + } |
|
87 | 95 | |
88 | 96 | return new self($name, $example, $syntax, $semantics); |
89 | 97 | |
@@ -207,8 +215,7 @@ discard block |
||
207 | 215 | if( preg_match($this->syntax(), $string, $tokens) ) |
208 | 216 | { |
209 | 217 | return TRUE; |
210 | - } |
|
211 | - else |
|
218 | + } else |
|
212 | 219 | { |
213 | 220 | return FALSE; |
214 | 221 | } |
@@ -74,7 +74,9 @@ discard block |
||
74 | 74 | { |
75 | 75 | // Create a new string for $args $i thru $j |
76 | 76 | $list = ""; |
77 | - for($k=$i; $k<=$j; $k++) $list .= $args[$k]; |
|
77 | + for($k=$i; $k<=$j; $k++) { |
|
78 | + $list .= $args[$k]; |
|
79 | + } |
|
78 | 80 | |
79 | 81 | //echo "DEBUG: Replace elements $i thru $j with: $list\n"; |
80 | 82 | |
@@ -83,8 +85,7 @@ discard block |
||
83 | 85 | |
84 | 86 | // Stop searching for the end of the list |
85 | 87 | break; |
86 | - } |
|
87 | - else |
|
88 | + } else |
|
88 | 89 | { |
89 | 90 | throw new ArghException(__METHOD__ . ': Syntax Error: Invalid list.'); |
90 | 91 | } |
@@ -132,8 +133,7 @@ discard block |
||
132 | 133 | { |
133 | 134 | // Wrap (space containing) argument in quotes |
134 | 135 | $args[$i] = "'" . $args[$i] . "'"; |
135 | - } |
|
136 | - else |
|
136 | + } else |
|
137 | 137 | { |
138 | 138 | // Wrap (space containing) argument value - after '=' sign in quotes |
139 | 139 |
@@ -97,12 +97,24 @@ discard block |
||
97 | 97 | $options = array(); |
98 | 98 | |
99 | 99 | // Extract parameter attributes from array |
100 | - if( array_key_exists('name', $attributes) ) $name = $attributes['name']; |
|
101 | - if( array_key_exists('flag', $attributes) ) $flag = $attributes['flag']; |
|
102 | - if( array_key_exists('required', $attributes) ) $required = $attributes['required']; |
|
103 | - if( array_key_exists('default', $attributes) ) $default = $attributes['default']; |
|
104 | - if( array_key_exists('description', $attributes) ) $description = $attributes['description']; |
|
105 | - if( array_key_exists('options', $attributes) ) $options = $attributes['options']; |
|
100 | + if( array_key_exists('name', $attributes) ) { |
|
101 | + $name = $attributes['name']; |
|
102 | + } |
|
103 | + if( array_key_exists('flag', $attributes) ) { |
|
104 | + $flag = $attributes['flag']; |
|
105 | + } |
|
106 | + if( array_key_exists('required', $attributes) ) { |
|
107 | + $required = $attributes['required']; |
|
108 | + } |
|
109 | + if( array_key_exists('default', $attributes) ) { |
|
110 | + $default = $attributes['default']; |
|
111 | + } |
|
112 | + if( array_key_exists('description', $attributes) ) { |
|
113 | + $description = $attributes['description']; |
|
114 | + } |
|
115 | + if( array_key_exists('options', $attributes) ) { |
|
116 | + $options = $attributes['options']; |
|
117 | + } |
|
106 | 118 | |
107 | 119 | // Construct a new Parameter instance |
108 | 120 | // Late static binding results in new instance of (calling) subclass |
@@ -224,8 +236,7 @@ discard block |
||
224 | 236 | if(count($this->options) > 0) |
225 | 237 | { |
226 | 238 | return TRUE; |
227 | - } |
|
228 | - else |
|
239 | + } else |
|
229 | 240 | { |
230 | 241 | return FALSE; |
231 | 242 | } |
@@ -245,8 +256,7 @@ discard block |
||
245 | 256 | if( in_array($value, $this->options) ) |
246 | 257 | { |
247 | 258 | return TRUE; |
248 | - } |
|
249 | - else |
|
259 | + } else |
|
250 | 260 | { |
251 | 261 | return FALSE; |
252 | 262 | } |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | if( !empty( parent::getDefault() ) ) |
49 | 49 | { |
50 | 50 | return TRUE; |
51 | - } |
|
52 | - else |
|
51 | + } else |
|
53 | 52 | { |
54 | 53 | return FALSE; |
55 | 54 | } |
@@ -83,18 +82,15 @@ discard block |
||
83 | 82 | { |
84 | 83 | // null (no value) considered TRUE (this is how flags work; e.g. the presence of a boolean flag -x without value means TRUE) |
85 | 84 | $this->value = TRUE; |
86 | - } |
|
87 | - else if( FALSE == $value ) |
|
85 | + } else if( FALSE == $value ) |
|
88 | 86 | { |
89 | 87 | // 'Falsey' (boolean) FALSE, (int) 0, (float 0.0), (string) '0', (string) '', NULL |
90 | 88 | $this->value = FALSE; |
91 | - } |
|
92 | - else if( in_array($value, array('0', 'false', 'False', 'FALSE', 'off', 'Off', 'OFF')) ) |
|
89 | + } else if( in_array($value, array('0', 'false', 'False', 'FALSE', 'off', 'Off', 'OFF')) ) |
|
93 | 90 | { |
94 | 91 | // Certain character values should be considered to mean FALSE |
95 | 92 | $this->value = FALSE; |
96 | - } |
|
97 | - else |
|
93 | + } else |
|
98 | 94 | { |
99 | 95 | // Everything else considered TRUE |
100 | 96 | $this->value = TRUE; |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | if(is_array($value)) |
59 | 59 | { |
60 | 60 | $this->value = $value; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->value = array($value); |
65 | 64 | } |
@@ -88,11 +87,12 @@ discard block |
||
88 | 87 | { |
89 | 88 | // Append new single value to this Parameters value array |
90 | 89 | $this->value[] = $value; |
91 | - } |
|
92 | - else |
|
90 | + } else |
|
93 | 91 | { |
94 | 92 | // Append every new value to this Parameters value array |
95 | - foreach($value as $v) $this->value[] = $v; |
|
93 | + foreach($value as $v) { |
|
94 | + $this->value[] = $v; |
|
95 | + } |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 |
@@ -108,8 +108,7 @@ |
||
108 | 108 | if( is_array($this->value) ) |
109 | 109 | { |
110 | 110 | return TRUE; |
111 | - } |
|
112 | - else |
|
111 | + } else |
|
113 | 112 | { |
114 | 113 | return FALSE; |
115 | 114 | } |
@@ -139,8 +139,7 @@ discard block |
||
139 | 139 | if( $this->parameters->exists($key) ) |
140 | 140 | { |
141 | 141 | return TRUE; |
142 | - } |
|
143 | - else |
|
142 | + } else |
|
144 | 143 | { |
145 | 144 | return FALSE; |
146 | 145 | } |
@@ -213,8 +212,7 @@ discard block |
||
213 | 212 | |
214 | 213 | // Merge Arguments into Parameters |
215 | 214 | $this->parameters->mergeArguments($arguments); |
216 | - } |
|
217 | - catch(ArghException $e) |
|
215 | + } catch(ArghException $e) |
|
218 | 216 | { |
219 | 217 | throw $e; |
220 | 218 | } |
@@ -241,13 +239,11 @@ discard block |
||
241 | 239 | if( array_key_exists($i, $this->argv) ) |
242 | 240 | { |
243 | 241 | return $this->argv[$i]; |
244 | - } |
|
245 | - else |
|
242 | + } else |
|
246 | 243 | { |
247 | 244 | throw new ArghException('Invalid index for argv'); |
248 | 245 | } |
249 | - } |
|
250 | - else |
|
246 | + } else |
|
251 | 247 | { |
252 | 248 | return $this->argv; |
253 | 249 | } |
@@ -286,8 +282,7 @@ discard block |
||
286 | 282 | { |
287 | 283 | // Return the Parameters value |
288 | 284 | return $this->parameters->get($key)->getValue(); |
289 | - } |
|
290 | - else |
|
285 | + } else |
|
291 | 286 | { |
292 | 287 | // Return the Parameters default value, if any |
293 | 288 | return $this->parameters->get($key)->getDefault(); |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | if(is_array($value)) |
59 | 59 | { |
60 | 60 | $this->value = $value; |
61 | - } |
|
62 | - else |
|
61 | + } else |
|
63 | 62 | { |
64 | 63 | $this->value = array($value); |
65 | 64 | } |
@@ -88,11 +87,12 @@ discard block |
||
88 | 87 | { |
89 | 88 | // Append new single value to this Parameters value array |
90 | 89 | $this->value[] = $value; |
91 | - } |
|
92 | - else |
|
90 | + } else |
|
93 | 91 | { |
94 | 92 | // Append every new value to this Parameters value array |
95 | - foreach($value as $v) $this->value[] = $v; |
|
93 | + foreach($value as $v) { |
|
94 | + $this->value[] = $v; |
|
95 | + } |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 |