@@ -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 @phpstan-ignore-line
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 ;
@@ -251,9 +252,14 @@ private function validate_args( $args ) {
251252 }
252253 }
253254
255+ /**
256+ * @param string $path
257+ *
258+ * @phpstan-ignore method.unused
259+ */
254260 private function check_dir ( $ path ) {
255261 if ( empty ( $ path ) ) {
256- $ path = getcwd ();
262+ $ path = ( string ) getcwd ();
257263 } elseif ( ! is_dir ( $ path ) ) {
258264 WP_CLI ::error ( sprintf ( "The directory '%s' does not exist. " , $ path ) );
259265 } elseif ( ! is_writable ( $ path ) ) {
@@ -265,34 +271,49 @@ private function check_dir( $path ) {
265271 return true ;
266272 }
267273
274+ /**
275+ * @param string $date
276+ *
277+ * @phpstan-ignore method.unused
278+ */
268279 private function check_start_date ( $ date ) {
269280 if ( null === $ date ) {
270281 return true ;
271282 }
272283
273284 $ time = strtotime ( $ date );
274- if ( ! empty ( $ date ) && ! $ time ) {
285+ if ( ! empty ( $ date ) && false === $ time ) {
275286 WP_CLI ::warning ( sprintf ( 'The start_date %s is invalid. ' , $ date ) );
276287 return false ;
277288 }
278- $ 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
279290 return true ;
280291 }
281292
293+ /**
294+ * @param string $date
295+ *
296+ * @phpstan-ignore method.unused
297+ */
282298 private function check_end_date ( $ date ) {
283299 if ( null === $ date ) {
284300 return true ;
285301 }
286302
287303 $ time = strtotime ( $ date );
288- if ( ! empty ( $ date ) && ! $ time ) {
304+ if ( ! empty ( $ date ) && false === $ time ) {
289305 WP_CLI ::warning ( sprintf ( 'The end_date %s is invalid. ' , $ date ) );
290306 return false ;
291307 }
292- $ 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
293309 return true ;
294310 }
295311
312+ /**
313+ * @param string $post_type
314+ *
315+ * @phpstan-ignore method.unused
316+ */
296317 private function check_post_type ( $ post_type ) {
297318 if ( null === $ post_type || 'any ' === $ post_type ) {
298319 return true ;
@@ -317,6 +338,11 @@ private function check_post_type( $post_type ) {
317338 return true ;
318339 }
319340
341+ /**
342+ * @param string $post_type
343+ *
344+ * @phpstan-ignore method.unused
345+ */
320346 private function check_post_type__not_in ( $ post_type ) {
321347 if ( null === $ post_type ) {
322348 return true ;
@@ -341,6 +367,11 @@ private function check_post_type__not_in( $post_type ) {
341367 return true ;
342368 }
343369
370+ /**
371+ * @param string $post__in
372+ *
373+ * @phpstan-ignore method.unused
374+ */
344375 private function check_post__in ( $ post__in ) {
345376 if ( null === $ post__in ) {
346377 return true ;
@@ -357,6 +388,11 @@ private function check_post__in( $post__in ) {
357388 return true ;
358389 }
359390
391+ /**
392+ * @param string $start_id
393+ *
394+ * @phpstan-ignore method.unused
395+ */
360396 private function check_start_id ( $ start_id ) {
361397 if ( null === $ start_id ) {
362398 return true ;
@@ -374,14 +410,19 @@ private function check_start_id( $start_id ) {
374410 return true ;
375411 }
376412
413+ /**
414+ * @param string $author
415+ *
416+ * @phpstan-ignore method.unused
417+ */
377418 private function check_author ( $ author ) {
378419 if ( null === $ author ) {
379420 return true ;
380421 }
381422
382423 // phpcs:ignore WordPress.WP.DeprecatedFunctions.get_users_of_blogFound -- Fallback.
383- $ authors = function_exists ( 'get_users ' ) ? get_users () : get_users_of_blog ();
384- 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 ) ) {
385426 WP_CLI ::warning ( 'Could not find any authors in this blog. ' );
386427 return false ;
387428 }
@@ -407,6 +448,9 @@ private function check_author( $author ) {
407448 return true ;
408449 }
409450
451+ /**
452+ * @phpstan-ignore method.unused
453+ */
410454 private function check_max_num_posts ( $ num ) {
411455 if ( null !== $ num && ( ! is_numeric ( $ num ) || $ num <= 0 ) ) {
412456 WP_CLI ::warning ( 'max_num_posts should be a positive integer. ' );
@@ -418,6 +462,11 @@ private function check_max_num_posts( $num ) {
418462 return true ;
419463 }
420464
465+ /**
466+ * @param string $category
467+ *
468+ * @phpstan-ignore method.unused
469+ */
421470 private function check_category ( $ category ) {
422471 if ( null === $ category ) {
423472 return true ;
@@ -428,14 +477,19 @@ private function check_category( $category ) {
428477 }
429478
430479 $ term = category_exists ( $ category );
431- if ( empty ( $ term ) || is_wp_error ( $ term ) ) {
480+ if ( empty ( $ term ) ) {
432481 WP_CLI ::warning ( sprintf ( 'Could not find a category matching %s. ' , $ category ) );
433482 return false ;
434483 }
435484 $ this ->export_args ['category ' ] = $ category ;
436485 return true ;
437486 }
438487
488+ /**
489+ * @param string $status
490+ *
491+ * @phpstan-ignore method.unused
492+ */
439493 private function check_post_status ( $ status ) {
440494 if ( null === $ status ) {
441495 return true ;
@@ -456,6 +510,11 @@ private function check_post_status( $status ) {
456510 return true ;
457511 }
458512
513+ /**
514+ * @param string|null $skip
515+ *
516+ * @phpstan-ignore method.unused
517+ */
459518 private function check_skip_comments ( $ skip ) {
460519 if ( null === $ skip ) {
461520 return true ;
@@ -469,6 +528,11 @@ private function check_skip_comments( $skip ) {
469528 return true ;
470529 }
471530
531+ /**
532+ * @param string $size
533+ *
534+ * @phpstan-ignore method.unused
535+ */
472536 private function check_max_file_size ( $ size ) {
473537 if ( ! is_numeric ( $ size ) ) {
474538 WP_CLI ::warning ( 'max_file_size should be numeric. ' );
@@ -480,6 +544,11 @@ private function check_max_file_size( $size ) {
480544 return true ;
481545 }
482546
547+ /**
548+ * @param string $once
549+ *
550+ * @phpstan-ignore method.unused
551+ */
483552 private function check_include_once ( $ once ) {
484553 if ( null === $ once ) {
485554 return true ;
@@ -498,6 +567,11 @@ private function check_include_once( $once ) {
498567 return true ;
499568 }
500569
570+ /**
571+ * @param string $allow_orphan_terms
572+ *
573+ * @phpstan-ignore method.unused
574+ */
501575 private function check_allow_orphan_terms ( $ allow_orphan_terms ) {
502576 if ( null === $ allow_orphan_terms ) {
503577 return true ;
0 commit comments