PHP code example of fyre / macro

1. Go to this page and download the library: Download fyre/macro library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fyre / macro example snippets


use Fyre\Utility\Traits\MacroTrait;

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

MyClass::clearMacros();

$hasMacro = MyClass::hasMacro($name);

MyClass::macro($name, $callback);

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

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

use Fyre\Utility\Traits\StaticMacroTrait;

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

MyClass::clearStaticMacros();

$hasStaticMacro = MyClass::hasStaticMacro($name);

MyClass::staticMacro($name, $callback);

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

MyClass::myMethod(); // true