Kahlan\Plugin\Monkey::patched PHP Method

patched() public static method

Patches the string.
public static patched ( string $namespace, string $ref, boolean $isFunc = true, &$substitute = null ) : string
$namespace string The namespace.
$ref string The fully namespaced class/function reference string.
$isFunc boolean Boolean indicating if $ref is a function reference.
return string A fully namespaced reference.
    public static function patched($namespace, $ref, $isFunc = true, &$substitute = null)
    {
        $name = $ref;
        if ($namespace) {
            if (!$isFunc || function_exists("{$namespace}\\{$ref}")) {
                $name = "{$namespace}\\{$ref}";
            }
        }
        $method = isset(static::$_registered[$name]) ? static::$_registered[$name] : null;
        $fake = $method ? $method->substitute() : null;
        if (!$isFunc) {
            if (is_object($fake)) {
                $substitute = $fake;
            }
            return $fake ?: $name;
        }
        if (!Suite::registered($name) && !$method) {
            return $name;
        }
        return function () use($name, $method) {
            $args = func_get_args();
            if (Suite::registered($name)) {
                Calls::log(null, compact('name', 'args'));
            }
            if ($method && $method->matchArgs($args)) {
                return $method($args);
            }
            return call_user_func_array($name, $args);
        };
    }

Usage Example

Ejemplo n.º 1
0
 public function subChild()
 {
     $__KMONKEY__18 = \kahlan\plugin\Monkey::patched(__NAMESPACE__, 'RecursiveIteratorIterator', false);
     if ($options['recursive']) {
         $worker = new $__KMONKEY__18($worker, $iteratorFlags);
     }
 }
All Usage Examples Of Kahlan\Plugin\Monkey::patched