interitty/infinite-loop-prevention
最新稳定版本:v1.0.10
Composer 安装命令:
composer require interitty/infinite-loop-prevention
包简介
A simple infinite loop prevention tool.
README 文档
README
A simple infinite loop prevention tool that help developers to prevent the error Maximum function nesting level of '256' reached, aborting!.
Requirements
- PHP >= 8.5
Installation
The best way to install interitty/infinite-loop-prevention is using Composer:
composer require interitty/infinite-loop-prevention
Usage
For cases when an infinite loop can happen, especially when code work with a given callback, it can be handy to call preventive assertion in a non-production environment just to be sure, that code can't fall into an infinite loop.
Because the code is based on debug_backtrace,
it will be better to disable the mechanism on the production environment by setting the static
InfiniteLoopPrevention::$productionMode variable.
For better performance in the production environment, it will be better to use the assert,
because the execution and whole code generating can be disabled by the zend.assertions
in the php.ini file.
It only needs to call the static method without any parameters just inside the method or function where the given callback is called.
Example: Usage of checkFinite()
function test(): void
{
assert(InfiniteLoopPrevention::checkFinite());
test();
}
test();
统计信息
- 总下载量: 91
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-13