Skip to content

carbon组件php版本约束不严格导致出现php语法不兼容 #186

@xx9090950

Description

@xx9090950

开发环境使用了PHP7.3.3版本
queue组件依赖了nesbot/carbon 组件
composer.json中声明了
"nesbot/carbon": "^2.16"
实际composer 引入了nesbot/carbon 2.72.4 源码链接
在cabon的composer.json中申明兼容7.1~8.0
我的7.3php满足他的约束就成功引入了。但是他在代码中使用了php7.4才支持的匿名函数。导致运行时报错报错源码链接

[error] [0]syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
#0 /www/wwwroot/xxx/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/www/wwwroot/xxx...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Carbon\\Traits\\C...')
#2 /www/wwwroot/xxx/vendor/nesbot/carbon/src/Carbon/Traits/Date.php(530): spl_autoload_call('Carbon\\Traits\\C...')

解决方案,翻看了carbon的源码,发现这个问题时在2.72.4版本才改的2.72.3 没有这个问题。我在我项目中的composer.json中引入2.72.3,就解决这个问题了。希望tp能注意到这个引入问题,在后续版本修复。谢谢

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions