Skip to content

Commit 02a79eb

Browse files
committed
Fix up imports and namespaces
1 parent 4cf964c commit 02a79eb

26 files changed

Lines changed: 115 additions & 69 deletions

‎src/Comment_Command.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use WP_CLI\CommandWithDBObject;
4+
use WP_CLI\Fetchers\Comment as CommentFetcher;
35
use WP_CLI\Utils;
46

57
/**
@@ -26,7 +28,7 @@
2628
*
2729
* @package wp-cli
2830
*/
29-
class Comment_Command extends WP_CLI\CommandWithDBObject {
31+
class Comment_Command extends CommandWithDBObject {
3032

3133
protected $obj_type = 'comment';
3234
protected $obj_id_key = 'comment_ID';
@@ -40,7 +42,7 @@ class Comment_Command extends WP_CLI\CommandWithDBObject {
4042
];
4143

4244
public function __construct() {
43-
$this->fetcher = new \WP_CLI\Fetchers\Comment();
45+
$this->fetcher = new CommentFetcher();
4446
}
4547

4648
/**

‎src/Comment_Meta_Command.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use WP_CLI\CommandWithMeta;
4+
use WP_CLI\Fetchers\Comment as CommentFetcher;
5+
36
/**
47
* Adds, updates, deletes, and lists comment custom fields.
58
*
@@ -21,7 +24,7 @@
2124
* $ wp comment meta delete 123 description
2225
* Success: Deleted custom field.
2326
*/
24-
class Comment_Meta_Command extends WP_CLI\CommandWithMeta {
27+
class Comment_Meta_Command extends CommandWithMeta {
2528
protected $meta_type = 'comment';
2629

2730
/**
@@ -104,7 +107,7 @@ protected function delete_metadata( $object_id, $meta_key, $meta_value = '' ) {
104107
* @param int
105108
*/
106109
protected function check_object_id( $object_id ) {
107-
$fetcher = new WP_CLI\Fetchers\Comment();
110+
$fetcher = new CommentFetcher();
108111
$comment = $fetcher->get_check( $object_id );
109112
return $comment->comment_ID;
110113
}

‎src/Menu_Command.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use WP_CLI\Formatter;
34
use WP_CLI\Utils;
45

56
/**
@@ -69,7 +70,7 @@ public function create( $args, $assoc_args ) {
6970

7071
} else {
7172

72-
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' ) ) {
73+
if ( Utils\get_flag_value( $assoc_args, 'porcelain' ) ) {
7374
WP_CLI::line( $menu_id );
7475
} else {
7576
WP_CLI::success( "Created menu $menu_id." );
@@ -196,7 +197,7 @@ function( $o ) {
196197
}
197198

198199
protected function get_formatter( &$assoc_args ) {
199-
return new \WP_CLI\Formatter( $assoc_args, $this->obj_fields, $this->obj_type );
200+
return new Formatter( $assoc_args, $this->obj_fields, $this->obj_type );
200201
}
201202

202203
}

‎src/Menu_Item_Command.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use WP_CLI\Formatter;
34
use WP_CLI\Utils;
45

56
/**
@@ -503,7 +504,7 @@ private function add_or_update_item( $method, $type, $args, $assoc_args ) {
503504
}
504505

505506
protected function get_formatter( &$assoc_args ) {
506-
return new \WP_CLI\Formatter( $assoc_args, $this->obj_fields );
507+
return new Formatter( $assoc_args, $this->obj_fields );
507508
}
508509

509510
}

‎src/Menu_Location_Command.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use WP_CLI\Formatter;
4+
use WP_CLI\Utils;
5+
36
/**
47
* Assigns, removes, and lists a menu's locations.
58
*
@@ -66,13 +69,13 @@ public function list_( $_, $assoc_args ) {
6669
$locations = get_registered_nav_menus();
6770
$location_objs = [];
6871
foreach ( $locations as $location => $description ) {
69-
$location_obj = new \stdClass();
72+
$location_obj = new stdClass();
7073
$location_obj->location = $location;
7174
$location_obj->description = $description;
7275
$location_objs[] = $location_obj;
7376
}
7477

75-
$formatter = new \WP_CLI\Formatter( $assoc_args, [ 'location', 'description' ] );
78+
$formatter = new Formatter( $assoc_args, [ 'location', 'description' ] );
7679

7780
if ( 'ids' === $formatter->format ) {
7881
$ids = array_map(
@@ -155,7 +158,7 @@ public function remove( $args, $_ ) {
155158
}
156159

157160
$locations = get_nav_menu_locations();
158-
if ( WP_CLI\Utils\get_flag_value( $locations, $location ) !== $menu->term_id ) {
161+
if ( Utils\get_flag_value( $locations, $location ) !== $menu->term_id ) {
159162
WP_CLI::error( "Menu isn't assigned to location." );
160163
}
161164

‎src/Network_Meta_Command.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use WP_CLI\CommandWithMeta;
4+
35
/**
46
* Gets, adds, updates, deletes, and lists network custom fields.
57
*
@@ -11,6 +13,6 @@
1113
* 0 => 'supervisor',
1214
* )
1315
*/
14-
class Network_Meta_Command extends \WP_CLI\CommandWithMeta {
16+
class Network_Meta_Command extends CommandWithMeta {
1517
protected $meta_type = 'site';
1618
}

‎src/Option_Command.php‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use WP_CLI\Entity\RecursiveDataStructureTraverser;
4+
use WP_CLI\Formatter;
45
use WP_CLI\Utils;
56
use WP_CLI\Entity\Utils as EntityUtils;
67

@@ -337,7 +338,7 @@ function ( $a, $b ) use ( $orderby, $order ) {
337338
if ( Utils\get_flag_value( $assoc_args, 'format' ) === 'total_bytes' ) {
338339
WP_CLI::line( $results[0]->size_bytes );
339340
} else {
340-
$formatter = new \WP_CLI\Formatter(
341+
$formatter = new Formatter(
341342
$assoc_args,
342343
$fields
343344
);
@@ -509,7 +510,7 @@ function( $key ) {
509510

510511
try {
511512
$value = $traverser->get( $key_path );
512-
} catch ( \Exception $e ) {
513+
} catch ( Exception $e ) {
513514
die( 1 );
514515
}
515516

@@ -582,7 +583,7 @@ function( $key ) {
582583

583584
try {
584585
$traverser->$action( $key_path, $patch_value );
585-
} catch ( \Exception $e ) {
586+
} catch ( Exception $e ) {
586587
WP_CLI::error( $e->getMessage() );
587588
}
588589

‎src/Post_Command.php‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
use WP_CLI\CommandWithDBObject;
4+
use WP_CLI\Entity\Utils as EntityUtils;
5+
use WP_CLI\Fetchers\Post as PostFetcher;
6+
use WP_CLI\Fetchers\User as UserFetcher;
37
use WP_CLI\Utils;
48

59
/**
@@ -21,7 +25,7 @@
2125
*
2226
* @package wp-cli
2327
*/
24-
class Post_Command extends WP_CLI\CommandWithDBObject {
28+
class Post_Command extends CommandWithDBObject {
2529

2630
protected $obj_type = 'post';
2731
protected $obj_fields = [
@@ -33,7 +37,7 @@ class Post_Command extends WP_CLI\CommandWithDBObject {
3337
];
3438

3539
public function __construct() {
36-
$this->fetcher = new \WP_CLI\Fetchers\Post();
40+
$this->fetcher = new PostFetcher();
3741
}
3842

3943
/**
@@ -372,7 +376,7 @@ public function edit( $args, $_ ) {
372376
$r = $this->_edit( $post->post_content, "WP-CLI post {$post->ID}" );
373377

374378
if ( false === $r ) {
375-
\WP_CLI::warning( 'No change made to post content.', 'Aborted' );
379+
WP_CLI::warning( 'No change made to post content.', 'Aborted' );
376380
} else {
377381
$this->update( $args, [ 'post_content' => $r ] );
378382
}
@@ -750,12 +754,12 @@ public function generate( $args, $assoc_args ) {
750754
}
751755

752756
if ( $post_author ) {
753-
$user_fetcher = new \WP_CLI\Fetchers\User;
757+
$user_fetcher = new UserFetcher;
754758
$post_author = $user_fetcher->get_check( $post_author )->ID;
755759
}
756760

757761
if ( Utils\get_flag_value( $assoc_args, 'post_content' ) ) {
758-
if ( ! \WP_CLI\Entity\Utils::has_stdin() ) {
762+
if ( ! EntityUtils::has_stdin() ) {
759763
WP_CLI::error( 'The parameter `post_content` reads from STDIN.' );
760764
}
761765

@@ -854,7 +858,7 @@ private function read_from_file_or_stdin( $arg ) {
854858
if ( '-' !== $arg ) {
855859
$readfile = $arg;
856860
if ( ! file_exists( $readfile ) || ! is_file( $readfile ) ) {
857-
\WP_CLI::error( "Unable to read content from '$readfile'." );
861+
WP_CLI::error( "Unable to read content from '$readfile'." );
858862
}
859863
} else {
860864
$readfile = 'php://stdin';

‎src/Post_Meta_Command.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use WP_CLI\CommandWithMeta;
4+
use WP_CLI\Fetchers\Post as PostFetcher;
5+
36
/**
47
* Adds, updates, deletes, and lists post custom fields.
58
*
@@ -21,7 +24,7 @@
2124
* $ wp post meta delete 123 _wp_page_template
2225
* Success: Deleted custom field.
2326
*/
24-
class Post_Meta_Command extends \WP_CLI\CommandWithMeta {
27+
class Post_Meta_Command extends CommandWithMeta {
2528
protected $meta_type = 'post';
2629

2730
/**
@@ -30,7 +33,7 @@ class Post_Meta_Command extends \WP_CLI\CommandWithMeta {
3033
* @param int
3134
*/
3235
protected function check_object_id( $object_id ) {
33-
$fetcher = new WP_CLI\Fetchers\Post();
36+
$fetcher = new PostFetcher();
3437
$post = $fetcher->get_check( $object_id );
3538
return $post->ID;
3639
}

‎src/Post_Term_Command.php‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use WP_CLI\CommandWithTerms;
4+
use WP_CLI\Fetchers\Post as PostFetcher;
5+
36
/**
47
* Adds, updates, removes, and lists post terms.
58
*
@@ -9,11 +12,11 @@
912
* $ wp post term set 123 test category
1013
* Success: Set terms.
1114
*/
12-
class Post_Term_Command extends \WP_CLI\CommandWithTerms {
15+
class Post_Term_Command extends CommandWithTerms {
1316
protected $obj_type = 'post';
1417

1518
public function __construct() {
16-
$this->fetcher = new WP_CLI\Fetchers\Post();
19+
$this->fetcher = new PostFetcher();
1720
}
1821

1922
protected function get_object_type() {

0 commit comments

Comments
 (0)