/** * 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())); }; }
/** * 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); } } }
/** * 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']]; }
/** * @param string $path */ public function exclude($path) { TypeCheck::doCheck(DataType::STRING); if (realpath($path)) { $this->excluded[] = realpath($path); } return $this; }
/** * 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); }
/** * @param $httpOnly * * @return $this */ public function setHttpOnly($httpOnly) { TypeCheck::doCheck(DataType::BOOLEAN); $this->httpOnly = $httpOnly; return $this; }
/** * Constructor * * @param int $pid */ public function __construct($pid) { TypeCheck::doCheck(DataType::INT); $this->pid = $pid; }
/** * Constructor * * @param string $identifier * @param array $variables */ public function __construct($identifier, array $variables = []) { TypeCheck::doCheck(DataType::STRING); $this->viewIdentifier = $identifier; $this->variables = $variables; }