-
Notifications
You must be signed in to change notification settings - Fork 370
Description
When executing the phpbrew use
command to switch PHP versions while running PHP 8.4, the command fails with multiple deprecation warnings and a parse error, preventing successful version switching. The issue appears to stem from deprecated nullable parameter handling in the CLIFramework
and GetOptionKit
dependencies, which are incompatible with PHP 8.4's stricter type system.
Steps to Reproduce:
- Install PHP 8.4.7 and PHP 8.2.28 using
phpbrew
. - Run
phpbrew use php-8.4.7
to set PHP 8.4 as the active version. - Verify the version with
php -v
(should show PHP 8.4.7). - Attempt to switch to PHP 8.2.28 using
phpbrew use php-8.2.28
.
Expected Behavior:
The phpbrew use php-8.2.28
command should successfully switch the active PHP version to 8.2.28, and php -v
should reflect PHP 8.2.28.
Actual Behavior:
The command fails with multiple PHP deprecation warnings related to implicitly nullable parameters in CLIFramework
and GetOptionKit
classes, followed by a parse error:
PHP Deprecated: CLIFramework\Application::__construct(): Implicitly marking parameter $container as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/bin/phpbrew/vendor/corneltek/cliframework/src/Application.php on line 103
...
PHP Deprecated: GetOptionKit\OptionResult::create(): Implicitly marking parameter $arguments as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/bin/phpbrew/vendor/corneltek/getoptionkit/src/OptionResult.php on line 145
...
(eval):49: parse error near `}'
After the error, the PHP version remains 8.4.7 (php -v
still shows PHP 8.4.7).
Environment:
- PHP Versions: 8.4.7 (active), 8.2.28 (target)
- phpbrew Version: 2.2.0
- Operating System: macOS 11
- Dependencies:
- CLIFramework 2.5.4
Error Details:
The deprecation warnings indicate that several classes in CLIFramework
and GetOptionKit
use implicitly nullable parameters, which is deprecated in PHP 8.4. The specific files and lines are:
CLIFramework\Application::__construct()
(Application.php:103
)CLIFramework\CommandBase::__construct()
(CommandBase.php:86
)CLIFramework\Logger::__construct()
(Logger.php:75
)GetOptionKit\OptionResult::create()
(OptionResult.php:145
)CLIFramework\Command::__construct()
(Command.php:30
)CLIFramework\Command\output()
(MetaCommand.php:39
)
The final parse error near '}'
suggests a syntax issue triggered during execution, possibly due to PHP 8.4's stricter parsing.
Suggested Fix:
The CLIFramework
and GetOptionKit
dependencies need to be updated to use explicit nullable types (e.g., ?Type
instead of implicit nullability) to comply with PHP 8.4. Alternatively, phpbrew
could pin compatible versions of these dependencies or include a workaround for PHP 8.4 compatibility.
Additional Information:
- The issue does not occur when running
phpbrew use
under PHP 8.2 or earlier versions. - The problem is reproducible consistently when PHP 8.4 is the active version.
Logs:
➜ ~ phpbrew use php-8.4.7
➜ ~ php -v
PHP 8.4.7 (cli) (built: May 14 2025 09:22:46) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.7, Copyright (c) Zend Technologies
with Xdebug v3.4.2, Copyright (c) 2002-2025, by Derick Rethans
➜ ~ phpbrew use php-8.2.28
[Deprecation warnings and stack traces as shown above]
(eval):49: parse error near `}'
➜ ~ php -v
PHP 8.4.7 (cli) (built: May 14 2025 09:22:46) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.7, Copyright (c) Zend Technologies
with Xdebug v3.4.2, Copyright (c) 2002-2025, by Derick Rethans