zendframework / zend-test

Test component from Zend Framework
BSD 3-Clause "New" or "Revised" License
18 stars 38 forks source link

AbstractControllerTestCase's count not compatible with PHP 7.2 #62

Closed bitwombat closed 6 years ago

bitwombat commented 6 years ago

This line and similar:

https://github.com/zendframework/zend-test/blob/master/src/PHPUnit/Controller/AbstractControllerTestCase.php#L252

Rely on count, whose behavior has changed in PHP 7.2: http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.warn-on-non-countable-types

I think the fix is a simple boolean, taking advantage of short-circuit and behavior:

$params_exist = ( (null !==$params) && (count($params) > 0));

Will make that a PR if I'm not off the mark.

michalbundyra commented 6 years ago

@bitwombat In case $params can be only array|null and we check count($params) != 0 we can replace if with simply if ($params) and it will give us exactly the same result.

PR is very welcome ! 👍

michalbundyra commented 6 years ago

Fixed in #63

bitwombat commented 6 years ago

Beat me to it! Good work.