@@ -392,8 +392,6 @@ public function parse() {
392392 $ this ->_parsed = array ();
393393 $ this ->_lexer = new Lexer ($ this ->_input );
394394
395- $ this ->_applyDefaults ();
396-
397395 foreach ($ this ->_lexer as $ argument ) {
398396 if ($ this ->_parseFlag ($ argument )) {
399397 continue ;
@@ -410,24 +408,6 @@ public function parse() {
410408 }
411409 }
412410
413- /**
414- * This applies the default values, if any, of all of the
415- * flags and options, so that if there is a default value
416- * it will be available.
417- */
418- private function _applyDefaults () {
419- foreach ($ this ->_flags as $ flag => $ settings ) {
420- $ this [$ flag ] = $ settings ['default ' ];
421- }
422-
423- foreach ($ this ->_options as $ option => $ settings ) {
424- // If the default is 0 we should still let it be set.
425- if (!empty ($ settings ['default ' ]) || $ settings ['default ' ] === 0 ) {
426- $ this [$ option ] = $ settings ['default ' ];
427- }
428- }
429- }
430-
431411 private function _warn ($ message ) {
432412 trigger_error ('[ ' . __CLASS__ .'] ' . $ message , E_USER_WARNING );
433413 }
@@ -459,7 +439,7 @@ private function _parseOption($option) {
459439 if ($ this ->_lexer ->end () || !$ this ->_lexer ->peek ->isValue ) {
460440 $ optionSettings = $ this ->getOption ($ option ->key );
461441
462- if (empty ($ optionSettings ['default ' ]) && $ optionSettings !== 0 ) {
442+ if (empty ($ optionSettings ['default ' ])) {
463443 // Oops! Got no value and no default , throw a warning and continue.
464444 $ this ->_warn ('no value given for ' . $ option ->raw );
465445 $ this [$ option ->key ] = null ;
@@ -486,3 +466,4 @@ private function _parseOption($option) {
486466 return true ;
487467 }
488468}
469+
0 commit comments