masterexploder/PHPThumb

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

Opened this issue ยท 4 comments

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.

Resolved, check this
#134

a02b4b7

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

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

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.