yiisoft / yii2-debug

Debug Extension for Yii 2
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
202 stars 149 forks source link

#19380 PHP 8.1, class_exists(): Passing null to parameter #1 ($class) of type string is deprecated #483

Closed mazraara closed 2 years ago

mazraara commented 2 years ago

Caused by /app/vendor/yiisoft/yii2-debug/src/panels/UserPanel.php

        if (!$this->isEnabled() || $this->getUser()->isGuest) {
            return;
        }

        $this->userSwitch = new UserSwitch(['userComponent' => $this->userComponent]);
        $this->addAccessRules();

        if (!is_object($this->filterModel)
            && class_exists($this->filterModel)
            && in_array('yii\debug\models\search\UserSearchInterface', class_implements($this->filterModel), true)
        ) {
            $this->filterModel = new $this->filterModel;
        } elseif ($this->getUser() && $this->getUser()->identityClass) {
            if (is_subclass_of($this->getUser()->identityClass, 'yii\db\ActiveRecord')) {
                $this->filterModel = new \yii\debug\models\search\User();
            }
        }
    }

Reference https://php.watch/versions/8.1/internal-func-non-nullable-null-deprecation

Additional info

Q A
Yii version 2.0.45
PHP version 8.1
Operating system Mac
samdark commented 2 years ago

@mazraara do you have some time for a pull request?

mazraara commented 2 years ago

@samdark looks like there is already a fix for this here https://github.com/yiisoft/yii2-debug/pull/474/commits/5508ebe1bac8395c959b595a75e1a10aaf71124e

samdark commented 2 years ago

Great. Closing the issue then. Thanks for re-checking.