chargebee / chargebee-php

PHP library for the Chargebee API.

Home Page:https://apidocs.chargebee.com/docs/api?lang=php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Empty list (array) is converted to object

zluiten opened this issue · comments

When a property of a Model is supposed to be a list of some subtype (for example taxes of the InvoiceEstimate), but the ChargeBee returns 0 items in the list, the list is not becoming an empty array, but an (empty) instance of the list type.

It looks like that this can be fixed by isHash function (inside ChargeBee_Model) returning false not only when not being an array, but also when the array is empy.

    private function isHash($array)
    {
        if (!is_array($array) || count($array) === 0)
            return false;
        foreach (array_keys($array) as $k) {
            if (is_numeric($k))
                return false;
            }
        return true;
    }

Any one concern this PR?