Skip to content
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

Warning: count(): Parameter must be an array or an object that implements Countable #551

Closed
jtreurniet opened this issue Sep 6, 2017 · 5 comments

Comments

@jtreurniet
Copy link

Q A
php-code-coverage version 5.2.2
PHP version 7.2.0RC1
Driver Xdebug
Xdebug version (if used) 2.6.0
Installation Method PHPUnit PHAR
Usage Method PHPUnit
PHPUnit version (if used) 6.3.0

When generating HTML documentation, I'm getting the following warning (the warning is repeated many, many times). The output seems okay, as far as I've been able to tell, however.

Warning:  count(): Parameter must be an array or an object that implements Countable in phar:///usr/bin/phpunit/php-code-coverage/Report/Html/Renderer/File.php on line 307
Stack trace:
  1. {main}() /usr/bin/phpunit:0
  2. PHPUnit\TextUI\Command::main() /usr/bin/phpunit:557
  3. PHPUnit\TextUI\Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:141
  4. PHPUnit\TextUI\TestRunner->doRun() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:212
  5. SebastianBergmann\CodeCoverage\Report\Html\Facade->process() phar:///usr/bin/phpunit/phpunit/TextUI/TestRunner.php:598
  6. SebastianBergmann\CodeCoverage\Report\Html\File->render() phar:///usr/bin/phpunit/php-code-coverage/Report/Html/Facade.php:117
  7. SebastianBergmann\CodeCoverage\Report\Html\File->renderSource() phar:///usr/bin/phpunit/php-code-coverage/Report/Html/Renderer/File.php:61
  8. count() phar:///usr/bin/phpunit/php-code-coverage/Report/Html/Renderer/File.php:307

If any details are required regarding the environment or configuration I'd be happy to provide those.

@remicollet
Copy link
Contributor

Fixed by pr #554, probably worth cherry-pick the fix in 4.0 and 5.0

@moon9257
Copy link

moon9257 commented Mar 6, 2018

wordpress 中加载html图片时,报这个错

@jdpedrie
Copy link

jdpedrie commented May 2, 2018

@remicollet @sebastianbergmann any chance of getting this fix cherry-picked over to support PHPUnit 5.7? I'd be happy to open a PR for it if it is something that would be considered!

@sebastianbergmann
Copy link
Owner

PHPUnit 5.7 is no longer supported.

@elyobo
Copy link

elyobo commented Oct 17, 2018

@jdpedrie PHPUnit 5.7 is not supported, which is entirely reasonable, but I have a pile of old code to support that I don't have the time or inclination to upgrade. Tests are generally run with an error handler that throws ErrorExceptions on warnings so this breaks tests, so I needed a workaround.

My branch has the fix applied to the 4.0 branch, and this can be used to provide the dependency for PHPUnit with composer, e.g. along the lines of the following

{
   "repositories": [ 
        {
            "type": "git",
            "url": "https://github.com/elyobo/php-code-coverage.git"
        }
    ],
    "require": {
        "phpunit/phpunit": "~5.0",
        "phpunit/php-code-coverage": "dev-4.0-dev as 4.0.4"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

This has things working for me with PHPUnit 5.7.

xelan added a commit to gmitirol/toolkit-pdftk that referenced this issue Jan 24, 2019
…ssue

PHPUnit 5.7 uses php-code-coverage (4.0.8) which causes a warning "count(): Parameter must be an array or an object that implements Countable"
See sebastianbergmann/php-code-coverage#551
PavelJurasek added a commit to PavelJurasek/php-bitpay-client that referenced this issue Apr 10, 2019
bytestream added a commit to bytestream/laravel-jsvalidation that referenced this issue Nov 5, 2019
rosell-dk added a commit to rosell-dk/htaccess-capability-tester that referenced this issue Sep 9, 2020
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

No branches or pull requests

6 participants