@@ -181,7 +181,7 @@ public function __invoke( $_, $assoc_args ) {
181181 'wp_export_new_file ' ,
182182 static function ( $ file_path ) {
183183 WP_CLI ::log ( sprintf ( 'Writing to file %s ' , $ file_path ) );
184- Utils \wp_clear_object_cache ();
184+ Utils \wp_clear_object_cache (); // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.wp_clear_object_cacheDeprecatedRemoved
185185 }
186186 );
187187
@@ -190,15 +190,15 @@ static function ( $file_path ) {
190190 wp_export (
191191 [
192192 'filters ' => $ this ->export_args ,
193- 'writer ' => ' WP_Export_File_Writer ' ,
193+ 'writer ' => WP_Export_File_Writer::class ,
194194 'writer_args ' => 'php://output ' ,
195195 ]
196196 );
197197 } else {
198198 wp_export (
199199 [
200200 'filters ' => $ this ->export_args ,
201- 'writer ' => ' WP_Export_Split_Files_Writer ' ,
201+ 'writer ' => WP_Export_Split_Files_Writer::class ,
202202 'writer_args ' => [
203203 'max_file_size ' => $ this ->max_file_size ,
204204 'destination_directory ' => $ this ->wxr_path ,
@@ -234,6 +234,7 @@ private function validate_args( $args ) {
234234
235235 foreach ( $ args as $ key => $ value ) {
236236 if ( is_callable ( [ $ this , 'check_ ' . $ key ] ) ) {
237+ /** @phpstan-ignore argument.type */
237238 $ result = call_user_func ( [ $ this , 'check_ ' . $ key ], $ value );
238239 if ( false === $ result ) {
239240 $ has_errors = true ;
@@ -281,11 +282,11 @@ private function check_start_date( $date ) {
281282 }
282283
283284 $ time = strtotime ( $ date );
284- if ( ! empty ( $ date ) && ! $ time ) {
285+ if ( ! empty ( $ date ) && false === $ time ) {
285286 WP_CLI ::warning ( sprintf ( 'The start_date %s is invalid. ' , $ date ) );
286287 return false ;
287288 }
288- $ this ->export_args ['start_date ' ] = date ( 'Y-m-d ' , $ time ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
289+ $ this ->export_args ['start_date ' ] = date ( 'Y-m-d ' , ( int ) $ time ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
289290 return true ;
290291 }
291292
@@ -300,11 +301,11 @@ private function check_end_date( $date ) {
300301 }
301302
302303 $ time = strtotime ( $ date );
303- if ( ! empty ( $ date ) && ! $ time ) {
304+ if ( ! empty ( $ date ) && false === $ time ) {
304305 WP_CLI ::warning ( sprintf ( 'The end_date %s is invalid. ' , $ date ) );
305306 return false ;
306307 }
307- $ this ->export_args ['end_date ' ] = date ( 'Y-m-d ' , $ time ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
308+ $ this ->export_args ['end_date ' ] = date ( 'Y-m-d ' , ( int ) $ time ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
308309 return true ;
309310 }
310311
@@ -420,8 +421,8 @@ private function check_author( $author ) {
420421 }
421422
422423 // phpcs:ignore WordPress.WP.DeprecatedFunctions.get_users_of_blogFound -- Fallback.
423- $ authors = function_exists ( 'get_users ' ) ? get_users () : get_users_of_blog ();
424- if ( empty ( $ authors ) || is_wp_error ( $ authors ) ) {
424+ $ authors = function_exists ( 'get_users ' ) ? get_users () : get_users_of_blog (); // phpstan-ignore-line
425+ if ( empty ( $ authors ) ) {
425426 WP_CLI ::warning ( 'Could not find any authors in this blog. ' );
426427 return false ;
427428 }
@@ -447,6 +448,9 @@ private function check_author( $author ) {
447448 return true ;
448449 }
449450
451+ /**
452+ * @phpstan-ignore method.unused
453+ */
450454 private function check_max_num_posts ( $ num ) {
451455 if ( null !== $ num && ( ! is_numeric ( $ num ) || $ num <= 0 ) ) {
452456 WP_CLI ::warning ( 'max_num_posts should be a positive integer. ' );
@@ -473,7 +477,7 @@ private function check_category( $category ) {
473477 }
474478
475479 $ term = category_exists ( $ category );
476- if ( empty ( $ term ) || is_wp_error ( $ term ) ) {
480+ if ( empty ( $ term ) ) {
477481 WP_CLI ::warning ( sprintf ( 'Could not find a category matching %s. ' , $ category ) );
478482 return false ;
479483 }
@@ -492,7 +496,7 @@ private function check_post_status( $status ) {
492496 }
493497
494498 $ stati = get_post_stati ();
495- if ( empty ( $ stati ) || is_wp_error ( $ stati ) ) {
499+ if ( empty ( $ stati ) ) {
496500 WP_CLI ::warning ( 'Could not find any post stati. ' );
497501 return false ;
498502 }
0 commit comments