Fix: Ensure YAML formatter outputs scalar values correctly #6158
+132
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Ensure YAML formatter outputs scalar values (e.g., 0, strings) correctly
Description
This PR resolves an issue where scalar values were incorrectly rendered by the YAML formatter in WP-CLI.
Previously, scalars such as
0or"hello"were being output as YAML lists instead of simple scalar values.Problem
When running commands with
--format=yaml, scalar values were misrepresented:This behavior is inconsistent with expected YAML scalar formatting and can cause confusion or break automation pipelines that rely on precise YAML output.
Fix
Verification (After Fix)
Tests
Checklist
Notes on CI Failures
codecov/patch: Shows 0% diff hit because Behat feature tests are not included in Codecov coverage reports. However, additional scenarios were added that do exercise the new code paths.
Functional tests on WP trunk + PHP nightly (MySQL/SQLite): These jobs are known to be unstable. All stable PHP/MySQL builds pass successfully, indicating this patch is safe.
Related Issue
Fixes #6094