Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"composer/semver": "^1.4 || ^2 || ^3",
"wp-cli/wp-cli": "^2.12"
"wp-cli/wp-cli": "^2.13"
},
"require-dev": {
"wp-cli/checksum-command": "^1 || ^2",
Expand Down
20 changes: 18 additions & 2 deletions src/Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* 4.5.2
*
* @package wp-cli
*
* @phpstan-type HTTP_Response array{headers: array<string, string>, body: string, response: array{code:false|int, message: false|string}, cookies: array<string, string>, http_response: mixed}
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTTP_Response alias appears to be more specific than WordPress actually guarantees (e.g., cookies are typically WP_Http_Cookie[], and header values aren’t always just string). Consider loosening this alias to only the fields you read in this file (e.g., array{response: array{code:int, message:string}} & array<string, mixed>) or using array<string, mixed> to avoid encoding an incorrect contract into PHPStan types.

Suggested change
* @phpstan-type HTTP_Response array{headers: array<string, string>, body: string, response: array{code:false|int, message: false|string}, cookies: array<string, string>, http_response: mixed}
* @phpstan-type HTTP_Response array{response: array{code:false|int, message:false|string}} & array<string, mixed>

Copilot uses AI. Check for mistakes.
*/
class Core_Command extends WP_CLI_Command {

Expand Down Expand Up @@ -659,6 +661,10 @@ private static function set_multisite_defaults( $assoc_args ) {
}

private function do_install( $assoc_args ) {
/**
* @var \wpdb $wpdb
*/
global $wpdb;
if ( is_blog_installed() ) {
return false;
}
Expand Down Expand Up @@ -710,7 +716,7 @@ function wp_new_blog_notification() {
$args['locale']
);

if ( ! empty( $GLOBALS['wpdb']->last_error ) ) {
if ( ! empty( $wpdb->last_error ) ) {
WP_CLI::error( 'Installation produced database errors, and may have partially or completely failed.' );
}

Expand Down Expand Up @@ -1502,6 +1508,10 @@ private function get_updates( $assoc_args ) {
return [];
}

/**
* @var array{wp_version: string} $GLOBALS
*/

$compare_version = str_replace( '-src', '', $GLOBALS['wp_version'] );

$updates = [
Expand Down Expand Up @@ -1552,7 +1562,9 @@ private function get_updates( $assoc_args ) {
/**
* Sets or clears the version check error property based on an HTTP response.
*
* @param mixed $response The HTTP response (WP_Error, array, or other).
* @param mixed|\WP_Error $response The HTTP response (WP_Error, array, or other).
*
* @phpstan-param HTTP_Response|WP_Error $response
*/
private function set_version_check_error( $response ) {
if ( is_wp_error( $response ) ) {
Expand Down Expand Up @@ -1583,6 +1595,8 @@ private function set_version_check_error( $response ) {
* @param array $args HTTP request arguments.
* @param string $url The request URL.
* @return false|array|WP_Error The response, unmodified.
*
* @phpstan-param HTTP_Response|WP_Error|false $response
*/
public function capture_version_check_error( $response, $args, $url ) {
if ( false === strpos( $url, 'api.wordpress.org/core/version-check' ) ) {
Expand Down Expand Up @@ -1610,6 +1624,8 @@ public function capture_version_check_error( $response, $args, $url ) {
* @param string $_class HTTP transport class name (unused).
* @param array $_args HTTP request arguments (unused).
* @param string $url URL being requested.
*
* @phpstan-param HTTP_Response|WP_Error $response
*/
public function capture_version_check_error_from_response( $response, $context, $_class, $_args, $url ) {
if ( false === strpos( $url, 'api.wordpress.org/core/version-check' ) ) {
Expand Down
11 changes: 6 additions & 5 deletions src/WP_CLI/Core/CoreUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ public function download_package( $package, $check_signatures = false, $hook_ext
$hook_extra
);

/**
* @var false|string|\WP_Error $reply
*/

if ( false !== $reply ) {
// @phpstan-ignore return.type
return $reply;
}

Expand All @@ -96,7 +93,11 @@ function () use ( $temp ) {
}
);

$cache = WP_CLI::get_cache();
$cache = WP_CLI::get_cache();

/**
* @var object{locale: string} $update
*/
$update = $GLOBALS['wpcli_core_update_obj'];
$cache_key = "core/{$filename}-{$update->locale}.{$extension}";

Expand Down