PHP code example of apatis / callback_resolver

1. Go to this page and download the library: Download apatis/callback_resolver 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/ */

    

apatis / callback_resolver example snippets



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 
    */
});