Skip to content

Accept plaintext as an alias of var_export in cli param-dump - #6339

Merged
swissspidy merged 2 commits into
wp-cli:mainfrom
thisismyurl:fix/param-dump-accept-plaintext-format
Sep 14, 2026
Merged

swissspidy merged 2 commits into
wp-cli:mainfrom
thisismyurl:fix/param-dump-accept-plaintext-format

Conversation

@thisismyurl

@thisismyurl thisismyurl commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

plaintext and var_export are two names for the same plain-text output format across WP-CLI. The single-value formatters already register both names to the same handler, but cli param-dump does its own var_export( $spec ) and only listed var_export in its documented --format options.

That meant --format=plaintext wasn't silently doing anything wrong, it was rejected outright: WP-CLI validates a flag's value against its options: list before the command ever runs, so it errored with Invalid value specified for 'format' instead of running at all.

This accepts both names in param-dump and lists plaintext in the command's documented --format options, matching the suggestion on #4774 to accept both wherever that format is used. It is backward compatible: var_export keeps working and plaintext now works too.

To verify: wp cli param-dump --format=plaintext now emits the PHP var_export representation (e.g. 'path' =>) instead of erroring. A functional test in features/cli.feature covers it.

Refs #4774

(full disclosure: AI helped me identify the issue and verify my work)

`plaintext` and `var_export` are the same plain-text output format under two
names across WP-CLI commands. `cli param-dump` only honored `var_export`, so
`--format=plaintext` silently fell through to JSON. Accept both names (and list
`plaintext` in the documented options) so the format is consistent with the
single-value formatters, which already alias the two.

Adds a functional test asserting `--format=plaintext` emits the var_export
representation.

Refs wp-cli#4774
@thisismyurl
thisismyurl requested a review from a team as a code owner June 30, 2026 12:40
@github-actions

Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions Bot added command:cli Related to 'cli' command command:cli-param-dump Related to 'cli param-dump' command labels Jun 30, 2026
@codecov

codecov Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI lite review requested due to automatic review settings August 6, 2026 12:25
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a322a798-69ae-4e0e-87d5-f9216a5ddf5e

📥 Commits

Reviewing files that changed from the base of the PR and between 05fd7f2 and 2965e1b.

📒 Files selected for processing (2)
  • features/cli.feature
  • php/commands/src/CLI_Command.php

📝 Walkthrough

Walkthrough

wp cli param-dump now accepts plaintext as an alias for var_export and includes BDD coverage for its output, stderr, and exit code.

Changes

CLI parameter dump formatting

Layer / File(s) Summary
Plaintext format support
php/commands/src/CLI_Command.php, features/cli.feature
The command documents and accepts plaintext as a var_export format. The BDD scenario verifies the output, empty stderr, and successful exit code.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: bug

Suggested reviewers: copilot, schlessera, swissspidy

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: accepting plaintext as an alias for var_export in cli param-dump.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.2.7)

PHPStan was skipped because the config uses disallowed bootstrapFiles, bootstrapFile, or includes directives.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns wp cli param-dump with the rest of WP-CLI’s format naming by accepting plaintext as an alias of var_export, preventing --format=plaintext from falling back to JSON and documenting the alias.

Changes:

  • Accept both var_export and plaintext for wp cli param-dump --format=....
  • Document plaintext as a valid --format option for cli param-dump.
  • Add a Behat scenario verifying --format=plaintext emits var_export-style output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
php/commands/src/CLI_Command.php Accepts plaintext alongside var_export and documents the new option in the command help.
features/cli.feature Adds an acceptance test ensuring --format=plaintext outputs the var_export representation (e.g. 'path' =>).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@schlessera schlessera left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approve. The alias is right: Formatter.php:367 and :370 already register var_export and plaintext on the same handler, and param-dump was the one place that knew only one name. Adding plaintext to the options: list (CLI_Command.php:996) and accepting both in the check (:1042) is the whole fix, and the scenario covers it.

One correction for the description: on main --format=plaintext does not "silently fall through to JSON". The options: list in the docblock makes the argument validator reject it before the command runs (Subcommand.php:552-586): Error: Parameter errors: Invalid value specified for 'format'. So this turns a hard error into working output, which is additive and safe. Please reword that sentence so the release notes do not describe a fallback that never happened.

Optional, not blocking: CLI_Command.php:983 still says "as JSON or in var_export format"; naming both aliases there keeps wp help cli param-dump in step with the options list.

Milestone 3.0.0. #4774 stays open: this covers param-dump only.

@swissspidy swissspidy added this to the 3.0.0 milestone Sep 14, 2026
@swissspidy
swissspidy merged commit 07ac222 into wp-cli:main Sep 14, 2026
74 checks passed
@thisismyurl

Copy link
Copy Markdown
Contributor Author

Good catch, and you're right, that's not what happens. I traced it through Subcommand.php and it's a hard validation error against the options: list before the command body ever runs, not a fallback to anything. Reworded the description to say that plainly.

Appreciate you naming the exact lines. I'll leave the param-dump docblock summary as-is since this one's merged, but I'll fold "mentions plaintext in the summary line too" into whatever comes next on #4774.

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

Labels

command:cli Related to 'cli' command command:cli-param-dump Related to 'cli param-dump' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants