Skip to content

Conversation

@rollybueno
Copy link
Contributor

Corrected 2 inline docs for return_value():

  1. 3rd param is $values not a redundant $type.
  2. It's also an array since we loop the variable and looking for $value['name'] & $value['type'].
  3. @return is mixed since we are either return WP_CLI::error(), which technically null as per https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-error/, and $result[0]['value'] which is either boolean or string from WP config variables

@rollybueno rollybueno requested a review from a team as a code owner October 19, 2025 07:04
* @param string $name
* @param string $type
* @param string $type
* @param array $values
Copy link
Member

Choose a reason for hiding this comment

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

Can we make the type more precise? I think this one is correct

Suggested change
* @param array $values
* @param array<array{name: string, value: string, type: string}> $values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

value: mixed is more precise since it can be integer, string or boleean. e.g. define( 'WP_DEBUG', true ), define( 'SITE_ID_CURRENT_SITE', 1 ), define( 'DB_NAME', 'wp_cli_test' )

@swissspidy
Copy link
Member

3. @return is mixed since we are either return WP_CLI::error(), which technically null as per make.wordpress.org/cli/handbook/references/internal-api/wp-cli-error, and $result[0]['value'] which is either boolean or string from WP config variables

I don't think they can be booleans.. Can you double check that?

In any case, let's try to make the types as precise as possible. string|never is more accurate

@rollybueno
Copy link
Contributor Author

  1. @return is mixed since we are either return WP_CLI::error(), which technically null as per make.wordpress.org/cli/handbook/references/internal-api/wp-cli-error, and $result[0]['value'] which is either boolean or string from WP config variables

I don't think they can be booleans.. Can you double check that?

In any case, let's try to make the types as precise as possible. string|never is more accurate

The WP_CLI:error() here uses exit() so it indeed never, but it's returning mixed as well and not just string. So it should be mixed|never

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants