Skip to content

Commit 0ee6fe5

Browse files
committed
Further PHPDoc improvements
1 parent cbcd2b3 commit 0ee6fe5

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"wp-cli/db-command": "^1.3 || ^2",
2121
"wp-cli/entity-command": "^1.3 || ^2",
2222
"wp-cli/extension-command": "^1.2 || ^2",
23-
"wp-cli/wp-cli-tests": "dev-main"
23+
"wp-cli/wp-cli-tests": "dev-add/phpstan-enhancements"
2424
},
2525
"config": {
2626
"process-timeout": 7200,

src/Core_Command.php

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ class Core_Command extends WP_CLI_Command {
7575
* +---------+-------------+-------------------------------------------------------------+
7676
*
7777
* @subcommand check-update
78+
*
79+
* @param string[] $args Positional arguments. Unused.
80+
* @param array{minor?: bool, major?: bool, 'force-check'?: bool, field?: string, format: string} $assoc_args Associative arguments.
7881
*/
79-
public function check_update( $_, $assoc_args ) {
82+
public function check_update( $args, $assoc_args ) {
8083
$format = Utils\get_flag_value( $assoc_args, 'format', 'table' );
8184

8285
$updates = $this->get_updates( $assoc_args );
@@ -136,6 +139,9 @@ public function check_update( $_, $assoc_args ) {
136139
* Success: WordPress downloaded.
137140
*
138141
* @when before_wp_load
142+
*
143+
* @param array{0?: string} $args Positional arguments.
144+
* @param array{path?: string, locale?: string, version?: string, 'skip-content'?: bool, force?: bool, insecure?: bool, extract?: bool} $assoc_args Associative arguments.
139145
*/
140146
public function download( $args, $assoc_args ) {
141147
/**
@@ -175,13 +181,10 @@ public function download( $args, $assoc_args ) {
175181
WP_CLI::error( "'{$download_dir}' is not writable by current user." );
176182
}
177183

178-
/**
179-
* @var string $locale
180-
*/
181184
$locale = Utils\get_flag_value( $assoc_args, 'locale', 'en_US' );
182-
$skip_content = (bool) Utils\get_flag_value( $assoc_args, 'skip-content', false );
183-
$insecure = (bool) Utils\get_flag_value( $assoc_args, 'insecure', false );
184-
$extract = (bool) Utils\get_flag_value( $assoc_args, 'extract', true );
185+
$skip_content = Utils\get_flag_value( $assoc_args, 'skip-content', false );
186+
$insecure = Utils\get_flag_value( $assoc_args, 'insecure', false );
187+
$extract = Utils\get_flag_value( $assoc_args, 'extract', true );
185188

186189
if ( $skip_content && ! $extract ) {
187190
WP_CLI::error( 'Cannot use both --skip-content and --no-extract at the same time.' );
@@ -385,11 +388,12 @@ function () use ( $temp ) {
385388
* fi
386389
*
387390
* @subcommand is-installed
391+
*
392+
* @param string[] $args Positional arguments. Unused.
393+
* @param array{network?: bool} $assoc_args Associative arguments.
388394
*/
389395
public function is_installed( $args, $assoc_args ) {
390-
if ( is_blog_installed()
391-
&& ( ! Utils\get_flag_value( $assoc_args, 'network' )
392-
|| is_multisite() ) ) {
396+
if ( is_blog_installed() && ( ! Utils\get_flag_value( $assoc_args, 'network' ) || is_multisite() ) ) {
393397
WP_CLI::halt( 0 );
394398
}
395399

@@ -444,6 +448,9 @@ public function is_installed( $args, $assoc_args ) {
444448
*
445449
* # Install WordPress without disclosing admin_password to bash history
446450
* $ wp core install --url=example.com --title=Example --admin_user=supervisor --admin_email=info@example.com --prompt=admin_password < admin_password.txt
451+
*
452+
* @param string[] $args Positional arguments. Unused.
453+
* @param array{url: string, title: string, admin_user: string, admin_password?: string, admin_email: string, locale?: string, 'skip-email'?: bool} $assoc_args Associative arguments.
447454
*/
448455
public function install( $args, $assoc_args ) {
449456
if ( $this->do_install( $assoc_args ) ) {
@@ -491,6 +498,9 @@ public function install( $args, $assoc_args ) {
491498
*
492499
* @subcommand multisite-convert
493500
* @alias install-network
501+
*
502+
* @param string[] $args Positional arguments. Unused.
503+
* @param array{title?: string, base: string, subdomains?: bool, 'skip-config'?: bool} $assoc_args Associative arguments.
494504
*/
495505
public function multisite_convert( $args, $assoc_args ) {
496506
if ( is_multisite() ) {
@@ -569,6 +579,9 @@ public function multisite_convert( $args, $assoc_args ) {
569579
* Success: Network installed. Don't forget to set up rewrite rules.
570580
*
571581
* @subcommand multisite-install
582+
*
583+
* @param string[] $args Positional arguments. Unused.
584+
* @param array{url?: string, base: string, subdomains?: bool, title: string, admin_user: string, admin_password?: string, admin_email: string, 'skip-email'?: bool, 'skip-config'?: bool} $assoc_args Associative arguments.
572585
*/
573586
public function multisite_install( $args, $assoc_args ) {
574587
if ( $this->do_install( $assoc_args ) ) {
@@ -903,6 +916,9 @@ private static function get_clean_basedomain() {
903916
* Package language: en_US
904917
*
905918
* @when before_wp_load
919+
*
920+
* @param string[] $args Positional arguments. Unused.
921+
* @param array{extra?: bool} $assoc_args Associative arguments.
906922
*/
907923
public function version( $args = [], $assoc_args = [] ) {
908924
$details = self::get_wp_details();
@@ -1086,6 +1102,9 @@ private static function get_core_checksums( $version, $locale, $insecure ) {
10861102
* Success: WordPress updated successfully.
10871103
*
10881104
* @alias upgrade
1105+
*
1106+
* @param array{0?: string} $args Positional arguments.
1107+
* @param array{minor?: bool, version?: string, force?: bool, locale?: string, insecure?: bool} $assoc_args Associative arguments.
10891108
*/
10901109
public function update( $args, $assoc_args ) {
10911110
global $wp_version;
@@ -1248,6 +1267,9 @@ public function update( $args, $assoc_args ) {
12481267
* Success: WordPress database upgraded on 123/123 sites.
12491268
*
12501269
* @subcommand update-db
1270+
*
1271+
* @param string[] $args Positional arguments. Unused.
1272+
* @param array{network?: bool, 'dry-run'?: bool} $assoc_args Associative arguments.
12511273
*/
12521274
public function update_db( $args, $assoc_args ) {
12531275
global $wpdb, $wp_db_version, $wp_current_db_version;
@@ -1386,7 +1408,7 @@ private function get_download_url( $version, $locale = 'en_US', $file_type = 'zi
13861408
* @return array List of available updates , or an empty array if no updates are available.
13871409
*/
13881410
private function get_updates( $assoc_args ) {
1389-
$force_check = (bool) Utils\get_flag_value( $assoc_args, 'force-check' );
1411+
$force_check = Utils\get_flag_value( $assoc_args, 'force-check' );
13901412
wp_version_check( [], $force_check );
13911413

13921414
/**

0 commit comments

Comments
 (0)