From 4a44fcf828e1b58306525b0e8ba3f3a99d270261 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:39:59 -0700 Subject: [PATCH 01/14] Address most PhanPossiblyUndeclaredVariable instances --- .../analyzer/src/class-differences.php | 5 ++-- .../backup/src/class-jetpack-backup.php | 5 +--- .../connection/src/class-nonce-handler.php | 2 ++ .../image-cdn/src/class-image-cdn.php | 2 +- .../image-cdn/tests/php/Image_CDN_Test.php | 6 ++--- .../publicize/src/class-publicize.php | 4 ++-- .../src/widgets/class-search-widget.php | 1 + projects/packages/sync/src/class-settings.php | 1 + .../sync/src/modules/class-full-sync.php | 4 ++++ .../tests/php/VideoPress_Uploader_Test.php | 2 +- .../app/lib/minify/class-concatenate-js.php | 2 ++ .../lib/debugger/class-jetpack-debug-data.php | 4 ++-- .../plugins/jetpack/class.jetpack-network.php | 4 ++-- projects/plugins/jetpack/class.jetpack.php | 1 + .../jetpack/class.json-api-endpoints.php | 2 +- projects/plugins/jetpack/class.json-api.php | 8 ++++++- .../jetpack/extensions/blocks/story/story.php | 3 ++- ...ss.wpcom-json-api-update-post-endpoint.php | 1 + ...com-json-api-update-post-v1-2-endpoint.php | 1 + ...pack-json-api-plugins-install-endpoint.php | 1 + .../modules/shortcodes/crowdsignal.php | 2 +- .../plugins/jetpack/modules/subscriptions.php | 6 +++++ .../jetpack/modules/subscriptions/views.php | 24 +++++++------------ .../jetpack/modules/widgets/flickr.php | 3 +++ .../Jetpack_Subscriptions_Test.php | 1 + .../Jetpack_Sync_Full_Immediately_Test.php | 2 ++ .../tests/php/sync/Jetpack_Sync_Full_Test.php | 2 ++ .../vaultpress/class.vaultpress-database.php | 3 +++ .../class.vaultpress-filesystem.php | 7 ++++-- projects/plugins/vaultpress/vaultpress.php | 2 +- projects/plugins/vaultpress/vp-scanner.php | 2 +- projects/plugins/wpcomsh/safeguard/utils.php | 1 + 32 files changed, 74 insertions(+), 40 deletions(-) diff --git a/projects/packages/analyzer/src/class-differences.php b/projects/packages/analyzer/src/class-differences.php index 304b2ec9ccc59..bf9beb1ffa5c4 100644 --- a/projects/packages/analyzer/src/class-differences.php +++ b/projects/packages/analyzer/src/class-differences.php @@ -36,6 +36,7 @@ public function find( $new_declarations, $prev_declarations, $new_root = null, $ $moved = false; $moved_with_empty_file = false; $deprecated = false; + $new_declaration = false; foreach ( $new_declarations->get() as $new_declaration ) { if ( $prev_declaration->match( $new_declaration ) ) { @@ -69,7 +70,7 @@ public function find( $new_declarations, $prev_declarations, $new_root = null, $ } // Add differences for any detected deprecations. - if ( $deprecated ) { + if ( $deprecated && $new_declaration ) { switch ( $new_declaration->type() ) { case 'method': $this->add( new Differences\Class_Method_Deprecated( $prev_declaration ) ); @@ -82,7 +83,7 @@ public function find( $new_declarations, $prev_declarations, $new_root = null, $ } $deprecated_total++; - } elseif ( $matched && $moved ) { + } elseif ( $matched && $moved && $new_declaration ) { switch ( $prev_declaration->type() ) { case 'class': $this->add( new Differences\Class_Moved( $prev_declaration, $new_declaration ) ); diff --git a/projects/packages/backup/src/class-jetpack-backup.php b/projects/packages/backup/src/class-jetpack-backup.php index 46cbdbea1c182..385c24b8fa2b3 100644 --- a/projects/packages/backup/src/class-jetpack-backup.php +++ b/projects/packages/backup/src/class-jetpack-backup.php @@ -717,6 +717,7 @@ public static function get_storage_addon_upsell_slug( $bytes_used, $bytes_availa return $upsell_products[ $bytes_1tb ]; } + $matched_bytes = $bytes_10gb; foreach ( $upsell_products as $bytes => $product ) { if ( $bytes > $additional_bytes_needed ) { $matched_bytes = $bytes; @@ -724,10 +725,6 @@ public static function get_storage_addon_upsell_slug( $bytes_used, $bytes_availa } } - if ( ! $matched_bytes ) { - $matched_bytes = $bytes_10gb; - } - return $upsell_products[ $matched_bytes ]; } diff --git a/projects/packages/connection/src/class-nonce-handler.php b/projects/packages/connection/src/class-nonce-handler.php index 48e14a15b8abd..ae00b6a76e81b 100644 --- a/projects/packages/connection/src/class-nonce-handler.php +++ b/projects/packages/connection/src/class-nonce-handler.php @@ -90,6 +90,8 @@ public function add( $timestamp, $nonce ) { // Raw query so we can avoid races: add_option will also update. $show_errors = $this->db->hide_errors(); + $return = false; + // Running `try...finally` to make sure that we re-enable errors in case of an exception. try { $old_nonce = $this->db->get_row( diff --git a/projects/packages/image-cdn/src/class-image-cdn.php b/projects/packages/image-cdn/src/class-image-cdn.php index a71f82265f0c1..52c66078d9cd0 100644 --- a/projects/packages/image-cdn/src/class-image-cdn.php +++ b/projects/packages/image-cdn/src/class-image-cdn.php @@ -651,7 +651,7 @@ public static function filter_the_content( $content ) { if ( isset( $placeholder_src ) && self::validate_image_url( $placeholder_src ) ) { $placeholder_src = Image_CDN_Core::cdn_url( $placeholder_src ); - if ( $placeholder_src !== $placeholder_src_orig ) { + if ( isset( $placeholder_src_orig ) && $placeholder_src !== $placeholder_src_orig ) { $processor->set_attribute( $source_type, $placeholder_src ); } diff --git a/projects/packages/image-cdn/tests/php/Image_CDN_Test.php b/projects/packages/image-cdn/tests/php/Image_CDN_Test.php index acf585b05ad32..90075f47d8dd2 100644 --- a/projects/packages/image-cdn/tests/php/Image_CDN_Test.php +++ b/projects/packages/image-cdn/tests/php/Image_CDN_Test.php @@ -143,10 +143,10 @@ protected function helper_get_query( $data ) { * @return int Post ID (attachment) of the image. */ protected function helper_get_image( $size = 'large', $meta = true ) { - if ( 'large' === $size ) { // 1600x1200 - $filename = __DIR__ . '/sample-content/test-image-large.png'; - } elseif ( 'medium' === $size ) { // 1024x768 + if ( 'medium' === $size ) { // 1024x768 $filename = __DIR__ . '/sample-content/test-image-medium.png'; + } else { // 1600x1200 - default to 'large' + $filename = __DIR__ . '/sample-content/test-image-large.png'; } // Add sizes that exist before uploading the file. add_image_size( 'jetpack_soft_defined', 700, 500, false ); // Intentionally not a 1.33333 ratio. diff --git a/projects/packages/publicize/src/class-publicize.php b/projects/packages/publicize/src/class-publicize.php index 396bddc9cb219..7f8a64b859ab0 100644 --- a/projects/packages/publicize/src/class-publicize.php +++ b/projects/packages/publicize/src/class-publicize.php @@ -653,8 +653,8 @@ public function test_connection( $service_name, $connection ) { $error_data = array( 'user_can_refresh' => $user_can_refresh, - 'refresh_text' => $refresh_text, - 'refresh_url' => $refresh_url, + 'refresh_text' => $refresh_text ?? '', + 'refresh_url' => $refresh_url ?? '', ); $this->test_connection_results[ $id ] = new WP_Error( $connection_error_code, $connection_test_message, $error_data ); diff --git a/projects/packages/search/src/widgets/class-search-widget.php b/projects/packages/search/src/widgets/class-search-widget.php index 3007b1a4dbbff..a83effd565de0 100644 --- a/projects/packages/search/src/widgets/class-search-widget.php +++ b/projects/packages/search/src/widgets/class-search-widget.php @@ -325,6 +325,7 @@ public function widget( $args, $instance ) { * @since 8.3.0 */ public function widget_non_instant( $args, $instance ) { + $filters = array(); $display_filters = false; // Search instance must have been initialized before widget render. diff --git a/projects/packages/sync/src/class-settings.php b/projects/packages/sync/src/class-settings.php index 724df5a75e24d..1b1cec280416c 100644 --- a/projects/packages/sync/src/class-settings.php +++ b/projects/packages/sync/src/class-settings.php @@ -283,6 +283,7 @@ public static function update_settings( $new_settings ) { /** * Regular option update and handling */ + $updated = false; if ( self::is_network_setting( $setting ) ) { if ( is_multisite() && is_main_site() ) { $updated = update_site_option( self::SETTINGS_OPTION_PREFIX . $setting, $value ); diff --git a/projects/packages/sync/src/modules/class-full-sync.php b/projects/packages/sync/src/modules/class-full-sync.php index 67ad1694fbe17..af1f6fd65f091 100644 --- a/projects/packages/sync/src/modules/class-full-sync.php +++ b/projects/packages/sync/src/modules/class-full-sync.php @@ -340,6 +340,10 @@ public function get_range( $type ) { $id = 'comment_ID'; $where_sql = Settings::get_comments_filter_sql(); break; + default: + // This should never be reached due to the guard condition above, + // but Phan complains so let's make it happy. + return array(); } // TODO: Call $wpdb->prepare on the following query. diff --git a/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php b/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php index 3df5c05babb4b..0995fbdcf437d 100644 --- a/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php +++ b/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php @@ -172,7 +172,7 @@ public function test_get_upload_token( $response_from_server, $expected, $throw $callback = array( $this, 'return_valid_response' ); } elseif ( 'empty' === $response_from_server ) { $callback = array( $this, 'return_empty_response' ); - } elseif ( 'error' === $response_from_server ) { + } else { $callback = array( $this, 'return_wp_error' ); } $u = new Uploader( $this->valid_attachment_id ); diff --git a/projects/plugins/boost/app/lib/minify/class-concatenate-js.php b/projects/plugins/boost/app/lib/minify/class-concatenate-js.php index a98ffb9298640..e43c496ec0e30 100644 --- a/projects/plugins/boost/app/lib/minify/class-concatenate-js.php +++ b/projects/plugins/boost/app/lib/minify/class-concatenate-js.php @@ -83,6 +83,7 @@ public function do_items( $handles = false, $group = false ) { $level = 0; $using_strict = false; + $strict_count = 0; foreach ( $this->to_do as $key => $handle ) { $script_is_strict = false; if ( in_array( $handle, $this->done, true ) || ! isset( $this->registered[ $handle ] ) ) { @@ -140,6 +141,7 @@ public function do_items( $handles = false, $group = false ) { $do_concat = false; } + $js_realpath = false; if ( $do_concat ) { // Resolve paths and concat scripts that exist in the filesystem $js_realpath = $this->dependency_path_mapping->dependency_src_to_fs_path( $js_url ); diff --git a/projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-debug-data.php b/projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-debug-data.php index 4bf7131ffcb81..9cc7da823b5c1 100644 --- a/projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-debug-data.php +++ b/projects/plugins/jetpack/_inc/lib/debugger/class-jetpack-debug-data.php @@ -226,12 +226,12 @@ public static function debug_data() { ); $debug_info['blog_token'] = array( 'label' => 'Blog Public Key', - 'value' => ( $blog_token ) ? $blog_key : 'Not set.', + 'value' => $blog_key ?? 'Not set.', 'private' => false, ); $debug_info['user_token'] = array( 'label' => 'User Public Key', - 'value' => ( $user_token ) ? $user_key : 'Not set.', + 'value' => $user_key ?? 'Not set.', 'private' => false, ); diff --git a/projects/plugins/jetpack/class.jetpack-network.php b/projects/plugins/jetpack/class.jetpack-network.php index 2e166064d57f2..3e8e4a9cec656 100644 --- a/projects/plugins/jetpack/class.jetpack-network.php +++ b/projects/plugins/jetpack/class.jetpack-network.php @@ -387,8 +387,8 @@ public function show_jetpack_notice() { $classname = 'error'; } ?> -
-

+
+

-1 ) { $author['site_ID'] = (int) $site_id; - $author['site_visible'] = $site_visible; + $author['site_visible'] = $site_visible ?? false; } // Only include WordPress.com user data when author_wpcom_data is enabled. diff --git a/projects/plugins/jetpack/class.json-api.php b/projects/plugins/jetpack/class.json-api.php index 21e8dbd2db0ea..3ce9b2ec66b5b 100644 --- a/projects/plugins/jetpack/class.json-api.php +++ b/projects/plugins/jetpack/class.json-api.php @@ -476,7 +476,8 @@ public function serve( $exit = true ) { } // Find which endpoint to serve. - $found = false; + $found = false; + $path_pieces = array(); foreach ( $this->endpoints as $endpoint_path_versions => $endpoints_by_method ) { // @todo Determine if anything depends on this being serialized rather than e.g. JSON. // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize -- Legacy, possibly depended on elsewhere. @@ -499,6 +500,7 @@ public function serve( $exit = true ) { $endpoint_path = untrailingslashit( $endpoint_path ); if ( $is_help ) { // Truncate path at help depth. + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $depth is set when $is_help is true. $endpoint_path = implode( '/', array_slice( explode( '/', $endpoint_path ), 0, $depth ) ); } @@ -557,6 +559,7 @@ public function serve( $exit = true ) { */ do_action( 'wpcom_json_api_output', 'help' ); $proxied = function_exists( 'wpcom_is_proxied_request' ) ? wpcom_is_proxied_request() : false; + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $help_content_type is set when $is_help is true. if ( 'json' === $help_content_type ) { $docs = array(); foreach ( $matching_endpoints as $matching_endpoint ) { @@ -576,13 +579,16 @@ public function serve( $exit = true ) { exit( 0 ); } + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false, which is guaranteed here. if ( $endpoint->in_testing && ! WPCOM_JSON_API__DEBUG ) { return $this->output( 404, '', 'text/plain' ); } /** This action is documented in class.json-api.php */ + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false, which is guaranteed here. do_action( 'wpcom_json_api_output', $endpoint->stat ); + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false, which is guaranteed here. $response = $this->process_request( $endpoint, $path_pieces ); if ( ! $response && ! is_array( $response ) ) { diff --git a/projects/plugins/jetpack/extensions/blocks/story/story.php b/projects/plugins/jetpack/extensions/blocks/story/story.php index e8658d464d124..77a5409b82dfd 100644 --- a/projects/plugins/jetpack/extensions/blocks/story/story.php +++ b/projects/plugins/jetpack/extensions/blocks/story/story.php @@ -196,7 +196,7 @@ function render_image( $media ) { } // if image does not match. - if ( ! $image || isset( $media['url'] ) && ! is_same_resource( $media['url'], $src ) ) { + if ( ! $image || isset( $media['url'] ) && ! is_same_resource( $media['url'], $src ?? '' ) ) { $width = isset( $media['width'] ) ? $media['width'] : null; $height = isset( $media['height'] ) ? $media['height'] : null; $title = isset( $media['title'] ) ? $media['title'] : ''; @@ -215,6 +215,7 @@ class="wp-block-jetpack-story_image wp-story-image %3$s" ); } + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $width and $height are set when $image is truthy, and other scenarios return early. $crop_class = get_image_crop_class( $width, $height ); // need to specify the size of the embed so it picks an image that is large enough for the `src` attribute // `sizes` is optimized for 1080x1920 (9:16) images diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php index f14d0e76b20f7..d2f9c1d2f6272 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-endpoint.php @@ -543,6 +543,7 @@ public function write_post( $path, $blog_id, $post_id ) { $post_id = wp_insert_post( add_magic_quotes( $insert ), true ); } else { + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $post is set and validated several blocks earlier if $new (only set once) is falsy. $insert['ID'] = $post->ID; // wp_update_post ignores date unless edit_date is set diff --git a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php index d93b77c791f08..bfdce982ef38e 100644 --- a/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php @@ -621,6 +621,7 @@ public function write_post( $path, $blog_id, $post_id ) { $post_id = wp_insert_post( add_magic_quotes( $insert ), true ); } } else { + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $post is set and validated several blocks earlier if $new (only set once) is falsy. $insert['ID'] = $post->ID; // wp_update_post ignores date unless edit_date is set diff --git a/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php b/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php index 9fd8c6a4150ee..775f48b39d6d7 100644 --- a/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php @@ -105,6 +105,7 @@ protected function install() { } // No errors, install worked. Now replace the slug with the actual plugin id + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- we return early if there is an issue; otherwise $index and $slug are set in the foreach loop $this->plugins[ $index ] = Plugins_Installer::get_plugin_id_by_slug( $slug ); return true; diff --git a/projects/plugins/jetpack/modules/shortcodes/crowdsignal.php b/projects/plugins/jetpack/modules/shortcodes/crowdsignal.php index df8b3e0b899b6..feab435a29843 100644 --- a/projects/plugins/jetpack/modules/shortcodes/crowdsignal.php +++ b/projects/plugins/jetpack/modules/shortcodes/crowdsignal.php @@ -647,7 +647,7 @@ class_exists( 'Jetpack_AMP_Support' ) 'back_color' => $back_color, 'align' => $attributes['align'], 'style' => $attributes['style'], - 'id' => $survey, + 'id' => $survey ?? null, 'site' => $attributes['site'], ) ); diff --git a/projects/plugins/jetpack/modules/subscriptions.php b/projects/plugins/jetpack/modules/subscriptions.php index c237a5a2445f3..3a1876a626965 100644 --- a/projects/plugins/jetpack/modules/subscriptions.php +++ b/projects/plugins/jetpack/modules/subscriptions.php @@ -566,6 +566,7 @@ public function subscribe( $email, $post_ids = 0, $async = true, $extra_data = a if ( $async ) { XMLRPC_Async_Call::add_call( 'jetpack.subscribeToSite', 0, $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize } else { + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize } } @@ -575,17 +576,22 @@ public function subscribe( $email, $post_ids = 0, $async = true, $extra_data = a } // Call. + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false, otherwise we return early $xml->query(); + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false, otherwise we return early if ( $xml->isError() ) { + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false, otherwise we return early return $xml->get_jetpack_error(); } + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false $responses = $xml->getResponse(); $r = array(); foreach ( (array) $responses as $response ) { if ( isset( $response['faultCode'] ) || isset( $response['faultString'] ) ) { + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false $r[] = $xml->get_jetpack_error( $response['faultCode'], $response['faultString'] ); continue; } diff --git a/projects/plugins/jetpack/modules/subscriptions/views.php b/projects/plugins/jetpack/modules/subscriptions/views.php index a7a4d2f7905a8..f5b35e9ac42bf 100644 --- a/projects/plugins/jetpack/modules/subscriptions/views.php +++ b/projects/plugins/jetpack/modules/subscriptions/views.php @@ -748,18 +748,6 @@ public function form( $instance ) { $subscribe_logged_in = ! empty( $instance['subscribe_logged_in'] ) ? esc_attr( stripslashes( $instance['subscribe_logged_in'] ) ) : ''; $subscribe_button = ! empty( $instance['subscribe_button'] ) ? esc_attr( stripslashes( $instance['subscribe_button'] ) ) : ''; $subscribers_total = self::fetch_subscriber_count(); - } - - if ( self::is_jetpack() ) { - $title = ! empty( $instance['title'] ) ? stripslashes( $instance['title'] ) : ''; - $subscribe_text = ! empty( $instance['subscribe_text'] ) ? stripslashes( $instance['subscribe_text'] ) : ''; - $subscribe_placeholder = ! empty( $instance['subscribe_placeholder'] ) ? stripslashes( $instance['subscribe_placeholder'] ) : ''; - $subscribe_button = ! empty( $instance['subscribe_button'] ) ? stripslashes( $instance['subscribe_button'] ) : ''; - $success_message = ! empty( $instance['success_message'] ) ? stripslashes( $instance['success_message'] ) : ''; - $subscribers_total = self::fetch_subscriber_count(); - } - - if ( self::is_wpcom() ) : ?>

get_enclosure()->get_link(); break; + default: + $src = ''; + break; } $photos .= '{$type_user_id}; } diff --git a/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Immediately_Test.php b/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Immediately_Test.php index 038492666780e..1c60933207184 100644 --- a/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Immediately_Test.php +++ b/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Immediately_Test.php @@ -334,6 +334,7 @@ public function test_full_sync_sends_all_term_relationships_with_previous_interv public function test_full_sync_sends_all_users() { self::factory()->user->create( array( 'role' => 'subscriber' ) ); $first_user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); + $user_id = 0; // Phan thinks the for loop might not run and thus $user_id might not be declared, so let's initialize it. for ( $i = 0; $i < 9; $i++ ) { $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); } @@ -908,6 +909,7 @@ public function test_full_sync_end_sends_range() { public function create_dummy_data_and_reset_sync_status() { // lets create a bunch of posts + $post = 0; // Phan thinks the for loop might not run and thus $post might not be declared, so let's initialize it. for ( $i = 0; $i < $this->test_posts_count; $i++ ) { $post = self::factory()->post->create(); } diff --git a/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Test.php b/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Test.php index ac225fbcaec42..0e7272511d6c5 100644 --- a/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Test.php +++ b/projects/plugins/jetpack/tests/php/sync/Jetpack_Sync_Full_Test.php @@ -467,6 +467,7 @@ public function test_full_sync_sends_all_term_relationships_with_previous_interv public function test_full_sync_sends_all_users() { self::factory()->user->create( array( 'role' => 'subscriber' ) ); $first_user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); + $user_id = 0; // Phan thinks the for loop might not run and thus $user_id might not be declared, so let's initialize it. for ( $i = 0; $i < 9; $i++ ) { $user_id = self::factory()->user->create( array( 'role' => 'contributor' ) ); } @@ -1157,6 +1158,7 @@ public function record_full_sync_start_config( $modules ) { public function create_dummy_data_and_empty_the_queue() { // lets create a bunch of posts + $post = 0; // Phan thinks the for loop might not run and thus $post might not be declared, so let's initialize it. for ( $i = 0; $i < $this->test_posts_count; $i++ ) { $post = self::factory()->post->create(); } diff --git a/projects/plugins/vaultpress/class.vaultpress-database.php b/projects/plugins/vaultpress/class.vaultpress-database.php index df7b9528083f3..41a993a15555b 100644 --- a/projects/plugins/vaultpress/class.vaultpress-database.php +++ b/projects/plugins/vaultpress/class.vaultpress-database.php @@ -169,6 +169,9 @@ function convert_to_sql_string( $data, $datatypes ) { if ( !is_object( $data ) || !is_object( $datatypes ) ) return false; + $keys = array(); + $vals = array(); + foreach ( array_keys( (array)$data ) as $key ) $keys[] = sprintf( "`%s`", esc_sql( $key ) ); foreach ( (array)$data as $key => $val ) { diff --git a/projects/plugins/vaultpress/class.vaultpress-filesystem.php b/projects/plugins/vaultpress/class.vaultpress-filesystem.php index 6422fcf481b02..12a9e22bd0a6f 100644 --- a/projects/plugins/vaultpress/class.vaultpress-filesystem.php +++ b/projects/plugins/vaultpress/class.vaultpress-filesystem.php @@ -75,10 +75,13 @@ function exec_checksum( $file, $method ) { if ( !function_exists( 'exec' ) ) return false; $out = array(); - if ( 'md5' == $method ) + if ( 'md5' === $method ) { $method_bin = 'md5sum'; - if ( 'sha1' == $method ) + } elseif ( 'sha1' === $method ) { $method_bin = 'sha1sum'; + } else { + return false; + } $checksum = ''; exec( sprintf( '%s %s', escapeshellcmd( $method_bin ), escapeshellarg( $file ) ), $out ); if ( !empty( $out ) ) diff --git a/projects/plugins/vaultpress/vaultpress.php b/projects/plugins/vaultpress/vaultpress.php index 06526da788dbc..4dc080f8edeb6 100644 --- a/projects/plugins/vaultpress/vaultpress.php +++ b/projects/plugins/vaultpress/vaultpress.php @@ -1016,8 +1016,8 @@ function ui_delete_vp_settings_button() { function ui_logo() { if ( ! class_exists( 'Jetpack_Logo' ) ) { require_once VAULTPRESS__PLUGIN_DIR . 'class-jetpack-logo.php'; - $jetpack_logo = new Jetpack_Logo(); } + $jetpack_logo = new Jetpack_Logo(); return $jetpack_logo->output(); } diff --git a/projects/plugins/vaultpress/vp-scanner.php b/projects/plugins/vaultpress/vp-scanner.php index a71f56ce5bdef..6f800fbfb4cab 100644 --- a/projects/plugins/vaultpress/vp-scanner.php +++ b/projects/plugins/vaultpress/vp-scanner.php @@ -65,7 +65,7 @@ function _scan_files( $path, &$files, $offset, $limit, &$last_dir ) { } if ( count( $files ) >= $limit ) { closedir( $handle ); - return array( $_return_offset, $_return_dir ); + return array( $_return_offset ?? 0, $_return_dir ?? null ); } } closedir( $handle ); diff --git a/projects/plugins/wpcomsh/safeguard/utils.php b/projects/plugins/wpcomsh/safeguard/utils.php index b2d0e77f99443..d2337c8d35410 100644 --- a/projects/plugins/wpcomsh/safeguard/utils.php +++ b/projects/plugins/wpcomsh/safeguard/utils.php @@ -198,6 +198,7 @@ function get_plugin_data_from_package( $package ) { return new WP_Error( 'process_package_fails', 'Invalid plugin file.' ); } + $plugin_folder = false; $tmp_plugin_folder = uncompress_package( $package ); if ( is_wp_error( $tmp_plugin_folder ) ) { return $tmp_plugin_folder; From 9eeffa940a0b173af65764caee765ba2ab36949e Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:47:13 -0700 Subject: [PATCH 02/14] Remove now-redundant assignment --- projects/packages/connection/src/class-nonce-handler.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/packages/connection/src/class-nonce-handler.php b/projects/packages/connection/src/class-nonce-handler.php index ae00b6a76e81b..888e46c887c3f 100644 --- a/projects/packages/connection/src/class-nonce-handler.php +++ b/projects/packages/connection/src/class-nonce-handler.php @@ -107,8 +107,6 @@ public function add( $timestamp, $nonce ) { 'no' ) ); - } else { - $return = false; } } finally { $this->db->show_errors( $show_errors ); From 629650e11adf14eb48eabfd77ddd020255704f28 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:47:57 -0700 Subject: [PATCH 03/14] Update Phan baselines --- projects/packages/analyzer/.phan/baseline.php | 4 --- projects/packages/backup/.phan/baseline.php | 3 +- .../packages/connection/.phan/baseline.php | 4 +-- .../packages/image-cdn/.phan/baseline.php | 6 ++-- .../packages/publicize/.phan/baseline.php | 3 +- projects/packages/search/.phan/baseline.php | 3 +- projects/packages/sync/.phan/baseline.php | 7 ++-- .../packages/videopress/.phan/baseline.php | 3 +- projects/plugins/boost/.phan/baseline.php | 6 ++-- projects/plugins/jetpack/.phan/baseline.php | 35 +++++++++---------- .../plugins/vaultpress/.phan/baseline.php | 13 +++---- projects/plugins/wpcomsh/.phan/baseline.php | 3 +- 12 files changed, 35 insertions(+), 55 deletions(-) diff --git a/projects/packages/analyzer/.phan/baseline.php b/projects/packages/analyzer/.phan/baseline.php index 223c0ad67dc70..7b9b523e1542e 100644 --- a/projects/packages/analyzer/.phan/baseline.php +++ b/projects/packages/analyzer/.phan/baseline.php @@ -11,16 +11,13 @@ // # Issue statistics: // PhanUndeclaredProperty : 25+ occurrences // PhanTypeMismatchArgument : 8 occurrences - // PhanPossiblyUndeclaredVariable : 7 occurrences // PhanParamSignatureMismatch : 6 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 6 occurrences // PhanTypeMismatchReturnProbablyReal : 6 occurrences // PhanUndeclaredClassMethod : 6 occurrences // PhanUndeclaredMethod : 6 occurrences // PhanTypeArraySuspiciousNullable : 5 occurrences - // PhanTypeMismatchArgumentNullable : 5 occurrences // PhanUndeclaredTypeParameter : 4 occurrences - // PhanNonClassMethodCall : 2 occurrences // PhanPluginDuplicateCatchStatementBody : 2 occurrences // PhanTypeMismatchDeclaredParam : 2 occurrences // PhanUndeclaredClassStaticProperty : 2 occurrences @@ -49,7 +46,6 @@ 'src/api/class-model.php' => ['PhanTypeArraySuspiciousNullable'], 'src/api/class-plugin-downloader.php' => ['PhanPluginDuplicateExpressionAssignmentOperation'], 'src/class-declarations.php' => ['PhanPluginDuplicateCatchStatementBody'], - 'src/class-differences.php' => ['PhanNonClassMethodCall', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullable'], 'src/class-invocations.php' => ['PhanPluginDuplicateCatchStatementBody'], 'src/class-utils.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredMethod', 'PhanUndeclaredProperty', 'PhanUndeclaredTypeParameter'], 'src/class-warnings.php' => ['PhanUndeclaredMethod'], diff --git a/projects/packages/backup/.phan/baseline.php b/projects/packages/backup/.phan/baseline.php index 6d2c06fd19914..810069a69e88c 100644 --- a/projects/packages/backup/.phan/baseline.php +++ b/projects/packages/backup/.phan/baseline.php @@ -12,11 +12,10 @@ // PhanTypeMismatchReturnProbablyReal : 15+ occurrences // PhanTypeMismatchReturn : 6 occurrences // PhanUndeclaredStaticMethod : 2 occurrences - // PhanPossiblyUndeclaredVariable : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'src/class-jetpack-backup.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredStaticMethod'], + 'src/class-jetpack-backup.php' => ['PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanUndeclaredStaticMethod'], 'src/class-rest-controller.php' => ['PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/packages/connection/.phan/baseline.php b/projects/packages/connection/.phan/baseline.php index bf846b955fdbd..7c25835af9119 100644 --- a/projects/packages/connection/.phan/baseline.php +++ b/projects/packages/connection/.phan/baseline.php @@ -21,14 +21,13 @@ // PhanDeprecatedFunction : 2 occurrences // PhanNonClassMethodCall : 2 occurrences // PhanPluginUnreachableCode : 2 occurrences - // PhanPossiblyUndeclaredVariable : 2 occurrences // PhanTypeMismatchPropertyDefault : 2 occurrences - // PhanTypeMismatchReturnNullable : 2 occurrences // PhanTypePossiblyInvalidDimOffset : 2 occurrences // PhanPluginDuplicateAdjacentStatement : 1 occurrence // PhanPluginSimplifyExpressionBool : 1 occurrence // PhanTypeMismatchArgumentNullable : 1 occurrence // PhanTypeMismatchDeclaredParamNullable : 1 occurrence + // PhanTypeMismatchReturnNullable : 1 occurrence // PhanUndeclaredClassMethod : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions @@ -40,7 +39,6 @@ 'src/class-error-handler.php' => ['PhanTypeMismatchReturnProbablyReal'], 'src/class-heartbeat.php' => ['PhanTypeMismatchPropertyDefault'], 'src/class-manager.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeMismatchDefault', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal'], - 'src/class-nonce-handler.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchReturnNullable'], 'src/class-partner-coupon.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-partner.php' => ['PhanTypeMismatchPropertyProbablyReal'], 'src/class-rest-authentication.php' => ['PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchPropertyProbablyReal'], diff --git a/projects/packages/image-cdn/.phan/baseline.php b/projects/packages/image-cdn/.phan/baseline.php index cc6e5297c116c..18fd0cfa387ee 100644 --- a/projects/packages/image-cdn/.phan/baseline.php +++ b/projects/packages/image-cdn/.phan/baseline.php @@ -13,11 +13,9 @@ // PhanPluginSimplifyExpressionBool : 6 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 4 occurrences // PhanTypeMismatchArgumentProbablyReal : 4 occurrences - // PhanPossiblyUndeclaredVariable : 2 occurrences // PhanTypeMismatchPropertyProbablyReal : 2 occurrences // PhanNonClassMethodCall : 1 occurrence // PhanTypeArraySuspicious : 1 occurrence - // PhanTypeMismatchArgumentNullable : 1 occurrence // PhanTypeMismatchArgumentNullableInternal : 1 occurrence // PhanTypeMismatchReturn : 1 occurrence // PhanTypeMismatchReturnProbablyReal : 1 occurrence @@ -28,10 +26,10 @@ // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ 'src/class-image-cdn-image-sizes.php' => ['PhanPluginSimplifyExpressionBool'], - 'src/class-image-cdn.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspicious', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset'], + 'src/class-image-cdn.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanTypeArraySuspicious', 'PhanTypeMismatchPropertyProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset'], 'src/compatibility/photon.php' => ['PhanTypeMismatchArgumentNullableInternal'], 'tests/php/Image_CDN_Core_Test.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeObjectUnsetDeclaredProperty'], - 'tests/php/Image_CDN_Test.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchPropertyProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredStaticMethod'], + 'tests/php/Image_CDN_Test.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchPropertyProbablyReal', 'PhanUndeclaredMethod', 'PhanUndeclaredStaticMethod'], ], // '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/publicize/.phan/baseline.php b/projects/packages/publicize/.phan/baseline.php index a7ed0443327d3..f89bfd2bd9dd4 100644 --- a/projects/packages/publicize/.phan/baseline.php +++ b/projects/packages/publicize/.phan/baseline.php @@ -14,7 +14,6 @@ // PhanPluginUnreachableCode : 4 occurrences // PhanTypeMismatchArgument : 3 occurrences // PhanUndeclaredClassMethod : 3 occurrences - // PhanPossiblyUndeclaredVariable : 2 occurrences // PhanTypeMismatchArgumentNullable : 2 occurrences // PhanTypeMismatchReturnProbablyReal : 2 occurrences // PhanTypeMissingReturn : 2 occurrences @@ -35,7 +34,7 @@ 'src/class-keyring-helper.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault'], 'src/class-publicize-base.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanSuspiciousMagicConstant', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchDimFetch'], 'src/class-publicize-ui.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanTypeMismatchReturnProbablyReal'], - 'src/class-publicize.php' => ['PhanParamSignatureMismatch', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMissingReturn'], + 'src/class-publicize.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchArgument', 'PhanTypeMissingReturn'], 'src/class-rest-controller.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'], 'src/rest-api/class-connections-controller.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeSuspiciousNonTraversableForeach'], 'src/rest-api/class-connections-post-field.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], diff --git a/projects/packages/search/.phan/baseline.php b/projects/packages/search/.phan/baseline.php index e7a91fd48081d..b780bdd14e659 100644 --- a/projects/packages/search/.phan/baseline.php +++ b/projects/packages/search/.phan/baseline.php @@ -20,7 +20,6 @@ // PhanImpossibleCondition : 2 occurrences // PhanDeprecatedPartiallySupportedCallable : 1 occurrence // PhanPluginSimplifyExpressionBool : 1 occurrence - // PhanPossiblyUndeclaredVariable : 1 occurrence // PhanTypeInvalidDimOffset : 1 occurrence // PhanTypeMismatchDeclaredParamNullable : 1 occurrence // PhanTypeMismatchDefault : 1 occurrence @@ -38,7 +37,7 @@ 'src/classic-search/class-classic-search.php' => ['PhanTypeInvalidDimOffset', 'PhanTypeMismatchDeclaredParamNullable', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], 'src/customizer/customize-controls/class-excluded-post-types-control.php' => ['PhanTypeMismatchReturnProbablyReal'], 'src/instant-search/class-instant-search.php' => ['PhanTypeMismatchProperty', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], - 'src/widgets/class-search-widget.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument'], + 'src/widgets/class-search-widget.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'], 'src/wpes/class-query-builder.php' => ['PhanImpossibleCondition', 'PhanTypeMismatchDimAssignment', 'PhanTypeMismatchReturnProbablyReal'], 'tests/php/Helpers_Test.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchArgument'], 'tests/php/Plan_Test.php' => ['PhanDeprecatedFunction', 'PhanTypeMismatchArgumentProbablyReal'], diff --git a/projects/packages/sync/.phan/baseline.php b/projects/packages/sync/.phan/baseline.php index d7979c7ae7010..68e2e18caf190 100644 --- a/projects/packages/sync/.phan/baseline.php +++ b/projects/packages/sync/.phan/baseline.php @@ -11,13 +11,12 @@ // # Issue statistics: // PhanTypeMismatchArgument : 40+ occurrences // PhanPluginDuplicateConditionalNullCoalescing : 30+ occurrences - // PhanTypeMismatchReturnProbablyReal : 30+ occurrences + // PhanTypeMismatchReturnProbablyReal : 25+ occurrences // PhanTypeMismatchReturn : 20+ occurrences // PhanParamSignatureMismatch : 10+ occurrences // PhanTypeMismatchArgumentProbablyReal : 10+ occurrences // PhanPluginSimplifyExpressionBool : 9 occurrences // PhanPluginDuplicateSwitchCaseLooseEquality : 6 occurrences - // PhanPossiblyUndeclaredVariable : 4 occurrences // PhanTypeExpectedObjectPropAccess : 4 occurrences // PhanNonClassMethodCall : 3 occurrences // PhanTypeArraySuspiciousNullable : 3 occurrences @@ -50,13 +49,13 @@ 'src/class-rest-sender.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentProbablyReal'], 'src/class-sender.php' => ['PhanNonClassMethodCall', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-server.php' => ['PhanTypeMismatchDeclaredParam', 'PhanTypeMismatchReturnProbablyReal'], - 'src/class-settings.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'src/class-settings.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'src/class-utils.php' => ['PhanTypeExpectedObjectPropAccess'], 'src/modules/class-callables.php' => ['PhanParamSignatureMismatch', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgument'], 'src/modules/class-comments.php' => ['PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], 'src/modules/class-constants.php' => ['PhanParamSignatureMismatch'], 'src/modules/class-full-sync-immediately.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeMismatchReturn'], - 'src/modules/class-full-sync.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable'], + 'src/modules/class-full-sync.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool'], 'src/modules/class-module.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal'], 'src/modules/class-network-options.php' => ['PhanParamSignatureMismatch'], 'src/modules/class-options.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchReturnProbablyReal'], diff --git a/projects/packages/videopress/.phan/baseline.php b/projects/packages/videopress/.phan/baseline.php index 16f09439cfe79..685af7ff78422 100644 --- a/projects/packages/videopress/.phan/baseline.php +++ b/projects/packages/videopress/.phan/baseline.php @@ -19,7 +19,6 @@ // PhanNonClassMethodCall : 4 occurrences // PhanTypeArraySuspiciousNullable : 4 occurrences // PhanTypeMismatchArgument : 4 occurrences - // PhanPossiblyUndeclaredVariable : 2 occurrences // PhanTypeInvalidDimOffset : 2 occurrences // PhanUndeclaredExtendedClass : 2 occurrences // PhanUndeclaredMethod : 2 occurrences @@ -53,7 +52,7 @@ 'src/videopress-divi/class-videopress-divi-extension.php' => ['PhanCommentOverrideOnNonOverrideMethod', 'PhanUndeclaredClass', 'PhanUndeclaredClassMethod', 'PhanUndeclaredExtendedClass', 'PhanUndeclaredMethod', 'PhanUndeclaredMethodInCallable'], 'src/videopress-divi/class-videopress-divi-module.php' => ['PhanUndeclaredExtendedClass'], 'tests/php/Uploader_Test.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'tests/php/VideoPress_Uploader_Test.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument'], + 'tests/php/VideoPress_Uploader_Test.php' => ['PhanTypeMismatchArgument'], ], // '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/plugins/boost/.phan/baseline.php b/projects/plugins/boost/.phan/baseline.php index 2c4106273d6ad..5a24e570c060e 100644 --- a/projects/plugins/boost/.phan/baseline.php +++ b/projects/plugins/boost/.phan/baseline.php @@ -18,12 +18,10 @@ // PhanUndeclaredClassConstant : 4 occurrences // PhanUndeclaredFunction : 4 occurrences // PhanPluginUseReturnValueInternalKnown : 2 occurrences - // PhanPossiblyUndeclaredVariable : 2 occurrences - // PhanTypeMismatchArgumentNullableInternal : 2 occurrences // PhanTypeMismatchPropertyDefault : 2 occurrences // PhanCoalescingNeverNull : 1 occurrence // PhanRedefineFunction : 1 occurrence - // PhanTypeInvalidUnaryOperandIncOrDec : 1 occurrence + // PhanTypeMismatchArgumentNullableInternal : 1 occurrence // PhanTypeMismatchProperty : 1 occurrence // PhanTypeMissingReturn : 1 occurrence // PhanUndeclaredClassMethod : 1 occurrence @@ -37,7 +35,7 @@ 'app/lib/class-cli.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'], 'app/lib/critical-css/class-critical-css-state.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable'], 'app/lib/minify/class-concatenate-css.php' => ['PhanPluginUseReturnValueInternalKnown', 'PhanTypeMismatchArgument'], - 'app/lib/minify/class-concatenate-js.php' => ['PhanPluginUseReturnValueInternalKnown', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidUnaryOperandIncOrDec', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal'], + 'app/lib/minify/class-concatenate-js.php' => ['PhanPluginUseReturnValueInternalKnown', 'PhanTypeMismatchArgument'], 'app/lib/minify/class-dependency-path-mapping.php' => ['PhanUndeclaredConstant'], 'app/lib/minify/functions-helpers.php' => ['PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredConstant'], 'app/modules/image-guide/class-image-guide-proxy.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php index b24e9a3868045..99c6d56ee6811 100644 --- a/projects/plugins/jetpack/.phan/baseline.php +++ b/projects/plugins/jetpack/.phan/baseline.php @@ -16,10 +16,8 @@ // PhanTypeMismatchReturnProbablyReal : 120+ occurrences // PhanTypePossiblyInvalidDimOffset : 90+ occurrences // PhanDeprecatedFunction : 60+ occurrences - // PhanPossiblyUndeclaredVariable : 55+ occurrences // PhanTypeArraySuspiciousNullable : 55+ occurrences // PhanRedefineFunction : 45+ occurrences - // PhanTypeMismatchArgumentNullable : 45+ occurrences // PhanPluginDuplicateAdjacentStatement : 40+ occurrences // PhanTypeExpectedObjectPropAccess : 30+ occurrences // PhanTypeMismatchDefault : 25+ occurrences @@ -30,6 +28,7 @@ // PhanTypeArraySuspicious : 20+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences // PhanSuspiciousMagicConstant : 15+ occurrences + // PhanTypeMismatchArgumentNullable : 15+ occurrences // PhanTypeMismatchPropertyDefault : 15+ occurrences // PhanTypeSuspiciousNonTraversableForeach : 15+ occurrences // PhanPluginDuplicateExpressionAssignmentOperation : 10+ occurrences @@ -48,6 +47,7 @@ // PhanCommentAbstractOnInheritedMethod : 6 occurrences // PhanTypeInvalidLeftOperandOfNumericOp : 6 occurrences // PhanDeprecatedClass : 5 occurrences + // PhanPossiblyUndeclaredVariable : 5 occurrences // PhanTypeMismatchDimAssignment : 5 occurrences // PhanTypeInvalidDimOffset : 4 occurrences // PhanTypeInvalidLeftOperandOfAdd : 4 occurrences @@ -125,7 +125,7 @@ '_inc/lib/core-api/wpcom-endpoints/service-api-keys.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious', 'PhanTypeMismatchReturnProbablyReal'], '_inc/lib/debugger/class-jetpack-cxn-test-base.php' => ['PhanDeprecatedFunctionInternal', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturn'], '_inc/lib/debugger/class-jetpack-cxn-tests.php' => ['PhanPluginSimplifyExpressionBool'], - '_inc/lib/debugger/class-jetpack-debug-data.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument'], + '_inc/lib/debugger/class-jetpack-debug-data.php' => ['PhanTypeMismatchArgument'], '_inc/lib/debugger/class-jetpack-debugger.php' => ['PhanTypeMismatchArgumentProbablyReal'], '_inc/lib/debugger/debug-functions.php' => ['PhanTypeMismatchReturnProbablyReal'], '_inc/lib/icalendar-reader.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginDuplicateExpressionAssignmentOperation', 'PhanPossiblyUndeclaredVariable', 'PhanTypeInvalidLeftOperandOfNumericOp', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypePossiblyInvalidDimOffset'], @@ -143,12 +143,12 @@ 'class.jetpack-heartbeat.php' => ['PhanTypeMismatchPropertyDefault'], 'class.jetpack-modules-list-table.php' => ['PhanCommentAbstractOnInheritedMethod'], 'class.jetpack-network-sites-list-table.php' => ['PhanCommentAbstractOnInheritedMethod'], - 'class.jetpack-network.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal'], + 'class.jetpack-network.php' => ['PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal'], 'class.jetpack-post-images.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturnProbablyReal'], 'class.jetpack-twitter-cards.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypePossiblyInvalidDimOffset'], - 'class.jetpack.php' => ['PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], - 'class.json-api-endpoints.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeComparisonToArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal'], - 'class.json-api.php' => ['PhanPluginDuplicateSwitchCaseLooseEquality', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspicious', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty', 'PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchReturnProbablyReal'], + 'class.jetpack.php' => ['PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable', 'PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnProbablyReal'], + 'class.json-api-endpoints.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanTypeArraySuspiciousNullable', 'PhanTypeComparisonToArray', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturnProbablyReal'], + 'class.json-api.php' => ['PhanPluginDuplicateSwitchCaseLooseEquality', 'PhanPluginSimplifyExpressionBool', 'PhanTypeArraySuspicious', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchProperty', 'PhanTypeMismatchPropertyDefault', 'PhanTypeMismatchReturnProbablyReal'], 'enhanced-open-graph.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable'], 'extensions/blocks/ai-chat/ai-chat.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'], 'extensions/blocks/blog-stats/blog-stats.php' => ['PhanTypeMismatchReturnProbablyReal'], @@ -173,7 +173,7 @@ 'extensions/blocks/repeat-visitor/repeat-visitor.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'extensions/blocks/sharing-button/class-sharing-source-block.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturnProbablyReal'], 'extensions/blocks/slideshow/slideshow.php' => ['PhanPluginSimplifyExpressionBool', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchReturnProbablyReal'], - 'extensions/blocks/story/story.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable'], + 'extensions/blocks/story/story.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'extensions/blocks/subscriptions/subscriptions.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'extensions/blocks/top-posts/top-posts.php' => ['PhanTypeMismatchReturnProbablyReal'], 'extensions/blocks/wordads/wordads.php' => ['PhanTypeMismatchArgument'], @@ -232,9 +232,9 @@ 'json-endpoints/class.wpcom-json-api-update-customcss.php' => ['PhanTypeMismatchReturn'], 'json-endpoints/class.wpcom-json-api-update-media-endpoint.php' => ['PhanTypeMismatchReturn'], 'json-endpoints/class.wpcom-json-api-update-media-v1-1-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchReturn'], - 'json-endpoints/class.wpcom-json-api-update-post-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], + 'json-endpoints/class.wpcom-json-api-update-post-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], 'json-endpoints/class.wpcom-json-api-update-post-v1-1-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], - 'json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypePossiblyInvalidDimOffset'], + 'json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypePossiblyInvalidDimOffset'], 'json-endpoints/class.wpcom-json-api-update-site-homepage-endpoint.php' => ['PhanTypeMismatchReturn'], 'json-endpoints/class.wpcom-json-api-update-site-logo-endpoint.php' => ['PhanTypeMismatchReturn'], 'json-endpoints/class.wpcom-json-api-update-taxonomy-endpoint.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturn'], @@ -255,7 +255,7 @@ 'json-endpoints/jetpack/class.jetpack-json-api-log-endpoint.php' => ['PhanTypeMismatchPropertyDefault'], 'json-endpoints/jetpack/class.jetpack-json-api-modules-endpoint.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchArgument'], 'json-endpoints/jetpack/class.jetpack-json-api-plugins-endpoint.php' => ['PhanParamSignatureMismatch', 'PhanPluginDuplicateExpressionAssignmentOperation', 'PhanTypeMismatchArgument'], - 'json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchDimAssignment'], + 'json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php' => ['PhanTypeMismatchDimAssignment'], 'json-endpoints/jetpack/class.jetpack-json-api-plugins-modify-endpoint.php' => ['PhanTypeInvalidLeftOperandOfBitwiseOp', 'PhanTypeInvalidRightOperandOfBitwiseOp', 'PhanTypeMismatchArgumentProbablyReal'], 'json-endpoints/jetpack/class.jetpack-json-api-plugins-modify-v1-2-endpoint.php' => ['PhanTypeInvalidLeftOperandOfBitwiseOp', 'PhanTypeInvalidRightOperandOfBitwiseOp'], 'json-endpoints/jetpack/class.jetpack-json-api-plugins-new-endpoint.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchArgument', 'PhanTypeMissingReturn'], @@ -304,7 +304,6 @@ 'modules/shortcodes/archives.php' => ['PhanPluginSimplifyExpressionBool'], 'modules/shortcodes/brightcove.php' => ['PhanTypeMismatchArgument'], 'modules/shortcodes/class.filter-embedded-html-objects.php' => ['PhanTypeMismatchPropertyDefault'], - 'modules/shortcodes/crowdsignal.php' => ['PhanPossiblyUndeclaredVariable'], 'modules/shortcodes/dailymotion.php' => ['PhanTypeMismatchArgument'], 'modules/shortcodes/flickr.php' => ['PhanTypeMismatchReturn'], 'modules/shortcodes/getty.php' => ['PhanTypeMismatchArgument'], @@ -342,9 +341,9 @@ 'modules/sitemaps/sitemap-logger.php' => ['PhanTypeMismatchProperty'], 'modules/sitemaps/sitemaps.php' => ['PhanTypeMismatchArgument'], 'modules/stats.php' => ['PhanSuspiciousMagicConstant', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable', 'PhanTypeMismatchReturnProbablyReal'], - 'modules/subscriptions.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypeSuspiciousNonTraversableForeach'], + 'modules/subscriptions.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault', 'PhanTypeMismatchReturnProbablyReal', 'PhanTypeSuspiciousNonTraversableForeach'], 'modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php' => ['PhanTypeMismatchReturnNullable'], - 'modules/subscriptions/views.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypePossiblyInvalidDimOffset'], + 'modules/subscriptions/views.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypePossiblyInvalidDimOffset'], 'modules/theme-tools/content-options.php' => ['PhanRedefineFunction'], 'modules/theme-tools/content-options/author-bio.php' => ['PhanRedefineFunction', 'PhanTypeMismatchArgument'], 'modules/theme-tools/content-options/blog-display.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanRedefineFunction'], @@ -383,7 +382,7 @@ 'modules/widgets/class-jetpack-instagram-widget.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturn', 'PhanTypePossiblyInvalidDimOffset'], 'modules/widgets/contact-info.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument'], 'modules/widgets/facebook-likebox.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypePossiblyInvalidDimOffset'], - 'modules/widgets/flickr.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullable'], + 'modules/widgets/flickr.php' => ['PhanTypeMismatchArgumentNullable'], 'modules/widgets/flickr/form.php' => ['PhanTypeMismatchArgument'], 'modules/widgets/follow-button.php' => ['PhanPluginUseReturnValueInternalKnown'], 'modules/widgets/gallery.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'], @@ -451,14 +450,14 @@ 'tests/php/modules/shortcodes/Jetpack_Shortcodes_Vimeo_Test.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'tests/php/modules/sitemaps/Jetpack_Sitemap_Buffer_Test.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchPropertyProbablyReal'], 'tests/php/modules/sitemaps/Jetpack_Sitemap_Librarian_Test.php' => ['PhanTypeMismatchArgument'], - 'tests/php/modules/subscriptions/Jetpack_Subscriptions_Test.php' => ['PhanDeprecatedProperty', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], + 'tests/php/modules/subscriptions/Jetpack_Subscriptions_Test.php' => ['PhanDeprecatedProperty', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], 'tests/php/modules/widgets/Contact_Info_Widget_Test.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'tests/php/modules/widgets/Jetpack_Display_Posts_Widget_Test.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'tests/php/sync/Jetpack_Sync_Checksum_Smoke_Test.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturn'], 'tests/php/sync/Jetpack_Sync_Checksum_Test.php' => ['PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchReturn'], 'tests/php/sync/Jetpack_Sync_Comments_Test.php' => ['PhanTypeMismatchArgument'], - 'tests/php/sync/Jetpack_Sync_Full_Immediately_Test.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'tests/php/sync/Jetpack_Sync_Full_Test.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchArgumentReal'], + 'tests/php/sync/Jetpack_Sync_Full_Immediately_Test.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentProbablyReal'], + 'tests/php/sync/Jetpack_Sync_Full_Test.php' => ['PhanPluginDuplicateAdjacentStatement', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchArgumentReal'], 'tests/php/sync/Jetpack_Sync_Functions_Test.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMissingReturn'], 'tests/php/sync/Jetpack_Sync_Import_Test.php' => ['PhanRedefineClass'], 'tests/php/sync/Jetpack_Sync_Integration_Test.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchPropertyProbablyReal'], diff --git a/projects/plugins/vaultpress/.phan/baseline.php b/projects/plugins/vaultpress/.phan/baseline.php index cf843d6b9c5fc..d4fc63890e137 100644 --- a/projects/plugins/vaultpress/.phan/baseline.php +++ b/projects/plugins/vaultpress/.phan/baseline.php @@ -11,16 +11,14 @@ // # Issue statistics: // PhanUndeclaredClassMethod : 15+ occurrences // PhanPluginSimplifyExpressionBool : 8 occurrences - // PhanTypeMismatchArgumentNullableInternal : 8 occurrences // PhanUndeclaredConstant : 8 occurrences // PhanTypeMismatchArgument : 7 occurrences - // PhanPossiblyUndeclaredVariable : 6 occurrences + // PhanTypeMismatchArgumentNullableInternal : 6 occurrences // PhanTypePossiblyInvalidDimOffset : 6 occurrences // PhanPluginUnreachableCode : 5 occurrences // PhanTypeArraySuspiciousNullable : 5 occurrences // PhanTypeMismatchArgumentProbablyReal : 5 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 4 occurrences - // PhanUndeclaredVariableDim : 4 occurrences // PhanCommentParamWithoutRealParam : 3 occurrences // PhanTypeMismatchDimFetch : 3 occurrences // PhanUndeclaredFunction : 3 occurrences @@ -33,7 +31,6 @@ // PhanUndeclaredMethod : 2 occurrences // PhanUndeclaredVariable : 2 occurrences // PhanAccessMethodProtected : 1 occurrence - // PhanParamSpecial1 : 1 occurrence // PhanPluginDuplicateExpressionAssignment : 1 occurrence // PhanTypeInvalidRightOperandOfNumericOp : 1 occurrence // PhanTypeMismatchArgumentInternal : 1 occurrence @@ -42,12 +39,12 @@ // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'class.vaultpress-database.php' => ['PhanParamSpecial1', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeNonVarPassByRef', 'PhanTypeObjectUnsetDeclaredProperty', 'PhanUndeclaredConstant', 'PhanUndeclaredVariableDim'], - 'class.vaultpress-filesystem.php' => ['PhanPluginNeverReturnMethod', 'PhanPluginSimplifyExpressionBool', 'PhanPluginUnreachableCode', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeNonVarPassByRef', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredVariable'], + 'class.vaultpress-database.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspiciousNullable', 'PhanTypeMismatchArgumentInternal', 'PhanTypeNonVarPassByRef', 'PhanTypeObjectUnsetDeclaredProperty', 'PhanUndeclaredConstant'], + 'class.vaultpress-filesystem.php' => ['PhanPluginNeverReturnMethod', 'PhanPluginSimplifyExpressionBool', 'PhanPluginUnreachableCode', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeNonVarPassByRef', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredVariable'], 'class.vaultpress-hotfixes.php' => ['PhanDeprecatedFunction', 'PhanPluginSimplifyExpressionBool', 'PhanRedefineFunction', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypePossiblyInvalidDimOffset'], 'cron-tasks.php' => ['PhanRedefineFunction'], - 'vaultpress.php' => ['PhanAccessMethodProtected', 'PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginDuplicateExpressionAssignment', 'PhanPluginNeverReturnMethod', 'PhanPluginSimplifyExpressionBool', 'PhanPluginUnreachableCode', 'PhanPossiblyUndeclaredVariable', 'PhanTypeArraySuspiciousNullable', 'PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeInvalidRightOperandOfNumericOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypePossiblyInvalidDimOffset', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredConstant', 'PhanUndeclaredFunction', 'PhanUndeclaredMethod', 'PhanUndeclaredVariable'], - 'vp-scanner.php' => ['PhanCommentParamWithoutRealParam', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredFunction'], + 'vaultpress.php' => ['PhanAccessMethodProtected', 'PhanDeprecatedFunction', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginDuplicateExpressionAssignment', 'PhanPluginNeverReturnMethod', 'PhanPluginSimplifyExpressionBool', 'PhanPluginUnreachableCode', 'PhanTypeArraySuspiciousNullable', 'PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeInvalidRightOperandOfNumericOp', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypePossiblyInvalidDimOffset', 'PhanTypeSuspiciousStringExpression', 'PhanUndeclaredClassMethod', 'PhanUndeclaredClassReference', 'PhanUndeclaredConstant', 'PhanUndeclaredFunction', 'PhanUndeclaredMethod', 'PhanUndeclaredVariable'], + 'vp-scanner.php' => ['PhanCommentParamWithoutRealParam', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredFunction'], ], // '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/plugins/wpcomsh/.phan/baseline.php b/projects/plugins/wpcomsh/.phan/baseline.php index f80a933b70c5d..c03ac9158a81c 100644 --- a/projects/plugins/wpcomsh/.phan/baseline.php +++ b/projects/plugins/wpcomsh/.phan/baseline.php @@ -22,7 +22,6 @@ // PhanDeprecatedFunction : 1 occurrence // PhanDeprecatedProperty : 1 occurrence // PhanPluginUseReturnValueInternalKnown : 1 occurrence - // PhanPossiblyUndeclaredVariable : 1 occurrence // PhanTypeObjectUnsetDeclaredProperty : 1 occurrence // PhanUndeclaredClassConstant : 1 occurrence // PhanUndeclaredClassStaticProperty : 1 occurrence @@ -41,7 +40,7 @@ 'footer-credit/theme-optimizations.php' => ['PhanUndeclaredConstant', 'PhanUndeclaredStaticMethod'], 'functions.php' => ['PhanUndeclaredClassStaticProperty'], 'imports/playground/class-sql-importer.php' => ['PhanUndeclaredConstant'], - 'safeguard/utils.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument'], + 'safeguard/utils.php' => ['PhanTypeMismatchArgument'], 'tests/AnyoneCanRegisterNoticeTest.php' => ['PhanTypeMismatchArgument', 'PhanTypeVoidArgument', 'PhanTypeVoidAssignment'], 'tests/FrontendNoticesTest.php' => ['PhanUndeclaredStaticMethod'], 'tests/PlanNoticesTest.php' => ['PhanDeprecatedProperty', 'PhanPluginUseReturnValueInternalKnown', 'PhanUndeclaredStaticMethod'], From cee7f9e79a095b15c76bede0ca26de0727e65ce2 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 12 Nov 2025 14:48:49 -0700 Subject: [PATCH 04/14] Add changelogs --- .../changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../backup/changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../search/changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../sync/changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../boost/changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../jetpack/changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ .../wpcomsh/changelog/fix-phan-PhanPossiblyUndeclaredVariable | 4 ++++ 12 files changed, 48 insertions(+) create mode 100644 projects/packages/analyzer/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/packages/backup/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/packages/connection/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/packages/image-cdn/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/packages/publicize/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/packages/search/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/packages/sync/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/packages/videopress/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/plugins/boost/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/plugins/jetpack/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/plugins/vaultpress/changelog/fix-phan-PhanPossiblyUndeclaredVariable create mode 100644 projects/plugins/wpcomsh/changelog/fix-phan-PhanPossiblyUndeclaredVariable diff --git a/projects/packages/analyzer/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/analyzer/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/analyzer/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/packages/backup/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/backup/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/backup/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/packages/connection/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/connection/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/connection/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/packages/image-cdn/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/image-cdn/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/image-cdn/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/packages/publicize/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/publicize/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/publicize/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/packages/search/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/search/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/search/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/packages/sync/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/sync/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/sync/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/packages/videopress/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/packages/videopress/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/packages/videopress/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/plugins/boost/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/plugins/boost/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/plugins/boost/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/plugins/jetpack/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/plugins/jetpack/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..7d0055a6c5c14 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/plugins/vaultpress/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/plugins/vaultpress/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/plugins/vaultpress/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. diff --git a/projects/plugins/wpcomsh/changelog/fix-phan-PhanPossiblyUndeclaredVariable b/projects/plugins/wpcomsh/changelog/fix-phan-PhanPossiblyUndeclaredVariable new file mode 100644 index 0000000000000..473f10d2c7859 --- /dev/null +++ b/projects/plugins/wpcomsh/changelog/fix-phan-PhanPossiblyUndeclaredVariable @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Phan: Address PhanPossiblyUndeclaredVariable violations. From 86bf1b936fdd3ba15143889b37e4b251cc6356ab Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:49:05 -0700 Subject: [PATCH 05/14] Don't rely on foreach PHP quirk --- projects/packages/analyzer/src/class-differences.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/packages/analyzer/src/class-differences.php b/projects/packages/analyzer/src/class-differences.php index bf9beb1ffa5c4..4e63d6c9c24c6 100644 --- a/projects/packages/analyzer/src/class-differences.php +++ b/projects/packages/analyzer/src/class-differences.php @@ -57,7 +57,7 @@ public function find( $new_declarations, $prev_declarations, $new_root = null, $ $moved = true; } } - $matched = true; + $matched = $new_declaration; break; } elseif ( $prev_declaration->partial_match( $new_declaration ) ) { // TODO this is to catch things like function args changed, method the same @@ -70,7 +70,7 @@ public function find( $new_declarations, $prev_declarations, $new_root = null, $ } // Add differences for any detected deprecations. - if ( $deprecated && $new_declaration ) { + if ( $deprecated && $matched ) { switch ( $new_declaration->type() ) { case 'method': $this->add( new Differences\Class_Method_Deprecated( $prev_declaration ) ); @@ -83,7 +83,7 @@ public function find( $new_declarations, $prev_declarations, $new_root = null, $ } $deprecated_total++; - } elseif ( $matched && $moved && $new_declaration ) { + } elseif ( $matched && $moved ) { switch ( $prev_declaration->type() ) { case 'class': $this->add( new Differences\Class_Moved( $prev_declaration, $new_declaration ) ); From fd11cce10aff7145ab39363c447974b6b748ad0e Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:55:58 -0700 Subject: [PATCH 06/14] Reset vars early and in each loop --- projects/packages/image-cdn/src/class-image-cdn.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/packages/image-cdn/src/class-image-cdn.php b/projects/packages/image-cdn/src/class-image-cdn.php index 52c66078d9cd0..8f5e2e5b8f827 100644 --- a/projects/packages/image-cdn/src/class-image-cdn.php +++ b/projects/packages/image-cdn/src/class-image-cdn.php @@ -363,8 +363,10 @@ public static function filter_the_content( $content ) { } // Identify image source. - $src_orig = $processor->get_attribute( 'src' ); - $src = $src_orig; + $src_orig = $processor->get_attribute( 'src' ); + $src = $src_orig; + $placeholder_src = null; + $placeholder_src_orig = null; /* * Only examine tags that are considered an image, @@ -648,14 +650,12 @@ public static function filter_the_content( $content ) { $processor->set_attribute( 'src', $photon_url ); // If Lazy Load is in use, pass placeholder image through Photon. - if ( isset( $placeholder_src ) && self::validate_image_url( $placeholder_src ) ) { + if ( $placeholder_src !== null && self::validate_image_url( $placeholder_src ) ) { $placeholder_src = Image_CDN_Core::cdn_url( $placeholder_src ); - if ( isset( $placeholder_src_orig ) && $placeholder_src !== $placeholder_src_orig ) { + if ( $placeholder_src !== $placeholder_src_orig ) { $processor->set_attribute( $source_type, $placeholder_src ); } - - unset( $placeholder_src ); } // If we are not transforming the image with resize, fit, or letterbox (lb), then we should remove From 231d542985754872eb7edc162e4fc57d030bf7a9 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:06:13 -0700 Subject: [PATCH 07/14] Remove interim var --- .../search/src/widgets/class-search-widget.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/projects/packages/search/src/widgets/class-search-widget.php b/projects/packages/search/src/widgets/class-search-widget.php index a83effd565de0..a62c175bc4c1a 100644 --- a/projects/packages/search/src/widgets/class-search-widget.php +++ b/projects/packages/search/src/widgets/class-search-widget.php @@ -325,8 +325,7 @@ public function widget( $args, $instance ) { * @since 8.3.0 */ public function widget_non_instant( $args, $instance ) { - $filters = array(); - $display_filters = false; + $filters = array(); // Search instance must have been initialized before widget render. if ( is_search() ) { @@ -340,13 +339,9 @@ public function widget_non_instant( $args, $instance ) { if ( ! Helper::are_filters_by_widget_disabled() && ! $this->should_display_sitewide_filters() ) { $filters = array_filter( $filters, array( $this, 'is_for_current_widget' ) ); } - - if ( ! empty( $filters ) ) { - $display_filters = true; - } } - if ( ! $display_filters && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) { + if ( empty( $filters ) && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) { return; } @@ -401,7 +396,7 @@ public function widget_non_instant( $args, $instance ) { Date: Fri, 14 Nov 2025 14:27:12 -0700 Subject: [PATCH 08/14] Initialize vars at top of function --- projects/plugins/jetpack/extensions/blocks/story/story.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/extensions/blocks/story/story.php b/projects/plugins/jetpack/extensions/blocks/story/story.php index 77a5409b82dfd..471f5b763630b 100644 --- a/projects/plugins/jetpack/extensions/blocks/story/story.php +++ b/projects/plugins/jetpack/extensions/blocks/story/story.php @@ -187,6 +187,10 @@ function enrich_video_meta( $media_file ) { * @return string */ function render_image( $media ) { + $src = ''; + $width = null; + $height = null; + if ( empty( $media['id'] ) || empty( $media['url'] ) ) { return __( 'Error retrieving media', 'jetpack' ); } @@ -215,7 +219,6 @@ class="wp-block-jetpack-story_image wp-story-image %3$s" ); } - // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $width and $height are set when $image is truthy, and other scenarios return early. $crop_class = get_image_crop_class( $width, $height ); // need to specify the size of the embed so it picks an image that is large enough for the `src` attribute // `sizes` is optimized for 1080x1920 (9:16) images From d3651777183d82ab29c5bb79bc276a856b99551a Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:29:06 -0700 Subject: [PATCH 09/14] Add todo comment --- .../jetpack/class.jetpack-json-api-plugins-install-endpoint.php | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php b/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php index 775f48b39d6d7..c3e4a5a642fc8 100644 --- a/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-plugins-install-endpoint.php @@ -105,6 +105,7 @@ protected function install() { } // No errors, install worked. Now replace the slug with the actual plugin id + // @todo This code looks a bit suspect; why do we loop through plugins and only look at the last one? // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- we return early if there is an issue; otherwise $index and $slug are set in the foreach loop $this->plugins[ $index ] = Plugins_Installer::get_plugin_id_by_slug( $slug ); From a69001cb87288a610bc548981332821e6fcd4a25 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Fri, 14 Nov 2025 14:31:43 -0700 Subject: [PATCH 10/14] Apply suggestions from code review Co-authored-by: Brad Jorsch --- projects/packages/publicize/src/class-publicize.php | 4 ++-- .../videopress/tests/php/VideoPress_Uploader_Test.php | 4 +++- projects/plugins/jetpack/class.json-api.php | 6 +++--- .../modules/subscriptions/Jetpack_Subscriptions_Test.php | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/projects/packages/publicize/src/class-publicize.php b/projects/packages/publicize/src/class-publicize.php index 7f8a64b859ab0..82f498d99cdc0 100644 --- a/projects/packages/publicize/src/class-publicize.php +++ b/projects/packages/publicize/src/class-publicize.php @@ -653,8 +653,8 @@ public function test_connection( $service_name, $connection ) { $error_data = array( 'user_can_refresh' => $user_can_refresh, - 'refresh_text' => $refresh_text ?? '', - 'refresh_url' => $refresh_url ?? '', + 'refresh_text' => $refresh_text ?? null, + 'refresh_url' => $refresh_url ?? null, ); $this->test_connection_results[ $id ] = new WP_Error( $connection_error_code, $connection_test_message, $error_data ); diff --git a/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php b/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php index 0995fbdcf437d..96f20a69e6b04 100644 --- a/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php +++ b/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php @@ -172,8 +172,10 @@ public function test_get_upload_token( $response_from_server, $expected, $throw $callback = array( $this, 'return_valid_response' ); } elseif ( 'empty' === $response_from_server ) { $callback = array( $this, 'return_empty_response' ); - } else { + } elseif ( 'error' === $response_from_server ) { $callback = array( $this, 'return_wp_error' ); + } else { + $this->fail( "Unsupported response '$response_from_server'" ); } $u = new Uploader( $this->valid_attachment_id ); if ( $throw ) { diff --git a/projects/plugins/jetpack/class.json-api.php b/projects/plugins/jetpack/class.json-api.php index 3ce9b2ec66b5b..5b5f67244227d 100644 --- a/projects/plugins/jetpack/class.json-api.php +++ b/projects/plugins/jetpack/class.json-api.php @@ -579,16 +579,16 @@ public function serve( $exit = true ) { exit( 0 ); } - // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false, which is guaranteed here. + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false and $found is true, which is guaranteed here. if ( $endpoint->in_testing && ! WPCOM_JSON_API__DEBUG ) { return $this->output( 404, '', 'text/plain' ); } /** This action is documented in class.json-api.php */ - // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false, which is guaranteed here. + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false and $found is true, which is guaranteed here. do_action( 'wpcom_json_api_output', $endpoint->stat ); - // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false, which is guaranteed here. + // @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $endpoint is set when $find_all_matching_endpoints is false and $found is true, which is guaranteed here. $response = $this->process_request( $endpoint, $path_pieces ); if ( ! $response && ! is_array( $response ) ) { diff --git a/projects/plugins/jetpack/tests/php/modules/subscriptions/Jetpack_Subscriptions_Test.php b/projects/plugins/jetpack/tests/php/modules/subscriptions/Jetpack_Subscriptions_Test.php index 21330c67be714..c4003f06483e2 100644 --- a/projects/plugins/jetpack/tests/php/modules/subscriptions/Jetpack_Subscriptions_Test.php +++ b/projects/plugins/jetpack/tests/php/modules/subscriptions/Jetpack_Subscriptions_Test.php @@ -286,7 +286,7 @@ private function get_payload( $is_subscribed, $is_paid_subscriber = false, $subs */ #[DataProvider( 'matrix_access' )] public function test_subscriber_access_level( $type_user_id, $logged, $token_set, $post_access_level, $should_email_be_sent, $should_user_access_post, $subscription_end_date = null, $status = null ) { - $user_id = 0; + $user_id = null; if ( $type_user_id !== null ) { $user_id = $this->{$type_user_id}; } From 9c383110789c19f6f08a53b40700a5a77e8a7464 Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:27:16 -0700 Subject: [PATCH 11/14] Empty arrays are falsy Co-authored-by: Brad Jorsch --- .../packages/search/src/widgets/class-search-widget.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/packages/search/src/widgets/class-search-widget.php b/projects/packages/search/src/widgets/class-search-widget.php index a62c175bc4c1a..f451eb5cbc4e5 100644 --- a/projects/packages/search/src/widgets/class-search-widget.php +++ b/projects/packages/search/src/widgets/class-search-widget.php @@ -341,7 +341,7 @@ public function widget_non_instant( $args, $instance ) { } } - if ( empty( $filters ) && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) { + if ( ! $filters && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) { return; } @@ -396,7 +396,7 @@ public function widget_non_instant( $args, $instance ) { Date: Wed, 19 Nov 2025 16:19:54 -0700 Subject: [PATCH 12/14] Use null as fallback instead of bool Co-authored-by: Brad Jorsch --- projects/plugins/jetpack/class.json-api-endpoints.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/class.json-api-endpoints.php b/projects/plugins/jetpack/class.json-api-endpoints.php index 83147fc3783e4..3febeae084a8e 100644 --- a/projects/plugins/jetpack/class.json-api-endpoints.php +++ b/projects/plugins/jetpack/class.json-api-endpoints.php @@ -1589,7 +1589,7 @@ public function get_author( $author, $show_email_and_ip = false ) { if ( $site_id > -1 ) { $author['site_ID'] = (int) $site_id; - $author['site_visible'] = $site_visible ?? false; + $author['site_visible'] = $site_visible ?? null; } // Only include WordPress.com user data when author_wpcom_data is enabled. From c2c3f63281115decb272e348780d268c4ddd04ae Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:23:11 -0700 Subject: [PATCH 13/14] No need to initialize $path_pieces --- projects/plugins/jetpack/class.json-api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/class.json-api.php b/projects/plugins/jetpack/class.json-api.php index 5b5f67244227d..90cff6857e78e 100644 --- a/projects/plugins/jetpack/class.json-api.php +++ b/projects/plugins/jetpack/class.json-api.php @@ -476,8 +476,8 @@ public function serve( $exit = true ) { } // Find which endpoint to serve. - $found = false; - $path_pieces = array(); + $found = false; + foreach ( $this->endpoints as $endpoint_path_versions => $endpoints_by_method ) { // @todo Determine if anything depends on this being serialized rather than e.g. JSON. // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize -- Legacy, possibly depended on elsewhere. From 5b3a0973c3fd9229b2b0e14d0ef397653ed045ce Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:32:52 -0700 Subject: [PATCH 14/14] Revert "No need to initialize $path_pieces" This reverts commit 830d826dbc9551dd1d8b8fee39bef0329e7dfdae. --- projects/plugins/jetpack/class.json-api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/plugins/jetpack/class.json-api.php b/projects/plugins/jetpack/class.json-api.php index 90cff6857e78e..5b5f67244227d 100644 --- a/projects/plugins/jetpack/class.json-api.php +++ b/projects/plugins/jetpack/class.json-api.php @@ -476,8 +476,8 @@ public function serve( $exit = true ) { } // Find which endpoint to serve. - $found = false; - + $found = false; + $path_pieces = array(); foreach ( $this->endpoints as $endpoint_path_versions => $endpoints_by_method ) { // @todo Determine if anything depends on this being serialized rather than e.g. JSON. // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize -- Legacy, possibly depended on elsewhere.