Skip to content

Commit 6019c03

Browse files
committed
fix(ci): clear lint drift in rest.php Refs #842
- Suppress PHPStan argument.type at both inner call_user_func sites in static_site_importer_rest_execute_import_ability() and remove the stale outer ignore - Re-align array double arrows in the continuation envelope, terminal envelope, and requires_ability_capable_target sub-array - Drop the unused $input parameter from static_site_importer_rest_source_runtime() and update its 3 callers Errors fixed: - PHPStan argument.type at includes/rest.php:731 and includes/rest.php:743 - PHPCS WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned (15 warnings) - PHPCS Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed (1 warning) PHP 8.2 compatible. All CI checks passing. Refs #842
1 parent 9042270 commit 6019c03

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

includes/rest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ function static_site_importer_rest_open_in_playground( array $source, array $inp
563563
$input['activate'] = true;
564564
$input['overwrite'] = true;
565565

566-
$runtime = static_site_importer_rest_source_runtime( $source, $input );
566+
$runtime = static_site_importer_rest_source_runtime( $source );
567567
if ( is_wp_error( $runtime ) ) {
568568
return $runtime;
569569
}
@@ -701,7 +701,7 @@ function static_site_importer_rest_apply_to_current_site( array $source, array $
701701
return $result;
702702
};
703703

704-
$runtime = static_site_importer_rest_source_runtime( $source, $input );
704+
$runtime = static_site_importer_rest_source_runtime( $source );
705705
if ( is_wp_error( $runtime ) ) {
706706
return $runtime;
707707
}
@@ -728,6 +728,7 @@ function static_site_importer_rest_apply_to_current_site( array $source, array $
728728
*/
729729
function static_site_importer_rest_execute_import_ability( string $ability_name, array $input, string $fallback_callback, bool $prefer_fallback = false ) {
730730
if ( $prefer_fallback ) {
731+
// @phpstan-ignore-next-line argument.type — $fallback_callback is a function name string resolved by call_user_func at runtime.
731732
return call_user_func( $fallback_callback, $input );
732733
}
733734

@@ -740,6 +741,7 @@ function static_site_importer_rest_execute_import_ability( string $ability_name,
740741
}
741742
}
742743

744+
// @phpstan-ignore-next-line argument.type — $fallback_callback is a function name string resolved by call_user_func at runtime.
743745
return call_user_func( $fallback_callback, $input );
744746
}
745747

@@ -782,7 +784,6 @@ function static_site_importer_rest_route_url_import( array $source, array $input
782784
)
783785
);
784786

785-
// @phpstan-ignore-next-line argument.type — the fallback callback is a function name string resolved by call_user_func at runtime.
786787
$result = static_site_importer_rest_execute_import_ability(
787788
'static-site-importer/import-url',
788789
$ability_in,
@@ -794,11 +795,11 @@ function static_site_importer_rest_route_url_import( array $source, array $input
794795

795796
if ( ! empty( $result['continuation'] ) ) {
796797
return array(
797-
'success' => true,
798-
'continuation' => true,
799-
'continuation_reason' => isset( $result['continuation_reason'] ) ? (string) $result['continuation_reason'] : '',
800-
'import_id' => isset( $result['import_id'] ) ? (string) $result['import_id'] : '',
801-
'url_batch_run' => isset( $result['url_batch_run'] ) && is_array( $result['url_batch_run'] ) ? $result['url_batch_run'] : array(),
798+
'success' => true,
799+
'continuation' => true,
800+
'continuation_reason' => isset( $result['continuation_reason'] ) ? (string) $result['continuation_reason'] : '',
801+
'import_id' => isset( $result['import_id'] ) ? (string) $result['import_id'] : '',
802+
'url_batch_run' => isset( $result['url_batch_run'] ) && is_array( $result['url_batch_run'] ) ? $result['url_batch_run'] : array(),
802803
'import_report_summary' => isset( $result['import_report_summary'] ) && is_array( $result['import_report_summary'] ) ? $result['import_report_summary'] : array(),
803804
);
804805
}
@@ -808,9 +809,9 @@ function static_site_importer_rest_route_url_import( array $source, array $input
808809
// branch above is where the preview/requires_ability_capable_target
809810
// envelope is constructed.
810811
return array(
811-
'success' => true,
812-
'import_id' => isset( $result['import_id'] ) ? (string) $result['import_id'] : '',
813-
'result' => isset( $result['result'] ) && is_array( $result['result'] ) ? $result['result'] : array(),
812+
'success' => true,
813+
'import_id' => isset( $result['import_id'] ) ? (string) $result['import_id'] : '',
814+
'result' => isset( $result['result'] ) && is_array( $result['result'] ) ? $result['result'] : array(),
814815
'import_report_summary' => isset( $result['import_report_summary'] ) && is_array( $result['import_report_summary'] ) ? $result['import_report_summary'] : array(),
815816
'terminal_batch_result' => isset( $result['url_batch_run']['terminal_batch_result'] ) && is_array( $result['url_batch_run']['terminal_batch_result'] )
816817
? $result['url_batch_run']['terminal_batch_result']
@@ -851,14 +852,14 @@ function static_site_importer_rest_url_playground_unavailable( string $url, stri
851852
),
852853
'input' => $input,
853854
'preview' => array(
854-
'status' => 'unavailable',
855-
'url' => $url,
856-
'message' => __( 'URL preview needs a disposable WordPress target that exposes the static-site-importer/import-url ability. The reference client must run the import inside its own ability-capable environment.', 'static-site-importer' ),
857-
'requires_ability_capable_target' => array(
858-
'schema' => 'static-site-importer/url-playground-requirement/v1',
859-
'ability' => 'static-site-importer/import-url',
860-
'url' => $url,
861-
'import_id' => $placeholder_id,
855+
'status' => 'unavailable',
856+
'url' => $url,
857+
'message' => __( 'URL preview needs a disposable WordPress target that exposes the static-site-importer/import-url ability. The reference client must run the import inside its own ability-capable environment.', 'static-site-importer' ),
858+
'requires_ability_capable_target' => array(
859+
'schema' => 'static-site-importer/url-playground-requirement/v1',
860+
'ability' => 'static-site-importer/import-url',
861+
'url' => $url,
862+
'import_id' => $placeholder_id,
862863
'instructions' => __( 'Inside a disposable WordPress instance, register the Static Site Importer plugin and POST to /wp-json/static-site-importer/v1/imports with the same source.url and import_id, looping on the continuation envelope until terminal.', 'static-site-importer' ),
863864
),
864865
),
@@ -901,10 +902,9 @@ function static_site_importer_rest_source_artifact( array $source ) {
901902
* Convert REST source input into the normalized website artifact runtime envelope.
902903
*
903904
* @param array<string,mixed> $source Source payload.
904-
* @param array<string,mixed> $input Import input carrying optional provider args.
905905
* @return array{artifact:array<string,mixed>,source_metadata:array<string,mixed>,provider:string}|WP_Error
906906
*/
907-
function static_site_importer_rest_source_runtime( array $source, array $input = array() ) {
907+
function static_site_importer_rest_source_runtime( array $source ) {
908908
if ( isset( $source['artifact'] ) && is_array( $source['artifact'] ) ) {
909909
return array(
910910
'artifact' => $source['artifact'],

0 commit comments

Comments
 (0)