예제 #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()));
     };
 }
예제 #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);
         }
     }
 }
예제 #3
0
파일: Exec.php 프로젝트: thinframe/pcntl
 /**
  * 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']];
 }
예제 #4
0
 /**
  * @param string $path
  */
 public function exclude($path)
 {
     TypeCheck::doCheck(DataType::STRING);
     if (realpath($path)) {
         $this->excluded[] = realpath($path);
     }
     return $this;
 }
예제 #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);
 }
예제 #6
0
파일: Cookie.php 프로젝트: thinframe/server
 /**
  * @param $httpOnly
  *
  * @return $this
  */
 public function setHttpOnly($httpOnly)
 {
     TypeCheck::doCheck(DataType::BOOLEAN);
     $this->httpOnly = $httpOnly;
     return $this;
 }
예제 #7
0
파일: Process.php 프로젝트: thinframe/pcntl
 /**
  * Constructor
  *
  * @param int $pid
  */
 public function __construct($pid)
 {
     TypeCheck::doCheck(DataType::INT);
     $this->pid = $pid;
 }
예제 #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;
 }