Docs: Fix return_value() inline documentation#205
Docs: Fix return_value() inline documentation#205rollybueno wants to merge 3 commits intowp-cli:mainfrom
Conversation
src/Config_Command.php
Outdated
| * @param string $name | ||
| * @param string $type | ||
| * @param string $type | ||
| * @param array $values |
There was a problem hiding this comment.
Can we make the type more precise? I think this one is correct
| * @param array $values | |
| * @param array<array{name: string, value: string, type: string}> $values |
There was a problem hiding this comment.
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' )
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. |
The WP_CLI:error() here uses exit() so it indeed never, but it's returning |
There was a problem hiding this comment.
Pull request overview
This PR corrects inline documentation for the return_value() method in the Config_Command class. The changes fix a duplicate parameter name and update the type annotations.
Changes:
- Fixed duplicate
@paramentry for$type- replaced with correct$valuesparameter - Updated
@paramtype annotation for$valuesto reflect its array structure - Updated
@returnannotation to describe the return type
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @param string $wp_config_file_name Config file name | ||
| * @return string The value of the requested constant or variable as defined in the wp-config.php file; if the | ||
| * requested constant or variable is not defined then the function will print an error and exit. | ||
| * @return mixed|null Original PHP value from wp-config.php or null if not found. |
There was a problem hiding this comment.
The return type documentation is inaccurate. This method never returns null. When the value is not found, the method calls WP_CLI::error() on lines 1051, 1063, or 1066, which terminates execution rather than returning a value. The method only returns a value on line 1055, which is $results[0]['value'] (mixed type). The correct documentation should be @return mixed with a note that the method exits via WP_CLI::error() if the value is not found.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Corrected 2 inline docs for return_value():
$valuesnot a redundant$type.$value['name']&$value['type'].@returnismixedsince we are either returnWP_CLI::error(), which technicallynullas 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