Magic getter method bug
obukhov opened this issue · comments
In the method \ChargeBee_Model::__get
there is a bug affecting snake case fields:
public function __get($k)
{
if (isset($this->_data[$k]))
{
return $this->_data[$k];
}
else if(in_array($k, $this->allowed))
{
return null;
}
The property allowed
contains snake case fields (i.e. "CustomerBillingAddress" has "first_name").
However "_data" field contains keys already converted to camelCase. See line 131 of the same file:
$this->_data[ChargeBee_Util::toCamelCaseFromUnderscore($k)] = $setVal;
So if the first name in billing address is empty, both $billingAddress->first_name
and $billingAddress->firstName
throws an error.
Expected result: if the field is empty it should return null
This has been fixed in v3.0.0