class_exists():不推荐将 null 传递给字符串类型的参数 #1 ($class)

发布于 2025-01-17 03:25:00 字数 1604 浏览 1 评论 0原文

我有这个新安装的 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"
        }
    ]
}

I had this newly installed Yii2 advanced and want to know if anyone of you ever encountered this error after login from the frontend?

What solution did you do to solve this issue?

Below is my 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"
        }
    ]
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡水深流 2025-01-24 03:25:00

从 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 的源代码,但可以工作:)
Yii 2.0.46 版本可能会修复这个问题

it looks like as of php 8.1 you can't put null values in the class_exists function.
To fix that issue, in file \vendor\yiisoft\yii2-debug\src\panels\UserPanel.php replace line 90/91

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

with

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

It's not good solution because we are editing the source code of yii, but works :)
It is possible that version 2.0.46 of Yii will fix this

梦途 2025-01-24 03:25:00

看来 Yii2 不兼容 PHP 8.1 版本。
我不得不在我的 macbook 中恢复到 PHP 7.4 版本

It seems that Yii2 is not compatible with PHP version 8.1.
I had to go back to version 7.4 of PHP in my macbook

不必了 2025-01-24 03:25:00

它已在 634b9cc5e89bcc65091fe25ea2b5538b5bc5ce76 中修复,因此当新版本发布时它将被修复,同时您可以使用 "yiisoft/yii2-debug": "dev-master#..."

https://github.com/yiisoft/yii2-debug/issues/482

it is fixed in 634b9cc5e89bcc65091fe25ea2b5538b5bc5ce76, so when new release comes out it will be fixed, in the meantime you can use "yiisoft/yii2-debug": "dev-master#..."

https://github.com/yiisoft/yii2-debug/issues/482

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文