Kahlan\Plugin\Pointcut::before PHP Method

before() public static method

Point cut called before method execution.
public static before ( $method, $self, &$args ) : boolean
return boolean If `true` is returned, the normal execution of the method is aborted.
    public static function before($method, $self, &$args)
    {
        if (!Suite::registered()) {
            return false;
        }
        list($class, $name) = explode('::', $method);
        $lsb = is_object($self) ? get_class($self) : $self;
        if (!Suite::registered($lsb) && !Suite::registered($class)) {
            return false;
        }
        if ($name === '__call' || $name === '__callStatic') {
            $name = array_shift($args);
            $args = array_shift($args);
        }
        return static::_stubbedMethod($lsb, $self, $class, $name, $args);
    }

Usage Example

示例#1
0
 /**
  * The JIT patcher.
  *
  * @param  NodeDef $node The node to patch.
  * @param  string  $path The file path of the source code.
  * @return NodeDef       The patched node.
  */
 public function process($node, $path = null)
 {
     $args = func_get_args();
     $self = isset($this) ? $this : get_called_class();
     if ($pointcut = Pointcut::before(__METHOD__, $self, $args)) {
         return $pointcut($args, $self);
     }
     return $node;
 }
All Usage Examples Of Kahlan\Plugin\Pointcut::before