Repository navigation
Conversation
The example prints each class name followed by a space, so its output has no quotes and ends with a space. The output comment wrapped that output in quotes, so the Code Reference showed output the code never prints. The comment now states the output as a JSON-encoded string, which shows the trailing space.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
I will probably tweak the expected output, I'm not excited about the JSON encoded version just to protect the trailing space. Open to suggestions. |
A JSON-encoded output comment is harder to read than the output it states. Printing each class name on its own line lets the multiline output comment state the output as plain text, with a final empty line for the trailing newline.
|
One clean alternative that avoids both the trailing space issue and JSON encoding is converting to an array or joining the yielded classes: $classes = iterator_to_array( $p->class_list() );
// [ 'free', '<egg>', 'lang-en' ]Or if joining them with a comma/delimiter: echo implode( ', ', iterator_to_array( $p->class_list() ) );
// Outputs: free, <egg>, lang-enAlternatively, if keeping the $names = array();
foreach ( $p->class_list() as $class_name ) {
$names[] = $class_name;
}
echo implode( ', ', $names );
// Outputs: free, <egg>, lang-en |
The
class_list()example prints each class name followed by a space. Its output comment wrapped that output in quotes, and a// Outputs:comment states the rest of its line as the output, so the Code Reference shows quotes the code never prints. The example now prints one class name per line, and the multiline output comment states that output as plain text, with a final empty//line for the trailing newline.// Outputs: "free <egg> lang-en "(trunk)'"free <egg> lang-en "''free <egg> lang-en '// Outputs:, then// free,// <egg>,// lang-en,//"free\n<egg>\nlang-en\n""free\n<egg>\nlang-en\n"Stated outputs are what phpdoc-parser at WordPress/phpdoc-parser@a1ba4bd extracts; printed outputs are from running each example.
Trac ticket: https://core.trac.wordpress.org/ticket/65860
Use of AI Tools
AI assistance: Yes
Tools: Claude Code
Models: Claude Opus 5.5
Used for: Finding the incorrect comment, the change, its verification, and drafting this description.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.