stdClass
in PHP should be an empty object, but it's count()
is 1
for some reason. Why?
PHP> (array)(new stdClass);
// array(
//
// )
PHP> empty(new stdClass);
// false
PHP> count(new stdClass);
// 1
If you read the documentation of the count function, you'll find this section about the return value:
Return Values
Returns the number of elements in array_or_countable. If the parameter is not an array or not an object with implemented Countable interface, 1 will be returned. There is one exception, if array_or_countable is NULL, 0 will be returned.