-
Notifications
You must be signed in to change notification settings - Fork 61
fix: resolve deprecations for implicitly nullable parameters in PHP 8.4 #231
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
base: master
Are you sure you want to change the base?
fix: resolve deprecations for implicitly nullable parameters in PHP 8.4 #231
Conversation
Resolved deprecation warnings related to implicitly nullable parameters in PHP 8.4. Adjusted parameter declarations to explicitly use nullable types where default `null` values are set. Changes were applied using the fixer with the `nullable_type_declaration_for_default_null_value` option. This ensures compatibility with PHP 8.4 and avoids deprecation messages.
@jcchavezs would you take a look. It'll take 2 min :) |
I would love to, have to admit that PHP is not my thing, @codefromthecrypt do you know who can help us here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! We have the same issue in our codebase
It looks like the CI needs to be updated in order to run. It's getting |
I added the missing PHP versions to the CI and updated the cache version. |
Reason: The ::set-output command was deprecated by GitHub. Replacing it improves security and ensures compatibility with the latest GitHub Actions standards. https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ Implementation: Replaced usages of the ::set-output command with the $GITHUB_OUTPUT. Side effects: None expected. The workflow behavior remains the same.
I swapped out |
Reason: The workflow was failing on Ubuntu and macOS because the output of the composer cache directory command had extra newlines, which broke the GitHub Actions output format. Implementation: Added a sanitization step to remove newlines and carriage returns from the command output using `tr -d '\n' | tr -d '\r'`. Side effects: None expected. The change ensures consistent behavior on all runners (Windows, macOS, and Linux).
I hope that's the end of the surprises... |
Reason: The CI workflow was failing because the step that retrieves the composer cache directory was not providing the correct path. This caused issues in subsequent steps that rely on the cache directory. Implementation: Modified the `Get composer cache directory` step to correctly define the path output. Side effects: None expected.
Reason: During tests, an error is thrown: `strpos(): Argument openzipkin#1 ($haystack) must be of type string, null given`. Implementation: Added a safeguard against null values. Additionally: Removed the `version` field from the Docker Compose file as it is unnecessary (the `version` attribute is obsolete). Side effects: None.
Reason: The abstract test classes had a "Test" suffix, which caused deprecation warnings in PHPUnit because it now tries to treat such classes as actual tests. Implementation: Renamed abstract test classes by appending the "Case" suffix to their names. Updated all references to the renamed classes accordingly. Side effects: No functional changes. Only class names were updated.
Reason: Namespace name doesn't match the PSR-0/PSR-4 project structure. Side effects: None expected.
Reason: PHP 8.0 is no longer a supported version. Implementation: Upgraded testing coverage to the latest supported PHP version (security fixes only). Side effects: None expected.
From what I can see, there’s probably an issue with access to Coveralls (maybe the token is invalid - I don’t know, it’s in the secrets). However, I also noticed a few other errors and warnings, so I’m fixing those. It’s possible that this test error was interfering with the coverage check. |
Can someone give an approval? |
Running the tests was failing:
|
Reason: This argument should be redundant, but CI tests fail to start, so it might be related to this issue (`Error response from daemon: No such container: zipkin_php_mysql_test`). Implementation: Added the `version` field to the Docker Compose file. Side effects: None expected.
One more approval, please. |
Reason: `docker-compose: not found`. Implementation: Replaced deprecated `docker-compose` commands with `docker compose`. Side effects: None.
That should help. |
Seems to have helped on ubuntu but macos is still having issues |
It seems that the As for macOS, it can be disabled for tests using Docker Compose (for Windows, it has been disabled for a long time). |
Reason: The mysql connection test by Docker compose does not work on macOS (`sh: docker: command not found`). Implementation: Previously, the test was skipped only on Windows. This update broadens the condition to skip the test on all non-Linux systems. Side effects: None.
Reason: We cannot push a simple fix due to an outdated CI configuration that has not been maintained for 2 years. Implementation: Commented out the step responsible for uploading coverage reports to the Codecov service. This change may be temporary or used to troubleshoot coverage reporting issues. Documentation references and environment variable configurations remain intact for future reactivation if needed. Side effects: Risk of neglecting code testing.
Since I doubt anyone will manage to configure php-coveralls, I suggest disabling it temporarily. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look reasonable to me, but like @reta, PHP is not in my area of expertise.
Shall we merge? |
Resolved deprecation warnings related to implicitly nullable parameters in PHP 8.4. Adjusted parameter declarations to explicitly use nullable types where default
null
values are set.Changes were applied using the fixer with the
nullable_type_declaration_for_default_null_value
option.This ensures compatibility with PHP 8.4 and avoids deprecation messages.