kartik-v / yii2-icons

Set of icon frameworks for easy use in Yii Framework 2.0
http://demos.krajee.com/icons
Other
71 stars 29 forks source link

PHP Deprecated Warning – yii\base\ErrorException strlen(): Passing null to parameter #1 ($string) of type string is deprecated #49

Closed newadventure079 closed 2 years ago

newadventure079 commented 2 years ago

Prerequisites

Steps to reproduce the issue

  1. Use yii 2.0.45 with php 8.1
  2. Include Icon::map($this);

Expected behavior and actual behavior

When I follow those steps, I see...

PHP Deprecated Warning – yii\base\ErrorException
strlen(): Passing null to parameter #1 ($string) of type string is deprecated
1. in /Users/Documents/code/htdocs/remv2/vendor/kartik-v/yii2-icons/src/Icon.phpat line 169

     * @var string $framework the framework to be used with the application
     * @var string $method the method in the Icon class (defaults to `show`)
     * @returns string the icon framework key
     * @throws InvalidConfigException
     * @return string
     */
    protected static function getFramework($framework = null, $method = 'show')
    {
        $len = strlen($framework);  <--- error here
        if ($len > 0 && !in_array($framework, array_keys(self::$_frameworks))) {
            $replace = ['{framework}' => $framework, '{method}' => 'Icon::' . $method];
            throw new InvalidConfigException(strtr(self::FRAMEWORK_INVALID, $replace));
        }
        if ($len > 0) {
            return $framework;
        }
        if ($len === 0 && empty(Yii::$app->params['icon-framework'])) {
            throw new InvalidConfigException(self::PARAM_NOT_SET);

I was expecting... The page to load without errors

Environment

Browsers

Operating System

Libraries

Isolating the problem