Ejemplo n.º 1
0
 /**
  * Get binding to specific event
  *
  * @param string $eventId that will be triggered when binding is called
  *
  * @return callable
  */
 public function bindTo($eventId)
 {
     TypeCheck::doCheck(DataType::STRING);
     $context = $this;
     return function () use($context, $eventId) {
         $context->trigger(new SimpleEvent($eventId, func_get_args()));
     };
 }
Ejemplo n.º 2
0
 /**
  * Process class annotations
  *
  * @param string $className
  * @param mixed  $instance
  */
 public function processClass($className, $instance = null)
 {
     TypeCheck::doCheck(DataType::STRING);
     $reflector = new \ReflectionClass($className);
     foreach ($this->handlers as $handler) {
         $handler->handleClassAnnotations($reflector, $this->collector->getAnnotationsFor($reflector), $instance);
         foreach ($reflector->getMethods() as $method) {
             $handler->handleMethodAnnotations($method, $this->collector->getAnnotationsFor($method), $instance);
         }
         foreach ($reflector->getProperties() as $property) {
             $handler->handlePropertyAnnotations($property, $this->collector->getAnnotationsFor($property), $instance);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Execute command via pipe
  *
  * @param      $command
  * @param null $workingDir
  *
  * @return array
  */
 public static function viaPipe($command, $workingDir = null)
 {
     TypeCheck::doCheck(DataType::STRING, DataType::STRING);
     $descriptorSpec = [1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
     $pipes = [];
     $resource = proc_open($command, $descriptorSpec, $pipes, $workingDir);
     $status = proc_get_status($resource);
     $stdOut = stream_get_contents($pipes[1]);
     $stdErr = stream_get_contents($pipes[2]);
     foreach ($pipes as $pipe) {
         fclose($pipe);
     }
     $exitStatus = trim(proc_close($resource));
     return ["exitStatus" => $exitStatus, "stdOut" => $stdOut, "stdErr" => $stdErr, "pid" => $status['pid']];
 }
Ejemplo n.º 4
0
 /**
  * @param string $path
  */
 public function exclude($path)
 {
     TypeCheck::doCheck(DataType::STRING);
     if (realpath($path)) {
         $this->excluded[] = realpath($path);
     }
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Constructor
  *
  * @param string $eventId
  * @param array  $payload
  */
 public function __construct($eventId, array $payload = [])
 {
     TypeCheck::doCheck(DataType::STRING);
     $this->eventId = $eventId;
     $this->payload = new Map($payload);
 }
Ejemplo n.º 6
0
 /**
  * @param $httpOnly
  *
  * @return $this
  */
 public function setHttpOnly($httpOnly)
 {
     TypeCheck::doCheck(DataType::BOOLEAN);
     $this->httpOnly = $httpOnly;
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * Constructor
  *
  * @param int $pid
  */
 public function __construct($pid)
 {
     TypeCheck::doCheck(DataType::INT);
     $this->pid = $pid;
 }
Ejemplo n.º 8
0
 /**
  * Constructor
  *
  * @param string $identifier
  * @param array  $variables
  */
 public function __construct($identifier, array $variables = [])
 {
     TypeCheck::doCheck(DataType::STRING);
     $this->viewIdentifier = $identifier;
     $this->variables = $variables;
 }