Skip to content

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

Conversation

wesolydexter
Copy link
Contributor

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.

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.
@wesolydexter
Copy link
Contributor Author

@jcchavezs would you take a look. It'll take 2 min :)

@jcchavezs
Copy link
Contributor

jcchavezs commented Apr 10, 2025

I am not part of this project anymore but changes LGTM. I would say you should add a link to the deprecation and support 8.2, 8.3 and 8.4 on the CI and see what happens and maybe @reta or @shakuzen can approve the CI.

@reta
Copy link

reta commented Apr 10, 2025

I am not part of this project anymore but changes LGTM. I would say you should add a link to the deprecation and support 8.2, 8.3 and 8.4 on the CI and see what happens and maybe @reta or @shakuzen can approve the CI.

I would love to, have to admit that PHP is not my thing, @codefromthecrypt do you know who can help us here?

Copy link

@BafS BafS left a 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

@shakuzen
Copy link
Member

It looks like the CI needs to be updated in order to run. It's getting Missing download info for actions/cache@v2 which looks to be caused by v2 of that Action being EOL: https://github.blog/changelog/2024-12-05-notice-of-upcoming-releases-and-breaking-changes-for-github-actions/#actions-cache-v1-v2-and-actions-toolkit-cache-package-closing-down

@wesolydexter
Copy link
Contributor Author

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.
@wesolydexter
Copy link
Contributor Author

I swapped out ::set-output for $GITHUB_OUTPUT because the old one’s outdated.
https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands

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).
@wesolydexter
Copy link
Contributor Author

I hope that's the end of the surprises...

dmajka added 5 commits April 11, 2025 12:38
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.
@wesolydexter
Copy link
Contributor Author

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.

@wesolydexter
Copy link
Contributor Author

Can someone give an approval?

@shakuzen
Copy link
Member

Running the tests was failing:

Run composer test -- --coverage-clover=build/logs/clover.xml
> phpunit tests '--coverage-clover=build/logs/clover.xml'
PHPUnit [9](https://github.com/openzipkin/zipkin-php/actions/runs/14403682799/job/40485287264?pr=231#step:9:10).6.22 by Sebastian Bergmann and contributors.
Error response from daemon: No such container: zipkin_php_mysql_test
sh: 1: docker-compose: not found

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.
@wesolydexter
Copy link
Contributor Author

One more approval, please.

Reason: `docker-compose: not found`.
Implementation: Replaced deprecated `docker-compose` commands with `docker compose`.
Side effects: None.
@wesolydexter
Copy link
Contributor Author

That should help.

@shakuzen
Copy link
Member

Seems to have helped on ubuntu but macos is still having issues

@wesolydexter
Copy link
Contributor Author

It seems that the php-coveralls configuration is causing the issue here. The error Client error occurred. status: 422 Unprocessable Entity and the message Couldn't find a repository matching this job usually indicate a problem with the COVERALLS_REPO_TOKEN configuration. Could you please double-check that the correct token is set in the repository secrets, and verify that the project is properly linked to Coveralls?
If fixing the token isn’t feasible or Coveralls isn’t critical for this project, we might consider removing this step from the workflow, as the coverage report submission isn’t working as expected anyway.

As for macOS, it can be disabled for tests using Docker Compose (for Windows, it has been disabled for a long time).

dmajka added 2 commits April 15, 2025 12:42
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.
@wesolydexter
Copy link
Contributor Author

Since I doubt anyone will manage to configure php-coveralls, I suggest disabling it temporarily.

Copy link
Member

@shakuzen shakuzen left a 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.

@wesolydexter
Copy link
Contributor Author

Shall we merge?

@wesolydexter
Copy link
Contributor Author

@reta?

@@ -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__));
Copy link

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

@reta
Copy link

reta commented Apr 20, 2025

@reta?

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)

@reta
Copy link

reta commented Apr 21, 2025

@codefromthecrypt could you please help with coverage token, I don't have access to repository settings sadly, thank you

@shakuzen
Copy link
Member

@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.

@codefromthecrypt
Copy link
Member

"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.

# 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
Copy link
Member

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

Copy link
Member

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.

@reta
Copy link

reta commented Apr 21, 2025

@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.

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.
@wesolydexter
Copy link
Contributor Author

Done.
@reta @shakuzen @codefromthecrypt

@reta
Copy link

reta commented Apr 23, 2025

Done.

Thanks @wesolydexter !

- name: Cache composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
Copy link

Choose a reason for hiding this comment

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

Suggested change
uses: actions/cache@v3
uses: actions/cache@v4

FYI the v4 is available too, hopefully it doesn't break anything

Copy link
Contributor Author

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

@wesolydexter
Copy link
Contributor Author

Who can merge?

@codefromthecrypt codefromthecrypt merged commit bad09ac into openzipkin:master Apr 24, 2025
18 checks passed
@codefromthecrypt
Copy link
Member

Epic. Thanks!

@wesolydexter
Copy link
Contributor Author

Maybe let's add a 3.2.1 tag?

@codefromthecrypt
Copy link
Member

@wesolydexter https://github.com/openzipkin/zipkin-php/releases/tag/3.2.1

Thanks for all the work renovating!

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.

6 participants