samlev/recursion-guard 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samlev/recursion-guard

Composer 安装命令:

composer require samlev/recursion-guard

包简介

A simple, zero-dependency mechanism for preventing infinite recursion in PHP

README 文档

README

A simple, zero dependency mechanism for preventing infinite recursion in PHP.

Build Status Total Downloads Latest Stable Version License

Installation

composer require samlev/recursion-guard

Usage

You can prevent a function from being called recursively by using RecursionGuard\Recurser::call() to execute a callback and provide a default result if the function is called recursively within the callback.

function bozo_repeat(string $repeat = ''): string
{
    return RecursionGuard\Recurser::call(
        // The callback that we want to call
        fn () => bozo_repeat() . ' : ' . bozo_repeat(),
        // What to return if this function is called recursively
        $repeat ?: 'bozo(' . random_int(0, 100)) . ')';
    );
}

bozo_repeat(); // 'bozo(4) : bozo(4)'
bozo_repeat('foo'); // 'foo : foo'
bozo_repeat(); // 'bozo(88) : bozo(88)'

See the documentation for more explanation, examples, and advanced usage.

Testing

You can run individual test suites using composer commands:

# Static Analysis with phpstan
composer test:types

# Architecture tests
composer test:architecture
# Documentation tests (tests that cover any code in the documentation)
composer test:docs
# Feature/integration tests
composer test:feature
# Unit tests
composer test:unit

# Code coverage
composer test:coverage

# Mutation tests
composer test:mutate

Or you can run grouped tests:

# All code style checks
composer lint

# Static analysis and main test suites
composer test

# All checks that should be performed before a PR (linting, static analysis, and mutation tests)
composer test:pr

Code Style

The code style for this project adheres to PSR-12, and can be checked using the following composer commands:

# Code Style checks with phpcs
composer lint:phpcs
# Code Style checks with PHP-CS-Fixer
composer lint:phpcsfixer

# Run all code style checks
composer lint

You can attempt to automatically fix a number of code style issues with the command:

composer lint:fix

Contributing

Contributions via PR are welcome, either as complete changes (including tests), or as failing test cases.

统计信息

  • 总下载量: 793
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固