repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
kakserpom/phpdaemon | PHPDaemon/FS/FileSystem.php | FileSystem.tempnamHandler | protected static function tempnamHandler($dir, $prefix, $cb, &$tries)
{
$cb = CallbackWrapper::forceWrap($cb);
if (++$tries >= 3) {
$cb(false);
return;
}
$path = FileSystem::genRndTempnam($dir, $prefix);
FileSystem::open($path, 'x+!', function ($file) ... | php | protected static function tempnamHandler($dir, $prefix, $cb, &$tries)
{
$cb = CallbackWrapper::forceWrap($cb);
if (++$tries >= 3) {
$cb(false);
return;
}
$path = FileSystem::genRndTempnam($dir, $prefix);
FileSystem::open($path, 'x+!', function ($file) ... | [
"protected",
"static",
"function",
"tempnamHandler",
"(",
"$",
"dir",
",",
"$",
"prefix",
",",
"$",
"cb",
",",
"&",
"$",
"tries",
")",
"{",
"$",
"cb",
"=",
"CallbackWrapper",
"::",
"forceWrap",
"(",
"$",
"cb",
")",
";",
"if",
"(",
"++",
"$",
"tries... | Generates closure tempnam handler
@param $dir
@param $prefix
@param $cb
@param $tries | [
"Generates",
"closure",
"tempnam",
"handler"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/FS/FileSystem.php#L615-L630 |
kakserpom/phpdaemon | PHPDaemon/FS/FileSystem.php | FileSystem.tempnam | public static function tempnam($dir, $prefix, $cb)
{
$cb = CallbackWrapper::forceWrap($cb);
if (!FileSystem::$supported) {
FileSystem::open(tempnam($dir, $prefix), 'w!', $cb);
}
$tries = 0;
static::tempnamHandler($dir, $prefix, $cb, $tries);
} | php | public static function tempnam($dir, $prefix, $cb)
{
$cb = CallbackWrapper::forceWrap($cb);
if (!FileSystem::$supported) {
FileSystem::open(tempnam($dir, $prefix), 'w!', $cb);
}
$tries = 0;
static::tempnamHandler($dir, $prefix, $cb, $tries);
} | [
"public",
"static",
"function",
"tempnam",
"(",
"$",
"dir",
",",
"$",
"prefix",
",",
"$",
"cb",
")",
"{",
"$",
"cb",
"=",
"CallbackWrapper",
"::",
"forceWrap",
"(",
"$",
"cb",
")",
";",
"if",
"(",
"!",
"FileSystem",
"::",
"$",
"supported",
")",
"{"... | Obtain exclusive temporary file
@param string $dir Directory
@param string $prefix Prefix
@param callable $cb Callback (File)
@return resource | [
"Obtain",
"exclusive",
"temporary",
"file"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/FS/FileSystem.php#L639-L647 |
kakserpom/phpdaemon | PHPDaemon/FS/FileSystem.php | FileSystem.open | public static function open($path, $flags, $cb, $mode = null, $pri = EIO_PRI_DEFAULT)
{
$cb = CallbackWrapper::forceWrap($cb);
if (!FileSystem::$supported) {
$mode = File::convertFlags($flags, true);
$fd = fopen($path, $mode);
if (!$fd) {
$cb(false... | php | public static function open($path, $flags, $cb, $mode = null, $pri = EIO_PRI_DEFAULT)
{
$cb = CallbackWrapper::forceWrap($cb);
if (!FileSystem::$supported) {
$mode = File::convertFlags($flags, true);
$fd = fopen($path, $mode);
if (!$fd) {
$cb(false... | [
"public",
"static",
"function",
"open",
"(",
"$",
"path",
",",
"$",
"flags",
",",
"$",
"cb",
",",
"$",
"mode",
"=",
"null",
",",
"$",
"pri",
"=",
"EIO_PRI_DEFAULT",
")",
"{",
"$",
"cb",
"=",
"CallbackWrapper",
"::",
"forceWrap",
"(",
"$",
"cb",
")"... | Open file
@param string $path Path
@param string $flags Flags
@param callable $cb Callback (File)
@param integer $mode Mode (see EIO_S_I* constants)
@param integer $pri Priority
@return resource | [
"Open",
"file"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/FS/FileSystem.php#L658-L717 |
kakserpom/phpdaemon | PHPDaemon/Core/CallbackWrapper.php | CallbackWrapper.wrap | public static function wrap($cb, $timeout = null, $ctx = false)
{
if ($cb instanceof CallbackWrapper || ((Daemon::$context === null) && ($timeout === null))) {
return $cb;
}
if ($cb === null) {
return null;
}
return new static($cb, $timeout, $ctx !== f... | php | public static function wrap($cb, $timeout = null, $ctx = false)
{
if ($cb instanceof CallbackWrapper || ((Daemon::$context === null) && ($timeout === null))) {
return $cb;
}
if ($cb === null) {
return null;
}
return new static($cb, $timeout, $ctx !== f... | [
"public",
"static",
"function",
"wrap",
"(",
"$",
"cb",
",",
"$",
"timeout",
"=",
"null",
",",
"$",
"ctx",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"cb",
"instanceof",
"CallbackWrapper",
"||",
"(",
"(",
"Daemon",
"::",
"$",
"context",
"===",
"null",
... | Wraps callback
@static
@param callable $cb
@param double $timeout = null
@return \Closure | [
"Wraps",
"callback"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/CallbackWrapper.php#L108-L117 |
kakserpom/phpdaemon | PHPDaemon/Core/CallbackWrapper.php | CallbackWrapper.forceWrap | public static function forceWrap($cb, $timeout = null)
{
if ($cb instanceof CallbackWrapper) {
return $cb;
}
if ($cb === null) {
return null;
}
return new static($cb, $timeout, Daemon::$context);
} | php | public static function forceWrap($cb, $timeout = null)
{
if ($cb instanceof CallbackWrapper) {
return $cb;
}
if ($cb === null) {
return null;
}
return new static($cb, $timeout, Daemon::$context);
} | [
"public",
"static",
"function",
"forceWrap",
"(",
"$",
"cb",
",",
"$",
"timeout",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cb",
"instanceof",
"CallbackWrapper",
")",
"{",
"return",
"$",
"cb",
";",
"}",
"if",
"(",
"$",
"cb",
"===",
"null",
")",
"{",
... | Wraps callback even without context
@static
@param callable $cb
@param double $timeout = null
@return CallbackWrapper|null | [
"Wraps",
"callback",
"even",
"without",
"context"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/CallbackWrapper.php#L126-L135 |
kakserpom/phpdaemon | PHPDaemon/Core/CallbackWrapper.php | CallbackWrapper.cancel | public function cancel()
{
$this->cb = null;
$this->context = null;
if ($this->timer !== null) {
Timer::remove($this->timer);
$this->timer = null;
}
} | php | public function cancel()
{
$this->cb = null;
$this->context = null;
if ($this->timer !== null) {
Timer::remove($this->timer);
$this->timer = null;
}
} | [
"public",
"function",
"cancel",
"(",
")",
"{",
"$",
"this",
"->",
"cb",
"=",
"null",
";",
"$",
"this",
"->",
"context",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"timer",
"!==",
"null",
")",
"{",
"Timer",
"::",
"remove",
"(",
"$",
"this",
... | Cancel
@return void | [
"Cancel"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/CallbackWrapper.php#L149-L157 |
kakserpom/phpdaemon | PHPDaemon/Examples/ExampleWithMongo.php | ExampleWithMongoRequest.init | public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) { // called when job is done
$job->keep(); // prevent cleaning up results
$this->wakeup(); // wake up the request immediately
});
$collection = $this->appInstance->mongo->{'t... | php | public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) { // called when job is done
$job->keep(); // prevent cleaning up results
$this->wakeup(); // wake up the request immediately
});
$collection = $this->appInstance->mongo->{'t... | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"job",
"=",
"$",
"this",
"->",
"job",
"=",
"new",
"\\",
"PHPDaemon",
"\\",
"Core",
"\\",
"ComplexJob",
"(",
"function",
"(",
"$",
"job",
")",
"{",
"// called when job is done",
"$",
"job",
"->",
"keep",... | Constructor.
@return void | [
"Constructor",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Examples/ExampleWithMongo.php#L44-L67 |
kakserpom/phpdaemon | PHPDaemon/Examples/ExampleWithMongo.php | ExampleWithMongoRequest.run | public function run()
{
try {
$this->header('Content-Type: text/html');
} catch (\Exception $e) {
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http:/... | php | public function run()
{
try {
$this->header('Content-Type: text/html');
} catch (\Exception $e) {
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http:/... | [
"public",
"function",
"run",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"header",
"(",
"'Content-Type: text/html'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"?>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional/... | Called when request iterated.
@return integer Status. | [
"Called",
"when",
"request",
"iterated",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Examples/ExampleWithMongo.php#L73-L102 |
kakserpom/phpdaemon | PHPDaemon/Clients/ICMP/Pool.php | Pool.sendPing | public function sendPing($host, $cb)
{
$this->connect('raw://' . $host, function ($conn) use ($cb) {
$conn->sendEcho($cb);
});
} | php | public function sendPing($host, $cb)
{
$this->connect('raw://' . $host, function ($conn) use ($cb) {
$conn->sendEcho($cb);
});
} | [
"public",
"function",
"sendPing",
"(",
"$",
"host",
",",
"$",
"cb",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
"'raw://'",
".",
"$",
"host",
",",
"function",
"(",
"$",
"conn",
")",
"use",
"(",
"$",
"cb",
")",
"{",
"$",
"conn",
"->",
"sendEcho",... | Establishes connection
@param string $host Address
@param callable $cb Callback
@callback $cb ( ) | [
"Establishes",
"connection"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/ICMP/Pool.php#L20-L25 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Exchange/ExchangeBindFrame.php | ExchangeBindFrame.create | public static function create(
$destination = null, $source = null, $routingKey = null, $nowait = null, $arguments = null
)
{
$frame = new self();
if (null !== $destination) {
$frame->destination = $destination;
}
if (null !== $source) {
$frame->s... | php | public static function create(
$destination = null, $source = null, $routingKey = null, $nowait = null, $arguments = null
)
{
$frame = new self();
if (null !== $destination) {
$frame->destination = $destination;
}
if (null !== $source) {
$frame->s... | [
"public",
"static",
"function",
"create",
"(",
"$",
"destination",
"=",
"null",
",",
"$",
"source",
"=",
"null",
",",
"$",
"routingKey",
"=",
"null",
",",
"$",
"nowait",
"=",
"null",
",",
"$",
"arguments",
"=",
"null",
")",
"{",
"$",
"frame",
"=",
... | table | [
"table"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Exchange/ExchangeBindFrame.php#L25-L48 |
kakserpom/phpdaemon | PHPDaemon/Clients/Gibson/Connection.php | Connection.onRead | protected function onRead()
{
start:
if ($this->state === static::STATE_STANDBY) {
if (($hdr = $this->readExact(2)) === false) {
return; // not enough data
}
$u = unpack('S', $hdr);
$this->responseCode = $u[1];
$this->state... | php | protected function onRead()
{
start:
if ($this->state === static::STATE_STANDBY) {
if (($hdr = $this->readExact(2)) === false) {
return; // not enough data
}
$u = unpack('S', $hdr);
$this->responseCode = $u[1];
$this->state... | [
"protected",
"function",
"onRead",
"(",
")",
"{",
"start",
":",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"static",
"::",
"STATE_STANDBY",
")",
"{",
"if",
"(",
"(",
"$",
"hdr",
"=",
"$",
"this",
"->",
"readExact",
"(",
"2",
")",
")",
"===",
"... | onRead
@return void | [
"onRead"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/Gibson/Connection.php#L125-L271 |
kakserpom/phpdaemon | PHPDaemon/Core/AppResolver.php | AppResolver.preload | public function preload($privileged = false)
{
foreach (Daemon::$config as $fullname => $section) {
if (!$section instanceof Config\Section) {
continue;
}
if (isset($section->limitinstances)) {
continue;
}
if ((isset... | php | public function preload($privileged = false)
{
foreach (Daemon::$config as $fullname => $section) {
if (!$section instanceof Config\Section) {
continue;
}
if (isset($section->limitinstances)) {
continue;
}
if ((isset... | [
"public",
"function",
"preload",
"(",
"$",
"privileged",
"=",
"false",
")",
"{",
"foreach",
"(",
"Daemon",
"::",
"$",
"config",
"as",
"$",
"fullname",
"=>",
"$",
"section",
")",
"{",
"if",
"(",
"!",
"$",
"section",
"instanceof",
"Config",
"\\",
"Sectio... | Preloads applications
@param boolean $privileged If true, we are in the pre-fork stage
@return void | [
"Preloads",
"applications"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/AppResolver.php#L21-L47 |
kakserpom/phpdaemon | PHPDaemon/Core/AppResolver.php | AppResolver.getInstance | public function getInstance($appName, $instance = '', $spawn = true, $preload = false)
{
$class = ClassFinder::find($appName, 'Applications');
if (isset(Daemon::$appInstances[$class][$instance])) {
return Daemon::$appInstances[$class][$instance];
}
if (!$spawn) {
... | php | public function getInstance($appName, $instance = '', $spawn = true, $preload = false)
{
$class = ClassFinder::find($appName, 'Applications');
if (isset(Daemon::$appInstances[$class][$instance])) {
return Daemon::$appInstances[$class][$instance];
}
if (!$spawn) {
... | [
"public",
"function",
"getInstance",
"(",
"$",
"appName",
",",
"$",
"instance",
"=",
"''",
",",
"$",
"spawn",
"=",
"true",
",",
"$",
"preload",
"=",
"false",
")",
"{",
"$",
"class",
"=",
"ClassFinder",
"::",
"find",
"(",
"$",
"appName",
",",
"'Applic... | Gets instance of application
@param string $appName Application name
@param string $instance Instance name
@param boolean $spawn If true, we spawn an instance if absent
@param boolean $preload If true, worker is at the preload stage
@return object $instance AppInstance | [
"Gets",
"instance",
"of",
"application"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/AppResolver.php#L57-L90 |
kakserpom/phpdaemon | PHPDaemon/Core/AppResolver.php | AppResolver.getRequest | public function getRequest($req, $upstream, $responder = null)
{
if (isset($req->attrs->server['APPNAME'])) {
$appName = $req->attrs->server['APPNAME'];
} elseif ($responder !== null) {
$appName = $responder;
} elseif (($appName = $this->getRequestRoute($req, $upstrea... | php | public function getRequest($req, $upstream, $responder = null)
{
if (isset($req->attrs->server['APPNAME'])) {
$appName = $req->attrs->server['APPNAME'];
} elseif ($responder !== null) {
$appName = $responder;
} elseif (($appName = $this->getRequestRoute($req, $upstrea... | [
"public",
"function",
"getRequest",
"(",
"$",
"req",
",",
"$",
"upstream",
",",
"$",
"responder",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"req",
"->",
"attrs",
"->",
"server",
"[",
"'APPNAME'",
"]",
")",
")",
"{",
"$",
"appName",
"=",
... | Routes incoming request to related application
@param object $req Generic
@param object $upstream AppInstance of Upstream
@param string $responder
@return object Request | [
"Routes",
"incoming",
"request",
"to",
"related",
"application"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/AppResolver.php#L110-L135 |
kakserpom/phpdaemon | PHPDaemon/Core/AppResolver.php | AppResolver.getInstanceByAppName | public function getInstanceByAppName($appName, $instance = '', $spawn = true, $preload = false)
{
return $this->getInstance($appName, $instance, $spawn, $preload);
} | php | public function getInstanceByAppName($appName, $instance = '', $spawn = true, $preload = false)
{
return $this->getInstance($appName, $instance, $spawn, $preload);
} | [
"public",
"function",
"getInstanceByAppName",
"(",
"$",
"appName",
",",
"$",
"instance",
"=",
"''",
",",
"$",
"spawn",
"=",
"true",
",",
"$",
"preload",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getInstance",
"(",
"$",
"appName",
",",
"$",
... | Gets instance of application
@alias AppResolver::getInstance
@param string $appName Application name
@param string $instance Instance name
@param boolean $spawn If true, we spawn an instance if absent
@param boolean $preload If true, worker is at the preload stage
@return object AppInstance | [
"Gets",
"instance",
"of",
"application"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/AppResolver.php#L156-L159 |
kakserpom/phpdaemon | PHPDaemon/Config/Entry/Generic.php | Generic.setHumanValue | public function setHumanValue($value)
{
$this->humanValue = $value;
$old = $this->value;
$this->value = static::humanToPlain($value);
$this->onUpdate($old);
} | php | public function setHumanValue($value)
{
$this->humanValue = $value;
$old = $this->value;
$this->value = static::humanToPlain($value);
$this->onUpdate($old);
} | [
"public",
"function",
"setHumanValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"humanValue",
"=",
"$",
"value",
";",
"$",
"old",
"=",
"$",
"this",
"->",
"value",
";",
"$",
"this",
"->",
"value",
"=",
"static",
"::",
"humanToPlain",
"(",
"$",
... | Set human-readable value
@param mixed
@return void | [
"Set",
"human",
"-",
"readable",
"value"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Config/Entry/Generic.php#L81-L87 |
kakserpom/phpdaemon | PHPDaemon/Config/Entry/Generic.php | Generic.setValue | public function setValue($value)
{
$old = $this->value;
$this->value = $value;
$this->humanValue = static::plainToHuman($value);
$this->onUpdate($old);
} | php | public function setValue($value)
{
$old = $this->value;
$this->value = $value;
$this->humanValue = static::plainToHuman($value);
$this->onUpdate($old);
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"value",
";",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"humanValue",
"=",
"static",
"::",
"plainToHuman",
"(",
"$",
"va... | Set value
@param mixed
@return void | [
"Set",
"value"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Config/Entry/Generic.php#L103-L109 |
kakserpom/phpdaemon | PHPDaemon/Config/Entry/Generic.php | Generic.pushValue | public function pushValue($value)
{
$old = $this->value;
if (!$this->stackable) {
$this->setValue($value);
return;
}
if (!is_array($this->value)) {
$this->value = [$this->value, $value];
} else {
$f = false;
foreach ... | php | public function pushValue($value)
{
$old = $this->value;
if (!$this->stackable) {
$this->setValue($value);
return;
}
if (!is_array($this->value)) {
$this->value = [$this->value, $value];
} else {
$f = false;
foreach ... | [
"public",
"function",
"pushValue",
"(",
"$",
"value",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"value",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"stackable",
")",
"{",
"$",
"this",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"return",
";",... | Push plain value
@param $value
@return void | [
"Push",
"plain",
"value"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Config/Entry/Generic.php#L142-L166 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php | Table.parseTable | private function parseTable()
{
$length = $this->parseUnsignedInt32();
$stopAt = strlen($this->buffer) - $length;
$table = [];
while (strlen($this->buffer) > $stopAt) {
$table[$this->parseShortString()] = $this->parseField();
}
return $table;
} | php | private function parseTable()
{
$length = $this->parseUnsignedInt32();
$stopAt = strlen($this->buffer) - $length;
$table = [];
while (strlen($this->buffer) > $stopAt) {
$table[$this->parseShortString()] = $this->parseField();
}
return $table;
} | [
"private",
"function",
"parseTable",
"(",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"parseUnsignedInt32",
"(",
")",
";",
"$",
"stopAt",
"=",
"strlen",
"(",
"$",
"this",
"->",
"buffer",
")",
"-",
"$",
"length",
";",
"$",
"table",
"=",
"[",
"]... | Parse an AMQP table from the head of the buffer.
@return array
@throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException | [
"Parse",
"an",
"AMQP",
"table",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php#L52-L63 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php | Table.parseField | private function parseField()
{
$type = $this->buffer[0];
$this->buffer = substr($this->buffer, 1);
// @todo bench switch vs if vs method map
switch ($type) {
case 's':
return $this->parseSignedInt16();
case 'l':
return $this->... | php | private function parseField()
{
$type = $this->buffer[0];
$this->buffer = substr($this->buffer, 1);
// @todo bench switch vs if vs method map
switch ($type) {
case 's':
return $this->parseSignedInt16();
case 'l':
return $this->... | [
"private",
"function",
"parseField",
"(",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"buffer",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"buffer",
"=",
"substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"1",
")",
";",
"// @todo bench switch vs if vs met... | Parse a table or array field.
@return integer|array|boolean|double|string|null
@throws AMQPProtocolException | [
"Parse",
"a",
"table",
"or",
"array",
"field",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php#L71-L114 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php | Table.parseDecimal | public function parseDecimal()
{
$scale = $this->parseUnsignedInt8();
$value = $this->parseSignedInt32();
if (0 === $scale) {
return (string)$value;
}
if ($value >= 0) {
$sign = '';
$value = (string)$value;
} else {
$s... | php | public function parseDecimal()
{
$scale = $this->parseUnsignedInt8();
$value = $this->parseSignedInt32();
if (0 === $scale) {
return (string)$value;
}
if ($value >= 0) {
$sign = '';
$value = (string)$value;
} else {
$s... | [
"public",
"function",
"parseDecimal",
"(",
")",
"{",
"$",
"scale",
"=",
"$",
"this",
"->",
"parseUnsignedInt8",
"(",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"parseSignedInt32",
"(",
")",
";",
"if",
"(",
"0",
"===",
"$",
"scale",
")",
"{",
"... | Parse an AMQP decimal from the head of the buffer.
@return string | [
"Parse",
"an",
"AMQP",
"decimal",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php#L120-L148 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php | Table.parseArray | private function parseArray()
{
$length = $this->parseUnsignedInt32();
$stopAt = strlen($this->buffer) - $length;
$array = [];
while (strlen($this->buffer) > $stopAt) {
$array[] = $this->parseField();
}
return $array;
} | php | private function parseArray()
{
$length = $this->parseUnsignedInt32();
$stopAt = strlen($this->buffer) - $length;
$array = [];
while (strlen($this->buffer) > $stopAt) {
$array[] = $this->parseField();
}
return $array;
} | [
"private",
"function",
"parseArray",
"(",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"parseUnsignedInt32",
"(",
")",
";",
"$",
"stopAt",
"=",
"strlen",
"(",
"$",
"this",
"->",
"buffer",
")",
"-",
"$",
"length",
";",
"$",
"array",
"=",
"[",
"]... | Parse an AMQP field-array value.
@return array
@throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException | [
"Parse",
"an",
"AMQP",
"field",
"-",
"array",
"value",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php#L155-L166 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php | Table.parseByteArray | private function parseByteArray()
{
list(, $length) = unpack('N', $this->buffer);
try {
return substr($this->buffer, 4, $length);
} finally {
$this->buffer = substr($this->buffer, $length + 4);
}
} | php | private function parseByteArray()
{
list(, $length) = unpack('N', $this->buffer);
try {
return substr($this->buffer, 4, $length);
} finally {
$this->buffer = substr($this->buffer, $length + 4);
}
} | [
"private",
"function",
"parseByteArray",
"(",
")",
"{",
"list",
"(",
",",
"$",
"length",
")",
"=",
"unpack",
"(",
"'N'",
",",
"$",
"this",
"->",
"buffer",
")",
";",
"try",
"{",
"return",
"substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"4",
",",
... | Parse an AMQP byte-array value.
@return array | [
"Parse",
"an",
"AMQP",
"byte",
"-",
"array",
"value",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/Table.php#L172-L181 |
kakserpom/phpdaemon | PHPDaemon/Network/ClientConnection.php | ClientConnection.onResponse | public function onResponse($cb)
{
if ($cb === null && !$this->noSAF) {
return;
}
$this->onResponse->push($cb);
$this->checkFree();
} | php | public function onResponse($cb)
{
if ($cb === null && !$this->noSAF) {
return;
}
$this->onResponse->push($cb);
$this->checkFree();
} | [
"public",
"function",
"onResponse",
"(",
"$",
"cb",
")",
"{",
"if",
"(",
"$",
"cb",
"===",
"null",
"&&",
"!",
"$",
"this",
"->",
"noSAF",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"onResponse",
"->",
"push",
"(",
"$",
"cb",
")",
";",
"$"... | Push callback to onReponse stack
@param callable $cb Callback
@return void | [
"Push",
"callback",
"to",
"onReponse",
"stack"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/ClientConnection.php#L66-L73 |
kakserpom/phpdaemon | PHPDaemon/Network/ClientConnection.php | ClientConnection.checkFree | public function checkFree()
{
$this->setFree(!$this->finished && !$this->acquired && (!$this->onResponse || $this->onResponse->count() < $this->maxQueue));
} | php | public function checkFree()
{
$this->setFree(!$this->finished && !$this->acquired && (!$this->onResponse || $this->onResponse->count() < $this->maxQueue));
} | [
"public",
"function",
"checkFree",
"(",
")",
"{",
"$",
"this",
"->",
"setFree",
"(",
"!",
"$",
"this",
"->",
"finished",
"&&",
"!",
"$",
"this",
"->",
"acquired",
"&&",
"(",
"!",
"$",
"this",
"->",
"onResponse",
"||",
"$",
"this",
"->",
"onResponse",... | Set connection free/busy according to onResponse emptiness and ->finished
@return void | [
"Set",
"connection",
"free",
"/",
"busy",
"according",
"to",
"onResponse",
"emptiness",
"and",
"-",
">",
"finished"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/ClientConnection.php#L79-L82 |
kakserpom/phpdaemon | PHPDaemon/Network/ClientConnection.php | ClientConnection.setFree | public function setFree($free = true)
{
if ($this->busy === !$free) {
return;
}
$this->busy = !$free;
if ($this->url === null) {
return;
}
if ($this->pool === null) {
return;
}
if ($this->finished) {
retu... | php | public function setFree($free = true)
{
if ($this->busy === !$free) {
return;
}
$this->busy = !$free;
if ($this->url === null) {
return;
}
if ($this->pool === null) {
return;
}
if ($this->finished) {
retu... | [
"public",
"function",
"setFree",
"(",
"$",
"free",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"busy",
"===",
"!",
"$",
"free",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"busy",
"=",
"!",
"$",
"free",
";",
"if",
"(",
"$",
"thi... | Set connection free/busy
@param boolean $free Free?
@return void | [
"Set",
"connection",
"free",
"/",
"busy"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/ClientConnection.php#L89-L110 |
kakserpom/phpdaemon | PHPDaemon/Network/ClientConnection.php | ClientConnection.onReady | public function onReady()
{
parent::onReady();
$this->setWatermark(null, $this->pool->maxAllowedPacket);
if ($this->url === null) {
return;
}
if ($this->connected && !$this->busy) {
$this->pool->markConnFree($this, $this->url);
}
} | php | public function onReady()
{
parent::onReady();
$this->setWatermark(null, $this->pool->maxAllowedPacket);
if ($this->url === null) {
return;
}
if ($this->connected && !$this->busy) {
$this->pool->markConnFree($this, $this->url);
}
} | [
"public",
"function",
"onReady",
"(",
")",
"{",
"parent",
"::",
"onReady",
"(",
")",
";",
"$",
"this",
"->",
"setWatermark",
"(",
"null",
",",
"$",
"this",
"->",
"pool",
"->",
"maxAllowedPacket",
")",
";",
"if",
"(",
"$",
"this",
"->",
"url",
"===",
... | Called when the connection is handshaked (at low-level), and peer is ready to recv. data
@return void | [
"Called",
"when",
"the",
"connection",
"is",
"handshaked",
"(",
"at",
"low",
"-",
"level",
")",
"and",
"peer",
"is",
"ready",
"to",
"recv",
".",
"data"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/ClientConnection.php#L116-L126 |
kakserpom/phpdaemon | PHPDaemon/Network/ClientConnection.php | ClientConnection.onFinish | public function onFinish()
{
$this->onResponse->executeAll($this, false);
$this->onResponse = null;
if ($this->pool && ($this->url !== null)) {
$this->pool->detachConnFromUrl($this, $this->url);
}
parent::onFinish();
} | php | public function onFinish()
{
$this->onResponse->executeAll($this, false);
$this->onResponse = null;
if ($this->pool && ($this->url !== null)) {
$this->pool->detachConnFromUrl($this, $this->url);
}
parent::onFinish();
} | [
"public",
"function",
"onFinish",
"(",
")",
"{",
"$",
"this",
"->",
"onResponse",
"->",
"executeAll",
"(",
"$",
"this",
",",
"false",
")",
";",
"$",
"this",
"->",
"onResponse",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"pool",
"&&",
"(",
"$",... | Called when connection finishes
@return void | [
"Called",
"when",
"connection",
"finishes"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/ClientConnection.php#L170-L178 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Basic/BasicQosFrame.php | BasicQosFrame.create | public static function create(
$prefetchSize = null, $prefetchCount = null, $global = null
)
{
$frame = new self();
if (null !== $prefetchSize) {
$frame->prefetchSize = $prefetchSize;
}
if (null !== $prefetchCount) {
$frame->prefetchCount = $prefe... | php | public static function create(
$prefetchSize = null, $prefetchCount = null, $global = null
)
{
$frame = new self();
if (null !== $prefetchSize) {
$frame->prefetchSize = $prefetchSize;
}
if (null !== $prefetchCount) {
$frame->prefetchCount = $prefe... | [
"public",
"static",
"function",
"create",
"(",
"$",
"prefetchSize",
"=",
"null",
",",
"$",
"prefetchCount",
"=",
"null",
",",
"$",
"global",
"=",
"null",
")",
"{",
"$",
"frame",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"pre... | bit | [
"bit"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Basic/BasicQosFrame.php#L22-L39 |
kakserpom/phpdaemon | PHPDaemon/Applications/FileReaderRequest.php | FileReaderRequest.init | public function init()
{
if (!isset($this->attrs->server['FR_PATH'])) {
$this->status(404);
$this->finish();
return;
}
$job = new \PHPDaemon\Core\ComplexJob(function ($job) {
$this->wakeup();
});
$this->job = $job;
$this... | php | public function init()
{
if (!isset($this->attrs->server['FR_PATH'])) {
$this->status(404);
$this->finish();
return;
}
$job = new \PHPDaemon\Core\ComplexJob(function ($job) {
$this->wakeup();
});
$this->job = $job;
$this... | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attrs",
"->",
"server",
"[",
"'FR_PATH'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"status",
"(",
"404",
")",
";",
"$",
"this",
"->",
"finish",
"(",
")... | Constructor.
@return void | [
"Constructor",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Applications/FileReaderRequest.php#L29-L88 |
kakserpom/phpdaemon | PHPDaemon/Applications/FileReaderRequest.php | FileReaderRequest.fileNotFound | public function fileNotFound()
{
try {
$this->header('404 Not Found');
$this->header('Content-Type: text/html');
} catch (\PHPDaemon\Request\RequestHeadersAlreadySent $e) {
}
$this->out('File not found.');
} | php | public function fileNotFound()
{
try {
$this->header('404 Not Found');
$this->header('Content-Type: text/html');
} catch (\PHPDaemon\Request\RequestHeadersAlreadySent $e) {
}
$this->out('File not found.');
} | [
"public",
"function",
"fileNotFound",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"header",
"(",
"'404 Not Found'",
")",
";",
"$",
"this",
"->",
"header",
"(",
"'Content-Type: text/html'",
")",
";",
"}",
"catch",
"(",
"\\",
"PHPDaemon",
"\\",
"Request",
... | Send header 404 or, if not possible already, response "File not found" | [
"Send",
"header",
"404",
"or",
"if",
"not",
"possible",
"already",
"response",
"File",
"not",
"found"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Applications/FileReaderRequest.php#L93-L101 |
kakserpom/phpdaemon | PHPDaemon/Clients/ICMP/Connection.php | Connection.sendEcho | public function sendEcho($cb, $data = 'phpdaemon')
{
++$this->seq;
if (mb_orig_strlen($data) % 2 !== 0) {
$data .= "\x00";
}
$packet = pack(
'ccnnn',
8, // type (c)
0, // code (c)
0, // checksum (n)
... | php | public function sendEcho($cb, $data = 'phpdaemon')
{
++$this->seq;
if (mb_orig_strlen($data) % 2 !== 0) {
$data .= "\x00";
}
$packet = pack(
'ccnnn',
8, // type (c)
0, // code (c)
0, // checksum (n)
... | [
"public",
"function",
"sendEcho",
"(",
"$",
"cb",
",",
"$",
"data",
"=",
"'phpdaemon'",
")",
"{",
"++",
"$",
"this",
"->",
"seq",
";",
"if",
"(",
"mb_orig_strlen",
"(",
"$",
"data",
")",
"%",
"2",
"!==",
"0",
")",
"{",
"$",
"data",
".=",
"\"\\x00... | Send echo-request
@param callable $cb Callback
@param string $data Data
@callback $cb ( )
@return void | [
"Send",
"echo",
"-",
"request"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/ICMP/Connection.php#L45-L64 |
kakserpom/phpdaemon | PHPDaemon/Clients/ICMP/Connection.php | Connection.checksum | protected static function checksum($data)
{
$bit = unpack('n*', $data);
$sum = array_sum($bit);
if (mb_orig_strlen($data) % 2) {
$temp = unpack('C*', $data[mb_orig_strlen($data) - 1]);
$sum += $temp[1];
}
$sum = ($sum >> 16) + ($sum & 0xffff);
... | php | protected static function checksum($data)
{
$bit = unpack('n*', $data);
$sum = array_sum($bit);
if (mb_orig_strlen($data) % 2) {
$temp = unpack('C*', $data[mb_orig_strlen($data) - 1]);
$sum += $temp[1];
}
$sum = ($sum >> 16) + ($sum & 0xffff);
... | [
"protected",
"static",
"function",
"checksum",
"(",
"$",
"data",
")",
"{",
"$",
"bit",
"=",
"unpack",
"(",
"'n*'",
",",
"$",
"data",
")",
";",
"$",
"sum",
"=",
"array_sum",
"(",
"$",
"bit",
")",
";",
"if",
"(",
"mb_orig_strlen",
"(",
"$",
"data",
... | Build checksum
@param string $data Source
@return string Checksum | [
"Build",
"checksum"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/ICMP/Connection.php#L71-L82 |
kakserpom/phpdaemon | PHPDaemon/Clients/ICMP/Connection.php | Connection.onRead | public function onRead()
{
$packet = $this->read(1024);
$orig = $packet;
$type = Binary::getByte($packet);
$code = Binary::getByte($packet);
$checksum = Binary::getStrWord($packet);
$id = Binary::getWord($packet);
$seq = Binary::getWord($packet);
if ($... | php | public function onRead()
{
$packet = $this->read(1024);
$orig = $packet;
$type = Binary::getByte($packet);
$code = Binary::getByte($packet);
$checksum = Binary::getStrWord($packet);
$id = Binary::getWord($packet);
$seq = Binary::getWord($packet);
if ($... | [
"public",
"function",
"onRead",
"(",
")",
"{",
"$",
"packet",
"=",
"$",
"this",
"->",
"read",
"(",
"1024",
")",
";",
"$",
"orig",
"=",
"$",
"packet",
";",
"$",
"type",
"=",
"Binary",
"::",
"getByte",
"(",
"$",
"packet",
")",
";",
"$",
"code",
"... | Called when new data received
@return void | [
"Called",
"when",
"new",
"data",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/ICMP/Connection.php#L88-L113 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.ensureCallback | public static function ensureCallback(&$arg)
{
if ($arg instanceof \Closure) {
return true;
}
if (is_array($arg) && sizeof($arg) === 2) {
if (isset($arg[0]) && $arg[0] instanceof \PHPDaemon\WebSocket\Route) {
if (isset($arg[1]) && is_string($arg[1]) &&... | php | public static function ensureCallback(&$arg)
{
if ($arg instanceof \Closure) {
return true;
}
if (is_array($arg) && sizeof($arg) === 2) {
if (isset($arg[0]) && $arg[0] instanceof \PHPDaemon\WebSocket\Route) {
if (isset($arg[1]) && is_string($arg[1]) &&... | [
"public",
"static",
"function",
"ensureCallback",
"(",
"&",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"arg",
"instanceof",
"\\",
"Closure",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"arg",
")",
"&&",
"sizeof",
"(",
"$",
"ar... | Ensures that the variable passed by reference holds a valid callback-function
If it doesn't, its value will be reset to null
@param mixed &$arg Argument
@return boolean | [
"Ensures",
"that",
"the",
"variable",
"passed",
"by",
"reference",
"holds",
"a",
"valid",
"callback",
"-",
"function",
"If",
"it",
"doesn",
"t",
"its",
"value",
"will",
"be",
"reset",
"to",
"null"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L60-L74 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.toJsonDebugResursive | public static function toJsonDebugResursive(&$m)
{
if ($m instanceof \Closure) {
$m = '__CALLBACK__';
} elseif (is_array($m)) {
if (sizeof($m) === 2 && isset($m[0]) && $m[0] instanceof \PHPDaemon\WebSocket\Route) {
if (isset($m[1]) && is_string($m[1]) && strnc... | php | public static function toJsonDebugResursive(&$m)
{
if ($m instanceof \Closure) {
$m = '__CALLBACK__';
} elseif (is_array($m)) {
if (sizeof($m) === 2 && isset($m[0]) && $m[0] instanceof \PHPDaemon\WebSocket\Route) {
if (isset($m[1]) && is_string($m[1]) && strnc... | [
"public",
"static",
"function",
"toJsonDebugResursive",
"(",
"&",
"$",
"m",
")",
"{",
"if",
"(",
"$",
"m",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"m",
"=",
"'__CALLBACK__'",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"m",
")",
")",
"{",
... | Recursion handler for toJsonDebug()
@param array &$a Data
@return void | [
"Recursion",
"handler",
"for",
"toJsonDebug",
"()"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L92-L111 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.defineLocalMethods | protected function defineLocalMethods($arr = [])
{
foreach (get_class_methods($this) as $m) {
if (substr($m, -6) === 'Method') {
$k = substr($m, 0, -6);
if ($k === 'methods') {
continue;
}
$arr[$k] = [$this, $m];... | php | protected function defineLocalMethods($arr = [])
{
foreach (get_class_methods($this) as $m) {
if (substr($m, -6) === 'Method') {
$k = substr($m, 0, -6);
if ($k === 'methods') {
continue;
}
$arr[$k] = [$this, $m];... | [
"protected",
"function",
"defineLocalMethods",
"(",
"$",
"arr",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"get_class_methods",
"(",
"$",
"this",
")",
"as",
"$",
"m",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"m",
",",
"-",
"6",
")",
"===",
"'Method'"... | Defines local methods
@param array $arr Associative array of callbacks (methodName => callback)
@return void | [
"Defines",
"local",
"methods"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L127-L144 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.exportObjectMethods | public static function exportObjectMethods($object) {
$methods = [];
foreach (get_class_methods($object) as $method) {
if ($method[0] === '_') {
continue;
}
$methods[$method] = [$object, $method];
}
return $methods;
} | php | public static function exportObjectMethods($object) {
$methods = [];
foreach (get_class_methods($object) as $method) {
if ($method[0] === '_') {
continue;
}
$methods[$method] = [$object, $method];
}
return $methods;
} | [
"public",
"static",
"function",
"exportObjectMethods",
"(",
"$",
"object",
")",
"{",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"get_class_methods",
"(",
"$",
"object",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"[",
"0",
... | Export object methods
@param $object
@return array | [
"Export",
"object",
"methods"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L164-L173 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.callRemoteArray | public function callRemoteArray($method, $args)
{
if (isset($this->remoteMethods[$method])) {
$this->remoteMethods[$method](...$args);
return $this;
}
$pct = [
'method' => $method,
];
if (sizeof($args)) {
$callbacks = [];
... | php | public function callRemoteArray($method, $args)
{
if (isset($this->remoteMethods[$method])) {
$this->remoteMethods[$method](...$args);
return $this;
}
$pct = [
'method' => $method,
];
if (sizeof($args)) {
$callbacks = [];
... | [
"public",
"function",
"callRemoteArray",
"(",
"$",
"method",
",",
"$",
"args",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"remoteMethods",
"[",
"$",
"method",
"]",
")",
")",
"{",
"$",
"this",
"->",
"remoteMethods",
"[",
"$",
"method",
"]",... | Calls a remote method with array of arguments
@param string $method Method name
@param array $args Arguments
@return this | [
"Calls",
"a",
"remote",
"method",
"with",
"array",
"of",
"arguments"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L181-L201 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.extractCallbacks | protected function extractCallbacks(&$args, &$list, &$path)
{
foreach ($args as $k => &$v) {
if (is_array($v)) {
if (sizeof($v) === 2) {
if (isset($v[0]) && is_object($v[0])) {
if (isset($v[1]) && is_string($v[1])) {
... | php | protected function extractCallbacks(&$args, &$list, &$path)
{
foreach ($args as $k => &$v) {
if (is_array($v)) {
if (sizeof($v) === 2) {
if (isset($v[0]) && is_object($v[0])) {
if (isset($v[1]) && is_string($v[1])) {
... | [
"protected",
"function",
"extractCallbacks",
"(",
"&",
"$",
"args",
",",
"&",
"$",
"list",
",",
"&",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"args",
"as",
"$",
"k",
"=>",
"&",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
... | Extracts callback functions from array of arguments
@param array &$args Arguments
@param array &$list Output array for 'callbacks' property
@param array &$path Recursion path holder
@return void | [
"Extracts",
"callback",
"functions",
"from",
"array",
"of",
"arguments"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L210-L245 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.sendPacket | protected function sendPacket($pct)
{
if (!$this->client) {
return;
}
if (is_string($pct['method']) && ctype_digit($pct['method'])) {
$pct['method'] = (int)$pct['method'];
}
$this->client->sendFrame(static::toJson($pct) . "\n");
} | php | protected function sendPacket($pct)
{
if (!$this->client) {
return;
}
if (is_string($pct['method']) && ctype_digit($pct['method'])) {
$pct['method'] = (int)$pct['method'];
}
$this->client->sendFrame(static::toJson($pct) . "\n");
} | [
"protected",
"function",
"sendPacket",
"(",
"$",
"pct",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"client",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"pct",
"[",
"'method'",
"]",
")",
"&&",
"ctype_digit",
"(",
"$",
"pct",
... | Sends a packet
@param array $pct Data
@return void | [
"Sends",
"a",
"packet"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L252-L261 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.callLocal | public function callLocal(...$args)
{
if (!sizeof($args)) {
return $this;
}
$method = array_shift($args);
$p = [
'method' => $method,
'arguments' => $args,
];
$this->onPacket($p);
return $this;
} | php | public function callLocal(...$args)
{
if (!sizeof($args)) {
return $this;
}
$method = array_shift($args);
$p = [
'method' => $method,
'arguments' => $args,
];
$this->onPacket($p);
return $this;
} | [
"public",
"function",
"callLocal",
"(",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"sizeof",
"(",
"$",
"args",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"method",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"p",
"=",
"[",... | Calls a local method
@param string $method Method name
@param mixed ...$args Arguments
@return this | [
"Calls",
"a",
"local",
"method"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L279-L291 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.onPacket | public function onPacket($pct)
{
if ($this->cleaned) {
return;
}
$m = isset($pct['method']) ? $pct['method'] : null;
$args = isset($pct['arguments']) ? $pct['arguments'] : [];
if (isset($pct['callbacks']) && is_array($pct['callbacks'])) {
foreach ($pct... | php | public function onPacket($pct)
{
if ($this->cleaned) {
return;
}
$m = isset($pct['method']) ? $pct['method'] : null;
$args = isset($pct['arguments']) ? $pct['arguments'] : [];
if (isset($pct['callbacks']) && is_array($pct['callbacks'])) {
foreach ($pct... | [
"public",
"function",
"onPacket",
"(",
"$",
"pct",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cleaned",
")",
"{",
"return",
";",
"}",
"$",
"m",
"=",
"isset",
"(",
"$",
"pct",
"[",
"'method'",
"]",
")",
"?",
"$",
"pct",
"[",
"'method'",
"]",
":",
... | Called when new packet is received
@param array $pct Packet
@return void | [
"Called",
"when",
"new",
"packet",
"is",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L298-L346 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.setPath | protected static function setPath(&$m, $path, $val)
{
foreach ($path as $p) {
$m =& $m[$p];
}
$m = $val;
} | php | protected static function setPath(&$m, $path, $val)
{
foreach ($path as $p) {
$m =& $m[$p];
}
$m = $val;
} | [
"protected",
"static",
"function",
"setPath",
"(",
"&",
"$",
"m",
",",
"$",
"path",
",",
"$",
"val",
")",
"{",
"foreach",
"(",
"$",
"path",
"as",
"$",
"p",
")",
"{",
"$",
"m",
"=",
"&",
"$",
"m",
"[",
"$",
"p",
"]",
";",
"}",
"$",
"m",
"=... | Sets value by materialized path
@param array &$m
@param array $path
@param mixed $val
@return void | [
"Sets",
"value",
"by",
"materialized",
"path"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L355-L361 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.& | protected static function &getPath(&$m, $path)
{
foreach ($path as $p) {
$m =& $m[$p];
}
return $m;
} | php | protected static function &getPath(&$m, $path)
{
foreach ($path as $p) {
$m =& $m[$p];
}
return $m;
} | [
"protected",
"static",
"function",
"&",
"getPath",
"(",
"&",
"$",
"m",
",",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"path",
"as",
"$",
"p",
")",
"{",
"$",
"m",
"=",
"&",
"$",
"m",
"[",
"$",
"p",
"]",
";",
"}",
"return",
"$",
"m",
";",
... | Finds value by materialized path
@param array &$m
@param array $path
@return mixed Value | [
"Finds",
"value",
"by",
"materialized",
"path"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L369-L375 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.cleanup | public function cleanup()
{
$this->cleaned = true;
$this->remoteMethods = [];
$this->localMethods = [];
$this->persistentCallbacks = [];
$this->callbacks = [];
} | php | public function cleanup()
{
$this->cleaned = true;
$this->remoteMethods = [];
$this->localMethods = [];
$this->persistentCallbacks = [];
$this->callbacks = [];
} | [
"public",
"function",
"cleanup",
"(",
")",
"{",
"$",
"this",
"->",
"cleaned",
"=",
"true",
";",
"$",
"this",
"->",
"remoteMethods",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"localMethods",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"persistentCallbacks",
"... | Swipes internal structures
@return void | [
"Swipes",
"internal",
"structures"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L391-L398 |
kakserpom/phpdaemon | PHPDaemon/DNode/DNode.php | DNode.onFrame | public function onFrame($data, $type)
{
foreach (explode("\n", $data) as $pct) {
if ($pct === '') {
continue;
}
$this->onPacket(json_decode($pct, true));
}
} | php | public function onFrame($data, $type)
{
foreach (explode("\n", $data) as $pct) {
if ($pct === '') {
continue;
}
$this->onPacket(json_decode($pct, true));
}
} | [
"public",
"function",
"onFrame",
"(",
"$",
"data",
",",
"$",
"type",
")",
"{",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"data",
")",
"as",
"$",
"pct",
")",
"{",
"if",
"(",
"$",
"pct",
"===",
"''",
")",
"{",
"continue",
";",
"}",
"$"... | Called when new frame is received
@param string $data Frame's contents
@param integer $type Frame's type
@return void | [
"Called",
"when",
"new",
"frame",
"is",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/DNode/DNode.php#L424-L432 |
kakserpom/phpdaemon | PHPDaemon/Traits/EventHandlers.php | EventHandlers.trigger | public function trigger($name, ...$args)
{
if ($this->addThisToEvents) {
array_unshift($args, $this);
}
if (isset($this->eventHandlers[$name])) {
$this->lastEventName = $name;
foreach ($this->eventHandlers[$name] as $cb) {
if ($cb(...$args)... | php | public function trigger($name, ...$args)
{
if ($this->addThisToEvents) {
array_unshift($args, $this);
}
if (isset($this->eventHandlers[$name])) {
$this->lastEventName = $name;
foreach ($this->eventHandlers[$name] as $cb) {
if ($cb(...$args)... | [
"public",
"function",
"trigger",
"(",
"$",
"name",
",",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"addThisToEvents",
")",
"{",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"this",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"th... | Propagate event
@param string $name Event name
@param mixed ...$args Arguments
@return this | [
"Propagate",
"event"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Traits/EventHandlers.php#L56-L70 |
kakserpom/phpdaemon | PHPDaemon/Traits/EventHandlers.php | EventHandlers.triggerAndCount | public function triggerAndCount($name, ...$args)
{
if ($this->addThisToEvents) {
array_unshift($args, $this);
}
$cnt = 0;
if (isset($this->eventHandlers[$name])) {
$this->lastEventName = $name;
foreach ($this->eventHandlers[$name] as $cb) {
... | php | public function triggerAndCount($name, ...$args)
{
if ($this->addThisToEvents) {
array_unshift($args, $this);
}
$cnt = 0;
if (isset($this->eventHandlers[$name])) {
$this->lastEventName = $name;
foreach ($this->eventHandlers[$name] as $cb) {
... | [
"public",
"function",
"triggerAndCount",
"(",
"$",
"name",
",",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"addThisToEvents",
")",
"{",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"this",
")",
";",
"}",
"$",
"cnt",
"=",
"0",
";",
... | Propagate event
@param string $name Event name
@param mixed ...$args Arguments
@return integer | [
"Propagate",
"event"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Traits/EventHandlers.php#L78-L93 |
kakserpom/phpdaemon | PHPDaemon/Traits/EventHandlers.php | EventHandlers.bind | public function bind($event, $cb)
{
if ($cb !== null) {
$cb = CallbackWrapper::wrap($cb);
}
$event = (array) $event;
foreach ($event as $e) {
CallbackWrapper::addToArray($this->eventHandlers[$e], $cb);
}
return $this;
} | php | public function bind($event, $cb)
{
if ($cb !== null) {
$cb = CallbackWrapper::wrap($cb);
}
$event = (array) $event;
foreach ($event as $e) {
CallbackWrapper::addToArray($this->eventHandlers[$e], $cb);
}
return $this;
} | [
"public",
"function",
"bind",
"(",
"$",
"event",
",",
"$",
"cb",
")",
"{",
"if",
"(",
"$",
"cb",
"!==",
"null",
")",
"{",
"$",
"cb",
"=",
"CallbackWrapper",
"::",
"wrap",
"(",
"$",
"cb",
")",
";",
"}",
"$",
"event",
"=",
"(",
"array",
")",
"$... | Bind event or events
@param string|array $event Event name
@param callable $cb Callback
@return this | [
"Bind",
"event",
"or",
"events"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Traits/EventHandlers.php#L122-L132 |
kakserpom/phpdaemon | PHPDaemon/Traits/EventHandlers.php | EventHandlers.unbind | public function unbind($event, $cb = null)
{
if ($cb !== null) {
$cb = CallbackWrapper::wrap($cb);
}
$event = (array) $event;
$success = true;
foreach ($event as $e) {
if (!isset($this->eventHandlers[$e])) {
$success = false;
... | php | public function unbind($event, $cb = null)
{
if ($cb !== null) {
$cb = CallbackWrapper::wrap($cb);
}
$event = (array) $event;
$success = true;
foreach ($event as $e) {
if (!isset($this->eventHandlers[$e])) {
$success = false;
... | [
"public",
"function",
"unbind",
"(",
"$",
"event",
",",
"$",
"cb",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cb",
"!==",
"null",
")",
"{",
"$",
"cb",
"=",
"CallbackWrapper",
"::",
"wrap",
"(",
"$",
"cb",
")",
";",
"}",
"$",
"event",
"=",
"(",
"... | Unbind event(s) or callback from event(s)
@param string|array $event Event name
@param callable $cb Callback, optional
@return this | [
"Unbind",
"event",
"(",
"s",
")",
"or",
"callback",
"from",
"event",
"(",
"s",
")"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Traits/EventHandlers.php#L152-L171 |
kakserpom/phpdaemon | PHPDaemon/Structures/ObjectStorage.php | ObjectStorage.each | public function each($method, ...$args)
{
if ($this->count() === 0) {
return 0;
}
$n = 0;
foreach ($this as $obj) {
$obj->$method(...$args);
++$n;
}
return $n;
} | php | public function each($method, ...$args)
{
if ($this->count() === 0) {
return 0;
}
$n = 0;
foreach ($this as $obj) {
$obj->$method(...$args);
++$n;
}
return $n;
} | [
"public",
"function",
"each",
"(",
"$",
"method",
",",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"$",
"n",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"as",
... | Call given method of all objects in storage
@param string $method Method name
@param mixed ...$args Arguments
@return integer Number of called objects | [
"Call",
"given",
"method",
"of",
"all",
"objects",
"in",
"storage"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Structures/ObjectStorage.php#L20-L31 |
kakserpom/phpdaemon | PHPDaemon/Structures/ObjectStorage.php | ObjectStorage.removeAll | public function removeAll($obj = null)
{
if ($obj === null) {
$this->removeAllExcept(new \SplObjectStorage);
}
parent::removeAll($obj);
} | php | public function removeAll($obj = null)
{
if ($obj === null) {
$this->removeAllExcept(new \SplObjectStorage);
}
parent::removeAll($obj);
} | [
"public",
"function",
"removeAll",
"(",
"$",
"obj",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"obj",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"removeAllExcept",
"(",
"new",
"\\",
"SplObjectStorage",
")",
";",
"}",
"parent",
"::",
"removeAll",
"(",
"$... | Remove all objects from this storage, which contained in another storage
@param \SplObjectStorage $obj
@return void | [
"Remove",
"all",
"objects",
"from",
"this",
"storage",
"which",
"contained",
"in",
"another",
"storage"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Structures/ObjectStorage.php#L38-L44 |
kakserpom/phpdaemon | PHPDaemon/Structures/ObjectStorage.php | ObjectStorage.detachFirst | public function detachFirst()
{
$this->rewind();
$o = $this->current();
if (!$o) {
return false;
}
$this->detach($o);
return $o;
} | php | public function detachFirst()
{
$this->rewind();
$o = $this->current();
if (!$o) {
return false;
}
$this->detach($o);
return $o;
} | [
"public",
"function",
"detachFirst",
"(",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"$",
"o",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"$",
"o",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"d... | Detaches first object and returns it
@return object | [
"Detaches",
"first",
"object",
"and",
"returns",
"it"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Structures/ObjectStorage.php#L50-L59 |
kakserpom/phpdaemon | PHPDaemon/Clients/Valve/Pool.php | Pool.ping | public function ping($addr, $cb)
{
$e = explode(':', $addr);
$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':' . $e[1] : '') . '/ping',
function ($conn) use ($cb) {
if (!$conn->connected) {
$cb($conn, false);
... | php | public function ping($addr, $cb)
{
$e = explode(':', $addr);
$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':' . $e[1] : '') . '/ping',
function ($conn) use ($cb) {
if (!$conn->connected) {
$cb($conn, false);
... | [
"public",
"function",
"ping",
"(",
"$",
"addr",
",",
"$",
"cb",
")",
"{",
"$",
"e",
"=",
"explode",
"(",
"':'",
",",
"$",
"addr",
")",
";",
"$",
"this",
"->",
"getConnection",
"(",
"'valve://[udp:'",
".",
"$",
"e",
"[",
"0",
"]",
".",
"']'",
".... | Sends echo-request
@param string $addr Address
@param callable $cb Callback
@callback $cb ( )
@return void | [
"Sends",
"echo",
"-",
"request"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/Valve/Pool.php#L29-L43 |
kakserpom/phpdaemon | PHPDaemon/Clients/Valve/Pool.php | Pool.request | public function request($addr, $type, $data, $cb)
{
$e = explode(':', $addr);
$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':' . $e[1] : '') . '/',
function ($conn) use ($cb, $addr, $data, $type) {
if (!$conn->connected) {
$cb($... | php | public function request($addr, $type, $data, $cb)
{
$e = explode(':', $addr);
$this->getConnection('valve://[udp:' . $e[0] . ']' . (isset($e[1]) ? ':' . $e[1] : '') . '/',
function ($conn) use ($cb, $addr, $data, $type) {
if (!$conn->connected) {
$cb($... | [
"public",
"function",
"request",
"(",
"$",
"addr",
",",
"$",
"type",
",",
"$",
"data",
",",
"$",
"cb",
")",
"{",
"$",
"e",
"=",
"explode",
"(",
"':'",
",",
"$",
"addr",
")",
";",
"$",
"this",
"->",
"getConnection",
"(",
"'valve://[udp:'",
".",
"$... | Sends a request
@param string $addr Address
@param string $type Type of request
@param string $data Data
@param callable $cb Callback
@callback $cb ( )
@return void | [
"Sends",
"a",
"request"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/Valve/Pool.php#L66-L77 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Connection/ConnectionOpenFrame.php | ConnectionOpenFrame.create | public static function create(
$virtualHost = null, $capabilities = null, $insist = null
)
{
$frame = new self();
if (null !== $virtualHost) {
$frame->virtualHost = $virtualHost;
}
if (null !== $capabilities) {
$frame->capabilities = $capabilities... | php | public static function create(
$virtualHost = null, $capabilities = null, $insist = null
)
{
$frame = new self();
if (null !== $virtualHost) {
$frame->virtualHost = $virtualHost;
}
if (null !== $capabilities) {
$frame->capabilities = $capabilities... | [
"public",
"static",
"function",
"create",
"(",
"$",
"virtualHost",
"=",
"null",
",",
"$",
"capabilities",
"=",
"null",
",",
"$",
"insist",
"=",
"null",
")",
"{",
"$",
"frame",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"virtu... | bit | [
"bit"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Connection/ConnectionOpenFrame.php#L22-L39 |
kakserpom/phpdaemon | PHPDaemon/Servers/FastCGI/Connection.php | Connection.onRead | public function onRead()
{
start:
if ($this->state === self::STATE_ROOT) {
$header = $this->readExact(8);
if ($header === false) {
return;
}
$this->header = unpack('Cver/Ctype/nreqid/nconlen/Cpadlen/Creserved', $header);
... | php | public function onRead()
{
start:
if ($this->state === self::STATE_ROOT) {
$header = $this->readExact(8);
if ($header === false) {
return;
}
$this->header = unpack('Cver/Ctype/nreqid/nconlen/Cpadlen/Creserved', $header);
... | [
"public",
"function",
"onRead",
"(",
")",
"{",
"start",
":",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"self",
"::",
"STATE_ROOT",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"readExact",
"(",
"8",
")",
";",
"if",
"(",
"$",
"header",
"==... | Called when new data received
@return void | [
"Called",
"when",
"new",
"data",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/FastCGI/Connection.php#L94-L275 |
kakserpom/phpdaemon | PHPDaemon/Servers/FastCGI/Connection.php | Connection.endRequest | public function endRequest($req, $appStatus, $protoStatus)
{
$c = pack('NC', $appStatus, $protoStatus) // app status, protocol status
. "\x00\x00\x00";
$this->write(
"\x01" // protocol version
. "\x03" // record type (END_REQUEST)
. pack('nn', $req->a... | php | public function endRequest($req, $appStatus, $protoStatus)
{
$c = pack('NC', $appStatus, $protoStatus) // app status, protocol status
. "\x00\x00\x00";
$this->write(
"\x01" // protocol version
. "\x03" // record type (END_REQUEST)
. pack('nn', $req->a... | [
"public",
"function",
"endRequest",
"(",
"$",
"req",
",",
"$",
"appStatus",
",",
"$",
"protoStatus",
")",
"{",
"$",
"c",
"=",
"pack",
"(",
"'NC'",
",",
"$",
"appStatus",
",",
"$",
"protoStatus",
")",
"// app status, protocol status",
".",
"\"\\x00\\x00\\x00\... | Handles the output from downstream requests
@param object $req
@param string $appStatus
@param string $protoStatus
@return void | [
"Handles",
"the",
"output",
"from",
"downstream",
"requests"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/FastCGI/Connection.php#L284-L303 |
kakserpom/phpdaemon | PHPDaemon/Servers/FastCGI/Connection.php | Connection.requestOut | public function requestOut($req, $out)
{
$cs = $this->pool->config->chunksize->value;
if (mb_orig_strlen($out) > $cs) {
while (($ol = mb_orig_strlen($out)) > 0) {
$l = min($cs, $ol);
if ($this->sendChunk($req, mb_orig_substr($out, 0, $l)) === false) {
... | php | public function requestOut($req, $out)
{
$cs = $this->pool->config->chunksize->value;
if (mb_orig_strlen($out) > $cs) {
while (($ol = mb_orig_strlen($out)) > 0) {
$l = min($cs, $ol);
if ($this->sendChunk($req, mb_orig_substr($out, 0, $l)) === false) {
... | [
"public",
"function",
"requestOut",
"(",
"$",
"req",
",",
"$",
"out",
")",
"{",
"$",
"cs",
"=",
"$",
"this",
"->",
"pool",
"->",
"config",
"->",
"chunksize",
"->",
"value",
";",
"if",
"(",
"mb_orig_strlen",
"(",
"$",
"out",
")",
">",
"$",
"cs",
"... | Handles the output from downstream requests
@param object $req Request
@param string $out The output
@return boolean Success | [
"Handles",
"the",
"output",
"from",
"downstream",
"requests"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/FastCGI/Connection.php#L311-L328 |
kakserpom/phpdaemon | PHPDaemon/Servers/FastCGI/Connection.php | Connection.sendChunk | public function sendChunk($req, $chunk)
{
$packet = "\x01" // protocol version
. "\x06" // record type (STDOUT)
. pack(
'nn',
$req->attrs->id,
mb_orig_strlen($chunk)
) // id, content length
. "\x00" // padding le... | php | public function sendChunk($req, $chunk)
{
$packet = "\x01" // protocol version
. "\x06" // record type (STDOUT)
. pack(
'nn',
$req->attrs->id,
mb_orig_strlen($chunk)
) // id, content length
. "\x00" // padding le... | [
"public",
"function",
"sendChunk",
"(",
"$",
"req",
",",
"$",
"chunk",
")",
"{",
"$",
"packet",
"=",
"\"\\x01\"",
"// protocol version",
".",
"\"\\x06\"",
"// record type (STDOUT)",
".",
"pack",
"(",
"'nn'",
",",
"$",
"req",
"->",
"attrs",
"->",
"id",
",",... | Sends a chunk
@param object $req Request
@param string $chunk Data
@return bool | [
"Sends",
"a",
"chunk"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/FastCGI/Connection.php#L336-L349 |
kakserpom/phpdaemon | PHPDaemon/Servers/FastCGI/Connection.php | Connection.freeRequest | public function freeRequest($req)
{
$req->attrs->input = null;
unset($this->requests[$req->attrs->id]);
} | php | public function freeRequest($req)
{
$req->attrs->input = null;
unset($this->requests[$req->attrs->id]);
} | [
"public",
"function",
"freeRequest",
"(",
"$",
"req",
")",
"{",
"$",
"req",
"->",
"attrs",
"->",
"input",
"=",
"null",
";",
"unset",
"(",
"$",
"this",
"->",
"requests",
"[",
"$",
"req",
"->",
"attrs",
"->",
"id",
"]",
")",
";",
"}"
] | Frees request
@param object $req | [
"Frees",
"request"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/FastCGI/Connection.php#L355-L359 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Basic/BasicGetFrame.php | BasicGetFrame.create | public static function create(
$queue = null, $noAck = null
)
{
$frame = new self();
if (null !== $queue) {
$frame->queue = $queue;
}
if (null !== $noAck) {
$frame->noAck = $noAck;
}
return $frame;
} | php | public static function create(
$queue = null, $noAck = null
)
{
$frame = new self();
if (null !== $queue) {
$frame->queue = $queue;
}
if (null !== $noAck) {
$frame->noAck = $noAck;
}
return $frame;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"queue",
"=",
"null",
",",
"$",
"noAck",
"=",
"null",
")",
"{",
"$",
"frame",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"queue",
")",
"{",
"$",
"frame",
"->",
"queue",
... | bit | [
"bit"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Basic/BasicGetFrame.php#L22-L36 |
kakserpom/phpdaemon | PHPDaemon/Applications/GibsonREST/Request.php | Request.init | public function init()
{
try {
$this->header('Content-Type: text/plain');
//$this->header('Content-Type: application/x-json');
} catch (\Exception $e) {
}
if (!$this->importCmdArgs()) {
return;
}
$this->sleep(5, true); // setting ti... | php | public function init()
{
try {
$this->header('Content-Type: text/plain');
//$this->header('Content-Type: application/x-json');
} catch (\Exception $e) {
}
if (!$this->importCmdArgs()) {
return;
}
$this->sleep(5, true); // setting ti... | [
"public",
"function",
"init",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"header",
"(",
"'Content-Type: text/plain'",
")",
";",
"//$this->header('Content-Type: application/x-json');",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"if",
"(",... | /*
Constructor.
@return void | [
"/",
"*",
"Constructor",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Applications/GibsonREST/Request.php#L16-L57 |
kakserpom/phpdaemon | PHPDaemon/Applications/GibsonREST/Request.php | Request.importCmdArgs | protected function importCmdArgs()
{
$this->cmd = static::getString($_GET['cmd']);
if ($this->cmd === '') {
$e = explode('/',
isset($this->attrs->server['SUBPATH']) ? $this->attrs->server['SUBPATH'] : $this->attrs->server['DOCUMENT_URI']);
$this->cmd = array_s... | php | protected function importCmdArgs()
{
$this->cmd = static::getString($_GET['cmd']);
if ($this->cmd === '') {
$e = explode('/',
isset($this->attrs->server['SUBPATH']) ? $this->attrs->server['SUBPATH'] : $this->attrs->server['DOCUMENT_URI']);
$this->cmd = array_s... | [
"protected",
"function",
"importCmdArgs",
"(",
")",
"{",
"$",
"this",
"->",
"cmd",
"=",
"static",
"::",
"getString",
"(",
"$",
"_GET",
"[",
"'cmd'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cmd",
"===",
"''",
")",
"{",
"$",
"e",
"=",
"explod... | /*
Import command name and arguments from input
@return void | [
"/",
"*",
"Import",
"command",
"name",
"and",
"arguments",
"from",
"input"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Applications/GibsonREST/Request.php#L63-L77 |
kakserpom/phpdaemon | PHPDaemon/Applications/GibsonREST/Request.php | Request.run | public function run()
{
if (!$this->performed && $this->result === null) {
$this->performed = true;
$this->importCmdArgsFromPost();
$this->performCommand();
if ($this->result === null) {
$this->sleep(5);
return;
}
... | php | public function run()
{
if (!$this->performed && $this->result === null) {
$this->performed = true;
$this->importCmdArgsFromPost();
$this->performCommand();
if ($this->result === null) {
$this->sleep(5);
return;
}
... | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"performed",
"&&",
"$",
"this",
"->",
"result",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"performed",
"=",
"true",
";",
"$",
"this",
"->",
"importCmdArgsFromPost",
"(",... | Called when request iterated.
@return integer Status. | [
"Called",
"when",
"request",
"iterated",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Applications/GibsonREST/Request.php#L88-L100 |
kakserpom/phpdaemon | PHPDaemon/Applications/GibsonREST/Request.php | Request.importCmdArgsFromPost | protected function importCmdArgsFromPost()
{
if ($this->result === null) {
foreach (static::getArray($_POST['args']) as $arg) {
if (is_string($arg)) {
$this->args[] = $arg;
}
}
}
} | php | protected function importCmdArgsFromPost()
{
if ($this->result === null) {
foreach (static::getArray($_POST['args']) as $arg) {
if (is_string($arg)) {
$this->args[] = $arg;
}
}
}
} | [
"protected",
"function",
"importCmdArgsFromPost",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"result",
"===",
"null",
")",
"{",
"foreach",
"(",
"static",
"::",
"getArray",
"(",
"$",
"_POST",
"[",
"'args'",
"]",
")",
"as",
"$",
"arg",
")",
"{",
"if"... | /*
Performs command
@return void | [
"/",
"*",
"Performs",
"command"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Applications/GibsonREST/Request.php#L107-L116 |
kakserpom/phpdaemon | PHPDaemon/XMLStream/XMLStream.php | XMLStream.finish | public function finish()
{
$this->xml_depth = 0;
$this->current_ns = [];
$this->idhandlers = [];
$this->xpathhandlers = [];
$this->eventHandlers = [];
} | php | public function finish()
{
$this->xml_depth = 0;
$this->current_ns = [];
$this->idhandlers = [];
$this->xpathhandlers = [];
$this->eventHandlers = [];
} | [
"public",
"function",
"finish",
"(",
")",
"{",
"$",
"this",
"->",
"xml_depth",
"=",
"0",
";",
"$",
"this",
"->",
"current_ns",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"idhandlers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"xpathhandlers",
"=",
"[",
... | Finishes the stream
@return void | [
"Finishes",
"the",
"stream"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/XMLStream/XMLStream.php#L45-L52 |
kakserpom/phpdaemon | PHPDaemon/XMLStream/XMLStream.php | XMLStream.__destroy | public function __destroy()
{
if ($this->parser) {
xml_parse($this->parser, '', true);
xml_parser_free($this->parser);
}
} | php | public function __destroy()
{
if ($this->parser) {
xml_parse($this->parser, '', true);
xml_parser_free($this->parser);
}
} | [
"public",
"function",
"__destroy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parser",
")",
"{",
"xml_parse",
"(",
"$",
"this",
"->",
"parser",
",",
"''",
",",
"true",
")",
";",
"xml_parser_free",
"(",
"$",
"this",
"->",
"parser",
")",
";",
"}",... | Destructor
@return void | [
"Destructor"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/XMLStream/XMLStream.php#L58-L64 |
kakserpom/phpdaemon | PHPDaemon/XMLStream/XMLStream.php | XMLStream.startXML | public function startXML($parser, $name, $attr)
{
++$this->xml_depth;
if (array_key_exists('XMLNS', $attr)) {
$this->current_ns[$this->xml_depth] = $attr['XMLNS'];
} else {
$this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1];
if (... | php | public function startXML($parser, $name, $attr)
{
++$this->xml_depth;
if (array_key_exists('XMLNS', $attr)) {
$this->current_ns[$this->xml_depth] = $attr['XMLNS'];
} else {
$this->current_ns[$this->xml_depth] = $this->current_ns[$this->xml_depth - 1];
if (... | [
"public",
"function",
"startXML",
"(",
"$",
"parser",
",",
"$",
"name",
",",
"$",
"attr",
")",
"{",
"++",
"$",
"this",
"->",
"xml_depth",
";",
"if",
"(",
"array_key_exists",
"(",
"'XMLNS'",
",",
"$",
"attr",
")",
")",
"{",
"$",
"this",
"->",
"curre... | XML start callback
@see xml_set_element_handler
@param resource $parser
@param string $name
@param array $attr
@return void | [
"XML",
"start",
"callback"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/XMLStream/XMLStream.php#L94-L123 |
kakserpom/phpdaemon | PHPDaemon/XMLStream/XMLStream.php | XMLStream.endXML | public function endXML($parser, $name)
{
--$this->xml_depth;
if ($this->xml_depth === 1) {
foreach ($this->xpathhandlers as $handler) {
if (is_array($this->xmlobj) && array_key_exists(2, $this->xmlobj)) {
$searchxml = $this->xmlobj[2];
... | php | public function endXML($parser, $name)
{
--$this->xml_depth;
if ($this->xml_depth === 1) {
foreach ($this->xpathhandlers as $handler) {
if (is_array($this->xmlobj) && array_key_exists(2, $this->xmlobj)) {
$searchxml = $this->xmlobj[2];
... | [
"public",
"function",
"endXML",
"(",
"$",
"parser",
",",
"$",
"name",
")",
"{",
"--",
"$",
"this",
"->",
"xml_depth",
";",
"if",
"(",
"$",
"this",
"->",
"xml_depth",
"===",
"1",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpathhandlers",
"as",
"$... | XML end callback
@see xml_set_element_handler
@param resource $parser
@param string $name
@return void | [
"XML",
"end",
"callback"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/XMLStream/XMLStream.php#L134-L179 |
kakserpom/phpdaemon | PHPDaemon/XMLStream/XMLStream.php | XMLStream.addXPathHandler | public function addXPathHandler($xpath, $cb, $obj = null)
{
if (preg_match_all("/\(?{[^\}]+}\)?(\/?)[^\/]+/", $xpath, $regs)) {
$ns_tags = $regs[0];
} else {
$ns_tags = [$xpath];
}
foreach ($ns_tags as $ns_tag) {
list($l, $r) = explode("}", $ns_tag... | php | public function addXPathHandler($xpath, $cb, $obj = null)
{
if (preg_match_all("/\(?{[^\}]+}\)?(\/?)[^\/]+/", $xpath, $regs)) {
$ns_tags = $regs[0];
} else {
$ns_tags = [$xpath];
}
foreach ($ns_tags as $ns_tag) {
list($l, $r) = explode("}", $ns_tag... | [
"public",
"function",
"addXPathHandler",
"(",
"$",
"xpath",
",",
"$",
"cb",
",",
"$",
"obj",
"=",
"null",
")",
"{",
"if",
"(",
"preg_match_all",
"(",
"\"/\\(?{[^\\}]+}\\)?(\\/?)[^\\/]+/\"",
",",
"$",
"xpath",
",",
"$",
"regs",
")",
")",
"{",
"$",
"ns_tag... | Add XPath Handler
@param string $xpath
@param \Closure $cb
@param null $obj | [
"Add",
"XPath",
"Handler"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/XMLStream/XMLStream.php#L227-L244 |
kakserpom/phpdaemon | PHPDaemon/BoundSocket/UDP.php | UDP.sendTo | public function sendTo($data, $flags, $host, $port)
{
return socket_sendto($this->fd, $data, mb_orig_strlen($data), $flags, $host, $port);
} | php | public function sendTo($data, $flags, $host, $port)
{
return socket_sendto($this->fd, $data, mb_orig_strlen($data), $flags, $host, $port);
} | [
"public",
"function",
"sendTo",
"(",
"$",
"data",
",",
"$",
"flags",
",",
"$",
"host",
",",
"$",
"port",
")",
"{",
"return",
"socket_sendto",
"(",
"$",
"this",
"->",
"fd",
",",
"$",
"data",
",",
"mb_orig_strlen",
"(",
"$",
"data",
")",
",",
"$",
... | Send UDP packet
@param string $data Data
@param integer $flags Flags
@param string $host Host
@param integer $port Port
@return integer | [
"Send",
"UDP",
"packet"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/BoundSocket/UDP.php#L72-L75 |
kakserpom/phpdaemon | PHPDaemon/BoundSocket/UDP.php | UDP.bindSocket | public function bindSocket()
{
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if (!$sock) {
$errno = socket_last_error();
Daemon::$process->log(get_class($this) . ': Couldn\'t create UDP-socket (' . $errno . ' - ' . socket_strerror($errno) . ').');
return fa... | php | public function bindSocket()
{
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if (!$sock) {
$errno = socket_last_error();
Daemon::$process->log(get_class($this) . ': Couldn\'t create UDP-socket (' . $errno . ' - ' . socket_strerror($errno) . ').');
return fa... | [
"public",
"function",
"bindSocket",
"(",
")",
"{",
"$",
"sock",
"=",
"socket_create",
"(",
"AF_INET",
",",
"SOCK_DGRAM",
",",
"SOL_UDP",
")",
";",
"if",
"(",
"!",
"$",
"sock",
")",
"{",
"$",
"errno",
"=",
"socket_last_error",
"(",
")",
";",
"Daemon",
... | Bind given addreess
@return boolean Success. | [
"Bind",
"given",
"addreess"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/BoundSocket/UDP.php#L101-L139 |
kakserpom/phpdaemon | PHPDaemon/BoundSocket/UDP.php | UDP.onBound | protected function onBound()
{
if (!$this->ev) {
Daemon::log(get_class($this) . '::' . __METHOD__ . ': Couldn\'t set event on bound socket: ' . Debug::dump($this->fd));
return false;
}
return true;
} | php | protected function onBound()
{
if (!$this->ev) {
Daemon::log(get_class($this) . '::' . __METHOD__ . ': Couldn\'t set event on bound socket: ' . Debug::dump($this->fd));
return false;
}
return true;
} | [
"protected",
"function",
"onBound",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ev",
")",
"{",
"Daemon",
"::",
"log",
"(",
"get_class",
"(",
"$",
"this",
")",
".",
"'::'",
".",
"__METHOD__",
".",
"': Couldn\\'t set event on bound socket: '",
".",
... | Called when socket is bound
@return boolean Success | [
"Called",
"when",
"socket",
"is",
"bound"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/BoundSocket/UDP.php#L145-L152 |
kakserpom/phpdaemon | PHPDaemon/BoundSocket/UDP.php | UDP.enable | public function enable()
{
if ($this->enabled) {
return;
}
if (!$this->fd) {
return;
}
$this->enabled = true;
if ($this->ev === null) {
if ($this->eventLoop === null) {
// @TODO нужно перенести куда-то выше, не годи... | php | public function enable()
{
if ($this->enabled) {
return;
}
if (!$this->fd) {
return;
}
$this->enabled = true;
if ($this->ev === null) {
if ($this->eventLoop === null) {
// @TODO нужно перенести куда-то выше, не годи... | [
"public",
"function",
"enable",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"enabled",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"fd",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"enabled",
"=",
"true",
";",
"if",
... | Enable socket events
@return void | [
"Enable",
"socket",
"events"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/BoundSocket/UDP.php#L158-L180 |
kakserpom/phpdaemon | PHPDaemon/BoundSocket/UDP.php | UDP.onReadUdp | public function onReadUdp($stream = null, $events = 0, $arg = null)
{
if (Daemon::$process->reload) {
return false;
}
if ($this->pool->maxConcurrency) {
if ($this->pool->count() >= $this->pool->maxConcurrency) {
$this->overload = true;
... | php | public function onReadUdp($stream = null, $events = 0, $arg = null)
{
if (Daemon::$process->reload) {
return false;
}
if ($this->pool->maxConcurrency) {
if ($this->pool->count() >= $this->pool->maxConcurrency) {
$this->overload = true;
... | [
"public",
"function",
"onReadUdp",
"(",
"$",
"stream",
"=",
"null",
",",
"$",
"events",
"=",
"0",
",",
"$",
"arg",
"=",
"null",
")",
"{",
"if",
"(",
"Daemon",
"::",
"$",
"process",
"->",
"reload",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",... | Called when we got UDP packet
@param resource $stream Descriptor
@param integer $events Events
@param mixed $arg Attached variable
@return boolean Success. | [
"Called",
"when",
"we",
"got",
"UDP",
"packet"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/BoundSocket/UDP.php#L189-L235 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.exec | public static function exec($binPath = null, $cb = null, $args = null, $env = null)
{
$o = new static;
$data = '';
$o->bind('read', function ($o) use (&$data) {
$data .= $o->readUnlimited();
});
$o->bind('eof', function ($o) use (&$data, $cb) {
$cb($o,... | php | public static function exec($binPath = null, $cb = null, $args = null, $env = null)
{
$o = new static;
$data = '';
$o->bind('read', function ($o) use (&$data) {
$data .= $o->readUnlimited();
});
$o->bind('eof', function ($o) use (&$data, $cb) {
$cb($o,... | [
"public",
"static",
"function",
"exec",
"(",
"$",
"binPath",
"=",
"null",
",",
"$",
"cb",
"=",
"null",
",",
"$",
"args",
"=",
"null",
",",
"$",
"env",
"=",
"null",
")",
"{",
"$",
"o",
"=",
"new",
"static",
";",
"$",
"data",
"=",
"''",
";",
"$... | Execute
@param string $binPath Binpath
@param callable $cb Callback
@param array $args Optional. Arguments
@param array $env Optional. Hash of environment's variables | [
"Execute"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L96-L108 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.execute | public function execute($binPath = null, $args = null, $env = null)
{
if ($binPath !== null) {
$this->binPath = $binPath;
}
if ($env !== null) {
$this->env = $env;
}
if ($args !== null) {
$this->args = $args;
}
$this->cmd ... | php | public function execute($binPath = null, $args = null, $env = null)
{
if ($binPath !== null) {
$this->binPath = $binPath;
}
if ($env !== null) {
$this->env = $env;
}
if ($args !== null) {
$this->args = $args;
}
$this->cmd ... | [
"public",
"function",
"execute",
"(",
"$",
"binPath",
"=",
"null",
",",
"$",
"args",
"=",
"null",
",",
"$",
"env",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"binPath",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"binPath",
"=",
"$",
"binPath",
";",
... | Execute
@param string $binPath Optional. Binpath
@param array $args Optional. Arguments
@param array $env Optional. Hash of environment's variables
@return this | [
"Execute"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L117-L163 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.buildArgs | public static function buildArgs($args)
{
if (!is_array($args)) {
return '';
}
$ret = '';
foreach ($args as $k => $v) {
if (!is_int($v) && ($v !== null)) {
$v = escapeshellarg($v);
}
if (is_int($k)) {
$re... | php | public static function buildArgs($args)
{
if (!is_array($args)) {
return '';
}
$ret = '';
foreach ($args as $k => $v) {
if (!is_int($v) && ($v !== null)) {
$v = escapeshellarg($v);
}
if (is_int($k)) {
$re... | [
"public",
"static",
"function",
"buildArgs",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"ret",
"=",
"''",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"k",
"=>",
"$",
... | Build arguments string from associative/enumerated array (may be mixed)
@param array $args
@return string | [
"Build",
"arguments",
"string",
"from",
"associative",
"/",
"enumerated",
"array",
"(",
"may",
"be",
"mixed",
")"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L170-L191 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.setFd | public function setFd($fd, $bev = null)
{
$this->fd = $fd;
if ($fd === false) {
$this->finish();
return;
}
$this->fdWrite = $this->pipes[0];
$flags = !is_resource($this->fd) ? \EventBufferEvent::OPT_CLOSE_ON_FREE : 0;
$flags |= \EventBufferEven... | php | public function setFd($fd, $bev = null)
{
$this->fd = $fd;
if ($fd === false) {
$this->finish();
return;
}
$this->fdWrite = $this->pipes[0];
$flags = !is_resource($this->fd) ? \EventBufferEvent::OPT_CLOSE_ON_FREE : 0;
$flags |= \EventBufferEven... | [
"public",
"function",
"setFd",
"(",
"$",
"fd",
",",
"$",
"bev",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"fd",
"=",
"$",
"fd",
";",
"if",
"(",
"$",
"fd",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"finish",
"(",
")",
";",
"return",
";",
... | Sets fd
@param resource $fd File descriptor
@param \EventBufferEvent $bev
@return void | [
"Sets",
"fd"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L199-L252 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.closeWrite | public function closeWrite()
{
if ($this->bevWrite) {
if (isset($this->bevWrite)) {
$this->bevWrite->free();
}
$this->bevWrite = null;
}
if ($this->fdWrite) {
fclose($this->fdWrite);
$this->fdWrite = null;
}... | php | public function closeWrite()
{
if ($this->bevWrite) {
if (isset($this->bevWrite)) {
$this->bevWrite->free();
}
$this->bevWrite = null;
}
if ($this->fdWrite) {
fclose($this->fdWrite);
$this->fdWrite = null;
}... | [
"public",
"function",
"closeWrite",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"bevWrite",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"bevWrite",
")",
")",
"{",
"$",
"this",
"->",
"bevWrite",
"->",
"free",
"(",
")",
";",
"}",
"$",
... | Close write stream
@return this | [
"Close",
"write",
"stream"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L361-L376 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.write | public function write($data)
{
if (!$this->alive) {
Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
return false;
}
if (!isset($this->bevWrite)) {
return false;
}
if (!mb_orig_strlen($data)) {
return... | php | public function write($data)
{
if (!$this->alive) {
Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
return false;
}
if (!isset($this->bevWrite)) {
return false;
}
if (!mb_orig_strlen($data)) {
return... | [
"public",
"function",
"write",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"alive",
")",
"{",
"Daemon",
"::",
"log",
"(",
"'Attempt to write to dead IOStream ('",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"')'",
")",
";",
"return... | Send data to the connection. Note that it just writes to buffer that flushes at every baseloop
@param string $data Data to send
@return boolean Success | [
"Send",
"data",
"to",
"the",
"connection",
".",
"Note",
"that",
"it",
"just",
"writes",
"to",
"buffer",
"that",
"flushes",
"at",
"every",
"baseloop"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L414-L433 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.close | public function close()
{
parent::close();
$this->closeWrite();
if (is_resource($this->pd)) {
proc_close($this->pd);
}
} | php | public function close()
{
parent::close();
$this->closeWrite();
if (is_resource($this->pd)) {
proc_close($this->pd);
}
} | [
"public",
"function",
"close",
"(",
")",
"{",
"parent",
"::",
"close",
"(",
")",
";",
"$",
"this",
"->",
"closeWrite",
"(",
")",
";",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"pd",
")",
")",
"{",
"proc_close",
"(",
"$",
"this",
"->",
"pd... | Close the process
@return void | [
"Close",
"the",
"process"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L439-L446 |
kakserpom/phpdaemon | PHPDaemon/Core/ShellCommand.php | ShellCommand.writeln | public function writeln($data)
{
if (!$this->alive) {
Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
return false;
}
if (!isset($this->bevWrite)) {
return false;
}
if (!mb_orig_strlen($data) && !mb_orig_strlen(... | php | public function writeln($data)
{
if (!$this->alive) {
Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
return false;
}
if (!isset($this->bevWrite)) {
return false;
}
if (!mb_orig_strlen($data) && !mb_orig_strlen(... | [
"public",
"function",
"writeln",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"alive",
")",
"{",
"Daemon",
"::",
"log",
"(",
"'Attempt to write to dead IOStream ('",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"')'",
")",
";",
"retu... | Send data and appending \n to connection. Note that it just writes to buffer flushed at every baseloop
@param string Data to send
@return boolean Success | [
"Send",
"data",
"and",
"appending",
"\\",
"n",
"to",
"connection",
".",
"Note",
"that",
"it",
"just",
"writes",
"to",
"buffer",
"flushed",
"at",
"every",
"baseloop"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ShellCommand.php#L453-L469 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.setFd | public function setFd($fd, $bev = null)
{
if ($this->eventLoop === null) {
$this->eventLoop = EventLoop::$instance;
}
$this->fd = $fd;
if ($this->fd === false) {
$this->finish();
return;
}
if ($bev !== null) {
$this->bev... | php | public function setFd($fd, $bev = null)
{
if ($this->eventLoop === null) {
$this->eventLoop = EventLoop::$instance;
}
$this->fd = $fd;
if ($this->fd === false) {
$this->finish();
return;
}
if ($bev !== null) {
$this->bev... | [
"public",
"function",
"setFd",
"(",
"$",
"fd",
",",
"$",
"bev",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"eventLoop",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"eventLoop",
"=",
"EventLoop",
"::",
"$",
"instance",
";",
"}",
"$",
"th... | Sets fd
@param resource $fd File descriptor
@param object $bev EventBufferEvent
@return void | [
"Sets",
"fd"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L276-L355 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.setTimeouts | public function setTimeouts($read, $write)
{
$this->timeoutRead = $read;
$this->timeoutWrite = $write;
if ($this->bev) {
$this->bev->setTimeouts($this->timeoutRead, $this->timeoutWrite);
}
} | php | public function setTimeouts($read, $write)
{
$this->timeoutRead = $read;
$this->timeoutWrite = $write;
if ($this->bev) {
$this->bev->setTimeouts($this->timeoutRead, $this->timeoutWrite);
}
} | [
"public",
"function",
"setTimeouts",
"(",
"$",
"read",
",",
"$",
"write",
")",
"{",
"$",
"this",
"->",
"timeoutRead",
"=",
"$",
"read",
";",
"$",
"this",
"->",
"timeoutWrite",
"=",
"$",
"write",
";",
"if",
"(",
"$",
"this",
"->",
"bev",
")",
"{",
... | Set timeouts
@param integer $read Read timeout in seconds
@param integer $write Write timeout in seconds
@return void | [
"Set",
"timeouts"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L373-L380 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.setWatermark | public function setWatermark($low = null, $high = null)
{
if ($low !== null) {
$this->lowMark = $low;
}
if ($high !== null) {
$this->highMark = $high;
}
if ($this->highMark > 0) {
$this->highMark = max($this->lowMark, $this->highMark);
... | php | public function setWatermark($low = null, $high = null)
{
if ($low !== null) {
$this->lowMark = $low;
}
if ($high !== null) {
$this->highMark = $high;
}
if ($this->highMark > 0) {
$this->highMark = max($this->lowMark, $this->highMark);
... | [
"public",
"function",
"setWatermark",
"(",
"$",
"low",
"=",
"null",
",",
"$",
"high",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"low",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"lowMark",
"=",
"$",
"low",
";",
"}",
"if",
"(",
"$",
"high",
"!==",... | Sets watermark
@param integer|null $low Low
@param integer|null $high High
@return void | [
"Sets",
"watermark"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L399-L411 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.readLine | public function readLine($eol = null)
{
if (!isset($this->bev)) {
return null;
}
return $this->bev->input->readLine($eol ?: $this->EOLS);
} | php | public function readLine($eol = null)
{
if (!isset($this->bev)) {
return null;
}
return $this->bev->input->readLine($eol ?: $this->EOLS);
} | [
"public",
"function",
"readLine",
"(",
"$",
"eol",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"readLine",
"(",... | Reads line from buffer
@param integer $eol EOLS_*
@return string|null | [
"Reads",
"line",
"from",
"buffer"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L426-L432 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.drainIfMatch | public function drainIfMatch($str)
{
if (!isset($this->bev)) {
return false;
}
$in = $this->bev->input;
$l = mb_orig_strlen($str);
$ll = $in->length;
if ($ll === 0) {
return $l === 0 ? true : null;
}
if ($ll < $l) {
... | php | public function drainIfMatch($str)
{
if (!isset($this->bev)) {
return false;
}
$in = $this->bev->input;
$l = mb_orig_strlen($str);
$ll = $in->length;
if ($ll === 0) {
return $l === 0 ? true : null;
}
if ($ll < $l) {
... | [
"public",
"function",
"drainIfMatch",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"in",
"=",
"$",
"this",
"->",
"bev",
"->",
"input",
";",
"$",
"l",
"=",
... | Drains buffer it matches the string
@param string $str Data
@return boolean|null Success | [
"Drains",
"buffer",
"it",
"matches",
"the",
"string"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L449-L473 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.prependInput | public function prependInput($str)
{
if (!isset($this->bev)) {
return false;
}
return $this->bev->input->prepend($str);
} | php | public function prependInput($str)
{
if (!isset($this->bev)) {
return false;
}
return $this->bev->input->prepend($str);
} | [
"public",
"function",
"prependInput",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"prepend",
"(",
"$",
"st... | Prepends data to input buffer
@param string $str Data
@return boolean Success | [
"Prepends",
"data",
"to",
"input",
"buffer"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L497-L503 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.prependOutput | public function prependOutput($str)
{
if (!isset($this->bev)) {
return false;
}
return $this->bev->output->prepend($str);
} | php | public function prependOutput($str)
{
if (!isset($this->bev)) {
return false;
}
return $this->bev->output->prepend($str);
} | [
"public",
"function",
"prependOutput",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"bev",
"->",
"output",
"->",
"prepend",
"(",
"$",
"... | Prepends data to output buffer
@param string $str Data
@return boolean Success | [
"Prepends",
"data",
"to",
"output",
"buffer"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L510-L516 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.look | public function look($n, $o = 0)
{
if (!isset($this->bev)) {
return false;
}
if ($this->bev->input->length <= $o) {
return '';
}
return $this->bev->input->substr($o, $n);
} | php | public function look($n, $o = 0)
{
if (!isset($this->bev)) {
return false;
}
if ($this->bev->input->length <= $o) {
return '';
}
return $this->bev->input->substr($o, $n);
} | [
"public",
"function",
"look",
"(",
"$",
"n",
",",
"$",
"o",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"l... | Read from buffer without draining
@param integer $n Number of bytes to read
@param integer $o Offset
@return string|false | [
"Read",
"from",
"buffer",
"without",
"draining"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L524-L533 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.substr | public function substr($o, $n = -1)
{
if (!isset($this->bev)) {
return false;
}
return $this->bev->input->substr($o, $n);
} | php | public function substr($o, $n = -1)
{
if (!isset($this->bev)) {
return false;
}
return $this->bev->input->substr($o, $n);
} | [
"public",
"function",
"substr",
"(",
"$",
"o",
",",
"$",
"n",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"bev",
"->",
"input",
"->"... | Read from buffer without draining
@param integer $o Offset
@param integer $n Number of bytes to read
@return string|false | [
"Read",
"from",
"buffer",
"without",
"draining"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L541-L547 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.search | public function search($what, $start = 0, $end = -1)
{
return $this->bev->input->search($what, $start, $end);
} | php | public function search($what, $start = 0, $end = -1)
{
return $this->bev->input->search($what, $start, $end);
} | [
"public",
"function",
"search",
"(",
"$",
"what",
",",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"-",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"search",
"(",
"$",
"what",
",",
"$",
"start",
",",
"$",
"end",
... | Searches first occurence of the string in input buffer
@param string $what Needle
@param integer $start Offset start
@param integer $end Offset end
@return integer Position | [
"Searches",
"first",
"occurence",
"of",
"the",
"string",
"in",
"input",
"buffer"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L556-L559 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.readExact | public function readExact($n)
{
if ($n === 0) {
return '';
}
if (!$this->bev || $this->bev->input->length < $n) {
return false;
}
return $this->read($n);
} | php | public function readExact($n)
{
if ($n === 0) {
return '';
}
if (!$this->bev || $this->bev->input->length < $n) {
return false;
}
return $this->read($n);
} | [
"public",
"function",
"readExact",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"===",
"0",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"bev",
"||",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"length",
"<",
"$"... | Reads exact $n bytes from buffer
@param integer $n Number of bytes to read
@return string|false | [
"Reads",
"exact",
"$n",
"bytes",
"from",
"buffer"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L566-L575 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.freezeInput | public function freezeInput($at_front = true)
{
if (isset($this->bev)) {
return $this->bev->input->freeze($at_front);
}
return false;
} | php | public function freezeInput($at_front = true)
{
if (isset($this->bev)) {
return $this->bev->input->freeze($at_front);
}
return false;
} | [
"public",
"function",
"freezeInput",
"(",
"$",
"at_front",
"=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"freeze",
"(",
"$",
"at_front",
")",
";",
... | Freeze input
@param boolean $at_front At front. Default is true. If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until i... | [
"Freeze",
"input"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L601-L607 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.unfreezeInput | public function unfreezeInput($at_front = true)
{
if (isset($this->bev)) {
return $this->bev->input->unfreeze($at_front);
}
return false;
} | php | public function unfreezeInput($at_front = true)
{
if (isset($this->bev)) {
return $this->bev->input->unfreeze($at_front);
}
return false;
} | [
"public",
"function",
"unfreezeInput",
"(",
"$",
"at_front",
"=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"unfreeze",
"(",
"$",
"at_front",
")",
";... | Unfreeze input
@param boolean $at_front At front. Default is true. If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until... | [
"Unfreeze",
"input"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L614-L620 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.freezeOutput | public function freezeOutput($at_front = true)
{
if (isset($this->bev)) {
return $this->bev->output->unfreeze($at_front);
}
return false;
} | php | public function freezeOutput($at_front = true)
{
if (isset($this->bev)) {
return $this->bev->output->unfreeze($at_front);
}
return false;
} | [
"public",
"function",
"freezeOutput",
"(",
"$",
"at_front",
"=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"bev",
")",
")",
"{",
"return",
"$",
"this",
"->",
"bev",
"->",
"output",
"->",
"unfreeze",
"(",
"$",
"at_front",
")",
";... | Freeze output
@param boolean $at_front At front. Default is true. If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until ... | [
"Freeze",
"output"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L627-L633 |
kakserpom/phpdaemon | PHPDaemon/Network/IOStream.php | IOStream.finish | public function finish()
{
if ($this->finished) {
return;
}
$this->finished = true;
$this->eventLoop->interrupt();
$this->onFinish();
if (!$this->writing) {
$this->close();
}
} | php | public function finish()
{
if ($this->finished) {
return;
}
$this->finished = true;
$this->eventLoop->interrupt();
$this->onFinish();
if (!$this->writing) {
$this->close();
}
} | [
"public",
"function",
"finish",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"finished",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"finished",
"=",
"true",
";",
"$",
"this",
"->",
"eventLoop",
"->",
"interrupt",
"(",
")",
";",
"$",
"this",
... | Finish the session. You should not worry about buffers, they are going to be flushed properly
@return void | [
"Finish",
"the",
"session",
".",
"You",
"should",
"not",
"worry",
"about",
"buffers",
"they",
"are",
"going",
"to",
"be",
"flushed",
"properly"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Network/IOStream.php#L709-L720 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.