Skip to content

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 😉

@balazscsaba2006
Copy link
Author

@shulard I fixed the spec tests now, sorry about that.

@balazscsaba2006 balazscsaba2006 requested a review from shulard July 15, 2025 08:49
@shulard
Copy link
Member

shulard commented Jul 15, 2025

@shulard I fixed the spec tests now, sorry about that.

No worries, thank you for the change. I still get issues in the CI about PHPStan like this:

composer run analyse
> phpstan analyse
Note: Using configuration file /home/runner/work/phpspec-code-coverage/phpspec-code-coverage/phpstan.neon.
 0/7 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
 7/7 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ --------------------------------------------------------------------- 
  Line   CodeCoverageExtension.php                                            
 ------ --------------------------------------------------------------------- 
  125    Parameter #2 $highLowerBound of class                                
         SebastianBergmann\CodeCoverage\Report\Text constructor expects int,  
         bool given.                                                          
 ------ ---------------------------------------------------------------------

Can you check those too ?

@balazscsaba2006
Copy link
Author

I get no error with the analyze command, I'm guessing it's due to the version of the phpunit/php-code-coverage:9.2. Locally I have v11.xx, I will make a fix for this.

@balazscsaba2006
Copy link
Author

@shulard I had to ignore the PHPStan issue, since it's not valid in case phpunit/php-code-coverage < 10.0. I also tested with all allowed major versions, 9.2, 10.0 and 11.0, it now should be fine.

@balazscsaba2006
Copy link
Author

@shulard https://github.com/friends-of-phpspec/phpspec-code-coverage/actions/runs/16315004454/job/46078986656?pr=64 is failing, and I don't have the permission to re-run it. Can you help out with rerunning pls?

@shulard
Copy link
Member

shulard commented Jul 16, 2025

@shulard https://github.com/friends-of-phpspec/phpspec-code-coverage/actions/runs/16315004454/job/46078986656?pr=64 is failing, and I don't have the permission to re-run it. Can you help out with rerunning pls?

Yes I tried to rerun, looks like we have some instabilities in the CI… Your changes are fixing all the remaining issues, whenever the pipeline is green, I'll merge them.

@balazscsaba2006
Copy link
Author

@shulard https://github.com/friends-of-phpspec/phpspec-code-coverage/actions/runs/16315004454/job/46078986656?pr=64 is failing, and I don't have the permission to re-run it. Can you help out with rerunning pls?

Yes I tried to rerun, looks like we have some instabilities in the CI… Your changes are fixing all the remaining issues, whenever the pipeline is green, I'll merge them.

now only one job is cancelled, probably too many processes running in parallel at one

@balazscsaba2006
Copy link
Author

balazscsaba2006 commented Jul 16, 2025

@shulard it seems now all of the jobs ran successfully in the CI 💪
If you will merge this, can you please create a release as well? 🙌

@shulard shulard merged commit e29538a into friends-of-phpspec:master Jul 16, 2025
260 of 362 checks passed
@shulard
Copy link
Member

shulard commented Jul 16, 2025

Yes I create a release now, thank you for this patch 🎉

@shulard
Copy link
Member

shulard commented Jul 16, 2025

Here it is, thank you for your work: https://github.com/friends-of-phpspec/phpspec-code-coverage/releases/tag/v6.5.0

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