Beispiel #1
0
 /**
  * Constructs annotation.
  *
  * @param   callback    $callback
  */
 public function __construct($callback)
 {
     if (!is_callable($callback)) {
         throw new \InvalidArgumentException(sprintf('"%s" hook callback should be a valid callable, but %s given', basename(str_replace('\\', '/', get_class($this))), gettype($callback)));
     }
     parent::__construct($callback);
 }
 /**
  * Initializes transformation.
  *
  * @param callback $callback definition callback
  * @param string   $regex    definition regular expression
  *
  * @throws \InvalidArgumentException
  */
 public function __construct($callback, $regex)
 {
     if (!is_callable($callback)) {
         throw new \InvalidArgumentException(sprintf('Transformation callback should be a valid callable, but %s given', gettype($callback)));
     }
     parent::__construct($callback);
     $this->regex = $regex;
 }
Beispiel #3
0
 /**
  * Initializes transformation.
  *
  * @param   callback    $callback   definition callback
  * @param   string      $regex      definition regular expression
  */
 public function __construct($callback, $regex)
 {
     if (!is_callable($callback)) {
         throw new \InvalidArgumentException(sprintf('Transformation callback should be a valid callable, but %s given', gettype($callback)));
     }
     parent::__construct($callback);
     if (!$this->isClosure()) {
         $methodRefl = new \ReflectionMethod($callback[0], $callback[1]);
         if (!$methodRefl->isStatic()) {
             throw new \InvalidArgumentException(sprintf('Transformation callback: %s::%s() must be a static method', $callback[0], $callback[1]));
         }
     }
     $this->regex = $regex;
 }