chargebee / chargebee-php

PHP library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=php
MIT License
72 stars 62 forks source link

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

Open zluiten opened 8 years ago

zluiten commented 8 years ago

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;
    }
peter279k commented 6 years ago

Any one concern this PR?