升级到PHP 8时查找破坏变化
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
校长从早期版本升级代码(并降级(如果需要))。对于
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 anis_countable($var)
check ahead of the use of problematic variables within thecount()
.Using a 'set' of rules is usually easier, such as:
$containerConfigurator->import(LevelSetList::UP_TO_PHP_80);