Search code examples
phpsymfonywampcountable

wamp- count(): Parameter must be an array or an object that implements Countable


i am working on symfony and got this message

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

This message is showing only for php 7.2.14, not for php 7.1.26.

I would like a solution that is applied on the server like this one for phpmyAdmin.

I know there are solutions involving changing the code like this one.

But i want a solution that is for all pages, so in the server side.

Thanks in advance !


Solution

  • PHP 7.2 now emits a warning if the count() argument is not countable. From the PHP doc :

    Version 7.2.0 : count() will now yield a warning on invalid countable types passed to the array_or_countable parameter.

    If the issue is coming from Symfony you should update to at least Symfony version 3.4 (see this issue).

    If the issue is coming from your code, you should edit your code to only count() arrays or classes implementing the Countable interface