fyre/macro 问题修复 & 功能扩展

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

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

fyre/macro

最新稳定版本:v2.0.1

Composer 安装命令:

composer require fyre/macro

包简介

A macro utility library.

README 文档

README

FyreMacro is a free, open-source macro utility library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/macro

Macros

You can attach Fyre\Utility\Traits\MacroTrait to any class.

use Fyre\Utility\Traits\MacroTrait;

// in any class
class MyClass {
    use MacroTrait;
}

Clear Macros

Clear all macros.

MyClass::clearMacros();

Has Macro

Determine whether a macro is registered.

  • $name is a string representing the name of the macro.
$hasMacro = MyClass::hasMacro($name);

Macro

Register a macro.

  • $name is a string representing the name of the macro.
  • $callback is the macro callback.
MyClass::macro($name, $callback);

Calling Macros

MyClass::macro('myMethod', function(): bool {
    return true;
});

new MyClass()->myMethod(); // true

Static Macros

You can attach Fyre\Utility\Traits\StaticMacroTrait to any class.

use Fyre\Utility\Traits\StaticMacroTrait;

// in any class
class MyClass {
    use StaticMacroTrait;
}

Clear Static Macros

Clear all static macros.

MyClass::clearStaticMacros();

Has Static Macro

Determine whether a static macro is registered.

  • $name is a string representing the name of the macro.
$hasStaticMacro = MyClass::hasStaticMacro($name);

Static Macro

Register a static macro.

  • $name is a string representing the name of the macro.
  • $callback is the macro callback.
MyClass::staticMacro($name, $callback);

Calling Static Macros

MyClass::staticMacro('myMethod', function(): bool {
    return true;
});

MyClass::myMethod(); // true

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-27