repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
picturae/php-composition-utils | src/WithEvents.php | WithEvents.trigger | public function trigger($eventType, $params)
{
if (isset($this->eventList[$eventType]) && is_array($this->eventList[$eventType])) {
foreach ($this->eventList[$eventType] as $callbackDescriptor) {
call_user_func_array($callbackDescriptor['cb'], $params);
}
}
} | php | public function trigger($eventType, $params)
{
if (isset($this->eventList[$eventType]) && is_array($this->eventList[$eventType])) {
foreach ($this->eventList[$eventType] as $callbackDescriptor) {
call_user_func_array($callbackDescriptor['cb'], $params);
}
}
} | [
"public",
"function",
"trigger",
"(",
"$",
"eventType",
",",
"$",
"params",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"eventList",
"[",
"$",
"eventType",
"]",
"as",
"$",
"callbackDescriptor",
")",
"{",
"call_user_func_array",
"(",
"$",
"callbackDescriptor",
"[",
"'cb'",
"]",
",",
"$",
"params",
")",
";",
"}",
"}",
"}"
] | Fire an event
@param string $event - Event type constant.
@param array $params - Additional parameters. | [
"Fire",
"an",
"event"
] | train | https://github.com/picturae/php-composition-utils/blob/59a8191066c27687daabc8c5b33addb3599826ab/src/WithEvents.php#L64-L71 |
dann95/ts3-php | TeamSpeak3/Node/Servergroup.php | Servergroup.delete | public function delete($force = false)
{
$this->getParent()->serverGroupDelete($this->getId(), $force);
unset($this);
} | php | public function delete($force = false)
{
$this->getParent()->serverGroupDelete($this->getId(), $force);
unset($this);
} | [
"public",
"function",
"delete",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"serverGroupDelete",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"force",
")",
";",
"unset",
"(",
"$",
"this",
")",
";",
"}"
] | Deletes the server group. If $force is set to 1, the server group will be
deleted even if there are clients within.
@param boolean $force
@return void | [
"Deletes",
"the",
"server",
"group",
".",
"If",
"$force",
"is",
"set",
"to",
"1",
"the",
"server",
"group",
"will",
"be",
"deleted",
"even",
"if",
"there",
"are",
"clients",
"within",
"."
] | train | https://github.com/dann95/ts3-php/blob/d4693d78b54be0177a2b5fab316c0ff9d036238d/TeamSpeak3/Node/Servergroup.php#L79-L84 |
dann95/ts3-php | TeamSpeak3/Node/Servergroup.php | Servergroup.permAssign | public function permAssign($permid, $permvalue, $permnegated = false, $permskip = false)
{
return $this->getParent()->serverGroupPermAssign($this->getId(), $permid, $permvalue, $permnegated, $permskip);
} | php | public function permAssign($permid, $permvalue, $permnegated = false, $permskip = false)
{
return $this->getParent()->serverGroupPermAssign($this->getId(), $permid, $permvalue, $permnegated, $permskip);
} | [
"public",
"function",
"permAssign",
"(",
"$",
"permid",
",",
"$",
"permvalue",
",",
"$",
"permnegated",
"=",
"false",
",",
"$",
"permskip",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"serverGroupPermAssign",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"permid",
",",
"$",
"permvalue",
",",
"$",
"permnegated",
",",
"$",
"permskip",
")",
";",
"}"
] | Adds a set of specified permissions to the server group. Multiple permissions
can be added by providing the four parameters of each permission in separate arrays.
@param integer $permid
@param integer $permvalue
@param bool|int $permnegated
@param bool|int $permskip
@return void | [
"Adds",
"a",
"set",
"of",
"specified",
"permissions",
"to",
"the",
"server",
"group",
".",
"Multiple",
"permissions",
"can",
"be",
"added",
"by",
"providing",
"the",
"four",
"parameters",
"of",
"each",
"permission",
"in",
"separate",
"arrays",
"."
] | train | https://github.com/dann95/ts3-php/blob/d4693d78b54be0177a2b5fab316c0ff9d036238d/TeamSpeak3/Node/Servergroup.php#L120-L123 |
netbull/CoreBundle | DependencyInjection/Compiler/FormTwigTemplateCompilerPass.php | FormTwigTemplateCompilerPass.process | public function process(ContainerBuilder $container)
{
if (false === $container->hasParameter('twig.form.resources')) {
return;
}
$parameter = $container->getParameter('twig.form.resources');
if (in_array($this->telLayout, $parameter)) {
return;
}
// Insert right after base template if it exists.
if (($key = array_search('bootstrap_', $parameter)) !== false) {
array_splice($parameter, ++$key, 0, array($this->telBootstrapLayout));
} elseif (($key = array_search('form_div_layout.html.twig', $parameter)) !== false) {
array_splice($parameter, ++$key, 0, array($this->telLayout));
} else {
// Put it in first position.
array_unshift($parameter, array($this->telLayout));
}
$container->setParameter('twig.form.resources', $parameter);
} | php | public function process(ContainerBuilder $container)
{
if (false === $container->hasParameter('twig.form.resources')) {
return;
}
$parameter = $container->getParameter('twig.form.resources');
if (in_array($this->telLayout, $parameter)) {
return;
}
// Insert right after base template if it exists.
if (($key = array_search('bootstrap_', $parameter)) !== false) {
array_splice($parameter, ++$key, 0, array($this->telBootstrapLayout));
} elseif (($key = array_search('form_div_layout.html.twig', $parameter)) !== false) {
array_splice($parameter, ++$key, 0, array($this->telLayout));
} else {
// Put it in first position.
array_unshift($parameter, array($this->telLayout));
}
$container->setParameter('twig.form.resources', $parameter);
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"container",
"->",
"hasParameter",
"(",
"'twig.form.resources'",
")",
")",
"{",
"return",
";",
"}",
"$",
"parameter",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'twig.form.resources'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"telLayout",
",",
"$",
"parameter",
")",
")",
"{",
"return",
";",
"}",
"// Insert right after base template if it exists.",
"if",
"(",
"(",
"$",
"key",
"=",
"array_search",
"(",
"'bootstrap_'",
",",
"$",
"parameter",
")",
")",
"!==",
"false",
")",
"{",
"array_splice",
"(",
"$",
"parameter",
",",
"++",
"$",
"key",
",",
"0",
",",
"array",
"(",
"$",
"this",
"->",
"telBootstrapLayout",
")",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"key",
"=",
"array_search",
"(",
"'form_div_layout.html.twig'",
",",
"$",
"parameter",
")",
")",
"!==",
"false",
")",
"{",
"array_splice",
"(",
"$",
"parameter",
",",
"++",
"$",
"key",
",",
"0",
",",
"array",
"(",
"$",
"this",
"->",
"telLayout",
")",
")",
";",
"}",
"else",
"{",
"// Put it in first position.",
"array_unshift",
"(",
"$",
"parameter",
",",
"array",
"(",
"$",
"this",
"->",
"telLayout",
")",
")",
";",
"}",
"$",
"container",
"->",
"setParameter",
"(",
"'twig.form.resources'",
",",
"$",
"parameter",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/DependencyInjection/Compiler/FormTwigTemplateCompilerPass.php#L20-L43 |
praxigento/mobi_mod_downline | Helper/Tree.php | Tree.composeSnapData | private function composeSnapData(&$result, $tree, $parentId = null)
{
foreach ($tree as $custId => $children) {
if (is_null($parentId)) {
/* this is root node */
$result[$custId] = [
Snap::A_CUSTOMER_REF => $custId,
Snap::A_PARENT_REF => $custId,
Snap::A_DEPTH => Cfg::INIT_DEPTH,
Snap::A_PATH => Cfg::DTPS
];
} else {
$parentData = $result[$parentId];
$result[$custId] = [
Snap::A_CUSTOMER_REF => $custId,
Snap::A_PARENT_REF => $parentId,
Snap::A_DEPTH => $parentData[Snap::A_DEPTH] + 1,
Snap::A_PATH => $parentData[Snap::A_PATH] . $parentId . Cfg::DTPS
];
}
if (sizeof($children) > 0) {
$this->composeSnapData($result, $children, $custId);
}
}
} | php | private function composeSnapData(&$result, $tree, $parentId = null)
{
foreach ($tree as $custId => $children) {
if (is_null($parentId)) {
/* this is root node */
$result[$custId] = [
Snap::A_CUSTOMER_REF => $custId,
Snap::A_PARENT_REF => $custId,
Snap::A_DEPTH => Cfg::INIT_DEPTH,
Snap::A_PATH => Cfg::DTPS
];
} else {
$parentData = $result[$parentId];
$result[$custId] = [
Snap::A_CUSTOMER_REF => $custId,
Snap::A_PARENT_REF => $parentId,
Snap::A_DEPTH => $parentData[Snap::A_DEPTH] + 1,
Snap::A_PATH => $parentData[Snap::A_PATH] . $parentId . Cfg::DTPS
];
}
if (sizeof($children) > 0) {
$this->composeSnapData($result, $children, $custId);
}
}
} | [
"private",
"function",
"composeSnapData",
"(",
"&",
"$",
"result",
",",
"$",
"tree",
",",
"$",
"parentId",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"tree",
"as",
"$",
"custId",
"=>",
"$",
"children",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"parentId",
")",
")",
"{",
"/* this is root node */",
"$",
"result",
"[",
"$",
"custId",
"]",
"=",
"[",
"Snap",
"::",
"A_CUSTOMER_REF",
"=>",
"$",
"custId",
",",
"Snap",
"::",
"A_PARENT_REF",
"=>",
"$",
"custId",
",",
"Snap",
"::",
"A_DEPTH",
"=>",
"Cfg",
"::",
"INIT_DEPTH",
",",
"Snap",
"::",
"A_PATH",
"=>",
"Cfg",
"::",
"DTPS",
"]",
";",
"}",
"else",
"{",
"$",
"parentData",
"=",
"$",
"result",
"[",
"$",
"parentId",
"]",
";",
"$",
"result",
"[",
"$",
"custId",
"]",
"=",
"[",
"Snap",
"::",
"A_CUSTOMER_REF",
"=>",
"$",
"custId",
",",
"Snap",
"::",
"A_PARENT_REF",
"=>",
"$",
"parentId",
",",
"Snap",
"::",
"A_DEPTH",
"=>",
"$",
"parentData",
"[",
"Snap",
"::",
"A_DEPTH",
"]",
"+",
"1",
",",
"Snap",
"::",
"A_PATH",
"=>",
"$",
"parentData",
"[",
"Snap",
"::",
"A_PATH",
"]",
".",
"$",
"parentId",
".",
"Cfg",
"::",
"DTPS",
"]",
";",
"}",
"if",
"(",
"sizeof",
"(",
"$",
"children",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"composeSnapData",
"(",
"$",
"result",
",",
"$",
"children",
",",
"$",
"custId",
")",
";",
"}",
"}",
"}"
] | Recursively compose $result as array of elements:
[
Snap::A_CUSTOMER_ID,
Snap::A_PARENT_ID,
Snap::A_DEPTH,
Snap::A_PATH
]
@param $result
@param $tree
@param null $parentId | [
"Recursively",
"compose",
"$result",
"as",
"array",
"of",
"elements",
":",
"[",
"Snap",
"::",
"A_CUSTOMER_ID",
"Snap",
"::",
"A_PARENT_ID",
"Snap",
"::",
"A_DEPTH",
"Snap",
"::",
"A_PATH",
"]"
] | train | https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Helper/Tree.php#L30-L54 |
praxigento/mobi_mod_downline | Helper/Tree.php | Tree.getParentId | private function getParentId($item, $key)
{
if (is_array($item)) {
$result = $item[$key];
} elseif ($item instanceof \Praxigento\Core\Data) {
$result = $item->get($key);
} else {
$result = $item;
}
return $result;
} | php | private function getParentId($item, $key)
{
if (is_array($item)) {
$result = $item[$key];
} elseif ($item instanceof \Praxigento\Core\Data) {
$result = $item->get($key);
} else {
$result = $item;
}
return $result;
} | [
"private",
"function",
"getParentId",
"(",
"$",
"item",
",",
"$",
"key",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"$",
"result",
"=",
"$",
"item",
"[",
"$",
"key",
"]",
";",
"}",
"elseif",
"(",
"$",
"item",
"instanceof",
"\\",
"Praxigento",
"\\",
"Core",
"\\",
"Data",
")",
"{",
"$",
"result",
"=",
"$",
"item",
"->",
"get",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get Parent ID from entry. Entry can be integer, array or Data Object.
@param int|array|\Praxigento\Core\Data $item
@param string $key
@return int | [
"Get",
"Parent",
"ID",
"from",
"entry",
".",
"Entry",
"can",
"be",
"integer",
"array",
"or",
"Data",
"Object",
"."
] | train | https://github.com/praxigento/mobi_mod_downline/blob/0f3c276dfff1aa029f9fd205ccfc56f207a2e75b/Helper/Tree.php#L102-L112 |
jenskooij/cloudcontrol | src/storage/factories/ApplicationComponentFactory.php | ApplicationComponentFactory.createApplicationComponentFromPostValues | public static function createApplicationComponentFromPostValues($postValues)
{
if (isset($postValues['title'], $postValues['component'])) {
$applicationComponent = new \stdClass();
$applicationComponent->title = $postValues['title'];
$applicationComponent->slug = StringUtil::slugify($postValues['title']);
$applicationComponent->component = $postValues['component'];
$applicationComponent->parameters = new \stdClass();
if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
foreach ($postValues['parameterNames'] as $key => $value) {
$applicationComponent->parameters->$value = $postValues['parameterValues'][$key];
}
}
return $applicationComponent;
} else {
throw new \Exception('Trying to create application component with invalid data.');
}
} | php | public static function createApplicationComponentFromPostValues($postValues)
{
if (isset($postValues['title'], $postValues['component'])) {
$applicationComponent = new \stdClass();
$applicationComponent->title = $postValues['title'];
$applicationComponent->slug = StringUtil::slugify($postValues['title']);
$applicationComponent->component = $postValues['component'];
$applicationComponent->parameters = new \stdClass();
if (isset($postValues['parameterNames'], $postValues['parameterValues'])) {
foreach ($postValues['parameterNames'] as $key => $value) {
$applicationComponent->parameters->$value = $postValues['parameterValues'][$key];
}
}
return $applicationComponent;
} else {
throw new \Exception('Trying to create application component with invalid data.');
}
} | [
"public",
"static",
"function",
"createApplicationComponentFromPostValues",
"(",
"$",
"postValues",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"postValues",
"[",
"'title'",
"]",
",",
"$",
"postValues",
"[",
"'component'",
"]",
")",
")",
"{",
"$",
"applicationComponent",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"applicationComponent",
"->",
"title",
"=",
"$",
"postValues",
"[",
"'title'",
"]",
";",
"$",
"applicationComponent",
"->",
"slug",
"=",
"StringUtil",
"::",
"slugify",
"(",
"$",
"postValues",
"[",
"'title'",
"]",
")",
";",
"$",
"applicationComponent",
"->",
"component",
"=",
"$",
"postValues",
"[",
"'component'",
"]",
";",
"$",
"applicationComponent",
"->",
"parameters",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"postValues",
"[",
"'parameterNames'",
"]",
",",
"$",
"postValues",
"[",
"'parameterValues'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"postValues",
"[",
"'parameterNames'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"applicationComponent",
"->",
"parameters",
"->",
"$",
"value",
"=",
"$",
"postValues",
"[",
"'parameterValues'",
"]",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"applicationComponent",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Trying to create application component with invalid data.'",
")",
";",
"}",
"}"
] | @param $postValues
@return \stdClass
@throws \Exception | [
"@param",
"$postValues"
] | train | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/factories/ApplicationComponentFactory.php#L21-L39 |
Wedeto/Log | src/Writer/AbstractWriter.php | AbstractWriter.isLevelEnabled | public function isLevelEnabled(string $level, int $level_num = null)
{
if ($level_num === null)
$level_num = Logger::getLevelNumeric($level);
return $level_num >= $this->min_level;
} | php | public function isLevelEnabled(string $level, int $level_num = null)
{
if ($level_num === null)
$level_num = Logger::getLevelNumeric($level);
return $level_num >= $this->min_level;
} | [
"public",
"function",
"isLevelEnabled",
"(",
"string",
"$",
"level",
",",
"int",
"$",
"level_num",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"level_num",
"===",
"null",
")",
"$",
"level_num",
"=",
"Logger",
"::",
"getLevelNumeric",
"(",
"$",
"level",
")",
";",
"return",
"$",
"level_num",
">=",
"$",
"this",
"->",
"min_level",
";",
"}"
] | Return if a message of a specific level would be accepted
@param string $level The LogLevel
@param int $level_num The level as int, with 0 being DEBUG and 8 being EMERGENCY. When omitted,
it is obtained from Logger.
@return bool True if a message with this level would be accepted, false it it would be dropped. | [
"Return",
"if",
"a",
"message",
"of",
"a",
"specific",
"level",
"would",
"be",
"accepted"
] | train | https://github.com/Wedeto/Log/blob/88252c5052089fdcc5dae466d1ad5889bb2b735f/src/Writer/AbstractWriter.php#L71-L76 |
Wedeto/Log | src/Writer/AbstractWriter.php | AbstractWriter.format | public function format(string $level, string $message, array $context)
{
if ($this->formatter !== null)
return $this->formatter->format($level, $message, $context);
// Fall back to the logger placeholder filler
return Logger::fillPlaceholders($message, $context);
} | php | public function format(string $level, string $message, array $context)
{
if ($this->formatter !== null)
return $this->formatter->format($level, $message, $context);
// Fall back to the logger placeholder filler
return Logger::fillPlaceholders($message, $context);
} | [
"public",
"function",
"format",
"(",
"string",
"$",
"level",
",",
"string",
"$",
"message",
",",
"array",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formatter",
"!==",
"null",
")",
"return",
"$",
"this",
"->",
"formatter",
"->",
"format",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
";",
"// Fall back to the logger placeholder filler",
"return",
"Logger",
"::",
"fillPlaceholders",
"(",
"$",
"message",
",",
"$",
"context",
")",
";",
"}"
] | Format the message
@param string $level The LogLevel of the message
@param string $messsage The message to be formatted
@param array $context The values for the placeholders
@return string The formatted message. | [
"Format",
"the",
"message"
] | train | https://github.com/Wedeto/Log/blob/88252c5052089fdcc5dae466d1ad5889bb2b735f/src/Writer/AbstractWriter.php#L85-L92 |
synaq/SynaqCurlBundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('synaq_curl');
$rootNode
->children()
->scalarNode('user_agent')->defaultValue('user_agent')->end()
->scalarNode('cookie_file')->defaultFalse()->end()
->scalarNode('follow_redirects')->defaultTrue()->end()
->scalarNode('referrer')->defaultValue('referrer')->end()
->variableNode('options')->defaultValue(array())->end()
->variableNode('headers')->defaultValue(array())->end()
->end();
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('synaq_curl');
$rootNode
->children()
->scalarNode('user_agent')->defaultValue('user_agent')->end()
->scalarNode('cookie_file')->defaultFalse()->end()
->scalarNode('follow_redirects')->defaultTrue()->end()
->scalarNode('referrer')->defaultValue('referrer')->end()
->variableNode('options')->defaultValue(array())->end()
->variableNode('headers')->defaultValue(array())->end()
->end();
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'synaq_curl'",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'user_agent'",
")",
"->",
"defaultValue",
"(",
"'user_agent'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'cookie_file'",
")",
"->",
"defaultFalse",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'follow_redirects'",
")",
"->",
"defaultTrue",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'referrer'",
")",
"->",
"defaultValue",
"(",
"'referrer'",
")",
"->",
"end",
"(",
")",
"->",
"variableNode",
"(",
"'options'",
")",
"->",
"defaultValue",
"(",
"array",
"(",
")",
")",
"->",
"end",
"(",
")",
"->",
"variableNode",
"(",
"'headers'",
")",
"->",
"defaultValue",
"(",
"array",
"(",
")",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"treeBuilder",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/synaq/SynaqCurlBundle/blob/3bfb4ef7693ea621c31b9a32565a23c7d99f8a14/DependencyInjection/Configuration.php#L18-L34 |
Stinger-Soft/DoctrineCommons | src/StingerSoft/DoctrineCommons/Utils/DoctrineFunctions.php | DoctrineFunctions.getAllMetadata | protected function getAllMetadata($managerName = null) {
if(!$this->allMetadata) {
$this->allMetadata = $this->registry->getManager($managerName)->getMetadataFactory()->getAllMetadata();
}
return $this->allMetadata;
} | php | protected function getAllMetadata($managerName = null) {
if(!$this->allMetadata) {
$this->allMetadata = $this->registry->getManager($managerName)->getMetadataFactory()->getAllMetadata();
}
return $this->allMetadata;
} | [
"protected",
"function",
"getAllMetadata",
"(",
"$",
"managerName",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"allMetadata",
")",
"{",
"$",
"this",
"->",
"allMetadata",
"=",
"$",
"this",
"->",
"registry",
"->",
"getManager",
"(",
"$",
"managerName",
")",
"->",
"getMetadataFactory",
"(",
")",
"->",
"getAllMetadata",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"allMetadata",
";",
"}"
] | Returns all management class metadata
@return ClassMetadata[] | [
"Returns",
"all",
"management",
"class",
"metadata"
] | train | https://github.com/Stinger-Soft/DoctrineCommons/blob/1f0dd56a94654c8de63927d7eec2175aab3cf809/src/StingerSoft/DoctrineCommons/Utils/DoctrineFunctions.php#L226-L231 |
netbull/CoreBundle | Form/Type/PhoneNumberType.php | PhoneNumberType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (self::WIDGET_COUNTRY_CHOICE === $options['widget']) {
$util = PhoneNumberUtil::getInstance();
$countries = [];
if (is_array($options['country_choices'])) {
foreach ($options['country_choices'] as $country) {
$code = $util->getCountryCodeForRegion($country);
if ($code) {
$countries[$country] = $code;
}
}
}
if (empty($countries)) {
foreach ($util->getSupportedRegions() as $country) {
$countries[$country] = $util->getCountryCodeForRegion($country);
}
}
$countryChoices = [];
foreach (Intl::getRegionBundle()->getCountryNames() as $region => $name) {
if (false === isset($countries[$region])) {
continue;
}
$countryChoices[sprintf('%s (+%s)', $name, $countries[$region])] = $region;
}
$transformerChoices = array_values($countryChoices);
$countryOptions = $numberOptions = [
'error_bubbling' => true,
'required' => $options['required'],
'disabled' => $options['disabled'],
'translation_domain' => $options['translation_domain'],
];
if (method_exists('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix')) {
$choiceType = 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType';
$textType = 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType';
$countryOptions['choice_translation_domain'] = false;
// To be removed when dependency on Symfony Form is bumped to 3.1.
if (!in_array('Symfony\\Component\\Form\\DataTransformerInterface', class_implements('Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType'))) {
$countryOptions['choices_as_values'] = true;
}
} else {
// To be removed when dependency on Symfony Form is bumped to 2.7.
$choiceType = 'choice';
$textType = 'text';
$countryChoices = array_flip($countryChoices);
}
$countryOptions['required'] = true;
$countryOptions['choices'] = $countryChoices;
$countryOptions['preferred_choices'] = $options['preferred_country_choices'];
if ($options['country_placeholder']) {
$countryOptions['placeholder'] = $options['country_placeholder'];
}
$builder
->add('country', $choiceType, $countryOptions)
->add('number', $textType, $numberOptions)
->addViewTransformer(new PhoneNumberToArrayTransformer($transformerChoices));
} else {
$builder->addViewTransformer(
new PhoneNumberToStringTransformer($options['default_region'], $options['format'])
);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (self::WIDGET_COUNTRY_CHOICE === $options['widget']) {
$util = PhoneNumberUtil::getInstance();
$countries = [];
if (is_array($options['country_choices'])) {
foreach ($options['country_choices'] as $country) {
$code = $util->getCountryCodeForRegion($country);
if ($code) {
$countries[$country] = $code;
}
}
}
if (empty($countries)) {
foreach ($util->getSupportedRegions() as $country) {
$countries[$country] = $util->getCountryCodeForRegion($country);
}
}
$countryChoices = [];
foreach (Intl::getRegionBundle()->getCountryNames() as $region => $name) {
if (false === isset($countries[$region])) {
continue;
}
$countryChoices[sprintf('%s (+%s)', $name, $countries[$region])] = $region;
}
$transformerChoices = array_values($countryChoices);
$countryOptions = $numberOptions = [
'error_bubbling' => true,
'required' => $options['required'],
'disabled' => $options['disabled'],
'translation_domain' => $options['translation_domain'],
];
if (method_exists('Symfony\\Component\\Form\\AbstractType', 'getBlockPrefix')) {
$choiceType = 'Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType';
$textType = 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType';
$countryOptions['choice_translation_domain'] = false;
// To be removed when dependency on Symfony Form is bumped to 3.1.
if (!in_array('Symfony\\Component\\Form\\DataTransformerInterface', class_implements('Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType'))) {
$countryOptions['choices_as_values'] = true;
}
} else {
// To be removed when dependency on Symfony Form is bumped to 2.7.
$choiceType = 'choice';
$textType = 'text';
$countryChoices = array_flip($countryChoices);
}
$countryOptions['required'] = true;
$countryOptions['choices'] = $countryChoices;
$countryOptions['preferred_choices'] = $options['preferred_country_choices'];
if ($options['country_placeholder']) {
$countryOptions['placeholder'] = $options['country_placeholder'];
}
$builder
->add('country', $choiceType, $countryOptions)
->add('number', $textType, $numberOptions)
->addViewTransformer(new PhoneNumberToArrayTransformer($transformerChoices));
} else {
$builder->addViewTransformer(
new PhoneNumberToStringTransformer($options['default_region'], $options['format'])
);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"self",
"::",
"WIDGET_COUNTRY_CHOICE",
"===",
"$",
"options",
"[",
"'widget'",
"]",
")",
"{",
"$",
"util",
"=",
"PhoneNumberUtil",
"::",
"getInstance",
"(",
")",
";",
"$",
"countries",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"options",
"[",
"'country_choices'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"[",
"'country_choices'",
"]",
"as",
"$",
"country",
")",
"{",
"$",
"code",
"=",
"$",
"util",
"->",
"getCountryCodeForRegion",
"(",
"$",
"country",
")",
";",
"if",
"(",
"$",
"code",
")",
"{",
"$",
"countries",
"[",
"$",
"country",
"]",
"=",
"$",
"code",
";",
"}",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"countries",
")",
")",
"{",
"foreach",
"(",
"$",
"util",
"->",
"getSupportedRegions",
"(",
")",
"as",
"$",
"country",
")",
"{",
"$",
"countries",
"[",
"$",
"country",
"]",
"=",
"$",
"util",
"->",
"getCountryCodeForRegion",
"(",
"$",
"country",
")",
";",
"}",
"}",
"$",
"countryChoices",
"=",
"[",
"]",
";",
"foreach",
"(",
"Intl",
"::",
"getRegionBundle",
"(",
")",
"->",
"getCountryNames",
"(",
")",
"as",
"$",
"region",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"countries",
"[",
"$",
"region",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"countryChoices",
"[",
"sprintf",
"(",
"'%s (+%s)'",
",",
"$",
"name",
",",
"$",
"countries",
"[",
"$",
"region",
"]",
")",
"]",
"=",
"$",
"region",
";",
"}",
"$",
"transformerChoices",
"=",
"array_values",
"(",
"$",
"countryChoices",
")",
";",
"$",
"countryOptions",
"=",
"$",
"numberOptions",
"=",
"[",
"'error_bubbling'",
"=>",
"true",
",",
"'required'",
"=>",
"$",
"options",
"[",
"'required'",
"]",
",",
"'disabled'",
"=>",
"$",
"options",
"[",
"'disabled'",
"]",
",",
"'translation_domain'",
"=>",
"$",
"options",
"[",
"'translation_domain'",
"]",
",",
"]",
";",
"if",
"(",
"method_exists",
"(",
"'Symfony\\\\Component\\\\Form\\\\AbstractType'",
",",
"'getBlockPrefix'",
")",
")",
"{",
"$",
"choiceType",
"=",
"'Symfony\\\\Component\\\\Form\\\\Extension\\\\Core\\\\Type\\\\ChoiceType'",
";",
"$",
"textType",
"=",
"'Symfony\\\\Component\\\\Form\\\\Extension\\\\Core\\\\Type\\\\TextType'",
";",
"$",
"countryOptions",
"[",
"'choice_translation_domain'",
"]",
"=",
"false",
";",
"// To be removed when dependency on Symfony Form is bumped to 3.1.",
"if",
"(",
"!",
"in_array",
"(",
"'Symfony\\\\Component\\\\Form\\\\DataTransformerInterface'",
",",
"class_implements",
"(",
"'Symfony\\\\Component\\\\Form\\\\Extension\\\\Core\\\\Type\\\\TextType'",
")",
")",
")",
"{",
"$",
"countryOptions",
"[",
"'choices_as_values'",
"]",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"// To be removed when dependency on Symfony Form is bumped to 2.7.",
"$",
"choiceType",
"=",
"'choice'",
";",
"$",
"textType",
"=",
"'text'",
";",
"$",
"countryChoices",
"=",
"array_flip",
"(",
"$",
"countryChoices",
")",
";",
"}",
"$",
"countryOptions",
"[",
"'required'",
"]",
"=",
"true",
";",
"$",
"countryOptions",
"[",
"'choices'",
"]",
"=",
"$",
"countryChoices",
";",
"$",
"countryOptions",
"[",
"'preferred_choices'",
"]",
"=",
"$",
"options",
"[",
"'preferred_country_choices'",
"]",
";",
"if",
"(",
"$",
"options",
"[",
"'country_placeholder'",
"]",
")",
"{",
"$",
"countryOptions",
"[",
"'placeholder'",
"]",
"=",
"$",
"options",
"[",
"'country_placeholder'",
"]",
";",
"}",
"$",
"builder",
"->",
"add",
"(",
"'country'",
",",
"$",
"choiceType",
",",
"$",
"countryOptions",
")",
"->",
"add",
"(",
"'number'",
",",
"$",
"textType",
",",
"$",
"numberOptions",
")",
"->",
"addViewTransformer",
"(",
"new",
"PhoneNumberToArrayTransformer",
"(",
"$",
"transformerChoices",
")",
")",
";",
"}",
"else",
"{",
"$",
"builder",
"->",
"addViewTransformer",
"(",
"new",
"PhoneNumberToStringTransformer",
"(",
"$",
"options",
"[",
"'default_region'",
"]",
",",
"$",
"options",
"[",
"'format'",
"]",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/Form/Type/PhoneNumberType.php#L30-L105 |
netbull/CoreBundle | Form/Type/PhoneNumberType.php | PhoneNumberType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'widget' => self::WIDGET_SINGLE_TEXT,
'compound' => function (Options $options) {
return PhoneNumberType::WIDGET_SINGLE_TEXT !== $options['widget'];
},
'default_region' => PhoneNumberUtil::UNKNOWN_REGION,
'format' => PhoneNumberFormat::INTERNATIONAL,
'invalid_message' => 'This value is not a valid phone number.',
'by_reference' => false,
'error_bubbling' => false,
'country_choices' => [],
'country_placeholder' => false,
'preferred_country_choices' => [],
]);
if (method_exists($resolver, 'setDefault')) {
$resolver->setAllowedValues('widget', [
self::WIDGET_SINGLE_TEXT,
self::WIDGET_COUNTRY_CHOICE,
]);
}
} | php | public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'widget' => self::WIDGET_SINGLE_TEXT,
'compound' => function (Options $options) {
return PhoneNumberType::WIDGET_SINGLE_TEXT !== $options['widget'];
},
'default_region' => PhoneNumberUtil::UNKNOWN_REGION,
'format' => PhoneNumberFormat::INTERNATIONAL,
'invalid_message' => 'This value is not a valid phone number.',
'by_reference' => false,
'error_bubbling' => false,
'country_choices' => [],
'country_placeholder' => false,
'preferred_country_choices' => [],
]);
if (method_exists($resolver, 'setDefault')) {
$resolver->setAllowedValues('widget', [
self::WIDGET_SINGLE_TEXT,
self::WIDGET_COUNTRY_CHOICE,
]);
}
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setDefaults",
"(",
"[",
"'widget'",
"=>",
"self",
"::",
"WIDGET_SINGLE_TEXT",
",",
"'compound'",
"=>",
"function",
"(",
"Options",
"$",
"options",
")",
"{",
"return",
"PhoneNumberType",
"::",
"WIDGET_SINGLE_TEXT",
"!==",
"$",
"options",
"[",
"'widget'",
"]",
";",
"}",
",",
"'default_region'",
"=>",
"PhoneNumberUtil",
"::",
"UNKNOWN_REGION",
",",
"'format'",
"=>",
"PhoneNumberFormat",
"::",
"INTERNATIONAL",
",",
"'invalid_message'",
"=>",
"'This value is not a valid phone number.'",
",",
"'by_reference'",
"=>",
"false",
",",
"'error_bubbling'",
"=>",
"false",
",",
"'country_choices'",
"=>",
"[",
"]",
",",
"'country_placeholder'",
"=>",
"false",
",",
"'preferred_country_choices'",
"=>",
"[",
"]",
",",
"]",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"resolver",
",",
"'setDefault'",
")",
")",
"{",
"$",
"resolver",
"->",
"setAllowedValues",
"(",
"'widget'",
",",
"[",
"self",
"::",
"WIDGET_SINGLE_TEXT",
",",
"self",
"::",
"WIDGET_COUNTRY_CHOICE",
",",
"]",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/Form/Type/PhoneNumberType.php#L130-L153 |
KDF5000/EasyThink | src/ThinkPHP/Library/Think/Upload/Driver/Bcs/requestcore.php | BCS_RequestCore.prep_request | public function prep_request() {
$curl_handle = curl_init ();
// Set default options.
curl_setopt ( $curl_handle, CURLOPT_URL, $this->request_url );
curl_setopt ( $curl_handle, CURLOPT_FILETIME, true );
curl_setopt ( $curl_handle, CURLOPT_FRESH_CONNECT, false );
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true );
curl_setopt ( $curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED );
curl_setopt ( $curl_handle, CURLOPT_MAXREDIRS, 5 );
curl_setopt ( $curl_handle, CURLOPT_HEADER, true );
curl_setopt ( $curl_handle, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $curl_handle, CURLOPT_TIMEOUT, 5184000 );
curl_setopt ( $curl_handle, CURLOPT_CONNECTTIMEOUT, 120 );
curl_setopt ( $curl_handle, CURLOPT_NOSIGNAL, true );
curl_setopt ( $curl_handle, CURLOPT_REFERER, $this->request_url );
curl_setopt ( $curl_handle, CURLOPT_USERAGENT, $this->useragent );
curl_setopt ( $curl_handle, CURLOPT_READFUNCTION, array (
$this,
'streaming_read_callback' ) );
if ($this->debug_mode) {
curl_setopt ( $curl_handle, CURLOPT_VERBOSE, true );
}
//if (! ini_get ( 'safe_mode' )) {
//modify by zhengkan
//curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
//}
// Enable a proxy connection if requested.
if ($this->proxy) {
curl_setopt ( $curl_handle, CURLOPT_HTTPPROXYTUNNEL, true );
$host = $this->proxy ['host'];
$host .= ($this->proxy ['port']) ? ':' . $this->proxy ['port'] : '';
curl_setopt ( $curl_handle, CURLOPT_PROXY, $host );
if (isset ( $this->proxy ['user'] ) && isset ( $this->proxy ['pass'] )) {
curl_setopt ( $curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy ['user'] . ':' . $this->proxy ['pass'] );
}
}
// Set credentials for HTTP Basic/Digest Authentication.
if ($this->username && $this->password) {
curl_setopt ( $curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY );
curl_setopt ( $curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password );
}
// Handle the encoding if we can.
if (extension_loaded ( 'zlib' )) {
curl_setopt ( $curl_handle, CURLOPT_ENCODING, '' );
}
// Process custom headers
if (isset ( $this->request_headers ) && count ( $this->request_headers )) {
$temp_headers = array ();
foreach ( $this->request_headers as $k => $v ) {
$temp_headers [] = $k . ': ' . $v;
}
curl_setopt ( $curl_handle, CURLOPT_HTTPHEADER, $temp_headers );
}
switch ($this->method) {
case self::HTTP_PUT :
curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT' );
if (isset ( $this->read_stream )) {
if (! isset ( $this->read_stream_size ) || $this->read_stream_size < 0) {
throw new BCS_RequestCore_Exception ( 'The stream size for the streaming upload cannot be determined.' );
}
curl_setopt ( $curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size );
curl_setopt ( $curl_handle, CURLOPT_UPLOAD, true );
} else {
curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
}
break;
case self::HTTP_POST :
curl_setopt ( $curl_handle, CURLOPT_POST, true );
curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
break;
case self::HTTP_HEAD :
curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD );
curl_setopt ( $curl_handle, CURLOPT_NOBODY, 1 );
break;
default : // Assumed GET
curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, $this->method );
if (isset ( $this->write_stream )) {
curl_setopt ( $curl_handle, CURLOPT_WRITEFUNCTION, array (
$this,
'streaming_write_callback' ) );
curl_setopt ( $curl_handle, CURLOPT_HEADER, false );
} else {
curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
}
break;
}
// Merge in the CURLOPTs
if (isset ( $this->curlopts ) && sizeof ( $this->curlopts ) > 0) {
foreach ( $this->curlopts as $k => $v ) {
curl_setopt ( $curl_handle, $k, $v );
}
}
return $curl_handle;
} | php | public function prep_request() {
$curl_handle = curl_init ();
// Set default options.
curl_setopt ( $curl_handle, CURLOPT_URL, $this->request_url );
curl_setopt ( $curl_handle, CURLOPT_FILETIME, true );
curl_setopt ( $curl_handle, CURLOPT_FRESH_CONNECT, false );
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true );
curl_setopt ( $curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED );
curl_setopt ( $curl_handle, CURLOPT_MAXREDIRS, 5 );
curl_setopt ( $curl_handle, CURLOPT_HEADER, true );
curl_setopt ( $curl_handle, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $curl_handle, CURLOPT_TIMEOUT, 5184000 );
curl_setopt ( $curl_handle, CURLOPT_CONNECTTIMEOUT, 120 );
curl_setopt ( $curl_handle, CURLOPT_NOSIGNAL, true );
curl_setopt ( $curl_handle, CURLOPT_REFERER, $this->request_url );
curl_setopt ( $curl_handle, CURLOPT_USERAGENT, $this->useragent );
curl_setopt ( $curl_handle, CURLOPT_READFUNCTION, array (
$this,
'streaming_read_callback' ) );
if ($this->debug_mode) {
curl_setopt ( $curl_handle, CURLOPT_VERBOSE, true );
}
//if (! ini_get ( 'safe_mode' )) {
//modify by zhengkan
//curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
//}
// Enable a proxy connection if requested.
if ($this->proxy) {
curl_setopt ( $curl_handle, CURLOPT_HTTPPROXYTUNNEL, true );
$host = $this->proxy ['host'];
$host .= ($this->proxy ['port']) ? ':' . $this->proxy ['port'] : '';
curl_setopt ( $curl_handle, CURLOPT_PROXY, $host );
if (isset ( $this->proxy ['user'] ) && isset ( $this->proxy ['pass'] )) {
curl_setopt ( $curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy ['user'] . ':' . $this->proxy ['pass'] );
}
}
// Set credentials for HTTP Basic/Digest Authentication.
if ($this->username && $this->password) {
curl_setopt ( $curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY );
curl_setopt ( $curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password );
}
// Handle the encoding if we can.
if (extension_loaded ( 'zlib' )) {
curl_setopt ( $curl_handle, CURLOPT_ENCODING, '' );
}
// Process custom headers
if (isset ( $this->request_headers ) && count ( $this->request_headers )) {
$temp_headers = array ();
foreach ( $this->request_headers as $k => $v ) {
$temp_headers [] = $k . ': ' . $v;
}
curl_setopt ( $curl_handle, CURLOPT_HTTPHEADER, $temp_headers );
}
switch ($this->method) {
case self::HTTP_PUT :
curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT' );
if (isset ( $this->read_stream )) {
if (! isset ( $this->read_stream_size ) || $this->read_stream_size < 0) {
throw new BCS_RequestCore_Exception ( 'The stream size for the streaming upload cannot be determined.' );
}
curl_setopt ( $curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size );
curl_setopt ( $curl_handle, CURLOPT_UPLOAD, true );
} else {
curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
}
break;
case self::HTTP_POST :
curl_setopt ( $curl_handle, CURLOPT_POST, true );
curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
break;
case self::HTTP_HEAD :
curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD );
curl_setopt ( $curl_handle, CURLOPT_NOBODY, 1 );
break;
default : // Assumed GET
curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, $this->method );
if (isset ( $this->write_stream )) {
curl_setopt ( $curl_handle, CURLOPT_WRITEFUNCTION, array (
$this,
'streaming_write_callback' ) );
curl_setopt ( $curl_handle, CURLOPT_HEADER, false );
} else {
curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body );
}
break;
}
// Merge in the CURLOPTs
if (isset ( $this->curlopts ) && sizeof ( $this->curlopts ) > 0) {
foreach ( $this->curlopts as $k => $v ) {
curl_setopt ( $curl_handle, $k, $v );
}
}
return $curl_handle;
} | [
"public",
"function",
"prep_request",
"(",
")",
"{",
"$",
"curl_handle",
"=",
"curl_init",
"(",
")",
";",
"// Set default options.",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_URL",
",",
"$",
"this",
"->",
"request_url",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_FILETIME",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_FRESH_CONNECT",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_SSL_VERIFYHOST",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_CLOSEPOLICY",
",",
"CURLCLOSEPOLICY_LEAST_RECENTLY_USED",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_MAXREDIRS",
",",
"5",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_HEADER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_TIMEOUT",
",",
"5184000",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_CONNECTTIMEOUT",
",",
"120",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_NOSIGNAL",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_REFERER",
",",
"$",
"this",
"->",
"request_url",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_USERAGENT",
",",
"$",
"this",
"->",
"useragent",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_READFUNCTION",
",",
"array",
"(",
"$",
"this",
",",
"'streaming_read_callback'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug_mode",
")",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_VERBOSE",
",",
"true",
")",
";",
"}",
"//if (! ini_get ( 'safe_mode' )) {",
"//modify by zhengkan",
"//curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);",
"//}",
"// Enable a proxy connection if requested.",
"if",
"(",
"$",
"this",
"->",
"proxy",
")",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_HTTPPROXYTUNNEL",
",",
"true",
")",
";",
"$",
"host",
"=",
"$",
"this",
"->",
"proxy",
"[",
"'host'",
"]",
";",
"$",
"host",
".=",
"(",
"$",
"this",
"->",
"proxy",
"[",
"'port'",
"]",
")",
"?",
"':'",
".",
"$",
"this",
"->",
"proxy",
"[",
"'port'",
"]",
":",
"''",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_PROXY",
",",
"$",
"host",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"proxy",
"[",
"'user'",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"proxy",
"[",
"'pass'",
"]",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_PROXYUSERPWD",
",",
"$",
"this",
"->",
"proxy",
"[",
"'user'",
"]",
".",
"':'",
".",
"$",
"this",
"->",
"proxy",
"[",
"'pass'",
"]",
")",
";",
"}",
"}",
"// Set credentials for HTTP Basic/Digest Authentication.",
"if",
"(",
"$",
"this",
"->",
"username",
"&&",
"$",
"this",
"->",
"password",
")",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_HTTPAUTH",
",",
"CURLAUTH_ANY",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_USERPWD",
",",
"$",
"this",
"->",
"username",
".",
"':'",
".",
"$",
"this",
"->",
"password",
")",
";",
"}",
"// Handle the encoding if we can.",
"if",
"(",
"extension_loaded",
"(",
"'zlib'",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_ENCODING",
",",
"''",
")",
";",
"}",
"// Process custom headers",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"request_headers",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"request_headers",
")",
")",
"{",
"$",
"temp_headers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"request_headers",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"temp_headers",
"[",
"]",
"=",
"$",
"k",
".",
"': '",
".",
"$",
"v",
";",
"}",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_HTTPHEADER",
",",
"$",
"temp_headers",
")",
";",
"}",
"switch",
"(",
"$",
"this",
"->",
"method",
")",
"{",
"case",
"self",
"::",
"HTTP_PUT",
":",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"'PUT'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"read_stream",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"read_stream_size",
")",
"||",
"$",
"this",
"->",
"read_stream_size",
"<",
"0",
")",
"{",
"throw",
"new",
"BCS_RequestCore_Exception",
"(",
"'The stream size for the streaming upload cannot be determined.'",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_INFILESIZE",
",",
"$",
"this",
"->",
"read_stream_size",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_UPLOAD",
",",
"true",
")",
";",
"}",
"else",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"this",
"->",
"request_body",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"HTTP_POST",
":",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"this",
"->",
"request_body",
")",
";",
"break",
";",
"case",
"self",
"::",
"HTTP_HEAD",
":",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"self",
"::",
"HTTP_HEAD",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_NOBODY",
",",
"1",
")",
";",
"break",
";",
"default",
":",
"// Assumed GET",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"this",
"->",
"method",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"write_stream",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_WRITEFUNCTION",
",",
"array",
"(",
"$",
"this",
",",
"'streaming_write_callback'",
")",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_HEADER",
",",
"false",
")",
";",
"}",
"else",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"this",
"->",
"request_body",
")",
";",
"}",
"break",
";",
"}",
"// Merge in the CURLOPTs",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"curlopts",
")",
"&&",
"sizeof",
"(",
"$",
"this",
"->",
"curlopts",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"curlopts",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"return",
"$",
"curl_handle",
";",
"}"
] | Prepares and adds the details of the cURL request. This can be passed along to a <php:curl_multi_exec()>
function.
@return resource The handle for the cURL object. | [
"Prepares",
"and",
"adds",
"the",
"details",
"of",
"the",
"cURL",
"request",
".",
"This",
"can",
"be",
"passed",
"along",
"to",
"a",
"<php",
":",
"curl_multi_exec",
"()",
">",
"function",
"."
] | train | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Upload/Driver/Bcs/requestcore.php#L490-L584 |
KDF5000/EasyThink | src/ThinkPHP/Library/Think/Upload/Driver/Bcs/requestcore.php | BCS_RequestCore.isBaeEnv | private function isBaeEnv() {
if (isset ( $_SERVER ['HTTP_HOST'] )) {
$host = $_SERVER ['HTTP_HOST'];
$pos = strpos ( $host, '.' );
if ($pos !== false) {
$substr = substr ( $host, $pos + 1 );
if ($substr == 'duapp.com') {
return true;
}
}
}
if (isset ( $_SERVER ["HTTP_BAE_LOGID"] )) {
return true;
}
return false;
} | php | private function isBaeEnv() {
if (isset ( $_SERVER ['HTTP_HOST'] )) {
$host = $_SERVER ['HTTP_HOST'];
$pos = strpos ( $host, '.' );
if ($pos !== false) {
$substr = substr ( $host, $pos + 1 );
if ($substr == 'duapp.com') {
return true;
}
}
}
if (isset ( $_SERVER ["HTTP_BAE_LOGID"] )) {
return true;
}
return false;
} | [
"private",
"function",
"isBaeEnv",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
")",
"{",
"$",
"host",
"=",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
";",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"host",
",",
"'.'",
")",
";",
"if",
"(",
"$",
"pos",
"!==",
"false",
")",
"{",
"$",
"substr",
"=",
"substr",
"(",
"$",
"host",
",",
"$",
"pos",
"+",
"1",
")",
";",
"if",
"(",
"$",
"substr",
"==",
"'duapp.com'",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"\"HTTP_BAE_LOGID\"",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | is the environment BAE?
@return boolean the result of the answer | [
"is",
"the",
"environment",
"BAE?"
] | train | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Upload/Driver/Bcs/requestcore.php#L590-L606 |
KDF5000/EasyThink | src/ThinkPHP/Library/Think/Upload/Driver/Bcs/requestcore.php | BCS_RequestCore.send_request | public function send_request($parse = false) {
if (false === $this->isBaeEnv ()) {
set_time_limit ( 0 );
}
$curl_handle = $this->prep_request ();
$this->response = curl_exec ( $curl_handle );
if ($this->response === false ||
($this->method === self::HTTP_GET &&
curl_errno($curl_handle) === CURLE_PARTIAL_FILE)) {
throw new BCS_RequestCore_Exception ( 'cURL resource: ' . ( string ) $curl_handle . '; cURL error: ' . curl_error ( $curl_handle ) . ' (' . curl_errno ( $curl_handle ) . ')' );
}
$parsed_response = $this->process_response ( $curl_handle, $this->response );
curl_close ( $curl_handle );
if ($parse) {
return $parsed_response;
}
return $this->response;
} | php | public function send_request($parse = false) {
if (false === $this->isBaeEnv ()) {
set_time_limit ( 0 );
}
$curl_handle = $this->prep_request ();
$this->response = curl_exec ( $curl_handle );
if ($this->response === false ||
($this->method === self::HTTP_GET &&
curl_errno($curl_handle) === CURLE_PARTIAL_FILE)) {
throw new BCS_RequestCore_Exception ( 'cURL resource: ' . ( string ) $curl_handle . '; cURL error: ' . curl_error ( $curl_handle ) . ' (' . curl_errno ( $curl_handle ) . ')' );
}
$parsed_response = $this->process_response ( $curl_handle, $this->response );
curl_close ( $curl_handle );
if ($parse) {
return $parsed_response;
}
return $this->response;
} | [
"public",
"function",
"send_request",
"(",
"$",
"parse",
"=",
"false",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"isBaeEnv",
"(",
")",
")",
"{",
"set_time_limit",
"(",
"0",
")",
";",
"}",
"$",
"curl_handle",
"=",
"$",
"this",
"->",
"prep_request",
"(",
")",
";",
"$",
"this",
"->",
"response",
"=",
"curl_exec",
"(",
"$",
"curl_handle",
")",
";",
"if",
"(",
"$",
"this",
"->",
"response",
"===",
"false",
"||",
"(",
"$",
"this",
"->",
"method",
"===",
"self",
"::",
"HTTP_GET",
"&&",
"curl_errno",
"(",
"$",
"curl_handle",
")",
"===",
"CURLE_PARTIAL_FILE",
")",
")",
"{",
"throw",
"new",
"BCS_RequestCore_Exception",
"(",
"'cURL resource: '",
".",
"(",
"string",
")",
"$",
"curl_handle",
".",
"'; cURL error: '",
".",
"curl_error",
"(",
"$",
"curl_handle",
")",
".",
"' ('",
".",
"curl_errno",
"(",
"$",
"curl_handle",
")",
".",
"')'",
")",
";",
"}",
"$",
"parsed_response",
"=",
"$",
"this",
"->",
"process_response",
"(",
"$",
"curl_handle",
",",
"$",
"this",
"->",
"response",
")",
";",
"curl_close",
"(",
"$",
"curl_handle",
")",
";",
"if",
"(",
"$",
"parse",
")",
"{",
"return",
"$",
"parsed_response",
";",
"}",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] | Sends the request, calling necessary utility functions to update built-in properties.
@param boolean $parse (Optional) Whether to parse the response with BCS_ResponseCore or not.
@return string The resulting unparsed data from the request. | [
"Sends",
"the",
"request",
"calling",
"necessary",
"utility",
"functions",
"to",
"update",
"built",
"-",
"in",
"properties",
"."
] | train | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Upload/Driver/Bcs/requestcore.php#L662-L679 |
lightwerk/SurfTasks | Classes/Lightwerk/SurfTasks/Task/Git/CleanTask.php | CleanTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
$gitRootPath = $deployment->getWorkspacePath($application);
} else {
$gitRootPath = $deployment->getApplicationReleasePath($application);
}
// $quietFlag = (isset($options['verbose']) && $options['verbose']) ? '' : '-q';
if (!empty($options['nodeName'])) {
$node = $deployment->getNode($options['nodeName']);
if ($node === null) {
throw new InvalidConfigurationException(
sprintf('Node "%s" not found', $options['nodeName']),
1413298085
);
}
}
$commands = [
'cd '.escapeshellarg($gitRootPath),
'if [ -d \'.git\' ] && hash git 2>/dev/null; then '.
// 'git clean ' . $quietFlag . ' -d -ff && ' .
'git checkout -- .; '.
'fi;',
];
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
if (isset($options['useApplicationWorkspace']) && $options['useApplicationWorkspace'] === true) {
$gitRootPath = $deployment->getWorkspacePath($application);
} else {
$gitRootPath = $deployment->getApplicationReleasePath($application);
}
// $quietFlag = (isset($options['verbose']) && $options['verbose']) ? '' : '-q';
if (!empty($options['nodeName'])) {
$node = $deployment->getNode($options['nodeName']);
if ($node === null) {
throw new InvalidConfigurationException(
sprintf('Node "%s" not found', $options['nodeName']),
1413298085
);
}
}
$commands = [
'cd '.escapeshellarg($gitRootPath),
'if [ -d \'.git\' ] && hash git 2>/dev/null; then '.
// 'git clean ' . $quietFlag . ' -d -ff && ' .
'git checkout -- .; '.
'fi;',
];
$this->shell->executeOrSimulate($commands, $node, $deployment);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'useApplicationWorkspace'",
"]",
")",
"&&",
"$",
"options",
"[",
"'useApplicationWorkspace'",
"]",
"===",
"true",
")",
"{",
"$",
"gitRootPath",
"=",
"$",
"deployment",
"->",
"getWorkspacePath",
"(",
"$",
"application",
")",
";",
"}",
"else",
"{",
"$",
"gitRootPath",
"=",
"$",
"deployment",
"->",
"getApplicationReleasePath",
"(",
"$",
"application",
")",
";",
"}",
"//\t\t$quietFlag = (isset($options['verbose']) && $options['verbose']) ? '' : '-q';",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'nodeName'",
"]",
")",
")",
"{",
"$",
"node",
"=",
"$",
"deployment",
"->",
"getNode",
"(",
"$",
"options",
"[",
"'nodeName'",
"]",
")",
";",
"if",
"(",
"$",
"node",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidConfigurationException",
"(",
"sprintf",
"(",
"'Node \"%s\" not found'",
",",
"$",
"options",
"[",
"'nodeName'",
"]",
")",
",",
"1413298085",
")",
";",
"}",
"}",
"$",
"commands",
"=",
"[",
"'cd '",
".",
"escapeshellarg",
"(",
"$",
"gitRootPath",
")",
",",
"'if [ -d \\'.git\\' ] && hash git 2>/dev/null; then '",
".",
"//\t\t\t\t'git clean ' . $quietFlag . ' -d -ff && ' .",
"'git checkout -- .; '",
".",
"'fi;'",
",",
"]",
";",
"$",
"this",
"->",
"shell",
"->",
"executeOrSimulate",
"(",
"$",
"commands",
",",
"$",
"node",
",",
"$",
"deployment",
")",
";",
"}"
] | Executes this task.
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options
@throws InvalidConfigurationException | [
"Executes",
"this",
"task",
"."
] | train | https://github.com/lightwerk/SurfTasks/blob/8a6e4c85e42c762ad6515778c3fc7e19052cd9d1/Classes/Lightwerk/SurfTasks/Task/Git/CleanTask.php#L52-L81 |
Eden-PHP/Block | Form/Post.php | Post.getVariables | public function getVariables()
{
return array(
'use_wysiwyg' => $this->wysiwyg,
'fields' => $this->show,
'labels' => $this->labels,
'data' => $this->data,
'errors' => $this->errors,
'holders' => $this->holders);
} | php | public function getVariables()
{
return array(
'use_wysiwyg' => $this->wysiwyg,
'fields' => $this->show,
'labels' => $this->labels,
'data' => $this->data,
'errors' => $this->errors,
'holders' => $this->holders);
} | [
"public",
"function",
"getVariables",
"(",
")",
"{",
"return",
"array",
"(",
"'use_wysiwyg'",
"=>",
"$",
"this",
"->",
"wysiwyg",
",",
"'fields'",
"=>",
"$",
"this",
"->",
"show",
",",
"'labels'",
"=>",
"$",
"this",
"->",
"labels",
",",
"'data'",
"=>",
"$",
"this",
"->",
"data",
",",
"'errors'",
"=>",
"$",
"this",
"->",
"errors",
",",
"'holders'",
"=>",
"$",
"this",
"->",
"holders",
")",
";",
"}"
] | Returns the template variables in key value format
@param array data
@return array | [
"Returns",
"the",
"template",
"variables",
"in",
"key",
"value",
"format"
] | train | https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Form/Post.php#L64-L73 |
Eden-PHP/Block | Form/Post.php | Post.setErrors | public function setErrors($errors)
{
if(is_array($errors)) {
$this->errors = $errors;
return $this;
}
$args = func_get_args();
$this->errors[$args[0]] = $args[1];
return $this;
} | php | public function setErrors($errors)
{
if(is_array($errors)) {
$this->errors = $errors;
return $this;
}
$args = func_get_args();
$this->errors[$args[0]] = $args[1];
return $this;
} | [
"public",
"function",
"setErrors",
"(",
"$",
"errors",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"$",
"errors",
";",
"return",
"$",
"this",
";",
"}",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"errors",
"[",
"$",
"args",
"[",
"0",
"]",
"]",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Sets errors
@param array|string
@return Eden\Block\Form\Post | [
"Sets",
"errors"
] | train | https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Form/Post.php#L144-L155 |
Eden-PHP/Block | Form/Post.php | Post.setLabels | public function setLabels($labels)
{
if(is_array($labels)) {
$this->labels = $labels;
return $this;
}
$args = func_get_args();
$this->labels[$args[0]] = $args[1];
return $this;
} | php | public function setLabels($labels)
{
if(is_array($labels)) {
$this->labels = $labels;
return $this;
}
$args = func_get_args();
$this->labels[$args[0]] = $args[1];
return $this;
} | [
"public",
"function",
"setLabels",
"(",
"$",
"labels",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"labels",
")",
")",
"{",
"$",
"this",
"->",
"labels",
"=",
"$",
"labels",
";",
"return",
"$",
"this",
";",
"}",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"labels",
"[",
"$",
"args",
"[",
"0",
"]",
"]",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Sets labels
@param string|array
@return Eden\Block\Form\Post | [
"Sets",
"labels"
] | train | https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Form/Post.php#L182-L193 |
mattferris/bridge-components | src/HttpRouting/ServicesProvider.php | ServicesProvider.provides | public function provides($consumer)
{
$consumer->set('HttpDispatcher', function (ContainerInterface $container) {
return new Dispatcher($container);
}, true, DispatcherInterface::class);
} | php | public function provides($consumer)
{
$consumer->set('HttpDispatcher', function (ContainerInterface $container) {
return new Dispatcher($container);
}, true, DispatcherInterface::class);
} | [
"public",
"function",
"provides",
"(",
"$",
"consumer",
")",
"{",
"$",
"consumer",
"->",
"set",
"(",
"'HttpDispatcher'",
",",
"function",
"(",
"ContainerInterface",
"$",
"container",
")",
"{",
"return",
"new",
"Dispatcher",
"(",
"$",
"container",
")",
";",
"}",
",",
"true",
",",
"DispatcherInterface",
"::",
"class",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mattferris/bridge-components/blob/60468450704983ee496f24c1ef9588fe109ac59a/src/HttpRouting/ServicesProvider.php#L27-L32 |
formapro/BadaBoom | src/BadaBoom/ChainNode/Provider/ExceptionStackTraceProvider.php | ExceptionStackTraceProvider.handle | public function handle(\Exception $exception, DataHolderInterface $data)
{
$data->set($this->sectionName, (string) $exception);
$this->handleNextNode($exception, $data);
} | php | public function handle(\Exception $exception, DataHolderInterface $data)
{
$data->set($this->sectionName, (string) $exception);
$this->handleNextNode($exception, $data);
} | [
"public",
"function",
"handle",
"(",
"\\",
"Exception",
"$",
"exception",
",",
"DataHolderInterface",
"$",
"data",
")",
"{",
"$",
"data",
"->",
"set",
"(",
"$",
"this",
"->",
"sectionName",
",",
"(",
"string",
")",
"$",
"exception",
")",
";",
"$",
"this",
"->",
"handleNextNode",
"(",
"$",
"exception",
",",
"$",
"data",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/formapro/BadaBoom/blob/db42dbc4a43f7070586229c0e6075fe3a781e04e/src/BadaBoom/ChainNode/Provider/ExceptionStackTraceProvider.php#L24-L29 |
werx/core | src/Config.php | Config.getEnvironment | public function getEnvironment()
{
$environment_file = $this->resolvePath('config/environment');
if (file_exists($environment_file)) {
$environment = trim(file_get_contents($environment_file));
} else {
$environment = 'local';
}
return $environment;
} | php | public function getEnvironment()
{
$environment_file = $this->resolvePath('config/environment');
if (file_exists($environment_file)) {
$environment = trim(file_get_contents($environment_file));
} else {
$environment = 'local';
}
return $environment;
} | [
"public",
"function",
"getEnvironment",
"(",
")",
"{",
"$",
"environment_file",
"=",
"$",
"this",
"->",
"resolvePath",
"(",
"'config/environment'",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"environment_file",
")",
")",
"{",
"$",
"environment",
"=",
"trim",
"(",
"file_get_contents",
"(",
"$",
"environment_file",
")",
")",
";",
"}",
"else",
"{",
"$",
"environment",
"=",
"'local'",
";",
"}",
"return",
"$",
"environment",
";",
"}"
] | What environment are we running in? Local? Development? Production?
@return string | [
"What",
"environment",
"are",
"we",
"running",
"in?",
"Local?",
"Development?",
"Production?"
] | train | https://github.com/werx/core/blob/9ab7a9f7a8c02e1d41ca40301afada8129ea0a79/src/Config.php#L58-L69 |
werx/core | src/Config.php | Config.getBaseUrl | public function getBaseUrl($include_script_name = false)
{
$this->config->load('config');
$base_url = $this->config->get('base_url');
if (empty($base_url)) {
// No base_url defined in the config. Work it out based on server name.
// This won't work if the app is running behind a proxied URL.
$protocol = 'http://';
if (array_key_exists('HTTPS', $_SERVER) && strtolower($_SERVER['HTTPS']) == 'on') {
$protocol = 'https://';
}
$base_url = $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']);
}
$base_url = rtrim($base_url, '/') . '/';
if ($include_script_name) {
# http://example.com/path/to/app/index.php
return $base_url . basename($_SERVER['SCRIPT_NAME']);
} else {
# http://example.com/path/to/app/
return $base_url;
}
} | php | public function getBaseUrl($include_script_name = false)
{
$this->config->load('config');
$base_url = $this->config->get('base_url');
if (empty($base_url)) {
// No base_url defined in the config. Work it out based on server name.
// This won't work if the app is running behind a proxied URL.
$protocol = 'http://';
if (array_key_exists('HTTPS', $_SERVER) && strtolower($_SERVER['HTTPS']) == 'on') {
$protocol = 'https://';
}
$base_url = $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['SCRIPT_NAME']);
}
$base_url = rtrim($base_url, '/') . '/';
if ($include_script_name) {
# http://example.com/path/to/app/index.php
return $base_url . basename($_SERVER['SCRIPT_NAME']);
} else {
# http://example.com/path/to/app/
return $base_url;
}
} | [
"public",
"function",
"getBaseUrl",
"(",
"$",
"include_script_name",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"load",
"(",
"'config'",
")",
";",
"$",
"base_url",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'base_url'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"base_url",
")",
")",
"{",
"// No base_url defined in the config. Work it out based on server name.",
"// This won't work if the app is running behind a proxied URL.",
"$",
"protocol",
"=",
"'http://'",
";",
"if",
"(",
"array_key_exists",
"(",
"'HTTPS'",
",",
"$",
"_SERVER",
")",
"&&",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"==",
"'on'",
")",
"{",
"$",
"protocol",
"=",
"'https://'",
";",
"}",
"$",
"base_url",
"=",
"$",
"protocol",
".",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
".",
"dirname",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_NAME'",
"]",
")",
";",
"}",
"$",
"base_url",
"=",
"rtrim",
"(",
"$",
"base_url",
",",
"'/'",
")",
".",
"'/'",
";",
"if",
"(",
"$",
"include_script_name",
")",
"{",
"# http://example.com/path/to/app/index.php",
"return",
"$",
"base_url",
".",
"basename",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_NAME'",
"]",
")",
";",
"}",
"else",
"{",
"# http://example.com/path/to/app/",
"return",
"$",
"base_url",
";",
"}",
"}"
] | Get the the base url of our app
@param bool $include_script_name Should we include the filename (index.php)?
@return null|string The full URL to our app. | [
"Get",
"the",
"the",
"base",
"url",
"of",
"our",
"app"
] | train | https://github.com/werx/core/blob/9ab7a9f7a8c02e1d41ca40301afada8129ea0a79/src/Config.php#L77-L103 |
randomhost/icinga-check-minecraft | src/php/Base.php | Base.preRun | protected function preRun()
{
parent::preRun();
$options = $this->getOptions();
$this->mcStatus
->setHostname($options['host'])
->setPort($options['port']);
return $this;
} | php | protected function preRun()
{
parent::preRun();
$options = $this->getOptions();
$this->mcStatus
->setHostname($options['host'])
->setPort($options['port']);
return $this;
} | [
"protected",
"function",
"preRun",
"(",
")",
"{",
"parent",
"::",
"preRun",
"(",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
";",
"$",
"this",
"->",
"mcStatus",
"->",
"setHostname",
"(",
"$",
"options",
"[",
"'host'",
"]",
")",
"->",
"setPort",
"(",
"$",
"options",
"[",
"'port'",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Reads command line options and performs pre-run tasks.
@return $this | [
"Reads",
"command",
"line",
"options",
"and",
"performs",
"pre",
"-",
"run",
"tasks",
"."
] | train | https://github.com/randomhost/icinga-check-minecraft/blob/0587ea307b0706654b4a996d76e20e7ec04176a0/src/php/Base.php#L68-L79 |
thomasez/BisonLabSakonninBundle | Entity/SakonninFile.php | SakonninFile.setFile | public function setFile(File $file = null)
{
$this->file = $file;
// Until php7/uploaderbundle 1.7
if ($file instanceof UploadedFile) {
$this->setMimeType($file->getMimeType());
$this->setName($file->getClientOriginalName());
$this->setSize($file->getSize());
}
return $this;
} | php | public function setFile(File $file = null)
{
$this->file = $file;
// Until php7/uploaderbundle 1.7
if ($file instanceof UploadedFile) {
$this->setMimeType($file->getMimeType());
$this->setName($file->getClientOriginalName());
$this->setSize($file->getSize());
}
return $this;
} | [
"public",
"function",
"setFile",
"(",
"File",
"$",
"file",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"file",
"=",
"$",
"file",
";",
"// Until php7/uploaderbundle 1.7",
"if",
"(",
"$",
"file",
"instanceof",
"UploadedFile",
")",
"{",
"$",
"this",
"->",
"setMimeType",
"(",
"$",
"file",
"->",
"getMimeType",
"(",
")",
")",
";",
"$",
"this",
"->",
"setName",
"(",
"$",
"file",
"->",
"getClientOriginalName",
"(",
")",
")",
";",
"$",
"this",
"->",
"setSize",
"(",
"$",
"file",
"->",
"getSize",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | /*
@param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
@return Product | [
"/",
"*",
"@param",
"File|",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"HttpFoundation",
"\\",
"File",
"\\",
"UploadedFile",
"$image"
] | train | https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Entity/SakonninFile.php#L146-L157 |
thomasez/BisonLabSakonninBundle | Entity/SakonninFile.php | SakonninFile.setFileType | public function setFileType($fileType)
{
if ($fileType == $this->fileType) return $this;
if (!isset(self::getFileTypes()[$fileType])) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid file type.', $fileType));
}
$this->fileType = $fileType;
return $this;
} | php | public function setFileType($fileType)
{
if ($fileType == $this->fileType) return $this;
if (!isset(self::getFileTypes()[$fileType])) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid file type.', $fileType));
}
$this->fileType = $fileType;
return $this;
} | [
"public",
"function",
"setFileType",
"(",
"$",
"fileType",
")",
"{",
"if",
"(",
"$",
"fileType",
"==",
"$",
"this",
"->",
"fileType",
")",
"return",
"$",
"this",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"getFileTypes",
"(",
")",
"[",
"$",
"fileType",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%s\" is not a valid file type.'",
",",
"$",
"fileType",
")",
")",
";",
"}",
"$",
"this",
"->",
"fileType",
"=",
"$",
"fileType",
";",
"return",
"$",
"this",
";",
"}"
] | Set fileType
@param string $
@return Message | [
"Set",
"fileType"
] | train | https://github.com/thomasez/BisonLabSakonninBundle/blob/45ca7ce9874c4a2be7b503d7067b3d11d2b518cb/Entity/SakonninFile.php#L290-L299 |
Gendoria/command-queue | src/Gendoria/CommandQueue/QueueManager/SingleQueueManager.php | SingleQueueManager.sendCommand | public function sendCommand(CommandInterface $command)
{
if (!$this->sendDriver) {
throw new RuntimeException('Send driver not set');
}
$this->sendDriver->send($command);
} | php | public function sendCommand(CommandInterface $command)
{
if (!$this->sendDriver) {
throw new RuntimeException('Send driver not set');
}
$this->sendDriver->send($command);
} | [
"public",
"function",
"sendCommand",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sendDriver",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Send driver not set'",
")",
";",
"}",
"$",
"this",
"->",
"sendDriver",
"->",
"send",
"(",
"$",
"command",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/QueueManager/SingleQueueManager.php#L25-L31 |
opensourcerefinery/vicus | src/Provider/EnvironmentServiceProvider.php | EnvironmentServiceProvider.register | public function register(Container $container)
{
$environment = $this->determine();
if (false !== $environment && true === $this->isValid($environment)) {
$container['environment'] = $environment;
} elseif (false !== $this->default) {
$container['environment'] = $this->default;
} else {
throw new NoEnvironmentSetException('No valid runtime environment was set.');
}
} | php | public function register(Container $container)
{
$environment = $this->determine();
if (false !== $environment && true === $this->isValid($environment)) {
$container['environment'] = $environment;
} elseif (false !== $this->default) {
$container['environment'] = $this->default;
} else {
throw new NoEnvironmentSetException('No valid runtime environment was set.');
}
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"container",
")",
"{",
"$",
"environment",
"=",
"$",
"this",
"->",
"determine",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"environment",
"&&",
"true",
"===",
"$",
"this",
"->",
"isValid",
"(",
"$",
"environment",
")",
")",
"{",
"$",
"container",
"[",
"'environment'",
"]",
"=",
"$",
"environment",
";",
"}",
"elseif",
"(",
"false",
"!==",
"$",
"this",
"->",
"default",
")",
"{",
"$",
"container",
"[",
"'environment'",
"]",
"=",
"$",
"this",
"->",
"default",
";",
"}",
"else",
"{",
"throw",
"new",
"NoEnvironmentSetException",
"(",
"'No valid runtime environment was set.'",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/opensourcerefinery/vicus/blob/5be93d75bf6ab8009a299e9946c8333f0017fa3e/src/Provider/EnvironmentServiceProvider.php#L61-L72 |
opensourcerefinery/vicus | src/Provider/EnvironmentServiceProvider.php | EnvironmentServiceProvider.determine | private function determine()
{
if (false !== $this->filepath && true === is_readable($this->filepath . '/' . $this->filename)) {
return strtolower(trim(file_get_contents($this->filepath . '/' . $this->filename)));
} elseif (null !== getenv($this->variable)) {
return getenv($this->variable);
} else {
return false;
}
} | php | private function determine()
{
if (false !== $this->filepath && true === is_readable($this->filepath . '/' . $this->filename)) {
return strtolower(trim(file_get_contents($this->filepath . '/' . $this->filename)));
} elseif (null !== getenv($this->variable)) {
return getenv($this->variable);
} else {
return false;
}
} | [
"private",
"function",
"determine",
"(",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"this",
"->",
"filepath",
"&&",
"true",
"===",
"is_readable",
"(",
"$",
"this",
"->",
"filepath",
".",
"'/'",
".",
"$",
"this",
"->",
"filename",
")",
")",
"{",
"return",
"strtolower",
"(",
"trim",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"filepath",
".",
"'/'",
".",
"$",
"this",
"->",
"filename",
")",
")",
")",
";",
"}",
"elseif",
"(",
"null",
"!==",
"getenv",
"(",
"$",
"this",
"->",
"variable",
")",
")",
"{",
"return",
"getenv",
"(",
"$",
"this",
"->",
"variable",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Dertermines the runtime environment by checking for a file or an
environment variable containing the applications runtime environment
name. If both checks fail it will return false.
@return string|bool | [
"Dertermines",
"the",
"runtime",
"environment",
"by",
"checking",
"for",
"a",
"file",
"or",
"an",
"environment",
"variable",
"containing",
"the",
"applications",
"runtime",
"environment",
"name",
".",
"If",
"both",
"checks",
"fail",
"it",
"will",
"return",
"false",
"."
] | train | https://github.com/opensourcerefinery/vicus/blob/5be93d75bf6ab8009a299e9946c8333f0017fa3e/src/Provider/EnvironmentServiceProvider.php#L86-L96 |
integratedfordevelopers/integrated-asset-bundle | Twig/TokenParser/AssetTokenParser.php | AssetTokenParser.parse | public function parse(Twig_Token $token)
{
$assets = [];
$mode = AssetManager::MODE_APPEND;
$inline = false;
$stream = $this->parser->getStream();
while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
if ($stream->test(\Twig_Token::STRING_TYPE)) {
// 'js/src/extra.js'
$assets[] = $stream->next()->getValue();
} elseif ($stream->test(\Twig_Token::NAME_TYPE, 'inline')) {
// inline=true
$stream->next();
$stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
$inline = 'true' === $stream->expect(\Twig_Token::NAME_TYPE, ['true', 'false'])->getValue();
} elseif ($stream->test(\Twig_Token::NAME_TYPE, 'mode')) {
// mode='prepend'
$stream->next();
$stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
$mode = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
}
}
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse([$this, 'testEndTag'], true);
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
return new AssetNode($body, $assets, $inline, $mode, $token->getLine(), $this->getTag());
} | php | public function parse(Twig_Token $token)
{
$assets = [];
$mode = AssetManager::MODE_APPEND;
$inline = false;
$stream = $this->parser->getStream();
while (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
if ($stream->test(\Twig_Token::STRING_TYPE)) {
// 'js/src/extra.js'
$assets[] = $stream->next()->getValue();
} elseif ($stream->test(\Twig_Token::NAME_TYPE, 'inline')) {
// inline=true
$stream->next();
$stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
$inline = 'true' === $stream->expect(\Twig_Token::NAME_TYPE, ['true', 'false'])->getValue();
} elseif ($stream->test(\Twig_Token::NAME_TYPE, 'mode')) {
// mode='prepend'
$stream->next();
$stream->expect(\Twig_Token::OPERATOR_TYPE, '=');
$mode = $stream->expect(\Twig_Token::STRING_TYPE)->getValue();
}
}
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse([$this, 'testEndTag'], true);
$stream->expect(\Twig_Token::BLOCK_END_TYPE);
return new AssetNode($body, $assets, $inline, $mode, $token->getLine(), $this->getTag());
} | [
"public",
"function",
"parse",
"(",
"Twig_Token",
"$",
"token",
")",
"{",
"$",
"assets",
"=",
"[",
"]",
";",
"$",
"mode",
"=",
"AssetManager",
"::",
"MODE_APPEND",
";",
"$",
"inline",
"=",
"false",
";",
"$",
"stream",
"=",
"$",
"this",
"->",
"parser",
"->",
"getStream",
"(",
")",
";",
"while",
"(",
"!",
"$",
"stream",
"->",
"test",
"(",
"\\",
"Twig_Token",
"::",
"BLOCK_END_TYPE",
")",
")",
"{",
"if",
"(",
"$",
"stream",
"->",
"test",
"(",
"\\",
"Twig_Token",
"::",
"STRING_TYPE",
")",
")",
"{",
"// 'js/src/extra.js'",
"$",
"assets",
"[",
"]",
"=",
"$",
"stream",
"->",
"next",
"(",
")",
"->",
"getValue",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"stream",
"->",
"test",
"(",
"\\",
"Twig_Token",
"::",
"NAME_TYPE",
",",
"'inline'",
")",
")",
"{",
"// inline=true",
"$",
"stream",
"->",
"next",
"(",
")",
";",
"$",
"stream",
"->",
"expect",
"(",
"\\",
"Twig_Token",
"::",
"OPERATOR_TYPE",
",",
"'='",
")",
";",
"$",
"inline",
"=",
"'true'",
"===",
"$",
"stream",
"->",
"expect",
"(",
"\\",
"Twig_Token",
"::",
"NAME_TYPE",
",",
"[",
"'true'",
",",
"'false'",
"]",
")",
"->",
"getValue",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"stream",
"->",
"test",
"(",
"\\",
"Twig_Token",
"::",
"NAME_TYPE",
",",
"'mode'",
")",
")",
"{",
"// mode='prepend'",
"$",
"stream",
"->",
"next",
"(",
")",
";",
"$",
"stream",
"->",
"expect",
"(",
"\\",
"Twig_Token",
"::",
"OPERATOR_TYPE",
",",
"'='",
")",
";",
"$",
"mode",
"=",
"$",
"stream",
"->",
"expect",
"(",
"\\",
"Twig_Token",
"::",
"STRING_TYPE",
")",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"$",
"stream",
"->",
"expect",
"(",
"\\",
"Twig_Token",
"::",
"BLOCK_END_TYPE",
")",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"parser",
"->",
"subparse",
"(",
"[",
"$",
"this",
",",
"'testEndTag'",
"]",
",",
"true",
")",
";",
"$",
"stream",
"->",
"expect",
"(",
"\\",
"Twig_Token",
"::",
"BLOCK_END_TYPE",
")",
";",
"return",
"new",
"AssetNode",
"(",
"$",
"body",
",",
"$",
"assets",
",",
"$",
"inline",
",",
"$",
"mode",
",",
"$",
"token",
"->",
"getLine",
"(",
")",
",",
"$",
"this",
"->",
"getTag",
"(",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/integratedfordevelopers/integrated-asset-bundle/blob/a49b619a80d06896864980c922e165661d7eb49d/Twig/TokenParser/AssetTokenParser.php#L40-L70 |
Polosa/shade-framework-core | app/Profiler.php | Profiler.benchmark | public static function benchmark(callable $code, $iterationsNumber = self::BENCHMARK_ITERATIONS_NUMBER)
{
$startTime = microtime(true);
for ($i = 1; $i < $iterationsNumber; $i++) {
$code();
}
$endTime = microtime(true);
return $endTime - $startTime;
} | php | public static function benchmark(callable $code, $iterationsNumber = self::BENCHMARK_ITERATIONS_NUMBER)
{
$startTime = microtime(true);
for ($i = 1; $i < $iterationsNumber; $i++) {
$code();
}
$endTime = microtime(true);
return $endTime - $startTime;
} | [
"public",
"static",
"function",
"benchmark",
"(",
"callable",
"$",
"code",
",",
"$",
"iterationsNumber",
"=",
"self",
"::",
"BENCHMARK_ITERATIONS_NUMBER",
")",
"{",
"$",
"startTime",
"=",
"microtime",
"(",
"true",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"$",
"iterationsNumber",
";",
"$",
"i",
"++",
")",
"{",
"$",
"code",
"(",
")",
";",
"}",
"$",
"endTime",
"=",
"microtime",
"(",
"true",
")",
";",
"return",
"$",
"endTime",
"-",
"$",
"startTime",
";",
"}"
] | Do benchmarking
@param callable $code Code snippet for benchmarking
@param int $iterationsNumber Number of iterations
@return float | [
"Do",
"benchmarking"
] | train | https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/Profiler.php#L30-L39 |
netgen/site-legacy-bundle | bundle/Composer/ScriptHandler.php | ScriptHandler.installLegacySymlinks | public static function installLegacySymlinks(Event $event): void
{
$options = static::getOptions($event);
$consoleDir = static::getConsoleDir($event, 'install legacy symlinks');
static::executeCommand($event, $consoleDir, 'ngsite:symlink:legacy', $options['process-timeout']);
} | php | public static function installLegacySymlinks(Event $event): void
{
$options = static::getOptions($event);
$consoleDir = static::getConsoleDir($event, 'install legacy symlinks');
static::executeCommand($event, $consoleDir, 'ngsite:symlink:legacy', $options['process-timeout']);
} | [
"public",
"static",
"function",
"installLegacySymlinks",
"(",
"Event",
"$",
"event",
")",
":",
"void",
"{",
"$",
"options",
"=",
"static",
"::",
"getOptions",
"(",
"$",
"event",
")",
";",
"$",
"consoleDir",
"=",
"static",
"::",
"getConsoleDir",
"(",
"$",
"event",
",",
"'install legacy symlinks'",
")",
";",
"static",
"::",
"executeCommand",
"(",
"$",
"event",
",",
"$",
"consoleDir",
",",
"'ngsite:symlink:legacy'",
",",
"$",
"options",
"[",
"'process-timeout'",
"]",
")",
";",
"}"
] | Symlinks legacy siteaccesses and various other legacy files to their proper locations. | [
"Symlinks",
"legacy",
"siteaccesses",
"and",
"various",
"other",
"legacy",
"files",
"to",
"their",
"proper",
"locations",
"."
] | train | https://github.com/netgen/site-legacy-bundle/blob/943224cdee28cfb9ef07854c11c91d060456b394/bundle/Composer/ScriptHandler.php#L15-L21 |
koolkode/stream | src/DeflateInputStream.php | DeflateInputStream.getContents | public function getContents()
{
if($this->stream === NULL)
{
throw new \RuntimeException(sprintf('Cannot read contents of detached stream'));
}
$contents = '';
while(!$this->eof())
{
$contents .= $this->read($this->window);
}
return $contents;
} | php | public function getContents()
{
if($this->stream === NULL)
{
throw new \RuntimeException(sprintf('Cannot read contents of detached stream'));
}
$contents = '';
while(!$this->eof())
{
$contents .= $this->read($this->window);
}
return $contents;
} | [
"public",
"function",
"getContents",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stream",
"===",
"NULL",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Cannot read contents of detached stream'",
")",
")",
";",
"}",
"$",
"contents",
"=",
"''",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"contents",
".=",
"$",
"this",
"->",
"read",
"(",
"$",
"this",
"->",
"window",
")",
";",
"}",
"return",
"$",
"contents",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/koolkode/stream/blob/05e83efd76e1cb9e40a972711986b4a7e38bc141/src/DeflateInputStream.php#L147-L162 |
koolkode/stream | src/DeflateInputStream.php | DeflateInputStream.read | public function read($length)
{
if($this->stream === NULL)
{
throw new \RuntimeException(sprintf('Cannot read from detached stream'));
}
if($this->finished || $length == 0)
{
return '';
}
if($this->buffer === '')
{
if($this->stream->eof())
{
$this->buffer = $this->invokeWithErrorHandler('deflate_add', $this->context, '', ZLIB_FINISH);
$this->finished = true;
}
else
{
while(!$this->stream->eof())
{
$this->buffer .= $this->invokeWithErrorHandler('deflate_add', $this->context, $this->stream->read(max($length, $this->window)));
if($this->buffer !== '')
{
break;
}
}
}
}
$chunk = (string)substr($this->buffer, 0, $length);
$len = strlen($chunk);
$this->buffer = (string)substr($this->buffer, $len);
$this->offset += $len;
return $chunk;
} | php | public function read($length)
{
if($this->stream === NULL)
{
throw new \RuntimeException(sprintf('Cannot read from detached stream'));
}
if($this->finished || $length == 0)
{
return '';
}
if($this->buffer === '')
{
if($this->stream->eof())
{
$this->buffer = $this->invokeWithErrorHandler('deflate_add', $this->context, '', ZLIB_FINISH);
$this->finished = true;
}
else
{
while(!$this->stream->eof())
{
$this->buffer .= $this->invokeWithErrorHandler('deflate_add', $this->context, $this->stream->read(max($length, $this->window)));
if($this->buffer !== '')
{
break;
}
}
}
}
$chunk = (string)substr($this->buffer, 0, $length);
$len = strlen($chunk);
$this->buffer = (string)substr($this->buffer, $len);
$this->offset += $len;
return $chunk;
} | [
"public",
"function",
"read",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stream",
"===",
"NULL",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Cannot read from detached stream'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"finished",
"||",
"$",
"length",
"==",
"0",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"buffer",
"===",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stream",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"this",
"->",
"buffer",
"=",
"$",
"this",
"->",
"invokeWithErrorHandler",
"(",
"'deflate_add'",
",",
"$",
"this",
"->",
"context",
",",
"''",
",",
"ZLIB_FINISH",
")",
";",
"$",
"this",
"->",
"finished",
"=",
"true",
";",
"}",
"else",
"{",
"while",
"(",
"!",
"$",
"this",
"->",
"stream",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"this",
"->",
"buffer",
".=",
"$",
"this",
"->",
"invokeWithErrorHandler",
"(",
"'deflate_add'",
",",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"stream",
"->",
"read",
"(",
"max",
"(",
"$",
"length",
",",
"$",
"this",
"->",
"window",
")",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"buffer",
"!==",
"''",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"$",
"chunk",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"0",
",",
"$",
"length",
")",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"chunk",
")",
";",
"$",
"this",
"->",
"buffer",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"$",
"len",
")",
";",
"$",
"this",
"->",
"offset",
"+=",
"$",
"len",
";",
"return",
"$",
"chunk",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/koolkode/stream/blob/05e83efd76e1cb9e40a972711986b4a7e38bc141/src/DeflateInputStream.php#L167-L207 |
Retentio/Boomgo | src/Boomgo/Mapper/MapperProvider.php | MapperProvider.createInstance | protected function createInstance(\ReflectionClass $reflectedClass)
{
$constructor = $reflectedClass->getConstructor();
if ($constructor && $constructor->getNumberOfRequiredParameters() > 0) {
throw new \RuntimeException('Unable to hydrate an object requiring constructor param');
}
return $reflectedClass->newInstance();
} | php | protected function createInstance(\ReflectionClass $reflectedClass)
{
$constructor = $reflectedClass->getConstructor();
if ($constructor && $constructor->getNumberOfRequiredParameters() > 0) {
throw new \RuntimeException('Unable to hydrate an object requiring constructor param');
}
return $reflectedClass->newInstance();
} | [
"protected",
"function",
"createInstance",
"(",
"\\",
"ReflectionClass",
"$",
"reflectedClass",
")",
"{",
"$",
"constructor",
"=",
"$",
"reflectedClass",
"->",
"getConstructor",
"(",
")",
";",
"if",
"(",
"$",
"constructor",
"&&",
"$",
"constructor",
"->",
"getNumberOfRequiredParameters",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to hydrate an object requiring constructor param'",
")",
";",
"}",
"return",
"$",
"reflectedClass",
"->",
"newInstance",
"(",
")",
";",
"}"
] | Create an instance from a Reflected class
@param ReflectionClass $reflectedClass
@throws RuntimeException If constructor requires parameter
@return mixed | [
"Create",
"an",
"instance",
"from",
"a",
"Reflected",
"class"
] | train | https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Mapper/MapperProvider.php#L33-L42 |
Retentio/Boomgo | src/Boomgo/Mapper/MapperProvider.php | MapperProvider.normalize | protected function normalize($data)
{
if (null === $data || is_scalar($data)) {
return $data;
}
if (is_array($data)) {
foreach ($data as $key => $val) {
$data[$key] = $this->normalize($val);
}
return $data;
}
throw new \RuntimeException('An unexpected value could not be normalized: '.var_export($data, true));
} | php | protected function normalize($data)
{
if (null === $data || is_scalar($data)) {
return $data;
}
if (is_array($data)) {
foreach ($data as $key => $val) {
$data[$key] = $this->normalize($val);
}
return $data;
}
throw new \RuntimeException('An unexpected value could not be normalized: '.var_export($data, true));
} | [
"protected",
"function",
"normalize",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"data",
"||",
"is_scalar",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"val",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'An unexpected value could not be normalized: '",
".",
"var_export",
"(",
"$",
"data",
",",
"true",
")",
")",
";",
"}"
] | Normalize php data for mongo
This code chunk was inspired by the Symfony framework
and is subject to the MIT license. Please see the LICENCE
at https://github.com/symfony/symfony
(c) Fabien Potencier <[email protected]>
Author Nils Adermann <[email protected]>
@param mixed $data
@return mixed | [
"Normalize",
"php",
"data",
"for",
"mongo"
] | train | https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Mapper/MapperProvider.php#L58-L73 |
Retentio/Boomgo | src/Boomgo/Mapper/MapperProvider.php | MapperProvider.serializeEmbeddedCollection | protected function serializeEmbeddedCollection(MapperInterface $mapper, array $collection)
{
$data = array();
foreach ($collection as $object) {
$data[] = $mapper->serialize($object);
}
return $data;
} | php | protected function serializeEmbeddedCollection(MapperInterface $mapper, array $collection)
{
$data = array();
foreach ($collection as $object) {
$data[] = $mapper->serialize($object);
}
return $data;
} | [
"protected",
"function",
"serializeEmbeddedCollection",
"(",
"MapperInterface",
"$",
"mapper",
",",
"array",
"$",
"collection",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"object",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"mapper",
"->",
"serialize",
"(",
"$",
"object",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Serialize an embedded collection
Return a collection of hydrated objects
@param MapperInterface $mapper
@param array $collection
@return array | [
"Serialize",
"an",
"embedded",
"collection"
] | train | https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Mapper/MapperProvider.php#L85-L93 |
Retentio/Boomgo | src/Boomgo/Mapper/MapperProvider.php | MapperProvider.unserializeEmbeddedCollection | protected function unserializeEmbeddedCollection(MapperInterface $mapper, array $data)
{
$collection = array();
foreach ($data as $document) {
$collection[] = $mapper->unserialize($document);
}
return $collection;
} | php | protected function unserializeEmbeddedCollection(MapperInterface $mapper, array $data)
{
$collection = array();
foreach ($data as $document) {
$collection[] = $mapper->unserialize($document);
}
return $collection;
} | [
"protected",
"function",
"unserializeEmbeddedCollection",
"(",
"MapperInterface",
"$",
"mapper",
",",
"array",
"$",
"data",
")",
"{",
"$",
"collection",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"document",
")",
"{",
"$",
"collection",
"[",
"]",
"=",
"$",
"mapper",
"->",
"unserialize",
"(",
"$",
"document",
")",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] | Unserialize an embedded collection
Return a collection of serialized objects (arrays)
@param MapperInterface $mapper
@param array $data
@return array | [
"Unserialize",
"an",
"embedded",
"collection"
] | train | https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Mapper/MapperProvider.php#L105-L113 |
phossa/phossa-di | src/Phossa/Di/Extension/Provider/ProviderAbstract.php | ProviderAbstract.isMatching | protected function isMatching()/*# : bool */
{
if (empty($this->tags)) {
return true;
} else {
return $this->getContainer()->hasTag($this->tags);
}
} | php | protected function isMatching()/*# : bool */
{
if (empty($this->tags)) {
return true;
} else {
return $this->getContainer()->hasTag($this->tags);
}
} | [
"protected",
"function",
"isMatching",
"(",
")",
"/*# : bool */",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"tags",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"hasTag",
"(",
"$",
"this",
"->",
"tags",
")",
";",
"}",
"}"
] | Check tags match with $container's
Empty $this->tags means this provider is not conflict with $container.
Thus always TRUE if $this->tags is empty.
@return bool
@access protected | [
"Check",
"tags",
"match",
"with",
"$container",
"s"
] | train | https://github.com/phossa/phossa-di/blob/bbe1e95b081068e2bc49c6cd465f38aab0374be5/src/Phossa/Di/Extension/Provider/ProviderAbstract.php#L124-L131 |
vatson/isolated-callback | src/Vatson/Callback/Ipc/SharedMemory.php | SharedMemory.get | public function get()
{
if (shm_has_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID)) {
$data = shm_get_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID);
shm_remove_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID);
return $data;
}
} | php | public function get()
{
if (shm_has_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID)) {
$data = shm_get_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID);
shm_remove_var($this->shared_memory_segment, self::$SEGMENT_VAR_ID);
return $data;
}
} | [
"public",
"function",
"get",
"(",
")",
"{",
"if",
"(",
"shm_has_var",
"(",
"$",
"this",
"->",
"shared_memory_segment",
",",
"self",
"::",
"$",
"SEGMENT_VAR_ID",
")",
")",
"{",
"$",
"data",
"=",
"shm_get_var",
"(",
"$",
"this",
"->",
"shared_memory_segment",
",",
"self",
"::",
"$",
"SEGMENT_VAR_ID",
")",
";",
"shm_remove_var",
"(",
"$",
"this",
"->",
"shared_memory_segment",
",",
"self",
"::",
"$",
"SEGMENT_VAR_ID",
")",
";",
"return",
"$",
"data",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vatson/isolated-callback/blob/c048f4cc830c246c0aa8c45da91af9e8c5a86ca4/src/Vatson/Callback/Ipc/SharedMemory.php#L35-L43 |
Erebot/Intl | src/Translator/GnuGettextMo.php | GnuGettextMo.load | protected function load($filename)
{
$this->catalog = array();
$fp = fopen($filename, 'rb', false);
if ($fp === false) {
throw new \RuntimeException("Could not read $filename");
}
$data = fread($fp, 20);
if (strlen($data) != 20) {
throw new \RuntimeException('Invalid file');
}
$magic = substr($data, 0, 4);
if ($magic === "\x95\x04\x12\xde") {
$dword = 'N';
} elseif ($magic === "\xde\x12\x04\x95") {
$dword = 'V';
} else {
throw new \RuntimeException('Invalid file');
}
list(, $revision) = unpack("@4/${dword}", $data);
if ($revision !== 0) {
throw new \RuntimeException('Invalid file');
}
list(, $count, $origOffset, $transOffset) = unpack("@8/${dword}3", $data);
fseek($fp, $origOffset);
$origEntries = array();
for ($i = 0; $i < $count; $i++) {
$origEntries[] = unpack("${dword}2", fread($fp, 8));
}
fseek($fp, $transOffset);
$transEntries = array();
for ($i = 0; $i < $count; $i++) {
$transEntries[] = unpack("${dword}2", fread($fp, 8));
}
for ($i = 0; $i < $count; $i++) {
fseek($fp, $origEntries[$i][2]);
$msgid = $origEntries[$i][1] > 0 ? fread($fp, $origEntries[$i][1]) : "";
fseek($fp, $transEntries[$i][2]);
$translations = $transEntries[$i][1] > 0 ? explode("\x00", fread($fp, $transEntries[$i][1])) : "";
$ctx = self::NO_CONTEXT;
if (($pos = strpos($msgid, self::NO_CONTEXT)) !== false) {
$ctx = (string) substr($msgid, 0, $pos);
$msgid = (string) substr($msgid, $pos + 1);
}
$this->catalog[$ctx][$msgid] = $translations;
}
} | php | protected function load($filename)
{
$this->catalog = array();
$fp = fopen($filename, 'rb', false);
if ($fp === false) {
throw new \RuntimeException("Could not read $filename");
}
$data = fread($fp, 20);
if (strlen($data) != 20) {
throw new \RuntimeException('Invalid file');
}
$magic = substr($data, 0, 4);
if ($magic === "\x95\x04\x12\xde") {
$dword = 'N';
} elseif ($magic === "\xde\x12\x04\x95") {
$dword = 'V';
} else {
throw new \RuntimeException('Invalid file');
}
list(, $revision) = unpack("@4/${dword}", $data);
if ($revision !== 0) {
throw new \RuntimeException('Invalid file');
}
list(, $count, $origOffset, $transOffset) = unpack("@8/${dword}3", $data);
fseek($fp, $origOffset);
$origEntries = array();
for ($i = 0; $i < $count; $i++) {
$origEntries[] = unpack("${dword}2", fread($fp, 8));
}
fseek($fp, $transOffset);
$transEntries = array();
for ($i = 0; $i < $count; $i++) {
$transEntries[] = unpack("${dword}2", fread($fp, 8));
}
for ($i = 0; $i < $count; $i++) {
fseek($fp, $origEntries[$i][2]);
$msgid = $origEntries[$i][1] > 0 ? fread($fp, $origEntries[$i][1]) : "";
fseek($fp, $transEntries[$i][2]);
$translations = $transEntries[$i][1] > 0 ? explode("\x00", fread($fp, $transEntries[$i][1])) : "";
$ctx = self::NO_CONTEXT;
if (($pos = strpos($msgid, self::NO_CONTEXT)) !== false) {
$ctx = (string) substr($msgid, 0, $pos);
$msgid = (string) substr($msgid, $pos + 1);
}
$this->catalog[$ctx][$msgid] = $translations;
}
} | [
"protected",
"function",
"load",
"(",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"catalog",
"=",
"array",
"(",
")",
";",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"filename",
",",
"'rb'",
",",
"false",
")",
";",
"if",
"(",
"$",
"fp",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Could not read $filename\"",
")",
";",
"}",
"$",
"data",
"=",
"fread",
"(",
"$",
"fp",
",",
"20",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",
"!=",
"20",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Invalid file'",
")",
";",
"}",
"$",
"magic",
"=",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"4",
")",
";",
"if",
"(",
"$",
"magic",
"===",
"\"\\x95\\x04\\x12\\xde\"",
")",
"{",
"$",
"dword",
"=",
"'N'",
";",
"}",
"elseif",
"(",
"$",
"magic",
"===",
"\"\\xde\\x12\\x04\\x95\"",
")",
"{",
"$",
"dword",
"=",
"'V'",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Invalid file'",
")",
";",
"}",
"list",
"(",
",",
"$",
"revision",
")",
"=",
"unpack",
"(",
"\"@4/${dword}\"",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"revision",
"!==",
"0",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Invalid file'",
")",
";",
"}",
"list",
"(",
",",
"$",
"count",
",",
"$",
"origOffset",
",",
"$",
"transOffset",
")",
"=",
"unpack",
"(",
"\"@8/${dword}3\"",
",",
"$",
"data",
")",
";",
"fseek",
"(",
"$",
"fp",
",",
"$",
"origOffset",
")",
";",
"$",
"origEntries",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"origEntries",
"[",
"]",
"=",
"unpack",
"(",
"\"${dword}2\"",
",",
"fread",
"(",
"$",
"fp",
",",
"8",
")",
")",
";",
"}",
"fseek",
"(",
"$",
"fp",
",",
"$",
"transOffset",
")",
";",
"$",
"transEntries",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"transEntries",
"[",
"]",
"=",
"unpack",
"(",
"\"${dword}2\"",
",",
"fread",
"(",
"$",
"fp",
",",
"8",
")",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"fseek",
"(",
"$",
"fp",
",",
"$",
"origEntries",
"[",
"$",
"i",
"]",
"[",
"2",
"]",
")",
";",
"$",
"msgid",
"=",
"$",
"origEntries",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
">",
"0",
"?",
"fread",
"(",
"$",
"fp",
",",
"$",
"origEntries",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
")",
":",
"\"\"",
";",
"fseek",
"(",
"$",
"fp",
",",
"$",
"transEntries",
"[",
"$",
"i",
"]",
"[",
"2",
"]",
")",
";",
"$",
"translations",
"=",
"$",
"transEntries",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
">",
"0",
"?",
"explode",
"(",
"\"\\x00\"",
",",
"fread",
"(",
"$",
"fp",
",",
"$",
"transEntries",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
")",
")",
":",
"\"\"",
";",
"$",
"ctx",
"=",
"self",
"::",
"NO_CONTEXT",
";",
"if",
"(",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"msgid",
",",
"self",
"::",
"NO_CONTEXT",
")",
")",
"!==",
"false",
")",
"{",
"$",
"ctx",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"msgid",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"msgid",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"msgid",
",",
"$",
"pos",
"+",
"1",
")",
";",
"}",
"$",
"this",
"->",
"catalog",
"[",
"$",
"ctx",
"]",
"[",
"$",
"msgid",
"]",
"=",
"$",
"translations",
";",
"}",
"}"
] | See https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html#MO-Files
for more information about this file format. | [
"See",
"https",
":",
"//",
"www",
".",
"gnu",
".",
"org",
"/",
"software",
"/",
"gettext",
"/",
"manual",
"/",
"html_node",
"/",
"MO",
"-",
"Files",
".",
"html#MO",
"-",
"Files",
"for",
"more",
"information",
"about",
"this",
"file",
"format",
"."
] | train | https://github.com/Erebot/Intl/blob/2cd6e8ace3455e134377b41942ccd1ee6cb1d035/src/Translator/GnuGettextMo.php#L110-L167 |
MBHFramework/mbh-rest | Mbh/DefaultServicesProvider.php | DefaultServicesProvider.register | public function register(ContainerInterface $container)
{
if (! isset($container['session'])) {
$container['session'] = function (ContainerInterface $container) {
return new Session;
};
}
if (! isset($container['router'])) {
/**
* This service MUST return a SHARED instance
* of Mbh\Interfaces\RouterInterface.
*
* @param Container $container
* @return RouterInterface
*/
$container['router'] = function (ContainerInterface $container) {
$routerCacheFile = false;
if (isset($container->get('settings')['routerCacheFile'])) {
$routerCacheFile = $container->get('settings')['routerCacheFile'];
}
$router = (new Router)->setCacheFile($routerCacheFile);
if (method_exists($router, 'setContainer')) {
$router->setContainer($container);
}
if (method_exists($router, 'setCallableResolver')) {
$router->setCallableResolver($container['callableResolver']);
}
return $router;
};
}
} | php | public function register(ContainerInterface $container)
{
if (! isset($container['session'])) {
$container['session'] = function (ContainerInterface $container) {
return new Session;
};
}
if (! isset($container['router'])) {
/**
* This service MUST return a SHARED instance
* of Mbh\Interfaces\RouterInterface.
*
* @param Container $container
* @return RouterInterface
*/
$container['router'] = function (ContainerInterface $container) {
$routerCacheFile = false;
if (isset($container->get('settings')['routerCacheFile'])) {
$routerCacheFile = $container->get('settings')['routerCacheFile'];
}
$router = (new Router)->setCacheFile($routerCacheFile);
if (method_exists($router, 'setContainer')) {
$router->setContainer($container);
}
if (method_exists($router, 'setCallableResolver')) {
$router->setCallableResolver($container['callableResolver']);
}
return $router;
};
}
} | [
"public",
"function",
"register",
"(",
"ContainerInterface",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'session'",
"]",
")",
")",
"{",
"$",
"container",
"[",
"'session'",
"]",
"=",
"function",
"(",
"ContainerInterface",
"$",
"container",
")",
"{",
"return",
"new",
"Session",
";",
"}",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'router'",
"]",
")",
")",
"{",
"/**\n * This service MUST return a SHARED instance\n * of Mbh\\Interfaces\\RouterInterface.\n *\n * @param Container $container\n * @return RouterInterface\n */",
"$",
"container",
"[",
"'router'",
"]",
"=",
"function",
"(",
"ContainerInterface",
"$",
"container",
")",
"{",
"$",
"routerCacheFile",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"container",
"->",
"get",
"(",
"'settings'",
")",
"[",
"'routerCacheFile'",
"]",
")",
")",
"{",
"$",
"routerCacheFile",
"=",
"$",
"container",
"->",
"get",
"(",
"'settings'",
")",
"[",
"'routerCacheFile'",
"]",
";",
"}",
"$",
"router",
"=",
"(",
"new",
"Router",
")",
"->",
"setCacheFile",
"(",
"$",
"routerCacheFile",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"router",
",",
"'setContainer'",
")",
")",
"{",
"$",
"router",
"->",
"setContainer",
"(",
"$",
"container",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"router",
",",
"'setCallableResolver'",
")",
")",
"{",
"$",
"router",
"->",
"setCallableResolver",
"(",
"$",
"container",
"[",
"'callableResolver'",
"]",
")",
";",
"}",
"return",
"$",
"router",
";",
"}",
";",
"}",
"}"
] | Register Mbh's default services.
@param Container $container A DI container implementing ArrayAccess and container-interop. | [
"Register",
"Mbh",
"s",
"default",
"services",
"."
] | train | https://github.com/MBHFramework/mbh-rest/blob/e23b4e66dc2b8da35e06312dcfdba41c4cfc2c83/Mbh/DefaultServicesProvider.php#L28-L62 |
agentmedia/phine-core | src/Core/Modules/Backend/ModuleForm.php | ModuleForm.AddModuleTypeOption | private function AddModuleTypeOption(Select $select, $type)
{
if ($type != 'BuiltIn-Container' ||
(!Request::GetData('container') && Container::Schema()->Count() > 0))
{
$select->AddOption($type, Trans($type));
}
} | php | private function AddModuleTypeOption(Select $select, $type)
{
if ($type != 'BuiltIn-Container' ||
(!Request::GetData('container') && Container::Schema()->Count() > 0))
{
$select->AddOption($type, Trans($type));
}
} | [
"private",
"function",
"AddModuleTypeOption",
"(",
"Select",
"$",
"select",
",",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"!=",
"'BuiltIn-Container'",
"||",
"(",
"!",
"Request",
"::",
"GetData",
"(",
"'container'",
")",
"&&",
"Container",
"::",
"Schema",
"(",
")",
"->",
"Count",
"(",
")",
">",
"0",
")",
")",
"{",
"$",
"select",
"->",
"AddOption",
"(",
"$",
"type",
",",
"Trans",
"(",
"$",
"type",
")",
")",
";",
"}",
"}"
] | Adds the module type option, if allowed
@param Select $select The select box
@param string $type The module type | [
"Adds",
"the",
"module",
"type",
"option",
"if",
"allowed"
] | train | https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/ModuleForm.php#L52-L59 |
TiMESPLiNTER/tsFramework | src/ch/timesplinter/logger/Logger.php | Logger.error | public function error($msg, Exception $e = null) {
if($e !== null) {
$msg .= PHP_EOL . get_class($e) . ': (' . $e->getCode() . ') "' . $e->getMessage() . '"' . PHP_EOL;
$msg .= 'thrown in file: ' . $e->getFile() . ' (Line: ' . $e->getLine() . ')' . PHP_EOL . PHP_EOL;
$msg .= $e->getTraceAsString();
}
$msg .= PHP_EOL . PHP_EOL . '$_SERVER = ' . print_r($_SERVER, true);
$msg .= PHP_EOL . PHP_EOL . '$_GET = ' . print_r($_GET, true);
$msg .= PHP_EOL . PHP_EOL . '$_POST = ' . print_r($_POST, true);
$msg .= PHP_EOL . PHP_EOL . '$_FILES = ' . print_r($_FILES, true);
$msg .= PHP_EOL . PHP_EOL . '$_COOKIE = ' . print_r($_COOKIE, true);
$this->mailMessage(self::LEVEL_ERROR, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_ERROR) !== true)
return;
$this->writeMessage(self::LEVEL_ERROR, $msg);
} | php | public function error($msg, Exception $e = null) {
if($e !== null) {
$msg .= PHP_EOL . get_class($e) . ': (' . $e->getCode() . ') "' . $e->getMessage() . '"' . PHP_EOL;
$msg .= 'thrown in file: ' . $e->getFile() . ' (Line: ' . $e->getLine() . ')' . PHP_EOL . PHP_EOL;
$msg .= $e->getTraceAsString();
}
$msg .= PHP_EOL . PHP_EOL . '$_SERVER = ' . print_r($_SERVER, true);
$msg .= PHP_EOL . PHP_EOL . '$_GET = ' . print_r($_GET, true);
$msg .= PHP_EOL . PHP_EOL . '$_POST = ' . print_r($_POST, true);
$msg .= PHP_EOL . PHP_EOL . '$_FILES = ' . print_r($_FILES, true);
$msg .= PHP_EOL . PHP_EOL . '$_COOKIE = ' . print_r($_COOKIE, true);
$this->mailMessage(self::LEVEL_ERROR, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_ERROR) !== true)
return;
$this->writeMessage(self::LEVEL_ERROR, $msg);
} | [
"public",
"function",
"error",
"(",
"$",
"msg",
",",
"Exception",
"$",
"e",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"e",
"!==",
"null",
")",
"{",
"$",
"msg",
".=",
"PHP_EOL",
".",
"get_class",
"(",
"$",
"e",
")",
".",
"': ('",
".",
"$",
"e",
"->",
"getCode",
"(",
")",
".",
"') \"'",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"'\"'",
".",
"PHP_EOL",
";",
"$",
"msg",
".=",
"'thrown in file: '",
".",
"$",
"e",
"->",
"getFile",
"(",
")",
".",
"' (Line: '",
".",
"$",
"e",
"->",
"getLine",
"(",
")",
".",
"')'",
".",
"PHP_EOL",
".",
"PHP_EOL",
";",
"$",
"msg",
".=",
"$",
"e",
"->",
"getTraceAsString",
"(",
")",
";",
"}",
"$",
"msg",
".=",
"PHP_EOL",
".",
"PHP_EOL",
".",
"'$_SERVER = '",
".",
"print_r",
"(",
"$",
"_SERVER",
",",
"true",
")",
";",
"$",
"msg",
".=",
"PHP_EOL",
".",
"PHP_EOL",
".",
"'$_GET = '",
".",
"print_r",
"(",
"$",
"_GET",
",",
"true",
")",
";",
"$",
"msg",
".=",
"PHP_EOL",
".",
"PHP_EOL",
".",
"'$_POST = '",
".",
"print_r",
"(",
"$",
"_POST",
",",
"true",
")",
";",
"$",
"msg",
".=",
"PHP_EOL",
".",
"PHP_EOL",
".",
"'$_FILES = '",
".",
"print_r",
"(",
"$",
"_FILES",
",",
"true",
")",
";",
"$",
"msg",
".=",
"PHP_EOL",
".",
"PHP_EOL",
".",
"'$_COOKIE = '",
".",
"print_r",
"(",
"$",
"_COOKIE",
",",
"true",
")",
";",
"$",
"this",
"->",
"mailMessage",
"(",
"self",
"::",
"LEVEL_ERROR",
",",
"$",
"msg",
")",
";",
"if",
"(",
"$",
"this",
"->",
"checkLevel",
"(",
"$",
"this",
"->",
"loglevels",
",",
"self",
"::",
"LEVEL_ERROR",
")",
"!==",
"true",
")",
"return",
";",
"$",
"this",
"->",
"writeMessage",
"(",
"self",
"::",
"LEVEL_ERROR",
",",
"$",
"msg",
")",
";",
"}"
] | Logs an error with optional exception
@param string $msg
@param Exception $e | [
"Logs",
"an",
"error",
"with",
"optional",
"exception"
] | train | https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/logger/Logger.php#L76-L95 |
TiMESPLiNTER/tsFramework | src/ch/timesplinter/logger/Logger.php | Logger.warn | public function warn($msg) {
$this->mailMessage(self::LEVEL_WARN, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_WARN) !== true)
return;
$this->writeMessage(self::LEVEL_WARN, $msg);
} | php | public function warn($msg) {
$this->mailMessage(self::LEVEL_WARN, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_WARN) !== true)
return;
$this->writeMessage(self::LEVEL_WARN, $msg);
} | [
"public",
"function",
"warn",
"(",
"$",
"msg",
")",
"{",
"$",
"this",
"->",
"mailMessage",
"(",
"self",
"::",
"LEVEL_WARN",
",",
"$",
"msg",
")",
";",
"if",
"(",
"$",
"this",
"->",
"checkLevel",
"(",
"$",
"this",
"->",
"loglevels",
",",
"self",
"::",
"LEVEL_WARN",
")",
"!==",
"true",
")",
"return",
";",
"$",
"this",
"->",
"writeMessage",
"(",
"self",
"::",
"LEVEL_WARN",
",",
"$",
"msg",
")",
";",
"}"
] | Logs a warning
@param type $msg | [
"Logs",
"a",
"warning"
] | train | https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/logger/Logger.php#L101-L108 |
TiMESPLiNTER/tsFramework | src/ch/timesplinter/logger/Logger.php | Logger.info | public function info($msg) {
$this->mailMessage(self::LEVEL_INFO, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_INFO) !== true)
return;
$this->writeMessage(self::LEVEL_INFO, $msg);
} | php | public function info($msg) {
$this->mailMessage(self::LEVEL_INFO, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_INFO) !== true)
return;
$this->writeMessage(self::LEVEL_INFO, $msg);
} | [
"public",
"function",
"info",
"(",
"$",
"msg",
")",
"{",
"$",
"this",
"->",
"mailMessage",
"(",
"self",
"::",
"LEVEL_INFO",
",",
"$",
"msg",
")",
";",
"if",
"(",
"$",
"this",
"->",
"checkLevel",
"(",
"$",
"this",
"->",
"loglevels",
",",
"self",
"::",
"LEVEL_INFO",
")",
"!==",
"true",
")",
"return",
";",
"$",
"this",
"->",
"writeMessage",
"(",
"self",
"::",
"LEVEL_INFO",
",",
"$",
"msg",
")",
";",
"}"
] | Logs an information
@param string $msg
@return type | [
"Logs",
"an",
"information"
] | train | https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/logger/Logger.php#L115-L122 |
TiMESPLiNTER/tsFramework | src/ch/timesplinter/logger/Logger.php | Logger.debug | public function debug($msg, $vars = array()) {
$this->mailMessage(self::LEVEL_DEBUG, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_DEBUG) !== true)
return;
if(!is_array($vars))
$vars = array($vars);
$varDump = '';
$varCount = count($vars);
if($varCount > 0) {
$vars = array_values($vars);
$bt = debug_backtrace();
$content = file($bt[0]['file']);
$line = $content[$bt[0]['line'] - 1];
preg_match('/debug\((.+?),array\((.+)\)\)/', $line, $matches);
$varNames = null;
if(count($matches) > 0)
$varNames = explode(',', $matches[2]);
for($i = 0; $i < $varCount; $i++) {
$printedVar = trim(var_export($vars[$i], true));
$varDump .= "\r\n\t" . (($varNames !== null) ? trim($varNames[$i]) . '=' : '') . str_replace("\n", "\r\n\t", $printedVar);
}
}
$this->writeMessage(self::LEVEL_DEBUG, $msg . $varDump);
} | php | public function debug($msg, $vars = array()) {
$this->mailMessage(self::LEVEL_DEBUG, $msg);
if($this->checkLevel($this->loglevels, self::LEVEL_DEBUG) !== true)
return;
if(!is_array($vars))
$vars = array($vars);
$varDump = '';
$varCount = count($vars);
if($varCount > 0) {
$vars = array_values($vars);
$bt = debug_backtrace();
$content = file($bt[0]['file']);
$line = $content[$bt[0]['line'] - 1];
preg_match('/debug\((.+?),array\((.+)\)\)/', $line, $matches);
$varNames = null;
if(count($matches) > 0)
$varNames = explode(',', $matches[2]);
for($i = 0; $i < $varCount; $i++) {
$printedVar = trim(var_export($vars[$i], true));
$varDump .= "\r\n\t" . (($varNames !== null) ? trim($varNames[$i]) . '=' : '') . str_replace("\n", "\r\n\t", $printedVar);
}
}
$this->writeMessage(self::LEVEL_DEBUG, $msg . $varDump);
} | [
"public",
"function",
"debug",
"(",
"$",
"msg",
",",
"$",
"vars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"mailMessage",
"(",
"self",
"::",
"LEVEL_DEBUG",
",",
"$",
"msg",
")",
";",
"if",
"(",
"$",
"this",
"->",
"checkLevel",
"(",
"$",
"this",
"->",
"loglevels",
",",
"self",
"::",
"LEVEL_DEBUG",
")",
"!==",
"true",
")",
"return",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"vars",
")",
")",
"$",
"vars",
"=",
"array",
"(",
"$",
"vars",
")",
";",
"$",
"varDump",
"=",
"''",
";",
"$",
"varCount",
"=",
"count",
"(",
"$",
"vars",
")",
";",
"if",
"(",
"$",
"varCount",
">",
"0",
")",
"{",
"$",
"vars",
"=",
"array_values",
"(",
"$",
"vars",
")",
";",
"$",
"bt",
"=",
"debug_backtrace",
"(",
")",
";",
"$",
"content",
"=",
"file",
"(",
"$",
"bt",
"[",
"0",
"]",
"[",
"'file'",
"]",
")",
";",
"$",
"line",
"=",
"$",
"content",
"[",
"$",
"bt",
"[",
"0",
"]",
"[",
"'line'",
"]",
"-",
"1",
"]",
";",
"preg_match",
"(",
"'/debug\\((.+?),array\\((.+)\\)\\)/'",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"$",
"varNames",
"=",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
">",
"0",
")",
"$",
"varNames",
"=",
"explode",
"(",
"','",
",",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"varCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"printedVar",
"=",
"trim",
"(",
"var_export",
"(",
"$",
"vars",
"[",
"$",
"i",
"]",
",",
"true",
")",
")",
";",
"$",
"varDump",
".=",
"\"\\r\\n\\t\"",
".",
"(",
"(",
"$",
"varNames",
"!==",
"null",
")",
"?",
"trim",
"(",
"$",
"varNames",
"[",
"$",
"i",
"]",
")",
".",
"'='",
":",
"''",
")",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\r\\n\\t\"",
",",
"$",
"printedVar",
")",
";",
"}",
"}",
"$",
"this",
"->",
"writeMessage",
"(",
"self",
"::",
"LEVEL_DEBUG",
",",
"$",
"msg",
".",
"$",
"varDump",
")",
";",
"}"
] | Logs a debug message
@param string $msg
@param array $vars | [
"Logs",
"a",
"debug",
"message"
] | train | https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/logger/Logger.php#L129-L161 |
phpffcms/ffcms-core | src/Traits/ClassTools.php | ClassTools.createStringClassSnapshotHash | public function createStringClassSnapshotHash()
{
$hash = null;
foreach ($this as $property => $value) {
$hash = md5($hash . $property . '=' . $value);
}
return $hash;
} | php | public function createStringClassSnapshotHash()
{
$hash = null;
foreach ($this as $property => $value) {
$hash = md5($hash . $property . '=' . $value);
}
return $hash;
} | [
"public",
"function",
"createStringClassSnapshotHash",
"(",
")",
"{",
"$",
"hash",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"hash",
"=",
"md5",
"(",
"$",
"hash",
".",
"$",
"property",
".",
"'='",
".",
"$",
"value",
")",
";",
"}",
"return",
"$",
"hash",
";",
"}"
] | Create hash string from current class properties and itself values.
This method is good stuff for caching dynamic instances
@return string|null | [
"Create",
"hash",
"string",
"from",
"current",
"class",
"properties",
"and",
"itself",
"values",
".",
"This",
"method",
"is",
"good",
"stuff",
"for",
"caching",
"dynamic",
"instances"
] | train | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Traits/ClassTools.php#L16-L23 |
phpffcms/ffcms-core | src/Traits/ClassTools.php | ClassTools.getMethodRequiredArgCount | public function getMethodRequiredArgCount($class, string $method): int
{
$instance = new \ReflectionMethod($class, $method);
$count = 0;
// calculate method defined arguments count
foreach ($instance->getParameters() as $arg) {
if (!$arg->isOptional()) {
$count++;
}
}
return $count;
} | php | public function getMethodRequiredArgCount($class, string $method): int
{
$instance = new \ReflectionMethod($class, $method);
$count = 0;
// calculate method defined arguments count
foreach ($instance->getParameters() as $arg) {
if (!$arg->isOptional()) {
$count++;
}
}
return $count;
} | [
"public",
"function",
"getMethodRequiredArgCount",
"(",
"$",
"class",
",",
"string",
"$",
"method",
")",
":",
"int",
"{",
"$",
"instance",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"method",
")",
";",
"$",
"count",
"=",
"0",
";",
"// calculate method defined arguments count",
"foreach",
"(",
"$",
"instance",
"->",
"getParameters",
"(",
")",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"!",
"$",
"arg",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] | Get method required arguments count
@param $class
@param string $method
@return int | [
"Get",
"method",
"required",
"arguments",
"count"
] | train | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Traits/ClassTools.php#L31-L43 |
IgorTimoshenko/IMTDataGrid | src/Filter/Filter.php | Filter.loadValidatorMetadata | public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint(
'options',
new Assert\Collection(
array(
'fields' => array(
'groupOp' => array(
new Assert\NotBlank(),
new Assert\Type(
array(
'type' => 'string',
)
),
new Assert\Choice(
array(
'choices' => array(
'AND',
'OR',
)
)
),
)
),
)
)
);
} | php | public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint(
'options',
new Assert\Collection(
array(
'fields' => array(
'groupOp' => array(
new Assert\NotBlank(),
new Assert\Type(
array(
'type' => 'string',
)
),
new Assert\Choice(
array(
'choices' => array(
'AND',
'OR',
)
)
),
)
),
)
)
);
} | [
"public",
"static",
"function",
"loadValidatorMetadata",
"(",
"ClassMetadata",
"$",
"metadata",
")",
"{",
"$",
"metadata",
"->",
"addPropertyConstraint",
"(",
"'options'",
",",
"new",
"Assert",
"\\",
"Collection",
"(",
"array",
"(",
"'fields'",
"=>",
"array",
"(",
"'groupOp'",
"=>",
"array",
"(",
"new",
"Assert",
"\\",
"NotBlank",
"(",
")",
",",
"new",
"Assert",
"\\",
"Type",
"(",
"array",
"(",
"'type'",
"=>",
"'string'",
",",
")",
")",
",",
"new",
"Assert",
"\\",
"Choice",
"(",
"array",
"(",
"'choices'",
"=>",
"array",
"(",
"'AND'",
",",
"'OR'",
",",
")",
")",
")",
",",
")",
")",
",",
")",
")",
")",
";",
"}"
] | Loads the metadata for the validator
@param ClassMetadata $metadata | [
"Loads",
"the",
"metadata",
"for",
"the",
"validator"
] | train | https://github.com/IgorTimoshenko/IMTDataGrid/blob/c70c12a250e9b17870c2cd6cc7fa1f35cbf3b9af/src/Filter/Filter.php#L117-L144 |
dms-org/common.structure | src/Geo/Persistence/GeoOrm.php | GeoOrm.define | protected function define(OrmDefinition $orm)
{
$orm->valueObjects([
LatLng::class => LatLngMapper::class,
StreetAddress::class => StreetAddressMapper::class,
StreetAddressWithLatLng::class => StreetAddressWithLatLngMapper::class,
]);
} | php | protected function define(OrmDefinition $orm)
{
$orm->valueObjects([
LatLng::class => LatLngMapper::class,
StreetAddress::class => StreetAddressMapper::class,
StreetAddressWithLatLng::class => StreetAddressWithLatLngMapper::class,
]);
} | [
"protected",
"function",
"define",
"(",
"OrmDefinition",
"$",
"orm",
")",
"{",
"$",
"orm",
"->",
"valueObjects",
"(",
"[",
"LatLng",
"::",
"class",
"=>",
"LatLngMapper",
"::",
"class",
",",
"StreetAddress",
"::",
"class",
"=>",
"StreetAddressMapper",
"::",
"class",
",",
"StreetAddressWithLatLng",
"::",
"class",
"=>",
"StreetAddressWithLatLngMapper",
"::",
"class",
",",
"]",
")",
";",
"}"
] | Defines the object mappers registered in the orm.
@param OrmDefinition $orm
@return void | [
"Defines",
"the",
"object",
"mappers",
"registered",
"in",
"the",
"orm",
"."
] | train | https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Geo/Persistence/GeoOrm.php#L25-L32 |
WellCommerce/PaymentBundle | Visitor/PaymentMethodOrderVisitor.php | PaymentMethodOrderVisitor.visitOrder | public function visitOrder(OrderInterface $order)
{
if (false === $order->hasShippingMethod()) {
$order->setPaymentMethod(null);
return;
}
$shippingMethod = $order->getShippingMethod();
$paymentMethods = $shippingMethod->getPaymentMethods();
if (false === $order->hasPaymentMethod() || false === $paymentMethods->contains($order->getPaymentMethod())) {
$order->setPaymentMethod($paymentMethods->first());
}
} | php | public function visitOrder(OrderInterface $order)
{
if (false === $order->hasShippingMethod()) {
$order->setPaymentMethod(null);
return;
}
$shippingMethod = $order->getShippingMethod();
$paymentMethods = $shippingMethod->getPaymentMethods();
if (false === $order->hasPaymentMethod() || false === $paymentMethods->contains($order->getPaymentMethod())) {
$order->setPaymentMethod($paymentMethods->first());
}
} | [
"public",
"function",
"visitOrder",
"(",
"OrderInterface",
"$",
"order",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"order",
"->",
"hasShippingMethod",
"(",
")",
")",
"{",
"$",
"order",
"->",
"setPaymentMethod",
"(",
"null",
")",
";",
"return",
";",
"}",
"$",
"shippingMethod",
"=",
"$",
"order",
"->",
"getShippingMethod",
"(",
")",
";",
"$",
"paymentMethods",
"=",
"$",
"shippingMethod",
"->",
"getPaymentMethods",
"(",
")",
";",
"if",
"(",
"false",
"===",
"$",
"order",
"->",
"hasPaymentMethod",
"(",
")",
"||",
"false",
"===",
"$",
"paymentMethods",
"->",
"contains",
"(",
"$",
"order",
"->",
"getPaymentMethod",
"(",
")",
")",
")",
"{",
"$",
"order",
"->",
"setPaymentMethod",
"(",
"$",
"paymentMethods",
"->",
"first",
"(",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/WellCommerce/PaymentBundle/blob/7fdeb0b5155646f2b638082d2135bec05eb8be98/Visitor/PaymentMethodOrderVisitor.php#L28-L42 |
inetstudio/widgets | src/Services/Front/WidgetsService.php | WidgetsService.getWidgetContent | public function getWidgetContent(int $id): string
{
$widget = $this->repository->getItemByID($id);
if ($widget->id) {
$view = $widget->view;
if (view()->exists($view)) {
$params = $widget->params;
return view($view, array_merge(is_array($params) ? $params : [], ['widget' => $widget]));
}
}
return '';
} | php | public function getWidgetContent(int $id): string
{
$widget = $this->repository->getItemByID($id);
if ($widget->id) {
$view = $widget->view;
if (view()->exists($view)) {
$params = $widget->params;
return view($view, array_merge(is_array($params) ? $params : [], ['widget' => $widget]));
}
}
return '';
} | [
"public",
"function",
"getWidgetContent",
"(",
"int",
"$",
"id",
")",
":",
"string",
"{",
"$",
"widget",
"=",
"$",
"this",
"->",
"repository",
"->",
"getItemByID",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"widget",
"->",
"id",
")",
"{",
"$",
"view",
"=",
"$",
"widget",
"->",
"view",
";",
"if",
"(",
"view",
"(",
")",
"->",
"exists",
"(",
"$",
"view",
")",
")",
"{",
"$",
"params",
"=",
"$",
"widget",
"->",
"params",
";",
"return",
"view",
"(",
"$",
"view",
",",
"array_merge",
"(",
"is_array",
"(",
"$",
"params",
")",
"?",
"$",
"params",
":",
"[",
"]",
",",
"[",
"'widget'",
"=>",
"$",
"widget",
"]",
")",
")",
";",
"}",
"}",
"return",
"''",
";",
"}"
] | Получаем содержимое виджета.
@param int $id
@return string | [
"Получаем",
"содержимое",
"виджета",
"."
] | train | https://github.com/inetstudio/widgets/blob/bc9357a1183a028f93f725b55b9db2867b7ec731/src/Services/Front/WidgetsService.php#L35-L49 |
KDF5000/EasyThink | src/ThinkPHP/Library/Vendor/Smarty/sysplugins/smarty_cacheresource_custom.php | Smarty_CacheResource_Custom.clear | public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
$this->cache = array();
return $this->delete($resource_name, $cache_id, $compile_id, $exp_time);
} | php | public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
$this->cache = array();
return $this->delete($resource_name, $cache_id, $compile_id, $exp_time);
} | [
"public",
"function",
"clear",
"(",
"Smarty",
"$",
"smarty",
",",
"$",
"resource_name",
",",
"$",
"cache_id",
",",
"$",
"compile_id",
",",
"$",
"exp_time",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"array",
"(",
")",
";",
"return",
"$",
"this",
"->",
"delete",
"(",
"$",
"resource_name",
",",
"$",
"cache_id",
",",
"$",
"compile_id",
",",
"$",
"exp_time",
")",
";",
"}"
] | Empty cache for a specific template
@param Smarty $smarty Smarty object
@param string $resource_name template name
@param string $cache_id cache id
@param string $compile_id compile id
@param integer $exp_time expiration time (number of seconds, not timestamp)
@return integer number of cache files deleted | [
"Empty",
"cache",
"for",
"a",
"specific",
"template"
] | train | https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Vendor/Smarty/sysplugins/smarty_cacheresource_custom.php#L182-L186 |
MinyFramework/Miny-Core | src/Controller/AbstractControllerRunner.php | AbstractControllerRunner.run | public function run(Request $request, Response $response)
{
$this->initController($request, $response);
$event = $this->eventDispatcher->raiseEvent(
$this->createLoadedEvent()
);
if ($event->isHandled() && $event->getResponse() instanceof Response) {
return $event->getResponse();
}
$this->eventDispatcher->raiseEvent(
$this->createFinishedEvent(
$this->runController($request, $response)
)
);
return $response;
} | php | public function run(Request $request, Response $response)
{
$this->initController($request, $response);
$event = $this->eventDispatcher->raiseEvent(
$this->createLoadedEvent()
);
if ($event->isHandled() && $event->getResponse() instanceof Response) {
return $event->getResponse();
}
$this->eventDispatcher->raiseEvent(
$this->createFinishedEvent(
$this->runController($request, $response)
)
);
return $response;
} | [
"public",
"function",
"run",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"initController",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"$",
"event",
"=",
"$",
"this",
"->",
"eventDispatcher",
"->",
"raiseEvent",
"(",
"$",
"this",
"->",
"createLoadedEvent",
"(",
")",
")",
";",
"if",
"(",
"$",
"event",
"->",
"isHandled",
"(",
")",
"&&",
"$",
"event",
"->",
"getResponse",
"(",
")",
"instanceof",
"Response",
")",
"{",
"return",
"$",
"event",
"->",
"getResponse",
"(",
")",
";",
"}",
"$",
"this",
"->",
"eventDispatcher",
"->",
"raiseEvent",
"(",
"$",
"this",
"->",
"createFinishedEvent",
"(",
"$",
"this",
"->",
"runController",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] | @param Request $request
@param Response $response
@return Response | [
"@param",
"Request",
"$request",
"@param",
"Response",
"$response"
] | train | https://github.com/MinyFramework/Miny-Core/blob/a1bfe801a44a49cf01f16411cb4663473e9c827c/src/Controller/AbstractControllerRunner.php#L46-L64 |
PenoaksDev/Milky-Framework | src/Milky/Database/Connectors/ConnectionFactory.php | ConnectionFactory.make | public function make( array $config, $name = null )
{
$config = $this->parseConfig( $config, $name );
if ( isset( $config['read'] ) )
return $this->createReadWriteConnection( $config );
return $this->createSingleConnection( $config );
} | php | public function make( array $config, $name = null )
{
$config = $this->parseConfig( $config, $name );
if ( isset( $config['read'] ) )
return $this->createReadWriteConnection( $config );
return $this->createSingleConnection( $config );
} | [
"public",
"function",
"make",
"(",
"array",
"$",
"config",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"parseConfig",
"(",
"$",
"config",
",",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'read'",
"]",
")",
")",
"return",
"$",
"this",
"->",
"createReadWriteConnection",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"createSingleConnection",
"(",
"$",
"config",
")",
";",
"}"
] | Establish a PDO connection based on the configuration.
@param array $config
@param string $name
@return Connection | [
"Establish",
"a",
"PDO",
"connection",
"based",
"on",
"the",
"configuration",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Connectors/ConnectionFactory.php#L20-L28 |
PenoaksDev/Milky-Framework | src/Milky/Database/Connectors/ConnectionFactory.php | ConnectionFactory.getReadConfig | protected function getReadConfig( array $config )
{
$readConfig = $this->getReadWriteConfig( $config, 'read' );
if ( isset( $readConfig['host'] ) && is_array( $readConfig['host'] ) )
$readConfig['host'] = count( $readConfig['host'] ) > 1 ? $readConfig['host'][array_rand( $readConfig['host'] )] : $readConfig['host'][0];
return $this->mergeReadWriteConfig( $config, $readConfig );
} | php | protected function getReadConfig( array $config )
{
$readConfig = $this->getReadWriteConfig( $config, 'read' );
if ( isset( $readConfig['host'] ) && is_array( $readConfig['host'] ) )
$readConfig['host'] = count( $readConfig['host'] ) > 1 ? $readConfig['host'][array_rand( $readConfig['host'] )] : $readConfig['host'][0];
return $this->mergeReadWriteConfig( $config, $readConfig );
} | [
"protected",
"function",
"getReadConfig",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"readConfig",
"=",
"$",
"this",
"->",
"getReadWriteConfig",
"(",
"$",
"config",
",",
"'read'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"readConfig",
"[",
"'host'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"readConfig",
"[",
"'host'",
"]",
")",
")",
"$",
"readConfig",
"[",
"'host'",
"]",
"=",
"count",
"(",
"$",
"readConfig",
"[",
"'host'",
"]",
")",
">",
"1",
"?",
"$",
"readConfig",
"[",
"'host'",
"]",
"[",
"array_rand",
"(",
"$",
"readConfig",
"[",
"'host'",
"]",
")",
"]",
":",
"$",
"readConfig",
"[",
"'host'",
"]",
"[",
"0",
"]",
";",
"return",
"$",
"this",
"->",
"mergeReadWriteConfig",
"(",
"$",
"config",
",",
"$",
"readConfig",
")",
";",
"}"
] | Get the read configuration for a read / write connection.
@param array $config
@return array | [
"Get",
"the",
"read",
"configuration",
"for",
"a",
"read",
"/",
"write",
"connection",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Connectors/ConnectionFactory.php#L78-L86 |
PenoaksDev/Milky-Framework | src/Milky/Database/Connectors/ConnectionFactory.php | ConnectionFactory.getReadWriteConfig | protected function getReadWriteConfig( array $config, $type )
{
if ( isset( $config[$type][0] ) )
return $config[$type][array_rand( $config[$type] )];
return $config[$type];
} | php | protected function getReadWriteConfig( array $config, $type )
{
if ( isset( $config[$type][0] ) )
return $config[$type][array_rand( $config[$type] )];
return $config[$type];
} | [
"protected",
"function",
"getReadWriteConfig",
"(",
"array",
"$",
"config",
",",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"$",
"type",
"]",
"[",
"0",
"]",
")",
")",
"return",
"$",
"config",
"[",
"$",
"type",
"]",
"[",
"array_rand",
"(",
"$",
"config",
"[",
"$",
"type",
"]",
")",
"]",
";",
"return",
"$",
"config",
"[",
"$",
"type",
"]",
";",
"}"
] | Get a read / write level configuration.
@param array $config
@param string $type
@return array | [
"Get",
"a",
"read",
"/",
"write",
"level",
"configuration",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Connectors/ConnectionFactory.php#L108-L114 |
PenoaksDev/Milky-Framework | src/Milky/Database/Connectors/ConnectionFactory.php | ConnectionFactory.createConnector | public function createConnector( array $config )
{
if ( !isset( $config['driver'] ) )
throw new InvalidArgumentException( 'A driver must be specified.' );
switch ( $config['driver'] )
{
case 'mysql':
return new MySqlConnector;
case 'pgsql':
return new PostgresConnector;
case 'sqlite':
return new SQLiteConnector;
case 'sqlsrv':
return new SqlServerConnector;
}
throw new InvalidArgumentException( "Unsupported driver [{$config['driver']}]" );
} | php | public function createConnector( array $config )
{
if ( !isset( $config['driver'] ) )
throw new InvalidArgumentException( 'A driver must be specified.' );
switch ( $config['driver'] )
{
case 'mysql':
return new MySqlConnector;
case 'pgsql':
return new PostgresConnector;
case 'sqlite':
return new SQLiteConnector;
case 'sqlsrv':
return new SqlServerConnector;
}
throw new InvalidArgumentException( "Unsupported driver [{$config['driver']}]" );
} | [
"public",
"function",
"createConnector",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'A driver must be specified.'",
")",
";",
"switch",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
"{",
"case",
"'mysql'",
":",
"return",
"new",
"MySqlConnector",
";",
"case",
"'pgsql'",
":",
"return",
"new",
"PostgresConnector",
";",
"case",
"'sqlite'",
":",
"return",
"new",
"SQLiteConnector",
";",
"case",
"'sqlsrv'",
":",
"return",
"new",
"SqlServerConnector",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unsupported driver [{$config['driver']}]\"",
")",
";",
"}"
] | Create a connector instance based on the configuration.
@param array $config
@return ConnectorInterface
@throws \InvalidArgumentException | [
"Create",
"a",
"connector",
"instance",
"based",
"on",
"the",
"configuration",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Connectors/ConnectionFactory.php#L148-L166 |
PenoaksDev/Milky-Framework | src/Milky/Database/Connectors/ConnectionFactory.php | ConnectionFactory.createConnection | protected function createConnection( $driver, $connection, $database, $prefix = '', array $config = [] )
{
switch ( $driver )
{
case 'mysql':
return new MySqlConnection( $connection, $database, $prefix, $config );
case 'pgsql':
return new PostgresConnection( $connection, $database, $prefix, $config );
case 'sqlite':
return new SQLiteConnection( $connection, $database, $prefix, $config );
case 'sqlsrv':
return new SqlServerConnection( $connection, $database, $prefix, $config );
}
throw new InvalidArgumentException( "Unsupported driver [$driver]" );
} | php | protected function createConnection( $driver, $connection, $database, $prefix = '', array $config = [] )
{
switch ( $driver )
{
case 'mysql':
return new MySqlConnection( $connection, $database, $prefix, $config );
case 'pgsql':
return new PostgresConnection( $connection, $database, $prefix, $config );
case 'sqlite':
return new SQLiteConnection( $connection, $database, $prefix, $config );
case 'sqlsrv':
return new SqlServerConnection( $connection, $database, $prefix, $config );
}
throw new InvalidArgumentException( "Unsupported driver [$driver]" );
} | [
"protected",
"function",
"createConnection",
"(",
"$",
"driver",
",",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"prefix",
"=",
"''",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"'mysql'",
":",
"return",
"new",
"MySqlConnection",
"(",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"prefix",
",",
"$",
"config",
")",
";",
"case",
"'pgsql'",
":",
"return",
"new",
"PostgresConnection",
"(",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"prefix",
",",
"$",
"config",
")",
";",
"case",
"'sqlite'",
":",
"return",
"new",
"SQLiteConnection",
"(",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"prefix",
",",
"$",
"config",
")",
";",
"case",
"'sqlsrv'",
":",
"return",
"new",
"SqlServerConnection",
"(",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"prefix",
",",
"$",
"config",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unsupported driver [$driver]\"",
")",
";",
"}"
] | Create a new connection instance.
@param string $driver
@param string $database
@param string $prefix
@param array $config
@return Connection
@throws \InvalidArgumentException | [
"Create",
"a",
"new",
"connection",
"instance",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Database/Connectors/ConnectionFactory.php#L179-L194 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.contains | public function contains($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
return $this->unitOfWork->isScheduledForInsert($document) ||
$this->unitOfWork->isInIdentityMap($document) &&
!$this->unitOfWork->isScheduledForDelete($document);
} | php | public function contains($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
return $this->unitOfWork->isScheduledForInsert($document) ||
$this->unitOfWork->isInIdentityMap($document) &&
!$this->unitOfWork->isScheduledForDelete($document);
} | [
"public",
"function",
"contains",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"document",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"document",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"unitOfWork",
"->",
"isScheduledForInsert",
"(",
"$",
"document",
")",
"||",
"$",
"this",
"->",
"unitOfWork",
"->",
"isInIdentityMap",
"(",
"$",
"document",
")",
"&&",
"!",
"$",
"this",
"->",
"unitOfWork",
"->",
"isScheduledForDelete",
"(",
"$",
"document",
")",
";",
"}"
] | Determines whether a document instance is managed in this DocumentManager.
@param object $document
@throws \InvalidArgumentException When the $document param is not an object
@return bool TRUE if this DocumentManager currently manages the given document, FALSE otherwise. | [
"Determines",
"whether",
"a",
"document",
"instance",
"is",
"managed",
"in",
"this",
"DocumentManager",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L207-L216 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.detach | public function detach($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->detach($document);
} | php | public function detach($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->detach($document);
} | [
"public",
"function",
"detach",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"document",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"document",
")",
")",
";",
"}",
"$",
"this",
"->",
"unitOfWork",
"->",
"detach",
"(",
"$",
"document",
")",
";",
"}"
] | Detaches a document from the DocumentManager, causing a managed document to
become detached. Unflushed changes made to the document if any
(including removal of the document), will not be synchronized to the database.
Documents which previously referenced the detached document will continue to
reference it.
@param object $document The document to detach.
@throws \InvalidArgumentException when the $document param is not an object | [
"Detaches",
"a",
"document",
"from",
"the",
"DocumentManager",
"causing",
"a",
"managed",
"document",
"to",
"become",
"detached",
".",
"Unflushed",
"changes",
"made",
"to",
"the",
"document",
"if",
"any",
"(",
"including",
"removal",
"of",
"the",
"document",
")",
"will",
"not",
"be",
"synchronized",
"to",
"the",
"database",
".",
"Documents",
"which",
"previously",
"referenced",
"the",
"detached",
"document",
"will",
"continue",
"to",
"reference",
"it",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L258-L264 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.find | public function find($documentName, $hashValue, $rangeValue = null)
{
return $this->getRepository($documentName)->find($hashValue, $rangeValue);
} | php | public function find($documentName, $hashValue, $rangeValue = null)
{
return $this->getRepository($documentName)->find($hashValue, $rangeValue);
} | [
"public",
"function",
"find",
"(",
"$",
"documentName",
",",
"$",
"hashValue",
",",
"$",
"rangeValue",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getRepository",
"(",
"$",
"documentName",
")",
"->",
"find",
"(",
"$",
"hashValue",
",",
"$",
"rangeValue",
")",
";",
"}"
] | Finds a Document by its primary key.
This is just a convenient shortcut for getRepository($documentName)->find().
@param string $documentName
@param mixed $hashValue
@param mixed|null $rangeValue
@return object $document | [
"Finds",
"a",
"Document",
"by",
"its",
"primary",
"key",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L289-L292 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.getFilterCollection | public function getFilterCollection()
{
if (null === $this->filterCollection) {
$this->filterCollection = new Filter\FilterCollection($this);
}
return $this->filterCollection;
} | php | public function getFilterCollection()
{
if (null === $this->filterCollection) {
$this->filterCollection = new Filter\FilterCollection($this);
}
return $this->filterCollection;
} | [
"public",
"function",
"getFilterCollection",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"filterCollection",
")",
"{",
"$",
"this",
"->",
"filterCollection",
"=",
"new",
"Filter",
"\\",
"FilterCollection",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"filterCollection",
";",
"}"
] | Gets the filter collection.
@return Filter\FilterCollection The active filter collection. | [
"Gets",
"the",
"filter",
"collection",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L356-L363 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.lock | public function lock($document, $lockMode, $lockVersion = null)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->lock($document, $lockMode, $lockVersion);
} | php | public function lock($document, $lockMode, $lockVersion = null)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->lock($document, $lockMode, $lockVersion);
} | [
"public",
"function",
"lock",
"(",
"$",
"document",
",",
"$",
"lockMode",
",",
"$",
"lockVersion",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"document",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"document",
")",
")",
";",
"}",
"$",
"this",
"->",
"unitOfWork",
"->",
"lock",
"(",
"$",
"document",
",",
"$",
"lockMode",
",",
"$",
"lockVersion",
")",
";",
"}"
] | Acquire a lock on the given document.
@param object $document
@param int $lockMode
@param int $lockVersion
@throws \InvalidArgumentException | [
"Acquire",
"a",
"lock",
"on",
"the",
"given",
"document",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L459-L465 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.persist | public function persist($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
$this->unitOfWork->persist($document);
} | php | public function persist($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
$this->unitOfWork->persist($document);
} | [
"public",
"function",
"persist",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"document",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"document",
")",
")",
";",
"}",
"$",
"this",
"->",
"errorIfClosed",
"(",
")",
";",
"$",
"this",
"->",
"unitOfWork",
"->",
"persist",
"(",
"$",
"document",
")",
";",
"}"
] | Tells the DocumentManager to make an instance managed and persistent.
The document will be entered into the database at or before transaction
commit or as a result of the flush operation.
NOTE: The persist operation always considers documents that are not yet known to
this DocumentManager as NEW. Do not pass detached documents to the persist operation.
@param object $document The instance to make managed and persistent.
@throws \InvalidArgumentException When the given $document param is not an object | [
"Tells",
"the",
"DocumentManager",
"to",
"make",
"an",
"instance",
"managed",
"and",
"persistent",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L500-L507 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.refresh | public function refresh($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
$this->unitOfWork->refresh($document);
} | php | public function refresh($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
$this->unitOfWork->refresh($document);
} | [
"public",
"function",
"refresh",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"document",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"document",
")",
")",
";",
"}",
"$",
"this",
"->",
"errorIfClosed",
"(",
")",
";",
"$",
"this",
"->",
"unitOfWork",
"->",
"refresh",
"(",
"$",
"document",
")",
";",
"}"
] | Refreshes the persistent state of a document from the database,
overriding any local changes that have not yet been persisted.
@param object $document The document to refresh.
@throws \InvalidArgumentException When the given $document param is not an object | [
"Refreshes",
"the",
"persistent",
"state",
"of",
"a",
"document",
"from",
"the",
"database",
"overriding",
"any",
"local",
"changes",
"that",
"have",
"not",
"yet",
"been",
"persisted",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L517-L524 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.remove | public function remove($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
$this->unitOfWork->remove($document);
} | php | public function remove($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->errorIfClosed();
$this->unitOfWork->remove($document);
} | [
"public",
"function",
"remove",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"document",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"document",
")",
")",
";",
"}",
"$",
"this",
"->",
"errorIfClosed",
"(",
")",
";",
"$",
"this",
"->",
"unitOfWork",
"->",
"remove",
"(",
"$",
"document",
")",
";",
"}"
] | Removes a document instance.
A removed document will be removed from the database at or before transaction commit
or as a result of the flush operation.
@param object $document The document instance to remove.
@throws \InvalidArgumentException when the $document param is not an object | [
"Removes",
"a",
"document",
"instance",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L536-L543 |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/DocumentManager.php | DocumentManager.unlock | public function unlock($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->unlock($document);
} | php | public function unlock($document)
{
if (!is_object($document)) {
throw new \InvalidArgumentException(gettype($document));
}
$this->unitOfWork->unlock($document);
} | [
"public",
"function",
"unlock",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"document",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"gettype",
"(",
"$",
"document",
")",
")",
";",
"}",
"$",
"this",
"->",
"unitOfWork",
"->",
"unlock",
"(",
"$",
"document",
")",
";",
"}"
] | Releases a lock on the given document.
@param object $document
@throws \InvalidArgumentException if the $document param is not an object | [
"Releases",
"a",
"lock",
"on",
"the",
"given",
"document",
"."
] | train | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/DocumentManager.php#L570-L576 |
lightwerk/SurfTasks | Classes/Lightwerk/SurfTasks/Task/TYPO3/Flow/FlushCacheTask.php | FlushCacheTask.execute | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate(
'cd '.$targetPath.' && FLOW_CONTEXT='.$options['context'].' ./flow typo3.flow:cache:flush',
$node,
$deployment
);
} | php | public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
{
$targetPath = $deployment->getApplicationReleasePath($application);
$this->shell->executeOrSimulate(
'cd '.$targetPath.' && FLOW_CONTEXT='.$options['context'].' ./flow typo3.flow:cache:flush',
$node,
$deployment
);
} | [
"public",
"function",
"execute",
"(",
"Node",
"$",
"node",
",",
"Application",
"$",
"application",
",",
"Deployment",
"$",
"deployment",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"targetPath",
"=",
"$",
"deployment",
"->",
"getApplicationReleasePath",
"(",
"$",
"application",
")",
";",
"$",
"this",
"->",
"shell",
"->",
"executeOrSimulate",
"(",
"'cd '",
".",
"$",
"targetPath",
".",
"' && FLOW_CONTEXT='",
".",
"$",
"options",
"[",
"'context'",
"]",
".",
"' ./flow typo3.flow:cache:flush'",
",",
"$",
"node",
",",
"$",
"deployment",
")",
";",
"}"
] | Executes this task.
@param Node $node
@param Application $application
@param Deployment $deployment
@param array $options
@throws TaskExecutionException | [
"Executes",
"this",
"task",
"."
] | train | https://github.com/lightwerk/SurfTasks/blob/8a6e4c85e42c762ad6515778c3fc7e19052cd9d1/Classes/Lightwerk/SurfTasks/Task/TYPO3/Flow/FlushCacheTask.php#L51-L59 |
intpro/extractor | src/Selection/Specification/SpecificationSet.php | SpecificationSet.applyAll | public function applyAll(Builder $query)
{
//Сначала И элементы связанные через ИЛИ
foreach($this->or_union as $union)
{
if(count($union) > 0)
{
$query->where(function($sub) use ($union){
$or = false;
foreach($union as $specUnit)
{
$specUnit->apply($sub, $or);
$or = true;
}
});
}
}
//Затем отдельные И элементы
foreach($this->free as $specUnit)
{
$specUnit->apply($query);
}
} | php | public function applyAll(Builder $query)
{
//Сначала И элементы связанные через ИЛИ
foreach($this->or_union as $union)
{
if(count($union) > 0)
{
$query->where(function($sub) use ($union){
$or = false;
foreach($union as $specUnit)
{
$specUnit->apply($sub, $or);
$or = true;
}
});
}
}
//Затем отдельные И элементы
foreach($this->free as $specUnit)
{
$specUnit->apply($query);
}
} | [
"public",
"function",
"applyAll",
"(",
"Builder",
"$",
"query",
")",
"{",
"//Сначала И элементы связанные через ИЛИ",
"foreach",
"(",
"$",
"this",
"->",
"or_union",
"as",
"$",
"union",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"union",
")",
">",
"0",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"function",
"(",
"$",
"sub",
")",
"use",
"(",
"$",
"union",
")",
"{",
"$",
"or",
"=",
"false",
";",
"foreach",
"(",
"$",
"union",
"as",
"$",
"specUnit",
")",
"{",
"$",
"specUnit",
"->",
"apply",
"(",
"$",
"sub",
",",
"$",
"or",
")",
";",
"$",
"or",
"=",
"true",
";",
"}",
"}",
")",
";",
"}",
"}",
"//Затем отдельные И элементы",
"foreach",
"(",
"$",
"this",
"->",
"free",
"as",
"$",
"specUnit",
")",
"{",
"$",
"specUnit",
"->",
"apply",
"(",
"$",
"query",
")",
";",
"}",
"}"
] | @param Builder $query
@return void | [
"@param",
"Builder",
"$query"
] | train | https://github.com/intpro/extractor/blob/01aa06cd3d421896dc3e94a8715d5c33869be369/src/Selection/Specification/SpecificationSet.php#L46-L69 |
intpro/extractor | src/Selection/Specification/SpecificationSet.php | SpecificationSet.addUnit | public function addUnit(SpecificationUnit $specUnit, $or_union_name = null)
{
if($or_union_name === null)
{
$this->free[] = $specUnit;
}
else
{
$this->check_or_union($or_union_name);
$this->or_union[$or_union_name][] = $specUnit;
}
$this->fields_paths[] = $specUnit->getFieldName();
} | php | public function addUnit(SpecificationUnit $specUnit, $or_union_name = null)
{
if($or_union_name === null)
{
$this->free[] = $specUnit;
}
else
{
$this->check_or_union($or_union_name);
$this->or_union[$or_union_name][] = $specUnit;
}
$this->fields_paths[] = $specUnit->getFieldName();
} | [
"public",
"function",
"addUnit",
"(",
"SpecificationUnit",
"$",
"specUnit",
",",
"$",
"or_union_name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"or_union_name",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"free",
"[",
"]",
"=",
"$",
"specUnit",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"check_or_union",
"(",
"$",
"or_union_name",
")",
";",
"$",
"this",
"->",
"or_union",
"[",
"$",
"or_union_name",
"]",
"[",
"]",
"=",
"$",
"specUnit",
";",
"}",
"$",
"this",
"->",
"fields_paths",
"[",
"]",
"=",
"$",
"specUnit",
"->",
"getFieldName",
"(",
")",
";",
"}"
] | Сырой метод добавления spec.Unit
@param \Interpro\Extractor\Contracts\Selection\SpecificationUnit $specUnit
@param mixed $or_union_name
@return void | [
"Сырой",
"метод",
"добавления",
"spec",
".",
"Unit"
] | train | https://github.com/intpro/extractor/blob/01aa06cd3d421896dc3e94a8715d5c33869be369/src/Selection/Specification/SpecificationSet.php#L87-L101 |
jooaziz/Jlib | src/JModules/Pages/Controllers/Admin/PagesController.php | PagesController.store | public
function store(Validator $request)
{
$init = new InitData($request);
Model::quickSave($init->getDataForCreate());
flash()->success('Your Item Created');
return redirect()->to(self::getScope().'/'.self::getModule($this));
} | php | public
function store(Validator $request)
{
$init = new InitData($request);
Model::quickSave($init->getDataForCreate());
flash()->success('Your Item Created');
return redirect()->to(self::getScope().'/'.self::getModule($this));
} | [
"public",
"function",
"store",
"(",
"Validator",
"$",
"request",
")",
"{",
"$",
"init",
"=",
"new",
"InitData",
"(",
"$",
"request",
")",
";",
"Model",
"::",
"quickSave",
"(",
"$",
"init",
"->",
"getDataForCreate",
"(",
")",
")",
";",
"flash",
"(",
")",
"->",
"success",
"(",
"'Your Item Created'",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"to",
"(",
"self",
"::",
"getScope",
"(",
")",
".",
"'/'",
".",
"self",
"::",
"getModule",
"(",
"$",
"this",
")",
")",
";",
"}"
] | Store a newly created resource in storage.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"Store",
"a",
"newly",
"created",
"resource",
"in",
"storage",
"."
] | train | https://github.com/jooaziz/Jlib/blob/1060ab7964690da5ed0660bb4a6cbbd354778463/src/JModules/Pages/Controllers/Admin/PagesController.php#L43-L49 |
jooaziz/Jlib | src/JModules/Pages/Controllers/Admin/PagesController.php | PagesController.edit | public
function edit($id)
{
return $this->view(["row" => Model::findOrFail($id),'template'=>Template::pluck('title','id')->toArray()], "pages::admin.edit");
//
} | php | public
function edit($id)
{
return $this->view(["row" => Model::findOrFail($id),'template'=>Template::pluck('title','id')->toArray()], "pages::admin.edit");
//
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"view",
"(",
"[",
"\"row\"",
"=>",
"Model",
"::",
"findOrFail",
"(",
"$",
"id",
")",
",",
"'template'",
"=>",
"Template",
"::",
"pluck",
"(",
"'title'",
",",
"'id'",
")",
"->",
"toArray",
"(",
")",
"]",
",",
"\"pages::admin.edit\"",
")",
";",
"//",
"}"
] | Show the form for editing the specified resource.
@param int $id
@return \Illuminate\Http\Response | [
"Show",
"the",
"form",
"for",
"editing",
"the",
"specified",
"resource",
"."
] | train | https://github.com/jooaziz/Jlib/blob/1060ab7964690da5ed0660bb4a6cbbd354778463/src/JModules/Pages/Controllers/Admin/PagesController.php#L72-L76 |
jooaziz/Jlib | src/JModules/Pages/Controllers/Admin/PagesController.php | PagesController.update | public
function update(Validator $request)
{
$init = new InitData($request);
Model::quickUpdate($init->getDataForEdit());
flash()->success('Your Item Updated');
return redirect()->to(self::getScope().'/'.self::getModule($this));
} | php | public
function update(Validator $request)
{
$init = new InitData($request);
Model::quickUpdate($init->getDataForEdit());
flash()->success('Your Item Updated');
return redirect()->to(self::getScope().'/'.self::getModule($this));
} | [
"public",
"function",
"update",
"(",
"Validator",
"$",
"request",
")",
"{",
"$",
"init",
"=",
"new",
"InitData",
"(",
"$",
"request",
")",
";",
"Model",
"::",
"quickUpdate",
"(",
"$",
"init",
"->",
"getDataForEdit",
"(",
")",
")",
";",
"flash",
"(",
")",
"->",
"success",
"(",
"'Your Item Updated'",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"to",
"(",
"self",
"::",
"getScope",
"(",
")",
".",
"'/'",
".",
"self",
"::",
"getModule",
"(",
"$",
"this",
")",
")",
";",
"}"
] | Update the specified resource in storage.
@param \Illuminate\Http\Request $request
@param int $id
@return \Illuminate\Http\Response | [
"Update",
"the",
"specified",
"resource",
"in",
"storage",
"."
] | train | https://github.com/jooaziz/Jlib/blob/1060ab7964690da5ed0660bb4a6cbbd354778463/src/JModules/Pages/Controllers/Admin/PagesController.php#L86-L92 |
jooaziz/Jlib | src/JModules/Pages/Controllers/Admin/PagesController.php | PagesController.destory | public
function destory($id)
{
$row = Model::find($id);
$row->delete();
flash()->success('Your Item Deleted');
return redirect()->to(self::getScope().'/'.self::getModule($this));
} | php | public
function destory($id)
{
$row = Model::find($id);
$row->delete();
flash()->success('Your Item Deleted');
return redirect()->to(self::getScope().'/'.self::getModule($this));
} | [
"public",
"function",
"destory",
"(",
"$",
"id",
")",
"{",
"$",
"row",
"=",
"Model",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"row",
"->",
"delete",
"(",
")",
";",
"flash",
"(",
")",
"->",
"success",
"(",
"'Your Item Deleted'",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"to",
"(",
"self",
"::",
"getScope",
"(",
")",
".",
"'/'",
".",
"self",
"::",
"getModule",
"(",
"$",
"this",
")",
")",
";",
"}"
] | Update the specified resource in storage.
@param \Illuminate\Http\Request $request
@param int $id
@return \Illuminate\Http\Response | [
"Update",
"the",
"specified",
"resource",
"in",
"storage",
"."
] | train | https://github.com/jooaziz/Jlib/blob/1060ab7964690da5ed0660bb4a6cbbd354778463/src/JModules/Pages/Controllers/Admin/PagesController.php#L102-L108 |
jyggen/cs | src/GrumPHP.php | GrumPHP.load | public function load(ContainerBuilder $container): void
{
$tasks = (array) $container->getParameter('tasks');
$tasks = \array_replace_recursive(self::DEFAULTS, $tasks);
\ksort($tasks); // Run tasks in alphabetical order.
$container->setParameter('tasks', $tasks);
$container->setParameter('ascii', [
'failed' => null,
'succeeded' => null,
]);
} | php | public function load(ContainerBuilder $container): void
{
$tasks = (array) $container->getParameter('tasks');
$tasks = \array_replace_recursive(self::DEFAULTS, $tasks);
\ksort($tasks); // Run tasks in alphabetical order.
$container->setParameter('tasks', $tasks);
$container->setParameter('ascii', [
'failed' => null,
'succeeded' => null,
]);
} | [
"public",
"function",
"load",
"(",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"$",
"tasks",
"=",
"(",
"array",
")",
"$",
"container",
"->",
"getParameter",
"(",
"'tasks'",
")",
";",
"$",
"tasks",
"=",
"\\",
"array_replace_recursive",
"(",
"self",
"::",
"DEFAULTS",
",",
"$",
"tasks",
")",
";",
"\\",
"ksort",
"(",
"$",
"tasks",
")",
";",
"// Run tasks in alphabetical order.",
"$",
"container",
"->",
"setParameter",
"(",
"'tasks'",
",",
"$",
"tasks",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'ascii'",
",",
"[",
"'failed'",
"=>",
"null",
",",
"'succeeded'",
"=>",
"null",
",",
"]",
")",
";",
"}"
] | {@inheritdoc}
@throws InvalidArgumentException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/jyggen/cs/blob/faf9c29563876eb9dabf20eb594ad838fad59cdc/src/GrumPHP.php#L89-L101 |
jenskooij/cloudcontrol | src/storage/storage/BricksStorage.php | BricksStorage.addBrick | public function addBrick($postValues)
{
$brickObject = BrickFactory::createBrickFromPostValues($postValues);
$bricks = $this->repository->bricks;
$bricks[] = $brickObject;
$this->repository->bricks = $bricks;
$this->save();
} | php | public function addBrick($postValues)
{
$brickObject = BrickFactory::createBrickFromPostValues($postValues);
$bricks = $this->repository->bricks;
$bricks[] = $brickObject;
$this->repository->bricks = $bricks;
$this->save();
} | [
"public",
"function",
"addBrick",
"(",
"$",
"postValues",
")",
"{",
"$",
"brickObject",
"=",
"BrickFactory",
"::",
"createBrickFromPostValues",
"(",
"$",
"postValues",
")",
";",
"$",
"bricks",
"=",
"$",
"this",
"->",
"repository",
"->",
"bricks",
";",
"$",
"bricks",
"[",
"]",
"=",
"$",
"brickObject",
";",
"$",
"this",
"->",
"repository",
"->",
"bricks",
"=",
"$",
"bricks",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Add a brick
@param $postValues
@throws \Exception | [
"Add",
"a",
"brick"
] | train | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/storage/BricksStorage.php#L28-L37 |
jenskooij/cloudcontrol | src/storage/storage/BricksStorage.php | BricksStorage.getBrickBySlug | public function getBrickBySlug($slug)
{
$bricks = $this->repository->bricks;
foreach ($bricks as $brick) {
if ($brick->slug == $slug) {
return $brick;
}
}
return null;
} | php | public function getBrickBySlug($slug)
{
$bricks = $this->repository->bricks;
foreach ($bricks as $brick) {
if ($brick->slug == $slug) {
return $brick;
}
}
return null;
} | [
"public",
"function",
"getBrickBySlug",
"(",
"$",
"slug",
")",
"{",
"$",
"bricks",
"=",
"$",
"this",
"->",
"repository",
"->",
"bricks",
";",
"foreach",
"(",
"$",
"bricks",
"as",
"$",
"brick",
")",
"{",
"if",
"(",
"$",
"brick",
"->",
"slug",
"==",
"$",
"slug",
")",
"{",
"return",
"$",
"brick",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Get a brick by its slug
@param $slug
@return \stdClass | [
"Get",
"a",
"brick",
"by",
"its",
"slug"
] | train | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/storage/BricksStorage.php#L46-L56 |
jenskooij/cloudcontrol | src/storage/storage/BricksStorage.php | BricksStorage.saveBrick | public function saveBrick($slug, $postValues)
{
$brickObject = BrickFactory::createBrickFromPostValues($postValues);
$bricks = $this->repository->bricks;
foreach ($bricks as $key => $brick) {
if ($brick->slug == $slug) {
$bricks[$key] = $brickObject;
}
}
$this->repository->bricks = $bricks;
$this->save();
} | php | public function saveBrick($slug, $postValues)
{
$brickObject = BrickFactory::createBrickFromPostValues($postValues);
$bricks = $this->repository->bricks;
foreach ($bricks as $key => $brick) {
if ($brick->slug == $slug) {
$bricks[$key] = $brickObject;
}
}
$this->repository->bricks = $bricks;
$this->save();
} | [
"public",
"function",
"saveBrick",
"(",
"$",
"slug",
",",
"$",
"postValues",
")",
"{",
"$",
"brickObject",
"=",
"BrickFactory",
"::",
"createBrickFromPostValues",
"(",
"$",
"postValues",
")",
";",
"$",
"bricks",
"=",
"$",
"this",
"->",
"repository",
"->",
"bricks",
";",
"foreach",
"(",
"$",
"bricks",
"as",
"$",
"key",
"=>",
"$",
"brick",
")",
"{",
"if",
"(",
"$",
"brick",
"->",
"slug",
"==",
"$",
"slug",
")",
"{",
"$",
"bricks",
"[",
"$",
"key",
"]",
"=",
"$",
"brickObject",
";",
"}",
"}",
"$",
"this",
"->",
"repository",
"->",
"bricks",
"=",
"$",
"bricks",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Save changes to a brick
@param $slug
@param $postValues
@throws \Exception | [
"Save",
"changes",
"to",
"a",
"brick"
] | train | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/storage/BricksStorage.php#L66-L78 |
jenskooij/cloudcontrol | src/storage/storage/BricksStorage.php | BricksStorage.deleteBrickBySlug | public function deleteBrickBySlug($slug)
{
$bricks = $this->repository->bricks;
foreach ($bricks as $key => $brickObject) {
if ($brickObject->slug == $slug) {
unset($bricks[$key]);
}
}
$bricks = array_values($bricks);
$this->repository->bricks = $bricks;
$this->save();
} | php | public function deleteBrickBySlug($slug)
{
$bricks = $this->repository->bricks;
foreach ($bricks as $key => $brickObject) {
if ($brickObject->slug == $slug) {
unset($bricks[$key]);
}
}
$bricks = array_values($bricks);
$this->repository->bricks = $bricks;
$this->save();
} | [
"public",
"function",
"deleteBrickBySlug",
"(",
"$",
"slug",
")",
"{",
"$",
"bricks",
"=",
"$",
"this",
"->",
"repository",
"->",
"bricks",
";",
"foreach",
"(",
"$",
"bricks",
"as",
"$",
"key",
"=>",
"$",
"brickObject",
")",
"{",
"if",
"(",
"$",
"brickObject",
"->",
"slug",
"==",
"$",
"slug",
")",
"{",
"unset",
"(",
"$",
"bricks",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"bricks",
"=",
"array_values",
"(",
"$",
"bricks",
")",
";",
"$",
"this",
"->",
"repository",
"->",
"bricks",
"=",
"$",
"bricks",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] | Delete a brick by its slug
@param $slug
@throws \Exception | [
"Delete",
"a",
"brick",
"by",
"its",
"slug"
] | train | https://github.com/jenskooij/cloudcontrol/blob/76e5d9ac8f9c50d06d39a995d13cc03742536548/src/storage/storage/BricksStorage.php#L87-L99 |
fond-of/spryker-product-list-customer | src/FondOfSpryker/Zed/ProductListCustomer/Communication/Plugin/ProductListCustomerRelationPostSaverPlugin.php | ProductListCustomerRelationPostSaverPlugin.postSave | public function postSave(ProductListTransfer $productListTransfer): ProductListTransfer
{
$productListCustomerRelationTransfer = $productListTransfer->getProductListCustomerRelation();
if (!$productListCustomerRelationTransfer) {
return $productListTransfer;
}
$productListTransfer = $this->saveProductListCustomerRelation(
$productListTransfer,
$productListCustomerRelationTransfer
);
return $productListTransfer;
} | php | public function postSave(ProductListTransfer $productListTransfer): ProductListTransfer
{
$productListCustomerRelationTransfer = $productListTransfer->getProductListCustomerRelation();
if (!$productListCustomerRelationTransfer) {
return $productListTransfer;
}
$productListTransfer = $this->saveProductListCustomerRelation(
$productListTransfer,
$productListCustomerRelationTransfer
);
return $productListTransfer;
} | [
"public",
"function",
"postSave",
"(",
"ProductListTransfer",
"$",
"productListTransfer",
")",
":",
"ProductListTransfer",
"{",
"$",
"productListCustomerRelationTransfer",
"=",
"$",
"productListTransfer",
"->",
"getProductListCustomerRelation",
"(",
")",
";",
"if",
"(",
"!",
"$",
"productListCustomerRelationTransfer",
")",
"{",
"return",
"$",
"productListTransfer",
";",
"}",
"$",
"productListTransfer",
"=",
"$",
"this",
"->",
"saveProductListCustomerRelation",
"(",
"$",
"productListTransfer",
",",
"$",
"productListCustomerRelationTransfer",
")",
";",
"return",
"$",
"productListTransfer",
";",
"}"
] | @param \Generated\Shared\Transfer\ProductListTransfer $productListTransfer
@return \Generated\Shared\Transfer\ProductListTransfer | [
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"ProductListTransfer",
"$productListTransfer"
] | train | https://github.com/fond-of/spryker-product-list-customer/blob/ffedeaed9dd614a98541245e3458490dd0d0fa73/src/FondOfSpryker/Zed/ProductListCustomer/Communication/Plugin/ProductListCustomerRelationPostSaverPlugin.php#L20-L34 |
fond-of/spryker-product-list-customer | src/FondOfSpryker/Zed/ProductListCustomer/Communication/Plugin/ProductListCustomerRelationPostSaverPlugin.php | ProductListCustomerRelationPostSaverPlugin.saveProductListCustomerRelation | protected function saveProductListCustomerRelation(
ProductListTransfer $productListTransfer,
ProductListCustomerRelationTransfer $productListCustomerRelationTransfer
): ProductListTransfer {
$productListCustomerRelationTransfer->setIdProductList($productListTransfer->getIdProductList());
$productListCustomerRelationTransfer = $this->getFacade()
->saveProductListCustomerRelation($productListCustomerRelationTransfer);
$productListTransfer->setProductListCustomerRelation($productListCustomerRelationTransfer);
return $productListTransfer;
} | php | protected function saveProductListCustomerRelation(
ProductListTransfer $productListTransfer,
ProductListCustomerRelationTransfer $productListCustomerRelationTransfer
): ProductListTransfer {
$productListCustomerRelationTransfer->setIdProductList($productListTransfer->getIdProductList());
$productListCustomerRelationTransfer = $this->getFacade()
->saveProductListCustomerRelation($productListCustomerRelationTransfer);
$productListTransfer->setProductListCustomerRelation($productListCustomerRelationTransfer);
return $productListTransfer;
} | [
"protected",
"function",
"saveProductListCustomerRelation",
"(",
"ProductListTransfer",
"$",
"productListTransfer",
",",
"ProductListCustomerRelationTransfer",
"$",
"productListCustomerRelationTransfer",
")",
":",
"ProductListTransfer",
"{",
"$",
"productListCustomerRelationTransfer",
"->",
"setIdProductList",
"(",
"$",
"productListTransfer",
"->",
"getIdProductList",
"(",
")",
")",
";",
"$",
"productListCustomerRelationTransfer",
"=",
"$",
"this",
"->",
"getFacade",
"(",
")",
"->",
"saveProductListCustomerRelation",
"(",
"$",
"productListCustomerRelationTransfer",
")",
";",
"$",
"productListTransfer",
"->",
"setProductListCustomerRelation",
"(",
"$",
"productListCustomerRelationTransfer",
")",
";",
"return",
"$",
"productListTransfer",
";",
"}"
] | @param \Generated\Shared\Transfer\ProductListTransfer $productListTransfer
@param \Generated\Shared\Transfer\ProductListCustomerRelationTransfer $productListCustomerRelationTransfer
@return \Generated\Shared\Transfer\ProductListTransfer | [
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"ProductListTransfer",
"$productListTransfer",
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"ProductListCustomerRelationTransfer",
"$productListCustomerRelationTransfer"
] | train | https://github.com/fond-of/spryker-product-list-customer/blob/ffedeaed9dd614a98541245e3458490dd0d0fa73/src/FondOfSpryker/Zed/ProductListCustomer/Communication/Plugin/ProductListCustomerRelationPostSaverPlugin.php#L42-L54 |
nemundo/core | src/Archive/ZipArchive.php | ZipArchive.addFilename | public function addFilename($filename)
{
$item = new ZipFileItem();
$item->orginalFilename = $filename;
$item->internalFilename = (new File($filename))->filename;
$this->fileItemList[] = $item;
return $this;
} | php | public function addFilename($filename)
{
$item = new ZipFileItem();
$item->orginalFilename = $filename;
$item->internalFilename = (new File($filename))->filename;
$this->fileItemList[] = $item;
return $this;
} | [
"public",
"function",
"addFilename",
"(",
"$",
"filename",
")",
"{",
"$",
"item",
"=",
"new",
"ZipFileItem",
"(",
")",
";",
"$",
"item",
"->",
"orginalFilename",
"=",
"$",
"filename",
";",
"$",
"item",
"->",
"internalFilename",
"=",
"(",
"new",
"File",
"(",
"$",
"filename",
")",
")",
"->",
"filename",
";",
"$",
"this",
"->",
"fileItemList",
"[",
"]",
"=",
"$",
"item",
";",
"return",
"$",
"this",
";",
"}"
] | /*public function addFile(File $file)
{
$this->addFilename($file->fullFilename);
return $this;
} | [
"/",
"*",
"public",
"function",
"addFile",
"(",
"File",
"$file",
")",
"{",
"$this",
"-",
">",
"addFilename",
"(",
"$file",
"-",
">",
"fullFilename",
")",
";",
"return",
"$this",
";",
"}"
] | train | https://github.com/nemundo/core/blob/5ca14889fdfb9155b52fedb364b34502d14e21ed/src/Archive/ZipArchive.php#L34-L44 |
nemundo/core | src/Archive/ZipArchive.php | ZipArchive.createArchiveInternal | private function createArchiveInternal($zipFilename)
{
$zip = new \ZipArchive;
if ($zip->open($zipFilename, \ZipArchive::CREATE) === TRUE) {
foreach ($this->fileItemList as $fileItem) {
$zip->addFile($fileItem->orginalFilename, $fileItem->internalFilename);
}
$zip->close();
} else {
(new LogMessage())->writeError('Failed to create Zip File');
}
} | php | private function createArchiveInternal($zipFilename)
{
$zip = new \ZipArchive;
if ($zip->open($zipFilename, \ZipArchive::CREATE) === TRUE) {
foreach ($this->fileItemList as $fileItem) {
$zip->addFile($fileItem->orginalFilename, $fileItem->internalFilename);
}
$zip->close();
} else {
(new LogMessage())->writeError('Failed to create Zip File');
}
} | [
"private",
"function",
"createArchiveInternal",
"(",
"$",
"zipFilename",
")",
"{",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
";",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"zipFilename",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
")",
"===",
"TRUE",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fileItemList",
"as",
"$",
"fileItem",
")",
"{",
"$",
"zip",
"->",
"addFile",
"(",
"$",
"fileItem",
"->",
"orginalFilename",
",",
"$",
"fileItem",
"->",
"internalFilename",
")",
";",
"}",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"}",
"else",
"{",
"(",
"new",
"LogMessage",
"(",
")",
")",
"->",
"writeError",
"(",
"'Failed to create Zip File'",
")",
";",
"}",
"}"
] | /*
auslagern nach ZipArchiveResponse/ZipResponse
public function sendToBrowser()
{
if ($this->zipFilename == null) {
$this->zipFilename = 'file.zip';
}
$tmpFilename = ProjectConfig::$tmpPath . $this->zipFilename;
$this->createArchiveInternal($tmpFilename);
$response = new FileResponse();
$response->filename = $tmpFilename;
$response->sendResponse();
$file = new File($tmpFilename);
$file->deleteFile();
} | [
"/",
"*",
"auslagern",
"nach",
"ZipArchiveResponse",
"/",
"ZipResponse",
"public",
"function",
"sendToBrowser",
"()",
"{"
] | train | https://github.com/nemundo/core/blob/5ca14889fdfb9155b52fedb364b34502d14e21ed/src/Archive/ZipArchive.php#L116-L133 |
pluf/geo | src/Geo/Views/LocationTag.php | Geo_Views_LocationTag.tags | public function tags ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
// Pluf pagination
$pag = new Pluf_Paginator(new SaaSKM_Tag());
$pag->model_view = 'join_row';
$pag->forced_where = new Pluf_SQL(
'saaskm_tag.tenant=%s AND owner_class=%s AND owner_id=%s',
array(
$request->tenant->id,
$location->_a['model'],
$location->id
));
$list_display = array(
'title' => __('location title'),
'description' => __('description')
);
$search_fields = array(
'name',
'description'
);
$sort_fields = array(
'creation_date',
'modif_dtime'
);
$pag->configure($list_display, $search_fields, $sort_fields);
$pag->sort_order = array(
'creation_dtime',
'DESC'
);
$pag->setFromRequest($request);
return new Pluf_HTTP_Response_Json($pag->render_object());
} | php | public function tags ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
// Pluf pagination
$pag = new Pluf_Paginator(new SaaSKM_Tag());
$pag->model_view = 'join_row';
$pag->forced_where = new Pluf_SQL(
'saaskm_tag.tenant=%s AND owner_class=%s AND owner_id=%s',
array(
$request->tenant->id,
$location->_a['model'],
$location->id
));
$list_display = array(
'title' => __('location title'),
'description' => __('description')
);
$search_fields = array(
'name',
'description'
);
$sort_fields = array(
'creation_date',
'modif_dtime'
);
$pag->configure($list_display, $search_fields, $sort_fields);
$pag->sort_order = array(
'creation_dtime',
'DESC'
);
$pag->setFromRequest($request);
return new Pluf_HTTP_Response_Json($pag->render_object());
} | [
"public",
"function",
"tags",
"(",
"$",
"request",
",",
"$",
"match",
")",
"{",
"$",
"location",
"=",
"Geo_Shortcuts_GetLocationOr404",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"Geo_Precondition",
"::",
"canEditLocation",
"(",
"$",
"request",
",",
"$",
"location",
")",
";",
"// Pluf pagination",
"$",
"pag",
"=",
"new",
"Pluf_Paginator",
"(",
"new",
"SaaSKM_Tag",
"(",
")",
")",
";",
"$",
"pag",
"->",
"model_view",
"=",
"'join_row'",
";",
"$",
"pag",
"->",
"forced_where",
"=",
"new",
"Pluf_SQL",
"(",
"'saaskm_tag.tenant=%s AND owner_class=%s AND owner_id=%s'",
",",
"array",
"(",
"$",
"request",
"->",
"tenant",
"->",
"id",
",",
"$",
"location",
"->",
"_a",
"[",
"'model'",
"]",
",",
"$",
"location",
"->",
"id",
")",
")",
";",
"$",
"list_display",
"=",
"array",
"(",
"'title'",
"=>",
"__",
"(",
"'location title'",
")",
",",
"'description'",
"=>",
"__",
"(",
"'description'",
")",
")",
";",
"$",
"search_fields",
"=",
"array",
"(",
"'name'",
",",
"'description'",
")",
";",
"$",
"sort_fields",
"=",
"array",
"(",
"'creation_date'",
",",
"'modif_dtime'",
")",
";",
"$",
"pag",
"->",
"configure",
"(",
"$",
"list_display",
",",
"$",
"search_fields",
",",
"$",
"sort_fields",
")",
";",
"$",
"pag",
"->",
"sort_order",
"=",
"array",
"(",
"'creation_dtime'",
",",
"'DESC'",
")",
";",
"$",
"pag",
"->",
"setFromRequest",
"(",
"$",
"request",
")",
";",
"return",
"new",
"Pluf_HTTP_Response_Json",
"(",
"$",
"pag",
"->",
"render_object",
"(",
")",
")",
";",
"}"
] | فهرست برچسبهایی را تعیین میکند که به یک مگان داده شده است.
@param unknown $request
@param unknown $match
@return Pluf_HTTP_Response_Json | [
"فهرست",
"برچسبهایی",
"را",
"تعیین",
"میکند",
"که",
"به",
"یک",
"مگان",
"داده",
"شده",
"است",
"."
] | train | https://github.com/pluf/geo/blob/53413e06627d12ab0e4239eeb72a7a146c4fb820/src/Geo/Views/LocationTag.php#L32-L65 |
pluf/geo | src/Geo/Views/LocationTag.php | Geo_Views_LocationTag.addTag | public function addTag ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Shortcuts_GetTagOr404($match[2]);
SaaSKM_Precondition::userCanAccessTag($request, $tag);
SaaSKM_TagRow::add($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | php | public function addTag ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Shortcuts_GetTagOr404($match[2]);
SaaSKM_Precondition::userCanAccessTag($request, $tag);
SaaSKM_TagRow::add($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | [
"public",
"function",
"addTag",
"(",
"$",
"request",
",",
"$",
"match",
")",
"{",
"$",
"location",
"=",
"Geo_Shortcuts_GetLocationOr404",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"Geo_Precondition",
"::",
"canEditLocation",
"(",
"$",
"request",
",",
"$",
"location",
")",
";",
"$",
"tag",
"=",
"SaaSKM_Shortcuts_GetTagOr404",
"(",
"$",
"match",
"[",
"2",
"]",
")",
";",
"SaaSKM_Precondition",
"::",
"userCanAccessTag",
"(",
"$",
"request",
",",
"$",
"tag",
")",
";",
"SaaSKM_TagRow",
"::",
"add",
"(",
"$",
"request",
"->",
"tenant",
",",
"$",
"location",
",",
"$",
"tag",
")",
";",
"return",
"new",
"Pluf_HTTP_Response_Json",
"(",
"$",
"location",
")",
";",
"}"
] | یک تگ به مکان اضافه میکند
@param unknown $request
@param unknown $match
@return Pluf_HTTP_Response_Json | [
"یک",
"تگ",
"به",
"مکان",
"اضافه",
"میکند"
] | train | https://github.com/pluf/geo/blob/53413e06627d12ab0e4239eeb72a7a146c4fb820/src/Geo/Views/LocationTag.php#L74-L82 |
pluf/geo | src/Geo/Views/LocationTag.php | Geo_Views_LocationTag.deleteTag | public function deleteTag ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Shortcuts_GetTagOr404($match[2]);
SaaSKM_TagRow::remove($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | php | public function deleteTag ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Shortcuts_GetTagOr404($match[2]);
SaaSKM_TagRow::remove($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | [
"public",
"function",
"deleteTag",
"(",
"$",
"request",
",",
"$",
"match",
")",
"{",
"$",
"location",
"=",
"Geo_Shortcuts_GetLocationOr404",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"Geo_Precondition",
"::",
"canEditLocation",
"(",
"$",
"request",
",",
"$",
"location",
")",
";",
"$",
"tag",
"=",
"SaaSKM_Shortcuts_GetTagOr404",
"(",
"$",
"match",
"[",
"2",
"]",
")",
";",
"SaaSKM_TagRow",
"::",
"remove",
"(",
"$",
"request",
"->",
"tenant",
",",
"$",
"location",
",",
"$",
"tag",
")",
";",
"return",
"new",
"Pluf_HTTP_Response_Json",
"(",
"$",
"location",
")",
";",
"}"
] | یک تگ را از مکان حذف میکند
@param unknown $request
@param unknown $match | [
"یک",
"تگ",
"را",
"از",
"مکان",
"حذف",
"میکند"
] | train | https://github.com/pluf/geo/blob/53413e06627d12ab0e4239eeb72a7a146c4fb820/src/Geo/Views/LocationTag.php#L90-L97 |
pluf/geo | src/Geo/Views/LocationTag.php | Geo_Views_LocationTag.addTagBykeyvalue | public function addTagBykeyvalue ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Tag::getFromString($request->tenant, $request->REQUEST['tag']);
if(! $tag){
throw new Pluf_Exception("Tag not found");
}
SaaSKM_Precondition::userCanAccessTag($request, $tag);
SaaSKM_TagRow::add($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | php | public function addTagBykeyvalue ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Tag::getFromString($request->tenant, $request->REQUEST['tag']);
if(! $tag){
throw new Pluf_Exception("Tag not found");
}
SaaSKM_Precondition::userCanAccessTag($request, $tag);
SaaSKM_TagRow::add($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | [
"public",
"function",
"addTagBykeyvalue",
"(",
"$",
"request",
",",
"$",
"match",
")",
"{",
"$",
"location",
"=",
"Geo_Shortcuts_GetLocationOr404",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"Geo_Precondition",
"::",
"canEditLocation",
"(",
"$",
"request",
",",
"$",
"location",
")",
";",
"$",
"tag",
"=",
"SaaSKM_Tag",
"::",
"getFromString",
"(",
"$",
"request",
"->",
"tenant",
",",
"$",
"request",
"->",
"REQUEST",
"[",
"'tag'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"tag",
")",
"{",
"throw",
"new",
"Pluf_Exception",
"(",
"\"Tag not found\"",
")",
";",
"}",
"SaaSKM_Precondition",
"::",
"userCanAccessTag",
"(",
"$",
"request",
",",
"$",
"tag",
")",
";",
"SaaSKM_TagRow",
"::",
"add",
"(",
"$",
"request",
"->",
"tenant",
",",
"$",
"location",
",",
"$",
"tag",
")",
";",
"return",
"new",
"Pluf_HTTP_Response_Json",
"(",
"$",
"location",
")",
";",
"}"
] | یک تگ را به مکان اضافه میکند
در این روش تگ با استفاده از کلدی و مقدار تعیین مسشود.
@param unknown $request
@param unknown $match
@return Pluf_HTTP_Response_Json | [
"یک",
"تگ",
"را",
"به",
"مکان",
"اضافه",
"میکند"
] | train | https://github.com/pluf/geo/blob/53413e06627d12ab0e4239eeb72a7a146c4fb820/src/Geo/Views/LocationTag.php#L108-L119 |
pluf/geo | src/Geo/Views/LocationTag.php | Geo_Views_LocationTag.deleteTagBykeyvalue | public function deleteTagBykeyvalue ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Tag::getFromString($request->tenant, $request->REQUEST['tag']);
if(! $tag){
throw new Pluf_Exception("Tag not found");
}
// XXX: maso, 1394: بررسی وجود برچسب
SaaSKM_TagRow::remove($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | php | public function deleteTagBykeyvalue ($request, $match)
{
$location = Geo_Shortcuts_GetLocationOr404($match[1]);
Geo_Precondition::canEditLocation($request, $location);
$tag = SaaSKM_Tag::getFromString($request->tenant, $request->REQUEST['tag']);
if(! $tag){
throw new Pluf_Exception("Tag not found");
}
// XXX: maso, 1394: بررسی وجود برچسب
SaaSKM_TagRow::remove($request->tenant, $location, $tag);
return new Pluf_HTTP_Response_Json($location);
} | [
"public",
"function",
"deleteTagBykeyvalue",
"(",
"$",
"request",
",",
"$",
"match",
")",
"{",
"$",
"location",
"=",
"Geo_Shortcuts_GetLocationOr404",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"Geo_Precondition",
"::",
"canEditLocation",
"(",
"$",
"request",
",",
"$",
"location",
")",
";",
"$",
"tag",
"=",
"SaaSKM_Tag",
"::",
"getFromString",
"(",
"$",
"request",
"->",
"tenant",
",",
"$",
"request",
"->",
"REQUEST",
"[",
"'tag'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"tag",
")",
"{",
"throw",
"new",
"Pluf_Exception",
"(",
"\"Tag not found\"",
")",
";",
"}",
"// XXX: maso, 1394: بررسی وجود برچسب",
"SaaSKM_TagRow",
"::",
"remove",
"(",
"$",
"request",
"->",
"tenant",
",",
"$",
"location",
",",
"$",
"tag",
")",
";",
"return",
"new",
"Pluf_HTTP_Response_Json",
"(",
"$",
"location",
")",
";",
"}"
] | یک تگ را از یک مکان حذف میکند.
@param unknown $request
@param unknown $match
@return Pluf_HTTP_Response_Json | [
"یک",
"تگ",
"را",
"از",
"یک",
"مکان",
"حذف",
"میکند",
"."
] | train | https://github.com/pluf/geo/blob/53413e06627d12ab0e4239eeb72a7a146c4fb820/src/Geo/Views/LocationTag.php#L128-L139 |
PenoaksDev/Milky-Framework | src/Milky/Queue/QueueClosure.php | QueueClosure.fire | public function fire( $job, $data )
{
$closure = unserialize( $this->crypt->decrypt( $data['closure'] ) );
$closure( $job );
} | php | public function fire( $job, $data )
{
$closure = unserialize( $this->crypt->decrypt( $data['closure'] ) );
$closure( $job );
} | [
"public",
"function",
"fire",
"(",
"$",
"job",
",",
"$",
"data",
")",
"{",
"$",
"closure",
"=",
"unserialize",
"(",
"$",
"this",
"->",
"crypt",
"->",
"decrypt",
"(",
"$",
"data",
"[",
"'closure'",
"]",
")",
")",
";",
"$",
"closure",
"(",
"$",
"job",
")",
";",
"}"
] | Fire the Closure based queue job.
@param Job $job
@param array $data
@return void | [
"Fire",
"the",
"Closure",
"based",
"queue",
"job",
"."
] | train | https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Queue/QueueClosure.php#L33-L38 |
pipaslot/forms | src/Forms/Latte/Runtime.php | Runtime.renderFormBegin | public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE)
{
$renderer = $form->getRenderer();
if ($renderer instanceof IManualRenderer) {
$renderer->beforeRender($form);
}
return parent::renderFormBegin($form, $attrs, $withTags);
} | php | public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE)
{
$renderer = $form->getRenderer();
if ($renderer instanceof IManualRenderer) {
$renderer->beforeRender($form);
}
return parent::renderFormBegin($form, $attrs, $withTags);
} | [
"public",
"static",
"function",
"renderFormBegin",
"(",
"Form",
"$",
"form",
",",
"array",
"$",
"attrs",
",",
"$",
"withTags",
"=",
"TRUE",
")",
"{",
"$",
"renderer",
"=",
"$",
"form",
"->",
"getRenderer",
"(",
")",
";",
"if",
"(",
"$",
"renderer",
"instanceof",
"IManualRenderer",
")",
"{",
"$",
"renderer",
"->",
"beforeRender",
"(",
"$",
"form",
")",
";",
"}",
"return",
"parent",
"::",
"renderFormBegin",
"(",
"$",
"form",
",",
"$",
"attrs",
",",
"$",
"withTags",
")",
";",
"}"
] | Renders form begin.
@param Form $form
@param array $attrs
@param bool $withTags
@return string | [
"Renders",
"form",
"begin",
"."
] | train | https://github.com/pipaslot/forms/blob/9e1d48db512f843270fd4079ed3ff1b1729c951b/src/Forms/Latte/Runtime.php#L23-L30 |
miaoxing/plugin | src/Service/AppRecord.php | AppRecord.isExists | public function isExists($name)
{
// 忽略非数字和字母组成的项目名称
if (!ctype_alnum($name)) {
return false;
}
if (in_array($name, $this->predefinedNames)) {
return true;
}
return $this->cache->get('appExists' . $name, 86400, function () use ($name) {
$app = wei()->appRecord()->select('name')->fetch(['name' => $name]);
return $app && $app['name'] === $name;
});
} | php | public function isExists($name)
{
// 忽略非数字和字母组成的项目名称
if (!ctype_alnum($name)) {
return false;
}
if (in_array($name, $this->predefinedNames)) {
return true;
}
return $this->cache->get('appExists' . $name, 86400, function () use ($name) {
$app = wei()->appRecord()->select('name')->fetch(['name' => $name]);
return $app && $app['name'] === $name;
});
} | [
"public",
"function",
"isExists",
"(",
"$",
"name",
")",
"{",
"// 忽略非数字和字母组成的项目名称",
"if",
"(",
"!",
"ctype_alnum",
"(",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"predefinedNames",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"'appExists'",
".",
"$",
"name",
",",
"86400",
",",
"function",
"(",
")",
"use",
"(",
"$",
"name",
")",
"{",
"$",
"app",
"=",
"wei",
"(",
")",
"->",
"appRecord",
"(",
")",
"->",
"select",
"(",
"'name'",
")",
"->",
"fetch",
"(",
"[",
"'name'",
"=>",
"$",
"name",
"]",
")",
";",
"return",
"$",
"app",
"&&",
"$",
"app",
"[",
"'name'",
"]",
"===",
"$",
"name",
";",
"}",
")",
";",
"}"
] | Repo: 根据名称判断应用是否存在
@param string $name
@return bool | [
"Repo",
":",
"根据名称判断应用是否存在"
] | train | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/AppRecord.php#L59-L75 |
miaoxing/plugin | src/Service/AppRecord.php | AppRecord.getIdByDomain | public function getIdByDomain($domain)
{
return $this->cache->get('appDomain' . $domain, 86400, function () use ($domain) {
$app = wei()->appRecord()->select('name')->fetch(['domain' => $domain]);
return $app ? $app['name'] : false;
});
} | php | public function getIdByDomain($domain)
{
return $this->cache->get('appDomain' . $domain, 86400, function () use ($domain) {
$app = wei()->appRecord()->select('name')->fetch(['domain' => $domain]);
return $app ? $app['name'] : false;
});
} | [
"public",
"function",
"getIdByDomain",
"(",
"$",
"domain",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"'appDomain'",
".",
"$",
"domain",
",",
"86400",
",",
"function",
"(",
")",
"use",
"(",
"$",
"domain",
")",
"{",
"$",
"app",
"=",
"wei",
"(",
")",
"->",
"appRecord",
"(",
")",
"->",
"select",
"(",
"'name'",
")",
"->",
"fetch",
"(",
"[",
"'domain'",
"=>",
"$",
"domain",
"]",
")",
";",
"return",
"$",
"app",
"?",
"$",
"app",
"[",
"'name'",
"]",
":",
"false",
";",
"}",
")",
";",
"}"
] | Repo: 根据域名查找应用名称
@param string $domain
@return string|false | [
"Repo",
":",
"根据域名查找应用名称"
] | train | https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/AppRecord.php#L83-L90 |
LartTyler/PHP-DaybreakCommons | src/DaybreakStudios/Common/Collection/Collections.php | Collections.toMap | public static function toMap(array $array) {
$map = new SimpleMap();
foreach ($array as $k => $v)
$map->put($k, $v);
return $map;
} | php | public static function toMap(array $array) {
$map = new SimpleMap();
foreach ($array as $k => $v)
$map->put($k, $v);
return $map;
} | [
"public",
"static",
"function",
"toMap",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"map",
"=",
"new",
"SimpleMap",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"$",
"map",
"->",
"put",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"return",
"$",
"map",
";",
"}"
] | Converts a PHP array into a Map.
@see SimpleMap
@param array $array the array to convert
@return Map the map built from the PHP array | [
"Converts",
"a",
"PHP",
"array",
"into",
"a",
"Map",
"."
] | train | https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Collection/Collections.php#L17-L24 |
nathan818fr/phpuc-io-streams | src/InputStream.php | InputStream.skip | public function skip(int $n) : int
{
if ($n <= 0) {
return 0;
}
$skipped = 0;
$skipLimit = min(self::MAX_SKIP_BUFFER_SIZE, $n);
while ($skipped < $n) {
$buf = $this->read(min($skipLimit, $n - $skipped));
if ($buf === null) {
break;
}
$skipped += strlen($buf);
}
return $skipped;
} | php | public function skip(int $n) : int
{
if ($n <= 0) {
return 0;
}
$skipped = 0;
$skipLimit = min(self::MAX_SKIP_BUFFER_SIZE, $n);
while ($skipped < $n) {
$buf = $this->read(min($skipLimit, $n - $skipped));
if ($buf === null) {
break;
}
$skipped += strlen($buf);
}
return $skipped;
} | [
"public",
"function",
"skip",
"(",
"int",
"$",
"n",
")",
":",
"int",
"{",
"if",
"(",
"$",
"n",
"<=",
"0",
")",
"{",
"return",
"0",
";",
"}",
"$",
"skipped",
"=",
"0",
";",
"$",
"skipLimit",
"=",
"min",
"(",
"self",
"::",
"MAX_SKIP_BUFFER_SIZE",
",",
"$",
"n",
")",
";",
"while",
"(",
"$",
"skipped",
"<",
"$",
"n",
")",
"{",
"$",
"buf",
"=",
"$",
"this",
"->",
"read",
"(",
"min",
"(",
"$",
"skipLimit",
",",
"$",
"n",
"-",
"$",
"skipped",
")",
")",
";",
"if",
"(",
"$",
"buf",
"===",
"null",
")",
"{",
"break",
";",
"}",
"$",
"skipped",
"+=",
"strlen",
"(",
"$",
"buf",
")",
";",
"}",
"return",
"$",
"skipped",
";",
"}"
] | Skips over and discards n bytes of data from this input stream.
@param int $n the number of bytes to be skipped
@return int the actual number of bytes skipped
@throws IOException | [
"Skips",
"over",
"and",
"discards",
"n",
"bytes",
"of",
"data",
"from",
"this",
"input",
"stream",
"."
] | train | https://github.com/nathan818fr/phpuc-io-streams/blob/8f748c1b3338b50e7c6e25a2f2ee73699cadb0ba/src/InputStream.php#L50-L66 |
Topolis/FunctionLibrary | src/Token.php | Token.uuid | public static function uuid($version = self::UUID_V4){
switch($version){
case self::UUID_V4:
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
default:
throw new Exception("Invalid or unknown uuid version specified");
}
} | php | public static function uuid($version = self::UUID_V4){
switch($version){
case self::UUID_V4:
$data = openssl_random_pseudo_bytes(16);
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0010
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
default:
throw new Exception("Invalid or unknown uuid version specified");
}
} | [
"public",
"static",
"function",
"uuid",
"(",
"$",
"version",
"=",
"self",
"::",
"UUID_V4",
")",
"{",
"switch",
"(",
"$",
"version",
")",
"{",
"case",
"self",
"::",
"UUID_V4",
":",
"$",
"data",
"=",
"openssl_random_pseudo_bytes",
"(",
"16",
")",
";",
"$",
"data",
"[",
"6",
"]",
"=",
"chr",
"(",
"ord",
"(",
"$",
"data",
"[",
"6",
"]",
")",
"&",
"0x0f",
"|",
"0x40",
")",
";",
"// set version to 0010",
"$",
"data",
"[",
"8",
"]",
"=",
"chr",
"(",
"ord",
"(",
"$",
"data",
"[",
"8",
"]",
")",
"&",
"0x3f",
"|",
"0x80",
")",
";",
"// set bits 6-7 to 10",
"return",
"vsprintf",
"(",
"'%s%s-%s-%s-%s-%s%s%s'",
",",
"str_split",
"(",
"bin2hex",
"(",
"$",
"data",
")",
",",
"4",
")",
")",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"\"Invalid or unknown uuid version specified\"",
")",
";",
"}",
"}"
] | Generate a uuid according to a specific UUID definition
@param integer $version format/version of UUID to generate
@throws \Exception
@return string | [
"Generate",
"a",
"uuid",
"according",
"to",
"a",
"specific",
"UUID",
"definition"
] | train | https://github.com/Topolis/FunctionLibrary/blob/bc57f465932fbf297927c2a32765255131b907eb/src/Token.php#L17-L31 |
CrunchPHP/fastcgi | src/Protocol/Request.php | Request.toRecords | public function toRecords()
{
$result = [new Record(new Header(RecordType::beginRequest(), $this->getRequestId(), 8), \pack('xCCxxxxx', $this->role->value(), 0xFF & ($this->keepConnection ? 1 : 0)))];
foreach ($this->getParameters()->encode($this->getRequestId()) as $value) {
$result[] = $value;
}
while ($chunk = $this->stdin->read(65535)) {
$result[] = new Record(new Header(RecordType::stdin(), $this->getRequestId(), strlen($chunk)), $chunk);
}
$result[] = new Record(new Header(RecordType::stdin(), $this->getRequestId(), 0, 0), '');
return new ArrayIterator($result);
} | php | public function toRecords()
{
$result = [new Record(new Header(RecordType::beginRequest(), $this->getRequestId(), 8), \pack('xCCxxxxx', $this->role->value(), 0xFF & ($this->keepConnection ? 1 : 0)))];
foreach ($this->getParameters()->encode($this->getRequestId()) as $value) {
$result[] = $value;
}
while ($chunk = $this->stdin->read(65535)) {
$result[] = new Record(new Header(RecordType::stdin(), $this->getRequestId(), strlen($chunk)), $chunk);
}
$result[] = new Record(new Header(RecordType::stdin(), $this->getRequestId(), 0, 0), '');
return new ArrayIterator($result);
} | [
"public",
"function",
"toRecords",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"new",
"Record",
"(",
"new",
"Header",
"(",
"RecordType",
"::",
"beginRequest",
"(",
")",
",",
"$",
"this",
"->",
"getRequestId",
"(",
")",
",",
"8",
")",
",",
"\\",
"pack",
"(",
"'xCCxxxxx'",
",",
"$",
"this",
"->",
"role",
"->",
"value",
"(",
")",
",",
"0xFF",
"&",
"(",
"$",
"this",
"->",
"keepConnection",
"?",
"1",
":",
"0",
")",
")",
")",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getParameters",
"(",
")",
"->",
"encode",
"(",
"$",
"this",
"->",
"getRequestId",
"(",
")",
")",
"as",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"while",
"(",
"$",
"chunk",
"=",
"$",
"this",
"->",
"stdin",
"->",
"read",
"(",
"65535",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"new",
"Record",
"(",
"new",
"Header",
"(",
"RecordType",
"::",
"stdin",
"(",
")",
",",
"$",
"this",
"->",
"getRequestId",
"(",
")",
",",
"strlen",
"(",
"$",
"chunk",
")",
")",
",",
"$",
"chunk",
")",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"new",
"Record",
"(",
"new",
"Header",
"(",
"RecordType",
"::",
"stdin",
"(",
")",
",",
"$",
"this",
"->",
"getRequestId",
"(",
")",
",",
"0",
",",
"0",
")",
",",
"''",
")",
";",
"return",
"new",
"ArrayIterator",
"(",
"$",
"result",
")",
";",
"}"
] | Encodes request into an traversable of records.
@return Traversable|Record[] | [
"Encodes",
"request",
"into",
"an",
"traversable",
"of",
"records",
"."
] | train | https://github.com/CrunchPHP/fastcgi/blob/102437193e67e5a841ec5a897549ec345788d1bd/src/Protocol/Request.php#L88-L103 |
Xsaven/laravel-intelect-admin | src/Addons/JWTAuth/JWTAuth.php | JWTAuth.toUser | public function toUser($token = false)
{
$payload = $this->getPayload($token);
if (! $user = $this->user->getBy($this->identifier, $payload['sub'])) {
return false;
}
return $user;
} | php | public function toUser($token = false)
{
$payload = $this->getPayload($token);
if (! $user = $this->user->getBy($this->identifier, $payload['sub'])) {
return false;
}
return $user;
} | [
"public",
"function",
"toUser",
"(",
"$",
"token",
"=",
"false",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"getPayload",
"(",
"$",
"token",
")",
";",
"if",
"(",
"!",
"$",
"user",
"=",
"$",
"this",
"->",
"user",
"->",
"getBy",
"(",
"$",
"this",
"->",
"identifier",
",",
"$",
"payload",
"[",
"'sub'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"user",
";",
"}"
] | Find a user using the user identifier in the subject claim.
@param bool|string $token
@return mixed | [
"Find",
"a",
"user",
"using",
"the",
"user",
"identifier",
"in",
"the",
"subject",
"claim",
"."
] | train | https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/JWTAuth.php#L63-L72 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.