升级到PHP 8时查找破坏变化

发布于 2025-02-03 18:07:36 字数 188 浏览 2 评论 0原文

PHP 8.0引入了许多可以破坏现有代码的更改。例如 count()现在抛出异常而不是返回布尔值当给出零论点时。在

PHP 8.0 introduces a number of changes that can break existing code. For example count() now throws an exception instead of returning a boolean when given a null argument. This change is not mentioned in the Backward Incompatible Changes document. Is there tool or method to systematically analyze an existing PHP code base to flag potential breaking changes caused by upgrading to the PHP 8 engine?

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

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

发布评论

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

评论(1

怀念你的温柔 2025-02-10 18:07:36

校长从早期版本升级代码(并降级(如果需要))。对于count()的问题,有 iscountablerector ,它将添加is_countable($ var)在使用count> Count()内使用问题变量之前检查。

使用“一组”规则通常更容易,例如:
$ contionerConfigurator-> import(LevelSetList :: UP_TO_TO_PHP_80);

Rector can help to upgrade code from earlier versions (and downgrade, if required). For the issue of count(), there is the IsCountableRector, which will add an is_countable($var) check ahead of the use of problematic variables within the count().

Using a 'set' of rules is usually easier, such as:
$containerConfigurator->import(LevelSetList::UP_TO_PHP_80);

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