From afd13ad988e75f3fb15dbfa91a6d4eb49865d20e Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 8 Oct 2024 11:14:36 -0400 Subject: [PATCH] explat: Fix Phan issues (#39443) Add some missing `use` directives and add `WP_Error` to one return declaration. --- projects/packages/explat/.phan/baseline.php | 8 +------- .../explat/changelog/fix-phan-errors-in-packages-explat | 5 +++++ projects/packages/explat/src/class-rest-controller.php | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 projects/packages/explat/changelog/fix-phan-errors-in-packages-explat diff --git a/projects/packages/explat/.phan/baseline.php b/projects/packages/explat/.phan/baseline.php index 40b84d3f8b7da..3df50068147ad 100644 --- a/projects/packages/explat/.phan/baseline.php +++ b/projects/packages/explat/.phan/baseline.php @@ -8,15 +8,9 @@ * (can be combined with --load-baseline) */ return [ - // # Issue statistics: - // PhanTypeArraySuspicious : 3 occurrences - // PhanTypeMismatchReturn : 3 occurrences - // PhanUndeclaredTypeParameter : 1 occurrence - // PhanUndeclaredTypeReturnType : 1 occurrence - + // This baseline has no suppressions // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'src/class-rest-controller.php' => ['PhanTypeArraySuspicious', 'PhanTypeMismatchReturn', 'PhanUndeclaredTypeParameter', 'PhanUndeclaredTypeReturnType'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. // (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases) diff --git a/projects/packages/explat/changelog/fix-phan-errors-in-packages-explat b/projects/packages/explat/changelog/fix-phan-errors-in-packages-explat new file mode 100644 index 0000000000000..21dd20666788b --- /dev/null +++ b/projects/packages/explat/changelog/fix-phan-errors-in-packages-explat @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Add missing `use` and one return type to fix Phan issues. No change to functionality. + + diff --git a/projects/packages/explat/src/class-rest-controller.php b/projects/packages/explat/src/class-rest-controller.php index 9ee70dfaccc07..cd80d6d2157d7 100644 --- a/projects/packages/explat/src/class-rest-controller.php +++ b/projects/packages/explat/src/class-rest-controller.php @@ -11,6 +11,8 @@ use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Connection\Manager as Jetpack_Connection; use WP_Error; +use WP_REST_Request; +use WP_REST_Response; use WP_REST_Server; /** @@ -71,7 +73,7 @@ public function register_rest_routes() { * Get the assignments for a given experiment and anon_id * * @param WP_REST_Request $request The REST request object. - * @return WP_REST_Response + * @return WP_REST_Response|WP_Error */ public function get_assignments( $request ) { $response = null;