apatis / callback_resolver
Callable Resolver
1.0.5
2018-01-28 09:11 UTC
Requires
- php: ^7.0
Requires (Dev)
This package is not auto-updated.
Last update: 2025-03-02 05:51:03 UTC
README
Resolve callable value
<?php use \Apatis\CallbackResolver\CallbackResolver; // use null to bind closure to null $bind = null; $resolveStaticMethod = true; $resolver = new CallbackResolver($bind, $resolveStaticMethod); $callable_1 = $resolver->resolve('Class:method'); // Class:method is equal with Class->method // Method operator use $callable_2 = $resolver->resolve('Class->method'); $callable_closure = $resolver->resolve(function() { /** * @var null $this * even callable inside of Object * When binding set to null it will bind into null */ }); // set Bind to \stdClass $resolver->setBinding(new stdClass()); $callable_closure_std_class = $resolver->resolve(function() { /** * @var \stdClass $this * after binding set into \stdClass * the variable $this will be accessible info \stdClass */ });
OPERATOR
- Use operator single `:` or `->` to determine that class need to be new instance
- Use double `:` (eg : 'class::method') to determine that method is static
or will be convert like a (standard) `->` operator if method is non static
and set as resolve static method