Fix php_uname() ValueError on PHP 8.4+#125
Open
JoshSalway wants to merge 2 commits intolaravel:masterfrom
Open
Fix php_uname() ValueError on PHP 8.4+#125JoshSalway wants to merge 2 commits intolaravel:masterfrom
JoshSalway wants to merge 2 commits intolaravel:masterfrom
Conversation
PHP_OS is a string constant (e.g. "Darwin"), not a valid single-character mode for php_uname(). Use PHP_OS directly since it already contains the OS name. Fixes laravel#106 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that the OS detection in OpenCommand works without throwing a ValueError, confirming the php_uname() fix for PHP 8.4+. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Fixes #106
Summary
OpenCommandpassesPHP_OS(a string constant like"Darwin"or"Linux") as the mode parameter tophp_uname():In PHP 8.4+,
php_uname()strictly requires a single character mode ('a','s','n', etc.), causing aValueError. On PHP < 8.4, the multi-character string was silently accepted but produced undefined behavior (it only used the first character).Since
PHP_OSalready contains the OS name (same value asphp_uname('s')), the fix is to use it directly:PHP_OSis a compile-time constant available since PHP 4, so this works on all supported versions (^8.1.0per composer.json).Tests
Added
tests/Feature/OpenCommandTest.phpwith 3 tests:it can open a site in the browser— integration test exercising the full command with mocksit detects os without throwing value error— unit test confirmingstrtolower(PHP_OS)works without ValueError (the exact regression this PR fixes)it correctly identifies the current platform— validates OS detection returns darwin/linux/otherAll 3 tests pass.
Test plan
forge openworks on macOS (PHP_OS= "Darwin")forge openworks on Linux (PHP_OS= "Linux")🤖 Generated with Claude Code