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

bug GD in php 8.1 sizeof(): Argument #1 ($value) must be of type Countable|array, null given #38

Open
lllyx1 opened this issue Feb 28, 2024 · 0 comments

Comments

@lllyx1
Copy link

lllyx1 commented Feb 28, 2024

sizeof(): Argument #1 ($value) must be of type Countable|array, null given

code

<?php

namespace app\models;

use Yii;
use yiidreamteam\upload\ImageUploadBehavior;

/**
 * This is the model class for table "reviews".
 *
 * @property int $id
 * @property string|null $name
 * @property string|null $body
 * @property string|null $avatar
 * @property int|null $rating
 *
 * @mixin ImageUploadBehavior
 */
class Reviews extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'reviews';
    }
    public function behaviors(): array
    {
        return [
            [
                'class' => ImageUploadBehavior::class,
                'attribute' => 'avatar',
                'createThumbsOnRequest' => true,
                'filePath' => '@webroot/origin/reviews/[[id]].[[extension]]',
                'fileUrl' => '@web/origin/reviews/[[id]].[[extension]]',
                'thumbPath' => '@webroot/cache/reviews/[[profile]]_[[id]].[[extension]]',
                'thumbUrl' => '@web/cache/reviews/[[profile]]_[[id]].[[extension]]',
                'thumbs' => [
                    'thumb' => ['width'=>286, 'height'=>220],
                    'mini' => ['width' => 240, 'height' => 160],
                    'admin' => ['width'=> 100, 'height'=>100],
                    'webp_thumb' => ['width' => 100, 'height' => 100, 'extension' => 'webp'],
                ],
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['name', 'body'], 'string'],
            [['rating'], 'integer'],
            ['avatar', 'image', 'extensions' => 'jpg, jpeg, gif, png']
        ];
    }

}

Corrected if written in the GD file
protected $options = [];

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

1 participant