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/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/analyzer/src/class-differences.php b/projects/packages/analyzer/src/class-differences.php index 304b2ec9ccc59..4e63d6c9c24c6 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 ) ) { @@ -56,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 @@ -69,7 +70,7 @@ public function find( $new_declarations, $prev_declarations, $new_root = null, $ } // Add differences for any detected deprecations. - if ( $deprecated ) { + if ( $deprecated && $matched ) { switch ( $new_declaration->type() ) { case 'method': $this->add( new Differences\Class_Method_Deprecated( $prev_declaration ) ); 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/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/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/.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/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/connection/src/class-nonce-handler.php b/projects/packages/connection/src/class-nonce-handler.php index 48e14a15b8abd..888e46c887c3f 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( @@ -105,8 +107,6 @@ public function add( $timestamp, $nonce ) { 'no' ) ); - } else { - $return = false; } } finally { $this->db->show_errors( $show_errors ); 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/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/image-cdn/src/class-image-cdn.php b/projects/packages/image-cdn/src/class-image-cdn.php index a71f82265f0c1..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 ( $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 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/.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/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/publicize/src/class-publicize.php b/projects/packages/publicize/src/class-publicize.php index 396bddc9cb219..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/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/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/search/src/widgets/class-search-widget.php b/projects/packages/search/src/widgets/class-search-widget.php index 3007b1a4dbbff..f451eb5cbc4e5 100644 --- a/projects/packages/search/src/widgets/class-search-widget.php +++ b/projects/packages/search/src/widgets/class-search-widget.php @@ -325,7 +325,7 @@ public function widget( $args, $instance ) { * @since 8.3.0 */ public function widget_non_instant( $args, $instance ) { - $display_filters = false; + $filters = array(); // Search instance must have been initialized before widget render. if ( is_search() ) { @@ -339,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 ( ! $filters && empty( $instance['search_box_enabled'] ) && empty( $instance['user_sort_enabled'] ) ) { return; } @@ -400,7 +396,7 @@ public function widget_non_instant( $args, $instance ) { ['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/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/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/.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/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/packages/videopress/tests/php/VideoPress_Uploader_Test.php b/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php index 3df5c05babb4b..96f20a69e6b04 100644 --- a/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php +++ b/projects/packages/videopress/tests/php/VideoPress_Uploader_Test.php @@ -174,6 +174,8 @@ public function test_get_upload_token( $response_from_server, $expected, $throw $callback = array( $this, 'return_empty_response' ); } 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/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/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/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/.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/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/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/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'; } ?> -