Skip to content

fix: PHP 8.4 nullable types, stderr error routing, and PHPUnit deprecations - #1407

Open
hiimalexjgarcia wants to merge 2 commits into
phpbrew:masterfrom
hiimalexjgarcia:fix/php-8.4-compatibility
Open

hiimalexjgarcia wants to merge 2 commits into
phpbrew:masterfrom
hiimalexjgarcia:fix/php-8.4-compatibility

Conversation

@hiimalexjgarcia

Copy link
Copy Markdown

Fixed up some PHP 8.4 deprecation notice regarding nullable parameters (apparently these issues will be fatal in PHP 9, so might as well address them).

The noticeable fix is sending errors and dep notices to stderr instead of stdout so they don't corrupt ~/.phpbrew/init and the like.

  • Explicitly mark nullable parameters (?Type $param = null) for PHP 8.4 compatibility in:
    • src/PhpBrew/VariantBuilder.php (build)
    • src/PhpBrew/Exception/SystemCommandException.php (__construct)
    • src/PhpBrew/Tasks/BaseTask.php (__construct)
    • src/PhpBrew/Tasks/PrepareDirectoryTask.php (run)
    • src/PhpBrew/ReleaseList.php (getReadyInstance)
    • src/PhpBrew/Extension/ExtensionInstaller.php (__construct)
  • Route PHP errors and deprecation notices to stderr via ini_set('display_errors', 'stderr') in bin/phpbrew before autoloading so shell-evaluated output is not corrupted.
  • Add PHP 8.4 to the test matrix in .github/workflows/tests.yaml.
  • Replace deprecated PHPUnit @ExpectedException and assertInternalType in tests.

Full disclosure: I used AI to produce this PR (Gemini 4 in this case).

- Remove blank lines after class opening braces (PSR12.Classes.OpeningBraceSpace.Found) in:
  - src/PhpBrew/Distribution/DistributionUrlPolicy.php
  - tests/PhpBrew/Command/DownloadCommandTest.php
  - tests/PhpBrew/Command/PathCommandTest.php
  - tests/PhpBrew/Extension/ExtensionInstallerTest.php
  - tests/PhpBrew/Extension/KnownCommandTest.php
  - tests/PhpBrew/Patches/Apache2ModuleNamePatchTest.php
- Wrap 8 lines exceeding 120 characters (Generic.Files.LineLength.TooLong) in src/PhpBrew/VariantBuilder.php (imap, pcre, and openssl variant builders).
…ations

- Explicitly mark nullable parameters (?Type $param = null) for PHP 8.4 compatibility in:
  - src/PhpBrew/VariantBuilder.php (build)
  - src/PhpBrew/Exception/SystemCommandException.php (__construct)
  - src/PhpBrew/Tasks/BaseTask.php (__construct)
  - src/PhpBrew/Tasks/PrepareDirectoryTask.php (run)
  - src/PhpBrew/ReleaseList.php (getReadyInstance)
  - src/PhpBrew/Extension/ExtensionInstaller.php (__construct)
- Route PHP errors and deprecation notices to stderr via ini_set('display_errors', 'stderr') in bin/phpbrew before autoloading so shell-evaluated output is not corrupted.
- Add PHP 8.4 to the test matrix in .github/workflows/tests.yaml.
- Replace deprecated PHPUnit @ExpectedException and assertInternalType in tests.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant