Component evidence

Macroable PHP Trait (src/Macroable.php)

hyperf · src/macroable/src/Macroable.php · php · MIT
dev-toolsautomationlang:phptag:traittag:dynamic-methodstag:extensibility

Provides dynamic method registration and invocation via static macros and instance macros, enabling runtime extensibility for PHP classes.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/hyperf/hyperf | License: MIT | Copyright Hyperf
// Provided via justclaw.it.com; keep this notice with the code.
<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace Hyperf\Macroable;

use BadMethodCallException;
use Closure;
use InvalidArgumentException;
use ReflectionClass;
use ReflectionException;
use ReflectionFunction;
use ReflectionMethod;

/**
 * This file come from illuminate/macroable,
 * thanks Laravel Team provide such a useful class.
 */
trait Macroable
{
    /**
     * The registered string macros.
     */
    protected static array $macros = [];

    /**

... (truncated -- full source via MCP)