Skip to content

Fix main PHPSpec and PHP 8.4 compatibility: Wrap service container arrays in objects #64

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

balazscsaba2006
Copy link

The extension fails on PHP 8.4 with a TypeError when PhpSpec's IndexedServiceContainer::get() method expects an object return type but receives an array. This is due to stricter type enforcement in PHP 8.4.

Error:

Uncaught TypeError: PhpSpec\ServiceContainer\IndexedServiceContainer::get(): Return value must be of type object, array returned

PhpSpec's service container has a strict return type declaration of object for the get() method, but two services were returning arrays directly:

  • code_coverage.options - returned configuration array
  • code_coverage.reports - returned reports array

Introduced wrapper classes to encapsulate arrays while maintaining backward compatibility:

  1. CodeCoverageOptions Class
  2. CodeCoverageReports Class

Copy link
Member

@shulard shulard 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 @balazscsaba2006 for this PR. Some tiny questions in this review 😄.

@shulard
Copy link
Member

shulard commented Jul 10, 2025

Hello @balazscsaba2006 !

I've pushed some changes in #65 to fix issues with the GitHub workflows. Can you rebase your changes ? If you don't know how to do it I can help 😄.

@balazscsaba2006
Copy link
Author

Hello @balazscsaba2006 !

I've pushed some changes in #65 to fix issues with the GitHub workflows. Can you rebase your changes ? If you don't know how to do it I can help 😄.

Nice! I have rebased the PR.

@shulard
Copy link
Member

shulard commented Jul 10, 2025

Looks like there are some issues in the CI, can you try to run the following commands locally on your code:

composer run analyse
composer run lint
composer run test

This way you'll check the code structure and the tests. Let me know if you have strange issues 😉

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.

2 participants