Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.4 support #672

Merged
merged 7 commits into from
Dec 11, 2024
Merged

PHP 8.4 support #672

merged 7 commits into from
Dec 11, 2024

Conversation

agrzegorzewski
Copy link
Contributor

@agrzegorzewski agrzegorzewski commented Dec 6, 2024

Goal

With the recent release of PHP 8.4, some of the features that were used by the notifier were marked as deprecated and started throwing depreciation warnings. This PR removes both of the depreciation warnings without breaking backwards compatibility.

https://php.watch/versions/8.4/E_STRICT-deprecated
https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated

Design

The issue with nullable types was solved by removing type annotations from parameters that default to null. Type annotations provided in the doc comments above already provide accurate annotations, so LSPs should continue to infer types correctly.

The depreciation of E_STRICT required more widespread changes. Due to conditional properties in associative arrays not being supported in <6.0, the list of errors had to be rewritten with an initializer that conditionally adds the value to the array. This also warranted a change in tests that rely on E_STRICT.

The added tests for PHP 8.3 and 8.4 required small changes in the unit tests to account for differences in error messages.

Changeset

  • Removed type hints from optional parameters.
  • Removed the usage of E_STRICT in PHP 8.4+.
  • Added PHP 8.3 and 8.4 to tests.
  • Adjusted unit tests.

Testing

Tested manually and automatically. No new tests were added. Some of the existing tests were extended.

@agrzegorzewski agrzegorzewski changed the title only include E_STRICT on <8.4 PHP 8.4 support Dec 6, 2024
@agrzegorzewski
Copy link
Contributor Author

I have no clue why PHP 7.2 tests suddenly fail. It feels related to bugsnag/bugsnag-laravel#544

@agrzegorzewski
Copy link
Contributor Author

I tried applying the same fix as in that Laravel PR, but it didn't help

Copy link
Contributor

@Cawllec Cawllec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this against our previous versions, and it seems to resolve the 8.4 issues nicely! I've also tested with PHP 5, and can confirm it works there as well.

Could we retarget the merge into next, then I can take care of the changelog and version bumps, and get it released?

@tomlongridge tomlongridge changed the base branch from master to next December 6, 2024 17:05
@Cawllec Cawllec merged commit f5b4d2d into next Dec 11, 2024
50 checks passed
@Cawllec Cawllec deleted the fix/php84support branch December 11, 2024 11:41
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.

3 participants