-
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
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? |
@@ -20,12 +20,12 @@ final class MysqliTest extends TestCase | |||
private static function launchMySQL(): array | |||
{ | |||
shell_exec('docker rm -f zipkin_php_mysql_test'); | |||
shell_exec(sprintf('cd %s; docker-compose up -d', __DIR__)); | |||
shell_exec(sprintf('cd %s; docker compose up -d', __DIR__)); |
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.
So this change cuts docker compose v1 off (docker-compose
vs docker compose
), probably makes sense, just highlighting that
Doing my best, read https://php.watch/versions/8.0/null-safe-operator over and change does look good, the coverage part needs a solution (could be separate pull request, looking into it) |
@codefromthecrypt could you please help with coverage token, I don't have access to repository settings sadly, thank you |
@reta it looks like I have access to the repo settings. Can I help with updating the coverage token? Or I can try adding permissions for you, although I can't figure out why we would have different permissions. |
"coverage token"? we didn't put anything intentionally to require coverage checks... I know we optionally had it at some point, but that's something that can be removed. |
.github/workflows/ci.yml
Outdated
# https://github.com/php-coveralls/php-coveralls/issues/273#issuecomment-537473525 | ||
COVERALLS_RUN_LOCALLY: 1 | ||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | ||
# - name: Upload coverage report to codecov service |
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.
I would just delete this whole section
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.
and also delete the icon from the README as well. then no more problem around this.
Thanks @shakuzen , let's us get rid of this section altogether , as @codefromthecrypt suggested, thank you. @wesolydexter could you please do that? thank you |
Reason: Due to the outdated configuration of the Coveralls tool, we are removing code coverage from the project CI. We decided that code coverage can be addressed in a separate PR in the future. Implementation: Code coverage has been removed from the CI pipeline and README.md. Side effects: The support for code coverage should be restored in the future.
Done. |
Thanks @wesolydexter ! |
- name: Cache composer dependencies | ||
uses: actions/cache@v2 | ||
uses: actions/cache@v3 |
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.
uses: actions/cache@v3 | |
uses: actions/cache@v4 |
FYI the v4 is available too, hopefully it doesn't break anything
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.
ok, now let it stay as it is
Who can merge? |
Epic. Thanks! |
Maybe let's add a 3.2.1 tag? |
@wesolydexter https://github.com/openzipkin/zipkin-php/releases/tag/3.2.1 Thanks for all the work renovating! |
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.