laravel-paypalpayment icon indicating copy to clipboard operation
laravel-paypalpayment copied to clipboard

sizeof(): Parameter must be an array or an object that implements Countable

Open Marcelofj opened this issue 6 years ago • 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.

Marcelofj avatar Mar 05 '18 19:03 Marcelofj

I also keep getting this same error. Running the example provided in the readme generates this exact error.

ngugijames avatar Mar 06 '18 17:03 ngugijames

i have same error and don't know how to solve this one

amitm13 avatar Apr 20 '18 05:04 amitm13

#148

found the solutions

s201236215H avatar Apr 23 '18 07:04 s201236215H

I found this in https://github.com/paypal/PayPal-PHP-SDK/issues/1014 You need to change:

} elseif (sizeof($v) <= 0 && is_array($v) ) { to } elseif (is_array($v) && sizeof($v) <= 0) {

HelyChirinos avatar May 13 '18 05:05 HelyChirinos

Hi, where is } elseif (sizeof($v) <= 0 && is_array($v) ) { ? What file ? thanks

gutofurlan avatar Jun 26 '18 14:06 gutofurlan

For reference, in my case it was in /includes/libs/PayPal-PHP-SDK/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalModel.php

nelitow avatar Aug 01 '18 01:08 nelitow

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"

sahraoui17 avatar Nov 17 '18 07:11 sahraoui17