Fix CLI streams in Playground PHP runtimes - #1905
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
clinamespace fallback contract in the real Playground PHPUnit integration fixtureRoot cause
PHP-WASM does not define the CLI-only global
STDIN,STDOUT, orSTDERRconstants. WP Codebox already polyfilled them for the dedicatedwordpress.wp-clicommand, butwordpress.phpunitenters through the shared Playground PHP bootstrap instead. Tests that load WP-CLI formatter libraries therefore reachedphp-cli-toolswithout globalSTDOUT.PHP reports the failed unqualified lookup from
namespace clias the exact fatal:A Playground probe confirmed both
defined('STDOUT')anddefined('cli\\STDOUT')were false before this change. The fix defines the global CLI primitive; PHP's normal namespace fallback then resolves unqualifiedSTDOUTinclicode without defining a separate namespaced constant.Layer ownership
This belongs to WP Codebox's Playground/PHP runtime bootstrap. It does not patch vendored WP-CLI code and does not add a consumer workaround in data-machine-events.
Verification
npm run buildnpm run test:runtime-php-snippetsnpm exec -- tsx tests/phpunit-project-autoload.test.tsnpm run test:playground-phpunit-readonly-cache-integrationnpm run test:production-boundary-enforcementgit diff --checkwordpress.run-phpPlayground probe: globalSTDOUT/STDERRare defined resources and unqualifiedSTDOUTresolves insidenamespace cliThe broader runtime smoke group also exposed an unrelated pre-existing 25 ms timing assertion failure, tracked separately in #1904.
Closes #1901