Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xx9090950 opened this issue Jun 12, 2024 · 1 comment
Open

Comments

@xx9090950
Copy link

开发环境使用了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能注意到这个引入问题,在后续版本修复。谢谢

@yunwuxin
Copy link
Member

那这个应该是carbon的问题 他代码里使用了比他的composer.json要求的php版本高的特性

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants