Codeigniter: PHP 7.2 strict/warning. Count on row_array() fails when there are no results.

Created on 27 Mar 2018  路  1Comment  路  Source: bcit-ci/CodeIgniter

Hi,

Since php 7.2 the count of a non-countable object fails.
See https://wiki.php.net/rfc/counting_non_countables
and http://php.net/manual/en/function.count.php

This function row_array:
https://github.com/bcit-ci/CodeIgniter/blob/c243df3af851fe90cd272f3958f7eb7bf76173b1/system/database/DB_result.php#L431

returns null when count of the result equals null, but the @return states it should return an array. I think this function should return the array like the phpdoc states as to make it compatible with php7.2. Example can be found in

https://github.com/bcit-ci/CodeIgniter/blob/c243df3af851fe90cd272f3958f7eb7bf76173b1/system/database/DB_result.php#L274

>All comments

There's nothing incompatible or wrong with the function and it won't be changed.

It's the phpdoc annotation that's inaccurate, and there's many more instances of that throughout the entire framework. We simply don't treat those as code, but as inline documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

it-can picture it-can  路  5Comments

anharku picture anharku  路  3Comments

Tjoosten picture Tjoosten  路  6Comments

vahidvdn picture vahidvdn  路  4Comments

mckaygerhard picture mckaygerhard  路  4Comments