Skip to content

Commit 1c594b8

Browse files
authored
Merge pull request #602 from wp-cli/copilot/fix-multiline-argument-parsing
2 parents 8e5fa18 + aac59dc commit 1c594b8

File tree

6 files changed

+16
-23
lines changed

6 files changed

+16
-23
lines changed

bin/Handbook_Command.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -791,13 +791,10 @@ private static function parse_docblock( $docblock ) {
791791
if ( preg_match( '/^(?=\s+?\*[^\/])(.+)/', $line, $matches ) ) {
792792
$info = trim( $matches[1] );
793793
$info = preg_replace( '/^(\*\s+?)/', '', $info );
794-
if ( $in_param ) {
794+
if ( $in_param && ! empty( $info ) && '@' !== $info[0] ) {
795795
list( $param_name, $key ) = $in_param;
796796
$ret['parameters'][ $param_name ][ $key ][2] .= PHP_EOL . $info;
797-
if ( '}' === substr( $info, -1 ) ) {
798-
$in_param = false;
799-
}
800-
} elseif ( '@' !== $info[0] ) {
797+
} elseif ( ! empty( $info ) && '@' !== $info[0] ) {
801798
$ret['description'] .= PHP_EOL . "{$extra_line}{$info}";
802799
} else {
803800
preg_match( '/@(\w+)/', $info, $matches );
@@ -815,9 +812,11 @@ private static function parse_docblock( $docblock ) {
815812
end( $ret['parameters'][ $param_name ] );
816813
$key = key( $ret['parameters'][ $param_name ] );
817814
reset( $ret['parameters'][ $param_name ] );
818-
if ( ! empty( $ret['parameters'][ $param_name ][ $key ][2] )
819-
&& '{' === substr( $ret['parameters'][ $param_name ][ $key ][2], -1 ) ) {
815+
// Always set $in_param for tags that can have multiline descriptions
816+
if ( ! empty( $ret['parameters'][ $param_name ][ $key ][2] ) ) {
820817
$in_param = [ $param_name, $key ];
818+
} else {
819+
$in_param = false;
821820
}
822821
}
823822
$extra_line = '';

bin/handbook-manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"behat-steps": {
99
"title": "Behat Steps",
1010
"slug": "behat-steps",
11-
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/behat-steps.md",
12-
"parent": null
11+
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/references\/behat-steps.md",
12+
"parent": "references"
1313
},
1414
"bug-reports": {
1515
"title": "Bug Reports",
@@ -368,8 +368,8 @@
368368
"internal-api": {
369369
"title": "Internal API",
370370
"slug": "internal-api",
371-
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/internal-api.md",
372-
"parent": null
371+
"markdown_source": "https:\/\/github.com\/wp-cli\/handbook\/blob\/main\/references\/internal-api.md",
372+
"parent": "references"
373373
},
374374
"philosophy": {
375375
"title": "Philosophy",

internal-api/wp-cli-debug.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Display debug message prefixed with "Debug: " when `--debug` is used.
1010

1111
<div>
1212
<strong>$message</strong> (string|WP_Error|Exception|Throwable) Message to write to STDERR.<br />
13-
<strong>$group</strong> (string|bool) Organize debug message to a specific group.<br />
13+
<strong>$group</strong> (string|bool) Organize debug message to a specific group.<br />Use `false` to not group the message.<br />
1414
<strong>@return</strong> (void) <br />
1515
</div>
1616

@@ -37,7 +37,6 @@ private static function set_wp_root( $path ) {
3737
# [...]
3838
# Debug: ABSPATH defined: /srv/www/wordpress-develop.dev/src/ (0.225s)
3939
```
40-
Use `false` to not group the message.
4140

4241

4342
*Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.*

internal-api/wp-cli-do-hook.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Execute callbacks registered to a given hook.
1010

1111
<div>
1212
<strong>$when</strong> (string) Identifier for the hook.<br />
13-
<strong>...$args</strong> (mixed) Optional. Arguments that will be passed onto the<br />
14-
<strong>@return</strong> (null|mixed) the first optional argument if optional<br />
13+
<strong>...$args</strong> (mixed) Optional. Arguments that will be passed onto the<br /> callback provided by `WP_CLI::add_hook()`.<br />
14+
<strong>@return</strong> (null|mixed) the first optional argument if optional&lt;br /&gt; arguments were passed, otherwise returns null.<br />
1515
</div>
1616

1717

@@ -21,8 +21,6 @@ Execute callbacks registered to a given hook.
2121

2222
See `WP_CLI::add_hook()` for details on WP-CLI's internal hook system.
2323
Commands can provide and call their own hooks.
24-
callback provided by `WP_CLI::add_hook()`.
25-
arguments were passed, otherwise returns null.
2624

2725

2826
*Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.*

internal-api/wp-cli-utils-esc-like.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ First half of escaping for LIKE special characters % and _ before preparing for
99
WP_CLI\Utils\esc_like( $text )
1010

1111
<div>
12-
<strong>$text</strong> (string) The raw text to be escaped. The input typed by the user should have no<br />
13-
<strong>@return</strong> (string) in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare()<br />
12+
<strong>$text</strong> (string) The raw text to be escaped. The input typed by the user should have no<br /> extra or deleted slashes.<br />
13+
<strong>@return</strong> (string) in the form of a LIKE phrase. The output is not SQL safe. Call $wpdb::prepare()&lt;br /&gt; or real_escape next.<br />
1414
</div>
1515

1616

@@ -21,8 +21,6 @@ First half of escaping for LIKE special characters % and _ before preparing for
2121
Use this only before wpdb::prepare() or esc_sql(). Reversing the order is very bad for security.
2222

2323
Copied from core "wp-includes/wp-db.php". Avoids dependency on WP 4.4 wpdb.
24-
extra or deleted slashes.
25-
or real_escape next.
2624

2725

2826
*Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.*

internal-api/wp-cli-utils-http-request.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Make a HTTP request to a remote URL.
1111
<div>
1212
<strong>$method</strong> (string) HTTP method (GET, POST, DELETE, etc.).<br />
1313
<strong>$url</strong> (string) URL to make the HTTP request to.<br />
14-
<strong>$data</strong> (array|null) Data to send either as a query string for GET/HEAD requests,<br />
14+
<strong>$data</strong> (array|null) Data to send either as a query string for GET/HEAD requests,<br /> or in the body for POST requests.<br />
1515
<strong>$headers</strong> (array) Add specific headers to the request.<br />
1616
<strong>$options</strong> (array) {<br /> Optional. An associative array of additional request options.<br /> @type bool $halt_on_error Whether or not command execution should be halted on error. Default: true<br /> @type bool|string $verify A boolean to use enable/disable SSL verification<br /> or string absolute path to CA cert to use.<br /> Defaults to detected CA cert bundled with the Requests library.<br /> @type bool $insecure Whether to retry automatically without certificate validation.<br />}<br />
1717
<strong>@return</strong> (\Requests_Response|Response) <br />
@@ -32,7 +32,6 @@ if ( 20 != substr( $md5_response->status_code, 0, 2 ) ) {
3232
WP_CLI::error( "Couldn't access md5 hash for release (HTTP code {$response->status_code})" );
3333
}
3434
```
35-
or in the body for POST requests.
3635

3736

3837
*Internal API documentation is generated from the WP-CLI codebase on every release. To suggest improvements, please submit a pull request.*

0 commit comments

Comments
 (0)