【问题标题】:class_exists(): Passing null to parameter #1 ($class) of type string is deprecatedclass_exists():不推荐将 null 传递给字符串类型的参数 #1 ($class)
【发布时间】:2022-07-03 01:13:02
【问题描述】:

我有这个新安装的 Yii2 Advanced,想知道你们中的任何人在从前端登录后是否遇到过这个错误?

你为解决这个问题做了什么?

下面是我的 composer.json

{
    "name": "yiisoft/yii2-app-advanced",
    "description": "Yii 2 Advanced Project Template",
    "keywords": ["yii2", "framework", "advanced", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.6.0",
        "yiisoft/yii2": "~2.0.14",
        "yiisoft/yii2-bootstrap4": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.1.0",
        "yiisoft/yii2-gii": "~2.2.0",
        "yiisoft/yii2-faker": "~2.0.0",
        "codeception/codeception": "^4.0",
        "codeception/module-asserts": "^1.0",
        "codeception/module-yii2": "^1.0",
        "codeception/module-filesystem": "^1.0",
        "codeception/verify": "~0.5.0 || ~1.1.0",
        "symfony/browser-kit": ">=2.7 <=4.2.4"
    },
    "config": {
        "process-timeout": 1800,
        "fxp-asset": {
            "enabled": false
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]
}

【问题讨论】:

  • 你从哪里得到这个错误的?在 wich 文件的哪一行?
  • 我能够通过将我的 php 版本降级到 7.2 来解决它。感谢您的帮助
  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。

标签: docker authentication yii2 deprecated yii2-advanced-app


【解决方案1】:

Yii2 似乎与 PHP 8.1 版本不兼容。 我不得不在我的 macbook 中回到 PHP 7.4 版

【讨论】:

    【解决方案2】:

    从 php 8.1 开始,您不能在 class_exists 函数中放置空值。 要解决这个问题,在文件 \vendor\yiisoft\yii2-debug\src\panels\UserPanel.php 中替换第 90/91 行

            if (!is_object($this->filterModel)
                && class_exists($this->filterModel)
    

            if (!is_object($this->filterModel) && $this->filterModel !== null
                && class_exists($this->filterModel)
    

    这不是很好的解决方案,因为我们正在编辑 yii 的源代码,但可以工作:)

    【讨论】:

      猜你喜欢
      • 2022-10-23
      • 2022-01-13
      • 2023-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 2021-10-02
      • 1970-01-01
      相关资源
      最近更新 更多