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

Created on 8 Dec 2017  路  10Comments  路  Source: guzzle/guzzle

| Q | A
| ------------ | ---
| Bug? | yes
| New Feature? | no
| Version | 6.2.1

Actual Behavior

I get an ErrorException/app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php in handleError in this line:

if (count($this->handles) >= $this->maxHandles) {

Expected Behavior

There should not be an exception.

Possible Solutions

$this->handles should be an array or implement Countable. Maybe initialized with an empty array in the constructor.

Most helpful comment

Yes, This bug was fixed in 6.3.

Thank you @rawzone for the help.

All 10 comments

Also seeing this problem.

Using Guzzle 6.2.1 in a Laravel project.

Edit: Upgrading Guzzle to 6.3 fixed the problem though.

Yes, This bug was fixed in 6.3.

Thank you @rawzone for the help.

Ahhh @Nyholm! You're everywhere :)

Thanks!

simple fix.

if (count($this->handles) >= $this->maxHandles)

if ( $this->handles != null && count($this->handles) >= $this->maxHandles )

FYI I am fairly certain this has to do with only php 7.2

@Diego04 Thank you! I can't thank you enough!

I can't upgrade due to the whole erp built on user being gotten through the constructor __construct...

@mfoote I'm seeing this on php 5.5.9.

The problem is in PHP 7.2 the parameter for count() can't be NULL. The warning gets displayed when $this->handles equals NULL. Just replace line 67 in CurlFactory.php with the following:

if (($this->handles ? count($this->handles) : 0) >= $this->maxHandles) {

ErrorException in 51f0db6001c4f9b3b8a340919b69cacf9b5ea4aa.php line 227:
count(): Parameter must be an array or an object that implements Countable (View: C:\xampp\htdocs\bbtravels\resources\views\Frontend\Pages\index.blade.php)
@vinnoangel this error arises after i replaced line 67 with above line

Please produce line 227 for better understanding. Meanwhile I think the problem seems to be same with your former line 67. The count() parameter must be an array or object.

Was this page helpful?
0 / 5 - 0 ratings