Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Marcelofj opened this issue Mar 5, 2018 · 7 comments

Comments

@Marcelofj
Copy link

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.

@ngugijames
Copy link

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

@amitm13
Copy link

amitm13 commented Apr 20, 2018

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

@s201236215H
Copy link

#148

found the solutions

@HelyChirinos
Copy link

HelyChirinos commented May 13, 2018

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) {

@gutofurlan
Copy link

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

@nelitow
Copy link

nelitow commented Aug 1, 2018

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

@sahraoui17
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants