Phalcon\Mvc\Model::count() return string

In document, count() return int.

Abstract class Phalcon\Mvc\Model — Phalcon 1.3.0 documentation http://docs.phalconphp.com/en/latest/api/Phalcon%5Mvc%5Model.html

public static int count ([array $parameters])

But count() return string.

code:

        $count = Robots::count();
        var_dump($count);

result:

string '2' (length=1)

Is it bug?

Phalcon 1.3.2 (DB: MySQL)



9.4k

PHP is a weak type language, if a number present as a string, you still can use it as number, and make number operation on it.

Hi, hu2008yinxiang.

If count() returns int described in the document, I want to chek result by strict comparisons.

PHP: PHP type comparison tables - Manual http://php.net/manual/en/types.comparisons.php#type.comparisons-strict

Thanks.



9.4k

as the document it returns int, mean the result is number value, do you think it is realy matter the number value's type ?



9.4k

strict comparison work for the mixed returned value, but the Model::count always return a string-type number value. not the mixed-type

Hi, hu2008yinxiang.

This is not realy matter :). I feel a little bad feeling.

I haven't check cphalcon source code deeply, sorry. If the Model::count never returns FALSE, NULL and "", I'll check result by loose comparisons.

If the Model::count always return a string-type, I hope fix the document.

Thanks.