OSDN Git Service

Use `wp_parse_args()` where we can
authorJohn Blackbourn <johnbillion@gmail.com>
Tue, 6 Aug 2013 17:38:26 +0000 (18:38 +0100)
committerJohn Blackbourn <johnbillion@gmail.com>
Tue, 6 Aug 2013 17:38:26 +0000 (18:38 +0100)
php/WP_CLI/CommandWithUpgrade.php
php/commands/post.php

index aaac62e..6331de3 100644 (file)
@@ -219,19 +219,12 @@ abstract class CommandWithUpgrade extends \WP_CLI_Command {
                }
        }
 
-       protected function _list( $_, $format ) {
+       protected function _list( $_, $assoc_args ) {
                $values = array(
                        'format' => 'table',
                        'fields' => $this->fields
                );
-
-               foreach ( $values as $key => &$value ) {
-                       if ( isset( $format[ $key ] ) ) {
-                               $value = $format[ $key ];
-                               unset( $format[ $key ] );
-                       }
-               }
-               unset( $value );
+               $values = wp_parse_args( $assoc_args, $values );
 
                $all_items = $this->get_all_items();
                $items = $this->create_objects( $all_items );
index 1792830..7465cc5 100644 (file)
@@ -168,14 +168,7 @@ class Post_Command extends \WP_CLI\CommandWithDBObject {
                        'format' => 'table',
                        'fields' => $this->fields
                );
-
-               foreach ( $values as $key => &$value ) {
-                       if ( isset( $assoc_args[ $key ] ) ) {
-                               $value = $assoc_args[ $key ];
-                               unset( $assoc_args[ $key ] );
-                       }
-               }
-               unset( $value );
+               $values = wp_parse_args( $assoc_args, $values );
 
                foreach ( $assoc_args as $key => $value ) {
                        if ( true === $value )