@@ -446,6 +446,14 @@ public function list_( $args, $assoc_args ) {
446446 if ( 'dotenv ' === $ assoc_args ['format ' ] ) {
447447 return array_walk ( $ values , array ( $ this , 'print_dotenv ' ) );
448448 }
449+
450+ if ( ! $ strict ) {
451+ foreach ( $ values as $ index => $ value ) {
452+ if ( is_bool ( $ value ['value ' ] ) ) {
453+ $ values [ $ index ]['value ' ] = $ value ['value ' ] ? 'true ' : 'false ' ;
454+ }
455+ }
456+ }
449457
450458 Utils \format_items ( $ assoc_args ['format ' ], $ values , $ assoc_args ['fields ' ] );
451459 }
@@ -494,6 +502,10 @@ public function list_( $args, $assoc_args ) {
494502 */
495503 public function get ( $ args , $ assoc_args ) {
496504 $ value = $ this ->get_value ( $ assoc_args , $ args );
505+ if ( is_bool ( $ value ) ) {
506+ $ value = $ value ? 'true ' : 'false ' ;
507+ }
508+
497509 WP_CLI ::print_value ( $ value , $ assoc_args );
498510 }
499511
@@ -534,7 +546,7 @@ public function get( $args, $assoc_args ) {
534546 public function is_true ( $ args , $ assoc_args ) {
535547 $ value = $ this ->get_value ( $ assoc_args , $ args );
536548
537- if ( boolval ( $ value ) && ' false ' !== $ value ) { // Second condition is needed because we have literal "false" as string and boolval('false') is true.
549+ if ( boolval ( $ value ) ) {
538550 WP_CLI ::halt ( 0 );
539551 }
540552 WP_CLI ::halt ( 1 );
@@ -578,14 +590,7 @@ private static function get_wp_config_vars( $wp_config_path = '' ) {
578590 ];
579591 }
580592
581- $ merged_vars = array_merge ( $ wp_config_vars , $ wp_config_constants , $ wp_config_includes_array );
582- // Modify boolean values for easier handling.
583- foreach ( $ merged_vars as $ index => $ var ) {
584- if ( 'boolean ' === gettype ( $ var ['value ' ] ) ) {
585- $ merged_vars [ $ index ]['value ' ] = $ var ['value ' ] ? 'true ' : 'false ' ;
586- }
587- }
588- return $ merged_vars ;
593+ return array_merge ( $ wp_config_vars , $ wp_config_constants , $ wp_config_includes_array );
589594 }
590595
591596 /**
0 commit comments