sizeof(): Parameter must be an array or an object that implements Countable
Marcelofj opened this issue · 7 comments
Hi, how can I Solve this?
private function _convertToArray($param)
{
$ret = array();
foreach ($param as $k => $v) {
if ($v instanceof PayPalModel) {
$ret[$k] = $v->toArray();
} elseif (sizeof($v) <= 0 && is_array($v)) { // this code error line
$ret[$k] = array();
} elseif (is_array($v)) {
$ret[$k] = $this->_convertToArray($v);
} else {
$ret[$k] = $v;
}
}
// If the array is empty, which means an empty object,
// we need to convert array to StdClass object to properly
// represent JSON String
if (sizeof($ret) <= 0) {
$ret = new PayPalModel();
}
return $ret;
}
Thanks.
I also keep getting this same error. Running the example provided in the readme generates this exact error.
i have same error and don't know how to solve this one
found the solutions
I found this in paypal/PayPal-PHP-SDK#1014
You need to change:
} elseif (sizeof($v) <= 0 && is_array($v) ) {
to
} elseif (is_array($v) && sizeof($v) <= 0) {
Hi, where is } elseif (sizeof($v) <= 0 && is_array($v) ) { ?
What file ?
thanks
For reference, in my case it was in /includes/libs/PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalModel.php
Hi, where is } elseif (sizeof($v) <= 0 && is_array($v) ) { ?
What file ?
thanks
At "vendor\paypal\rest-api-sdk-php\lib\PayPal\Common\PayPalModel.php"