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/Servers/HTTP/Connection.php | Connection.onFinish | public function onFinish()
{
Timer::remove($this->keepaliveTimer);
if ($this->req !== null && $this->req instanceof Generic) {
if (!$this->req->isFinished()) {
$this->req->abort();
}
}
$this->req = null;
} | php | public function onFinish()
{
Timer::remove($this->keepaliveTimer);
if ($this->req !== null && $this->req instanceof Generic) {
if (!$this->req->isFinished()) {
$this->req->abort();
}
}
$this->req = null;
} | [
"public",
"function",
"onFinish",
"(",
")",
"{",
"Timer",
"::",
"remove",
"(",
"$",
"this",
"->",
"keepaliveTimer",
")",
";",
"if",
"(",
"$",
"this",
"->",
"req",
"!==",
"null",
"&&",
"$",
"this",
"->",
"req",
"instanceof",
"Generic",
")",
"{",
"if",... | Called when connection is finished
@return void | [
"Called",
"when",
"connection",
"is",
"finished"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/HTTP/Connection.php#L406-L415 |
kakserpom/phpdaemon | PHPDaemon/Servers/HTTP/Connection.php | Connection.badRequest | public function badRequest($req)
{
$this->state = self::STATE_ROOT;
$this->write("400 Bad Request\r\n\r\n<html><head><title>400 Bad Request</title></head><body bgcolor=\"white\"><center><h1>400 Bad Request</h1></center></body></html>");
$this->finish();
} | php | public function badRequest($req)
{
$this->state = self::STATE_ROOT;
$this->write("400 Bad Request\r\n\r\n<html><head><title>400 Bad Request</title></head><body bgcolor=\"white\"><center><h1>400 Bad Request</h1></center></body></html>");
$this->finish();
} | [
"public",
"function",
"badRequest",
"(",
"$",
"req",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_ROOT",
";",
"$",
"this",
"->",
"write",
"(",
"\"400 Bad Request\\r\\n\\r\\n<html><head><title>400 Bad Request</title></head><body bgcolor=\\\"white\\\"><ce... | Send Bad request
@return void | [
"Send",
"Bad",
"request"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/HTTP/Connection.php#L421-L426 |
kakserpom/phpdaemon | PHPDaemon/Config/Entry/Time.php | Time.humanToPlain | public static function humanToPlain($value)
{
$time = 0;
preg_replace_callback('~(\d+(\.\d+)?)\s*([smhd])\s*|(.+)~i', function ($m) use (&$time) {
if (isset($m[4]) && ($m[4] !== '')) {
$time = false;
}
if ($time === false) {
retur... | php | public static function humanToPlain($value)
{
$time = 0;
preg_replace_callback('~(\d+(\.\d+)?)\s*([smhd])\s*|(.+)~i', function ($m) use (&$time) {
if (isset($m[4]) && ($m[4] !== '')) {
$time = false;
}
if ($time === false) {
retur... | [
"public",
"static",
"function",
"humanToPlain",
"(",
"$",
"value",
")",
"{",
"$",
"time",
"=",
"0",
";",
"preg_replace_callback",
"(",
"'~(\\d+(\\.\\d+)?)\\s*([smhd])\\s*|(.+)~i'",
",",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"&",
"$",
"time",
")",
"{",
... | Converts human-readable value to plain
@param $value
@return int | [
"Converts",
"human",
"-",
"readable",
"value",
"to",
"plain"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Config/Entry/Time.php#L20-L53 |
kakserpom/phpdaemon | PHPDaemon/Servers/IRCBouncer/Connection.php | Connection.onReady | public function onReady()
{
$conn = $this;
$this->keepaliveTimer = setTimeout(function ($timer) use ($conn) {
$conn->ping();
}, 10e6);
} | php | public function onReady()
{
$conn = $this;
$this->keepaliveTimer = setTimeout(function ($timer) use ($conn) {
$conn->ping();
}, 10e6);
} | [
"public",
"function",
"onReady",
"(",
")",
"{",
"$",
"conn",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"keepaliveTimer",
"=",
"setTimeout",
"(",
"function",
"(",
"$",
"timer",
")",
"use",
"(",
"$",
"conn",
")",
"{",
"$",
"conn",
"->",
"ping",
"(",
... | 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/Servers/IRCBouncer/Connection.php#L55-L61 |
kakserpom/phpdaemon | PHPDaemon/Clients/Mongo/Connection.php | Connection.onRead | public function onRead()
{
start:
if ($this->freed) {
return;
}
if ($this->state === self::STATE_ROOT) {
if (false === ($hdr = $this->readExact(16))) {
return; // we do not have a header
}
$this->hdr = unpack('Vlen/VreqI... | php | public function onRead()
{
start:
if ($this->freed) {
return;
}
if ($this->state === self::STATE_ROOT) {
if (false === ($hdr = $this->readExact(16))) {
return; // we do not have a header
}
$this->hdr = unpack('Vlen/VreqI... | [
"public",
"function",
"onRead",
"(",
")",
"{",
"start",
":",
"if",
"(",
"$",
"this",
"->",
"freed",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"self",
"::",
"STATE_ROOT",
")",
"{",
"if",
"(",
"false",
"===",
"(",
... | Called when new data received
@return void | [
"Called",
"when",
"new",
"data",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/Mongo/Connection.php#L88-L183 |
kakserpom/phpdaemon | PHPDaemon/Clients/Mongo/Connection.php | Connection.onFinish | public function onFinish()
{
foreach ($this->cursors as $curId => $cur) {
if ($cur instanceof Cursor) {
$cur->destroy(true);
}
}
$this->cursors = null;
$this->requests = null;
parent::onFinish();
} | php | public function onFinish()
{
foreach ($this->cursors as $curId => $cur) {
if ($cur instanceof Cursor) {
$cur->destroy(true);
}
}
$this->cursors = null;
$this->requests = null;
parent::onFinish();
} | [
"public",
"function",
"onFinish",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"cursors",
"as",
"$",
"curId",
"=>",
"$",
"cur",
")",
"{",
"if",
"(",
"$",
"cur",
"instanceof",
"Cursor",
")",
"{",
"$",
"cur",
"->",
"destroy",
"(",
"true",
")",
... | onFinish
@return void | [
"onFinish"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/Mongo/Connection.php#L189-L199 |
kakserpom/phpdaemon | PHPDaemon/SockJS/Methods/Welcome.php | Welcome.init | public function init()
{
parent::init();
$this->header('Cache-Control: max-age=31536000, public, pre-check=0, post-check=0');
$this->header('Expires: ' . date('r', strtotime('+1 year')));
echo "Welcome to SockJS!\n";
$this->finish();
} | php | public function init()
{
parent::init();
$this->header('Cache-Control: max-age=31536000, public, pre-check=0, post-check=0');
$this->header('Expires: ' . date('r', strtotime('+1 year')));
echo "Welcome to SockJS!\n";
$this->finish();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"$",
"this",
"->",
"header",
"(",
"'Cache-Control: max-age=31536000, public, pre-check=0, post-check=0'",
")",
";",
"$",
"this",
"->",
"header",
"(",
"'Expires: '",
".",
"date",
... | Constructor
@return void | [
"Constructor"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/SockJS/Methods/Welcome.php#L18-L25 |
kakserpom/phpdaemon | PHPDaemon/Structures/StackCallbacks.php | StackCallbacks.executeOne | public function executeOne(...$args)
{
if ($this->isEmpty()) {
return false;
}
$cb = $this->shift();
if ($cb) {
$cb(...$args);
if ($cb instanceof CallbackWrapper) {
$cb->cancel();
}
}
return true;
} | php | public function executeOne(...$args)
{
if ($this->isEmpty()) {
return false;
}
$cb = $this->shift();
if ($cb) {
$cb(...$args);
if ($cb instanceof CallbackWrapper) {
$cb->cancel();
}
}
return true;
} | [
"public",
"function",
"executeOne",
"(",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cb",
"=",
"$",
"this",
"->",
"shift",
"(",
")",
";",
"if",
"(",
"$",
"cb",
... | Executes one callback from the top with given arguments
@param mixed ...$args Arguments
@return boolean | [
"Executes",
"one",
"callback",
"from",
"the",
"top",
"with",
"given",
"arguments"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Structures/StackCallbacks.php#L28-L41 |
kakserpom/phpdaemon | PHPDaemon/Structures/StackCallbacks.php | StackCallbacks.executeAndKeepOne | public function executeAndKeepOne(...$args)
{
if ($this->isEmpty()) {
return false;
}
$cb = $this->shift();
$this->unshift($cb);
if ($cb) {
$cb(...$args);
}
return true;
} | php | public function executeAndKeepOne(...$args)
{
if ($this->isEmpty()) {
return false;
}
$cb = $this->shift();
$this->unshift($cb);
if ($cb) {
$cb(...$args);
}
return true;
} | [
"public",
"function",
"executeAndKeepOne",
"(",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cb",
"=",
"$",
"this",
"->",
"shift",
"(",
")",
";",
"$",
"this",
"->",
... | Executes one callback from the top with given arguments without taking it out
@param mixed ...$args Arguments
@return boolean | [
"Executes",
"one",
"callback",
"from",
"the",
"top",
"with",
"given",
"arguments",
"without",
"taking",
"it",
"out"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Structures/StackCallbacks.php#L48-L59 |
kakserpom/phpdaemon | PHPDaemon/Structures/StackCallbacks.php | StackCallbacks.executeAll | public function executeAll(...$args)
{
if ($this->isEmpty()) {
return 0;
}
$n = 0;
do {
if ($cb = $this->shift()) {
$cb(...$args);
++$n;
if ($cb instanceof CallbackWrapper) {
$cb->cancel();
... | php | public function executeAll(...$args)
{
if ($this->isEmpty()) {
return 0;
}
$n = 0;
do {
if ($cb = $this->shift()) {
$cb(...$args);
++$n;
if ($cb instanceof CallbackWrapper) {
$cb->cancel();
... | [
"public",
"function",
"executeAll",
"(",
"...",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"$",
"n",
"=",
"0",
";",
"do",
"{",
"if",
"(",
"$",
"cb",
"=",
"$",
"this",
"->",
"... | Executes all callbacks with given arguments
@param array $args
@return int | [
"Executes",
"all",
"callbacks",
"with",
"given",
"arguments"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Structures/StackCallbacks.php#L76-L93 |
kakserpom/phpdaemon | PHPDaemon/Utils/Crypt.php | Crypt.hash | public static function hash($str, $salt = '', $plain = false)
{
$size = 512;
$rounds = 1;
if (strncmp($salt, '$', 1) === 0) {
$e = explode('$', $salt, 3);
$ee = explode('=', $e[1]);
if (ctype_digit($ee[0])) {
$size = (int)$e[1];
... | php | public static function hash($str, $salt = '', $plain = false)
{
$size = 512;
$rounds = 1;
if (strncmp($salt, '$', 1) === 0) {
$e = explode('$', $salt, 3);
$ee = explode('=', $e[1]);
if (ctype_digit($ee[0])) {
$size = (int)$e[1];
... | [
"public",
"static",
"function",
"hash",
"(",
"$",
"str",
",",
"$",
"salt",
"=",
"''",
",",
"$",
"plain",
"=",
"false",
")",
"{",
"$",
"size",
"=",
"512",
";",
"$",
"rounds",
"=",
"1",
";",
"if",
"(",
"strncmp",
"(",
"$",
"salt",
",",
"'$'",
"... | Generate keccak hash for string with salt
@param string $str Data
@param string $salt Salt
@param boolean $plain Is plain text?
@return string
@deprecated | [
"Generate",
"keccak",
"hash",
"for",
"string",
"with",
"salt"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Utils/Crypt.php#L26-L53 |
kakserpom/phpdaemon | PHPDaemon/Utils/Crypt.php | Crypt.randomString | public static function randomString($len = null, $chars = null, $cb = null, $pri = 0, $hang = false)
{
if ($len === null) {
$len = 64;
}
if ($chars === null) {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.';
}
if ($cb === ... | php | public static function randomString($len = null, $chars = null, $cb = null, $pri = 0, $hang = false)
{
if ($len === null) {
$len = 64;
}
if ($chars === null) {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.';
}
if ($cb === ... | [
"public",
"static",
"function",
"randomString",
"(",
"$",
"len",
"=",
"null",
",",
"$",
"chars",
"=",
"null",
",",
"$",
"cb",
"=",
"null",
",",
"$",
"pri",
"=",
"0",
",",
"$",
"hang",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"len",
"===",
"null"... | Returns string of pseudo random characters
@param integer $len Length of desired string
@param string $chars String of allowed characters
@param callable $cb Callback
@param integer $pri Priority of EIO operation
@param boolean $hang If true, we shall use /dev/random instead of /dev/urandom and it may cause a dela... | [
"Returns",
"string",
"of",
"pseudo",
"random",
"characters"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Utils/Crypt.php#L64-L113 |
kakserpom/phpdaemon | PHPDaemon/Utils/Crypt.php | Crypt.stringIdx | public static function stringIdx($str, $idx)
{
// FIXME: Make the const-time hack below work for all integer sizes, or
// check it properly
$l = mb_orig_strlen($str);
if ($l > 65535 || $idx > $l) {
return false;
}
$r = 0;
for ($i = 0; $i < $l; ++$i... | php | public static function stringIdx($str, $idx)
{
// FIXME: Make the const-time hack below work for all integer sizes, or
// check it properly
$l = mb_orig_strlen($str);
if ($l > 65535 || $idx > $l) {
return false;
}
$r = 0;
for ($i = 0; $i < $l; ++$i... | [
"public",
"static",
"function",
"stringIdx",
"(",
"$",
"str",
",",
"$",
"idx",
")",
"{",
"// FIXME: Make the const-time hack below work for all integer sizes, or",
"// check it properly",
"$",
"l",
"=",
"mb_orig_strlen",
"(",
"$",
"str",
")",
";",
"if",
"(",
"$",
... | Returns the character at index $idx in $str in constant time
@param string $str String
@param integer $idx Index
@return string | [
"Returns",
"the",
"character",
"at",
"index",
"$idx",
"in",
"$str",
"in",
"constant",
"time"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Utils/Crypt.php#L121-L136 |
kakserpom/phpdaemon | PHPDaemon/Utils/Crypt.php | Crypt.randomBytes | public static function randomBytes($len, $cb, $pri = 0, $hang = false)
{
$cb = CallbackWrapper::wrap($cb);
FileSystem::open('/dev/' . ($hang ? '' : 'u') . 'random', 'r', function ($file) use ($len, $cb, $pri) {
if (!$file) {
$cb(false);
return;
... | php | public static function randomBytes($len, $cb, $pri = 0, $hang = false)
{
$cb = CallbackWrapper::wrap($cb);
FileSystem::open('/dev/' . ($hang ? '' : 'u') . 'random', 'r', function ($file) use ($len, $cb, $pri) {
if (!$file) {
$cb(false);
return;
... | [
"public",
"static",
"function",
"randomBytes",
"(",
"$",
"len",
",",
"$",
"cb",
",",
"$",
"pri",
"=",
"0",
",",
"$",
"hang",
"=",
"false",
")",
"{",
"$",
"cb",
"=",
"CallbackWrapper",
"::",
"wrap",
"(",
"$",
"cb",
")",
";",
"FileSystem",
"::",
"o... | Returns string of pseudo random bytes
@param integer $len Length of desired string
@param callable $cb Callback
@param integer $pri Priority of EIO operation
@param boolean $hang If true, we shall use /dev/random instead of /dev/urandom and it may cause a delay
@return integer | [
"Returns",
"string",
"of",
"pseudo",
"random",
"bytes"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Utils/Crypt.php#L146-L158 |
kakserpom/phpdaemon | PHPDaemon/Utils/Crypt.php | Crypt.randomInts | public static function randomInts($numInts, $cb, $pri = 0, $hang = false)
{
static::randomBytes(PHP_INT_SIZE * $numInts, function ($bytes) use ($cb, $numInts) {
if ($bytes === false) {
$cb(false);
return;
}
$ints = [];
for ($i =... | php | public static function randomInts($numInts, $cb, $pri = 0, $hang = false)
{
static::randomBytes(PHP_INT_SIZE * $numInts, function ($bytes) use ($cb, $numInts) {
if ($bytes === false) {
$cb(false);
return;
}
$ints = [];
for ($i =... | [
"public",
"static",
"function",
"randomInts",
"(",
"$",
"numInts",
",",
"$",
"cb",
",",
"$",
"pri",
"=",
"0",
",",
"$",
"hang",
"=",
"false",
")",
"{",
"static",
"::",
"randomBytes",
"(",
"PHP_INT_SIZE",
"*",
"$",
"numInts",
",",
"function",
"(",
"$"... | Returns array of pseudo random integers of machine-dependent size
@param integer $numInts Number of integers
@param callable $cb Callback
@param integer $pri Priority of EIO operation
@param boolean $hang If true, we shall use /dev/random instead of /dev/urandom and it may cause a delay
@return integer | [
"Returns",
"array",
"of",
"pseudo",
"random",
"integers",
"of",
"machine",
"-",
"dependent",
"size"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Utils/Crypt.php#L168-L187 |
kakserpom/phpdaemon | PHPDaemon/Utils/Crypt.php | Crypt.randomInts32 | public static function randomInts32($numInts, $cb, $pri = 0, $hang = false)
{
static::randomBytes(4 * $numInts, function ($bytes) use ($cb, $numInts) {
if ($bytes === false) {
$cb(false);
return;
}
$ints = [];
for ($i = 0; $i < ... | php | public static function randomInts32($numInts, $cb, $pri = 0, $hang = false)
{
static::randomBytes(4 * $numInts, function ($bytes) use ($cb, $numInts) {
if ($bytes === false) {
$cb(false);
return;
}
$ints = [];
for ($i = 0; $i < ... | [
"public",
"static",
"function",
"randomInts32",
"(",
"$",
"numInts",
",",
"$",
"cb",
",",
"$",
"pri",
"=",
"0",
",",
"$",
"hang",
"=",
"false",
")",
"{",
"static",
"::",
"randomBytes",
"(",
"4",
"*",
"$",
"numInts",
",",
"function",
"(",
"$",
"byte... | Returns array of pseudo random 32-bit integers
@param integer $numInts Number of integers
@param callable $cb Callback
@param integer $pri Priority of EIO operation
@param boolean $hang If true, we shall use /dev/random instead of /dev/urandom and it may cause a delay
@return integer | [
"Returns",
"array",
"of",
"pseudo",
"random",
"32",
"-",
"bit",
"integers"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Utils/Crypt.php#L197-L216 |
kakserpom/phpdaemon | PHPDaemon/Utils/Crypt.php | Crypt.getMinimalBitMask | protected static function getMinimalBitMask($toRepresent)
{
if ($toRepresent < 1) {
return false;
}
$mask = 0x1;
while ($mask < $toRepresent) {
$mask = ($mask << 1) | 1;
}
return $mask;
} | php | protected static function getMinimalBitMask($toRepresent)
{
if ($toRepresent < 1) {
return false;
}
$mask = 0x1;
while ($mask < $toRepresent) {
$mask = ($mask << 1) | 1;
}
return $mask;
} | [
"protected",
"static",
"function",
"getMinimalBitMask",
"(",
"$",
"toRepresent",
")",
"{",
"if",
"(",
"$",
"toRepresent",
"<",
"1",
")",
"{",
"return",
"false",
";",
"}",
"$",
"mask",
"=",
"0x1",
";",
"while",
"(",
"$",
"mask",
"<",
"$",
"toRepresent",... | Returns the smallest bit mask of all 1s such that ($toRepresent & mask) = $toRepresent
@param integer $toRepresent must be an integer greater than or equal to 1
@return integer | [
"Returns",
"the",
"smallest",
"bit",
"mask",
"of",
"all",
"1s",
"such",
"that",
"(",
"$toRepresent",
"&",
"mask",
")",
"=",
"$toRepresent"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Utils/Crypt.php#L223-L233 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Connection/ConnectionStartFrame.php | ConnectionStartFrame.create | public static function create(
$versionMajor = null, $versionMinor = null, $serverProperties = null, $mechanisms = null, $locales = null
)
{
$frame = new self();
if (null !== $versionMajor) {
$frame->versionMajor = $versionMajor;
}
if (null !== $versionMinor)... | php | public static function create(
$versionMajor = null, $versionMinor = null, $serverProperties = null, $mechanisms = null, $locales = null
)
{
$frame = new self();
if (null !== $versionMajor) {
$frame->versionMajor = $versionMajor;
}
if (null !== $versionMinor)... | [
"public",
"static",
"function",
"create",
"(",
"$",
"versionMajor",
"=",
"null",
",",
"$",
"versionMinor",
"=",
"null",
",",
"$",
"serverProperties",
"=",
"null",
",",
"$",
"mechanisms",
"=",
"null",
",",
"$",
"locales",
"=",
"null",
")",
"{",
"$",
"fr... | longstr | [
"longstr"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Connection/ConnectionStartFrame.php#L24-L47 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.getFrameType | public function getFrameType($type)
{
if (is_int($type)) {
return $type;
}
if ($type === null) {
$type = 'STRING';
}
$frametype = @constant(get_class($this) . '::' . $type);
if ($frametype === null) {
Daemon::log(__METHOD__ . ' : Un... | php | public function getFrameType($type)
{
if (is_int($type)) {
return $type;
}
if ($type === null) {
$type = 'STRING';
}
$frametype = @constant(get_class($this) . '::' . $type);
if ($frametype === null) {
Daemon::log(__METHOD__ . ' : Un... | [
"public",
"function",
"getFrameType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"type",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"{",
"$",
"type",
"=",
"'STRING'",
";",
"}",
"$... | Get real frame type identificator
@param $type
@return integer | [
"Get",
"real",
"frame",
"type",
"identificator"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L115-L128 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.onInheritanceFromRequest | public function onInheritanceFromRequest($req)
{
$this->state = self::STATE_HEADERS;
$this->addr = $req->attrs->server['REMOTE_ADDR'];
$this->server = $req->attrs->server;
$this->get = $req->attrs->get;
$this->prependInput("\r\n");
$this->onRead();
} | php | public function onInheritanceFromRequest($req)
{
$this->state = self::STATE_HEADERS;
$this->addr = $req->attrs->server['REMOTE_ADDR'];
$this->server = $req->attrs->server;
$this->get = $req->attrs->get;
$this->prependInput("\r\n");
$this->onRead();
} | [
"public",
"function",
"onInheritanceFromRequest",
"(",
"$",
"req",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_HEADERS",
";",
"$",
"this",
"->",
"addr",
"=",
"$",
"req",
"->",
"attrs",
"->",
"server",
"[",
"'REMOTE_ADDR'",
"]",
";",
... | Called when connection is inherited from HTTP request
@param object $req
@return void | [
"Called",
"when",
"connection",
"is",
"inherited",
"from",
"HTTP",
"request"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L136-L144 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.onFinish | public function onFinish()
{
$this->sendFrame('', 'CONNCLOSE');
if ($this->route) {
$this->route->onFinish();
}
$this->route = null;
} | php | public function onFinish()
{
$this->sendFrame('', 'CONNCLOSE');
if ($this->route) {
$this->route->onFinish();
}
$this->route = null;
} | [
"public",
"function",
"onFinish",
"(",
")",
"{",
"$",
"this",
"->",
"sendFrame",
"(",
"''",
",",
"'CONNCLOSE'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"route",
")",
"{",
"$",
"this",
"->",
"route",
"->",
"onFinish",
"(",
")",
";",
"}",
"$",
"thi... | Event of Connection.
@return void | [
"Event",
"of",
"Connection",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L163-L171 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.onFrame | public function onFrame($data, $type)
{
if (!isset($this->route)) {
return false;
}
try {
$this->route->onWakeup();
$this->route->onFrame($data, $type);
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
i... | php | public function onFrame($data, $type)
{
if (!isset($this->route)) {
return false;
}
try {
$this->route->onWakeup();
$this->route->onFrame($data, $type);
} catch (\Exception $e) {
Daemon::uncaughtExceptionHandler($e);
}
i... | [
"public",
"function",
"onFrame",
"(",
"$",
"data",
",",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"route",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"route",
"->",
"onWakeup",
"(",
... | Called when new frame received.
@param string $data Frame's data.
@param string $type Frame's type ("STRING" OR "BINARY").
@return boolean Success. | [
"Called",
"when",
"new",
"frame",
"received",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L192-L207 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.gracefulShutdown | public function gracefulShutdown()
{
if ((!$this->route) || $this->route->gracefulShutdown()) {
$this->finish();
return true;
}
return false;
} | php | public function gracefulShutdown()
{
if ((!$this->route) || $this->route->gracefulShutdown()) {
$this->finish();
return true;
}
return false;
} | [
"public",
"function",
"gracefulShutdown",
"(",
")",
"{",
"if",
"(",
"(",
"!",
"$",
"this",
"->",
"route",
")",
"||",
"$",
"this",
"->",
"route",
"->",
"gracefulShutdown",
"(",
")",
")",
"{",
"$",
"this",
"->",
"finish",
"(",
")",
";",
"return",
"tr... | Called when the worker is going to shutdown.
@return boolean Ready to shutdown ? | [
"Called",
"when",
"the",
"worker",
"is",
"going",
"to",
"shutdown",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L213-L220 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.handshake | public function handshake()
{
$this->route = $this->pool->getRoute($this->server['DOCUMENT_URI'], $this);
if (!$this->route) {
Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot handshake session for client "' . $this->addr . '"');
$this->finish();
... | php | public function handshake()
{
$this->route = $this->pool->getRoute($this->server['DOCUMENT_URI'], $this);
if (!$this->route) {
Daemon::$process->log(get_class($this) . '::' . __METHOD__ . ' : Cannot handshake session for client "' . $this->addr . '"');
$this->finish();
... | [
"public",
"function",
"handshake",
"(",
")",
"{",
"$",
"this",
"->",
"route",
"=",
"$",
"this",
"->",
"pool",
"->",
"getRoute",
"(",
"$",
"this",
"->",
"server",
"[",
"'DOCUMENT_URI'",
"]",
",",
"$",
"this",
")",
";",
"if",
"(",
"!",
"$",
"this",
... | Called when we're going to handshake.
@return boolean Handshake status | [
"Called",
"when",
"we",
"re",
"going",
"to",
"handshake",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L227-L250 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.httpReadFirstline | protected function httpReadFirstline()
{
if (($l = $this->readline()) === null) {
return null;
}
$e = explode(' ', $l);
$u = isset($e[1]) ? parse_url($e[1]) : false;
if ($u === false) {
$this->badRequest();
return false;
}
i... | php | protected function httpReadFirstline()
{
if (($l = $this->readline()) === null) {
return null;
}
$e = explode(' ', $l);
$u = isset($e[1]) ? parse_url($e[1]) : false;
if ($u === false) {
$this->badRequest();
return false;
}
i... | [
"protected",
"function",
"httpReadFirstline",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"l",
"=",
"$",
"this",
"->",
"readline",
"(",
")",
")",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"e",
"=",
"explode",
"(",
"' '",
",",
"$",
"l",
... | Read first line of HTTP request
@return boolean|null Success | [
"Read",
"first",
"line",
"of",
"HTTP",
"request"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L295-L325 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.httpReadHeaders | protected function httpReadHeaders()
{
while (($l = $this->readLine()) !== null) {
if ($l === '') {
return true;
}
$e = explode(': ', $l);
if (isset($e[1])) {
$this->currentHeader = 'HTTP_' . strtoupper(strtr($e[0], Generic::$ht... | php | protected function httpReadHeaders()
{
while (($l = $this->readLine()) !== null) {
if ($l === '') {
return true;
}
$e = explode(': ', $l);
if (isset($e[1])) {
$this->currentHeader = 'HTTP_' . strtoupper(strtr($e[0], Generic::$ht... | [
"protected",
"function",
"httpReadHeaders",
"(",
")",
"{",
"while",
"(",
"(",
"$",
"l",
"=",
"$",
"this",
"->",
"readLine",
"(",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"l",
"===",
"''",
")",
"{",
"return",
"true",
";",
"}",
"$",
"e"... | Read headers line-by-line
@return boolean|null Success | [
"Read",
"headers",
"line",
"-",
"by",
"-",
"line"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L331-L351 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.onRead | protected function onRead()
{
if (!$this->policyReqNotFound) {
$d = $this->drainIfMatch("<policy-file-request/>\x00");
if ($d === null) { // partially match
return;
}
if ($d) {
if (($FP = \PHPDaemon\Servers\FlashPolicy\Pool::get... | php | protected function onRead()
{
if (!$this->policyReqNotFound) {
$d = $this->drainIfMatch("<policy-file-request/>\x00");
if ($d === null) { // partially match
return;
}
if ($d) {
if (($FP = \PHPDaemon\Servers\FlashPolicy\Pool::get... | [
"protected",
"function",
"onRead",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"policyReqNotFound",
")",
"{",
"$",
"d",
"=",
"$",
"this",
"->",
"drainIfMatch",
"(",
"\"<policy-file-request/>\\x00\"",
")",
";",
"if",
"(",
"$",
"d",
"===",
"null",
... | Called when new data received.
@return void | [
"Called",
"when",
"new",
"data",
"received",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L357-L403 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.httpProcessHeaders | protected function httpProcessHeaders()
{
$this->state = self::STATE_PREHANDSHAKE;
if (isset($this->server['HTTP_SEC_WEBSOCKET_EXTENSIONS'])) {
$str = strtolower($this->server['HTTP_SEC_WEBSOCKET_EXTENSIONS']);
$str = preg_replace($this->extensionsCleanRegex, '', $str);
... | php | protected function httpProcessHeaders()
{
$this->state = self::STATE_PREHANDSHAKE;
if (isset($this->server['HTTP_SEC_WEBSOCKET_EXTENSIONS'])) {
$str = strtolower($this->server['HTTP_SEC_WEBSOCKET_EXTENSIONS']);
$str = preg_replace($this->extensionsCleanRegex, '', $str);
... | [
"protected",
"function",
"httpProcessHeaders",
"(",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_PREHANDSHAKE",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
"'HTTP_SEC_WEBSOCKET_EXTENSIONS'",
"]",
")",
")",
"{",
"$",
"... | Process headers
@return bool | [
"Process",
"headers"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L409-L454 |
kakserpom/phpdaemon | PHPDaemon/Servers/WebSocket/Connection.php | Connection.header | public function header($s, $replace = true, $code = false)
{
if ($code) {
$this->status($code);
}
if ($this->headers_sent) {
throw new RequestHeadersAlreadySent;
}
$s = strtr($s, "\r\n", ' ');
$e = explode(':', $s, 2);
if (!isset($e... | php | public function header($s, $replace = true, $code = false)
{
if ($code) {
$this->status($code);
}
if ($this->headers_sent) {
throw new RequestHeadersAlreadySent;
}
$s = strtr($s, "\r\n", ' ');
$e = explode(':', $s, 2);
if (!isset($e... | [
"public",
"function",
"header",
"(",
"$",
"s",
",",
"$",
"replace",
"=",
"true",
",",
"$",
"code",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"code",
")",
"{",
"$",
"this",
"->",
"status",
"(",
"$",
"code",
")",
";",
"}",
"if",
"(",
"$",
"this",... | Send the header
@param string $s Header. Example: 'Location: http://php.net/'
@param boolean $replace Optional. Replace?
@param boolean $code Optional. HTTP response code
@throws \PHPDaemon\Request\RequestHeadersAlreadySent
@return boolean Success | [
"Send",
"the",
"header"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/WebSocket/Connection.php#L497-L552 |
kakserpom/phpdaemon | PHPDaemon/Examples/GameMonitor.php | GameMonitor.init | public function init()
{
if ($this->isEnabled()) {
$this->client = \PHPDaemon\Clients\Valve\Pool::getInstance();
$this->db = \MongoClient::getInstance();
$this->servers = $this->db->{$this->config->dbname->value . '.servers'};
}
} | php | public function init()
{
if ($this->isEnabled()) {
$this->client = \PHPDaemon\Clients\Valve\Pool::getInstance();
$this->db = \MongoClient::getInstance();
$this->servers = $this->db->{$this->config->dbname->value . '.servers'};
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"\\",
"PHPDaemon",
"\\",
"Clients",
"\\",
"Valve",
"\\",
"Pool",
"::",
"getInstance",
"(",
")",
";",
"$",
... | Constructor.
@return void | [
"Constructor",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Examples/GameMonitor.php#L23-L30 |
kakserpom/phpdaemon | PHPDaemon/Examples/GameMonitor.php | GameMonitor.onReady | public function onReady()
{
if ($this->isEnabled()) {
$this->updateTimer = setTimeout(function ($timer) {
$this->updateAllServers();
$timer->timeout(2e6);
}, 1);
}
} | php | public function onReady()
{
if ($this->isEnabled()) {
$this->updateTimer = setTimeout(function ($timer) {
$this->updateAllServers();
$timer->timeout(2e6);
}, 1);
}
} | [
"public",
"function",
"onReady",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"updateTimer",
"=",
"setTimeout",
"(",
"function",
"(",
"$",
"timer",
")",
"{",
"$",
"this",
"->",
"updateAllServers",
"... | Called when the worker is ready to go.
@return void | [
"Called",
"when",
"the",
"worker",
"is",
"ready",
"to",
"go",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Examples/GameMonitor.php#L47-L55 |
kakserpom/phpdaemon | PHPDaemon/Examples/GameMonitor.php | GameMonitorHTTPRequest.init | public function init()
{
$req = $this;
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function () use ($req) { // called when job is done
$req->wakeup(); // wake up the request immediately
});
$job('getServers', function ($name, $job) use ($req) { // registering job named 'pingjob'
... | php | public function init()
{
$req = $this;
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function () use ($req) { // called when job is done
$req->wakeup(); // wake up the request immediately
});
$job('getServers', function ($name, $job) use ($req) { // registering job named 'pingjob'
... | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"req",
"=",
"$",
"this",
";",
"$",
"job",
"=",
"$",
"this",
"->",
"job",
"=",
"new",
"\\",
"PHPDaemon",
"\\",
"Core",
"\\",
"ComplexJob",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"req",
")",
... | Constructor.
@return void | [
"Constructor",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Examples/GameMonitor.php#L206-L226 |
kakserpom/phpdaemon | PHPDaemon/Clients/Redis/Examples/SimpleRequest.php | SimpleRequest.init | public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) {
// called when job is done
// prevent cleaning up results
$job->keep();
// wake up the request immediately
$this->wakeup();
});
// just... | php | public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) {
// called when job is done
// prevent cleaning up results
$job->keep();
// wake up the request immediately
$this->wakeup();
});
// just... | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"job",
"=",
"$",
"this",
"->",
"job",
"=",
"new",
"\\",
"PHPDaemon",
"\\",
"Core",
"\\",
"ComplexJob",
"(",
"function",
"(",
"$",
"job",
")",
"{",
"// called when job is done",
"// prevent cleaning up results... | Constructor.
@return void | [
"Constructor",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/Redis/Examples/SimpleRequest.php#L22-L53 |
kakserpom/phpdaemon | PHPDaemon/Core/EventLoop.php | EventLoop.run | public function run()
{
$this->stopped = false;
while (!$this->stopped) {
$this->callbacks->executeAll($this);
if (!$this->base->dispatch()) {
break;
}
}
} | php | public function run()
{
$this->stopped = false;
while (!$this->stopped) {
$this->callbacks->executeAll($this);
if (!$this->base->dispatch()) {
break;
}
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"stopped",
"=",
"false",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"stopped",
")",
"{",
"$",
"this",
"->",
"callbacks",
"->",
"executeAll",
"(",
"$",
"this",
")",
";",
"if",
"(",
"!"... | Run | [
"Run"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/EventLoop.php#L144-L153 |
kakserpom/phpdaemon | PHPDaemon/Examples/ExampleWithMySQL.php | ExampleWithMySQLRequest.init | public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) { // called when job is done
$job->keep();
$this->wakeup(); // wake up the request immediately
});
$job('select', function ($name, $job) { // registering job named 'select'
$this->appInsta... | php | public function init()
{
$job = $this->job = new \PHPDaemon\Core\ComplexJob(function ($job) { // called when job is done
$job->keep();
$this->wakeup(); // wake up the request immediately
});
$job('select', function ($name, $job) { // registering job named 'select'
$this->appInsta... | [
"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/ExampleWithMySQL.php#L56-L88 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Confirm/ConfirmSelectFrame.php | ConfirmSelectFrame.create | public static function create(
$nowait = null
)
{
$frame = new self();
if (null !== $nowait) {
$frame->nowait = $nowait;
}
return $frame;
} | php | public static function create(
$nowait = null
)
{
$frame = new self();
if (null !== $nowait) {
$frame->nowait = $nowait;
}
return $frame;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"nowait",
"=",
"null",
")",
"{",
"$",
"frame",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"nowait",
")",
"{",
"$",
"frame",
"->",
"nowait",
"=",
"$",
"nowait",
";",
"}",
... | bit | [
"bit"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Confirm/ConfirmSelectFrame.php#L20-L31 |
kakserpom/phpdaemon | PHPDaemon/Examples/ExampleComplexJob.php | ExampleComplexJob.onReady | public function onReady()
{
// Adding listener
// ComplexJob - STATE_WAITING
$job = new \PHPDaemon\Core\ComplexJob(function ($job) {
// ComplexJob - STATE_DONE
/*array (
'bar' =>
array (
'job' => 'bar',
... | php | public function onReady()
{
// Adding listener
// ComplexJob - STATE_WAITING
$job = new \PHPDaemon\Core\ComplexJob(function ($job) {
// ComplexJob - STATE_DONE
/*array (
'bar' =>
array (
'job' => 'bar',
... | [
"public",
"function",
"onReady",
"(",
")",
"{",
"// Adding listener",
"// ComplexJob - STATE_WAITING",
"$",
"job",
"=",
"new",
"\\",
"PHPDaemon",
"\\",
"Core",
"\\",
"ComplexJob",
"(",
"function",
"(",
"$",
"job",
")",
"{",
"// ComplexJob - STATE_DONE",
"/*array (... | Called when the worker is ready to go
@return void | [
"Called",
"when",
"the",
"worker",
"is",
"ready",
"to",
"go"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Examples/ExampleComplexJob.php#L20-L84 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Connection/ConnectionOpenOkFrame.php | ConnectionOpenOkFrame.create | public static function create(
$knownHosts = null
)
{
$frame = new self();
if (null !== $knownHosts) {
$frame->knownHosts = $knownHosts;
}
return $frame;
} | php | public static function create(
$knownHosts = null
)
{
$frame = new self();
if (null !== $knownHosts) {
$frame->knownHosts = $knownHosts;
}
return $frame;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"knownHosts",
"=",
"null",
")",
"{",
"$",
"frame",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"knownHosts",
")",
"{",
"$",
"frame",
"->",
"knownHosts",
"=",
"$",
"knownHosts",... | shortstr | [
"shortstr"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Connection/ConnectionOpenOkFrame.php#L20-L31 |
kakserpom/phpdaemon | PHPDaemon/PubSub/PubSubEvent.php | PubSubEvent.sub | public function sub($obj, $cb)
{
$act = $this->count() === 0;
$this->attach($obj, $cb);
if ($act) {
if (($func = $this->actCb) !== null) {
$func($this);
}
}
return $this;
} | php | public function sub($obj, $cb)
{
$act = $this->count() === 0;
$this->attach($obj, $cb);
if ($act) {
if (($func = $this->actCb) !== null) {
$func($this);
}
}
return $this;
} | [
"public",
"function",
"sub",
"(",
"$",
"obj",
",",
"$",
"cb",
")",
"{",
"$",
"act",
"=",
"$",
"this",
"->",
"count",
"(",
")",
"===",
"0",
";",
"$",
"this",
"->",
"attach",
"(",
"$",
"obj",
",",
"$",
"cb",
")",
";",
"if",
"(",
"$",
"act",
... | Subscribe
@param object $obj Subcriber object
@param callable $cb Callback
@return this | [
"Subscribe"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/PubSub/PubSubEvent.php#L82-L92 |
kakserpom/phpdaemon | PHPDaemon/PubSub/PubSubEvent.php | PubSubEvent.unsub | public function unsub($obj)
{
$this->detach($obj);
if ($this->count() === 0) {
if (($func = $this->deactCb) !== null) {
$func($this);
}
}
return $this;
} | php | public function unsub($obj)
{
$this->detach($obj);
if ($this->count() === 0) {
if (($func = $this->deactCb) !== null) {
$func($this);
}
}
return $this;
} | [
"public",
"function",
"unsub",
"(",
"$",
"obj",
")",
"{",
"$",
"this",
"->",
"detach",
"(",
"$",
"obj",
")",
";",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
"===",
"0",
")",
"{",
"if",
"(",
"(",
"$",
"func",
"=",
"$",
"this",
"->",
"d... | Unsubscripe
@param object $obj Subscriber object
@return this | [
"Unsubscripe"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/PubSub/PubSubEvent.php#L99-L108 |
kakserpom/phpdaemon | PHPDaemon/PubSub/PubSubEvent.php | PubSubEvent.pub | public function pub($data)
{
foreach ($this as $obj) {
$func = $this->getInfo();
$func($data);
}
return $this;
} | php | public function pub($data)
{
foreach ($this as $obj) {
$func = $this->getInfo();
$func($data);
}
return $this;
} | [
"public",
"function",
"pub",
"(",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"obj",
")",
"{",
"$",
"func",
"=",
"$",
"this",
"->",
"getInfo",
"(",
")",
";",
"$",
"func",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"thi... | Publish
@param mixed $data Data
@return this | [
"Publish"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/PubSub/PubSubEvent.php#L115-L122 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Queue/QueueDeleteOkFrame.php | QueueDeleteOkFrame.create | public static function create(
$messageCount = null
)
{
$frame = new self();
if (null !== $messageCount) {
$frame->messageCount = $messageCount;
}
return $frame;
} | php | public static function create(
$messageCount = null
)
{
$frame = new self();
if (null !== $messageCount) {
$frame->messageCount = $messageCount;
}
return $frame;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"messageCount",
"=",
"null",
")",
"{",
"$",
"frame",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"messageCount",
")",
"{",
"$",
"frame",
"->",
"messageCount",
"=",
"$",
"messag... | long | [
"long"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Protocol/Queue/QueueDeleteOkFrame.php#L20-L31 |
kakserpom/phpdaemon | PHPDaemon/SockJS/Methods/JsonpSend.php | JsonpSend.run | public function run()
{
if ($this->stage++ > 0) {
$this->header('500 Too Busy');
return;
}
$this->noncache();
if (isset($_SERVER['HTTP_CONTENT_TYPE']) && $_SERVER['HTTP_CONTENT_TYPE'] === 'application/x-www-form-urlencoded') {
if (!isset($_POST['d'... | php | public function run()
{
if ($this->stage++ > 0) {
$this->header('500 Too Busy');
return;
}
$this->noncache();
if (isset($_SERVER['HTTP_CONTENT_TYPE']) && $_SERVER['HTTP_CONTENT_TYPE'] === 'application/x-www-form-urlencoded') {
if (!isset($_POST['d'... | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stage",
"++",
">",
"0",
")",
"{",
"$",
"this",
"->",
"header",
"(",
"'500 Too Busy'",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"noncache",
"(",
")",
";",
"if",
"... | Called when request iterated
@return void | [
"Called",
"when",
"request",
"iterated"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/SockJS/Methods/JsonpSend.php#L18-L59 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.addListener | public function addListener($cb)
{
if ($this->state === self::STATE_DONE) {
$cb($this);
return;
}
$this->listeners[] = CallbackWrapper::wrap($cb);
} | php | public function addListener($cb)
{
if ($this->state === self::STATE_DONE) {
$cb($this);
return;
}
$this->listeners[] = CallbackWrapper::wrap($cb);
} | [
"public",
"function",
"addListener",
"(",
"$",
"cb",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"self",
"::",
"STATE_DONE",
")",
"{",
"$",
"cb",
"(",
"$",
"this",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"listeners",
"[",
"]"... | Adds listener
@param callable $cb Callback
@return void | [
"Adds",
"listener"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L82-L89 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.offsetGet | public function offsetGet($j)
{
return isset($this->results[$j]) ? $this->results[$j] : null;
} | php | public function offsetGet($j)
{
return isset($this->results[$j]) ? $this->results[$j] : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"j",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"results",
"[",
"$",
"j",
"]",
")",
"?",
"$",
"this",
"->",
"results",
"[",
"$",
"j",
"]",
":",
"null",
";",
"}"
] | Handler of $job[$name]
@param string $j Job name
@return mixed | [
"Handler",
"of",
"$job",
"[",
"$name",
"]"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L106-L109 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.setResult | public function setResult($jobname, $result = null)
{
if (isset($this->results[$jobname])) {
return false;
}
$this->results[$jobname] = $result;
++$this->resultsNum;
$this->checkIfAllReady();
return true;
} | php | public function setResult($jobname, $result = null)
{
if (isset($this->results[$jobname])) {
return false;
}
$this->results[$jobname] = $result;
++$this->resultsNum;
$this->checkIfAllReady();
return true;
} | [
"public",
"function",
"setResult",
"(",
"$",
"jobname",
",",
"$",
"result",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"results",
"[",
"$",
"jobname",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"re... | Set result
@param string $jobname Job name
@param mixed $result Result
@return boolean | [
"Set",
"result"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L128-L137 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.checkIfAllReady | protected function checkIfAllReady()
{
$this->checkQueue();
if ($this->resultsNum >= $this->jobsNum) {
$this->jobs = [];
$this->state = self::STATE_DONE;
foreach ($this->listeners as $cb) {
$cb($this);
}
if (!$this->keep && ... | php | protected function checkIfAllReady()
{
$this->checkQueue();
if ($this->resultsNum >= $this->jobsNum) {
$this->jobs = [];
$this->state = self::STATE_DONE;
foreach ($this->listeners as $cb) {
$cb($this);
}
if (!$this->keep && ... | [
"protected",
"function",
"checkIfAllReady",
"(",
")",
"{",
"$",
"this",
"->",
"checkQueue",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"resultsNum",
">=",
"$",
"this",
"->",
"jobsNum",
")",
"{",
"$",
"this",
"->",
"jobs",
"=",
"[",
"]",
";",
"$",... | Checks if all jobs are ready
@return void | [
"Checks",
"if",
"all",
"jobs",
"are",
"ready"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L143-L156 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.checkQueue | public function checkQueue()
{
if ($this->backlog !== null) {
while (!$this->backlog->isEmpty()) {
if ($this->maxConcurrency !== -1 && ($this->jobsNum - $this->resultsNum > $this->maxConcurrency)) {
return;
}
list($name, $cb) = ... | php | public function checkQueue()
{
if ($this->backlog !== null) {
while (!$this->backlog->isEmpty()) {
if ($this->maxConcurrency !== -1 && ($this->jobsNum - $this->resultsNum > $this->maxConcurrency)) {
return;
}
list($name, $cb) = ... | [
"public",
"function",
"checkQueue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"backlog",
"!==",
"null",
")",
"{",
"while",
"(",
"!",
"$",
"this",
"->",
"backlog",
"->",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"maxConcurrency... | Called automatically. Checks whether if the queue is full. If not, tries to pull more jobs from backlog and 'more'
@return void | [
"Called",
"automatically",
".",
"Checks",
"whether",
"if",
"the",
"queue",
"is",
"full",
".",
"If",
"not",
"tries",
"to",
"pull",
"more",
"jobs",
"from",
"backlog",
"and",
"more"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L162-L176 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.addJob | public function addJob($name, $cb)
{
if (isset($this->jobs[$name])) {
return false;
}
$cb = CallbackWrapper::wrap($cb);
if ($this->maxConcurrency !== -1 && ($this->jobsNum - $this->resultsNum > $this->maxConcurrency)) {
if ($this->backlog === null) {
... | php | public function addJob($name, $cb)
{
if (isset($this->jobs[$name])) {
return false;
}
$cb = CallbackWrapper::wrap($cb);
if ($this->maxConcurrency !== -1 && ($this->jobsNum - $this->resultsNum > $this->maxConcurrency)) {
if ($this->backlog === null) {
... | [
"public",
"function",
"addJob",
"(",
"$",
"name",
",",
"$",
"cb",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"jobs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cb",
"=",
"CallbackWrapper",
"::",
"wrap",
... | Adds job
@param string $name Job name
@param callable $cb Callback
@return boolean Success | [
"Adds",
"job"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L184-L204 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.more | public function more($cb = null)
{
if ($cb !== null) {
$this->more = $cb;
$this->moreFirstFlag = true;
return $this;
}
if ($this->more !== null) {
if ($this->more instanceof \Iterator) {
iterator:
$it = $this->mo... | php | public function more($cb = null)
{
if ($cb !== null) {
$this->more = $cb;
$this->moreFirstFlag = true;
return $this;
}
if ($this->more !== null) {
if ($this->more instanceof \Iterator) {
iterator:
$it = $this->mo... | [
"public",
"function",
"more",
"(",
"$",
"cb",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"cb",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"more",
"=",
"$",
"cb",
";",
"$",
"this",
"->",
"moreFirstFlag",
"=",
"true",
";",
"return",
"$",
"this",
";"... | Sets a callback which is going to be fired always when we have a room for more jobs
@param callable $cb Callback
@return this | [
"Sets",
"a",
"callback",
"which",
"is",
"going",
"to",
"be",
"fired",
"always",
"when",
"we",
"have",
"a",
"room",
"for",
"more",
"jobs"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L211-L242 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.cleanup | public function cleanup()
{
$this->listeners = [];
$this->results = [];
$this->jobs = [];
$this->more = null;
} | php | public function cleanup()
{
$this->listeners = [];
$this->results = [];
$this->jobs = [];
$this->more = null;
} | [
"public",
"function",
"cleanup",
"(",
")",
"{",
"$",
"this",
"->",
"listeners",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"results",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"jobs",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"more",
"=",
"null",
";",
... | Clean up
@return void | [
"Clean",
"up"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L257-L263 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.getResult | public function getResult($jobname)
{
return isset($this->results[$jobname]) ? $this->results[$jobname] : null;
} | php | public function getResult($jobname)
{
return isset($this->results[$jobname]) ? $this->results[$jobname] : null;
} | [
"public",
"function",
"getResult",
"(",
"$",
"jobname",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"results",
"[",
"$",
"jobname",
"]",
")",
"?",
"$",
"this",
"->",
"results",
"[",
"$",
"jobname",
"]",
":",
"null",
";",
"}"
] | Get result
@param string $jobname Job name
@return mixed Result or null | [
"Get",
"result"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L319-L322 |
kakserpom/phpdaemon | PHPDaemon/Core/ComplexJob.php | ComplexJob.execute | public function execute()
{
if ($this->state === self::STATE_WAITING) {
$this->state = self::STATE_RUNNING;
foreach ($this->jobs as $name => $cb) {
$cb($name, $this);
$this->jobs[$name] = null;
}
$this->checkIfAllReady();
... | php | public function execute()
{
if ($this->state === self::STATE_WAITING) {
$this->state = self::STATE_RUNNING;
foreach ($this->jobs as $name => $cb) {
$cb($name, $this);
$this->jobs[$name] = null;
}
$this->checkIfAllReady();
... | [
"public",
"function",
"execute",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"self",
"::",
"STATE_WAITING",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"self",
"::",
"STATE_RUNNING",
";",
"foreach",
"(",
"$",
"this",
"->",
"jobs",
"as... | Runs the job
@return void | [
"Runs",
"the",
"job"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Core/ComplexJob.php#L343-L353 |
kakserpom/phpdaemon | PHPDaemon/Clients/DNS/Connection.php | Connection.onRead | public function onRead()
{
start:
if ($this->type === 'udp') {
$this->onUdpPacket($this->read($this->getInputLength()));
return;
}
if ($this->state === self::STATE_ROOT) {
if (false === ($hdr = $this->readExact(2))) {
return; // not... | php | public function onRead()
{
start:
if ($this->type === 'udp') {
$this->onUdpPacket($this->read($this->getInputLength()));
return;
}
if ($this->state === self::STATE_ROOT) {
if (false === ($hdr = $this->readExact(2))) {
return; // not... | [
"public",
"function",
"onRead",
"(",
")",
"{",
"start",
":",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"'udp'",
")",
"{",
"$",
"this",
"->",
"onUdpPacket",
"(",
"$",
"this",
"->",
"read",
"(",
"$",
"this",
"->",
"getInputLength",
"(",
")",
")",
... | Called when new data received
@return void | [
"Called",
"when",
"new",
"data",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/DNS/Connection.php#L67-L91 |
kakserpom/phpdaemon | PHPDaemon/Clients/DNS/Connection.php | Connection.onUdpPacket | public function onUdpPacket($pct)
{
if (mb_orig_strlen($pct) < 10) {
return;
}
$orig = $pct;
$this->response = [];
Binary::getWord($pct); // ID
$bitmap = Binary::getBitmap(Binary::getByte($pct)) . Binary::getBitmap(Binary::getByte($pct));
//$qr = (... | php | public function onUdpPacket($pct)
{
if (mb_orig_strlen($pct) < 10) {
return;
}
$orig = $pct;
$this->response = [];
Binary::getWord($pct); // ID
$bitmap = Binary::getBitmap(Binary::getByte($pct)) . Binary::getBitmap(Binary::getByte($pct));
//$qr = (... | [
"public",
"function",
"onUdpPacket",
"(",
"$",
"pct",
")",
"{",
"if",
"(",
"mb_orig_strlen",
"(",
"$",
"pct",
")",
"<",
"10",
")",
"{",
"return",
";",
"}",
"$",
"orig",
"=",
"$",
"pct",
";",
"$",
"this",
"->",
"response",
"=",
"[",
"]",
";",
"B... | Called when new UDP packet received.
@param string $pct
@return void | [
"Called",
"when",
"new",
"UDP",
"packet",
"received",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/DNS/Connection.php#L98-L223 |
kakserpom/phpdaemon | PHPDaemon/Clients/DNS/Connection.php | Connection.get | public function get($hostname, $cb)
{
$this->onResponse->push($cb);
$this->setFree(false);
$e = explode(':', $hostname, 3);
$hostname = $e[0];
$qtype = isset($e[1]) ? $e[1] : 'A';
$qclass = isset($e[2]) ? $e[2] : 'IN';
$QD = [];
$qtypeInt = array_searc... | php | public function get($hostname, $cb)
{
$this->onResponse->push($cb);
$this->setFree(false);
$e = explode(':', $hostname, 3);
$hostname = $e[0];
$qtype = isset($e[1]) ? $e[1] : 'A';
$qclass = isset($e[2]) ? $e[2] : 'IN';
$QD = [];
$qtypeInt = array_searc... | [
"public",
"function",
"get",
"(",
"$",
"hostname",
",",
"$",
"cb",
")",
"{",
"$",
"this",
"->",
"onResponse",
"->",
"push",
"(",
"$",
"cb",
")",
";",
"$",
"this",
"->",
"setFree",
"(",
"false",
")",
";",
"$",
"e",
"=",
"explode",
"(",
"':'",
",... | Gets the host information
@param string $hostname Hostname
@param callable $cb Callback
@callback $cb ( )
@return void | [
"Gets",
"the",
"host",
"information"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/DNS/Connection.php#L245-L291 |
kakserpom/phpdaemon | PHPDaemon/Examples/ExampleSandbox.php | ExampleSandboxRequest.run | public function run()
{
$stime = microtime(true);
$this->header('Content-Type: text/html');
$sandbox = new \Runkit_Sandbox([
'safe_mode' => true,
'open_basedir' => '/var/www/users/jdoe/',
'allow_url_fopen' => 'false',
'disable_functions' => 'e... | php | public function run()
{
$stime = microtime(true);
$this->header('Content-Type: text/html');
$sandbox = new \Runkit_Sandbox([
'safe_mode' => true,
'open_basedir' => '/var/www/users/jdoe/',
'allow_url_fopen' => 'false',
'disable_functions' => 'e... | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"stime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"header",
"(",
"'Content-Type: text/html'",
")",
";",
"$",
"sandbox",
"=",
"new",
"\\",
"Runkit_Sandbox",
"(",
"[",
"'safe_mode'",
"=>",... | Called when request iterated.
@return integer Status. | [
"Called",
"when",
"request",
"iterated",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Examples/ExampleSandbox.php#L64-L82 |
kakserpom/phpdaemon | PHPDaemon/Cache/Item.php | Item.setValue | public function setValue($value)
{
$this->value = $value;
$this->listeners->executeAll($this->value);
} | php | public function setValue($value)
{
$this->value = $value;
$this->listeners->executeAll($this->value);
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"listeners",
"->",
"executeAll",
"(",
"$",
"this",
"->",
"value",
")",
";",
"}"
] | Sets the value
@param mixed $value | [
"Sets",
"the",
"value"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Cache/Item.php#L65-L69 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseShortString | private function parseShortString()
{
$length = \ord($this->buffer);
try {
return mb_orig_substr($this->buffer, 1, $length);
} finally {
$this->buffer = mb_orig_substr($this->buffer, $length + 1);
}
} | php | private function parseShortString()
{
$length = \ord($this->buffer);
try {
return mb_orig_substr($this->buffer, 1, $length);
} finally {
$this->buffer = mb_orig_substr($this->buffer, $length + 1);
}
} | [
"private",
"function",
"parseShortString",
"(",
")",
"{",
"$",
"length",
"=",
"\\",
"ord",
"(",
"$",
"this",
"->",
"buffer",
")",
";",
"try",
"{",
"return",
"mb_orig_substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"1",
",",
"$",
"length",
")",
";",
... | Parse an AMQP "short string" from the head of the buffer.
The maximum length of a short string is 255 bytes.
@todo UTF-8 validation, maybe. | [
"Parse",
"an",
"AMQP",
"short",
"string",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L29-L38 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseLongString | private function parseLongString()
{
list(, $length) = \unpack('N', $this->buffer);
try {
return mb_orig_substr($this->buffer, 4, $length);
} finally {
$this->buffer = mb_orig_substr($this->buffer, $length + 4);
}
} | php | private function parseLongString()
{
list(, $length) = \unpack('N', $this->buffer);
try {
return mb_orig_substr($this->buffer, 4, $length);
} finally {
$this->buffer = mb_orig_substr($this->buffer, $length + 4);
}
} | [
"private",
"function",
"parseLongString",
"(",
")",
"{",
"list",
"(",
",",
"$",
"length",
")",
"=",
"\\",
"unpack",
"(",
"'N'",
",",
"$",
"this",
"->",
"buffer",
")",
";",
"try",
"{",
"return",
"mb_orig_substr",
"(",
"$",
"this",
"->",
"buffer",
",",... | Parse an AMQP "long string" from the head of the buffer.
@todo UTF-8 validation, maybe.
@return string | [
"Parse",
"an",
"AMQP",
"long",
"string",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L46-L55 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseSignedInt8 | private function parseSignedInt8()
{
try {
$result = \ord($this->buffer);
if ($result & 0x80) {
return $result - 0x100;
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 1);
}
} | php | private function parseSignedInt8()
{
try {
$result = \ord($this->buffer);
if ($result & 0x80) {
return $result - 0x100;
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 1);
}
} | [
"private",
"function",
"parseSignedInt8",
"(",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"\\",
"ord",
"(",
"$",
"this",
"->",
"buffer",
")",
";",
"if",
"(",
"$",
"result",
"&",
"0x80",
")",
"{",
"return",
"$",
"result",
"-",
"0x100",
";",
"}",
"r... | Parse a 8-bit signed integer from the head of the buffer.
@return int | [
"Parse",
"a",
"8",
"-",
"bit",
"signed",
"integer",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L61-L74 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseSignedInt16 | private function parseSignedInt16()
{
try {
$result = \unpack('n', $this->buffer)[1];
if ($result & 0x8000) {
return $result - 0x10000;
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 2);
... | php | private function parseSignedInt16()
{
try {
$result = \unpack('n', $this->buffer)[1];
if ($result & 0x8000) {
return $result - 0x10000;
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 2);
... | [
"private",
"function",
"parseSignedInt16",
"(",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"\\",
"unpack",
"(",
"'n'",
",",
"$",
"this",
"->",
"buffer",
")",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"result",
"&",
"0x8000",
")",
"{",
"return",
"$",
"re... | Parse a 16-bit signed integer from the head of the buffer.
@return int | [
"Parse",
"a",
"16",
"-",
"bit",
"signed",
"integer",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L93-L106 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseSignedInt32 | private function parseSignedInt32()
{
try {
$result = \unpack('N', $this->buffer)[1];
if ($result & 0x80000000) {
return $result - 0x100000000;
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 4)... | php | private function parseSignedInt32()
{
try {
$result = \unpack('N', $this->buffer)[1];
if ($result & 0x80000000) {
return $result - 0x100000000;
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 4)... | [
"private",
"function",
"parseSignedInt32",
"(",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"\\",
"unpack",
"(",
"'N'",
",",
"$",
"this",
"->",
"buffer",
")",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"result",
"&",
"0x80000000",
")",
"{",
"return",
"$",
... | Parse a 32-bit signed integer from the head of the buffer.
@return int | [
"Parse",
"a",
"32",
"-",
"bit",
"signed",
"integer",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L112-L125 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseUnsignedInt64 | private function parseUnsignedInt64()
{
try {
$result = \unpack('J', $this->buffer)[1];
if ($result < 0) {
return sprintf('%u', $result);
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 8);
... | php | private function parseUnsignedInt64()
{
try {
$result = \unpack('J', $this->buffer)[1];
if ($result < 0) {
return sprintf('%u', $result);
}
return $result;
} finally {
$this->buffer = mb_orig_substr($this->buffer, 8);
... | [
"private",
"function",
"parseUnsignedInt64",
"(",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"\\",
"unpack",
"(",
"'J'",
",",
"$",
"this",
"->",
"buffer",
")",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"result",
"<",
"0",
")",
"{",
"return",
"sprintf",
... | Parse a 64-bit unsigned integer from the head of the buffer.
@return integer|string A string is returned when the value is is outside
the range of PHP's signed integer type. | [
"Parse",
"a",
"64",
"-",
"bit",
"unsigned",
"integer",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L161-L172 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseFloat | public function parseFloat()
{
try {
if (Endianness::LITTLE()) {
return \unpack('f', \strrev(mb_orig_substr($this->buffer, 0, 4)))[1];
}
return \unpack('f', $this->buffer)[1]; // @codeCoverageIgnore
} finally {
$this->buffer = mb_orig_s... | php | public function parseFloat()
{
try {
if (Endianness::LITTLE()) {
return \unpack('f', \strrev(mb_orig_substr($this->buffer, 0, 4)))[1];
}
return \unpack('f', $this->buffer)[1]; // @codeCoverageIgnore
} finally {
$this->buffer = mb_orig_s... | [
"public",
"function",
"parseFloat",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"Endianness",
"::",
"LITTLE",
"(",
")",
")",
"{",
"return",
"\\",
"unpack",
"(",
"'f'",
",",
"\\",
"strrev",
"(",
"mb_orig_substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"0",
... | Parse a float (4-byte) from the head of the buffer.
@return float | [
"Parse",
"a",
"float",
"(",
"4",
"-",
"byte",
")",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L178-L188 |
kakserpom/phpdaemon | PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php | ScalarParserTrait.parseDouble | public function parseDouble()
{
try {
if (Endianness::LITTLE()) {
return \unpack('d', \strrev(mb_orig_substr($this->buffer, 0, 8)))[1];
}
return \unpack('d', $this->buffer)[1]; // @codeCoverageIgnore
} finally {
$this->buffer = mb_orig_... | php | public function parseDouble()
{
try {
if (Endianness::LITTLE()) {
return \unpack('d', \strrev(mb_orig_substr($this->buffer, 0, 8)))[1];
}
return \unpack('d', $this->buffer)[1]; // @codeCoverageIgnore
} finally {
$this->buffer = mb_orig_... | [
"public",
"function",
"parseDouble",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"Endianness",
"::",
"LITTLE",
"(",
")",
")",
"{",
"return",
"\\",
"unpack",
"(",
"'d'",
",",
"\\",
"strrev",
"(",
"mb_orig_substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"0",... | Parse a double (8-byte) from the head of the buffer.
@return float | [
"Parse",
"a",
"double",
"(",
"8",
"-",
"byte",
")",
"from",
"the",
"head",
"of",
"the",
"buffer",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/AMQP/Driver/Protocol/v091/Parser/ScalarParserTrait.php#L194-L204 |
kakserpom/phpdaemon | PHPDaemon/Applications/ServerStatusRequest.php | ServerStatusRequest.run | public function run()
{
$stime = microtime(true);
$this->header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1... | php | public function run()
{
$stime = microtime(true);
$this->header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1... | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"stime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"header",
"(",
"'Content-Type: text/html; charset=utf-8'",
")",
";",
"?>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n ... | Called when request iterated.
@return integer Status. | [
"Called",
"when",
"request",
"iterated",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Applications/ServerStatusRequest.php#L21-L58 |
kakserpom/phpdaemon | PHPDaemon/SockJS/Methods/Info.php | Info.init | public function init()
{
parent::init();
Crypt::randomInts32(1, function ($ints) {
$this->opts['entropy'] = $ints[0];
echo json_encode($this->opts);
$this->finish();
}, 9);
$this->sleep(5, true);
} | php | public function init()
{
parent::init();
Crypt::randomInts32(1, function ($ints) {
$this->opts['entropy'] = $ints[0];
echo json_encode($this->opts);
$this->finish();
}, 9);
$this->sleep(5, true);
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"Crypt",
"::",
"randomInts32",
"(",
"1",
",",
"function",
"(",
"$",
"ints",
")",
"{",
"$",
"this",
"->",
"opts",
"[",
"'entropy'",
"]",
"=",
"$",
"ints",
"[",
"0"... | Constructor
@return void | [
"Constructor"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/SockJS/Methods/Info.php#L19-L28 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.onConnected | public function onConnected($cb)
{
if ($this->phase === self::PHASE_AUTH_ERR) {
$cb($this, false);
} elseif ($this->phase === self::PHASE_HANDSHAKED) {
$cb($this, true);
} else {
if (!$this->onConnected) {
$this->onConnected = new StackCall... | php | public function onConnected($cb)
{
if ($this->phase === self::PHASE_AUTH_ERR) {
$cb($this, false);
} elseif ($this->phase === self::PHASE_HANDSHAKED) {
$cb($this, true);
} else {
if (!$this->onConnected) {
$this->onConnected = new StackCall... | [
"public",
"function",
"onConnected",
"(",
"$",
"cb",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"phase",
"===",
"self",
"::",
"PHASE_AUTH_ERR",
")",
"{",
"$",
"cb",
"(",
"$",
"this",
",",
"false",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"ph... | Executes the given callback when/if the connection is handshaked
@param callable $cb Callback
@callback $cb ( Connection $conn, boolean $success )
@return void | [
"Executes",
"the",
"given",
"callback",
"when",
"/",
"if",
"the",
"connection",
"is",
"handshaked"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L198-L210 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.onReady | public function onReady()
{
if (mb_orig_strlen($this->path) && !mb_orig_strlen($this->dbname)) {
$this->dbname = $this->path;
}
} | php | public function onReady()
{
if (mb_orig_strlen($this->path) && !mb_orig_strlen($this->dbname)) {
$this->dbname = $this->path;
}
} | [
"public",
"function",
"onReady",
"(",
")",
"{",
"if",
"(",
"mb_orig_strlen",
"(",
"$",
"this",
"->",
"path",
")",
"&&",
"!",
"mb_orig_strlen",
"(",
"$",
"this",
"->",
"dbname",
")",
")",
"{",
"$",
"this",
"->",
"dbname",
"=",
"$",
"this",
"->",
"pa... | 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/Clients/MySQL/Connection.php#L216-L221 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.sendPacket | public function sendPacket($packet)
{
//Daemon::log('Client --> Server: ' . Debug::exportBytes($packet) . "\n\n");
return $this->write(Binary::int2bytes(3, mb_orig_strlen($packet), true) . chr($this->seq++) . $packet);
} | php | public function sendPacket($packet)
{
//Daemon::log('Client --> Server: ' . Debug::exportBytes($packet) . "\n\n");
return $this->write(Binary::int2bytes(3, mb_orig_strlen($packet), true) . chr($this->seq++) . $packet);
} | [
"public",
"function",
"sendPacket",
"(",
"$",
"packet",
")",
"{",
"//Daemon::log('Client --> Server: ' . Debug::exportBytes($packet) . \"\\n\\n\");",
"return",
"$",
"this",
"->",
"write",
"(",
"Binary",
"::",
"int2bytes",
"(",
"3",
",",
"mb_orig_strlen",
"(",
"$",
"pa... | Sends a packet
@param string $packet Data
@return boolean Success | [
"Sends",
"a",
"packet"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L228-L232 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.buildLenEncodedBinary | public function buildLenEncodedBinary($s)
{
if ($s === null) {
return "\251";
}
$l = mb_orig_strlen($s);
if ($l <= 250) {
return chr($l) . $s;
}
if ($l <= 0xFFFF) {
return "\252" . Binary::int2bytes(2, true) . $s;
}
... | php | public function buildLenEncodedBinary($s)
{
if ($s === null) {
return "\251";
}
$l = mb_orig_strlen($s);
if ($l <= 250) {
return chr($l) . $s;
}
if ($l <= 0xFFFF) {
return "\252" . Binary::int2bytes(2, true) . $s;
}
... | [
"public",
"function",
"buildLenEncodedBinary",
"(",
"$",
"s",
")",
"{",
"if",
"(",
"$",
"s",
"===",
"null",
")",
"{",
"return",
"\"\\251\"",
";",
"}",
"$",
"l",
"=",
"mb_orig_strlen",
"(",
"$",
"s",
")",
";",
"if",
"(",
"$",
"l",
"<=",
"250",
")"... | Builds length-encoded binary string
@param string $s String
@return string Resulting binary string | [
"Builds",
"length",
"-",
"encoded",
"binary",
"string"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L239-L260 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.parseEncodedBinary | public function parseEncodedBinary()
{
$f = ord($this->read(1));
if ($f <= 250) {
return $f;
}
if ($f === 251) {
return null;
}
if ($f === 255) {
return false;
}
if ($f === 252) {
return Binary::bytes2int... | php | public function parseEncodedBinary()
{
$f = ord($this->read(1));
if ($f <= 250) {
return $f;
}
if ($f === 251) {
return null;
}
if ($f === 255) {
return false;
}
if ($f === 252) {
return Binary::bytes2int... | [
"public",
"function",
"parseEncodedBinary",
"(",
")",
"{",
"$",
"f",
"=",
"ord",
"(",
"$",
"this",
"->",
"read",
"(",
"1",
")",
")",
";",
"if",
"(",
"$",
"f",
"<=",
"250",
")",
"{",
"return",
"$",
"f",
";",
"}",
"if",
"(",
"$",
"f",
"===",
... | Parses length-encoded binary integer
@return integer Result | [
"Parses",
"length",
"-",
"encoded",
"binary",
"integer"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L266-L285 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.parseEncodedString | public function parseEncodedString()
{
$l = $this->parseEncodedBinary();
if (($l === null) || ($l === false)) {
return $l;
}
return $this->read($l);
} | php | public function parseEncodedString()
{
$l = $this->parseEncodedBinary();
if (($l === null) || ($l === false)) {
return $l;
}
return $this->read($l);
} | [
"public",
"function",
"parseEncodedString",
"(",
")",
"{",
"$",
"l",
"=",
"$",
"this",
"->",
"parseEncodedBinary",
"(",
")",
";",
"if",
"(",
"(",
"$",
"l",
"===",
"null",
")",
"||",
"(",
"$",
"l",
"===",
"false",
")",
")",
"{",
"return",
"$",
"l"... | Parse length-encoded string
@return integer Result | [
"Parse",
"length",
"-",
"encoded",
"string"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L291-L298 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.getAuthToken | public function getAuthToken($scramble, $password)
{
return sha1($scramble . sha1($hash1 = sha1($password, true), true), true) ^ $hash1;
} | php | public function getAuthToken($scramble, $password)
{
return sha1($scramble . sha1($hash1 = sha1($password, true), true), true) ^ $hash1;
} | [
"public",
"function",
"getAuthToken",
"(",
"$",
"scramble",
",",
"$",
"password",
")",
"{",
"return",
"sha1",
"(",
"$",
"scramble",
".",
"sha1",
"(",
"$",
"hash1",
"=",
"sha1",
"(",
"$",
"password",
",",
"true",
")",
",",
"true",
")",
",",
"true",
... | Generates auth. token
@param string $scramble Scramble string
@param string $password Password
@return string Result | [
"Generates",
"auth",
".",
"token"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L306-L309 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.auth | public function auth()
{
if ($this->phase !== self::PHASE_GOT_INIT) {
return;
}
$this->phase = self::PHASE_AUTH_SENT;
$this->onResponse->push(function ($conn, $result) {
if ($conn->onConnected) {
$conn->connected = true;
$conn->... | php | public function auth()
{
if ($this->phase !== self::PHASE_GOT_INIT) {
return;
}
$this->phase = self::PHASE_AUTH_SENT;
$this->onResponse->push(function ($conn, $result) {
if ($conn->onConnected) {
$conn->connected = true;
$conn->... | [
"public",
"function",
"auth",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"phase",
"!==",
"self",
"::",
"PHASE_GOT_INIT",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"phase",
"=",
"self",
"::",
"PHASE_AUTH_SENT",
";",
"$",
"this",
"->",
"onResp... | Sends auth. packet
@return void | [
"Sends",
"auth",
".",
"packet"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L315-L348 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.query | public function query($q, $cb = null)
{
if ($this->finished) {
throw new ConnectionFinished;
}
return $this->command(Pool::COM_QUERY, $q, $cb);
} | php | public function query($q, $cb = null)
{
if ($this->finished) {
throw new ConnectionFinished;
}
return $this->command(Pool::COM_QUERY, $q, $cb);
} | [
"public",
"function",
"query",
"(",
"$",
"q",
",",
"$",
"cb",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"finished",
")",
"{",
"throw",
"new",
"ConnectionFinished",
";",
"}",
"return",
"$",
"this",
"->",
"command",
"(",
"Pool",
"::",
"COM... | Sends SQL-query
@param string $q Query
@param callable $cb Optional. Callback called when response received
@callback $cb ( Connection $conn, boolean $success )
@return boolean Success | [
"Sends",
"SQL",
"-",
"query"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L357-L363 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.command | public function command($cmd, $q = '', $cb = null)
{
if ($this->phase !== self::PHASE_HANDSHAKED) {
return false;
}
$this->onResponse->push($cb);
$this->seq = 0;
$this->sendPacket(chr($cmd) . $q);
return true;
} | php | public function command($cmd, $q = '', $cb = null)
{
if ($this->phase !== self::PHASE_HANDSHAKED) {
return false;
}
$this->onResponse->push($cb);
$this->seq = 0;
$this->sendPacket(chr($cmd) . $q);
return true;
} | [
"public",
"function",
"command",
"(",
"$",
"cmd",
",",
"$",
"q",
"=",
"''",
",",
"$",
"cb",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"phase",
"!==",
"self",
"::",
"PHASE_HANDSHAKED",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",... | Sends arbitrary command
@param string $cmd Command
@param string $q Data
@param callable $cb Optional
@throws ConnectionFinished
@callback $cb ( Connection $conn, boolean $success )
@return boolean Success | [
"Sends",
"arbitrary",
"command"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L417-L428 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.selectDB | public function selectDB($name)
{
$this->dbname = $name;
if ($this->phase !== self::PHASE_GOT_INIT) {
return $this->query('USE `' . $name . '`');
}
return true;
} | php | public function selectDB($name)
{
$this->dbname = $name;
if ($this->phase !== self::PHASE_GOT_INIT) {
return $this->query('USE `' . $name . '`');
}
return true;
} | [
"public",
"function",
"selectDB",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"dbname",
"=",
"$",
"name",
";",
"if",
"(",
"$",
"this",
"->",
"phase",
"!==",
"self",
"::",
"PHASE_GOT_INIT",
")",
"{",
"return",
"$",
"this",
"->",
"query",
"(",
"'U... | Sets default database name
@param string $name Database name
@return boolean Success | [
"Sets",
"default",
"database",
"name"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L435-L444 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.onRead | public function onRead()
{
packet:
if ($this->state === self::STATE_STANDBY) {
if ($this->bev->input->length < 4) {
return;
}
$this->pctSize = Binary::bytes2int($this->read(3), true);
$this->setWatermark($this->pctSize, $this->pctSize);... | php | public function onRead()
{
packet:
if ($this->state === self::STATE_STANDBY) {
if ($this->bev->input->length < 4) {
return;
}
$this->pctSize = Binary::bytes2int($this->read(3), true);
$this->setWatermark($this->pctSize, $this->pctSize);... | [
"public",
"function",
"onRead",
"(",
")",
"{",
"packet",
":",
"if",
"(",
"$",
"this",
"->",
"state",
"===",
"self",
"::",
"STATE_STANDBY",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"bev",
"->",
"input",
"->",
"length",
"<",
"4",
")",
"{",
"return",
... | Called when new data received
@return void | [
"Called",
"when",
"new",
"data",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L450-L597 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.onResultDone | public function onResultDone()
{
$this->rsState = self::RS_STATE_HEADER;
$this->onResponse->executeOne($this, true);
$this->checkFree();
$this->resultRows = [];
$this->resultFields = [];
} | php | public function onResultDone()
{
$this->rsState = self::RS_STATE_HEADER;
$this->onResponse->executeOne($this, true);
$this->checkFree();
$this->resultRows = [];
$this->resultFields = [];
} | [
"public",
"function",
"onResultDone",
"(",
")",
"{",
"$",
"this",
"->",
"rsState",
"=",
"self",
"::",
"RS_STATE_HEADER",
";",
"$",
"this",
"->",
"onResponse",
"->",
"executeOne",
"(",
"$",
"this",
",",
"true",
")",
";",
"$",
"this",
"->",
"checkFree",
... | Called when the whole result received
@return void | [
"Called",
"when",
"the",
"whole",
"result",
"received"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L613-L620 |
kakserpom/phpdaemon | PHPDaemon/Clients/MySQL/Connection.php | Connection.onError | public function onError()
{
$this->rsState = self::RS_STATE_HEADER;
$this->onResponse->executeOne($this, false);
$this->checkFree();
$this->resultRows = [];
$this->resultFields = [];
if (($this->phase === self::PHASE_AUTH_SENT) || ($this->phase === self::PHASE_GOT_IN... | php | public function onError()
{
$this->rsState = self::RS_STATE_HEADER;
$this->onResponse->executeOne($this, false);
$this->checkFree();
$this->resultRows = [];
$this->resultFields = [];
if (($this->phase === self::PHASE_AUTH_SENT) || ($this->phase === self::PHASE_GOT_IN... | [
"public",
"function",
"onError",
"(",
")",
"{",
"$",
"this",
"->",
"rsState",
"=",
"self",
"::",
"RS_STATE_HEADER",
";",
"$",
"this",
"->",
"onResponse",
"->",
"executeOne",
"(",
"$",
"this",
",",
"false",
")",
";",
"$",
"this",
"->",
"checkFree",
"(",... | Called when error occured
@return void | [
"Called",
"when",
"error",
"occured"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Clients/MySQL/Connection.php#L626-L641 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.run | protected function run()
{
$this->lambdaCache = new CappedStorageHits;
$this->lambdaCache->setMaxCacheSize(Daemon::$config->lambdacachemaxsize->value);
$this->lambdaCache->setCapWindow(Daemon::$config->lambdacachecapwindow->value);
if (Daemon::$process instanceof Master) {
... | php | protected function run()
{
$this->lambdaCache = new CappedStorageHits;
$this->lambdaCache->setMaxCacheSize(Daemon::$config->lambdacachemaxsize->value);
$this->lambdaCache->setCapWindow(Daemon::$config->lambdacachecapwindow->value);
if (Daemon::$process instanceof Master) {
... | [
"protected",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"lambdaCache",
"=",
"new",
"CappedStorageHits",
";",
"$",
"this",
"->",
"lambdaCache",
"->",
"setMaxCacheSize",
"(",
"Daemon",
"::",
"$",
"config",
"->",
"lambdacachemaxsize",
"->",
"value",
"... | Runtime of Worker process.
@return void | [
"Runtime",
"of",
"Worker",
"process",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L118-L217 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.overrideNativeFuncs | protected function overrideNativeFuncs()
{
if (Daemon::supported(Daemon::SUPPORT_RUNKIT_INTERNAL_MODIFY)) {
function define($k, $v)
{
if (defined($k)) {
runkit_constant_redefine($k, $v);
} else {
runkit_constant_... | php | protected function overrideNativeFuncs()
{
if (Daemon::supported(Daemon::SUPPORT_RUNKIT_INTERNAL_MODIFY)) {
function define($k, $v)
{
if (defined($k)) {
runkit_constant_redefine($k, $v);
} else {
runkit_constant_... | [
"protected",
"function",
"overrideNativeFuncs",
"(",
")",
"{",
"if",
"(",
"Daemon",
"::",
"supported",
"(",
"Daemon",
"::",
"SUPPORT_RUNKIT_INTERNAL_MODIFY",
")",
")",
"{",
"function",
"define",
"(",
"$",
"k",
",",
"$",
"v",
")",
"{",
"if",
"(",
"defined",... | Overrides native PHP functions.
@return void | [
"Overrides",
"native",
"PHP",
"functions",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L234-L325 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.createFunction | public function createFunction($args, $body, $ttl = null)
{
$key = $args . "\x00" . $body;
if (($f = $this->lambdaCache->getValue($key)) !== null) {
return $f;
}
$f = eval('return function(' . $args . '){' . $body . '};');
if ($ttl === null && Daemon::$config->lam... | php | public function createFunction($args, $body, $ttl = null)
{
$key = $args . "\x00" . $body;
if (($f = $this->lambdaCache->getValue($key)) !== null) {
return $f;
}
$f = eval('return function(' . $args . '){' . $body . '};');
if ($ttl === null && Daemon::$config->lam... | [
"public",
"function",
"createFunction",
"(",
"$",
"args",
",",
"$",
"body",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"args",
".",
"\"\\x00\"",
".",
"$",
"body",
";",
"if",
"(",
"(",
"$",
"f",
"=",
"$",
"this",
"->",
"lambda... | Creates anonymous function (old-fashioned) like create_function()
@return void | [
"Creates",
"anonymous",
"function",
"(",
"old",
"-",
"fashioned",
")",
"like",
"create_function",
"()"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L331-L343 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.prepareSystemEnv | protected function prepareSystemEnv()
{
proc_nice(Daemon::$config->workerpriority->value);
register_shutdown_function(function () {
$this->shutdown(true);
});
$this->setTitle(
Daemon::$runName . ': worker process'
. (Daemon::$config->pidfile->val... | php | protected function prepareSystemEnv()
{
proc_nice(Daemon::$config->workerpriority->value);
register_shutdown_function(function () {
$this->shutdown(true);
});
$this->setTitle(
Daemon::$runName . ': worker process'
. (Daemon::$config->pidfile->val... | [
"protected",
"function",
"prepareSystemEnv",
"(",
")",
"{",
"proc_nice",
"(",
"Daemon",
"::",
"$",
"config",
"->",
"workerpriority",
"->",
"value",
")",
";",
"register_shutdown_function",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"shutdown",
"(",
"t... | Setup settings on start.
@return void | [
"Setup",
"settings",
"on",
"start",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L349-L414 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.breakMainLoopCheck | protected function breakMainLoopCheck()
{
$time = microtime(true);
if ($this->terminated || $this->breakMainLoop) {
EventLoop::$instance->stop();
return;
}
if ($this->shutdown) {
EventLoop::$instance->stop();
return;
}
... | php | protected function breakMainLoopCheck()
{
$time = microtime(true);
if ($this->terminated || $this->breakMainLoop) {
EventLoop::$instance->stop();
return;
}
if ($this->shutdown) {
EventLoop::$instance->stop();
return;
}
... | [
"protected",
"function",
"breakMainLoopCheck",
"(",
")",
"{",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"terminated",
"||",
"$",
"this",
"->",
"breakMainLoop",
")",
"{",
"EventLoop",
"::",
"$",
"instance",
"->",
... | Check if we should break main loop
@return void | [
"Check",
"if",
"we",
"should",
"break",
"main",
"loop"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L445-L491 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.gracefulRestart | public function gracefulRestart()
{
$this->graceful = true;
$this->reload = true;
Timer::add(function () {
EventLoop::$instance->stop();
}, $this->reloadDelay * 1e6);
$this->setState($this->state);
} | php | public function gracefulRestart()
{
$this->graceful = true;
$this->reload = true;
Timer::add(function () {
EventLoop::$instance->stop();
}, $this->reloadDelay * 1e6);
$this->setState($this->state);
} | [
"public",
"function",
"gracefulRestart",
"(",
")",
"{",
"$",
"this",
"->",
"graceful",
"=",
"true",
";",
"$",
"this",
"->",
"reload",
"=",
"true",
";",
"Timer",
"::",
"add",
"(",
"function",
"(",
")",
"{",
"EventLoop",
"::",
"$",
"instance",
"->",
"s... | Graceful restart
@return void | [
"Graceful",
"restart"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L497-L505 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.gracefulStop | public function gracefulStop()
{
$this->graceful = true;
Timer::add(function () {
EventLoop::$instance->stop();
}, $this->reloadDelay * 1e6);
$this->setState($this->state);
} | php | public function gracefulStop()
{
$this->graceful = true;
Timer::add(function () {
EventLoop::$instance->stop();
}, $this->reloadDelay * 1e6);
$this->setState($this->state);
} | [
"public",
"function",
"gracefulStop",
"(",
")",
"{",
"$",
"this",
"->",
"graceful",
"=",
"true",
";",
"Timer",
"::",
"add",
"(",
"function",
"(",
")",
"{",
"EventLoop",
"::",
"$",
"instance",
"->",
"stop",
"(",
")",
";",
"}",
",",
"$",
"this",
"->"... | Graceful stop
@return void | [
"Graceful",
"stop"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L511-L518 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.appInstancesReloadReady | protected function appInstancesReloadReady()
{
$ready = true;
foreach (Daemon::$appInstances as $k => $app) {
foreach ($app as $name => $appInstance) {
if (!$appInstance->handleStatus($this->graceful ? AppInstance::EVENT_GRACEFUL_SHUTDOWN : AppInstance::EVENT_SHUTDOWN)) ... | php | protected function appInstancesReloadReady()
{
$ready = true;
foreach (Daemon::$appInstances as $k => $app) {
foreach ($app as $name => $appInstance) {
if (!$appInstance->handleStatus($this->graceful ? AppInstance::EVENT_GRACEFUL_SHUTDOWN : AppInstance::EVENT_SHUTDOWN)) ... | [
"protected",
"function",
"appInstancesReloadReady",
"(",
")",
"{",
"$",
"ready",
"=",
"true",
";",
"foreach",
"(",
"Daemon",
"::",
"$",
"appInstances",
"as",
"$",
"k",
"=>",
"$",
"app",
")",
"{",
"foreach",
"(",
"$",
"app",
"as",
"$",
"name",
"=>",
"... | Asks the running applications the whether we can go to shutdown current (old) worker.
@return boolean - Ready? | [
"Asks",
"the",
"running",
"applications",
"the",
"whether",
"we",
"can",
"go",
"to",
"shutdown",
"current",
"(",
"old",
")",
"worker",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L524-L537 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.shutdown | protected function shutdown($hard = false)
{
$error = error_get_last();
if ($error) {
if ($error['type'] === E_ERROR) {
Daemon::log('W#' . $this->pid . ' crashed by error \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line']);
}
}
... | php | protected function shutdown($hard = false)
{
$error = error_get_last();
if ($error) {
if ($error['type'] === E_ERROR) {
Daemon::log('W#' . $this->pid . ' crashed by error \'' . $error['message'] . '\' at ' . $error['file'] . ':' . $error['line']);
}
}
... | [
"protected",
"function",
"shutdown",
"(",
"$",
"hard",
"=",
"false",
")",
"{",
"$",
"error",
"=",
"error_get_last",
"(",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"if",
"(",
"$",
"error",
"[",
"'type'",
"]",
"===",
"E_ERROR",
")",
"{",
"Daemon",... | Shutdown this worker
@param boolean Hard? If hard, we shouldn't wait for graceful shutdown of the running applications.
@return boolean|null Ready? | [
"Shutdown",
"this",
"worker"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L544-L597 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.setState | public function setState($int)
{
if (Daemon::$compatMode) {
return true;
}
if (!$this->id) {
return false;
}
if (Daemon::$config->logworkersetstate->value) {
$this->log('state is ' . Daemon::$wstateRev[$int]);
}
$this->sta... | php | public function setState($int)
{
if (Daemon::$compatMode) {
return true;
}
if (!$this->id) {
return false;
}
if (Daemon::$config->logworkersetstate->value) {
$this->log('state is ' . Daemon::$wstateRev[$int]);
}
$this->sta... | [
"public",
"function",
"setState",
"(",
"$",
"int",
")",
"{",
"if",
"(",
"Daemon",
"::",
"$",
"compatMode",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"id",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"Daemon",
... | Set current status of worker
@param int Constant
@return boolean Success. | [
"Set",
"current",
"status",
"of",
"worker"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L604-L624 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.sigterm | protected function sigterm()
{
if (Daemon::$config->logsignals->value) {
$this->log('caught SIGTERM.');
}
$this->graceful = false;
EventLoop::$instance->stop();
} | php | protected function sigterm()
{
if (Daemon::$config->logsignals->value) {
$this->log('caught SIGTERM.');
}
$this->graceful = false;
EventLoop::$instance->stop();
} | [
"protected",
"function",
"sigterm",
"(",
")",
"{",
"if",
"(",
"Daemon",
"::",
"$",
"config",
"->",
"logsignals",
"->",
"value",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'caught SIGTERM.'",
")",
";",
"}",
"$",
"this",
"->",
"graceful",
"=",
"false",
... | Handler of the SIGTERM (graceful shutdown) signal in worker process.
@return void | [
"Handler",
"of",
"the",
"SIGTERM",
"(",
"graceful",
"shutdown",
")",
"signal",
"in",
"worker",
"process",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L643-L651 |
kakserpom/phpdaemon | PHPDaemon/Thread/Worker.php | Worker.sighup | protected function sighup()
{
if (Daemon::$config->logsignals->value) {
$this->log('caught SIGHUP (reload config).');
}
if (isset(Daemon::$config->configfile->value)) {
Daemon::loadConfig(Daemon::$config->configfile->value);
}
$this->update = true;
... | php | protected function sighup()
{
if (Daemon::$config->logsignals->value) {
$this->log('caught SIGHUP (reload config).');
}
if (isset(Daemon::$config->configfile->value)) {
Daemon::loadConfig(Daemon::$config->configfile->value);
}
$this->update = true;
... | [
"protected",
"function",
"sighup",
"(",
")",
"{",
"if",
"(",
"Daemon",
"::",
"$",
"config",
"->",
"logsignals",
"->",
"value",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'caught SIGHUP (reload config).'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"Daemon",
... | Handler of the SIGHUP (reload config) signal in worker process.
@return void | [
"Handler",
"of",
"the",
"SIGHUP",
"(",
"reload",
"config",
")",
"signal",
"in",
"worker",
"process",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Worker.php#L670-L681 |
kakserpom/phpdaemon | PHPDaemon/Servers/Ident/Connection.php | Connection.onRead | protected function onRead()
{
while (($line = $this->readline()) !== null) {
$e = explode(' , ', $line);
if ((sizeof($e) !== 2) || !ctype_digit($e[0]) || !ctype_digit($e[1])) {
$this->writeln($line . ' : ERROR : INVALID-PORT');
$this->finish();
... | php | protected function onRead()
{
while (($line = $this->readline()) !== null) {
$e = explode(' , ', $line);
if ((sizeof($e) !== 2) || !ctype_digit($e[0]) || !ctype_digit($e[1])) {
$this->writeln($line . ' : ERROR : INVALID-PORT');
$this->finish();
... | [
"protected",
"function",
"onRead",
"(",
")",
"{",
"while",
"(",
"(",
"$",
"line",
"=",
"$",
"this",
"->",
"readline",
"(",
")",
")",
"!==",
"null",
")",
"{",
"$",
"e",
"=",
"explode",
"(",
"' , '",
",",
"$",
"line",
")",
";",
"if",
"(",
"(",
... | Called when new data received.
@return void | [
"Called",
"when",
"new",
"data",
"received",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Servers/Ident/Connection.php#L26-L43 |
kakserpom/phpdaemon | PHPDaemon/Thread/Master.php | Master.run | protected function run()
{
Daemon::$process = $this;
$this->prepareSystemEnv();
class_exists('Timer'); // ensure loading this class
gc_enable();
$this->callbacks = new StackCallbacks;
/*
* @todo This line must be commented according to current libevent bin... | php | protected function run()
{
Daemon::$process = $this;
$this->prepareSystemEnv();
class_exists('Timer'); // ensure loading this class
gc_enable();
$this->callbacks = new StackCallbacks;
/*
* @todo This line must be commented according to current libevent bin... | [
"protected",
"function",
"run",
"(",
")",
"{",
"Daemon",
"::",
"$",
"process",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"prepareSystemEnv",
"(",
")",
";",
"class_exists",
"(",
"'Timer'",
")",
";",
"// ensure loading this class",
"gc_enable",
"(",
")",
";"... | Runtime of Master process
@return void | [
"Runtime",
"of",
"Master",
"process"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L48-L120 |
kakserpom/phpdaemon | PHPDaemon/Thread/Master.php | Master.prepareSystemEnv | protected function prepareSystemEnv()
{
register_shutdown_function(function () {
if ($this->pid != posix_getpid()) {
return;
}
if ($this->shutdown === true) {
return;
}
$this->log('Unexcepted shutdown.');
... | php | protected function prepareSystemEnv()
{
register_shutdown_function(function () {
if ($this->pid != posix_getpid()) {
return;
}
if ($this->shutdown === true) {
return;
}
$this->log('Unexcepted shutdown.');
... | [
"protected",
"function",
"prepareSystemEnv",
"(",
")",
"{",
"register_shutdown_function",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pid",
"!=",
"posix_getpid",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"... | Setup settings on start.
@return void | [
"Setup",
"settings",
"on",
"start",
"."
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L185-L210 |
kakserpom/phpdaemon | PHPDaemon/Thread/Master.php | Master.reloadWorker | public function reloadWorker($id)
{
if (isset($this->workers->threads[$id])) {
if (!$this->workers->threads[$id]->reloaded) {
Daemon::$process->log('Spawning worker-replacer for reloaded worker #' . $id);
$this->spawnWorkers(1);
$this->workers->thr... | php | public function reloadWorker($id)
{
if (isset($this->workers->threads[$id])) {
if (!$this->workers->threads[$id]->reloaded) {
Daemon::$process->log('Spawning worker-replacer for reloaded worker #' . $id);
$this->spawnWorkers(1);
$this->workers->thr... | [
"public",
"function",
"reloadWorker",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"workers",
"->",
"threads",
"[",
"$",
"id",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"workers",
"->",
"threads",
"[",
"$",
... | Reload worker by internal id
@param integer - Id of worker
@param integer $id
@return void | [
"Reload",
"worker",
"by",
"internal",
"id"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L218-L227 |
kakserpom/phpdaemon | PHPDaemon/Thread/Master.php | Master.spawnWorkers | protected function spawnWorkers($n)
{
if (FileSystem::$supported) {
eio_event_loop();
}
$n = (int)$n;
for ($i = 0; $i < $n; ++$i) {
$thread = new Worker;
$this->workers->push($thread);
$this->callbacks->push(function ($self) use ($thre... | php | protected function spawnWorkers($n)
{
if (FileSystem::$supported) {
eio_event_loop();
}
$n = (int)$n;
for ($i = 0; $i < $n; ++$i) {
$thread = new Worker;
$this->workers->push($thread);
$this->callbacks->push(function ($self) use ($thre... | [
"protected",
"function",
"spawnWorkers",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"FileSystem",
"::",
"$",
"supported",
")",
"{",
"eio_event_loop",
"(",
")",
";",
"}",
"$",
"n",
"=",
"(",
"int",
")",
"$",
"n",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";... | Spawn new worker processes
@param $n - integer - number of workers to spawn
@return boolean - success | [
"Spawn",
"new",
"worker",
"processes"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L234-L263 |
kakserpom/phpdaemon | PHPDaemon/Thread/Master.php | Master.spawnIPCThread | protected function spawnIPCThread()
{
if (FileSystem::$supported) {
eio_event_loop();
}
$thread = new IPC;
$this->ipcthreads->push($thread);
$this->callbacks->push(function ($self) use ($thread) {
$thread->start();
$pid = $thread->getPid()... | php | protected function spawnIPCThread()
{
if (FileSystem::$supported) {
eio_event_loop();
}
$thread = new IPC;
$this->ipcthreads->push($thread);
$this->callbacks->push(function ($self) use ($thread) {
$thread->start();
$pid = $thread->getPid()... | [
"protected",
"function",
"spawnIPCThread",
"(",
")",
"{",
"if",
"(",
"FileSystem",
"::",
"$",
"supported",
")",
"{",
"eio_event_loop",
"(",
")",
";",
"}",
"$",
"thread",
"=",
"new",
"IPC",
";",
"$",
"this",
"->",
"ipcthreads",
"->",
"push",
"(",
"$",
... | Spawn IPC process
@param $n - integer - number of workers to spawn
@return boolean - success | [
"Spawn",
"IPC",
"process"
] | train | https://github.com/kakserpom/phpdaemon/blob/cfbe02e60e162853747ea9484c12f15341e56833/PHPDaemon/Thread/Master.php#L270-L292 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.