id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
234,100
|
xylemical/php-expressions
|
src/Evaluator.php
|
Evaluator.evaluate
|
public function evaluate(array $tokens, Context $context)
{
$results = new \SplStack();
// for each token in the postfix expression:
foreach ($tokens as $token) {
// if token is an operator:
if (is_null($token->getOperator())) {
throw new ExpressionException('Unexpected token.');
}
// Get the operator, as this works relative
$op = $token->getOperator();
// Check there are enough operands.
if ($op->getOperands() > $results->count()) {
throw new ExpressionException('Improperly constructed expression.', $op);
}
// Get the operands from the stack in reverse order.
$operands = [];
for ($i = 0; $i < $op->getOperands(); $i++) {
$operands[] = $results->pop();
}
$operands = array_reverse($operands);
// result ← evaluate token with operand_1 and operand_2
$result = $op->evaluate($operands, $context, $token);
// push result back onto the stack
$results->push($result);
}
// Check the expression has been properly constructed.
if ($results->count() !== 1) {
throw new ExpressionException('Improperly constructed expression.');
}
// Get the final result.
return $results->pop();
}
|
php
|
public function evaluate(array $tokens, Context $context)
{
$results = new \SplStack();
// for each token in the postfix expression:
foreach ($tokens as $token) {
// if token is an operator:
if (is_null($token->getOperator())) {
throw new ExpressionException('Unexpected token.');
}
// Get the operator, as this works relative
$op = $token->getOperator();
// Check there are enough operands.
if ($op->getOperands() > $results->count()) {
throw new ExpressionException('Improperly constructed expression.', $op);
}
// Get the operands from the stack in reverse order.
$operands = [];
for ($i = 0; $i < $op->getOperands(); $i++) {
$operands[] = $results->pop();
}
$operands = array_reverse($operands);
// result ← evaluate token with operand_1 and operand_2
$result = $op->evaluate($operands, $context, $token);
// push result back onto the stack
$results->push($result);
}
// Check the expression has been properly constructed.
if ($results->count() !== 1) {
throw new ExpressionException('Improperly constructed expression.');
}
// Get the final result.
return $results->pop();
}
|
[
"public",
"function",
"evaluate",
"(",
"array",
"$",
"tokens",
",",
"Context",
"$",
"context",
")",
"{",
"$",
"results",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"// for each token in the postfix expression:",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"token",
")",
"{",
"// if token is an operator:",
"if",
"(",
"is_null",
"(",
"$",
"token",
"->",
"getOperator",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ExpressionException",
"(",
"'Unexpected token.'",
")",
";",
"}",
"// Get the operator, as this works relative",
"$",
"op",
"=",
"$",
"token",
"->",
"getOperator",
"(",
")",
";",
"// Check there are enough operands.",
"if",
"(",
"$",
"op",
"->",
"getOperands",
"(",
")",
">",
"$",
"results",
"->",
"count",
"(",
")",
")",
"{",
"throw",
"new",
"ExpressionException",
"(",
"'Improperly constructed expression.'",
",",
"$",
"op",
")",
";",
"}",
"// Get the operands from the stack in reverse order.",
"$",
"operands",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"op",
"->",
"getOperands",
"(",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"operands",
"[",
"]",
"=",
"$",
"results",
"->",
"pop",
"(",
")",
";",
"}",
"$",
"operands",
"=",
"array_reverse",
"(",
"$",
"operands",
")",
";",
"// result ← evaluate token with operand_1 and operand_2",
"$",
"result",
"=",
"$",
"op",
"->",
"evaluate",
"(",
"$",
"operands",
",",
"$",
"context",
",",
"$",
"token",
")",
";",
"// push result back onto the stack",
"$",
"results",
"->",
"push",
"(",
"$",
"result",
")",
";",
"}",
"// Check the expression has been properly constructed.",
"if",
"(",
"$",
"results",
"->",
"count",
"(",
")",
"!==",
"1",
")",
"{",
"throw",
"new",
"ExpressionException",
"(",
"'Improperly constructed expression.'",
")",
";",
"}",
"// Get the final result.",
"return",
"$",
"results",
"->",
"pop",
"(",
")",
";",
"}"
] |
Evaluates the series of tokens in Reverse Polish Notation Format.
@param \Xylemical\Expressions\Token[] $tokens
@param \Xylemical\Expressions\Context $context
@return string
@throws \Xylemical\Expressions\ExpressionException
@see https://en.wikipedia.org/wiki/Reverse_Polish_notation
|
[
"Evaluates",
"the",
"series",
"of",
"tokens",
"in",
"Reverse",
"Polish",
"Notation",
"Format",
"."
] |
4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73
|
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Evaluator.php#L29-L69
|
234,101
|
jkphl/dom-factory
|
src/Domfactory/Domain/HtmlParser.php
|
HtmlParser.loadHTML
|
public function loadHTML($html)
{
$dom = new \DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($html, LIBXML_NOWARNING);
$errors = libxml_get_errors();
libxml_use_internal_errors(false);
// Run through all errors
/** @var \LibXMLError $error */
foreach ($errors as $error) {
throw new InvalidArgumentException(
sprintf(InvalidArgumentException::INVALID_HTML_STR, trim($error->message)),
InvalidArgumentException::INVALID_HTML
);
}
return $dom;
}
|
php
|
public function loadHTML($html)
{
$dom = new \DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($html, LIBXML_NOWARNING);
$errors = libxml_get_errors();
libxml_use_internal_errors(false);
// Run through all errors
/** @var \LibXMLError $error */
foreach ($errors as $error) {
throw new InvalidArgumentException(
sprintf(InvalidArgumentException::INVALID_HTML_STR, trim($error->message)),
InvalidArgumentException::INVALID_HTML
);
}
return $dom;
}
|
[
"public",
"function",
"loadHTML",
"(",
"$",
"html",
")",
"{",
"$",
"dom",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"dom",
"->",
"loadHTML",
"(",
"$",
"html",
",",
"LIBXML_NOWARNING",
")",
";",
"$",
"errors",
"=",
"libxml_get_errors",
"(",
")",
";",
"libxml_use_internal_errors",
"(",
"false",
")",
";",
"// Run through all errors",
"/** @var \\LibXMLError $error */",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"InvalidArgumentException",
"::",
"INVALID_HTML_STR",
",",
"trim",
"(",
"$",
"error",
"->",
"message",
")",
")",
",",
"InvalidArgumentException",
"::",
"INVALID_HTML",
")",
";",
"}",
"return",
"$",
"dom",
";",
"}"
] |
Load an HTML document
@param string $html HTML document
@return \DOMDocument DOM Document
@throws InvalidArgumentException If the HTML source is invalid
|
[
"Load",
"an",
"HTML",
"document"
] |
460595b73b214510b29f483d61358296d2825143
|
https://github.com/jkphl/dom-factory/blob/460595b73b214510b29f483d61358296d2825143/src/Domfactory/Domain/HtmlParser.php#L54-L73
|
234,102
|
budde377/Part
|
lib/model/updater/GitUpdaterImpl.php
|
GitUpdaterImpl.checkForUpdates
|
public function checkForUpdates($quick = false)
{
if (!$this->subModuleUpdater) {
$this->site->getVariables()->setValue("last_checked", time());
}
if ($this->canBeUpdated === null) {
$this->canBeUpdated = $this->site->getVariables()->getValue("can_be_updated") == 1;
}
if ($this->canBeUpdated) {
return true;
}
if($quick){
return false;
}
$this->exec("git fetch");
$updateAvailable = ($this->getRevision('HEAD') != $this->getRevision("origin/" . $this->currentBranch()) || array_reduce($this->subUpdaters, function ($result, Updater $input) {
return $result || $input->checkForUpdates();
}, false));
if ($this->canBeUpdated != $updateAvailable) {
$this->site->getVariables()->setValue("can_be_updated", $updateAvailable ? 1 : 0);
}
return $this->canBeUpdated = $updateAvailable;
}
|
php
|
public function checkForUpdates($quick = false)
{
if (!$this->subModuleUpdater) {
$this->site->getVariables()->setValue("last_checked", time());
}
if ($this->canBeUpdated === null) {
$this->canBeUpdated = $this->site->getVariables()->getValue("can_be_updated") == 1;
}
if ($this->canBeUpdated) {
return true;
}
if($quick){
return false;
}
$this->exec("git fetch");
$updateAvailable = ($this->getRevision('HEAD') != $this->getRevision("origin/" . $this->currentBranch()) || array_reduce($this->subUpdaters, function ($result, Updater $input) {
return $result || $input->checkForUpdates();
}, false));
if ($this->canBeUpdated != $updateAvailable) {
$this->site->getVariables()->setValue("can_be_updated", $updateAvailable ? 1 : 0);
}
return $this->canBeUpdated = $updateAvailable;
}
|
[
"public",
"function",
"checkForUpdates",
"(",
"$",
"quick",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"subModuleUpdater",
")",
"{",
"$",
"this",
"->",
"site",
"->",
"getVariables",
"(",
")",
"->",
"setValue",
"(",
"\"last_checked\"",
",",
"time",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"canBeUpdated",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"canBeUpdated",
"=",
"$",
"this",
"->",
"site",
"->",
"getVariables",
"(",
")",
"->",
"getValue",
"(",
"\"can_be_updated\"",
")",
"==",
"1",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"canBeUpdated",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"quick",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"exec",
"(",
"\"git fetch\"",
")",
";",
"$",
"updateAvailable",
"=",
"(",
"$",
"this",
"->",
"getRevision",
"(",
"'HEAD'",
")",
"!=",
"$",
"this",
"->",
"getRevision",
"(",
"\"origin/\"",
".",
"$",
"this",
"->",
"currentBranch",
"(",
")",
")",
"||",
"array_reduce",
"(",
"$",
"this",
"->",
"subUpdaters",
",",
"function",
"(",
"$",
"result",
",",
"Updater",
"$",
"input",
")",
"{",
"return",
"$",
"result",
"||",
"$",
"input",
"->",
"checkForUpdates",
"(",
")",
";",
"}",
",",
"false",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"canBeUpdated",
"!=",
"$",
"updateAvailable",
")",
"{",
"$",
"this",
"->",
"site",
"->",
"getVariables",
"(",
")",
"->",
"setValue",
"(",
"\"can_be_updated\"",
",",
"$",
"updateAvailable",
"?",
"1",
":",
"0",
")",
";",
"}",
"return",
"$",
"this",
"->",
"canBeUpdated",
"=",
"$",
"updateAvailable",
";",
"}"
] |
Will check if there exists a new update.
This must be blocking if using external program such as git.
@param bool $quick If TRUE will do a quick check. May contain false positives.
@return bool Return TRUE on existing new update, else FALSE
|
[
"Will",
"check",
"if",
"there",
"exists",
"a",
"new",
"update",
".",
"This",
"must",
"be",
"blocking",
"if",
"using",
"external",
"program",
"such",
"as",
"git",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/updater/GitUpdaterImpl.php#L48-L75
|
234,103
|
budde377/Part
|
lib/WebsiteImpl.php
|
WebsiteImpl.generateSite
|
public function generateSite()
{
$template = new TemplateImpl($this->backendContainer);
$pageStrategy = $this->backendContainer->getCurrentPageStrategyInstance();
$cacheControl = $this->backendContainer->getCacheControlInstance();
if ($this->config->isDebugMode()) {
$cacheControl->disableCache();
$template->setTwigDebug(true);
}
$currentPage = $pageStrategy->getCurrentPage();
$template->setTemplateFromConfig($currentPage->getTemplate(), "_main");
$ajaxServer = $this->backendContainer->getAJAXServerInstance();
$id = null;
if (($id = $this->GETValueOfIndexIfSetElseDefault('ajax')) !== null) {
$template->onlyInitialize();
$ajaxServer->registerHandlersFromConfig();
}
//Decide output mode
if ($id !== null) {
echo json_encode($ajaxServer->handleFromFunctionString($id, $this->GETValueOfIndexIfSetElseDefault('token')), $this->config->isDebugMode()?JSON_PRETTY_PRINT:0);
} else if (!$cacheControl->setUpCache()) {
echo $template->render();
}
}
|
php
|
public function generateSite()
{
$template = new TemplateImpl($this->backendContainer);
$pageStrategy = $this->backendContainer->getCurrentPageStrategyInstance();
$cacheControl = $this->backendContainer->getCacheControlInstance();
if ($this->config->isDebugMode()) {
$cacheControl->disableCache();
$template->setTwigDebug(true);
}
$currentPage = $pageStrategy->getCurrentPage();
$template->setTemplateFromConfig($currentPage->getTemplate(), "_main");
$ajaxServer = $this->backendContainer->getAJAXServerInstance();
$id = null;
if (($id = $this->GETValueOfIndexIfSetElseDefault('ajax')) !== null) {
$template->onlyInitialize();
$ajaxServer->registerHandlersFromConfig();
}
//Decide output mode
if ($id !== null) {
echo json_encode($ajaxServer->handleFromFunctionString($id, $this->GETValueOfIndexIfSetElseDefault('token')), $this->config->isDebugMode()?JSON_PRETTY_PRINT:0);
} else if (!$cacheControl->setUpCache()) {
echo $template->render();
}
}
|
[
"public",
"function",
"generateSite",
"(",
")",
"{",
"$",
"template",
"=",
"new",
"TemplateImpl",
"(",
"$",
"this",
"->",
"backendContainer",
")",
";",
"$",
"pageStrategy",
"=",
"$",
"this",
"->",
"backendContainer",
"->",
"getCurrentPageStrategyInstance",
"(",
")",
";",
"$",
"cacheControl",
"=",
"$",
"this",
"->",
"backendContainer",
"->",
"getCacheControlInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"isDebugMode",
"(",
")",
")",
"{",
"$",
"cacheControl",
"->",
"disableCache",
"(",
")",
";",
"$",
"template",
"->",
"setTwigDebug",
"(",
"true",
")",
";",
"}",
"$",
"currentPage",
"=",
"$",
"pageStrategy",
"->",
"getCurrentPage",
"(",
")",
";",
"$",
"template",
"->",
"setTemplateFromConfig",
"(",
"$",
"currentPage",
"->",
"getTemplate",
"(",
")",
",",
"\"_main\"",
")",
";",
"$",
"ajaxServer",
"=",
"$",
"this",
"->",
"backendContainer",
"->",
"getAJAXServerInstance",
"(",
")",
";",
"$",
"id",
"=",
"null",
";",
"if",
"(",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"GETValueOfIndexIfSetElseDefault",
"(",
"'ajax'",
")",
")",
"!==",
"null",
")",
"{",
"$",
"template",
"->",
"onlyInitialize",
"(",
")",
";",
"$",
"ajaxServer",
"->",
"registerHandlersFromConfig",
"(",
")",
";",
"}",
"//Decide output mode",
"if",
"(",
"$",
"id",
"!==",
"null",
")",
"{",
"echo",
"json_encode",
"(",
"$",
"ajaxServer",
"->",
"handleFromFunctionString",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"GETValueOfIndexIfSetElseDefault",
"(",
"'token'",
")",
")",
",",
"$",
"this",
"->",
"config",
"->",
"isDebugMode",
"(",
")",
"?",
"JSON_PRETTY_PRINT",
":",
"0",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"cacheControl",
"->",
"setUpCache",
"(",
")",
")",
"{",
"echo",
"$",
"template",
"->",
"render",
"(",
")",
";",
"}",
"}"
] |
Generate site and output it in browser.
|
[
"Generate",
"site",
"and",
"output",
"it",
"in",
"browser",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/WebsiteImpl.php#L35-L67
|
234,104
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
|
UninterpretedOptionMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new UninterpretedOption();
case 1:
return new UninterpretedOption(func_get_arg(0));
case 2:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1));
case 3:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new UninterpretedOption();
case 1:
return new UninterpretedOption(func_get_arg(0));
case 2:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1));
case 3:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new UninterpretedOption(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"UninterpretedOption",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"UninterpretedOption",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\UninterpretedOption
@throws \InvalidArgumentException
@return UninterpretedOption
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"UninterpretedOption"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L64-L88
|
234,105
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
|
UninterpretedOptionMeta.reset
|
public static function reset($object)
{
if (!($object instanceof UninterpretedOption)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\UninterpretedOption.');
}
$object->name = NULL;
$object->identifierValue = NULL;
$object->positiveIntValue = NULL;
$object->negativeIntValue = NULL;
$object->doubleValue = NULL;
$object->stringValue = NULL;
$object->aggregateValue = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof UninterpretedOption)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\UninterpretedOption.');
}
$object->name = NULL;
$object->identifierValue = NULL;
$object->positiveIntValue = NULL;
$object->negativeIntValue = NULL;
$object->doubleValue = NULL;
$object->stringValue = NULL;
$object->aggregateValue = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"UninterpretedOption",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\UninterpretedOption.'",
")",
";",
"}",
"$",
"object",
"->",
"name",
"=",
"NULL",
";",
"$",
"object",
"->",
"identifierValue",
"=",
"NULL",
";",
"$",
"object",
"->",
"positiveIntValue",
"=",
"NULL",
";",
"$",
"object",
"->",
"negativeIntValue",
"=",
"NULL",
";",
"$",
"object",
"->",
"doubleValue",
"=",
"NULL",
";",
"$",
"object",
"->",
"stringValue",
"=",
"NULL",
";",
"$",
"object",
"->",
"aggregateValue",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\UninterpretedOption to default values
@param UninterpretedOption $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"UninterpretedOption",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L101-L113
|
234,106
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
|
UninterpretedOptionMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $v0) {
NamePartMeta::hash($v0, $ctx);
}
}
if (isset($object->identifierValue)) {
hash_update($ctx, 'identifierValue');
hash_update($ctx, (string)$object->identifierValue);
}
if (isset($object->positiveIntValue)) {
hash_update($ctx, 'positiveIntValue');
hash_update($ctx, (string)$object->positiveIntValue);
}
if (isset($object->negativeIntValue)) {
hash_update($ctx, 'negativeIntValue');
hash_update($ctx, (string)$object->negativeIntValue);
}
if (isset($object->doubleValue)) {
hash_update($ctx, 'doubleValue');
hash_update($ctx, (string)$object->doubleValue);
}
if (isset($object->stringValue)) {
hash_update($ctx, 'stringValue');
hash_update($ctx, (string)$object->stringValue);
}
if (isset($object->aggregateValue)) {
hash_update($ctx, 'aggregateValue');
hash_update($ctx, (string)$object->aggregateValue);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
php
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $v0) {
NamePartMeta::hash($v0, $ctx);
}
}
if (isset($object->identifierValue)) {
hash_update($ctx, 'identifierValue');
hash_update($ctx, (string)$object->identifierValue);
}
if (isset($object->positiveIntValue)) {
hash_update($ctx, 'positiveIntValue');
hash_update($ctx, (string)$object->positiveIntValue);
}
if (isset($object->negativeIntValue)) {
hash_update($ctx, 'negativeIntValue');
hash_update($ctx, (string)$object->negativeIntValue);
}
if (isset($object->doubleValue)) {
hash_update($ctx, 'doubleValue');
hash_update($ctx, (string)$object->doubleValue);
}
if (isset($object->stringValue)) {
hash_update($ctx, 'stringValue');
hash_update($ctx, (string)$object->stringValue);
}
if (isset($object->aggregateValue)) {
hash_update($ctx, 'aggregateValue');
hash_update($ctx, (string)$object->aggregateValue);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrCtx",
")",
";",
"}",
"else",
"{",
"$",
"ctx",
"=",
"$",
"algoOrCtx",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"name",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'name'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"name",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"name",
":",
"(",
"array",
")",
"$",
"object",
"->",
"name",
"as",
"$",
"v0",
")",
"{",
"NamePartMeta",
"::",
"hash",
"(",
"$",
"v0",
",",
"$",
"ctx",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"identifierValue",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'identifierValue'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"identifierValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"positiveIntValue",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'positiveIntValue'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"positiveIntValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"negativeIntValue",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'negativeIntValue'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"negativeIntValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"doubleValue",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'doubleValue'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"doubleValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"stringValue",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'stringValue'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"stringValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"aggregateValue",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'aggregateValue'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"aggregateValue",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\UninterpretedOption
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"UninterpretedOption"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L125-L175
|
234,107
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php
|
UninterpretedOptionMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->name) && ($filter === null || isset($filter['name']))) {
foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $k => $v) {
$output .= "\x12";
$buffer = NamePartMeta::toProtobuf($v, $filter === null ? null : $filter['name']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
if (isset($object->identifierValue) && ($filter === null || isset($filter['identifierValue']))) {
$output .= "\x1a";
$output .= Binary::encodeVarint(strlen($object->identifierValue));
$output .= $object->identifierValue;
}
if (isset($object->positiveIntValue) && ($filter === null || isset($filter['positiveIntValue']))) {
$output .= "\x20";
$output .= Binary::encodeVarint($object->positiveIntValue);
}
if (isset($object->negativeIntValue) && ($filter === null || isset($filter['negativeIntValue']))) {
$output .= "\x28";
$output .= Binary::encodeVarint($object->negativeIntValue);
}
if (isset($object->doubleValue) && ($filter === null || isset($filter['doubleValue']))) {
$output .= "\x31";
$output .= Binary::encodeDouble($object->doubleValue);
}
if (isset($object->stringValue) && ($filter === null || isset($filter['stringValue']))) {
$output .= "\x3a";
$output .= Binary::encodeVarint(strlen($object->stringValue));
$output .= $object->stringValue;
}
if (isset($object->aggregateValue) && ($filter === null || isset($filter['aggregateValue']))) {
$output .= "\x42";
$output .= Binary::encodeVarint(strlen($object->aggregateValue));
$output .= $object->aggregateValue;
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->name) && ($filter === null || isset($filter['name']))) {
foreach ($object->name instanceof \Traversable ? $object->name : (array)$object->name as $k => $v) {
$output .= "\x12";
$buffer = NamePartMeta::toProtobuf($v, $filter === null ? null : $filter['name']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
if (isset($object->identifierValue) && ($filter === null || isset($filter['identifierValue']))) {
$output .= "\x1a";
$output .= Binary::encodeVarint(strlen($object->identifierValue));
$output .= $object->identifierValue;
}
if (isset($object->positiveIntValue) && ($filter === null || isset($filter['positiveIntValue']))) {
$output .= "\x20";
$output .= Binary::encodeVarint($object->positiveIntValue);
}
if (isset($object->negativeIntValue) && ($filter === null || isset($filter['negativeIntValue']))) {
$output .= "\x28";
$output .= Binary::encodeVarint($object->negativeIntValue);
}
if (isset($object->doubleValue) && ($filter === null || isset($filter['doubleValue']))) {
$output .= "\x31";
$output .= Binary::encodeDouble($object->doubleValue);
}
if (isset($object->stringValue) && ($filter === null || isset($filter['stringValue']))) {
$output .= "\x3a";
$output .= Binary::encodeVarint(strlen($object->stringValue));
$output .= $object->stringValue;
}
if (isset($object->aggregateValue) && ($filter === null || isset($filter['aggregateValue']))) {
$output .= "\x42";
$output .= Binary::encodeVarint(strlen($object->aggregateValue));
$output .= $object->aggregateValue;
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"name",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'name'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"name",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"name",
":",
"(",
"array",
")",
"$",
"object",
"->",
"name",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\x12\"",
";",
"$",
"buffer",
"=",
"NamePartMeta",
"::",
"toProtobuf",
"(",
"$",
"v",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'name'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"identifierValue",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'identifierValue'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x1a\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"identifierValue",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"identifierValue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"positiveIntValue",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'positiveIntValue'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x20\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"object",
"->",
"positiveIntValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"negativeIntValue",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'negativeIntValue'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x28\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"object",
"->",
"negativeIntValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"doubleValue",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'doubleValue'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x31\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeDouble",
"(",
"$",
"object",
"->",
"doubleValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"stringValue",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'stringValue'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x3a\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"stringValue",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"stringValue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"aggregateValue",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'aggregateValue'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x42\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"aggregateValue",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"aggregateValue",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\UninterpretedOption to Protocol Buffers message.
@param UninterpretedOption $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"UninterpretedOption",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/UninterpretedOptionMeta.php#L326-L373
|
234,108
|
kaliop-uk/kueueingbundle
|
Service/EventDispatcher.php
|
EventDispatcher.addListenerService
|
public function addListenerService($eventName, $callback, $priority = 0, $queueName = null)
{
parent::addListenerService($eventName, $callback, $priority);
$this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority, $queueName);
}
|
php
|
public function addListenerService($eventName, $callback, $priority = 0, $queueName = null)
{
parent::addListenerService($eventName, $callback, $priority);
$this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority, $queueName);
}
|
[
"public",
"function",
"addListenerService",
"(",
"$",
"eventName",
",",
"$",
"callback",
",",
"$",
"priority",
"=",
"0",
",",
"$",
"queueName",
"=",
"null",
")",
"{",
"parent",
"::",
"addListenerService",
"(",
"$",
"eventName",
",",
"$",
"callback",
",",
"$",
"priority",
")",
";",
"$",
"this",
"->",
"listenerIds",
"[",
"$",
"eventName",
"]",
"[",
"]",
"=",
"array",
"(",
"$",
"callback",
"[",
"0",
"]",
",",
"$",
"callback",
"[",
"1",
"]",
",",
"$",
"priority",
",",
"$",
"queueName",
")",
";",
"}"
] |
Adds a service as event listener.
@param string $eventName Event for which the listener is added
@param array $callback The service ID of the listener service & the method
name that has to be called
@param int $priority The higher this value, the earlier an event listener
will be triggered in the chain.
Defaults to 0.
@param string $queueName Use null to subscribe to all queues
@throws \InvalidArgumentException
|
[
"Adds",
"a",
"service",
"as",
"event",
"listener",
"."
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/EventDispatcher.php#L36-L41
|
234,109
|
kaliop-uk/kueueingbundle
|
Service/EventDispatcher.php
|
EventDispatcher.doDispatch
|
protected function doDispatch($listeners, $eventName, Event $event)
{
foreach ($listeners as $id => $listener) {
if (isset($this->listeners[$eventName])) {
foreach($this->listeners[$eventName] as $key => $val) {
// services
if ($val[0] === $listener[0]) {
// queue names
if ($val[1] != null && $val[1] != $event->getMessage()->getQueueName()) {
continue 2;
}
break;
}
}
}
call_user_func($listener, $event, $eventName, $this);
if ($event->isPropagationStopped()) {
break;
}
}
}
|
php
|
protected function doDispatch($listeners, $eventName, Event $event)
{
foreach ($listeners as $id => $listener) {
if (isset($this->listeners[$eventName])) {
foreach($this->listeners[$eventName] as $key => $val) {
// services
if ($val[0] === $listener[0]) {
// queue names
if ($val[1] != null && $val[1] != $event->getMessage()->getQueueName()) {
continue 2;
}
break;
}
}
}
call_user_func($listener, $event, $eventName, $this);
if ($event->isPropagationStopped()) {
break;
}
}
}
|
[
"protected",
"function",
"doDispatch",
"(",
"$",
"listeners",
",",
"$",
"eventName",
",",
"Event",
"$",
"event",
")",
"{",
"foreach",
"(",
"$",
"listeners",
"as",
"$",
"id",
"=>",
"$",
"listener",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"// services",
"if",
"(",
"$",
"val",
"[",
"0",
"]",
"===",
"$",
"listener",
"[",
"0",
"]",
")",
"{",
"// queue names",
"if",
"(",
"$",
"val",
"[",
"1",
"]",
"!=",
"null",
"&&",
"$",
"val",
"[",
"1",
"]",
"!=",
"$",
"event",
"->",
"getMessage",
"(",
")",
"->",
"getQueueName",
"(",
")",
")",
"{",
"continue",
"2",
";",
"}",
"break",
";",
"}",
"}",
"}",
"call_user_func",
"(",
"$",
"listener",
",",
"$",
"event",
",",
"$",
"eventName",
",",
"$",
"this",
")",
";",
"if",
"(",
"$",
"event",
"->",
"isPropagationStopped",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"}"
] |
Triggers the listeners of an event UNLESS they are only listening to a different queue.
Since we get an array of listener instances which are not tied any more to the service key, we have to do a slow
loop to find if any listener was tied to a particular queue...
@param callable[] $listeners The event listeners.
@param string $eventName The name of the event to dispatch.
@param Event $event The event object to pass to the event handlers/listeners.
|
[
"Triggers",
"the",
"listeners",
"of",
"an",
"event",
"UNLESS",
"they",
"are",
"only",
"listening",
"to",
"a",
"different",
"queue",
".",
"Since",
"we",
"get",
"an",
"array",
"of",
"listener",
"instances",
"which",
"are",
"not",
"tied",
"any",
"more",
"to",
"the",
"service",
"key",
"we",
"have",
"to",
"do",
"a",
"slow",
"loop",
"to",
"find",
"if",
"any",
"listener",
"was",
"tied",
"to",
"a",
"particular",
"queue",
"..."
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/EventDispatcher.php#L52-L74
|
234,110
|
kaliop-uk/kueueingbundle
|
Service/EventDispatcher.php
|
EventDispatcher.lazyLoad
|
protected function lazyLoad($eventName)
{
parent::lazyLoad($eventName);
if (isset($this->listenerIds[$eventName])) {
foreach ($this->listenerIds[$eventName] as $args) {
list($serviceId, $method, $priority, $queueName) = $args;
if ($queueName != null) {
$listener = $this->container->get($serviceId);
$key = $serviceId.'.'.$method;
$this->listeners[$eventName][$key] = array($listener, $queueName);
}
}
}
}
|
php
|
protected function lazyLoad($eventName)
{
parent::lazyLoad($eventName);
if (isset($this->listenerIds[$eventName])) {
foreach ($this->listenerIds[$eventName] as $args) {
list($serviceId, $method, $priority, $queueName) = $args;
if ($queueName != null) {
$listener = $this->container->get($serviceId);
$key = $serviceId.'.'.$method;
$this->listeners[$eventName][$key] = array($listener, $queueName);
}
}
}
}
|
[
"protected",
"function",
"lazyLoad",
"(",
"$",
"eventName",
")",
"{",
"parent",
"::",
"lazyLoad",
"(",
"$",
"eventName",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"listenerIds",
"[",
"$",
"eventName",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listenerIds",
"[",
"$",
"eventName",
"]",
"as",
"$",
"args",
")",
"{",
"list",
"(",
"$",
"serviceId",
",",
"$",
"method",
",",
"$",
"priority",
",",
"$",
"queueName",
")",
"=",
"$",
"args",
";",
"if",
"(",
"$",
"queueName",
"!=",
"null",
")",
"{",
"$",
"listener",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceId",
")",
";",
"$",
"key",
"=",
"$",
"serviceId",
".",
"'.'",
".",
"$",
"method",
";",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
"$",
"listener",
",",
"$",
"queueName",
")",
";",
"}",
"}",
"}",
"}"
] |
When loading listener services, store in a separate index the queue to which service is limited
@param string $eventName
|
[
"When",
"loading",
"listener",
"services",
"store",
"in",
"a",
"separate",
"index",
"the",
"queue",
"to",
"which",
"service",
"is",
"limited"
] |
6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987
|
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/EventDispatcher.php#L80-L94
|
234,111
|
nymo/silex-twig-breadcrumb-extension
|
src/nymo/Twig/Extension/BreadCrumbExtension.php
|
BreadCrumbExtension.renderBreadCrumbs
|
public function renderBreadCrumbs(): string
{
$translator = isset($this->app['translator']) ? true : false;
return $this->app['twig']->render(
'breadcrumbs.html.twig',
[
'breadcrumbs' => $this->app['breadcrumbs']->getItems(),
'separator' => $this->separator,
'translator' => $translator
]
);
}
|
php
|
public function renderBreadCrumbs(): string
{
$translator = isset($this->app['translator']) ? true : false;
return $this->app['twig']->render(
'breadcrumbs.html.twig',
[
'breadcrumbs' => $this->app['breadcrumbs']->getItems(),
'separator' => $this->separator,
'translator' => $translator
]
);
}
|
[
"public",
"function",
"renderBreadCrumbs",
"(",
")",
":",
"string",
"{",
"$",
"translator",
"=",
"isset",
"(",
"$",
"this",
"->",
"app",
"[",
"'translator'",
"]",
")",
"?",
"true",
":",
"false",
";",
"return",
"$",
"this",
"->",
"app",
"[",
"'twig'",
"]",
"->",
"render",
"(",
"'breadcrumbs.html.twig'",
",",
"[",
"'breadcrumbs'",
"=>",
"$",
"this",
"->",
"app",
"[",
"'breadcrumbs'",
"]",
"->",
"getItems",
"(",
")",
",",
"'separator'",
"=>",
"$",
"this",
"->",
"separator",
",",
"'translator'",
"=>",
"$",
"translator",
"]",
")",
";",
"}"
] |
Returns the rendered breadcrumb template
@return string
|
[
"Returns",
"the",
"rendered",
"breadcrumb",
"template"
] |
9ddf46710f40ba06b47427d01e5b8c7e6c1d0b56
|
https://github.com/nymo/silex-twig-breadcrumb-extension/blob/9ddf46710f40ba06b47427d01e5b8c7e6c1d0b56/src/nymo/Twig/Extension/BreadCrumbExtension.php#L64-L76
|
234,112
|
comodojo/xmlrpc
|
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
|
XmlrpcDecoder.decodeResponse
|
public function decodeResponse($response) {
$xml_data = simplexml_load_string($response);
if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC response");
$data = array();
try {
if ( isset($xml_data->fault) ) {
$this->is_fault = true;
array_push($data, $this->decodeValue($xml_data->fault->value));
} else if ( isset($xml_data->params) ) {
foreach ( $xml_data->params->param as $param ) array_push($data, $this->decodeValue($param->value));
} else throw new XmlrpcException("Uncomprensible response");
} catch (XmlrpcException $xe) {
throw $xe;
}
return isset($data[0]) ? $data[0] : $data;
}
|
php
|
public function decodeResponse($response) {
$xml_data = simplexml_load_string($response);
if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC response");
$data = array();
try {
if ( isset($xml_data->fault) ) {
$this->is_fault = true;
array_push($data, $this->decodeValue($xml_data->fault->value));
} else if ( isset($xml_data->params) ) {
foreach ( $xml_data->params->param as $param ) array_push($data, $this->decodeValue($param->value));
} else throw new XmlrpcException("Uncomprensible response");
} catch (XmlrpcException $xe) {
throw $xe;
}
return isset($data[0]) ? $data[0] : $data;
}
|
[
"public",
"function",
"decodeResponse",
"(",
"$",
"response",
")",
"{",
"$",
"xml_data",
"=",
"simplexml_load_string",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"xml_data",
"===",
"false",
")",
"throw",
"new",
"XmlrpcException",
"(",
"\"Not a valid XMLRPC response\"",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"try",
"{",
"if",
"(",
"isset",
"(",
"$",
"xml_data",
"->",
"fault",
")",
")",
"{",
"$",
"this",
"->",
"is_fault",
"=",
"true",
";",
"array_push",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"decodeValue",
"(",
"$",
"xml_data",
"->",
"fault",
"->",
"value",
")",
")",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"xml_data",
"->",
"params",
")",
")",
"{",
"foreach",
"(",
"$",
"xml_data",
"->",
"params",
"->",
"param",
"as",
"$",
"param",
")",
"array_push",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"decodeValue",
"(",
"$",
"param",
"->",
"value",
")",
")",
";",
"}",
"else",
"throw",
"new",
"XmlrpcException",
"(",
"\"Uncomprensible response\"",
")",
";",
"}",
"catch",
"(",
"XmlrpcException",
"$",
"xe",
")",
"{",
"throw",
"$",
"xe",
";",
"}",
"return",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"?",
"$",
"data",
"[",
"0",
"]",
":",
"$",
"data",
";",
"}"
] |
Decode an xmlrpc response
@param string $response
@return array
@throws \Comodojo\Exception\XmlrpcException
|
[
"Decode",
"an",
"xmlrpc",
"response"
] |
2257167ce94ab657608c2062d485896f95f935a3
|
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L43-L73
|
234,113
|
comodojo/xmlrpc
|
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
|
XmlrpcDecoder.decodeCall
|
public function decodeCall($request) {
$xml_data = simplexml_load_string($request);
if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC call");
if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible request");
$method_name = $this->decodeString($xml_data->methodName[0]);
if ( $method_name == "system.multicall" ) {
try {
$data = $this->multicallDecode($xml_data);
} catch (XmlrpcException $xe) {
throw $xe;
}
} else {
$parsed = array();
try {
foreach ( $xml_data->params->param as $param ) $parsed[] = $this->decodeValue($param->value);
} catch (XmlrpcException $xe) {
throw $xe;
}
$data = array($method_name, $parsed);
}
return $data;
}
|
php
|
public function decodeCall($request) {
$xml_data = simplexml_load_string($request);
if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC call");
if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible request");
$method_name = $this->decodeString($xml_data->methodName[0]);
if ( $method_name == "system.multicall" ) {
try {
$data = $this->multicallDecode($xml_data);
} catch (XmlrpcException $xe) {
throw $xe;
}
} else {
$parsed = array();
try {
foreach ( $xml_data->params->param as $param ) $parsed[] = $this->decodeValue($param->value);
} catch (XmlrpcException $xe) {
throw $xe;
}
$data = array($method_name, $parsed);
}
return $data;
}
|
[
"public",
"function",
"decodeCall",
"(",
"$",
"request",
")",
"{",
"$",
"xml_data",
"=",
"simplexml_load_string",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"xml_data",
"===",
"false",
")",
"throw",
"new",
"XmlrpcException",
"(",
"\"Not a valid XMLRPC call\"",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"xml_data",
"->",
"methodName",
")",
")",
"throw",
"new",
"XmlrpcException",
"(",
"\"Uncomprensible request\"",
")",
";",
"$",
"method_name",
"=",
"$",
"this",
"->",
"decodeString",
"(",
"$",
"xml_data",
"->",
"methodName",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"method_name",
"==",
"\"system.multicall\"",
")",
"{",
"try",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"multicallDecode",
"(",
"$",
"xml_data",
")",
";",
"}",
"catch",
"(",
"XmlrpcException",
"$",
"xe",
")",
"{",
"throw",
"$",
"xe",
";",
"}",
"}",
"else",
"{",
"$",
"parsed",
"=",
"array",
"(",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"xml_data",
"->",
"params",
"->",
"param",
"as",
"$",
"param",
")",
"$",
"parsed",
"[",
"]",
"=",
"$",
"this",
"->",
"decodeValue",
"(",
"$",
"param",
"->",
"value",
")",
";",
"}",
"catch",
"(",
"XmlrpcException",
"$",
"xe",
")",
"{",
"throw",
"$",
"xe",
";",
"}",
"$",
"data",
"=",
"array",
"(",
"$",
"method_name",
",",
"$",
"parsed",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Decode an xmlrpc request.
Can handle single or multicall requests and return an array of: [method], [data]
WARNING: in case of multicall, it will not throw any exception for an invalid
boxcarred request; a null value will be placed instead of array(method,params).
@param string $request
@return array
@throws \Comodojo\Exception\XmlrpcException
|
[
"Decode",
"an",
"xmlrpc",
"request",
"."
] |
2257167ce94ab657608c2062d485896f95f935a3
|
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L95-L137
|
234,114
|
comodojo/xmlrpc
|
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
|
XmlrpcDecoder.decodeMulticall
|
public function decodeMulticall($request) {
$xml_data = simplexml_load_string($request);
if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC multicall");
if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible multicall request");
if ( $this->decodeString($xml_data->methodName[0]) != "system.multicall" ) throw new XmlrpcException("Invalid multicall request");
try {
$data = $this->multicallDecode($xml_data);
} catch (XmlrpcException $xe) {
throw $xe;
}
return $data;
}
|
php
|
public function decodeMulticall($request) {
$xml_data = simplexml_load_string($request);
if ( $xml_data === false ) throw new XmlrpcException("Not a valid XMLRPC multicall");
if ( !isset($xml_data->methodName) ) throw new XmlrpcException("Uncomprensible multicall request");
if ( $this->decodeString($xml_data->methodName[0]) != "system.multicall" ) throw new XmlrpcException("Invalid multicall request");
try {
$data = $this->multicallDecode($xml_data);
} catch (XmlrpcException $xe) {
throw $xe;
}
return $data;
}
|
[
"public",
"function",
"decodeMulticall",
"(",
"$",
"request",
")",
"{",
"$",
"xml_data",
"=",
"simplexml_load_string",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"xml_data",
"===",
"false",
")",
"throw",
"new",
"XmlrpcException",
"(",
"\"Not a valid XMLRPC multicall\"",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"xml_data",
"->",
"methodName",
")",
")",
"throw",
"new",
"XmlrpcException",
"(",
"\"Uncomprensible multicall request\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"decodeString",
"(",
"$",
"xml_data",
"->",
"methodName",
"[",
"0",
"]",
")",
"!=",
"\"system.multicall\"",
")",
"throw",
"new",
"XmlrpcException",
"(",
"\"Invalid multicall request\"",
")",
";",
"try",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"multicallDecode",
"(",
"$",
"xml_data",
")",
";",
"}",
"catch",
"(",
"XmlrpcException",
"$",
"xe",
")",
"{",
"throw",
"$",
"xe",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Decode an xmlrpc multicall
@param string $request
@return array
@throws \Comodojo\Exception\XmlrpcException
|
[
"Decode",
"an",
"xmlrpc",
"multicall"
] |
2257167ce94ab657608c2062d485896f95f935a3
|
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L148-L170
|
234,115
|
comodojo/xmlrpc
|
src/Comodojo/Xmlrpc/XmlrpcDecoder.php
|
XmlrpcDecoder.decodeValue
|
private function decodeValue($value) {
$children = $value->children();
if ( count($children) != 1 ) throw new XmlrpcException("Cannot decode value: invalid value element");
$child = $children[0];
$child_type = $child->getName();
switch ( $child_type ) {
case "i4":
case "int":
$return_value = $this->decodeInt($child);
break;
case "double":
$return_value = $this->decodeDouble($child);
break;
case "boolean":
$return_value = $this->decodeBool($child);
break;
case "base64":
$return_value = $this->decodeBase($child);
break;
case "dateTime.iso8601":
$return_value = $this->decodeIso8601Datetime($child);
break;
case "string":
$return_value = $this->decodeString($child);
break;
case "array":
$return_value = $this->decodeArray($child);
break;
case "struct":
$return_value = $this->decodeStruct($child);
break;
case "nil":
case "ex:nil":
$return_value = $this->decodeNil();
break;
default:
throw new XmlrpcException("Cannot decode value: invalid value type");
break;
}
return $return_value;
}
|
php
|
private function decodeValue($value) {
$children = $value->children();
if ( count($children) != 1 ) throw new XmlrpcException("Cannot decode value: invalid value element");
$child = $children[0];
$child_type = $child->getName();
switch ( $child_type ) {
case "i4":
case "int":
$return_value = $this->decodeInt($child);
break;
case "double":
$return_value = $this->decodeDouble($child);
break;
case "boolean":
$return_value = $this->decodeBool($child);
break;
case "base64":
$return_value = $this->decodeBase($child);
break;
case "dateTime.iso8601":
$return_value = $this->decodeIso8601Datetime($child);
break;
case "string":
$return_value = $this->decodeString($child);
break;
case "array":
$return_value = $this->decodeArray($child);
break;
case "struct":
$return_value = $this->decodeStruct($child);
break;
case "nil":
case "ex:nil":
$return_value = $this->decodeNil();
break;
default:
throw new XmlrpcException("Cannot decode value: invalid value type");
break;
}
return $return_value;
}
|
[
"private",
"function",
"decodeValue",
"(",
"$",
"value",
")",
"{",
"$",
"children",
"=",
"$",
"value",
"->",
"children",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"children",
")",
"!=",
"1",
")",
"throw",
"new",
"XmlrpcException",
"(",
"\"Cannot decode value: invalid value element\"",
")",
";",
"$",
"child",
"=",
"$",
"children",
"[",
"0",
"]",
";",
"$",
"child_type",
"=",
"$",
"child",
"->",
"getName",
"(",
")",
";",
"switch",
"(",
"$",
"child_type",
")",
"{",
"case",
"\"i4\"",
":",
"case",
"\"int\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeInt",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"double\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeDouble",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"boolean\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeBool",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"base64\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeBase",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"dateTime.iso8601\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeIso8601Datetime",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"string\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeString",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"array\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeArray",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"struct\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeStruct",
"(",
"$",
"child",
")",
";",
"break",
";",
"case",
"\"nil\"",
":",
"case",
"\"ex:nil\"",
":",
"$",
"return_value",
"=",
"$",
"this",
"->",
"decodeNil",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"XmlrpcException",
"(",
"\"Cannot decode value: invalid value type\"",
")",
";",
"break",
";",
"}",
"return",
"$",
"return_value",
";",
"}"
] |
Decode a value from xmlrpc data
@param mixed $value
@return mixed
@throws \Comodojo\Exception\XmlrpcException
|
[
"Decode",
"a",
"value",
"from",
"xmlrpc",
"data"
] |
2257167ce94ab657608c2062d485896f95f935a3
|
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcDecoder.php#L181-L239
|
234,116
|
budde377/Part
|
lib/model/user/UserImpl.php
|
UserImpl.setUsername
|
public function setUsername($username)
{
if($username == $this->username){
return true;
}
if ($this->usernameExists($username)) {
return false;
}
if ($this->setUsernameStatement === null) {
$this->setUsernameStatement = $this->connection->prepare("UPDATE User SET username = ? WHERE username = ?");
}
$wasLoggedIn = $this->isLoggedIn();
$this->setUsernameStatement->execute(array($username, $this->username));
$this->username = $username;
if ($wasLoggedIn) {
$this->updateLoginSession();
}
$this->notifyObservers(User::EVENT_USERNAME_UPDATE);
return true;
}
|
php
|
public function setUsername($username)
{
if($username == $this->username){
return true;
}
if ($this->usernameExists($username)) {
return false;
}
if ($this->setUsernameStatement === null) {
$this->setUsernameStatement = $this->connection->prepare("UPDATE User SET username = ? WHERE username = ?");
}
$wasLoggedIn = $this->isLoggedIn();
$this->setUsernameStatement->execute(array($username, $this->username));
$this->username = $username;
if ($wasLoggedIn) {
$this->updateLoginSession();
}
$this->notifyObservers(User::EVENT_USERNAME_UPDATE);
return true;
}
|
[
"public",
"function",
"setUsername",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"$",
"username",
"==",
"$",
"this",
"->",
"username",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"usernameExists",
"(",
"$",
"username",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"setUsernameStatement",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setUsernameStatement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"UPDATE User SET username = ? WHERE username = ?\"",
")",
";",
"}",
"$",
"wasLoggedIn",
"=",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
";",
"$",
"this",
"->",
"setUsernameStatement",
"->",
"execute",
"(",
"array",
"(",
"$",
"username",
",",
"$",
"this",
"->",
"username",
")",
")",
";",
"$",
"this",
"->",
"username",
"=",
"$",
"username",
";",
"if",
"(",
"$",
"wasLoggedIn",
")",
"{",
"$",
"this",
"->",
"updateLoginSession",
"(",
")",
";",
"}",
"$",
"this",
"->",
"notifyObservers",
"(",
"User",
"::",
"EVENT_USERNAME_UPDATE",
")",
";",
"return",
"true",
";",
"}"
] |
Will set the username, if username is unique.
@param string $username
@return bool FALSE if username invalid, TRUE on success
|
[
"Will",
"set",
"the",
"username",
"if",
"username",
"is",
"unique",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L95-L117
|
234,117
|
budde377/Part
|
lib/model/user/UserImpl.php
|
UserImpl.setMail
|
public function setMail($mail)
{
if (!$this->validMail($mail)) {
return false;
}
if ($this->setMailStatement === null) {
$this->setMailStatement = $this->connection->prepare("UPDATE User SET mail = ? WHERE username = ?");
$this->setMailStatement->bindParam(1, $this->mail);
$this->setMailStatement->bindParam(2, $this->username);
}
$this->mail = $mail;
$this->setMailStatement->execute();
return true;
}
|
php
|
public function setMail($mail)
{
if (!$this->validMail($mail)) {
return false;
}
if ($this->setMailStatement === null) {
$this->setMailStatement = $this->connection->prepare("UPDATE User SET mail = ? WHERE username = ?");
$this->setMailStatement->bindParam(1, $this->mail);
$this->setMailStatement->bindParam(2, $this->username);
}
$this->mail = $mail;
$this->setMailStatement->execute();
return true;
}
|
[
"public",
"function",
"setMail",
"(",
"$",
"mail",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validMail",
"(",
"$",
"mail",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"setMailStatement",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setMailStatement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"UPDATE User SET mail = ? WHERE username = ?\"",
")",
";",
"$",
"this",
"->",
"setMailStatement",
"->",
"bindParam",
"(",
"1",
",",
"$",
"this",
"->",
"mail",
")",
";",
"$",
"this",
"->",
"setMailStatement",
"->",
"bindParam",
"(",
"2",
",",
"$",
"this",
"->",
"username",
")",
";",
"}",
"$",
"this",
"->",
"mail",
"=",
"$",
"mail",
";",
"$",
"this",
"->",
"setMailStatement",
"->",
"execute",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Set the mail of the user, if mail is of right format.
@param string $mail
@return bool FALSE on wrong format of mail, else TRUE on success
|
[
"Set",
"the",
"mail",
"of",
"the",
"user",
"if",
"mail",
"is",
"of",
"right",
"format",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L124-L138
|
234,118
|
budde377/Part
|
lib/model/user/UserImpl.php
|
UserImpl.setPassword
|
public function setPassword($password)
{
if(!$this->isValidPassword($password)){
return false;
}
if ($this->setPasswordStatement === null) {
$this->setPasswordStatement = $this->connection->prepare("UPDATE User SET password=? WHERE username=?");
$this->setPasswordStatement->bindParam(1, $this->password);
$this->setPasswordStatement->bindParam(2, $this->username);
}
$wasLoggedIn = $this->isLoggedIn();
$this->password = $this->hashPassword($password);
$this->setPasswordStatement->execute();
if ($wasLoggedIn) {
$this->updateLoginSession();
}
return true;
}
|
php
|
public function setPassword($password)
{
if(!$this->isValidPassword($password)){
return false;
}
if ($this->setPasswordStatement === null) {
$this->setPasswordStatement = $this->connection->prepare("UPDATE User SET password=? WHERE username=?");
$this->setPasswordStatement->bindParam(1, $this->password);
$this->setPasswordStatement->bindParam(2, $this->username);
}
$wasLoggedIn = $this->isLoggedIn();
$this->password = $this->hashPassword($password);
$this->setPasswordStatement->execute();
if ($wasLoggedIn) {
$this->updateLoginSession();
}
return true;
}
|
[
"public",
"function",
"setPassword",
"(",
"$",
"password",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidPassword",
"(",
"$",
"password",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"setPasswordStatement",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setPasswordStatement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"UPDATE User SET password=? WHERE username=?\"",
")",
";",
"$",
"this",
"->",
"setPasswordStatement",
"->",
"bindParam",
"(",
"1",
",",
"$",
"this",
"->",
"password",
")",
";",
"$",
"this",
"->",
"setPasswordStatement",
"->",
"bindParam",
"(",
"2",
",",
"$",
"this",
"->",
"username",
")",
";",
"}",
"$",
"wasLoggedIn",
"=",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
";",
"$",
"this",
"->",
"password",
"=",
"$",
"this",
"->",
"hashPassword",
"(",
"$",
"password",
")",
";",
"$",
"this",
"->",
"setPasswordStatement",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"$",
"wasLoggedIn",
")",
"{",
"$",
"this",
"->",
"updateLoginSession",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Sets the password. Password must be non-empty string
@param string $password
@return bool
|
[
"Sets",
"the",
"password",
".",
"Password",
"must",
"be",
"non",
"-",
"empty",
"string"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L145-L166
|
234,119
|
budde377/Part
|
lib/model/user/UserImpl.php
|
UserImpl.delete
|
public function delete()
{
if ($this->deleteStatement == null) {
$this->deleteStatement = $this->connection->prepare("DELETE FROM User WHERE username = ?");
$this->deleteStatement->bindParam(1, $this->username);
}
try{
$this->deleteStatement->execute();
} catch (PDOException $exception){
return false;
}
if ($this->exists()) {
return false;
}
$this->notifyObservers(User::EVENT_DELETE);
return true;
}
|
php
|
public function delete()
{
if ($this->deleteStatement == null) {
$this->deleteStatement = $this->connection->prepare("DELETE FROM User WHERE username = ?");
$this->deleteStatement->bindParam(1, $this->username);
}
try{
$this->deleteStatement->execute();
} catch (PDOException $exception){
return false;
}
if ($this->exists()) {
return false;
}
$this->notifyObservers(User::EVENT_DELETE);
return true;
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"deleteStatement",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"deleteStatement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"DELETE FROM User WHERE username = ?\"",
")",
";",
"$",
"this",
"->",
"deleteStatement",
"->",
"bindParam",
"(",
"1",
",",
"$",
"this",
"->",
"username",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"deleteStatement",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"exception",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"notifyObservers",
"(",
"User",
"::",
"EVENT_DELETE",
")",
";",
"return",
"true",
";",
"}"
] |
Will delete user from persistent storage
@return bool Will return FALSE on failure, else TRUE
|
[
"Will",
"delete",
"user",
"from",
"persistent",
"storage"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L182-L198
|
234,120
|
budde377/Part
|
lib/model/user/UserImpl.php
|
UserImpl.create
|
public function create()
{
if ($this->createStatement == null) {
$this->createStatement = $this->connection->prepare("
INSERT INTO User (username,mail,password,id,parent) VALUES (?,?,?,?,?)");
$this->createStatement->bindParam(1, $this->username);
$this->createStatement->bindParam(2, $this->mail);
$this->createStatement->bindParam(3, $this->password);
$this->createStatement->bindParam(4, $this->userId);
$this->createStatement->bindParam(5, $this->parentID);
}
try {
$this->createStatement->execute();
} catch (PDOException $e) {
return false;
}
$this->setInitialValues();
return $this->exists();
}
|
php
|
public function create()
{
if ($this->createStatement == null) {
$this->createStatement = $this->connection->prepare("
INSERT INTO User (username,mail,password,id,parent) VALUES (?,?,?,?,?)");
$this->createStatement->bindParam(1, $this->username);
$this->createStatement->bindParam(2, $this->mail);
$this->createStatement->bindParam(3, $this->password);
$this->createStatement->bindParam(4, $this->userId);
$this->createStatement->bindParam(5, $this->parentID);
}
try {
$this->createStatement->execute();
} catch (PDOException $e) {
return false;
}
$this->setInitialValues();
return $this->exists();
}
|
[
"public",
"function",
"create",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"createStatement",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"createStatement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"\n INSERT INTO User (username,mail,password,id,parent) VALUES (?,?,?,?,?)\"",
")",
";",
"$",
"this",
"->",
"createStatement",
"->",
"bindParam",
"(",
"1",
",",
"$",
"this",
"->",
"username",
")",
";",
"$",
"this",
"->",
"createStatement",
"->",
"bindParam",
"(",
"2",
",",
"$",
"this",
"->",
"mail",
")",
";",
"$",
"this",
"->",
"createStatement",
"->",
"bindParam",
"(",
"3",
",",
"$",
"this",
"->",
"password",
")",
";",
"$",
"this",
"->",
"createStatement",
"->",
"bindParam",
"(",
"4",
",",
"$",
"this",
"->",
"userId",
")",
";",
"$",
"this",
"->",
"createStatement",
"->",
"bindParam",
"(",
"5",
",",
"$",
"this",
"->",
"parentID",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"createStatement",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setInitialValues",
"(",
")",
";",
"return",
"$",
"this",
"->",
"exists",
"(",
")",
";",
"}"
] |
Create the user on persistent storage
@return bool Will return TRUE if user has been created on persistent storage, else FALSE
|
[
"Create",
"the",
"user",
"on",
"persistent",
"storage"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L204-L222
|
234,121
|
budde377/Part
|
lib/model/user/UserImpl.php
|
UserImpl.login
|
public function login($password)
{
if (!$this->exists() ||
!$this->verifyLogin($password) ||
$this->someOneLoggedIn()
) {
return false;
}
if ($this->lastLoginStatement === null) {
$this->lastLoginStatement = $this->connection->prepare("UPDATE User SET lastLogin = FROM_UNIXTIME(?) WHERE username = ?");
$this->lastLoginStatement->bindParam(1, $this->lastLogin);
$this->lastLoginStatement->bindParam(2, $this->username);
}
$this->lastLogin = time();
$this->lastLoginStatement->execute();
$this->updateLoginSession();
$this->notifyObservers(User::EVENT_LOGIN);
return true;
}
|
php
|
public function login($password)
{
if (!$this->exists() ||
!$this->verifyLogin($password) ||
$this->someOneLoggedIn()
) {
return false;
}
if ($this->lastLoginStatement === null) {
$this->lastLoginStatement = $this->connection->prepare("UPDATE User SET lastLogin = FROM_UNIXTIME(?) WHERE username = ?");
$this->lastLoginStatement->bindParam(1, $this->lastLogin);
$this->lastLoginStatement->bindParam(2, $this->username);
}
$this->lastLogin = time();
$this->lastLoginStatement->execute();
$this->updateLoginSession();
$this->notifyObservers(User::EVENT_LOGIN);
return true;
}
|
[
"public",
"function",
"login",
"(",
"$",
"password",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"verifyLogin",
"(",
"$",
"password",
")",
"||",
"$",
"this",
"->",
"someOneLoggedIn",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"lastLoginStatement",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"lastLoginStatement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"UPDATE User SET lastLogin = FROM_UNIXTIME(?) WHERE username = ?\"",
")",
";",
"$",
"this",
"->",
"lastLoginStatement",
"->",
"bindParam",
"(",
"1",
",",
"$",
"this",
"->",
"lastLogin",
")",
";",
"$",
"this",
"->",
"lastLoginStatement",
"->",
"bindParam",
"(",
"2",
",",
"$",
"this",
"->",
"username",
")",
";",
"}",
"$",
"this",
"->",
"lastLogin",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"lastLoginStatement",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"updateLoginSession",
"(",
")",
";",
"$",
"this",
"->",
"notifyObservers",
"(",
"User",
"::",
"EVENT_LOGIN",
")",
";",
"return",
"true",
";",
"}"
] |
Will login the user
@param string $password
@return bool FALSE if another user is logged in, including self, or if password is not valid. Else TRUE.
|
[
"Will",
"login",
"the",
"user"
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserImpl.php#L247-L269
|
234,122
|
vcarreira/wordsapi
|
src/WordService.php
|
WordService.fetch
|
public function fetch($word, $verb, $prefetchDetails = false)
{
$url = 'https://wordsapiv1.p.mashape.com/words/'.rawurlencode($word);
$verbIsHidden = array_key_exists($verb, $this->hiddenVerbs) || $prefetchDetails;
if (!$verbIsHidden) {
$url .= '/'.$verb;
}
$headers = [
'X-Mashape-Key: '.$this->api_key,
'Accept: application/json',
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($statusCode !== 200) {
return false;
}
if (is_null($response) || empty($response)) {
return false;
}
$data = json_decode($response, true);
if ($verbIsHidden) {
return $this->transformFullRequest($data);
}
return [$verb => $this->transformVerb($data, $verb)];
}
|
php
|
public function fetch($word, $verb, $prefetchDetails = false)
{
$url = 'https://wordsapiv1.p.mashape.com/words/'.rawurlencode($word);
$verbIsHidden = array_key_exists($verb, $this->hiddenVerbs) || $prefetchDetails;
if (!$verbIsHidden) {
$url .= '/'.$verb;
}
$headers = [
'X-Mashape-Key: '.$this->api_key,
'Accept: application/json',
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($statusCode !== 200) {
return false;
}
if (is_null($response) || empty($response)) {
return false;
}
$data = json_decode($response, true);
if ($verbIsHidden) {
return $this->transformFullRequest($data);
}
return [$verb => $this->transformVerb($data, $verb)];
}
|
[
"public",
"function",
"fetch",
"(",
"$",
"word",
",",
"$",
"verb",
",",
"$",
"prefetchDetails",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"'https://wordsapiv1.p.mashape.com/words/'",
".",
"rawurlencode",
"(",
"$",
"word",
")",
";",
"$",
"verbIsHidden",
"=",
"array_key_exists",
"(",
"$",
"verb",
",",
"$",
"this",
"->",
"hiddenVerbs",
")",
"||",
"$",
"prefetchDetails",
";",
"if",
"(",
"!",
"$",
"verbIsHidden",
")",
"{",
"$",
"url",
".=",
"'/'",
".",
"$",
"verb",
";",
"}",
"$",
"headers",
"=",
"[",
"'X-Mashape-Key: '",
".",
"$",
"this",
"->",
"api_key",
",",
"'Accept: application/json'",
",",
"]",
";",
"$",
"curl",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"headers",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_TIMEOUT",
",",
"$",
"this",
"->",
"timeout",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"curl",
")",
";",
"$",
"statusCode",
"=",
"curl_getinfo",
"(",
"$",
"curl",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"curl_close",
"(",
"$",
"curl",
")",
";",
"if",
"(",
"$",
"statusCode",
"!==",
"200",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"response",
")",
"||",
"empty",
"(",
"$",
"response",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"if",
"(",
"$",
"verbIsHidden",
")",
"{",
"return",
"$",
"this",
"->",
"transformFullRequest",
"(",
"$",
"data",
")",
";",
"}",
"return",
"[",
"$",
"verb",
"=>",
"$",
"this",
"->",
"transformVerb",
"(",
"$",
"data",
",",
"$",
"verb",
")",
"]",
";",
"}"
] |
Fetch information about a specific word.
@param string $word the word to fetch.
@param string $verb the type of information to fetch. Check the {@link https://www.wordsapi.com/docs Words API documentation}.
@param bool $prefetchDetails true to ignore the verb and pre-fetch all word details.
@return array|false an associative array (indexed by verb) with the requested information,
false if the word is not found.
|
[
"Fetch",
"information",
"about",
"a",
"specific",
"word",
"."
] |
60ca55823ffdf8c422e6bbed614161dc8d6af394
|
https://github.com/vcarreira/wordsapi/blob/60ca55823ffdf8c422e6bbed614161dc8d6af394/src/WordService.php#L102-L137
|
234,123
|
xylemical/php-expressions
|
src/ExpressionFactory.php
|
ExpressionFactory.getOperators
|
public function getOperators()
{
// Order the by priority then precedent.
$list = (array)$this->operators;
usort($list, function(Operator $a, Operator $b) {
// Sort by priority.
if ($a->getPriority() === $b->getPriority()) {
// Then by associativity.
if ($a->getAssociativity() == $b->getAssociativity()) {
// Then by regex length (the longer the better).
if (strlen($a->getRegex()) === strlen($b->getRegex())) {
return 0;
}
return strlen($a->getRegex()) > strlen($b->getRegex()) ? -1 : 1;
}
return $a->getAssociativity() > $b->getAssociativity() ? -1 : 1;
}
return $a->getPriority() > $b->getPriority() ? -1 : 1;
});
return $list;
}
|
php
|
public function getOperators()
{
// Order the by priority then precedent.
$list = (array)$this->operators;
usort($list, function(Operator $a, Operator $b) {
// Sort by priority.
if ($a->getPriority() === $b->getPriority()) {
// Then by associativity.
if ($a->getAssociativity() == $b->getAssociativity()) {
// Then by regex length (the longer the better).
if (strlen($a->getRegex()) === strlen($b->getRegex())) {
return 0;
}
return strlen($a->getRegex()) > strlen($b->getRegex()) ? -1 : 1;
}
return $a->getAssociativity() > $b->getAssociativity() ? -1 : 1;
}
return $a->getPriority() > $b->getPriority() ? -1 : 1;
});
return $list;
}
|
[
"public",
"function",
"getOperators",
"(",
")",
"{",
"// Order the by priority then precedent.",
"$",
"list",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"operators",
";",
"usort",
"(",
"$",
"list",
",",
"function",
"(",
"Operator",
"$",
"a",
",",
"Operator",
"$",
"b",
")",
"{",
"// Sort by priority.",
"if",
"(",
"$",
"a",
"->",
"getPriority",
"(",
")",
"===",
"$",
"b",
"->",
"getPriority",
"(",
")",
")",
"{",
"// Then by associativity.",
"if",
"(",
"$",
"a",
"->",
"getAssociativity",
"(",
")",
"==",
"$",
"b",
"->",
"getAssociativity",
"(",
")",
")",
"{",
"// Then by regex length (the longer the better).",
"if",
"(",
"strlen",
"(",
"$",
"a",
"->",
"getRegex",
"(",
")",
")",
"===",
"strlen",
"(",
"$",
"b",
"->",
"getRegex",
"(",
")",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"strlen",
"(",
"$",
"a",
"->",
"getRegex",
"(",
")",
")",
">",
"strlen",
"(",
"$",
"b",
"->",
"getRegex",
"(",
")",
")",
"?",
"-",
"1",
":",
"1",
";",
"}",
"return",
"$",
"a",
"->",
"getAssociativity",
"(",
")",
">",
"$",
"b",
"->",
"getAssociativity",
"(",
")",
"?",
"-",
"1",
":",
"1",
";",
"}",
"return",
"$",
"a",
"->",
"getPriority",
"(",
")",
">",
"$",
"b",
"->",
"getPriority",
"(",
")",
"?",
"-",
"1",
":",
"1",
";",
"}",
")",
";",
"return",
"$",
"list",
";",
"}"
] |
Get the list of operators ordered by priority and association.
@return array
|
[
"Get",
"the",
"list",
"of",
"operators",
"ordered",
"by",
"priority",
"and",
"association",
"."
] |
4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73
|
https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/ExpressionFactory.php#L136-L157
|
234,124
|
skrz/meta
|
gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php
|
ExtensionRangeMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ExtensionRange();
case 1:
return new ExtensionRange(func_get_arg(0));
case 2:
return new ExtensionRange(func_get_arg(0), func_get_arg(1));
case 3:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ExtensionRange();
case 1:
return new ExtensionRange(func_get_arg(0));
case 2:
return new ExtensionRange(func_get_arg(0), func_get_arg(1));
case 3:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ExtensionRange(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"ExtensionRange",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"ExtensionRange",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\DescriptorProto\ExtensionRange
@throws \InvalidArgumentException
@return ExtensionRange
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto",
"\\",
"ExtensionRange"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php#L58-L82
|
234,125
|
skrz/meta
|
gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php
|
ExtensionRangeMeta.reset
|
public static function reset($object)
{
if (!($object instanceof ExtensionRange)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ExtensionRange.');
}
$object->start = NULL;
$object->end = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof ExtensionRange)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\DescriptorProto\ExtensionRange.');
}
$object->start = NULL;
$object->end = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"ExtensionRange",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\DescriptorProto\\ExtensionRange.'",
")",
";",
"}",
"$",
"object",
"->",
"start",
"=",
"NULL",
";",
"$",
"object",
"->",
"end",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\DescriptorProto\ExtensionRange to default values
@param ExtensionRange $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"DescriptorProto",
"\\",
"ExtensionRange",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/DescriptorProto/Meta/ExtensionRangeMeta.php#L95-L102
|
234,126
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Controllers/PostController.php
|
PostController.tag
|
public function tag($tag)
{
$posts = $this->posts->activeByTag($tag, Config::get('wardrobe.per_page'));
if ( ! $posts)
{
return App::abort(404, 'Page not found');
}
return View::make($this->theme.'.archive', compact('posts', 'tag'));
}
|
php
|
public function tag($tag)
{
$posts = $this->posts->activeByTag($tag, Config::get('wardrobe.per_page'));
if ( ! $posts)
{
return App::abort(404, 'Page not found');
}
return View::make($this->theme.'.archive', compact('posts', 'tag'));
}
|
[
"public",
"function",
"tag",
"(",
"$",
"tag",
")",
"{",
"$",
"posts",
"=",
"$",
"this",
"->",
"posts",
"->",
"activeByTag",
"(",
"$",
"tag",
",",
"Config",
"::",
"get",
"(",
"'wardrobe.per_page'",
")",
")",
";",
"if",
"(",
"!",
"$",
"posts",
")",
"{",
"return",
"App",
"::",
"abort",
"(",
"404",
",",
"'Page not found'",
")",
";",
"}",
"return",
"View",
"::",
"make",
"(",
"$",
"this",
"->",
"theme",
".",
"'.archive'",
",",
"compact",
"(",
"'posts'",
",",
"'tag'",
")",
")",
";",
"}"
] |
Get posts by tag
@param string $tag
@return Response
|
[
"Get",
"posts",
"by",
"tag"
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/PostController.php#L56-L66
|
234,127
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Controllers/PostController.php
|
PostController.preview
|
public function preview($id)
{
if ( ! $this->auth->check())
{
return App::abort(404, 'Page not found');
}
return View::make($this->theme.'.preview', array('id' => $id));
}
|
php
|
public function preview($id)
{
if ( ! $this->auth->check())
{
return App::abort(404, 'Page not found');
}
return View::make($this->theme.'.preview', array('id' => $id));
}
|
[
"public",
"function",
"preview",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"auth",
"->",
"check",
"(",
")",
")",
"{",
"return",
"App",
"::",
"abort",
"(",
"404",
",",
"'Page not found'",
")",
";",
"}",
"return",
"View",
"::",
"make",
"(",
"$",
"this",
"->",
"theme",
".",
"'.preview'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
")",
";",
"}"
] |
Show a post preview.
@param int $id
@return Response
|
[
"Show",
"a",
"post",
"preview",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/PostController.php#L94-L102
|
234,128
|
kss-php/kss-php
|
lib/CommentParser.php
|
CommentParser.parseBlocks
|
protected function parseBlocks()
{
$this->blocks = array();
$currentBlock = '';
// Do we need insideSingleLineBlock? It doesn't seem to be used anywhere
// Original Ruby version of KSS had it but I'm not seeing a purpose to it
$insideSingleLineBlock = false;
$insideMultiLineBlock = false;
foreach ($this->file as $line) {
$isSingleLineComment = self::isSingleLineComment($line);
$isStartMultiLineComment = self::isStartMultiLineComment($line);
$isEndMultiLineComment = self::isEndMultiLineComment($line);
if ($isSingleLineComment) {
$parsed = self::parseSingleLineComment($line);
if ($insideSingleLineBlock) {
$currentBlock .= "\n";
} else {
$insideSingleLineBlock = true;
}
$currentBlock .= $parsed;
}
if ($isStartMultiLineComment || $insideMultiLineBlock) {
$parsed = self::parseMultiLineComment($line);
if ($insideMultiLineBlock) {
$currentBlock .= "\n";
} else {
$insideMultiLineBlock = true;
}
$currentBlock .= $parsed;
}
if ($isEndMultiLineComment) {
$insideMultiLineBlock = false;
}
// If we're not in a comment then end the current block and go to
// the next one
if (!$isSingleLineComment && !$insideMultiLineBlock) {
if (!empty($currentBlock)) {
$this->blocks[] = $this->normalize($currentBlock);
$insideSingleLineBlock = false;
$currentBlock = '';
}
}
}
$this->parsed = true;
return $this->blocks;
}
|
php
|
protected function parseBlocks()
{
$this->blocks = array();
$currentBlock = '';
// Do we need insideSingleLineBlock? It doesn't seem to be used anywhere
// Original Ruby version of KSS had it but I'm not seeing a purpose to it
$insideSingleLineBlock = false;
$insideMultiLineBlock = false;
foreach ($this->file as $line) {
$isSingleLineComment = self::isSingleLineComment($line);
$isStartMultiLineComment = self::isStartMultiLineComment($line);
$isEndMultiLineComment = self::isEndMultiLineComment($line);
if ($isSingleLineComment) {
$parsed = self::parseSingleLineComment($line);
if ($insideSingleLineBlock) {
$currentBlock .= "\n";
} else {
$insideSingleLineBlock = true;
}
$currentBlock .= $parsed;
}
if ($isStartMultiLineComment || $insideMultiLineBlock) {
$parsed = self::parseMultiLineComment($line);
if ($insideMultiLineBlock) {
$currentBlock .= "\n";
} else {
$insideMultiLineBlock = true;
}
$currentBlock .= $parsed;
}
if ($isEndMultiLineComment) {
$insideMultiLineBlock = false;
}
// If we're not in a comment then end the current block and go to
// the next one
if (!$isSingleLineComment && !$insideMultiLineBlock) {
if (!empty($currentBlock)) {
$this->blocks[] = $this->normalize($currentBlock);
$insideSingleLineBlock = false;
$currentBlock = '';
}
}
}
$this->parsed = true;
return $this->blocks;
}
|
[
"protected",
"function",
"parseBlocks",
"(",
")",
"{",
"$",
"this",
"->",
"blocks",
"=",
"array",
"(",
")",
";",
"$",
"currentBlock",
"=",
"''",
";",
"// Do we need insideSingleLineBlock? It doesn't seem to be used anywhere",
"// Original Ruby version of KSS had it but I'm not seeing a purpose to it",
"$",
"insideSingleLineBlock",
"=",
"false",
";",
"$",
"insideMultiLineBlock",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"file",
"as",
"$",
"line",
")",
"{",
"$",
"isSingleLineComment",
"=",
"self",
"::",
"isSingleLineComment",
"(",
"$",
"line",
")",
";",
"$",
"isStartMultiLineComment",
"=",
"self",
"::",
"isStartMultiLineComment",
"(",
"$",
"line",
")",
";",
"$",
"isEndMultiLineComment",
"=",
"self",
"::",
"isEndMultiLineComment",
"(",
"$",
"line",
")",
";",
"if",
"(",
"$",
"isSingleLineComment",
")",
"{",
"$",
"parsed",
"=",
"self",
"::",
"parseSingleLineComment",
"(",
"$",
"line",
")",
";",
"if",
"(",
"$",
"insideSingleLineBlock",
")",
"{",
"$",
"currentBlock",
".=",
"\"\\n\"",
";",
"}",
"else",
"{",
"$",
"insideSingleLineBlock",
"=",
"true",
";",
"}",
"$",
"currentBlock",
".=",
"$",
"parsed",
";",
"}",
"if",
"(",
"$",
"isStartMultiLineComment",
"||",
"$",
"insideMultiLineBlock",
")",
"{",
"$",
"parsed",
"=",
"self",
"::",
"parseMultiLineComment",
"(",
"$",
"line",
")",
";",
"if",
"(",
"$",
"insideMultiLineBlock",
")",
"{",
"$",
"currentBlock",
".=",
"\"\\n\"",
";",
"}",
"else",
"{",
"$",
"insideMultiLineBlock",
"=",
"true",
";",
"}",
"$",
"currentBlock",
".=",
"$",
"parsed",
";",
"}",
"if",
"(",
"$",
"isEndMultiLineComment",
")",
"{",
"$",
"insideMultiLineBlock",
"=",
"false",
";",
"}",
"// If we're not in a comment then end the current block and go to",
"// the next one",
"if",
"(",
"!",
"$",
"isSingleLineComment",
"&&",
"!",
"$",
"insideMultiLineBlock",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"currentBlock",
")",
")",
"{",
"$",
"this",
"->",
"blocks",
"[",
"]",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"currentBlock",
")",
";",
"$",
"insideSingleLineBlock",
"=",
"false",
";",
"$",
"currentBlock",
"=",
"''",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"parsed",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"blocks",
";",
"}"
] |
Parses each line of the file looking for single or multi-line comments
@return array
|
[
"Parses",
"each",
"line",
"of",
"the",
"file",
"looking",
"for",
"single",
"or",
"multi",
"-",
"line",
"comments"
] |
5431bfb3c3708cfedb6a95fc3413181287d1f776
|
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/CommentParser.php#L73-L128
|
234,129
|
kss-php/kss-php
|
lib/CommentParser.php
|
CommentParser.normalize
|
protected function normalize($block)
{
// Remove any [whitespace]*'s from the start of each line
$normalizedBlock = preg_replace('-^\s*\*+-m', '', $block);
$indentSize = null;
$blockLines = explode("\n", $normalizedBlock);
$normalizedLines = array();
foreach ($blockLines as $line) {
preg_match('/^\s*/', $line, $matches);
$precedingWhitespace = strlen($matches[0]);
if ($indentSize === null) {
$indentSize = $precedingWhitespace;
}
if ($indentSize <= $precedingWhitespace && $indentSize > 0) {
$line = substr($line, $indentSize);
}
$normalizedLines[] = $line;
}
return trim(implode("\n", $normalizedLines));
}
|
php
|
protected function normalize($block)
{
// Remove any [whitespace]*'s from the start of each line
$normalizedBlock = preg_replace('-^\s*\*+-m', '', $block);
$indentSize = null;
$blockLines = explode("\n", $normalizedBlock);
$normalizedLines = array();
foreach ($blockLines as $line) {
preg_match('/^\s*/', $line, $matches);
$precedingWhitespace = strlen($matches[0]);
if ($indentSize === null) {
$indentSize = $precedingWhitespace;
}
if ($indentSize <= $precedingWhitespace && $indentSize > 0) {
$line = substr($line, $indentSize);
}
$normalizedLines[] = $line;
}
return trim(implode("\n", $normalizedLines));
}
|
[
"protected",
"function",
"normalize",
"(",
"$",
"block",
")",
"{",
"// Remove any [whitespace]*'s from the start of each line",
"$",
"normalizedBlock",
"=",
"preg_replace",
"(",
"'-^\\s*\\*+-m'",
",",
"''",
",",
"$",
"block",
")",
";",
"$",
"indentSize",
"=",
"null",
";",
"$",
"blockLines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"normalizedBlock",
")",
";",
"$",
"normalizedLines",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"blockLines",
"as",
"$",
"line",
")",
"{",
"preg_match",
"(",
"'/^\\s*/'",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"$",
"precedingWhitespace",
"=",
"strlen",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"if",
"(",
"$",
"indentSize",
"===",
"null",
")",
"{",
"$",
"indentSize",
"=",
"$",
"precedingWhitespace",
";",
"}",
"if",
"(",
"$",
"indentSize",
"<=",
"$",
"precedingWhitespace",
"&&",
"$",
"indentSize",
">",
"0",
")",
"{",
"$",
"line",
"=",
"substr",
"(",
"$",
"line",
",",
"$",
"indentSize",
")",
";",
"}",
"$",
"normalizedLines",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"return",
"trim",
"(",
"implode",
"(",
"\"\\n\"",
",",
"$",
"normalizedLines",
")",
")",
";",
"}"
] |
Makes all the white space consistent among the lines in a comment block.
That is if the first and second line had 10 spaces but the third line was
indented to 15 spaces, we'd normalize it so the first and second line have
no spaces and the third line has 5 spaces.
@param string $block
@return string
|
[
"Makes",
"all",
"the",
"white",
"space",
"consistent",
"among",
"the",
"lines",
"in",
"a",
"comment",
"block",
".",
"That",
"is",
"if",
"the",
"first",
"and",
"second",
"line",
"had",
"10",
"spaces",
"but",
"the",
"third",
"line",
"was",
"indented",
"to",
"15",
"spaces",
"we",
"d",
"normalize",
"it",
"so",
"the",
"first",
"and",
"second",
"line",
"have",
"no",
"spaces",
"and",
"the",
"third",
"line",
"has",
"5",
"spaces",
"."
] |
5431bfb3c3708cfedb6a95fc3413181287d1f776
|
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/CommentParser.php#L140-L163
|
234,130
|
kss-php/kss-php
|
lib/CommentParser.php
|
CommentParser.parseMultiLineComment
|
public static function parseMultiLineComment($line)
{
$parsed = preg_replace('-^\s*/\*+-', '', $line);
$parsed = preg_replace('-\*/-', '', $parsed);
return rtrim($parsed);
}
|
php
|
public static function parseMultiLineComment($line)
{
$parsed = preg_replace('-^\s*/\*+-', '', $line);
$parsed = preg_replace('-\*/-', '', $parsed);
return rtrim($parsed);
}
|
[
"public",
"static",
"function",
"parseMultiLineComment",
"(",
"$",
"line",
")",
"{",
"$",
"parsed",
"=",
"preg_replace",
"(",
"'-^\\s*/\\*+-'",
",",
"''",
",",
"$",
"line",
")",
";",
"$",
"parsed",
"=",
"preg_replace",
"(",
"'-\\*/-'",
",",
"''",
",",
"$",
"parsed",
")",
";",
"return",
"rtrim",
"(",
"$",
"parsed",
")",
";",
"}"
] |
Removes the comment markers from a multi line comment and trims the line
@param string $line
@return string
|
[
"Removes",
"the",
"comment",
"markers",
"from",
"a",
"multi",
"line",
"comment",
"and",
"trims",
"the",
"line"
] |
5431bfb3c3708cfedb6a95fc3413181287d1f776
|
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/CommentParser.php#L220-L225
|
234,131
|
budde377/Part
|
lib/model/user/UserLibraryImpl.php
|
UserLibraryImpl.deleteUser
|
public function deleteUser(User $user)
{
$parent = $user->getParent();
if (!isset($this->userList[$user->getUsername()]) || $this->userList[$user->getUsername()] !== $user ||
$parent == null
) {
return false;
}
$this->connection->beginTransaction();
$children = $this->getChildren($user);
$success = true;
foreach ($children as $child) {
/** @var $child User */
$success = $success && $child->setParent($parent);
}
$success = $success && $user->delete();
if ($success) {
$this->connection->commit();
$this->setUpIterator();
} else {
$this->connection->rollBack();
}
return $success;
}
|
php
|
public function deleteUser(User $user)
{
$parent = $user->getParent();
if (!isset($this->userList[$user->getUsername()]) || $this->userList[$user->getUsername()] !== $user ||
$parent == null
) {
return false;
}
$this->connection->beginTransaction();
$children = $this->getChildren($user);
$success = true;
foreach ($children as $child) {
/** @var $child User */
$success = $success && $child->setParent($parent);
}
$success = $success && $user->delete();
if ($success) {
$this->connection->commit();
$this->setUpIterator();
} else {
$this->connection->rollBack();
}
return $success;
}
|
[
"public",
"function",
"deleteUser",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"parent",
"=",
"$",
"user",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"userList",
"[",
"$",
"user",
"->",
"getUsername",
"(",
")",
"]",
")",
"||",
"$",
"this",
"->",
"userList",
"[",
"$",
"user",
"->",
"getUsername",
"(",
")",
"]",
"!==",
"$",
"user",
"||",
"$",
"parent",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"children",
"=",
"$",
"this",
"->",
"getChildren",
"(",
"$",
"user",
")",
";",
"$",
"success",
"=",
"true",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"/** @var $child User */",
"$",
"success",
"=",
"$",
"success",
"&&",
"$",
"child",
"->",
"setParent",
"(",
"$",
"parent",
")",
";",
"}",
"$",
"success",
"=",
"$",
"success",
"&&",
"$",
"user",
"->",
"delete",
"(",
")",
";",
"if",
"(",
"$",
"success",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"commit",
"(",
")",
";",
"$",
"this",
"->",
"setUpIterator",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"connection",
"->",
"rollBack",
"(",
")",
";",
"}",
"return",
"$",
"success",
";",
"}"
] |
Will delete user. The user must be instance in library.
@param User $user
@return bool
|
[
"Will",
"delete",
"user",
".",
"The",
"user",
"must",
"be",
"instance",
"in",
"library",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L70-L94
|
234,132
|
budde377/Part
|
lib/model/user/UserLibraryImpl.php
|
UserLibraryImpl.createUser
|
public function createUser($username, $password, $mail, User $parent=null)
{
$user = new UserImpl($this->container, $username);
if (!$user->setMail($mail) || !$user->setPassword($password) ) {
return false;
}
if($parent != null && !$user->setParent($parent->getUsername())){
return false;
}
if(!$user->create()){
return false;
}
$this->userList[$user->getUsername()] = $user;
$user->attachObserver($this);
$this->setUpIterator();
return $user;
}
|
php
|
public function createUser($username, $password, $mail, User $parent=null)
{
$user = new UserImpl($this->container, $username);
if (!$user->setMail($mail) || !$user->setPassword($password) ) {
return false;
}
if($parent != null && !$user->setParent($parent->getUsername())){
return false;
}
if(!$user->create()){
return false;
}
$this->userList[$user->getUsername()] = $user;
$user->attachObserver($this);
$this->setUpIterator();
return $user;
}
|
[
"public",
"function",
"createUser",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"mail",
",",
"User",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"new",
"UserImpl",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"username",
")",
";",
"if",
"(",
"!",
"$",
"user",
"->",
"setMail",
"(",
"$",
"mail",
")",
"||",
"!",
"$",
"user",
"->",
"setPassword",
"(",
"$",
"password",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"parent",
"!=",
"null",
"&&",
"!",
"$",
"user",
"->",
"setParent",
"(",
"$",
"parent",
"->",
"getUsername",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"user",
"->",
"create",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"userList",
"[",
"$",
"user",
"->",
"getUsername",
"(",
")",
"]",
"=",
"$",
"user",
";",
"$",
"user",
"->",
"attachObserver",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"setUpIterator",
"(",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
Will create a user, the username must be unique
The created instance can be deleted and will be in list
from listUsers.
@param string $username
@param string $password
@param string $mail
@param User $parent
@return User | bool FALSE on failure else instance of User
|
[
"Will",
"create",
"a",
"user",
"the",
"username",
"must",
"be",
"unique",
"The",
"created",
"instance",
"can",
"be",
"deleted",
"and",
"will",
"be",
"in",
"list",
"from",
"listUsers",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L106-L125
|
234,133
|
budde377/Part
|
lib/model/user/UserLibraryImpl.php
|
UserLibraryImpl.getChildren
|
public function getChildren(User $user)
{
$returnArray = array();
foreach ($this->userList as $u) {
/** @var $u User */
if ($u->getParent() == $user->getUsername()) {
$returnArray[] = $u;
$returnArray = array_merge($returnArray, $this->getChildren($u));
}
}
return $returnArray;
}
|
php
|
public function getChildren(User $user)
{
$returnArray = array();
foreach ($this->userList as $u) {
/** @var $u User */
if ($u->getParent() == $user->getUsername()) {
$returnArray[] = $u;
$returnArray = array_merge($returnArray, $this->getChildren($u));
}
}
return $returnArray;
}
|
[
"public",
"function",
"getChildren",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"returnArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"userList",
"as",
"$",
"u",
")",
"{",
"/** @var $u User */",
"if",
"(",
"$",
"u",
"->",
"getParent",
"(",
")",
"==",
"$",
"user",
"->",
"getUsername",
"(",
")",
")",
"{",
"$",
"returnArray",
"[",
"]",
"=",
"$",
"u",
";",
"$",
"returnArray",
"=",
"array_merge",
"(",
"$",
"returnArray",
",",
"$",
"this",
"->",
"getChildren",
"(",
"$",
"u",
")",
")",
";",
"}",
"}",
"return",
"$",
"returnArray",
";",
"}"
] |
Input must be instance of User and an instance provided by the library.
@param User $user
@return array Array containing children User instances. Empty array on no children or input not valid.
|
[
"Input",
"must",
"be",
"instance",
"of",
"User",
"and",
"an",
"instance",
"provided",
"by",
"the",
"library",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L196-L207
|
234,134
|
budde377/Part
|
lib/model/user/UserLibraryImpl.php
|
UserLibraryImpl.getUserSessionToken
|
public function getUserSessionToken()
{
if (($u = $this->getUserLoggedIn()) == null) {
return null;
}
return isset($_SESSION['model-user-library-session-token']) ? $_SESSION['model-user-library-session-token'] : $_SESSION['model-user-library-session-token'] = $u->getUserToken();
}
|
php
|
public function getUserSessionToken()
{
if (($u = $this->getUserLoggedIn()) == null) {
return null;
}
return isset($_SESSION['model-user-library-session-token']) ? $_SESSION['model-user-library-session-token'] : $_SESSION['model-user-library-session-token'] = $u->getUserToken();
}
|
[
"public",
"function",
"getUserSessionToken",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"u",
"=",
"$",
"this",
"->",
"getUserLoggedIn",
"(",
")",
")",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"isset",
"(",
"$",
"_SESSION",
"[",
"'model-user-library-session-token'",
"]",
")",
"?",
"$",
"_SESSION",
"[",
"'model-user-library-session-token'",
"]",
":",
"$",
"_SESSION",
"[",
"'model-user-library-session-token'",
"]",
"=",
"$",
"u",
"->",
"getUserToken",
"(",
")",
";",
"}"
] |
Returns the current user settings token.
If no user is logged in, the token will be null.
@return string
|
[
"Returns",
"the",
"current",
"user",
"settings",
"token",
".",
"If",
"no",
"user",
"is",
"logged",
"in",
"the",
"token",
"will",
"be",
"null",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserLibraryImpl.php#L299-L306
|
234,135
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
|
MessageOptionsMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new MessageOptions();
case 1:
return new MessageOptions(func_get_arg(0));
case 2:
return new MessageOptions(func_get_arg(0), func_get_arg(1));
case 3:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new MessageOptions();
case 1:
return new MessageOptions(func_get_arg(0));
case 2:
return new MessageOptions(func_get_arg(0), func_get_arg(1));
case 3:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new MessageOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"MessageOptions",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"MessageOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\MessageOptions
@throws \InvalidArgumentException
@return MessageOptions
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MessageOptions"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L61-L85
|
234,136
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
|
MessageOptionsMeta.reset
|
public static function reset($object)
{
if (!($object instanceof MessageOptions)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MessageOptions.');
}
$object->messageSetWireFormat = NULL;
$object->noStandardDescriptorAccessor = NULL;
$object->deprecated = NULL;
$object->mapEntry = NULL;
$object->uninterpretedOption = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof MessageOptions)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MessageOptions.');
}
$object->messageSetWireFormat = NULL;
$object->noStandardDescriptorAccessor = NULL;
$object->deprecated = NULL;
$object->mapEntry = NULL;
$object->uninterpretedOption = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"MessageOptions",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\MessageOptions.'",
")",
";",
"}",
"$",
"object",
"->",
"messageSetWireFormat",
"=",
"NULL",
";",
"$",
"object",
"->",
"noStandardDescriptorAccessor",
"=",
"NULL",
";",
"$",
"object",
"->",
"deprecated",
"=",
"NULL",
";",
"$",
"object",
"->",
"mapEntry",
"=",
"NULL",
";",
"$",
"object",
"->",
"uninterpretedOption",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\MessageOptions to default values
@param MessageOptions $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MessageOptions",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L98-L108
|
234,137
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
|
MessageOptionsMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->messageSetWireFormat)) {
hash_update($ctx, 'messageSetWireFormat');
hash_update($ctx, (string)$object->messageSetWireFormat);
}
if (isset($object->noStandardDescriptorAccessor)) {
hash_update($ctx, 'noStandardDescriptorAccessor');
hash_update($ctx, (string)$object->noStandardDescriptorAccessor);
}
if (isset($object->deprecated)) {
hash_update($ctx, 'deprecated');
hash_update($ctx, (string)$object->deprecated);
}
if (isset($object->mapEntry)) {
hash_update($ctx, 'mapEntry');
hash_update($ctx, (string)$object->mapEntry);
}
if (isset($object->uninterpretedOption)) {
hash_update($ctx, 'uninterpretedOption');
foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $v0) {
UninterpretedOptionMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
php
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->messageSetWireFormat)) {
hash_update($ctx, 'messageSetWireFormat');
hash_update($ctx, (string)$object->messageSetWireFormat);
}
if (isset($object->noStandardDescriptorAccessor)) {
hash_update($ctx, 'noStandardDescriptorAccessor');
hash_update($ctx, (string)$object->noStandardDescriptorAccessor);
}
if (isset($object->deprecated)) {
hash_update($ctx, 'deprecated');
hash_update($ctx, (string)$object->deprecated);
}
if (isset($object->mapEntry)) {
hash_update($ctx, 'mapEntry');
hash_update($ctx, (string)$object->mapEntry);
}
if (isset($object->uninterpretedOption)) {
hash_update($ctx, 'uninterpretedOption');
foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $v0) {
UninterpretedOptionMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrCtx",
")",
";",
"}",
"else",
"{",
"$",
"ctx",
"=",
"$",
"algoOrCtx",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"messageSetWireFormat",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'messageSetWireFormat'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"messageSetWireFormat",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"noStandardDescriptorAccessor",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'noStandardDescriptorAccessor'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"noStandardDescriptorAccessor",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"deprecated",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'deprecated'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"deprecated",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"mapEntry",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'mapEntry'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"mapEntry",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"uninterpretedOption",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'uninterpretedOption'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"uninterpretedOption",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"uninterpretedOption",
":",
"(",
"array",
")",
"$",
"object",
"->",
"uninterpretedOption",
"as",
"$",
"v0",
")",
"{",
"UninterpretedOptionMeta",
"::",
"hash",
"(",
"$",
"v0",
",",
"$",
"ctx",
")",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\MessageOptions
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MessageOptions"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L120-L160
|
234,138
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php
|
MessageOptionsMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->messageSetWireFormat) && ($filter === null || isset($filter['messageSetWireFormat']))) {
$output .= "\x08";
$output .= Binary::encodeVarint((int)$object->messageSetWireFormat);
}
if (isset($object->noStandardDescriptorAccessor) && ($filter === null || isset($filter['noStandardDescriptorAccessor']))) {
$output .= "\x10";
$output .= Binary::encodeVarint((int)$object->noStandardDescriptorAccessor);
}
if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) {
$output .= "\x18";
$output .= Binary::encodeVarint((int)$object->deprecated);
}
if (isset($object->mapEntry) && ($filter === null || isset($filter['mapEntry']))) {
$output .= "\x38";
$output .= Binary::encodeVarint((int)$object->mapEntry);
}
if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) {
foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) {
$output .= "\xba\x3e";
$buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->messageSetWireFormat) && ($filter === null || isset($filter['messageSetWireFormat']))) {
$output .= "\x08";
$output .= Binary::encodeVarint((int)$object->messageSetWireFormat);
}
if (isset($object->noStandardDescriptorAccessor) && ($filter === null || isset($filter['noStandardDescriptorAccessor']))) {
$output .= "\x10";
$output .= Binary::encodeVarint((int)$object->noStandardDescriptorAccessor);
}
if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) {
$output .= "\x18";
$output .= Binary::encodeVarint((int)$object->deprecated);
}
if (isset($object->mapEntry) && ($filter === null || isset($filter['mapEntry']))) {
$output .= "\x38";
$output .= Binary::encodeVarint((int)$object->mapEntry);
}
if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) {
foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) {
$output .= "\xba\x3e";
$buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"messageSetWireFormat",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'messageSetWireFormat'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x08\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"(",
"int",
")",
"$",
"object",
"->",
"messageSetWireFormat",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"noStandardDescriptorAccessor",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'noStandardDescriptorAccessor'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x10\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"(",
"int",
")",
"$",
"object",
"->",
"noStandardDescriptorAccessor",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"deprecated",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'deprecated'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x18\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"(",
"int",
")",
"$",
"object",
"->",
"deprecated",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"mapEntry",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'mapEntry'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x38\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"(",
"int",
")",
"$",
"object",
"->",
"mapEntry",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"uninterpretedOption",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'uninterpretedOption'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"uninterpretedOption",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"uninterpretedOption",
":",
"(",
"array",
")",
"$",
"object",
"->",
"uninterpretedOption",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\xba\\x3e\"",
";",
"$",
"buffer",
"=",
"UninterpretedOptionMeta",
"::",
"toProtobuf",
"(",
"$",
"v",
",",
"$",
"filter",
"===",
"null",
"?",
"null",
":",
"$",
"filter",
"[",
"'uninterpretedOption'",
"]",
")",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"buffer",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\MessageOptions to Protocol Buffers message.
@param MessageOptions $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MessageOptions",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MessageOptionsMeta.php#L265-L299
|
234,139
|
scherersoftware/cake-model-history
|
src/Model/Entity/ModelHistory.php
|
ModelHistory._getData
|
protected function _getData(array $data): array
{
// Stringify empty values
if (!empty($data)) {
foreach ($data as $fieldName => $value) {
$data[$fieldName] = $this->_stringifyEmptyValue($value);
}
}
return $data;
}
|
php
|
protected function _getData(array $data): array
{
// Stringify empty values
if (!empty($data)) {
foreach ($data as $fieldName => $value) {
$data[$fieldName] = $this->_stringifyEmptyValue($value);
}
}
return $data;
}
|
[
"protected",
"function",
"_getData",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"// Stringify empty values",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"fieldName",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"_stringifyEmptyValue",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
getter for data
@param array $data data
@return array
|
[
"getter",
"for",
"data"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Entity/ModelHistory.php#L46-L56
|
234,140
|
scherersoftware/cake-model-history
|
src/Model/Entity/ModelHistory.php
|
ModelHistory.getContextTypes
|
public static function getContextTypes(): array
{
return [
self::CONTEXT_TYPE_CONTROLLER => __d('model_history', 'context.type.controller'),
self::CONTEXT_TYPE_SHELL => __d('model_history', 'context.type.shell'),
self::CONTEXT_TYPE_SLUG => __d('model_history', 'context.type.slug')
];
}
|
php
|
public static function getContextTypes(): array
{
return [
self::CONTEXT_TYPE_CONTROLLER => __d('model_history', 'context.type.controller'),
self::CONTEXT_TYPE_SHELL => __d('model_history', 'context.type.shell'),
self::CONTEXT_TYPE_SLUG => __d('model_history', 'context.type.slug')
];
}
|
[
"public",
"static",
"function",
"getContextTypes",
"(",
")",
":",
"array",
"{",
"return",
"[",
"self",
"::",
"CONTEXT_TYPE_CONTROLLER",
"=>",
"__d",
"(",
"'model_history'",
",",
"'context.type.controller'",
")",
",",
"self",
"::",
"CONTEXT_TYPE_SHELL",
"=>",
"__d",
"(",
"'model_history'",
",",
"'context.type.shell'",
")",
",",
"self",
"::",
"CONTEXT_TYPE_SLUG",
"=>",
"__d",
"(",
"'model_history'",
",",
"'context.type.slug'",
")",
"]",
";",
"}"
] |
Retrieve available context types
@return array
|
[
"Retrieve",
"available",
"context",
"types"
] |
4dceac1cc7db0e6d443750dd9d76b960df385931
|
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Entity/ModelHistory.php#L80-L87
|
234,141
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php
|
ClassWithVarintPropertyMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithVarintProperty();
case 1:
return new ClassWithVarintProperty(func_get_arg(0));
case 2:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithVarintProperty();
case 1:
return new ClassWithVarintProperty(func_get_arg(0));
case 2:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithVarintProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"ClassWithVarintProperty",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithVarintProperty
@throws \InvalidArgumentException
@return ClassWithVarintProperty
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithVarintProperty"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php#L66-L90
|
234,142
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php
|
ClassWithVarintPropertyMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->x) && ($filter === null || isset($filter['x']))) {
$output .= "\x08";
$output .= Binary::encodeVarint($object->x);
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->x) && ($filter === null || isset($filter['x']))) {
$output .= "\x08";
$output .= Binary::encodeVarint($object->x);
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"x",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'x'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x08\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"object",
"->",
"x",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Skrz\Meta\Fixtures\Protobuf\ClassWithVarintProperty to Protocol Buffers message.
@param ClassWithVarintProperty $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithVarintProperty",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithVarintPropertyMeta.php#L387-L397
|
234,143
|
joetannenbaum/phpushbullet
|
src/PHPushbullet.php
|
PHPushbullet.devices
|
public function devices()
{
if (empty($this->all_devices)) {
$response = $this->fromJson($this->api->get('devices'));
$this->all_devices = array_map(function ($device) {
return new Device($device);
}, $response['devices']);
}
return $this->all_devices;
}
|
php
|
public function devices()
{
if (empty($this->all_devices)) {
$response = $this->fromJson($this->api->get('devices'));
$this->all_devices = array_map(function ($device) {
return new Device($device);
}, $response['devices']);
}
return $this->all_devices;
}
|
[
"public",
"function",
"devices",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"all_devices",
")",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"fromJson",
"(",
"$",
"this",
"->",
"api",
"->",
"get",
"(",
"'devices'",
")",
")",
";",
"$",
"this",
"->",
"all_devices",
"=",
"array_map",
"(",
"function",
"(",
"$",
"device",
")",
"{",
"return",
"new",
"Device",
"(",
"$",
"device",
")",
";",
"}",
",",
"$",
"response",
"[",
"'devices'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"all_devices",
";",
"}"
] |
Get a list of all of the devices available
@return array
|
[
"Get",
"a",
"list",
"of",
"all",
"of",
"the",
"devices",
"available"
] |
df138ebb3adebcddade282be478c0d2d6ebffb3e
|
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L69-L80
|
234,144
|
joetannenbaum/phpushbullet
|
src/PHPushbullet.php
|
PHPushbullet.all
|
public function all()
{
foreach ($this->devices() as $device) {
if ($device->pushable == true) {
$this->devices[] = $device->iden;
}
}
return $this;
}
|
php
|
public function all()
{
foreach ($this->devices() as $device) {
if ($device->pushable == true) {
$this->devices[] = $device->iden;
}
}
return $this;
}
|
[
"public",
"function",
"all",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"devices",
"(",
")",
"as",
"$",
"device",
")",
"{",
"if",
"(",
"$",
"device",
"->",
"pushable",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"devices",
"[",
"]",
"=",
"$",
"device",
"->",
"iden",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set all of the devices for the current push
@return \PHPushbullet\PHPushbullet
|
[
"Set",
"all",
"of",
"the",
"devices",
"for",
"the",
"current",
"push"
] |
df138ebb3adebcddade282be478c0d2d6ebffb3e
|
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L130-L139
|
234,145
|
joetannenbaum/phpushbullet
|
src/PHPushbullet.php
|
PHPushbullet.push
|
public function push($request)
{
if (empty($this->devices) && empty($this->users) && empty($this->channels)) {
throw new \Exception('You must specify something to push to.');
}
$responses = [];
$destinations = [
'devices' => 'device_iden',
'users' => 'email',
'channels' => 'channel_tag',
];
foreach ($destinations as $destination => $key) {
foreach ($this->{$destination} as $dest) {
$responses[] = $this->pushRequest($request, [$key => $dest]);
}
}
$this->devices = [];
$this->users = [];
$this->channels = [];
return $responses;
}
|
php
|
public function push($request)
{
if (empty($this->devices) && empty($this->users) && empty($this->channels)) {
throw new \Exception('You must specify something to push to.');
}
$responses = [];
$destinations = [
'devices' => 'device_iden',
'users' => 'email',
'channels' => 'channel_tag',
];
foreach ($destinations as $destination => $key) {
foreach ($this->{$destination} as $dest) {
$responses[] = $this->pushRequest($request, [$key => $dest]);
}
}
$this->devices = [];
$this->users = [];
$this->channels = [];
return $responses;
}
|
[
"public",
"function",
"push",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"devices",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"users",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"channels",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'You must specify something to push to.'",
")",
";",
"}",
"$",
"responses",
"=",
"[",
"]",
";",
"$",
"destinations",
"=",
"[",
"'devices'",
"=>",
"'device_iden'",
",",
"'users'",
"=>",
"'email'",
",",
"'channels'",
"=>",
"'channel_tag'",
",",
"]",
";",
"foreach",
"(",
"$",
"destinations",
"as",
"$",
"destination",
"=>",
"$",
"key",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"{",
"$",
"destination",
"}",
"as",
"$",
"dest",
")",
"{",
"$",
"responses",
"[",
"]",
"=",
"$",
"this",
"->",
"pushRequest",
"(",
"$",
"request",
",",
"[",
"$",
"key",
"=>",
"$",
"dest",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"devices",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"users",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"channels",
"=",
"[",
"]",
";",
"return",
"$",
"responses",
";",
"}"
] |
Actually send the push
@return array
|
[
"Actually",
"send",
"the",
"push"
] |
df138ebb3adebcddade282be478c0d2d6ebffb3e
|
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L146-L171
|
234,146
|
joetannenbaum/phpushbullet
|
src/PHPushbullet.php
|
PHPushbullet.pushRequest
|
protected function pushRequest($request, $merge)
{
$request = array_merge($request, $merge);
$response = $this->api->post('pushes', ['json' => $request]);
return $this->fromJson($response);
}
|
php
|
protected function pushRequest($request, $merge)
{
$request = array_merge($request, $merge);
$response = $this->api->post('pushes', ['json' => $request]);
return $this->fromJson($response);
}
|
[
"protected",
"function",
"pushRequest",
"(",
"$",
"request",
",",
"$",
"merge",
")",
"{",
"$",
"request",
"=",
"array_merge",
"(",
"$",
"request",
",",
"$",
"merge",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"api",
"->",
"post",
"(",
"'pushes'",
",",
"[",
"'json'",
"=>",
"$",
"request",
"]",
")",
";",
"return",
"$",
"this",
"->",
"fromJson",
"(",
"$",
"response",
")",
";",
"}"
] |
Create push request and... push it
@param array $request
@param array $merge
@return array
|
[
"Create",
"push",
"request",
"and",
"...",
"push",
"it"
] |
df138ebb3adebcddade282be478c0d2d6ebffb3e
|
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L186-L192
|
234,147
|
joetannenbaum/phpushbullet
|
src/PHPushbullet.php
|
PHPushbullet.getDeviceIden
|
protected function getDeviceIden($device)
{
foreach ($this->devices() as $available_device) {
foreach (['iden', 'nickname'] as $field) {
if ($available_device->$field == $device) {
return $available_device->iden;
}
}
}
return false;
}
|
php
|
protected function getDeviceIden($device)
{
foreach ($this->devices() as $available_device) {
foreach (['iden', 'nickname'] as $field) {
if ($available_device->$field == $device) {
return $available_device->iden;
}
}
}
return false;
}
|
[
"protected",
"function",
"getDeviceIden",
"(",
"$",
"device",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"devices",
"(",
")",
"as",
"$",
"available_device",
")",
"{",
"foreach",
"(",
"[",
"'iden'",
",",
"'nickname'",
"]",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"available_device",
"->",
"$",
"field",
"==",
"$",
"device",
")",
"{",
"return",
"$",
"available_device",
"->",
"iden",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get the `iden` for the device by either the iden or nickname
@param string $device
@return mixed (boolean|string)
|
[
"Get",
"the",
"iden",
"for",
"the",
"device",
"by",
"either",
"the",
"iden",
"or",
"nickname"
] |
df138ebb3adebcddade282be478c0d2d6ebffb3e
|
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/PHPushbullet.php#L201-L212
|
234,148
|
fab2s/NodalFlow
|
src/Flows/FlowMap.php
|
FlowMap.getStats
|
public function getStats()
{
$this->resetTotals();
foreach ($this->flow->getNodes() as $node) {
$nodeMap = $this->nodeMap[$node->getId()];
foreach ($this->incrementTotals as $srcKey => $totalKey) {
if (isset($nodeMap[$srcKey])) {
$this->flowStats[$totalKey] += $nodeMap[$srcKey];
}
}
if ($node instanceof BranchNodeInterface) {
$childFlowId = $node->getPayload()->getId();
$this->flowStats['branches'][$childFlowId] = $node->getPayload()->getStats();
foreach ($this->incrementTotals as $srcKey => $totalKey) {
if (isset($this->flowStats['branches'][$childFlowId][$totalKey])) {
$this->flowStats[$totalKey] += $this->flowStats['branches'][$childFlowId][$totalKey];
}
}
}
}
$flowStatus = $this->flow->getFlowStatus();
if ($flowStatus !== null) {
$this->flowStats['flow_status'] = $flowStatus->getStatus();
}
return $this->flowStats;
}
|
php
|
public function getStats()
{
$this->resetTotals();
foreach ($this->flow->getNodes() as $node) {
$nodeMap = $this->nodeMap[$node->getId()];
foreach ($this->incrementTotals as $srcKey => $totalKey) {
if (isset($nodeMap[$srcKey])) {
$this->flowStats[$totalKey] += $nodeMap[$srcKey];
}
}
if ($node instanceof BranchNodeInterface) {
$childFlowId = $node->getPayload()->getId();
$this->flowStats['branches'][$childFlowId] = $node->getPayload()->getStats();
foreach ($this->incrementTotals as $srcKey => $totalKey) {
if (isset($this->flowStats['branches'][$childFlowId][$totalKey])) {
$this->flowStats[$totalKey] += $this->flowStats['branches'][$childFlowId][$totalKey];
}
}
}
}
$flowStatus = $this->flow->getFlowStatus();
if ($flowStatus !== null) {
$this->flowStats['flow_status'] = $flowStatus->getStatus();
}
return $this->flowStats;
}
|
[
"public",
"function",
"getStats",
"(",
")",
"{",
"$",
"this",
"->",
"resetTotals",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"flow",
"->",
"getNodes",
"(",
")",
"as",
"$",
"node",
")",
"{",
"$",
"nodeMap",
"=",
"$",
"this",
"->",
"nodeMap",
"[",
"$",
"node",
"->",
"getId",
"(",
")",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"incrementTotals",
"as",
"$",
"srcKey",
"=>",
"$",
"totalKey",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"nodeMap",
"[",
"$",
"srcKey",
"]",
")",
")",
"{",
"$",
"this",
"->",
"flowStats",
"[",
"$",
"totalKey",
"]",
"+=",
"$",
"nodeMap",
"[",
"$",
"srcKey",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"node",
"instanceof",
"BranchNodeInterface",
")",
"{",
"$",
"childFlowId",
"=",
"$",
"node",
"->",
"getPayload",
"(",
")",
"->",
"getId",
"(",
")",
";",
"$",
"this",
"->",
"flowStats",
"[",
"'branches'",
"]",
"[",
"$",
"childFlowId",
"]",
"=",
"$",
"node",
"->",
"getPayload",
"(",
")",
"->",
"getStats",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"incrementTotals",
"as",
"$",
"srcKey",
"=>",
"$",
"totalKey",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"flowStats",
"[",
"'branches'",
"]",
"[",
"$",
"childFlowId",
"]",
"[",
"$",
"totalKey",
"]",
")",
")",
"{",
"$",
"this",
"->",
"flowStats",
"[",
"$",
"totalKey",
"]",
"+=",
"$",
"this",
"->",
"flowStats",
"[",
"'branches'",
"]",
"[",
"$",
"childFlowId",
"]",
"[",
"$",
"totalKey",
"]",
";",
"}",
"}",
"}",
"}",
"$",
"flowStatus",
"=",
"$",
"this",
"->",
"flow",
"->",
"getFlowStatus",
"(",
")",
";",
"if",
"(",
"$",
"flowStatus",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"flowStats",
"[",
"'flow_status'",
"]",
"=",
"$",
"flowStatus",
"->",
"getStatus",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"flowStats",
";",
"}"
] |
Get the latest Node stats
@return array<string,integer|string>
|
[
"Get",
"the",
"latest",
"Node",
"stats"
] |
da5d458ffea3e6e954d7ee734f938f4be5e46728
|
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L254-L282
|
234,149
|
fab2s/NodalFlow
|
src/Flows/FlowMap.php
|
FlowMap.resetNodeStats
|
public function resetNodeStats()
{
foreach ($this->nodeMap as &$nodeStat) {
foreach ($this->nodeIncrements as $key => $value) {
if (isset($nodeStat[$key])) {
$nodeStat[$key] = $value;
}
}
}
return $this;
}
|
php
|
public function resetNodeStats()
{
foreach ($this->nodeMap as &$nodeStat) {
foreach ($this->nodeIncrements as $key => $value) {
if (isset($nodeStat[$key])) {
$nodeStat[$key] = $value;
}
}
}
return $this;
}
|
[
"public",
"function",
"resetNodeStats",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodeMap",
"as",
"&",
"$",
"nodeStat",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodeIncrements",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"nodeStat",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"nodeStat",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Resets Nodes stats, can be used prior to Flow's re-exec
@return $this
|
[
"Resets",
"Nodes",
"stats",
"can",
"be",
"used",
"prior",
"to",
"Flow",
"s",
"re",
"-",
"exec"
] |
da5d458ffea3e6e954d7ee734f938f4be5e46728
|
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L314-L325
|
234,150
|
fab2s/NodalFlow
|
src/Flows/FlowMap.php
|
FlowMap.duration
|
public function duration($seconds)
{
$result = [
'hour' => (int) floor($seconds / 3600),
'min' => (int) floor(($seconds / 60) % 60),
'sec' => $seconds % 60,
'ms' => (int) round(\fmod($seconds, 1) * 1000),
];
$duration = '';
foreach ($result as $unit => $value) {
if (!empty($value) || $unit === 'ms') {
$duration .= $value . "$unit ";
}
}
$result['duration'] = trim($duration);
return $result;
}
|
php
|
public function duration($seconds)
{
$result = [
'hour' => (int) floor($seconds / 3600),
'min' => (int) floor(($seconds / 60) % 60),
'sec' => $seconds % 60,
'ms' => (int) round(\fmod($seconds, 1) * 1000),
];
$duration = '';
foreach ($result as $unit => $value) {
if (!empty($value) || $unit === 'ms') {
$duration .= $value . "$unit ";
}
}
$result['duration'] = trim($duration);
return $result;
}
|
[
"public",
"function",
"duration",
"(",
"$",
"seconds",
")",
"{",
"$",
"result",
"=",
"[",
"'hour'",
"=>",
"(",
"int",
")",
"floor",
"(",
"$",
"seconds",
"/",
"3600",
")",
",",
"'min'",
"=>",
"(",
"int",
")",
"floor",
"(",
"(",
"$",
"seconds",
"/",
"60",
")",
"%",
"60",
")",
",",
"'sec'",
"=>",
"$",
"seconds",
"%",
"60",
",",
"'ms'",
"=>",
"(",
"int",
")",
"round",
"(",
"\\",
"fmod",
"(",
"$",
"seconds",
",",
"1",
")",
"*",
"1000",
")",
",",
"]",
";",
"$",
"duration",
"=",
"''",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"unit",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
"||",
"$",
"unit",
"===",
"'ms'",
")",
"{",
"$",
"duration",
".=",
"$",
"value",
".",
"\"$unit \"",
";",
"}",
"}",
"$",
"result",
"[",
"'duration'",
"]",
"=",
"trim",
"(",
"$",
"duration",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Computes a human readable duration string from floating seconds
@param float $seconds
@return array<string,integer|string>
|
[
"Computes",
"a",
"human",
"readable",
"duration",
"string",
"from",
"floating",
"seconds"
] |
da5d458ffea3e6e954d7ee734f938f4be5e46728
|
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowMap.php#L334-L353
|
234,151
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
|
FieldDescriptorProtoMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new FieldDescriptorProto();
case 1:
return new FieldDescriptorProto(func_get_arg(0));
case 2:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new FieldDescriptorProto();
case 1:
return new FieldDescriptorProto(func_get_arg(0));
case 2:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new FieldDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"FieldDescriptorProto",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\FieldDescriptorProto
@throws \InvalidArgumentException
@return FieldDescriptorProto
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"FieldDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L66-L90
|
234,152
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
|
FieldDescriptorProtoMeta.reset
|
public static function reset($object)
{
if (!($object instanceof FieldDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FieldDescriptorProto.');
}
$object->name = NULL;
$object->number = NULL;
$object->label = NULL;
$object->type = NULL;
$object->typeName = NULL;
$object->extendee = NULL;
$object->defaultValue = NULL;
$object->oneofIndex = NULL;
$object->jsonName = NULL;
$object->options = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof FieldDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FieldDescriptorProto.');
}
$object->name = NULL;
$object->number = NULL;
$object->label = NULL;
$object->type = NULL;
$object->typeName = NULL;
$object->extendee = NULL;
$object->defaultValue = NULL;
$object->oneofIndex = NULL;
$object->jsonName = NULL;
$object->options = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"FieldDescriptorProto",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\FieldDescriptorProto.'",
")",
";",
"}",
"$",
"object",
"->",
"name",
"=",
"NULL",
";",
"$",
"object",
"->",
"number",
"=",
"NULL",
";",
"$",
"object",
"->",
"label",
"=",
"NULL",
";",
"$",
"object",
"->",
"type",
"=",
"NULL",
";",
"$",
"object",
"->",
"typeName",
"=",
"NULL",
";",
"$",
"object",
"->",
"extendee",
"=",
"NULL",
";",
"$",
"object",
"->",
"defaultValue",
"=",
"NULL",
";",
"$",
"object",
"->",
"oneofIndex",
"=",
"NULL",
";",
"$",
"object",
"->",
"jsonName",
"=",
"NULL",
";",
"$",
"object",
"->",
"options",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\FieldDescriptorProto to default values
@param FieldDescriptorProto $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"FieldDescriptorProto",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L103-L118
|
234,153
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php
|
FieldDescriptorProtoMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
hash_update($ctx, (string)$object->name);
}
if (isset($object->number)) {
hash_update($ctx, 'number');
hash_update($ctx, (string)$object->number);
}
if (isset($object->label)) {
hash_update($ctx, 'label');
hash_update($ctx, (string)$object->label);
}
if (isset($object->type)) {
hash_update($ctx, 'type');
hash_update($ctx, (string)$object->type);
}
if (isset($object->typeName)) {
hash_update($ctx, 'typeName');
hash_update($ctx, (string)$object->typeName);
}
if (isset($object->extendee)) {
hash_update($ctx, 'extendee');
hash_update($ctx, (string)$object->extendee);
}
if (isset($object->defaultValue)) {
hash_update($ctx, 'defaultValue');
hash_update($ctx, (string)$object->defaultValue);
}
if (isset($object->oneofIndex)) {
hash_update($ctx, 'oneofIndex');
hash_update($ctx, (string)$object->oneofIndex);
}
if (isset($object->jsonName)) {
hash_update($ctx, 'jsonName');
hash_update($ctx, (string)$object->jsonName);
}
if (isset($object->options)) {
hash_update($ctx, 'options');
FieldOptionsMeta::hash($object->options, $ctx);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
php
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
hash_update($ctx, (string)$object->name);
}
if (isset($object->number)) {
hash_update($ctx, 'number');
hash_update($ctx, (string)$object->number);
}
if (isset($object->label)) {
hash_update($ctx, 'label');
hash_update($ctx, (string)$object->label);
}
if (isset($object->type)) {
hash_update($ctx, 'type');
hash_update($ctx, (string)$object->type);
}
if (isset($object->typeName)) {
hash_update($ctx, 'typeName');
hash_update($ctx, (string)$object->typeName);
}
if (isset($object->extendee)) {
hash_update($ctx, 'extendee');
hash_update($ctx, (string)$object->extendee);
}
if (isset($object->defaultValue)) {
hash_update($ctx, 'defaultValue');
hash_update($ctx, (string)$object->defaultValue);
}
if (isset($object->oneofIndex)) {
hash_update($ctx, 'oneofIndex');
hash_update($ctx, (string)$object->oneofIndex);
}
if (isset($object->jsonName)) {
hash_update($ctx, 'jsonName');
hash_update($ctx, (string)$object->jsonName);
}
if (isset($object->options)) {
hash_update($ctx, 'options');
FieldOptionsMeta::hash($object->options, $ctx);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrCtx",
")",
";",
"}",
"else",
"{",
"$",
"ctx",
"=",
"$",
"algoOrCtx",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"name",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'name'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"name",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"number",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'number'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"number",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"label",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'label'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"label",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"type",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'type'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"type",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"typeName",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'typeName'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"typeName",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"extendee",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'extendee'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"extendee",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"defaultValue",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'defaultValue'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"defaultValue",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"oneofIndex",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'oneofIndex'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"oneofIndex",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"jsonName",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'jsonName'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"jsonName",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"options",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'options'",
")",
";",
"FieldOptionsMeta",
"::",
"hash",
"(",
"$",
"object",
"->",
"options",
",",
"$",
"ctx",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\FieldDescriptorProto
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"FieldDescriptorProto"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FieldDescriptorProtoMeta.php#L130-L193
|
234,154
|
wardrobecms/core-archived
|
src/Wardrobe/Core/Controllers/HomeController.php
|
HomeController.index
|
public function index()
{
$posts = $this->posts->active(Config::get('core::wardrobe.per_page'));
return View::make($this->theme.'.index', compact('posts'));
}
|
php
|
public function index()
{
$posts = $this->posts->active(Config::get('core::wardrobe.per_page'));
return View::make($this->theme.'.index', compact('posts'));
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"posts",
"=",
"$",
"this",
"->",
"posts",
"->",
"active",
"(",
"Config",
"::",
"get",
"(",
"'core::wardrobe.per_page'",
")",
")",
";",
"return",
"View",
"::",
"make",
"(",
"$",
"this",
"->",
"theme",
".",
"'.index'",
",",
"compact",
"(",
"'posts'",
")",
")",
";",
"}"
] |
Get the Wardrobe index.
@return Response
|
[
"Get",
"the",
"Wardrobe",
"index",
"."
] |
5c0836ea2e6885a428c852dc392073f2a2541c71
|
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/HomeController.php#L34-L39
|
234,155
|
scherersoftware/cake-notifications
|
src/Transport/Transport.php
|
Transport._performCallback
|
protected static function _performCallback(array $items, Notification &$notificationInstance = null)
{
$success = false;
foreach ($items as $item) {
if (!isset($item['class']) || !is_callable($item['class'])) {
$class = $item['class'];
if (is_array($item['class'])) {
$class = implode($item['class']);
}
throw new \InvalidArgumentException("{$class} is not callable");
}
$args = [];
if (isset($item['args']) && is_array($item['args'])) {
$args = $item['args'];
}
if (is_array($item['class']) && count($item['class']) == 2) {
$className = $item['class'][0];
$methodName = $item['class'][1];
$instance = new $className;
$success = call_user_func_array([$instance, $methodName], $args);
} elseif (is_string($item['class'])) {
$success = call_user_func_array($item['class'], $args);
}
if (is_callable($success)) {
$success($notificationInstance);
}
}
}
|
php
|
protected static function _performCallback(array $items, Notification &$notificationInstance = null)
{
$success = false;
foreach ($items as $item) {
if (!isset($item['class']) || !is_callable($item['class'])) {
$class = $item['class'];
if (is_array($item['class'])) {
$class = implode($item['class']);
}
throw new \InvalidArgumentException("{$class} is not callable");
}
$args = [];
if (isset($item['args']) && is_array($item['args'])) {
$args = $item['args'];
}
if (is_array($item['class']) && count($item['class']) == 2) {
$className = $item['class'][0];
$methodName = $item['class'][1];
$instance = new $className;
$success = call_user_func_array([$instance, $methodName], $args);
} elseif (is_string($item['class'])) {
$success = call_user_func_array($item['class'], $args);
}
if (is_callable($success)) {
$success($notificationInstance);
}
}
}
|
[
"protected",
"static",
"function",
"_performCallback",
"(",
"array",
"$",
"items",
",",
"Notification",
"&",
"$",
"notificationInstance",
"=",
"null",
")",
"{",
"$",
"success",
"=",
"false",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
"||",
"!",
"is_callable",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"item",
"[",
"'class'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"implode",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"{$class} is not callable\"",
")",
";",
"}",
"$",
"args",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'args'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"item",
"[",
"'args'",
"]",
")",
")",
"{",
"$",
"args",
"=",
"$",
"item",
"[",
"'args'",
"]",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
"&&",
"count",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
"==",
"2",
")",
"{",
"$",
"className",
"=",
"$",
"item",
"[",
"'class'",
"]",
"[",
"0",
"]",
";",
"$",
"methodName",
"=",
"$",
"item",
"[",
"'class'",
"]",
"[",
"1",
"]",
";",
"$",
"instance",
"=",
"new",
"$",
"className",
";",
"$",
"success",
"=",
"call_user_func_array",
"(",
"[",
"$",
"instance",
",",
"$",
"methodName",
"]",
",",
"$",
"args",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"item",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"success",
"=",
"call_user_func_array",
"(",
"$",
"item",
"[",
"'class'",
"]",
",",
"$",
"args",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"success",
")",
")",
"{",
"$",
"success",
"(",
"$",
"notificationInstance",
")",
";",
"}",
"}",
"}"
] |
Performs the before- or after send callback of the notification
@param array $items Contains the class and function name and optional, function params
@param Notification $notificationInstance Reference to the notification instance for a possible callbacks callback
@throws InvalidArgumentException
|
[
"Performs",
"the",
"before",
"-",
"or",
"after",
"send",
"callback",
"of",
"the",
"notification"
] |
916fa8d60dbe94c0b146339eed147b1a1f2a1902
|
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Transport/Transport.php#L16-L45
|
234,156
|
MW-Peachy/Peachy
|
Includes/User.php
|
User.create
|
public function create( $password = null, $email = null, $mailpassword = false, $reason = null, $realname = null, $language = null, $domain = null ) {
global $pgNotag, $pgTag;
pecho( "Creating user account " . $this->username . "...\n\n", PECHO_NOTICE );
try{
$this->preEditChecks( "Create" );
} catch( EditError $e ){
pecho( "Error: $e\n\n", PECHO_FATAL );
return false;
}
$token = $this->wiki->apiQuery(
array(
'action' => 'createaccount',
'name' => $this->username
), true
);
$token = $token['createaccount']['token'];
$apiArray = array(
'action' => 'createaccount',
'token' => $token,
'name' => $this->username
);
if( !$password == null ) $apiArray['password'] = $password;
if( !$email == null ) $apiArray['email'] = $email;
if( !$realname == null ) $apiArray['realname'] = $realname;
if( !$domain == null ) $apiArray['domain'] = $domain;
if( !$reason == null ) {
if( !$pgNotag ) $reason .= $pgTag;
$apiArray['reason'] = $reason;
}
if( !$language == null ) $apiArray['language'] = $language;
if( $this->exists() ) {
pecho( "Error: User account already exists.\n\n", PECHO_ERROR );
return false;
}
if( $password == null && !$mailpassword ) {
pecho( "Error: neither a password or the mailpassword have been set.\n\n", PECHO_ERROR );
return false;
}
if( $mailpassword ) {
if( $email == null ) {
pecho( "Error: Email not specified.\n\n", PECHO_ERROR );
return false;
} else $apiArray['mailpassword'] = 'yes';
} else {
if( is_null( $password ) ) {
pecho( "Error: No password specified.\n\n", PECHO_ERROR );
return false;
}
}
$result = $this->wiki->apiQuery( $apiArray, true );
$this->__construct( $this->wiki, $this->username );
if( isset( $result['createaccount']['result'] ) ) {
if( $result['createaccount']['result'] == 'success' ) {
return true;
} else {
pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL );
return false;
}
} else {
pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL );
return false;
}
}
|
php
|
public function create( $password = null, $email = null, $mailpassword = false, $reason = null, $realname = null, $language = null, $domain = null ) {
global $pgNotag, $pgTag;
pecho( "Creating user account " . $this->username . "...\n\n", PECHO_NOTICE );
try{
$this->preEditChecks( "Create" );
} catch( EditError $e ){
pecho( "Error: $e\n\n", PECHO_FATAL );
return false;
}
$token = $this->wiki->apiQuery(
array(
'action' => 'createaccount',
'name' => $this->username
), true
);
$token = $token['createaccount']['token'];
$apiArray = array(
'action' => 'createaccount',
'token' => $token,
'name' => $this->username
);
if( !$password == null ) $apiArray['password'] = $password;
if( !$email == null ) $apiArray['email'] = $email;
if( !$realname == null ) $apiArray['realname'] = $realname;
if( !$domain == null ) $apiArray['domain'] = $domain;
if( !$reason == null ) {
if( !$pgNotag ) $reason .= $pgTag;
$apiArray['reason'] = $reason;
}
if( !$language == null ) $apiArray['language'] = $language;
if( $this->exists() ) {
pecho( "Error: User account already exists.\n\n", PECHO_ERROR );
return false;
}
if( $password == null && !$mailpassword ) {
pecho( "Error: neither a password or the mailpassword have been set.\n\n", PECHO_ERROR );
return false;
}
if( $mailpassword ) {
if( $email == null ) {
pecho( "Error: Email not specified.\n\n", PECHO_ERROR );
return false;
} else $apiArray['mailpassword'] = 'yes';
} else {
if( is_null( $password ) ) {
pecho( "Error: No password specified.\n\n", PECHO_ERROR );
return false;
}
}
$result = $this->wiki->apiQuery( $apiArray, true );
$this->__construct( $this->wiki, $this->username );
if( isset( $result['createaccount']['result'] ) ) {
if( $result['createaccount']['result'] == 'success' ) {
return true;
} else {
pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL );
return false;
}
} else {
pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL );
return false;
}
}
|
[
"public",
"function",
"create",
"(",
"$",
"password",
"=",
"null",
",",
"$",
"email",
"=",
"null",
",",
"$",
"mailpassword",
"=",
"false",
",",
"$",
"reason",
"=",
"null",
",",
"$",
"realname",
"=",
"null",
",",
"$",
"language",
"=",
"null",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"global",
"$",
"pgNotag",
",",
"$",
"pgTag",
";",
"pecho",
"(",
"\"Creating user account \"",
".",
"$",
"this",
"->",
"username",
".",
"\"...\\n\\n\"",
",",
"PECHO_NOTICE",
")",
";",
"try",
"{",
"$",
"this",
"->",
"preEditChecks",
"(",
"\"Create\"",
")",
";",
"}",
"catch",
"(",
"EditError",
"$",
"e",
")",
"{",
"pecho",
"(",
"\"Error: $e\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"$",
"token",
"=",
"$",
"this",
"->",
"wiki",
"->",
"apiQuery",
"(",
"array",
"(",
"'action'",
"=>",
"'createaccount'",
",",
"'name'",
"=>",
"$",
"this",
"->",
"username",
")",
",",
"true",
")",
";",
"$",
"token",
"=",
"$",
"token",
"[",
"'createaccount'",
"]",
"[",
"'token'",
"]",
";",
"$",
"apiArray",
"=",
"array",
"(",
"'action'",
"=>",
"'createaccount'",
",",
"'token'",
"=>",
"$",
"token",
",",
"'name'",
"=>",
"$",
"this",
"->",
"username",
")",
";",
"if",
"(",
"!",
"$",
"password",
"==",
"null",
")",
"$",
"apiArray",
"[",
"'password'",
"]",
"=",
"$",
"password",
";",
"if",
"(",
"!",
"$",
"email",
"==",
"null",
")",
"$",
"apiArray",
"[",
"'email'",
"]",
"=",
"$",
"email",
";",
"if",
"(",
"!",
"$",
"realname",
"==",
"null",
")",
"$",
"apiArray",
"[",
"'realname'",
"]",
"=",
"$",
"realname",
";",
"if",
"(",
"!",
"$",
"domain",
"==",
"null",
")",
"$",
"apiArray",
"[",
"'domain'",
"]",
"=",
"$",
"domain",
";",
"if",
"(",
"!",
"$",
"reason",
"==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"pgNotag",
")",
"$",
"reason",
".=",
"$",
"pgTag",
";",
"$",
"apiArray",
"[",
"'reason'",
"]",
"=",
"$",
"reason",
";",
"}",
"if",
"(",
"!",
"$",
"language",
"==",
"null",
")",
"$",
"apiArray",
"[",
"'language'",
"]",
"=",
"$",
"language",
";",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
")",
")",
"{",
"pecho",
"(",
"\"Error: User account already exists.\\n\\n\"",
",",
"PECHO_ERROR",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"password",
"==",
"null",
"&&",
"!",
"$",
"mailpassword",
")",
"{",
"pecho",
"(",
"\"Error: neither a password or the mailpassword have been set.\\n\\n\"",
",",
"PECHO_ERROR",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"mailpassword",
")",
"{",
"if",
"(",
"$",
"email",
"==",
"null",
")",
"{",
"pecho",
"(",
"\"Error: Email not specified.\\n\\n\"",
",",
"PECHO_ERROR",
")",
";",
"return",
"false",
";",
"}",
"else",
"$",
"apiArray",
"[",
"'mailpassword'",
"]",
"=",
"'yes'",
";",
"}",
"else",
"{",
"if",
"(",
"is_null",
"(",
"$",
"password",
")",
")",
"{",
"pecho",
"(",
"\"Error: No password specified.\\n\\n\"",
",",
"PECHO_ERROR",
")",
";",
"return",
"false",
";",
"}",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"wiki",
"->",
"apiQuery",
"(",
"$",
"apiArray",
",",
"true",
")",
";",
"$",
"this",
"->",
"__construct",
"(",
"$",
"this",
"->",
"wiki",
",",
"$",
"this",
"->",
"username",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'createaccount'",
"]",
"[",
"'result'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"result",
"[",
"'createaccount'",
"]",
"[",
"'result'",
"]",
"==",
"'success'",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Create error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
"[",
"'createaccount'",
"]",
",",
"true",
")",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"pecho",
"(",
"\"Create error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
"[",
"'createaccount'",
"]",
",",
"true",
")",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Creates the account with the specified parameters
@access public
@param string $password Password (ignored if mailpassword is set). Default null.
@param string $email Email address of user (optional). Default null.
@param bool $mailpassword If set to true, a random password will be emailed to the user. Default false.
@param string $reason Optional reason for creating the account to be put in the logs. Default null.
@param string $realname Real name of user (optional). Default null.
@param bool $tboverride Override the title blacklist. Requires the tboverride right. Default false.
@param string $language Language code to set as default for the user (optional, defaults to content language). Default null.
@param string $domain Domain for external authentication (optional). Default null.
@return bool True on success, false otherwise
|
[
"Creates",
"the",
"account",
"with",
"the",
"specified",
"parameters"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L214-L285
|
234,157
|
MW-Peachy/Peachy
|
Includes/User.php
|
User.is_blocked
|
public function is_blocked( $force = false ) {
if( !$force && $this->blocked !== null ) {
return $this->blocked;
}
pecho( "Checking if {$this->username} is blocked...\n\n", PECHO_NORMAL );
$this->__construct( $this->wiki, $this->username );
return $this->blocked;
}
|
php
|
public function is_blocked( $force = false ) {
if( !$force && $this->blocked !== null ) {
return $this->blocked;
}
pecho( "Checking if {$this->username} is blocked...\n\n", PECHO_NORMAL );
$this->__construct( $this->wiki, $this->username );
return $this->blocked;
}
|
[
"public",
"function",
"is_blocked",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"force",
"&&",
"$",
"this",
"->",
"blocked",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"blocked",
";",
"}",
"pecho",
"(",
"\"Checking if {$this->username} is blocked...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"$",
"this",
"->",
"__construct",
"(",
"$",
"this",
"->",
"wiki",
",",
"$",
"this",
"->",
"username",
")",
";",
"return",
"$",
"this",
"->",
"blocked",
";",
"}"
] |
Returns whether or not the user is blocked
@access public
@param bool $force Whether or not to use the locally stored cache. Default false.
@return bool
|
[
"Returns",
"whether",
"or",
"not",
"the",
"user",
"is",
"blocked"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L294-L305
|
234,158
|
MW-Peachy/Peachy
|
Includes/User.php
|
User.unblock
|
public function unblock( $reason = null, $id = null ) {
global $pgNotag, $pgTag;
if( !in_array( 'block', $this->wiki->get_userrights() ) ) {
pecho( "User is not allowed to unblock users", PECHO_FATAL );
return false;
}
$token = $this->wiki->get_tokens();
if( !array_key_exists( 'block', $token ) ) return false;
$apiArr = array(
'action' => 'unblock',
'user' => $this->username,
'token' => $token['unblock'],
);
if( !is_null( $id ) ) {
$apiArr['id'] = $id;
unset( $apiArr['user'] );
}
if( !is_null( $reason ) ) {
if( !$pgNotag ) $reason .= $pgTag;
$apiArr['reason'] = $reason;
}
Hooks::runHook( 'StartUnblock', array( &$apiArr ) );
pecho( "Unblocking {$this->username}...\n\n", PECHO_NOTICE );
try{
$this->preEditChecks( "Unblock" );
} catch( EditError $e ){
pecho( "Error: $e\n\n", PECHO_FATAL );
return false;
}
$result = $this->wiki->apiQuery( $apiArr, true );
if( isset( $result['unblock'] ) ) {
if( isset( $result['unblock']['user'] ) ) {
$this->__construct( $this->wiki, $this->username );
return true;
} else {
pecho( "Unblock error...\n\n" . print_r( $result['unblock'], true ) . "\n\n", PECHO_FATAL );
return false;
}
} else {
pecho( "Unblock error...\n\n" . print_r( $result, true ), PECHO_FATAL );
return false;
}
}
|
php
|
public function unblock( $reason = null, $id = null ) {
global $pgNotag, $pgTag;
if( !in_array( 'block', $this->wiki->get_userrights() ) ) {
pecho( "User is not allowed to unblock users", PECHO_FATAL );
return false;
}
$token = $this->wiki->get_tokens();
if( !array_key_exists( 'block', $token ) ) return false;
$apiArr = array(
'action' => 'unblock',
'user' => $this->username,
'token' => $token['unblock'],
);
if( !is_null( $id ) ) {
$apiArr['id'] = $id;
unset( $apiArr['user'] );
}
if( !is_null( $reason ) ) {
if( !$pgNotag ) $reason .= $pgTag;
$apiArr['reason'] = $reason;
}
Hooks::runHook( 'StartUnblock', array( &$apiArr ) );
pecho( "Unblocking {$this->username}...\n\n", PECHO_NOTICE );
try{
$this->preEditChecks( "Unblock" );
} catch( EditError $e ){
pecho( "Error: $e\n\n", PECHO_FATAL );
return false;
}
$result = $this->wiki->apiQuery( $apiArr, true );
if( isset( $result['unblock'] ) ) {
if( isset( $result['unblock']['user'] ) ) {
$this->__construct( $this->wiki, $this->username );
return true;
} else {
pecho( "Unblock error...\n\n" . print_r( $result['unblock'], true ) . "\n\n", PECHO_FATAL );
return false;
}
} else {
pecho( "Unblock error...\n\n" . print_r( $result, true ), PECHO_FATAL );
return false;
}
}
|
[
"public",
"function",
"unblock",
"(",
"$",
"reason",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"global",
"$",
"pgNotag",
",",
"$",
"pgTag",
";",
"if",
"(",
"!",
"in_array",
"(",
"'block'",
",",
"$",
"this",
"->",
"wiki",
"->",
"get_userrights",
"(",
")",
")",
")",
"{",
"pecho",
"(",
"\"User is not allowed to unblock users\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"$",
"token",
"=",
"$",
"this",
"->",
"wiki",
"->",
"get_tokens",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'block'",
",",
"$",
"token",
")",
")",
"return",
"false",
";",
"$",
"apiArr",
"=",
"array",
"(",
"'action'",
"=>",
"'unblock'",
",",
"'user'",
"=>",
"$",
"this",
"->",
"username",
",",
"'token'",
"=>",
"$",
"token",
"[",
"'unblock'",
"]",
",",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
")",
")",
"{",
"$",
"apiArr",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"unset",
"(",
"$",
"apiArr",
"[",
"'user'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"reason",
")",
")",
"{",
"if",
"(",
"!",
"$",
"pgNotag",
")",
"$",
"reason",
".=",
"$",
"pgTag",
";",
"$",
"apiArr",
"[",
"'reason'",
"]",
"=",
"$",
"reason",
";",
"}",
"Hooks",
"::",
"runHook",
"(",
"'StartUnblock'",
",",
"array",
"(",
"&",
"$",
"apiArr",
")",
")",
";",
"pecho",
"(",
"\"Unblocking {$this->username}...\\n\\n\"",
",",
"PECHO_NOTICE",
")",
";",
"try",
"{",
"$",
"this",
"->",
"preEditChecks",
"(",
"\"Unblock\"",
")",
";",
"}",
"catch",
"(",
"EditError",
"$",
"e",
")",
"{",
"pecho",
"(",
"\"Error: $e\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"wiki",
"->",
"apiQuery",
"(",
"$",
"apiArr",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'unblock'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'unblock'",
"]",
"[",
"'user'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"__construct",
"(",
"$",
"this",
"->",
"wiki",
",",
"$",
"this",
"->",
"username",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Unblock error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
"[",
"'unblock'",
"]",
",",
"true",
")",
".",
"\"\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"pecho",
"(",
"\"Unblock error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
",",
"true",
")",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Unblocks the user, or a block ID
@access public
@param string $reason Reason for unblocking. Default null
@param int $id Block ID to unblock. Default null
@return bool
|
[
"Unblocks",
"the",
"user",
"or",
"a",
"block",
"ID"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L443-L494
|
234,159
|
MW-Peachy/Peachy
|
Includes/User.php
|
User.get_contribs
|
public function get_contribs( $mostrecentfirst = true, $limit = null ) {
if( !$this->exists ) return array();
$ucArray = array(
'_code' => 'uc',
'ucuser' => $this->username,
'action' => 'query',
'list' => 'usercontribs',
'_limit' => $limit,
);
if( $mostrecentfirst ) {
$ucArray['ucdir'] = "older";
} else {
$ucArray['ucdir'] = "newer";
}
$result = $this->wiki->listHandler( $ucArray );
pecho( "Getting list of contributions by {$this->username}...\n\n", PECHO_NORMAL );
return $result;
}
|
php
|
public function get_contribs( $mostrecentfirst = true, $limit = null ) {
if( !$this->exists ) return array();
$ucArray = array(
'_code' => 'uc',
'ucuser' => $this->username,
'action' => 'query',
'list' => 'usercontribs',
'_limit' => $limit,
);
if( $mostrecentfirst ) {
$ucArray['ucdir'] = "older";
} else {
$ucArray['ucdir'] = "newer";
}
$result = $this->wiki->listHandler( $ucArray );
pecho( "Getting list of contributions by {$this->username}...\n\n", PECHO_NORMAL );
return $result;
}
|
[
"public",
"function",
"get_contribs",
"(",
"$",
"mostrecentfirst",
"=",
"true",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
")",
"return",
"array",
"(",
")",
";",
"$",
"ucArray",
"=",
"array",
"(",
"'_code'",
"=>",
"'uc'",
",",
"'ucuser'",
"=>",
"$",
"this",
"->",
"username",
",",
"'action'",
"=>",
"'query'",
",",
"'list'",
"=>",
"'usercontribs'",
",",
"'_limit'",
"=>",
"$",
"limit",
",",
")",
";",
"if",
"(",
"$",
"mostrecentfirst",
")",
"{",
"$",
"ucArray",
"[",
"'ucdir'",
"]",
"=",
"\"older\"",
";",
"}",
"else",
"{",
"$",
"ucArray",
"[",
"'ucdir'",
"]",
"=",
"\"newer\"",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"wiki",
"->",
"listHandler",
"(",
"$",
"ucArray",
")",
";",
"pecho",
"(",
"\"Getting list of contributions by {$this->username}...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Returns a list of all user contributions
@access public
@param bool $mostrecentfirst Set to true to get the most recent edits first. Default true.
@param bool $limit Only get this many edits. Default null.
@return array Array, first level indexed, second level associative with keys user, pageid, revid, ns, title, timestamp, size and comment (edit summary).
|
[
"Returns",
"a",
"list",
"of",
"all",
"user",
"contributions"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L543-L565
|
234,160
|
MW-Peachy/Peachy
|
Includes/User.php
|
User.get_usergroups
|
public function get_usergroups( $force = false ) {
if( $force ) {
$uiRes = $this->wiki->apiQuery(
array(
'action' => 'query',
'list' => 'users',
'ususers' => $this->username,
'usprop' => 'groups'
)
);
$this->groups = $uiRes['query']['users'][0]['groups'];
}
return $this->groups;
}
|
php
|
public function get_usergroups( $force = false ) {
if( $force ) {
$uiRes = $this->wiki->apiQuery(
array(
'action' => 'query',
'list' => 'users',
'ususers' => $this->username,
'usprop' => 'groups'
)
);
$this->groups = $uiRes['query']['users'][0]['groups'];
}
return $this->groups;
}
|
[
"public",
"function",
"get_usergroups",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"force",
")",
"{",
"$",
"uiRes",
"=",
"$",
"this",
"->",
"wiki",
"->",
"apiQuery",
"(",
"array",
"(",
"'action'",
"=>",
"'query'",
",",
"'list'",
"=>",
"'users'",
",",
"'ususers'",
"=>",
"$",
"this",
"->",
"username",
",",
"'usprop'",
"=>",
"'groups'",
")",
")",
";",
"$",
"this",
"->",
"groups",
"=",
"$",
"uiRes",
"[",
"'query'",
"]",
"[",
"'users'",
"]",
"[",
"0",
"]",
"[",
"'groups'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"groups",
";",
"}"
] |
Returns the usergroups, NULL if user is IP.
@access public
@param bool force Force use of the API. Default false;
@return array
|
[
"Returns",
"the",
"usergroups",
"NULL",
"if",
"user",
"is",
"IP",
"."
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L584-L599
|
234,161
|
MW-Peachy/Peachy
|
Includes/User.php
|
User.email
|
public function email( $text = null, $subject = "Wikipedia Email", $ccme = false ) {
global $pgNotag;
if( !$this->has_email() ) {
pecho( "Cannot email {$this->username}, user has email disabled", PECHO_FATAL );
return false;
}
$tokens = $this->wiki->get_tokens();
if( !$pgNotag ) $text .= "\n\nPowered by Peachy " . PEACHYVERSION;
$editarray = array(
'action' => 'emailuser',
'target' => $this->username,
'token' => $tokens['email'],
'subject' => $subject,
'text' => $text
);
if( $ccme ) $editarray['ccme'] = 'yes';
Hooks::runHook( 'StartEmail', array( &$editarray ) );
pecho( "Emailing {$this->username}...\n\n", PECHO_NOTICE );
try{
$this->preEditChecks( "Email" );
} catch( EditError $e ){
pecho( "Error: $e\n\n", PECHO_FATAL );
return false;
}
$result = $this->wiki->apiQuery( $editarray, true );
if( isset( $result['error'] ) ) {
throw new EmailError( $result['error']['code'], $result['error']['info'] );
} elseif( isset( $result['emailuser'] ) ) {
if( $result['emailuser']['result'] == "Success" ) {
$this->__construct( $this->wiki, $this->username );
return true;
} else {
pecho( "Email error...\n\n" . print_r( $result['emailuser'], true ) . "\n\n", PECHO_FATAL );
return false;
}
} else {
pecho( "Email error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL );
return false;
}
}
|
php
|
public function email( $text = null, $subject = "Wikipedia Email", $ccme = false ) {
global $pgNotag;
if( !$this->has_email() ) {
pecho( "Cannot email {$this->username}, user has email disabled", PECHO_FATAL );
return false;
}
$tokens = $this->wiki->get_tokens();
if( !$pgNotag ) $text .= "\n\nPowered by Peachy " . PEACHYVERSION;
$editarray = array(
'action' => 'emailuser',
'target' => $this->username,
'token' => $tokens['email'],
'subject' => $subject,
'text' => $text
);
if( $ccme ) $editarray['ccme'] = 'yes';
Hooks::runHook( 'StartEmail', array( &$editarray ) );
pecho( "Emailing {$this->username}...\n\n", PECHO_NOTICE );
try{
$this->preEditChecks( "Email" );
} catch( EditError $e ){
pecho( "Error: $e\n\n", PECHO_FATAL );
return false;
}
$result = $this->wiki->apiQuery( $editarray, true );
if( isset( $result['error'] ) ) {
throw new EmailError( $result['error']['code'], $result['error']['info'] );
} elseif( isset( $result['emailuser'] ) ) {
if( $result['emailuser']['result'] == "Success" ) {
$this->__construct( $this->wiki, $this->username );
return true;
} else {
pecho( "Email error...\n\n" . print_r( $result['emailuser'], true ) . "\n\n", PECHO_FATAL );
return false;
}
} else {
pecho( "Email error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL );
return false;
}
}
|
[
"public",
"function",
"email",
"(",
"$",
"text",
"=",
"null",
",",
"$",
"subject",
"=",
"\"Wikipedia Email\"",
",",
"$",
"ccme",
"=",
"false",
")",
"{",
"global",
"$",
"pgNotag",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"has_email",
"(",
")",
")",
"{",
"pecho",
"(",
"\"Cannot email {$this->username}, user has email disabled\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"$",
"tokens",
"=",
"$",
"this",
"->",
"wiki",
"->",
"get_tokens",
"(",
")",
";",
"if",
"(",
"!",
"$",
"pgNotag",
")",
"$",
"text",
".=",
"\"\\n\\nPowered by Peachy \"",
".",
"PEACHYVERSION",
";",
"$",
"editarray",
"=",
"array",
"(",
"'action'",
"=>",
"'emailuser'",
",",
"'target'",
"=>",
"$",
"this",
"->",
"username",
",",
"'token'",
"=>",
"$",
"tokens",
"[",
"'email'",
"]",
",",
"'subject'",
"=>",
"$",
"subject",
",",
"'text'",
"=>",
"$",
"text",
")",
";",
"if",
"(",
"$",
"ccme",
")",
"$",
"editarray",
"[",
"'ccme'",
"]",
"=",
"'yes'",
";",
"Hooks",
"::",
"runHook",
"(",
"'StartEmail'",
",",
"array",
"(",
"&",
"$",
"editarray",
")",
")",
";",
"pecho",
"(",
"\"Emailing {$this->username}...\\n\\n\"",
",",
"PECHO_NOTICE",
")",
";",
"try",
"{",
"$",
"this",
"->",
"preEditChecks",
"(",
"\"Email\"",
")",
";",
"}",
"catch",
"(",
"EditError",
"$",
"e",
")",
"{",
"pecho",
"(",
"\"Error: $e\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"wiki",
"->",
"apiQuery",
"(",
"$",
"editarray",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'error'",
"]",
")",
")",
"{",
"throw",
"new",
"EmailError",
"(",
"$",
"result",
"[",
"'error'",
"]",
"[",
"'code'",
"]",
",",
"$",
"result",
"[",
"'error'",
"]",
"[",
"'info'",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"result",
"[",
"'emailuser'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"result",
"[",
"'emailuser'",
"]",
"[",
"'result'",
"]",
"==",
"\"Success\"",
")",
"{",
"$",
"this",
"->",
"__construct",
"(",
"$",
"this",
"->",
"wiki",
",",
"$",
"this",
"->",
"username",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"pecho",
"(",
"\"Email error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
"[",
"'emailuser'",
"]",
",",
"true",
")",
".",
"\"\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"pecho",
"(",
"\"Email error...\\n\\n\"",
".",
"print_r",
"(",
"$",
"result",
"[",
"'edit'",
"]",
",",
"true",
")",
".",
"\"\\n\\n\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Send an email to another wiki user
@access public
@param string $text Text to send
@param string $subject Subject of email. Default 'Wikipedia Email'
@param bool $ccme Whether or not to send a copy of the email to "myself". Default false.
@throws EmailError
@return bool True on success, false otherwise.
|
[
"Send",
"an",
"email",
"to",
"another",
"wiki",
"user"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L641-L687
|
234,162
|
MW-Peachy/Peachy
|
Includes/User.php
|
User.deletedcontribs
|
public function deletedcontribs( $content = false, $start = null, $end = null, $dir = 'older', $prop = array(
'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token'
) ) {
if( !in_array( 'deletedhistory', $this->wiki->get_userrights() ) ) {
pecho( "User is not allowed to view deleted revisions", PECHO_FATAL );
return false;
}
if( $content ) $prop[] = 'content';
$drArray = array(
'_code' => 'dr',
'list' => 'deletedrevs',
'druser' => $this->username,
'drprop' => implode( '|', $prop ),
'drdir' => $dir
);
if( !is_null( $start ) ) $drArray['drstart'] = $start;
if( !is_null( $end ) ) $drArray['drend'] = $end;
Hooks::runHook( 'StartDelrevs', array( &$drArray ) );
pecho( "Getting deleted revisions by {$this->username}...\n\n", PECHO_NORMAL );
return $this->wiki->listHandler( $drArray );
}
|
php
|
public function deletedcontribs( $content = false, $start = null, $end = null, $dir = 'older', $prop = array(
'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token'
) ) {
if( !in_array( 'deletedhistory', $this->wiki->get_userrights() ) ) {
pecho( "User is not allowed to view deleted revisions", PECHO_FATAL );
return false;
}
if( $content ) $prop[] = 'content';
$drArray = array(
'_code' => 'dr',
'list' => 'deletedrevs',
'druser' => $this->username,
'drprop' => implode( '|', $prop ),
'drdir' => $dir
);
if( !is_null( $start ) ) $drArray['drstart'] = $start;
if( !is_null( $end ) ) $drArray['drend'] = $end;
Hooks::runHook( 'StartDelrevs', array( &$drArray ) );
pecho( "Getting deleted revisions by {$this->username}...\n\n", PECHO_NORMAL );
return $this->wiki->listHandler( $drArray );
}
|
[
"public",
"function",
"deletedcontribs",
"(",
"$",
"content",
"=",
"false",
",",
"$",
"start",
"=",
"null",
",",
"$",
"end",
"=",
"null",
",",
"$",
"dir",
"=",
"'older'",
",",
"$",
"prop",
"=",
"array",
"(",
"'revid'",
",",
"'user'",
",",
"'parsedcomment'",
",",
"'minor'",
",",
"'len'",
",",
"'content'",
",",
"'token'",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"'deletedhistory'",
",",
"$",
"this",
"->",
"wiki",
"->",
"get_userrights",
"(",
")",
")",
")",
"{",
"pecho",
"(",
"\"User is not allowed to view deleted revisions\"",
",",
"PECHO_FATAL",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"content",
")",
"$",
"prop",
"[",
"]",
"=",
"'content'",
";",
"$",
"drArray",
"=",
"array",
"(",
"'_code'",
"=>",
"'dr'",
",",
"'list'",
"=>",
"'deletedrevs'",
",",
"'druser'",
"=>",
"$",
"this",
"->",
"username",
",",
"'drprop'",
"=>",
"implode",
"(",
"'|'",
",",
"$",
"prop",
")",
",",
"'drdir'",
"=>",
"$",
"dir",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"start",
")",
")",
"$",
"drArray",
"[",
"'drstart'",
"]",
"=",
"$",
"start",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"end",
")",
")",
"$",
"drArray",
"[",
"'drend'",
"]",
"=",
"$",
"end",
";",
"Hooks",
"::",
"runHook",
"(",
"'StartDelrevs'",
",",
"array",
"(",
"&",
"$",
"drArray",
")",
")",
";",
"pecho",
"(",
"\"Getting deleted revisions by {$this->username}...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"return",
"$",
"this",
"->",
"wiki",
"->",
"listHandler",
"(",
"$",
"drArray",
")",
";",
"}"
] |
List all deleted contributions.
The logged in user must have the 'deletedhistory' right
@access public
@param bool $content Whether or not to return content of each contribution. Default false
@param string $start Timestamp to start at. Default null.
@param string $end Timestamp to end at. Default null.
@param string $dir Direction to list. Default 'older'
@param array $prop Information to retrieve. Default array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' )
@return array
|
[
"List",
"all",
"deleted",
"contributions",
".",
"The",
"logged",
"in",
"user",
"must",
"have",
"the",
"deletedhistory",
"right"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L744-L770
|
234,163
|
budde377/Part
|
lib/util/db/MySQLDBImpl.php
|
MySQLDBImpl.getConnection
|
public function getConnection()
{
if ($this->connection === null) {
$this->connection = new PDO(
'mysql:dbname=' . $this->database . ';host=' . $this->host,
$this->username,
$this->password,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
return $this->connection;
}
|
php
|
public function getConnection()
{
if ($this->connection === null) {
$this->connection = new PDO(
'mysql:dbname=' . $this->database . ';host=' . $this->host,
$this->username,
$this->password,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
return $this->connection;
}
|
[
"public",
"function",
"getConnection",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connection",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"connection",
"=",
"new",
"PDO",
"(",
"'mysql:dbname='",
".",
"$",
"this",
"->",
"database",
".",
"';host='",
".",
"$",
"this",
"->",
"host",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"array",
"(",
"PDO",
"::",
"ATTR_ERRMODE",
"=>",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connection",
";",
"}"
] |
This returns the current connection, with info provided in config.
@return PDO
|
[
"This",
"returns",
"the",
"current",
"connection",
"with",
"info",
"provided",
"in",
"config",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/db/MySQLDBImpl.php#L47-L58
|
234,164
|
budde377/Part
|
lib/util/db/MySQLDBImpl.php
|
MySQLDBImpl.update
|
public function update()
{
$this->setUpVersion();
$connection = $this->getConnection();
foreach ($this->folders as $name => $path) {
$folder = new FolderImpl($path);
if (!$folder->exists()) {
continue;
}
/** @var File[] $files */
$files = $folder->listFolder(Folder::LIST_FOLDER_FILES);
usort($files, function (File $a, File $b) {
return $this->leadingNumber($a->getFilename()) - $this->leadingNumber($b->getFilename());
});
$lastFile = null;
$version = $this->getVersion($name);
foreach ($files as $file) {
if ($file->getExtension() != 'sql') {
continue;
}
if ($this->leadingNumber($file->getFilename()) <= $version) {
continue;
}
$stmt = $connection->prepare($file->getContents());
$stmt->execute();
while ($stmt->nextRowset()) ; //Polling row sets
$lastFile = $file;
}
if ($lastFile == null) {
continue;
}
$this->setVersion($name, $this->leadingNumber($lastFile->getFilename()));
}
}
|
php
|
public function update()
{
$this->setUpVersion();
$connection = $this->getConnection();
foreach ($this->folders as $name => $path) {
$folder = new FolderImpl($path);
if (!$folder->exists()) {
continue;
}
/** @var File[] $files */
$files = $folder->listFolder(Folder::LIST_FOLDER_FILES);
usort($files, function (File $a, File $b) {
return $this->leadingNumber($a->getFilename()) - $this->leadingNumber($b->getFilename());
});
$lastFile = null;
$version = $this->getVersion($name);
foreach ($files as $file) {
if ($file->getExtension() != 'sql') {
continue;
}
if ($this->leadingNumber($file->getFilename()) <= $version) {
continue;
}
$stmt = $connection->prepare($file->getContents());
$stmt->execute();
while ($stmt->nextRowset()) ; //Polling row sets
$lastFile = $file;
}
if ($lastFile == null) {
continue;
}
$this->setVersion($name, $this->leadingNumber($lastFile->getFilename()));
}
}
|
[
"public",
"function",
"update",
"(",
")",
"{",
"$",
"this",
"->",
"setUpVersion",
"(",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"folders",
"as",
"$",
"name",
"=>",
"$",
"path",
")",
"{",
"$",
"folder",
"=",
"new",
"FolderImpl",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"folder",
"->",
"exists",
"(",
")",
")",
"{",
"continue",
";",
"}",
"/** @var File[] $files */",
"$",
"files",
"=",
"$",
"folder",
"->",
"listFolder",
"(",
"Folder",
"::",
"LIST_FOLDER_FILES",
")",
";",
"usort",
"(",
"$",
"files",
",",
"function",
"(",
"File",
"$",
"a",
",",
"File",
"$",
"b",
")",
"{",
"return",
"$",
"this",
"->",
"leadingNumber",
"(",
"$",
"a",
"->",
"getFilename",
"(",
")",
")",
"-",
"$",
"this",
"->",
"leadingNumber",
"(",
"$",
"b",
"->",
"getFilename",
"(",
")",
")",
";",
"}",
")",
";",
"$",
"lastFile",
"=",
"null",
";",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"getExtension",
"(",
")",
"!=",
"'sql'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"leadingNumber",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
"<=",
"$",
"version",
")",
"{",
"continue",
";",
"}",
"$",
"stmt",
"=",
"$",
"connection",
"->",
"prepare",
"(",
"$",
"file",
"->",
"getContents",
"(",
")",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"while",
"(",
"$",
"stmt",
"->",
"nextRowset",
"(",
")",
")",
";",
"//Polling row sets",
"$",
"lastFile",
"=",
"$",
"file",
";",
"}",
"if",
"(",
"$",
"lastFile",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"setVersion",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"leadingNumber",
"(",
"$",
"lastFile",
"->",
"getFilename",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Updates the database according to the sql files
in the designated db folders.
@return void
|
[
"Updates",
"the",
"database",
"according",
"to",
"the",
"sql",
"files",
"in",
"the",
"designated",
"db",
"folders",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/db/MySQLDBImpl.php#L67-L106
|
234,165
|
baleen/migrations
|
src/Service/DomainBus/Migrate/Collection/CollectionHandler.php
|
CollectionHandler.handle
|
public function handle(CollectionCommand $command)
{
$target = $command->getTarget();
$collection = $command->getCollection();
$options = $command->getOptions();
$direction = $options->getDirection();
$comparator = $collection->getComparator();
if ($direction->isDown()) {
$comparator = $comparator->getReverse();
}
// filter to only get versions that need to be migrated
$filter = function (DeltaInterface $v) use ($target, $comparator, $direction) {
return ($direction->isUp() ^ $v->isMigrated()) // direction must be opposite to migration status
&& $comparator->compare($v, $target) <= 0; // version must be before or be equal to target (not
// affected by direction because comparator is reversed)
};
$scheduled = $collection->filter($filter)->sort($comparator);
// we don't check if $scheduled is empty after filtering because the collection-before and -after events should
// still be triggered by the runner
$event = $this->createRunnerFor($scheduled)->run($target, $options);
return $command->getVersionRepository()->updateAll($event->getCollection());
}
|
php
|
public function handle(CollectionCommand $command)
{
$target = $command->getTarget();
$collection = $command->getCollection();
$options = $command->getOptions();
$direction = $options->getDirection();
$comparator = $collection->getComparator();
if ($direction->isDown()) {
$comparator = $comparator->getReverse();
}
// filter to only get versions that need to be migrated
$filter = function (DeltaInterface $v) use ($target, $comparator, $direction) {
return ($direction->isUp() ^ $v->isMigrated()) // direction must be opposite to migration status
&& $comparator->compare($v, $target) <= 0; // version must be before or be equal to target (not
// affected by direction because comparator is reversed)
};
$scheduled = $collection->filter($filter)->sort($comparator);
// we don't check if $scheduled is empty after filtering because the collection-before and -after events should
// still be triggered by the runner
$event = $this->createRunnerFor($scheduled)->run($target, $options);
return $command->getVersionRepository()->updateAll($event->getCollection());
}
|
[
"public",
"function",
"handle",
"(",
"CollectionCommand",
"$",
"command",
")",
"{",
"$",
"target",
"=",
"$",
"command",
"->",
"getTarget",
"(",
")",
";",
"$",
"collection",
"=",
"$",
"command",
"->",
"getCollection",
"(",
")",
";",
"$",
"options",
"=",
"$",
"command",
"->",
"getOptions",
"(",
")",
";",
"$",
"direction",
"=",
"$",
"options",
"->",
"getDirection",
"(",
")",
";",
"$",
"comparator",
"=",
"$",
"collection",
"->",
"getComparator",
"(",
")",
";",
"if",
"(",
"$",
"direction",
"->",
"isDown",
"(",
")",
")",
"{",
"$",
"comparator",
"=",
"$",
"comparator",
"->",
"getReverse",
"(",
")",
";",
"}",
"// filter to only get versions that need to be migrated",
"$",
"filter",
"=",
"function",
"(",
"DeltaInterface",
"$",
"v",
")",
"use",
"(",
"$",
"target",
",",
"$",
"comparator",
",",
"$",
"direction",
")",
"{",
"return",
"(",
"$",
"direction",
"->",
"isUp",
"(",
")",
"^",
"$",
"v",
"->",
"isMigrated",
"(",
")",
")",
"// direction must be opposite to migration status",
"&&",
"$",
"comparator",
"->",
"compare",
"(",
"$",
"v",
",",
"$",
"target",
")",
"<=",
"0",
";",
"// version must be before or be equal to target (not",
"// affected by direction because comparator is reversed)",
"}",
";",
"$",
"scheduled",
"=",
"$",
"collection",
"->",
"filter",
"(",
"$",
"filter",
")",
"->",
"sort",
"(",
"$",
"comparator",
")",
";",
"// we don't check if $scheduled is empty after filtering because the collection-before and -after events should",
"// still be triggered by the runner",
"$",
"event",
"=",
"$",
"this",
"->",
"createRunnerFor",
"(",
"$",
"scheduled",
")",
"->",
"run",
"(",
"$",
"target",
",",
"$",
"options",
")",
";",
"return",
"$",
"command",
"->",
"getVersionRepository",
"(",
")",
"->",
"updateAll",
"(",
"$",
"event",
"->",
"getCollection",
"(",
")",
")",
";",
"}"
] |
Handle an "up" migration against a collection
@param CollectionCommand $command
@return bool The result of saving the collection of updated versions to the repository
|
[
"Handle",
"an",
"up",
"migration",
"against",
"a",
"collection"
] |
cfc8c439858cf4f0d4119af9eb67de493da8d95c
|
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/DomainBus/Migrate/Collection/CollectionHandler.php#L56-L80
|
234,166
|
budde377/Part
|
lib/util/file/FolderImpl.php
|
FolderImpl.clean
|
public function clean()
{
foreach($this->listFolder() as $f){
if($f instanceof Folder){
$f->delete(Folder::DELETE_FOLDER_RECURSIVE);
} else if($f instanceof File){
$f->delete();
}
}
}
|
php
|
public function clean()
{
foreach($this->listFolder() as $f){
if($f instanceof Folder){
$f->delete(Folder::DELETE_FOLDER_RECURSIVE);
} else if($f instanceof File){
$f->delete();
}
}
}
|
[
"public",
"function",
"clean",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listFolder",
"(",
")",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"$",
"f",
"instanceof",
"Folder",
")",
"{",
"$",
"f",
"->",
"delete",
"(",
"Folder",
"::",
"DELETE_FOLDER_RECURSIVE",
")",
";",
"}",
"else",
"if",
"(",
"$",
"f",
"instanceof",
"File",
")",
"{",
"$",
"f",
"->",
"delete",
"(",
")",
";",
"}",
"}",
"}"
] |
Cleans the folder for all content, folders as files.
@return void
|
[
"Cleans",
"the",
"folder",
"for",
"all",
"content",
"folders",
"as",
"files",
"."
] |
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
|
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FolderImpl.php#L284-L293
|
234,167
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php
|
EmbeddedMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new Embedded();
case 1:
return new Embedded(func_get_arg(0));
case 2:
return new Embedded(func_get_arg(0), func_get_arg(1));
case 3:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new Embedded();
case 1:
return new Embedded(func_get_arg(0));
case 2:
return new Embedded(func_get_arg(0), func_get_arg(1));
case 3:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"Embedded",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"Embedded",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded
@throws \InvalidArgumentException
@return Embedded
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithEmbeddedMessageProperty",
"\\",
"Embedded"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php#L66-L90
|
234,168
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php
|
EmbeddedMeta.fromArray
|
public static function fromArray($input, $group = NULL, $object = NULL)
{
if (!isset(self::$groups[$group])) {
throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithEmbeddedMessageProperty\\Embedded' . '.');
} else {
$id = self::$groups[$group];
}
if ($object === null) {
$object = new Embedded();
} elseif (!($object instanceof Embedded)) {
throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded.');
}
if (($id & 1) > 0 && isset($input['x'])) {
$object->x = $input['x'];
} elseif (($id & 1) > 0 && array_key_exists('x', $input) && $input['x'] === null) {
$object->x = null;
}
return $object;
}
|
php
|
public static function fromArray($input, $group = NULL, $object = NULL)
{
if (!isset(self::$groups[$group])) {
throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithEmbeddedMessageProperty\\Embedded' . '.');
} else {
$id = self::$groups[$group];
}
if ($object === null) {
$object = new Embedded();
} elseif (!($object instanceof Embedded)) {
throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded.');
}
if (($id & 1) > 0 && isset($input['x'])) {
$object->x = $input['x'];
} elseif (($id & 1) > 0 && array_key_exists('x', $input) && $input['x'] === null) {
$object->x = null;
}
return $object;
}
|
[
"public",
"static",
"function",
"fromArray",
"(",
"$",
"input",
",",
"$",
"group",
"=",
"NULL",
",",
"$",
"object",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"groups",
"[",
"$",
"group",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Group \\''",
".",
"$",
"group",
".",
"'\\' not supported for '",
".",
"'Skrz\\\\Meta\\\\Fixtures\\\\Protobuf\\\\ClassWithEmbeddedMessageProperty\\\\Embedded'",
".",
"'.'",
")",
";",
"}",
"else",
"{",
"$",
"id",
"=",
"self",
"::",
"$",
"groups",
"[",
"$",
"group",
"]",
";",
"}",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"Embedded",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"Embedded",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithEmbeddedMessageProperty\\Embedded.'",
")",
";",
"}",
"if",
"(",
"(",
"$",
"id",
"&",
"1",
")",
">",
"0",
"&&",
"isset",
"(",
"$",
"input",
"[",
"'x'",
"]",
")",
")",
"{",
"$",
"object",
"->",
"x",
"=",
"$",
"input",
"[",
"'x'",
"]",
";",
"}",
"elseif",
"(",
"(",
"$",
"id",
"&",
"1",
")",
">",
"0",
"&&",
"array_key_exists",
"(",
"'x'",
",",
"$",
"input",
")",
"&&",
"$",
"input",
"[",
"'x'",
"]",
"===",
"null",
")",
"{",
"$",
"object",
"->",
"x",
"=",
"null",
";",
"}",
"return",
"$",
"object",
";",
"}"
] |
Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded object from array
@param array $input
@param string $group
@param Embedded $object
@throws \Exception
@return Embedded
|
[
"Creates",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithEmbeddedMessageProperty",
"\\",
"Embedded",
"object",
"from",
"array"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php#L153-L174
|
234,169
|
skrz/meta
|
gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php
|
EmbeddedMeta.fromProtobuf
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new Embedded();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->x = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
}
|
php
|
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new Embedded();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->x = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
}
|
[
"public",
"static",
"function",
"fromProtobuf",
"(",
"$",
"input",
",",
"$",
"object",
"=",
"NULL",
",",
"&",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
"new",
"Embedded",
"(",
")",
";",
"}",
"if",
"(",
"$",
"end",
"===",
"null",
")",
"{",
"$",
"end",
"=",
"strlen",
"(",
"$",
"input",
")",
";",
"}",
"while",
"(",
"$",
"start",
"<",
"$",
"end",
")",
"{",
"$",
"tag",
"=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"$",
"wireType",
"=",
"$",
"tag",
"&",
"0x7",
";",
"$",
"number",
"=",
"$",
"tag",
">>",
"3",
";",
"switch",
"(",
"$",
"number",
")",
"{",
"case",
"1",
":",
"if",
"(",
"$",
"wireType",
"!==",
"2",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected wire type '",
".",
"$",
"wireType",
".",
"', expected 2.'",
",",
"$",
"number",
")",
";",
"}",
"$",
"length",
"=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"$",
"expectedStart",
"=",
"$",
"start",
"+",
"$",
"length",
";",
"if",
"(",
"$",
"expectedStart",
">",
"$",
"end",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Not enough data.'",
")",
";",
"}",
"$",
"object",
"->",
"x",
"=",
"substr",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"length",
")",
";",
"$",
"start",
"+=",
"$",
"length",
";",
"if",
"(",
"$",
"start",
"!==",
"$",
"expectedStart",
")",
"{",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected start. Expected '",
".",
"$",
"expectedStart",
".",
"', got '",
".",
"$",
"start",
".",
"'.'",
",",
"$",
"number",
")",
";",
"}",
"break",
";",
"default",
":",
"switch",
"(",
"$",
"wireType",
")",
"{",
"case",
"0",
":",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"start",
"+=",
"8",
";",
"break",
";",
"case",
"2",
":",
"$",
"start",
"+=",
"Binary",
"::",
"decodeVarint",
"(",
"$",
"input",
",",
"$",
"start",
")",
";",
"break",
";",
"case",
"5",
":",
"$",
"start",
"+=",
"4",
";",
"break",
";",
"default",
":",
"throw",
"new",
"ProtobufException",
"(",
"'Unexpected wire type '",
".",
"$",
"wireType",
".",
"'.'",
",",
"$",
"number",
")",
";",
"}",
"}",
"}",
"return",
"$",
"object",
";",
"}"
] |
Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded object from serialized Protocol Buffers message.
@param string $input
@param Embedded $object
@param int $start
@param int $end
@throws \Exception
@return Embedded
|
[
"Creates",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithEmbeddedMessageProperty",
"\\",
"Embedded",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php#L332-L383
|
234,170
|
fab2s/NodalFlow
|
src/Events/CallbackWrapper.php
|
CallbackWrapper.progress
|
public function progress(FlowEventInterface $event)
{
$this->callBack->progress($event->getFlow(), $event->getNode());
}
|
php
|
public function progress(FlowEventInterface $event)
{
$this->callBack->progress($event->getFlow(), $event->getNode());
}
|
[
"public",
"function",
"progress",
"(",
"FlowEventInterface",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"callBack",
"->",
"progress",
"(",
"$",
"event",
"->",
"getFlow",
"(",
")",
",",
"$",
"event",
"->",
"getNode",
"(",
")",
")",
";",
"}"
] |
Triggered when a Flow progresses,
eg exec once or generates once
@param FlowEventInterface $event
|
[
"Triggered",
"when",
"a",
"Flow",
"progresses",
"eg",
"exec",
"once",
"or",
"generates",
"once"
] |
da5d458ffea3e6e954d7ee734f938f4be5e46728
|
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Events/CallbackWrapper.php#L66-L69
|
234,171
|
joetannenbaum/phpushbullet
|
src/Request/PushAddress.php
|
PushAddress.setAddress
|
protected function setAddress($address)
{
if (is_array($address)) {
$new_address = [];
foreach (['address', 'city', 'state', 'zip'] as $field) {
if (array_key_exists($field, $address)) {
$new_address[] = $address[$field];
}
}
$address = implode(' ', $new_address);
}
return $address;
}
|
php
|
protected function setAddress($address)
{
if (is_array($address)) {
$new_address = [];
foreach (['address', 'city', 'state', 'zip'] as $field) {
if (array_key_exists($field, $address)) {
$new_address[] = $address[$field];
}
}
$address = implode(' ', $new_address);
}
return $address;
}
|
[
"protected",
"function",
"setAddress",
"(",
"$",
"address",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"address",
")",
")",
"{",
"$",
"new_address",
"=",
"[",
"]",
";",
"foreach",
"(",
"[",
"'address'",
",",
"'city'",
",",
"'state'",
",",
"'zip'",
"]",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"address",
")",
")",
"{",
"$",
"new_address",
"[",
"]",
"=",
"$",
"address",
"[",
"$",
"field",
"]",
";",
"}",
"}",
"$",
"address",
"=",
"implode",
"(",
"' '",
",",
"$",
"new_address",
")",
";",
"}",
"return",
"$",
"address",
";",
"}"
] |
The address can either be a string or an array,
make sure it's a string in the end
@param string|array $address
@return string
|
[
"The",
"address",
"can",
"either",
"be",
"a",
"string",
"or",
"an",
"array",
"make",
"sure",
"it",
"s",
"a",
"string",
"in",
"the",
"end"
] |
df138ebb3adebcddade282be478c0d2d6ebffb3e
|
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/Request/PushAddress.php#L29-L44
|
234,172
|
skrz/meta
|
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
|
LocationMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new Location();
case 1:
return new Location(func_get_arg(0));
case 2:
return new Location(func_get_arg(0), func_get_arg(1));
case 3:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new Location();
case 1:
return new Location(func_get_arg(0));
case 2:
return new Location(func_get_arg(0), func_get_arg(1));
case 3:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"Location",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"Location",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\SourceCodeInfo\Location
@throws \InvalidArgumentException
@return Location
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"SourceCodeInfo",
"\\",
"Location"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L61-L85
|
234,173
|
skrz/meta
|
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
|
LocationMeta.reset
|
public static function reset($object)
{
if (!($object instanceof Location)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\SourceCodeInfo\Location.');
}
$object->path = NULL;
$object->span = NULL;
$object->leadingComments = NULL;
$object->trailingComments = NULL;
$object->leadingDetachedComments = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof Location)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\SourceCodeInfo\Location.');
}
$object->path = NULL;
$object->span = NULL;
$object->leadingComments = NULL;
$object->trailingComments = NULL;
$object->leadingDetachedComments = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"Location",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\SourceCodeInfo\\Location.'",
")",
";",
"}",
"$",
"object",
"->",
"path",
"=",
"NULL",
";",
"$",
"object",
"->",
"span",
"=",
"NULL",
";",
"$",
"object",
"->",
"leadingComments",
"=",
"NULL",
";",
"$",
"object",
"->",
"trailingComments",
"=",
"NULL",
";",
"$",
"object",
"->",
"leadingDetachedComments",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\SourceCodeInfo\Location to default values
@param Location $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"SourceCodeInfo",
"\\",
"Location",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L98-L108
|
234,174
|
skrz/meta
|
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
|
LocationMeta.hash
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->path)) {
hash_update($ctx, 'path');
foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (isset($object->span)) {
hash_update($ctx, 'span');
foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (isset($object->leadingComments)) {
hash_update($ctx, 'leadingComments');
hash_update($ctx, (string)$object->leadingComments);
}
if (isset($object->trailingComments)) {
hash_update($ctx, 'trailingComments');
hash_update($ctx, (string)$object->trailingComments);
}
if (isset($object->leadingDetachedComments)) {
hash_update($ctx, 'leadingDetachedComments');
foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
php
|
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->path)) {
hash_update($ctx, 'path');
foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (isset($object->span)) {
hash_update($ctx, 'span');
foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (isset($object->leadingComments)) {
hash_update($ctx, 'leadingComments');
hash_update($ctx, (string)$object->leadingComments);
}
if (isset($object->trailingComments)) {
hash_update($ctx, 'trailingComments');
hash_update($ctx, (string)$object->trailingComments);
}
if (isset($object->leadingDetachedComments)) {
hash_update($ctx, 'leadingDetachedComments');
foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $v0) {
hash_update($ctx, (string)$v0);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
}
|
[
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrCtx",
")",
";",
"}",
"else",
"{",
"$",
"ctx",
"=",
"$",
"algoOrCtx",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"path",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'path'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"path",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"path",
":",
"(",
"array",
")",
"$",
"object",
"->",
"path",
"as",
"$",
"v0",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"v0",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"span",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'span'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"span",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"span",
":",
"(",
"array",
")",
"$",
"object",
"->",
"span",
"as",
"$",
"v0",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"v0",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"leadingComments",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'leadingComments'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"leadingComments",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"trailingComments",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'trailingComments'",
")",
";",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"object",
"->",
"trailingComments",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"leadingDetachedComments",
")",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"'leadingDetachedComments'",
")",
";",
"foreach",
"(",
"$",
"object",
"->",
"leadingDetachedComments",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"leadingDetachedComments",
":",
"(",
"array",
")",
"$",
"object",
"->",
"leadingDetachedComments",
"as",
"$",
"v0",
")",
"{",
"hash_update",
"(",
"$",
"ctx",
",",
"(",
"string",
")",
"$",
"v0",
")",
";",
"}",
"}",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"return",
"hash_final",
"(",
"$",
"ctx",
",",
"$",
"raw",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Computes hash of \Google\Protobuf\SourceCodeInfo\Location
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void
|
[
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"SourceCodeInfo",
"\\",
"Location"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L120-L164
|
234,175
|
skrz/meta
|
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
|
LocationMeta.toProtobuf
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->path) && ($filter === null || isset($filter['path']))) {
$packedBuffer = '';
$output .= "\x0a";
foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $k => $v) {
$packedBuffer .= Binary::encodeVarint($v);
}
$output .= Binary::encodeVarint(strlen($packedBuffer));
$output .= $packedBuffer;
}
if (isset($object->span) && ($filter === null || isset($filter['span']))) {
$packedBuffer = '';
$output .= "\x12";
foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $k => $v) {
$packedBuffer .= Binary::encodeVarint($v);
}
$output .= Binary::encodeVarint(strlen($packedBuffer));
$output .= $packedBuffer;
}
if (isset($object->leadingComments) && ($filter === null || isset($filter['leadingComments']))) {
$output .= "\x1a";
$output .= Binary::encodeVarint(strlen($object->leadingComments));
$output .= $object->leadingComments;
}
if (isset($object->trailingComments) && ($filter === null || isset($filter['trailingComments']))) {
$output .= "\x22";
$output .= Binary::encodeVarint(strlen($object->trailingComments));
$output .= $object->trailingComments;
}
if (isset($object->leadingDetachedComments) && ($filter === null || isset($filter['leadingDetachedComments']))) {
foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $k => $v) {
$output .= "\x32";
$output .= Binary::encodeVarint(strlen($v));
$output .= $v;
}
}
return $output;
}
|
php
|
public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->path) && ($filter === null || isset($filter['path']))) {
$packedBuffer = '';
$output .= "\x0a";
foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $k => $v) {
$packedBuffer .= Binary::encodeVarint($v);
}
$output .= Binary::encodeVarint(strlen($packedBuffer));
$output .= $packedBuffer;
}
if (isset($object->span) && ($filter === null || isset($filter['span']))) {
$packedBuffer = '';
$output .= "\x12";
foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $k => $v) {
$packedBuffer .= Binary::encodeVarint($v);
}
$output .= Binary::encodeVarint(strlen($packedBuffer));
$output .= $packedBuffer;
}
if (isset($object->leadingComments) && ($filter === null || isset($filter['leadingComments']))) {
$output .= "\x1a";
$output .= Binary::encodeVarint(strlen($object->leadingComments));
$output .= $object->leadingComments;
}
if (isset($object->trailingComments) && ($filter === null || isset($filter['trailingComments']))) {
$output .= "\x22";
$output .= Binary::encodeVarint(strlen($object->trailingComments));
$output .= $object->trailingComments;
}
if (isset($object->leadingDetachedComments) && ($filter === null || isset($filter['leadingDetachedComments']))) {
foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $k => $v) {
$output .= "\x32";
$output .= Binary::encodeVarint(strlen($v));
$output .= $v;
}
}
return $output;
}
|
[
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"path",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'path'",
"]",
")",
")",
")",
"{",
"$",
"packedBuffer",
"=",
"''",
";",
"$",
"output",
".=",
"\"\\x0a\"",
";",
"foreach",
"(",
"$",
"object",
"->",
"path",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"path",
":",
"(",
"array",
")",
"$",
"object",
"->",
"path",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"packedBuffer",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"v",
")",
";",
"}",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"packedBuffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"packedBuffer",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"span",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'span'",
"]",
")",
")",
")",
"{",
"$",
"packedBuffer",
"=",
"''",
";",
"$",
"output",
".=",
"\"\\x12\"",
";",
"foreach",
"(",
"$",
"object",
"->",
"span",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"span",
":",
"(",
"array",
")",
"$",
"object",
"->",
"span",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"packedBuffer",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"$",
"v",
")",
";",
"}",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"packedBuffer",
")",
")",
";",
"$",
"output",
".=",
"$",
"packedBuffer",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"leadingComments",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'leadingComments'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x1a\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"leadingComments",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"leadingComments",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"trailingComments",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'trailingComments'",
"]",
")",
")",
")",
"{",
"$",
"output",
".=",
"\"\\x22\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"object",
"->",
"trailingComments",
")",
")",
";",
"$",
"output",
".=",
"$",
"object",
"->",
"trailingComments",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"leadingDetachedComments",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
"isset",
"(",
"$",
"filter",
"[",
"'leadingDetachedComments'",
"]",
")",
")",
")",
"{",
"foreach",
"(",
"$",
"object",
"->",
"leadingDetachedComments",
"instanceof",
"\\",
"Traversable",
"?",
"$",
"object",
"->",
"leadingDetachedComments",
":",
"(",
"array",
")",
"$",
"object",
"->",
"leadingDetachedComments",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"output",
".=",
"\"\\x32\"",
";",
"$",
"output",
".=",
"Binary",
"::",
"encodeVarint",
"(",
"strlen",
"(",
"$",
"v",
")",
")",
";",
"$",
"output",
".=",
"$",
"v",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Serialized \Google\Protobuf\SourceCodeInfo\Location to Protocol Buffers message.
@param Location $object
@param array $filter
@throws \Exception
@return string
|
[
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"SourceCodeInfo",
"\\",
"Location",
"to",
"Protocol",
"Buffers",
"message",
"."
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L314-L359
|
234,176
|
fab2s/NodalFlow
|
src/Nodes/AggregateNode.php
|
AggregateNode.getTraversable
|
public function getTraversable($param)
{
$value = null;
/** @var $nodes TraversableNodeInterface[] */
$nodes = $this->payload->getNodes();
foreach ($nodes as $node) {
$returnVal = $node->isReturningVal();
foreach ($node->getTraversable($param) as $value) {
if ($returnVal) {
yield $value;
continue;
}
yield $param;
}
if ($returnVal) {
// since this node is returning something
// we will pass its last yield to the next
// traversable. It will be up to him to
// do whatever is necessary with it, including
// nothing
$param = $value;
}
}
}
|
php
|
public function getTraversable($param)
{
$value = null;
/** @var $nodes TraversableNodeInterface[] */
$nodes = $this->payload->getNodes();
foreach ($nodes as $node) {
$returnVal = $node->isReturningVal();
foreach ($node->getTraversable($param) as $value) {
if ($returnVal) {
yield $value;
continue;
}
yield $param;
}
if ($returnVal) {
// since this node is returning something
// we will pass its last yield to the next
// traversable. It will be up to him to
// do whatever is necessary with it, including
// nothing
$param = $value;
}
}
}
|
[
"public",
"function",
"getTraversable",
"(",
"$",
"param",
")",
"{",
"$",
"value",
"=",
"null",
";",
"/** @var $nodes TraversableNodeInterface[] */",
"$",
"nodes",
"=",
"$",
"this",
"->",
"payload",
"->",
"getNodes",
"(",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"returnVal",
"=",
"$",
"node",
"->",
"isReturningVal",
"(",
")",
";",
"foreach",
"(",
"$",
"node",
"->",
"getTraversable",
"(",
"$",
"param",
")",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"returnVal",
")",
"{",
"yield",
"$",
"value",
";",
"continue",
";",
"}",
"yield",
"$",
"param",
";",
"}",
"if",
"(",
"$",
"returnVal",
")",
"{",
"// since this node is returning something",
"// we will pass its last yield to the next",
"// traversable. It will be up to him to",
"// do whatever is necessary with it, including",
"// nothing",
"$",
"param",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] |
Get the traversable to traverse within the Flow
@param mixed $param
@return \Generator
|
[
"Get",
"the",
"traversable",
"to",
"traverse",
"within",
"the",
"Flow"
] |
da5d458ffea3e6e954d7ee734f938f4be5e46728
|
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Nodes/AggregateNode.php#L64-L89
|
234,177
|
MW-Peachy/Peachy
|
Includes/limeOutput.php
|
lime_output.diag
|
public function diag()
{
$messages = func_get_args();
foreach ($messages as $message) {
echo $this->colorizer->colorize('# ' . join("\n# ", (array)$message), 'COMMENT') . "\n";
}
}
|
php
|
public function diag()
{
$messages = func_get_args();
foreach ($messages as $message) {
echo $this->colorizer->colorize('# ' . join("\n# ", (array)$message), 'COMMENT') . "\n";
}
}
|
[
"public",
"function",
"diag",
"(",
")",
"{",
"$",
"messages",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"echo",
"$",
"this",
"->",
"colorizer",
"->",
"colorize",
"(",
"'# '",
".",
"join",
"(",
"\"\\n# \"",
",",
"(",
"array",
")",
"$",
"message",
")",
",",
"'COMMENT'",
")",
".",
"\"\\n\"",
";",
"}",
"}"
] |
Produces an Echo
|
[
"Produces",
"an",
"Echo"
] |
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
|
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/limeOutput.php#L25-L31
|
234,178
|
baleen/migrations
|
src/Service/Runner/CollectionRunner.php
|
CollectionRunner.run
|
public function run(DeltaInterface $target, OptionsInterface $options)
{
$current = 1;
$collection = $this->getCollection();
$context = CollectionContext::createWithProgress(max($collection->count(), 1), $current);
$migrationRunner = $this->migrationRunner->withContext($context);
$this->getPublisher()->publish(new CollectionBeforeEvent($target, $options, $collection));
$modified = new Collection();
$comparator = $collection->getComparator();
// IMPROVE: add tests to see if rewind is necessary
$collection->first(); // rewind
foreach ($collection as $version) {
$context->getProgress()->update($current);
$result = $migrationRunner->run($version, $options);
if ($result) {
$modified->add($version);
}
if ($comparator->compare($version, $target) >= 0) {
break;
}
$current += 1;
}
$event = new CollectionAfterEvent($target, $options, $modified);
$this->getPublisher()->publish($event);
return $event;
}
|
php
|
public function run(DeltaInterface $target, OptionsInterface $options)
{
$current = 1;
$collection = $this->getCollection();
$context = CollectionContext::createWithProgress(max($collection->count(), 1), $current);
$migrationRunner = $this->migrationRunner->withContext($context);
$this->getPublisher()->publish(new CollectionBeforeEvent($target, $options, $collection));
$modified = new Collection();
$comparator = $collection->getComparator();
// IMPROVE: add tests to see if rewind is necessary
$collection->first(); // rewind
foreach ($collection as $version) {
$context->getProgress()->update($current);
$result = $migrationRunner->run($version, $options);
if ($result) {
$modified->add($version);
}
if ($comparator->compare($version, $target) >= 0) {
break;
}
$current += 1;
}
$event = new CollectionAfterEvent($target, $options, $modified);
$this->getPublisher()->publish($event);
return $event;
}
|
[
"public",
"function",
"run",
"(",
"DeltaInterface",
"$",
"target",
",",
"OptionsInterface",
"$",
"options",
")",
"{",
"$",
"current",
"=",
"1",
";",
"$",
"collection",
"=",
"$",
"this",
"->",
"getCollection",
"(",
")",
";",
"$",
"context",
"=",
"CollectionContext",
"::",
"createWithProgress",
"(",
"max",
"(",
"$",
"collection",
"->",
"count",
"(",
")",
",",
"1",
")",
",",
"$",
"current",
")",
";",
"$",
"migrationRunner",
"=",
"$",
"this",
"->",
"migrationRunner",
"->",
"withContext",
"(",
"$",
"context",
")",
";",
"$",
"this",
"->",
"getPublisher",
"(",
")",
"->",
"publish",
"(",
"new",
"CollectionBeforeEvent",
"(",
"$",
"target",
",",
"$",
"options",
",",
"$",
"collection",
")",
")",
";",
"$",
"modified",
"=",
"new",
"Collection",
"(",
")",
";",
"$",
"comparator",
"=",
"$",
"collection",
"->",
"getComparator",
"(",
")",
";",
"// IMPROVE: add tests to see if rewind is necessary",
"$",
"collection",
"->",
"first",
"(",
")",
";",
"// rewind",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"version",
")",
"{",
"$",
"context",
"->",
"getProgress",
"(",
")",
"->",
"update",
"(",
"$",
"current",
")",
";",
"$",
"result",
"=",
"$",
"migrationRunner",
"->",
"run",
"(",
"$",
"version",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"modified",
"->",
"add",
"(",
"$",
"version",
")",
";",
"}",
"if",
"(",
"$",
"comparator",
"->",
"compare",
"(",
"$",
"version",
",",
"$",
"target",
")",
">=",
"0",
")",
"{",
"break",
";",
"}",
"$",
"current",
"+=",
"1",
";",
"}",
"$",
"event",
"=",
"new",
"CollectionAfterEvent",
"(",
"$",
"target",
",",
"$",
"options",
",",
"$",
"modified",
")",
";",
"$",
"this",
"->",
"getPublisher",
"(",
")",
"->",
"publish",
"(",
"$",
"event",
")",
";",
"return",
"$",
"event",
";",
"}"
] |
Runs a collection of versions towards the specified goal and using the specified options
@param DeltaInterface $target
@param OptionsInterface $options
@return CollectionAfterEvent
|
[
"Runs",
"a",
"collection",
"of",
"versions",
"towards",
"the",
"specified",
"goal",
"and",
"using",
"the",
"specified",
"options"
] |
cfc8c439858cf4f0d4119af9eb67de493da8d95c
|
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/Runner/CollectionRunner.php#L74-L104
|
234,179
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php
|
MethodOptionsMeta.create
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new MethodOptions();
case 1:
return new MethodOptions(func_get_arg(0));
case 2:
return new MethodOptions(func_get_arg(0), func_get_arg(1));
case 3:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
php
|
public static function create()
{
switch (func_num_args()) {
case 0:
return new MethodOptions();
case 1:
return new MethodOptions(func_get_arg(0));
case 2:
return new MethodOptions(func_get_arg(0), func_get_arg(1));
case 3:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
}
|
[
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"MethodOptions",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
")",
";",
"case",
"2",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
")",
";",
"case",
"3",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
")",
";",
"case",
"4",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
")",
";",
"case",
"5",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
")",
";",
"case",
"6",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
")",
";",
"case",
"7",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
")",
";",
"case",
"8",
":",
"return",
"new",
"MethodOptions",
"(",
"func_get_arg",
"(",
"0",
")",
",",
"func_get_arg",
"(",
"1",
")",
",",
"func_get_arg",
"(",
"2",
")",
",",
"func_get_arg",
"(",
"3",
")",
",",
"func_get_arg",
"(",
"4",
")",
",",
"func_get_arg",
"(",
"5",
")",
",",
"func_get_arg",
"(",
"6",
")",
",",
"func_get_arg",
"(",
"7",
")",
")",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'More than 8 arguments supplied, please be reasonable.'",
")",
";",
"}",
"}"
] |
Creates new instance of \Google\Protobuf\MethodOptions
@throws \InvalidArgumentException
@return MethodOptions
|
[
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MethodOptions"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php#L58-L82
|
234,180
|
skrz/meta
|
gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php
|
MethodOptionsMeta.reset
|
public static function reset($object)
{
if (!($object instanceof MethodOptions)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodOptions.');
}
$object->deprecated = NULL;
$object->uninterpretedOption = NULL;
}
|
php
|
public static function reset($object)
{
if (!($object instanceof MethodOptions)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodOptions.');
}
$object->deprecated = NULL;
$object->uninterpretedOption = NULL;
}
|
[
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"MethodOptions",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobuf\\MethodOptions.'",
")",
";",
"}",
"$",
"object",
"->",
"deprecated",
"=",
"NULL",
";",
"$",
"object",
"->",
"uninterpretedOption",
"=",
"NULL",
";",
"}"
] |
Resets properties of \Google\Protobuf\MethodOptions to default values
@param MethodOptions $object
@throws \InvalidArgumentException
@return void
|
[
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"MethodOptions",
"to",
"default",
"values"
] |
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
|
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php#L95-L102
|
234,181
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php
|
Zend_Validate_Date._checkFormat
|
private function _checkFormat($value)
{
try {
include_once 'Zend/Locale/Format.php';
$parsed = Zend_Locale_Format::getDate(
$value, array(
'date_format' => $this->_format, 'format_type' => 'iso',
'fix_date' => false)
);
if (isset($parsed['year']) and ((strpos(strtoupper($this->_format), 'YY') !== false)
and (strpos(strtoupper($this->_format), 'YYYY') === false))
) {
$parsed['year'] = Zend_Date::_century($parsed['year']);
}
} catch (Exception $e) {
// Date can not be parsed
return false;
}
if (((strpos($this->_format, 'Y') !== false) or (strpos($this->_format, 'y') !== false))
and (!isset($parsed['year']))
) {
// Year expected but not found
return false;
}
if ((strpos($this->_format, 'M') !== false) and (!isset($parsed['month']))) {
// Month expected but not found
return false;
}
if ((strpos($this->_format, 'd') !== false) and (!isset($parsed['day']))) {
// Day expected but not found
return false;
}
if (((strpos($this->_format, 'H') !== false) or (strpos($this->_format, 'h') !== false))
and (!isset($parsed['hour']))
) {
// Hour expected but not found
return false;
}
if ((strpos($this->_format, 'm') !== false) and (!isset($parsed['minute']))) {
// Minute expected but not found
return false;
}
if ((strpos($this->_format, 's') !== false) and (!isset($parsed['second']))) {
// Second expected but not found
return false;
}
// Date fits the format
return true;
}
|
php
|
private function _checkFormat($value)
{
try {
include_once 'Zend/Locale/Format.php';
$parsed = Zend_Locale_Format::getDate(
$value, array(
'date_format' => $this->_format, 'format_type' => 'iso',
'fix_date' => false)
);
if (isset($parsed['year']) and ((strpos(strtoupper($this->_format), 'YY') !== false)
and (strpos(strtoupper($this->_format), 'YYYY') === false))
) {
$parsed['year'] = Zend_Date::_century($parsed['year']);
}
} catch (Exception $e) {
// Date can not be parsed
return false;
}
if (((strpos($this->_format, 'Y') !== false) or (strpos($this->_format, 'y') !== false))
and (!isset($parsed['year']))
) {
// Year expected but not found
return false;
}
if ((strpos($this->_format, 'M') !== false) and (!isset($parsed['month']))) {
// Month expected but not found
return false;
}
if ((strpos($this->_format, 'd') !== false) and (!isset($parsed['day']))) {
// Day expected but not found
return false;
}
if (((strpos($this->_format, 'H') !== false) or (strpos($this->_format, 'h') !== false))
and (!isset($parsed['hour']))
) {
// Hour expected but not found
return false;
}
if ((strpos($this->_format, 'm') !== false) and (!isset($parsed['minute']))) {
// Minute expected but not found
return false;
}
if ((strpos($this->_format, 's') !== false) and (!isset($parsed['second']))) {
// Second expected but not found
return false;
}
// Date fits the format
return true;
}
|
[
"private",
"function",
"_checkFormat",
"(",
"$",
"value",
")",
"{",
"try",
"{",
"include_once",
"'Zend/Locale/Format.php'",
";",
"$",
"parsed",
"=",
"Zend_Locale_Format",
"::",
"getDate",
"(",
"$",
"value",
",",
"array",
"(",
"'date_format'",
"=>",
"$",
"this",
"->",
"_format",
",",
"'format_type'",
"=>",
"'iso'",
",",
"'fix_date'",
"=>",
"false",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parsed",
"[",
"'year'",
"]",
")",
"and",
"(",
"(",
"strpos",
"(",
"strtoupper",
"(",
"$",
"this",
"->",
"_format",
")",
",",
"'YY'",
")",
"!==",
"false",
")",
"and",
"(",
"strpos",
"(",
"strtoupper",
"(",
"$",
"this",
"->",
"_format",
")",
",",
"'YYYY'",
")",
"===",
"false",
")",
")",
")",
"{",
"$",
"parsed",
"[",
"'year'",
"]",
"=",
"Zend_Date",
"::",
"_century",
"(",
"$",
"parsed",
"[",
"'year'",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Date can not be parsed",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'Y'",
")",
"!==",
"false",
")",
"or",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'y'",
")",
"!==",
"false",
")",
")",
"and",
"(",
"!",
"isset",
"(",
"$",
"parsed",
"[",
"'year'",
"]",
")",
")",
")",
"{",
"// Year expected but not found",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'M'",
")",
"!==",
"false",
")",
"and",
"(",
"!",
"isset",
"(",
"$",
"parsed",
"[",
"'month'",
"]",
")",
")",
")",
"{",
"// Month expected but not found",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'d'",
")",
"!==",
"false",
")",
"and",
"(",
"!",
"isset",
"(",
"$",
"parsed",
"[",
"'day'",
"]",
")",
")",
")",
"{",
"// Day expected but not found",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'H'",
")",
"!==",
"false",
")",
"or",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'h'",
")",
"!==",
"false",
")",
")",
"and",
"(",
"!",
"isset",
"(",
"$",
"parsed",
"[",
"'hour'",
"]",
")",
")",
")",
"{",
"// Hour expected but not found",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'m'",
")",
"!==",
"false",
")",
"and",
"(",
"!",
"isset",
"(",
"$",
"parsed",
"[",
"'minute'",
"]",
")",
")",
")",
"{",
"// Minute expected but not found",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_format",
",",
"'s'",
")",
"!==",
"false",
")",
"and",
"(",
"!",
"isset",
"(",
"$",
"parsed",
"[",
"'second'",
"]",
")",
")",
")",
"{",
"// Second expected but not found",
"return",
"false",
";",
"}",
"// Date fits the format",
"return",
"true",
";",
"}"
] |
Check if the given date fits the given format
@param string $value Date to check
@return boolean False when date does not fit the format
|
[
"Check",
"if",
"the",
"given",
"date",
"fits",
"the",
"given",
"format"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php#L199-L254
|
234,182
|
oscarotero/fly-crud
|
src/Document.php
|
Document.arrayToObject
|
private static function arrayToObject(array $array)
{
$is_object = false;
foreach ($array as $key => &$value) {
if (is_array($value)) {
$value = self::arrayToObject($value);
}
if (is_string($key)) {
$is_object = true;
}
}
return $is_object ? (object) $array : $array;
}
|
php
|
private static function arrayToObject(array $array)
{
$is_object = false;
foreach ($array as $key => &$value) {
if (is_array($value)) {
$value = self::arrayToObject($value);
}
if (is_string($key)) {
$is_object = true;
}
}
return $is_object ? (object) $array : $array;
}
|
[
"private",
"static",
"function",
"arrayToObject",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"is_object",
"=",
"false",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"arrayToObject",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"is_object",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"is_object",
"?",
"(",
"object",
")",
"$",
"array",
":",
"$",
"array",
";",
"}"
] |
Converts the associative arrays to stdClass object recursively.
@return array|stdClass
|
[
"Converts",
"the",
"associative",
"arrays",
"to",
"stdClass",
"object",
"recursively",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Document.php#L65-L80
|
234,183
|
oscarotero/fly-crud
|
src/Document.php
|
Document.objectToArray
|
private static function objectToArray(array $array): array
{
foreach ($array as $key => &$value) {
if (is_object($value) || is_array($value)) {
$value = self::objectToArray((array) $value);
}
}
return (array) $array;
}
|
php
|
private static function objectToArray(array $array): array
{
foreach ($array as $key => &$value) {
if (is_object($value) || is_array($value)) {
$value = self::objectToArray((array) $value);
}
}
return (array) $array;
}
|
[
"private",
"static",
"function",
"objectToArray",
"(",
"array",
"$",
"array",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"||",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"objectToArray",
"(",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"}",
"return",
"(",
"array",
")",
"$",
"array",
";",
"}"
] |
Converts stdClass objects to arrays recursively.
|
[
"Converts",
"stdClass",
"objects",
"to",
"arrays",
"recursively",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Document.php#L85-L94
|
234,184
|
txj123/zilf
|
src/Zilf/Db/base/Controller.php
|
Controller.findLayoutFile
|
public function findLayoutFile($view)
{
$module = $this->module;
if (is_string($this->layout)) {
$layout = $this->layout;
} elseif ($this->layout === null) {
while ($module !== null && $module->layout === null) {
$module = $module->module;
}
if ($module !== null && is_string($module->layout)) {
$layout = $module->layout;
}
}
if (!isset($layout)) {
return false;
}
if (strncmp($layout, '@', 1) === 0) {
$file = Zilf::getAlias($layout);
} elseif (strncmp($layout, '/', 1) === 0) {
$file = Zilf::$app->getLayoutPath() . DIRECTORY_SEPARATOR . substr($layout, 1);
} else {
$file = $module->getLayoutPath() . DIRECTORY_SEPARATOR . $layout;
}
if (pathinfo($file, PATHINFO_EXTENSION) !== '') {
return $file;
}
$path = $file . '.' . $view->defaultExtension;
if ($view->defaultExtension !== 'php' && !is_file($path)) {
$path = $file . '.php';
}
return $path;
}
|
php
|
public function findLayoutFile($view)
{
$module = $this->module;
if (is_string($this->layout)) {
$layout = $this->layout;
} elseif ($this->layout === null) {
while ($module !== null && $module->layout === null) {
$module = $module->module;
}
if ($module !== null && is_string($module->layout)) {
$layout = $module->layout;
}
}
if (!isset($layout)) {
return false;
}
if (strncmp($layout, '@', 1) === 0) {
$file = Zilf::getAlias($layout);
} elseif (strncmp($layout, '/', 1) === 0) {
$file = Zilf::$app->getLayoutPath() . DIRECTORY_SEPARATOR . substr($layout, 1);
} else {
$file = $module->getLayoutPath() . DIRECTORY_SEPARATOR . $layout;
}
if (pathinfo($file, PATHINFO_EXTENSION) !== '') {
return $file;
}
$path = $file . '.' . $view->defaultExtension;
if ($view->defaultExtension !== 'php' && !is_file($path)) {
$path = $file . '.php';
}
return $path;
}
|
[
"public",
"function",
"findLayoutFile",
"(",
"$",
"view",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"module",
";",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"layout",
")",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"layout",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"layout",
"===",
"null",
")",
"{",
"while",
"(",
"$",
"module",
"!==",
"null",
"&&",
"$",
"module",
"->",
"layout",
"===",
"null",
")",
"{",
"$",
"module",
"=",
"$",
"module",
"->",
"module",
";",
"}",
"if",
"(",
"$",
"module",
"!==",
"null",
"&&",
"is_string",
"(",
"$",
"module",
"->",
"layout",
")",
")",
"{",
"$",
"layout",
"=",
"$",
"module",
"->",
"layout",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"layout",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"strncmp",
"(",
"$",
"layout",
",",
"'@'",
",",
"1",
")",
"===",
"0",
")",
"{",
"$",
"file",
"=",
"Zilf",
"::",
"getAlias",
"(",
"$",
"layout",
")",
";",
"}",
"elseif",
"(",
"strncmp",
"(",
"$",
"layout",
",",
"'/'",
",",
"1",
")",
"===",
"0",
")",
"{",
"$",
"file",
"=",
"Zilf",
"::",
"$",
"app",
"->",
"getLayoutPath",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"substr",
"(",
"$",
"layout",
",",
"1",
")",
";",
"}",
"else",
"{",
"$",
"file",
"=",
"$",
"module",
"->",
"getLayoutPath",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"layout",
";",
"}",
"if",
"(",
"pathinfo",
"(",
"$",
"file",
",",
"PATHINFO_EXTENSION",
")",
"!==",
"''",
")",
"{",
"return",
"$",
"file",
";",
"}",
"$",
"path",
"=",
"$",
"file",
".",
"'.'",
".",
"$",
"view",
"->",
"defaultExtension",
";",
"if",
"(",
"$",
"view",
"->",
"defaultExtension",
"!==",
"'php'",
"&&",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"file",
".",
"'.php'",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Finds the applicable layout file.
@param View $view the view object to render the layout file.
@return string|bool the layout file path, or false if layout is not needed.
Please refer to [[render()]] on how to specify this parameter.
@throws InvalidArgumentException if an invalid path alias is used to specify the layout.
|
[
"Finds",
"the",
"applicable",
"layout",
"file",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Controller.php#L504-L539
|
234,185
|
crysalead/sql-dialect
|
src/Statement/Select.php
|
Select.fields
|
public function fields($fields)
{
$fields = is_array($fields) && func_num_args() === 1 ? $fields : func_get_args();
$this->_parts['fields'] = Set::merge($this->_parts['fields'], $fields);
return $this;
}
|
php
|
public function fields($fields)
{
$fields = is_array($fields) && func_num_args() === 1 ? $fields : func_get_args();
$this->_parts['fields'] = Set::merge($this->_parts['fields'], $fields);
return $this;
}
|
[
"public",
"function",
"fields",
"(",
"$",
"fields",
")",
"{",
"$",
"fields",
"=",
"is_array",
"(",
"$",
"fields",
")",
"&&",
"func_num_args",
"(",
")",
"===",
"1",
"?",
"$",
"fields",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"_parts",
"[",
"'fields'",
"]",
"=",
"Set",
"::",
"merge",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'fields'",
"]",
",",
"$",
"fields",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds some fields to the query.
@param string|array $fields The fields.
@return string Formatted fields list.
|
[
"Adds",
"some",
"fields",
"to",
"the",
"query",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L60-L65
|
234,186
|
crysalead/sql-dialect
|
src/Statement/Select.php
|
Select.from
|
public function from($sources)
{
if (!$sources) {
throw new SqlException("A `FROM` clause requires a non empty table.");
}
$sources = is_array($sources) ? $sources : func_get_args();
$this->_parts['from'] += array_merge($this->_parts['from'], $sources);
return $this;
}
|
php
|
public function from($sources)
{
if (!$sources) {
throw new SqlException("A `FROM` clause requires a non empty table.");
}
$sources = is_array($sources) ? $sources : func_get_args();
$this->_parts['from'] += array_merge($this->_parts['from'], $sources);
return $this;
}
|
[
"public",
"function",
"from",
"(",
"$",
"sources",
")",
"{",
"if",
"(",
"!",
"$",
"sources",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"A `FROM` clause requires a non empty table.\"",
")",
";",
"}",
"$",
"sources",
"=",
"is_array",
"(",
"$",
"sources",
")",
"?",
"$",
"sources",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"_parts",
"[",
"'from'",
"]",
"+=",
"array_merge",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'from'",
"]",
",",
"$",
"sources",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds some tables in the from statement
@param string|array $sources The source tables.
@return string Formatted source table list.
|
[
"Adds",
"some",
"tables",
"in",
"the",
"from",
"statement"
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L73-L81
|
234,187
|
crysalead/sql-dialect
|
src/Statement/Select.php
|
Select.group
|
public function group($fields)
{
if (!$fields) {
return $this;
}
if ($fields = is_array($fields) ? $fields : func_get_args()) {
$this->_parts['group'] = array_merge($this->_parts['group'], array_fill_keys($fields, true));
}
return $this;
}
|
php
|
public function group($fields)
{
if (!$fields) {
return $this;
}
if ($fields = is_array($fields) ? $fields : func_get_args()) {
$this->_parts['group'] = array_merge($this->_parts['group'], array_fill_keys($fields, true));
}
return $this;
}
|
[
"public",
"function",
"group",
"(",
"$",
"fields",
")",
"{",
"if",
"(",
"!",
"$",
"fields",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"fields",
"=",
"is_array",
"(",
"$",
"fields",
")",
"?",
"$",
"fields",
":",
"func_get_args",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_parts",
"[",
"'group'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'group'",
"]",
",",
"array_fill_keys",
"(",
"$",
"fields",
",",
"true",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds some group by fields to the query.
@param string|array $fields The fields.
@return object Returns `$this`.
|
[
"Adds",
"some",
"group",
"by",
"fields",
"to",
"the",
"query",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L104-L113
|
234,188
|
crysalead/sql-dialect
|
src/Statement/Select.php
|
Select.having
|
public function having($conditions)
{
if ($conditions = is_array($conditions) && func_num_args() === 1 ? $conditions : func_get_args()) {
$this->_parts['having'][] = $conditions;
}
return $this;
}
|
php
|
public function having($conditions)
{
if ($conditions = is_array($conditions) && func_num_args() === 1 ? $conditions : func_get_args()) {
$this->_parts['having'][] = $conditions;
}
return $this;
}
|
[
"public",
"function",
"having",
"(",
"$",
"conditions",
")",
"{",
"if",
"(",
"$",
"conditions",
"=",
"is_array",
"(",
"$",
"conditions",
")",
"&&",
"func_num_args",
"(",
")",
"===",
"1",
"?",
"$",
"conditions",
":",
"func_get_args",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_parts",
"[",
"'having'",
"]",
"[",
"]",
"=",
"$",
"conditions",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds some having conditions to the query.
@param string|array $conditions The havings for this query.
@return object Returns `$this`.
|
[
"Adds",
"some",
"having",
"conditions",
"to",
"the",
"query",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L121-L127
|
234,189
|
crysalead/sql-dialect
|
src/Statement/Select.php
|
Select._group
|
protected function _group()
{
$result = [];
foreach ($this->_parts['group'] as $name => $value) {
$result[] = $this->dialect()->name($name);
}
return $fields = join(', ', $result);
}
|
php
|
protected function _group()
{
$result = [];
foreach ($this->_parts['group'] as $name => $value) {
$result[] = $this->dialect()->name($name);
}
return $fields = join(', ', $result);
}
|
[
"protected",
"function",
"_group",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'group'",
"]",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"name",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"fields",
"=",
"join",
"(",
"', '",
",",
"$",
"result",
")",
";",
"}"
] |
Build the `GROUP BY` clause.
@return string The `GROUP BY` clause.
|
[
"Build",
"the",
"GROUP",
"BY",
"clause",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L200-L207
|
234,190
|
crysalead/sql-dialect
|
src/Statement/Select.php
|
Select._buildJoins
|
protected function _buildJoins($schemas, $aliases)
{
$joins = [];
foreach ($this->_parts['joins'] as $value) {
$table = $value['join'];
$on = $value['on'];
$type = $value['type'];
$join = [strtoupper($type), 'JOIN'];
$join[] = $this->dialect()->name($table);
if ($on) {
$join[] = 'ON';
$join[] = $this->dialect()->conditions($on, compact('schemas', 'aliases'));
}
$joins[] = join(' ', $join);
}
return $joins ? ' ' . join(' ', $joins) : '';
}
|
php
|
protected function _buildJoins($schemas, $aliases)
{
$joins = [];
foreach ($this->_parts['joins'] as $value) {
$table = $value['join'];
$on = $value['on'];
$type = $value['type'];
$join = [strtoupper($type), 'JOIN'];
$join[] = $this->dialect()->name($table);
if ($on) {
$join[] = 'ON';
$join[] = $this->dialect()->conditions($on, compact('schemas', 'aliases'));
}
$joins[] = join(' ', $join);
}
return $joins ? ' ' . join(' ', $joins) : '';
}
|
[
"protected",
"function",
"_buildJoins",
"(",
"$",
"schemas",
",",
"$",
"aliases",
")",
"{",
"$",
"joins",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'joins'",
"]",
"as",
"$",
"value",
")",
"{",
"$",
"table",
"=",
"$",
"value",
"[",
"'join'",
"]",
";",
"$",
"on",
"=",
"$",
"value",
"[",
"'on'",
"]",
";",
"$",
"type",
"=",
"$",
"value",
"[",
"'type'",
"]",
";",
"$",
"join",
"=",
"[",
"strtoupper",
"(",
"$",
"type",
")",
",",
"'JOIN'",
"]",
";",
"$",
"join",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"name",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"on",
")",
"{",
"$",
"join",
"[",
"]",
"=",
"'ON'",
";",
"$",
"join",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"conditions",
"(",
"$",
"on",
",",
"compact",
"(",
"'schemas'",
",",
"'aliases'",
")",
")",
";",
"}",
"$",
"joins",
"[",
"]",
"=",
"join",
"(",
"' '",
",",
"$",
"join",
")",
";",
"}",
"return",
"$",
"joins",
"?",
"' '",
".",
"join",
"(",
"' '",
",",
"$",
"joins",
")",
":",
"''",
";",
"}"
] |
Build the `JOIN` clause.
@return string The `JOIN` clause.
|
[
"Build",
"the",
"JOIN",
"clause",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L214-L232
|
234,191
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Export/Format/BaseFormat.php
|
BaseFormat.createResponse
|
public function createResponse($result)
{
return Response::make($result, 200, [
'Content-Type' => $this->getContentType(),
'Content-Disposition' => sprintf('attachment; filename="%s"', $this->getFilename()),
]);
}
|
php
|
public function createResponse($result)
{
return Response::make($result, 200, [
'Content-Type' => $this->getContentType(),
'Content-Disposition' => sprintf('attachment; filename="%s"', $this->getFilename()),
]);
}
|
[
"public",
"function",
"createResponse",
"(",
"$",
"result",
")",
"{",
"return",
"Response",
"::",
"make",
"(",
"$",
"result",
",",
"200",
",",
"[",
"'Content-Type'",
"=>",
"$",
"this",
"->",
"getContentType",
"(",
")",
",",
"'Content-Disposition'",
"=>",
"sprintf",
"(",
"'attachment; filename=\"%s\"'",
",",
"$",
"this",
"->",
"getFilename",
"(",
")",
")",
",",
"]",
")",
";",
"}"
] |
Create the download response.
@param string $result
@access public
@return mixed
|
[
"Create",
"the",
"download",
"response",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Export/Format/BaseFormat.php#L133-L139
|
234,192
|
txj123/zilf
|
src/Zilf/Db/ActiveRecord.php
|
ActiveRecord.filterCondition
|
protected static function filterCondition(array $condition)
{
$result = [];
// valid column names are table column names or column names prefixed with table name
$columnNames = static::getTableSchema()->getColumnNames();
$tableName = static::tableName();
$columnNames = array_merge(
$columnNames, array_map(
function ($columnName) use ($tableName) {
return "$tableName.$columnName";
}, $columnNames
)
);
foreach ($condition as $key => $value) {
if (is_string($key) && !in_array($key, $columnNames, true)) {
throw new InvalidArgumentException('Key "' . $key . '" is not a column name and can not be used as a filter');
}
$result[$key] = is_array($value) ? array_values($value) : $value;
}
return $result;
}
|
php
|
protected static function filterCondition(array $condition)
{
$result = [];
// valid column names are table column names or column names prefixed with table name
$columnNames = static::getTableSchema()->getColumnNames();
$tableName = static::tableName();
$columnNames = array_merge(
$columnNames, array_map(
function ($columnName) use ($tableName) {
return "$tableName.$columnName";
}, $columnNames
)
);
foreach ($condition as $key => $value) {
if (is_string($key) && !in_array($key, $columnNames, true)) {
throw new InvalidArgumentException('Key "' . $key . '" is not a column name and can not be used as a filter');
}
$result[$key] = is_array($value) ? array_values($value) : $value;
}
return $result;
}
|
[
"protected",
"static",
"function",
"filterCondition",
"(",
"array",
"$",
"condition",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"// valid column names are table column names or column names prefixed with table name",
"$",
"columnNames",
"=",
"static",
"::",
"getTableSchema",
"(",
")",
"->",
"getColumnNames",
"(",
")",
";",
"$",
"tableName",
"=",
"static",
"::",
"tableName",
"(",
")",
";",
"$",
"columnNames",
"=",
"array_merge",
"(",
"$",
"columnNames",
",",
"array_map",
"(",
"function",
"(",
"$",
"columnName",
")",
"use",
"(",
"$",
"tableName",
")",
"{",
"return",
"\"$tableName.$columnName\"",
";",
"}",
",",
"$",
"columnNames",
")",
")",
";",
"foreach",
"(",
"$",
"condition",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
"&&",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"columnNames",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Key \"'",
".",
"$",
"key",
".",
"'\" is not a column name and can not be used as a filter'",
")",
";",
"}",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"is_array",
"(",
"$",
"value",
")",
"?",
"array_values",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Filters array condition before it is assiged to a Query filter.
This method will ensure that an array condition only filters on existing table columns.
@param array $condition condition to filter.
@return array filtered condition.
@throws InvalidArgumentException in case array contains unsafe values.
@since 2.0.15
@internal
|
[
"Filters",
"array",
"condition",
"before",
"it",
"is",
"assiged",
"to",
"a",
"Query",
"filter",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/ActiveRecord.php#L209-L230
|
234,193
|
oxygen-cms/core
|
src/Html/Navigation/Navigation.php
|
Navigation.all
|
public function all($toolbar = self::PRIMARY) {
$this->loadLazyOrders($toolbar);
return $this->toolbars[$toolbar]->getItems();
}
|
php
|
public function all($toolbar = self::PRIMARY) {
$this->loadLazyOrders($toolbar);
return $this->toolbars[$toolbar]->getItems();
}
|
[
"public",
"function",
"all",
"(",
"$",
"toolbar",
"=",
"self",
"::",
"PRIMARY",
")",
"{",
"$",
"this",
"->",
"loadLazyOrders",
"(",
"$",
"toolbar",
")",
";",
"return",
"$",
"this",
"->",
"toolbars",
"[",
"$",
"toolbar",
"]",
"->",
"getItems",
"(",
")",
";",
"}"
] |
Returns all toolbar items.
@param integer $toolbar Which toolbar to use
@return array
|
[
"Returns",
"all",
"toolbar",
"items",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Navigation/Navigation.php#L77-L81
|
234,194
|
oxygen-cms/core
|
src/Html/Navigation/Navigation.php
|
Navigation.order
|
public function order($toolbar, $keys) {
if(is_callable($keys)) {
$this->addLazyOrder($toolbar, $keys);
} else {
$this->toolbars[$toolbar]->setOrder($keys);
}
}
|
php
|
public function order($toolbar, $keys) {
if(is_callable($keys)) {
$this->addLazyOrder($toolbar, $keys);
} else {
$this->toolbars[$toolbar]->setOrder($keys);
}
}
|
[
"public",
"function",
"order",
"(",
"$",
"toolbar",
",",
"$",
"keys",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"this",
"->",
"addLazyOrder",
"(",
"$",
"toolbar",
",",
"$",
"keys",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"toolbars",
"[",
"$",
"toolbar",
"]",
"->",
"setOrder",
"(",
"$",
"keys",
")",
";",
"}",
"}"
] |
Orders the toolbar.
@param integer $toolbar Which toolbar to use
@param array|callable $keys
@return void
|
[
"Orders",
"the",
"toolbar",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Navigation/Navigation.php#L100-L106
|
234,195
|
oxygen-cms/core
|
src/Html/Navigation/Navigation.php
|
Navigation.loadLazyOrders
|
protected function loadLazyOrders($toolbar) {
foreach($this->lazyOrders[$toolbar] as $callback) {
$this->order($toolbar, $callback());
}
}
|
php
|
protected function loadLazyOrders($toolbar) {
foreach($this->lazyOrders[$toolbar] as $callback) {
$this->order($toolbar, $callback());
}
}
|
[
"protected",
"function",
"loadLazyOrders",
"(",
"$",
"toolbar",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"lazyOrders",
"[",
"$",
"toolbar",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"order",
"(",
"$",
"toolbar",
",",
"$",
"callback",
"(",
")",
")",
";",
"}",
"}"
] |
Loads orders of the navigation items.
@param string $toolbar
@return void
|
[
"Loads",
"orders",
"of",
"the",
"navigation",
"items",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Navigation/Navigation.php#L124-L128
|
234,196
|
willemo/flightstats
|
src/FlexClient.php
|
FlexClient.getClient
|
public function getClient()
{
if ($this->client === null) {
$this->client = new Client([
'base_uri' => $this->config['base_uri'],
]);
}
return $this->client;
}
|
php
|
public function getClient()
{
if ($this->client === null) {
$this->client = new Client([
'base_uri' => $this->config['base_uri'],
]);
}
return $this->client;
}
|
[
"public",
"function",
"getClient",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"client",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"client",
"=",
"new",
"Client",
"(",
"[",
"'base_uri'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'base_uri'",
"]",
",",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"client",
";",
"}"
] |
Get the configured HTTP client.
@return Client The configured HTTP client
|
[
"Get",
"the",
"configured",
"HTTP",
"client",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/FlexClient.php#L70-L79
|
234,197
|
willemo/flightstats
|
src/FlexClient.php
|
FlexClient.buildEndpoint
|
protected function buildEndpoint($api, $version, $endpoint)
{
return implode('/', [
$api,
$this->config['protocol'],
$version,
$this->config['format'],
$endpoint,
]);
}
|
php
|
protected function buildEndpoint($api, $version, $endpoint)
{
return implode('/', [
$api,
$this->config['protocol'],
$version,
$this->config['format'],
$endpoint,
]);
}
|
[
"protected",
"function",
"buildEndpoint",
"(",
"$",
"api",
",",
"$",
"version",
",",
"$",
"endpoint",
")",
"{",
"return",
"implode",
"(",
"'/'",
",",
"[",
"$",
"api",
",",
"$",
"this",
"->",
"config",
"[",
"'protocol'",
"]",
",",
"$",
"version",
",",
"$",
"this",
"->",
"config",
"[",
"'format'",
"]",
",",
"$",
"endpoint",
",",
"]",
")",
";",
"}"
] |
Build the endpoint of the URI.
@param string $api The API name
@param string $version The API version
@param string $endpoint The endpoint to use
@return string The full endpoint string for this API endpoint
|
[
"Build",
"the",
"endpoint",
"of",
"the",
"URI",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/FlexClient.php#L152-L161
|
234,198
|
willemo/flightstats
|
src/FlexClient.php
|
FlexClient.buildQuery
|
protected function buildQuery(array $queryParams = [])
{
$auth = [
'appId' => $this->config['appId'],
'appKey' => $this->config['appKey'],
];
$queryParams = array_merge($auth, $queryParams);
if (isset($queryParams['extendedOptions'])) {
$extendedOptions = $queryParams['extendedOptions'];
} else {
$extendedOptions = [];
}
if (!is_array($extendedOptions)) {
$extendedOptions = [$extendedOptions];
}
if ($this->config['use_http_errors'] &&
!in_array('useHTTPErrors', $extendedOptions)
) {
$extendedOptions[] = 'useHTTPErrors';
}
$queryParams['extendedOptions'] = implode('+', $extendedOptions);
return $queryParams;
}
|
php
|
protected function buildQuery(array $queryParams = [])
{
$auth = [
'appId' => $this->config['appId'],
'appKey' => $this->config['appKey'],
];
$queryParams = array_merge($auth, $queryParams);
if (isset($queryParams['extendedOptions'])) {
$extendedOptions = $queryParams['extendedOptions'];
} else {
$extendedOptions = [];
}
if (!is_array($extendedOptions)) {
$extendedOptions = [$extendedOptions];
}
if ($this->config['use_http_errors'] &&
!in_array('useHTTPErrors', $extendedOptions)
) {
$extendedOptions[] = 'useHTTPErrors';
}
$queryParams['extendedOptions'] = implode('+', $extendedOptions);
return $queryParams;
}
|
[
"protected",
"function",
"buildQuery",
"(",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"auth",
"=",
"[",
"'appId'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'appId'",
"]",
",",
"'appKey'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'appKey'",
"]",
",",
"]",
";",
"$",
"queryParams",
"=",
"array_merge",
"(",
"$",
"auth",
",",
"$",
"queryParams",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"queryParams",
"[",
"'extendedOptions'",
"]",
")",
")",
"{",
"$",
"extendedOptions",
"=",
"$",
"queryParams",
"[",
"'extendedOptions'",
"]",
";",
"}",
"else",
"{",
"$",
"extendedOptions",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"extendedOptions",
")",
")",
"{",
"$",
"extendedOptions",
"=",
"[",
"$",
"extendedOptions",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'use_http_errors'",
"]",
"&&",
"!",
"in_array",
"(",
"'useHTTPErrors'",
",",
"$",
"extendedOptions",
")",
")",
"{",
"$",
"extendedOptions",
"[",
"]",
"=",
"'useHTTPErrors'",
";",
"}",
"$",
"queryParams",
"[",
"'extendedOptions'",
"]",
"=",
"implode",
"(",
"'+'",
",",
"$",
"extendedOptions",
")",
";",
"return",
"$",
"queryParams",
";",
"}"
] |
Build the query array for the endpoint, including authentication
information.
@param array $queryParams The query parameters to use
@return array The query parameters
|
[
"Build",
"the",
"query",
"array",
"for",
"the",
"endpoint",
"including",
"authentication",
"information",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/FlexClient.php#L170-L198
|
234,199
|
willemo/flightstats
|
src/FlexClient.php
|
FlexClient.parseClientException
|
protected function parseClientException(ClientException $exception)
{
$response = $exception->getResponse();
$lines = explode("\n", $response->getBody());
$message = 'Something went wrong';
foreach ($lines as $line) {
if (strpos($line, 'message') !== false) {
$message = substr($line, 9);
break;
}
}
throw new FlexClientException($message, 0);
}
|
php
|
protected function parseClientException(ClientException $exception)
{
$response = $exception->getResponse();
$lines = explode("\n", $response->getBody());
$message = 'Something went wrong';
foreach ($lines as $line) {
if (strpos($line, 'message') !== false) {
$message = substr($line, 9);
break;
}
}
throw new FlexClientException($message, 0);
}
|
[
"protected",
"function",
"parseClientException",
"(",
"ClientException",
"$",
"exception",
")",
"{",
"$",
"response",
"=",
"$",
"exception",
"->",
"getResponse",
"(",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"$",
"message",
"=",
"'Something went wrong'",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"line",
",",
"'message'",
")",
"!==",
"false",
")",
"{",
"$",
"message",
"=",
"substr",
"(",
"$",
"line",
",",
"9",
")",
";",
"break",
";",
"}",
"}",
"throw",
"new",
"FlexClientException",
"(",
"$",
"message",
",",
"0",
")",
";",
"}"
] |
Parse the error response from the API
@param ClientException $exception The exception that contains the
response
@throws FlexClientException The parsed error response from the API
@return void
|
[
"Parse",
"the",
"error",
"response",
"from",
"the",
"API"
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/FlexClient.php#L219-L236
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.