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

[PHP 7.2] sizeof(): Parameter must be an array or an object that implements Countable #131

Open
pmaselkowski opened this issue Sep 8, 2017 · 4 comments

Comments

@pmaselkowski
Copy link

pmaselkowski commented Sep 8, 2017

I know that this project seems abandoned... But here's the issue with sizeof:

                                                                                                             
  [PHPUnit_Framework_Exception] sizeof(): Parameter must be an array or an object that implements Countable  
                                                                                                             
#1  Codeception\Subscriber\ErrorHandler->errorHandler
#2  /home/travis/build/Maslosoft/Mangan/vendor/masterexploder/phpthumb/src/PHPThumb/GD.php:972
#3  /home/travis/build/Maslosoft/Mangan/vendor/masterexploder/phpthumb/src/PHPThumb/PHPThumb.php:64
#4  /home/travis/build/Maslosoft/Mangan/vendor/masterexploder/phpthumb/src/PHPThumb/GD.php:89
#5  /home/travis/build/Maslosoft/Mangan/src/Model/Image.php:101
#6  /home/travis/build/Maslosoft/Mangan/src/Model/File.php:145
#7  /home/travis/build/Maslosoft/Mangan/vendor/maslosoft/mangantest/tests/unit/GridFS/ImageTest.php:34
#8  GridFS\ImageTest->testIfWillResizeSavedImage

The problem is that options are defined without value:

    protected $options;

So in fact are initialized with null, not empty array.

Then there is check for array size with sizeof (alias for count).

Workaround

Create class:

class ImageThumb extends GD
{
	protected $options = [];
}

And use this new class instead of GD.

@muslimakhan
Copy link

muslimakhan commented Oct 5, 2018

Resolved, check this
#134

a02b4b7

@pmaselkowski
Copy link
Author

@muslimakhan Are You capable of (ie, have permissions?) to create tag with this fix so that it would allow installing it with composer?

@monter08
Copy link

Everyone who have this issue and using composer:

Add to composer.json
"repositories": [ { "type": "vcs", "url": "https://github.com/monter08/PHPThumb" }]

and
composer update masterexploder/phpthumb

@henrycolonia
Copy link

Hello, is there a way for this change to be present in version 2.1 shown at https://packagist.org/packages/masterexploder/phpthumb#2.1 ?. I understand that it can be obtained from the version "
dev-master ", but I am using an external library that requires any version of this project that starts with" 2. * ", so updating against" dev-master "generates conflicts for me.

Thanks.

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

4 participants