定制 reagordi/serializable-closure 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

reagordi/serializable-closure

最新稳定版本:1.0.0

Composer 安装命令:

composer require reagordi/serializable-closure

包简介

Reagordi Serializable Closure provides an easy and secure way to serialize closures in PHP.

README 文档

README

Reagordi

Reagordi Serializable Closure


Latest Stable Version Total Downloads Build status Code Coverage

Mutation testing badge

static analysis type-coverage psalm-level

Reagordi Serializable Closure provides an easy and secure way to serialize closures in PHP.

Requirements

  • PHP 8.2 or higher.

Installation

The package could be installed with composer:

composer require reagordi/serializable-closure

General usage

You may serialize a closure this way:

use Reagordi\Component\SerializableClosure\SerializableClosure;

$closure = fn () => 'james';

// Recommended
SerializableClosure::setSecretKey('secret');

$serialized = serialize(new SerializableClosure($closure));
$closure = unserialize($serialized)->getClosure();

echo $closure(); // james;

Caveats

  • Anonymous classes cannot be created within closures.
  • Attributes cannot be used within closures.
  • Serializing closures on REPL environments like Laravel Tinker is not supported.
  • Serializing closures that reference objects with readonly properties is not supported.

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

Code style

Use Rector to make codebase follow some specific rules or use either newest or any specific version of PHP:

./vendor/bin/rector

Dependencies

Use ComposerRequireChecker to detect transitive Composer dependencies.

License

The Reagordi Serializable Closure is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Reagordi Group.

Support the project

Open Collective

Follow updates

Official website Telegram

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-05-01