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

**URL:** <https://discourse.cakephp.org/t/warning-2-count-parameter-must-be-an-array-or-an-object-that-implements-countable/8674>\
**Category:** Need Help\
**Created:** [November 30, 2020, 5:04pm UTC](https://discourse.cakephp.org/t/warning-2-count-parameter-must-be-an-array-or-an-object-that-implements-countable/8674 "2020-11-30T17:04:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahsan154](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@ahsan154](https://discourse.cakephp.org/u/ahsan154)\
**Post date:** [November 30, 2020, 5:04pm UTC](https://discourse.cakephp.org/t/warning-2-count-parameter-must-be-an-array-or-an-object-that-implements-countable/8674/1 "2020-11-30T17:04:24Z")

</div>

Hi Experts!

I am getting the following errors after upgrading php version from 7.2 to 7.3.

[**Warning** (2)](javascript:void(0);): count(): Parameter must be an array or an object that implements Countable [**CORE\src\Database\QueryCompiler.php** , line **128**]

I am using cakephp 3.3.8.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![jarekgol](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jarekgol](https://discourse.cakephp.org/u/jarekgol)\
**Post date:** [December 5, 2020, 12:10am UTC](https://discourse.cakephp.org/t/warning-2-count-parameter-must-be-an-array-or-an-object-that-implements-countable/8674/2 "2020-12-05T00:10:53Z")

</div>

> [@ahsan154](#):
>
> **CORE\src\Database\QueryCompiler.php** , line **128**

> <https://github.com/cakephp/cakephp/issues/10862>
>
> This is a (multiple allowed):
> 
> \* \[x\] bug
> \* \[\] enhancement
> \* \[\] feature-dis…cussion (RFC)
> 
> \* CakePHP Version: 3.4.8
> \* Platform and Target: Windows 7 (but it will affect all platforms running PHP 7.2)
> 
> PHP 7.2 has changed the behavior of count, it emits a warning if the object to be counted is not an array, or it does not implement the Countable interface:
> 
> https://wiki.php.net/rfc/counting\_non\_countables
> 
> As a result the \_sqlCompiler created function in the QueryBuilder now emits many warnings. This line is the problem:
> 
> https://github.com/cakephp/cakephp/blob/master/src/Database/QueryCompiler.php#L128
> 
> The \`$parts\` variable can be many different things, including non-arrays and objects not implementing the Countable interface (for example instances of Cake\\Database\\Expression\\ValuesExpression), and many different warnings will result during normal operations.
> 
> I presume that in future versions of PHP the old count behavior of returning 1 for non-arrays and non-Countable objects will be removed, so this should be fixed for that reason as well.
