repo stringclasses 21 values | path stringlengths 10 105 | func_name stringlengths 6 64 | original_string stringlengths 105 15.6k | language stringclasses 1 value | code stringlengths 105 15.6k | code_tokens listlengths 29 2.15k | docstring stringlengths 11 2.85k | docstring_tokens listlengths 1 290 | sha stringclasses 21 values | url stringlengths 100 194 | partition stringclasses 1 value | summary stringlengths 8 319 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dompdf/dompdf | lib/html5lib/TreeBuilder.php | HTML5_TreeBuilder.setupContext | public function setupContext($context = null) {
$this->fragment = true;
if ($context) {
$context = $this->dom->createElementNS(self::NS_HTML, $context);
/* 4.1. Set the HTML parser's tokenization stage's content model
* flag according to the context element, as follows: */
switch ($context->tagName) {
case 'title': case 'textarea':
$this->content_model = HTML5_Tokenizer::RCDATA;
break;
case 'style': case 'script': case 'xmp': case 'iframe':
case 'noembed': case 'noframes':
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'noscript':
// XSCRIPT: assuming scripting is enabled
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'plaintext':
$this->content_model = HTML5_Tokenizer::PLAINTEXT;
break;
}
/* 4.2. Let root be a new html element with no attributes. */
$root = $this->dom->createElementNS(self::NS_HTML, 'html');
$this->root = $root;
/* 4.3 Append the element root to the Document node created above. */
$this->dom->appendChild($root);
/* 4.4 Set up the parser's stack of open elements so that it
* contains just the single element root. */
$this->stack = array($root);
/* 4.5 Reset the parser's insertion mode appropriately. */
$this->resetInsertionMode($context);
/* 4.6 Set the parser's form element pointer to the nearest node
* to the context element that is a form element (going straight up
* the ancestor chain, and including the element itself, if it is a
* form element), or, if there is no such form element, to null. */
$node = $context;
do {
if ($node->tagName === 'form') {
$this->form_pointer = $node;
break;
}
} while ($node = $node->parentNode);
}
} | php | public function setupContext($context = null) {
$this->fragment = true;
if ($context) {
$context = $this->dom->createElementNS(self::NS_HTML, $context);
/* 4.1. Set the HTML parser's tokenization stage's content model
* flag according to the context element, as follows: */
switch ($context->tagName) {
case 'title': case 'textarea':
$this->content_model = HTML5_Tokenizer::RCDATA;
break;
case 'style': case 'script': case 'xmp': case 'iframe':
case 'noembed': case 'noframes':
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'noscript':
// XSCRIPT: assuming scripting is enabled
$this->content_model = HTML5_Tokenizer::CDATA;
break;
case 'plaintext':
$this->content_model = HTML5_Tokenizer::PLAINTEXT;
break;
}
/* 4.2. Let root be a new html element with no attributes. */
$root = $this->dom->createElementNS(self::NS_HTML, 'html');
$this->root = $root;
/* 4.3 Append the element root to the Document node created above. */
$this->dom->appendChild($root);
/* 4.4 Set up the parser's stack of open elements so that it
* contains just the single element root. */
$this->stack = array($root);
/* 4.5 Reset the parser's insertion mode appropriately. */
$this->resetInsertionMode($context);
/* 4.6 Set the parser's form element pointer to the nearest node
* to the context element that is a form element (going straight up
* the ancestor chain, and including the element itself, if it is a
* form element), or, if there is no such form element, to null. */
$node = $context;
do {
if ($node->tagName === 'form') {
$this->form_pointer = $node;
break;
}
} while ($node = $node->parentNode);
}
} | [
"public",
"function",
"setupContext",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"fragment",
"=",
"true",
";",
"if",
"(",
"$",
"context",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"dom",
"->",
"createElementNS",
"(",
"self... | Sets up the tree constructor for building a fragment.
@param null $context | [
"Sets",
"up",
"the",
"tree",
"constructor",
"for",
"building",
"a",
"fragment",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/TreeBuilder.php#L3771-L3815 | train | Setup the parser with the given context | [
30522,
2270,
3853,
16437,
8663,
18209,
1006,
1002,
6123,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
15778,
1027,
2995,
1025,
2065,
1006,
1002,
6123,
1007,
1063,
1002,
6123,
1027,
1002,
2023,
1011,
1028,
14383,
1011,
1028,
3443,
12260,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/Medium.php | Medium.display | public function display($mode = 'source')
{
if ($this->mode === $mode) {
return $this;
}
$this->mode = $mode;
return $mode === 'thumbnail' ? ($this->getThumbnail() ? $this->getThumbnail()->reset() : null) : $this->reset();
} | php | public function display($mode = 'source')
{
if ($this->mode === $mode) {
return $this;
}
$this->mode = $mode;
return $mode === 'thumbnail' ? ($this->getThumbnail() ? $this->getThumbnail()->reset() : null) : $this->reset();
} | [
"public",
"function",
"display",
"(",
"$",
"mode",
"=",
"'source'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mode",
"===",
"$",
"mode",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"mode",
"=",
"$",
"mode",
";",
"return",
"$",
... | Switch display mode.
@param string $mode
@return $this | [
"Switch",
"display",
"mode",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/Medium.php#L483-L493 | train | Display the image | [
30522,
2270,
3853,
4653,
1006,
1002,
5549,
1027,
1005,
3120,
1005,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5549,
1027,
1027,
1027,
1002,
5549,
1007,
1063,
2709,
1002,
2023,
1025,
1065,
1002,
2023,
1011,
1028,
5549,
1027,
1002,
554... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Filter.php | Filter.addScopes | public function addScopes(array $scopes)
{
foreach ($scopes as $name => $config) {
$scopeObj = $this->makeFilterScope($name, $config);
/*
* Check that the filter scope matches the active context
*/
if ($scopeObj->context !== null) {
$context = is_array($scopeObj->context) ? $scopeObj->context : [$scopeObj->context];
if (!in_array($this->getContext(), $context)) {
continue;
}
}
/*
* Validate scope model
*/
if (isset($config['modelClass'])) {
$class = $config['modelClass'];
$model = new $class;
$this->scopeModels[$name] = $model;
}
/*
* Ensure scope type options are set
*/
$scopeProperties = [];
switch ($scopeObj->type) {
case 'date':
case 'daterange':
$scopeProperties = [
'minDate' => '2000-01-01',
'maxDate' => '2099-12-31',
'firstDay' => 0,
'yearRange' => 10,
];
break;
}
foreach ($scopeProperties as $property => $value) {
if (isset($config[$property])) {
$value = $config[$property];
}
$scopeObj->{$property} = $value;
}
$this->allScopes[$name] = $scopeObj;
}
} | php | public function addScopes(array $scopes)
{
foreach ($scopes as $name => $config) {
$scopeObj = $this->makeFilterScope($name, $config);
/*
* Check that the filter scope matches the active context
*/
if ($scopeObj->context !== null) {
$context = is_array($scopeObj->context) ? $scopeObj->context : [$scopeObj->context];
if (!in_array($this->getContext(), $context)) {
continue;
}
}
/*
* Validate scope model
*/
if (isset($config['modelClass'])) {
$class = $config['modelClass'];
$model = new $class;
$this->scopeModels[$name] = $model;
}
/*
* Ensure scope type options are set
*/
$scopeProperties = [];
switch ($scopeObj->type) {
case 'date':
case 'daterange':
$scopeProperties = [
'minDate' => '2000-01-01',
'maxDate' => '2099-12-31',
'firstDay' => 0,
'yearRange' => 10,
];
break;
}
foreach ($scopeProperties as $property => $value) {
if (isset($config[$property])) {
$value = $config[$property];
}
$scopeObj->{$property} = $value;
}
$this->allScopes[$name] = $scopeObj;
}
} | [
"public",
"function",
"addScopes",
"(",
"array",
"$",
"scopes",
")",
"{",
"foreach",
"(",
"$",
"scopes",
"as",
"$",
"name",
"=>",
"$",
"config",
")",
"{",
"$",
"scopeObj",
"=",
"$",
"this",
"->",
"makeFilterScope",
"(",
"$",
"name",
",",
"$",
"config... | Programatically add scopes, used internally and for extensibility. | [
"Programatically",
"add",
"scopes",
"used",
"internally",
"and",
"for",
"extensibility",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L567-L619 | train | Adds the scopes to the filter | [
30522,
2270,
3853,
9909,
16186,
2015,
1006,
9140,
1002,
9531,
2015,
1007,
1063,
18921,
6776,
1006,
1002,
9531,
2015,
2004,
1002,
2171,
1027,
1028,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
9531,
16429,
3501,
1027,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/FormConfigBuilder.php | FormConfigBuilder.setInheritData | public function setInheritData($inheritData)
{
if ($this->locked) {
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
$this->inheritData = (bool) $inheritData;
return $this;
} | php | public function setInheritData($inheritData)
{
if ($this->locked) {
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
$this->inheritData = (bool) $inheritData;
return $this;
} | [
"public",
"function",
"setInheritData",
"(",
"$",
"inheritData",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInter... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormConfigBuilder.php#L614-L623 | train | Set whether or not to inherit data from the form | [
30522,
2270,
3853,
2275,
2378,
5886,
4183,
2850,
2696,
1006,
1002,
22490,
2850,
2696,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5299,
1007,
1063,
5466,
2047,
2919,
11368,
6806,
16409,
24164,
2595,
24422,
1006,
1005,
2433,
8663,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/Filesystem.php | Filesystem.directories | public function directories($directory)
{
$directories = [];
foreach (Finder::create()->in($directory)->directories()->depth(0)->sortByName() as $dir) {
$directories[] = $dir->getPathname();
}
return $directories;
} | php | public function directories($directory)
{
$directories = [];
foreach (Finder::create()->in($directory)->directories()->depth(0)->sortByName() as $dir) {
$directories[] = $dir->getPathname();
}
return $directories;
} | [
"public",
"function",
"directories",
"(",
"$",
"directory",
")",
"{",
"$",
"directories",
"=",
"[",
"]",
";",
"foreach",
"(",
"Finder",
"::",
"create",
"(",
")",
"->",
"in",
"(",
"$",
"directory",
")",
"->",
"directories",
"(",
")",
"->",
"depth",
"(... | Get all of the directories within a given directory.
@param string $directory
@return array | [
"Get",
"all",
"of",
"the",
"directories",
"within",
"a",
"given",
"directory",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/Filesystem.php#L440-L449 | train | Get all directories in a directory | [
30522,
2270,
3853,
2472,
3111,
1006,
1002,
14176,
1007,
1063,
1002,
2472,
3111,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
2424,
2121,
1024,
1024,
3443,
1006,
1007,
1011,
1028,
1999,
1006,
1002,
14176,
1007,
1011,
1028,
2472,
3111,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/traits/PropertyContainer.php | PropertyContainer.validateProperties | public function validateProperties(array $properties)
{
$definedProperties = $this->defineProperties() ?: [];
/*
* Determine and implement default values
*/
$defaultProperties = [];
foreach ($definedProperties as $name => $information) {
if (array_key_exists('default', $information)) {
$defaultProperties[$name] = $information['default'];
}
}
$properties = array_merge($defaultProperties, $properties);
return $properties;
} | php | public function validateProperties(array $properties)
{
$definedProperties = $this->defineProperties() ?: [];
/*
* Determine and implement default values
*/
$defaultProperties = [];
foreach ($definedProperties as $name => $information) {
if (array_key_exists('default', $information)) {
$defaultProperties[$name] = $information['default'];
}
}
$properties = array_merge($defaultProperties, $properties);
return $properties;
} | [
"public",
"function",
"validateProperties",
"(",
"array",
"$",
"properties",
")",
"{",
"$",
"definedProperties",
"=",
"$",
"this",
"->",
"defineProperties",
"(",
")",
"?",
":",
"[",
"]",
";",
"/*\n * Determine and implement default values\n */",
"$",
... | Validates the properties against the defined properties of the class.
This method also sets default properties.
@param array $properties The supplied property values.
@return array The validated property set, with defaults applied. | [
"Validates",
"the",
"properties",
"against",
"the",
"defined",
"properties",
"of",
"the",
"class",
".",
"This",
"method",
"also",
"sets",
"default",
"properties",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/PropertyContainer.php#L26-L44 | train | Validate properties and return the array | [
30522,
2270,
3853,
9398,
3686,
21572,
4842,
7368,
1006,
9140,
1002,
5144,
1007,
1063,
1002,
4225,
21572,
4842,
7368,
1027,
1002,
2023,
1011,
1028,
9375,
21572,
4842,
7368,
1006,
1007,
1029,
1024,
1031,
1033,
1025,
1013,
1008,
1008,
5646,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Protocol/Pop3.php | Zend_Mail_Protocol_Pop3.readResponse | public function readResponse($multiline = false)
{
$result = @fgets($this->_socket);
if (!is_string($result)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('read failed - connection closed?');
}
$result = trim($result);
if (strpos($result, ' ')) {
list($status, $message) = explode(' ', $result, 2);
} else {
$status = $result;
$message = '';
}
if ($status != '+OK') {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('last request failed');
}
if ($multiline) {
$message = '';
$line = fgets($this->_socket);
while ($line && rtrim($line, "\r\n") != '.') {
if ($line[0] == '.') {
$line = substr($line, 1);
}
$message .= $line;
$line = fgets($this->_socket);
};
}
return $message;
} | php | public function readResponse($multiline = false)
{
$result = @fgets($this->_socket);
if (!is_string($result)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('read failed - connection closed?');
}
$result = trim($result);
if (strpos($result, ' ')) {
list($status, $message) = explode(' ', $result, 2);
} else {
$status = $result;
$message = '';
}
if ($status != '+OK') {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('last request failed');
}
if ($multiline) {
$message = '';
$line = fgets($this->_socket);
while ($line && rtrim($line, "\r\n") != '.') {
if ($line[0] == '.') {
$line = substr($line, 1);
}
$message .= $line;
$line = fgets($this->_socket);
};
}
return $message;
} | [
"public",
"function",
"readResponse",
"(",
"$",
"multiline",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"@",
"fgets",
"(",
"$",
"this",
"->",
"_socket",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"result",
")",
")",
"{",
"/**\n * @se... | read a response
@param boolean $multiline response has multiple lines and should be read until "<nl>.<nl>"
@return string response
@throws Zend_Mail_Protocol_Exception | [
"read",
"a",
"response"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Pop3.php#L166-L206 | train | Read the response from the server | [
30522,
2270,
3853,
3191,
6072,
26029,
3366,
1006,
1002,
4800,
4179,
1027,
6270,
1007,
1063,
1002,
2765,
1027,
1030,
1042,
18150,
2015,
1006,
1002,
2023,
1011,
1028,
1035,
22278,
1007,
1025,
2065,
1006,
999,
2003,
1035,
5164,
1006,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Kernel.php | Kernel.initializeContainer | protected function initializeContainer()
{
$class = $this->getContainerClass();
$cacheDir = $this->warmupDir ?: $this->getCacheDir();
$cache = new ConfigCache($cacheDir.'/'.$class.'.php', $this->debug);
$oldContainer = null;
if ($fresh = $cache->isFresh()) {
// Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
$fresh = $oldContainer = false;
try {
if (file_exists($cache->getPath()) && \is_object($this->container = include $cache->getPath())) {
$this->container->set('kernel', $this);
$oldContainer = $this->container;
$fresh = true;
}
} catch (\Throwable $e) {
} catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
}
if ($fresh) {
return;
}
if ($this->debug) {
$collectedLogs = [];
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
}
if (isset($collectedLogs[$message])) {
++$collectedLogs[$message]['count'];
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
// Clean the trace by removing first frames added by the error handler itself.
for ($i = 0; isset($backtrace[$i]); ++$i) {
if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
$backtrace = \array_slice($backtrace, 1 + $i);
break;
}
}
// Remove frames added by DebugClassLoader.
for ($i = \count($backtrace) - 2; 0 < $i; --$i) {
if (DebugClassLoader::class === ($backtrace[$i]['class'] ?? null)) {
$backtrace = [$backtrace[$i + 1]];
break;
}
}
$collectedLogs[$message] = [
'type' => $type,
'message' => $message,
'file' => $file,
'line' => $line,
'trace' => [$backtrace[0]],
'count' => 1,
];
});
}
try {
$container = null;
$container = $this->buildContainer();
$container->compile();
} finally {
if ($this->debug && true !== $previousHandler) {
restore_error_handler();
file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : '');
}
}
if (null === $oldContainer && file_exists($cache->getPath())) {
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
try {
$oldContainer = include $cache->getPath();
} catch (\Throwable $e) {
} catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
}
$oldContainer = \is_object($oldContainer) ? new \ReflectionClass($oldContainer) : false;
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
$this->container = require $cache->getPath();
$this->container->set('kernel', $this);
if ($oldContainer && \get_class($this->container) !== $oldContainer->name) {
// Because concurrent requests might still be using them,
// old container files are not removed immediately,
// but on a next dump of the container.
static $legacyContainers = [];
$oldContainerDir = \dirname($oldContainer->getFileName());
$legacyContainers[$oldContainerDir.'.legacy'] = true;
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) {
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
(new Filesystem())->remove(substr($legacyContainer, 0, -7));
}
}
touch($oldContainerDir.'.legacy');
}
if ($this->container->has('cache_warmer')) {
$this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'));
}
} | php | protected function initializeContainer()
{
$class = $this->getContainerClass();
$cacheDir = $this->warmupDir ?: $this->getCacheDir();
$cache = new ConfigCache($cacheDir.'/'.$class.'.php', $this->debug);
$oldContainer = null;
if ($fresh = $cache->isFresh()) {
// Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
$fresh = $oldContainer = false;
try {
if (file_exists($cache->getPath()) && \is_object($this->container = include $cache->getPath())) {
$this->container->set('kernel', $this);
$oldContainer = $this->container;
$fresh = true;
}
} catch (\Throwable $e) {
} catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
}
if ($fresh) {
return;
}
if ($this->debug) {
$collectedLogs = [];
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
}
if (isset($collectedLogs[$message])) {
++$collectedLogs[$message]['count'];
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
// Clean the trace by removing first frames added by the error handler itself.
for ($i = 0; isset($backtrace[$i]); ++$i) {
if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
$backtrace = \array_slice($backtrace, 1 + $i);
break;
}
}
// Remove frames added by DebugClassLoader.
for ($i = \count($backtrace) - 2; 0 < $i; --$i) {
if (DebugClassLoader::class === ($backtrace[$i]['class'] ?? null)) {
$backtrace = [$backtrace[$i + 1]];
break;
}
}
$collectedLogs[$message] = [
'type' => $type,
'message' => $message,
'file' => $file,
'line' => $line,
'trace' => [$backtrace[0]],
'count' => 1,
];
});
}
try {
$container = null;
$container = $this->buildContainer();
$container->compile();
} finally {
if ($this->debug && true !== $previousHandler) {
restore_error_handler();
file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
file_put_contents($cacheDir.'/'.$class.'Compiler.log', null !== $container ? implode("\n", $container->getCompiler()->getLog()) : '');
}
}
if (null === $oldContainer && file_exists($cache->getPath())) {
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
try {
$oldContainer = include $cache->getPath();
} catch (\Throwable $e) {
} catch (\Exception $e) {
} finally {
error_reporting($errorLevel);
}
}
$oldContainer = \is_object($oldContainer) ? new \ReflectionClass($oldContainer) : false;
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
$this->container = require $cache->getPath();
$this->container->set('kernel', $this);
if ($oldContainer && \get_class($this->container) !== $oldContainer->name) {
// Because concurrent requests might still be using them,
// old container files are not removed immediately,
// but on a next dump of the container.
static $legacyContainers = [];
$oldContainerDir = \dirname($oldContainer->getFileName());
$legacyContainers[$oldContainerDir.'.legacy'] = true;
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) {
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
(new Filesystem())->remove(substr($legacyContainer, 0, -7));
}
}
touch($oldContainerDir.'.legacy');
}
if ($this->container->has('cache_warmer')) {
$this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'));
}
} | [
"protected",
"function",
"initializeContainer",
"(",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getContainerClass",
"(",
")",
";",
"$",
"cacheDir",
"=",
"$",
"this",
"->",
"warmupDir",
"?",
":",
"$",
"this",
"->",
"getCacheDir",
"(",
")",
";",
"$... | Initializes the service container.
The cached version of the service container is used when fresh, otherwise the
container is built. | [
"Initializes",
"the",
"service",
"container",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Kernel.php#L480-L596 | train | Initializes the container | [
30522,
5123,
3853,
3988,
4697,
8663,
18249,
2121,
1006,
1007,
1063,
1002,
2465,
1027,
1002,
2023,
1011,
1028,
2131,
8663,
18249,
2121,
26266,
1006,
1007,
1025,
1002,
17053,
4305,
2099,
1027,
1002,
2023,
1011,
1028,
4010,
6279,
4305,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.selectRaw | public function selectRaw($expression, array $bindings = [])
{
$this->addSelect(new Expression($expression));
if ($bindings) {
$this->addBinding($bindings, 'select');
}
return $this;
} | php | public function selectRaw($expression, array $bindings = [])
{
$this->addSelect(new Expression($expression));
if ($bindings) {
$this->addBinding($bindings, 'select');
}
return $this;
} | [
"public",
"function",
"selectRaw",
"(",
"$",
"expression",
",",
"array",
"$",
"bindings",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"addSelect",
"(",
"new",
"Expression",
"(",
"$",
"expression",
")",
")",
";",
"if",
"(",
"$",
"bindings",
")",
"{",
... | Add a new "raw" select expression to the query.
@param string $expression
@param array $bindings
@return \Illuminate\Database\Query\Builder|static | [
"Add",
"a",
"new",
"raw",
"select",
"expression",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L252-L261 | train | Select raw expression | [
30522,
2270,
3853,
7276,
2527,
2860,
1006,
1002,
3670,
1010,
9140,
1002,
8031,
2015,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
9909,
12260,
6593,
1006,
2047,
3670,
1006,
1002,
3670,
1007,
1007,
1025,
2065,
1006,
1002,
8031,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/MessageSelector.php | MessageSelector.choose | public function choose($message, $number, $locale)
{
$parts = [];
if (preg_match('/^\|++$/', $message)) {
$parts = explode('|', $message);
} elseif (preg_match_all('/(?:\|\||[^\|])++/', $message, $matches)) {
$parts = $matches[0];
}
$explicitRules = [];
$standardRules = [];
foreach ($parts as $part) {
$part = trim(str_replace('||', '|', $part));
if (preg_match('/^(?P<interval>'.Interval::getIntervalRegexp().')\s*(?P<message>.*?)$/xs', $part, $matches)) {
$explicitRules[$matches['interval']] = $matches['message'];
} elseif (preg_match('/^\w+\:\s*(.*?)$/', $part, $matches)) {
$standardRules[] = $matches[1];
} else {
$standardRules[] = $part;
}
}
// try to match an explicit rule, then fallback to the standard ones
foreach ($explicitRules as $interval => $m) {
if (Interval::test($number, $interval)) {
return $m;
}
}
$position = PluralizationRules::get($number, $locale);
if (!isset($standardRules[$position])) {
// when there's exactly one rule given, and that rule is a standard
// rule, use this rule
if (1 === \count($parts) && isset($standardRules[0])) {
return $standardRules[0];
}
throw new InvalidArgumentException(sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $message, $locale, $number));
}
return $standardRules[$position];
} | php | public function choose($message, $number, $locale)
{
$parts = [];
if (preg_match('/^\|++$/', $message)) {
$parts = explode('|', $message);
} elseif (preg_match_all('/(?:\|\||[^\|])++/', $message, $matches)) {
$parts = $matches[0];
}
$explicitRules = [];
$standardRules = [];
foreach ($parts as $part) {
$part = trim(str_replace('||', '|', $part));
if (preg_match('/^(?P<interval>'.Interval::getIntervalRegexp().')\s*(?P<message>.*?)$/xs', $part, $matches)) {
$explicitRules[$matches['interval']] = $matches['message'];
} elseif (preg_match('/^\w+\:\s*(.*?)$/', $part, $matches)) {
$standardRules[] = $matches[1];
} else {
$standardRules[] = $part;
}
}
// try to match an explicit rule, then fallback to the standard ones
foreach ($explicitRules as $interval => $m) {
if (Interval::test($number, $interval)) {
return $m;
}
}
$position = PluralizationRules::get($number, $locale);
if (!isset($standardRules[$position])) {
// when there's exactly one rule given, and that rule is a standard
// rule, use this rule
if (1 === \count($parts) && isset($standardRules[0])) {
return $standardRules[0];
}
throw new InvalidArgumentException(sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $message, $locale, $number));
}
return $standardRules[$position];
} | [
"public",
"function",
"choose",
"(",
"$",
"message",
",",
"$",
"number",
",",
"$",
"locale",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'/^\\|++$/'",
",",
"$",
"message",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
... | Given a message with different plural translations separated by a
pipe (|), this method returns the correct portion of the message based
on the given number, locale and the pluralization rules in the message
itself.
The message supports two different types of pluralization rules:
interval: {0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples
indexed: There is one apple|There are %count% apples
The indexed solution can also contain labels (e.g. one: There is one apple).
This is purely for making the translations more clear - it does not
affect the functionality.
The two methods can also be mixed:
{0} There are no apples|one: There is one apple|more: There are %count% apples
@param string $message The message being translated
@param int|float $number The number of items represented for the message
@param string $locale The locale to use for choosing
@return string
@throws InvalidArgumentException | [
"Given",
"a",
"message",
"with",
"different",
"plural",
"translations",
"separated",
"by",
"a",
"pipe",
"(",
"|",
")",
"this",
"method",
"returns",
"the",
"correct",
"portion",
"of",
"the",
"message",
"based",
"on",
"the",
"given",
"number",
"locale",
"and",... | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/MessageSelector.php#L54-L97 | train | Returns the plural form of the given number and locale | [
30522,
2270,
3853,
5454,
1006,
1002,
4471,
1010,
1002,
2193,
1010,
1002,
2334,
2063,
1007,
1063,
1002,
3033,
1027,
1031,
1033,
1025,
2065,
1006,
3653,
2290,
1035,
2674,
1006,
1005,
1013,
1034,
1032,
1064,
1009,
1009,
1002,
1013,
1005,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php | ValidatePostSize.handle | public function handle($request, Closure $next)
{
$max = $this->getPostMaxSize();
if ($max > 0 && $request->server('CONTENT_LENGTH') > $max) {
throw new PostTooLargeException;
}
return $next($request);
} | php | public function handle($request, Closure $next)
{
$max = $this->getPostMaxSize();
if ($max > 0 && $request->server('CONTENT_LENGTH') > $max) {
throw new PostTooLargeException;
}
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"$",
"max",
"=",
"$",
"this",
"->",
"getPostMaxSize",
"(",
")",
";",
"if",
"(",
"$",
"max",
">",
"0",
"&&",
"$",
"request",
"->",
"server",
"(",
"'CONTENT_L... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed
@throws \Illuminate\Http\Exceptions\PostTooLargeException | [
"Handle",
"an",
"incoming",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php#L19-L28 | train | Handle the request | [
30522,
2270,
3853,
5047,
1006,
1002,
5227,
1010,
8503,
1002,
2279,
1007,
1063,
1002,
4098,
1027,
1002,
2023,
1011,
1028,
2131,
19894,
17848,
5332,
4371,
1006,
1007,
1025,
2065,
1006,
1002,
4098,
1028,
1014,
1004,
1004,
1002,
5227,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Worker.php | Worker.run | public function run(array $options = [], callable $onHandledCallback = null): void
{
$options = array_merge([
'sleep' => 1000000,
], $options);
if (\function_exists('pcntl_signal')) {
pcntl_signal(SIGTERM, function () {
$this->stop();
});
}
$onHandled = function (?Envelope $envelope) use ($onHandledCallback) {
if (\function_exists('pcntl_signal_dispatch')) {
pcntl_signal_dispatch();
}
if (null !== $onHandledCallback) {
$onHandledCallback($envelope);
}
};
while (false === $this->shouldStop) {
$envelopeHandled = false;
foreach ($this->receivers as $transportName => $receiver) {
$envelopes = $receiver->get();
foreach ($envelopes as $envelope) {
$envelopeHandled = true;
$this->handleMessage($envelope, $receiver, $transportName, $this->retryStrategies[$transportName] ?? null);
$onHandled($envelope);
}
// after handling a single receiver, quit and start the loop again
// this should prevent multiple lower priority receivers from
// blocking too long before the higher priority are checked
if ($envelopeHandled) {
break;
}
}
if (false === $envelopeHandled) {
$onHandled(null);
usleep($options['sleep']);
}
}
$this->dispatchEvent(new WorkerStoppedEvent());
} | php | public function run(array $options = [], callable $onHandledCallback = null): void
{
$options = array_merge([
'sleep' => 1000000,
], $options);
if (\function_exists('pcntl_signal')) {
pcntl_signal(SIGTERM, function () {
$this->stop();
});
}
$onHandled = function (?Envelope $envelope) use ($onHandledCallback) {
if (\function_exists('pcntl_signal_dispatch')) {
pcntl_signal_dispatch();
}
if (null !== $onHandledCallback) {
$onHandledCallback($envelope);
}
};
while (false === $this->shouldStop) {
$envelopeHandled = false;
foreach ($this->receivers as $transportName => $receiver) {
$envelopes = $receiver->get();
foreach ($envelopes as $envelope) {
$envelopeHandled = true;
$this->handleMessage($envelope, $receiver, $transportName, $this->retryStrategies[$transportName] ?? null);
$onHandled($envelope);
}
// after handling a single receiver, quit and start the loop again
// this should prevent multiple lower priority receivers from
// blocking too long before the higher priority are checked
if ($envelopeHandled) {
break;
}
}
if (false === $envelopeHandled) {
$onHandled(null);
usleep($options['sleep']);
}
}
$this->dispatchEvent(new WorkerStoppedEvent());
} | [
"public",
"function",
"run",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"callable",
"$",
"onHandledCallback",
"=",
"null",
")",
":",
"void",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"[",
"'sleep'",
"=>",
"1000000",
",",
"]",
",",
"$",
"op... | Receive the messages and dispatch them to the bus.
Valid options are:
* sleep (default: 1000000): Time in microseconds to sleep after no messages are found | [
"Receive",
"the",
"messages",
"and",
"dispatch",
"them",
"to",
"the",
"bus",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Worker.php#L65-L115 | train | Runs the worker loop | [
30522,
2270,
3853,
2448,
1006,
9140,
1002,
7047,
1027,
1031,
1033,
1010,
2655,
3085,
1002,
2006,
11774,
3709,
9289,
20850,
8684,
1027,
19701,
1007,
1024,
11675,
1063,
1002,
7047,
1027,
9140,
1035,
13590,
1006,
1031,
1005,
3637,
1005,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Asset/Package.php | Package.getUrl | public function getUrl($path)
{
if ($this->isAbsoluteUrl($path)) {
return $path;
}
return $this->versionStrategy->applyVersion($path);
} | php | public function getUrl($path)
{
if ($this->isAbsoluteUrl($path)) {
return $path;
}
return $this->versionStrategy->applyVersion($path);
} | [
"public",
"function",
"getUrl",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAbsoluteUrl",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"return",
"$",
"this",
"->",
"versionStrategy",
"->",
"applyVersion",
"(",
"$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Asset/Package.php#L46-L53 | train | Returns the absolute URL of the given path. | [
30522,
2270,
3853,
2131,
3126,
2140,
1006,
1002,
4130,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
18061,
5910,
4747,
10421,
3126,
2140,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
1002,
4130,
1025,
1065,
2709,
1002,
2023,
1011,
1028,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php | HasRelationships.belongsToMany | public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null,
$parentKey = null, $relatedKey = null, $relation = null)
{
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply.
if (is_null($relation)) {
$relation = $this->guessBelongsToManyRelation();
}
// First, we'll need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we'll make the query
// instances as well as the relationship instances we need for this.
$instance = $this->newRelatedInstance($related);
$foreignPivotKey = $foreignPivotKey ?: $this->getForeignKey();
$relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey();
// If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names
// are transformed to snake case from their default CamelCase also.
if (is_null($table)) {
$table = $this->joiningTable($related, $instance);
}
return $this->newBelongsToMany(
$instance->newQuery(), $this, $table, $foreignPivotKey,
$relatedPivotKey, $parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(), $relation
);
} | php | public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null,
$parentKey = null, $relatedKey = null, $relation = null)
{
// If no relationship name was passed, we will pull backtraces to get the
// name of the calling function. We will use that function name as the
// title of this relation since that is a great convention to apply.
if (is_null($relation)) {
$relation = $this->guessBelongsToManyRelation();
}
// First, we'll need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we'll make the query
// instances as well as the relationship instances we need for this.
$instance = $this->newRelatedInstance($related);
$foreignPivotKey = $foreignPivotKey ?: $this->getForeignKey();
$relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey();
// If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names
// are transformed to snake case from their default CamelCase also.
if (is_null($table)) {
$table = $this->joiningTable($related, $instance);
}
return $this->newBelongsToMany(
$instance->newQuery(), $this, $table, $foreignPivotKey,
$relatedPivotKey, $parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(), $relation
);
} | [
"public",
"function",
"belongsToMany",
"(",
"$",
"related",
",",
"$",
"table",
"=",
"null",
",",
"$",
"foreignPivotKey",
"=",
"null",
",",
"$",
"relatedPivotKey",
"=",
"null",
",",
"$",
"parentKey",
"=",
"null",
",",
"$",
"relatedKey",
"=",
"null",
",",
... | Define a many-to-many relationship.
@param string $related
@param string $table
@param string $foreignPivotKey
@param string $relatedPivotKey
@param string $parentKey
@param string $relatedKey
@param string $relation
@return \Illuminate\Database\Eloquent\Relations\BelongsToMany | [
"Define",
"a",
"many",
"-",
"to",
"-",
"many",
"relationship",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php#L448-L479 | train | Returns a new BelongsToMany relation | [
30522,
2270,
3853,
7460,
20389,
19092,
1006,
1002,
3141,
1010,
1002,
2795,
1027,
19701,
1010,
1002,
3097,
8197,
22994,
14839,
1027,
19701,
1010,
1002,
3141,
8197,
22994,
14839,
1027,
19701,
1010,
1002,
6687,
14839,
1027,
19701,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Payment/Order/Client.php | Client.unify | public function unify(array $params)
{
if (empty($params['spbill_create_ip'])) {
$params['spbill_create_ip'] = ('NATIVE' === $params['trade_type']) ? Support\get_server_ip() : Support\get_client_ip();
}
$params['appid'] = $this->app['config']->app_id;
$params['notify_url'] = $params['notify_url'] ?? $this->app['config']['notify_url'];
return $this->request($this->wrap('pay/unifiedorder'), $params);
} | php | public function unify(array $params)
{
if (empty($params['spbill_create_ip'])) {
$params['spbill_create_ip'] = ('NATIVE' === $params['trade_type']) ? Support\get_server_ip() : Support\get_client_ip();
}
$params['appid'] = $this->app['config']->app_id;
$params['notify_url'] = $params['notify_url'] ?? $this->app['config']['notify_url'];
return $this->request($this->wrap('pay/unifiedorder'), $params);
} | [
"public",
"function",
"unify",
"(",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'spbill_create_ip'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'spbill_create_ip'",
"]",
"=",
"(",
"'NATIVE'",
"===",
"$",
"params",
"[",... | Unify order.
@param array $params
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Unify",
"order",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Order/Client.php#L28-L38 | train | Unify order. | [
30522,
2270,
3853,
4895,
8757,
1006,
9140,
1002,
11498,
5244,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
11498,
5244,
1031,
1005,
11867,
24457,
1035,
3443,
1035,
12997,
1005,
1033,
1007,
1007,
1063,
1002,
11498,
5244,
1031,
1005,
11867,
2445... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.onLoadMovePopup | public function onLoadMovePopup()
{
$this->abortIfReadOnly();
$exclude = Input::get('exclude', []);
if (!is_array($exclude)) {
throw new ApplicationException('Invalid input data');
}
$folders = MediaLibrary::instance()->listAllDirectories($exclude);
$folderList = [];
foreach ($folders as $folder) {
$path = $folder;
if ($folder == '/') {
$name = Lang::get('backend::lang.media.library');
}
else {
$segments = explode('/', $folder);
$name = str_repeat(' ', (count($segments)-1)*4).basename($folder);
}
$folderList[$path] = $name;
}
$this->vars['folders'] = $folderList;
$this->vars['originalPath'] = Input::get('path');
return $this->makePartial('move-form');
} | php | public function onLoadMovePopup()
{
$this->abortIfReadOnly();
$exclude = Input::get('exclude', []);
if (!is_array($exclude)) {
throw new ApplicationException('Invalid input data');
}
$folders = MediaLibrary::instance()->listAllDirectories($exclude);
$folderList = [];
foreach ($folders as $folder) {
$path = $folder;
if ($folder == '/') {
$name = Lang::get('backend::lang.media.library');
}
else {
$segments = explode('/', $folder);
$name = str_repeat(' ', (count($segments)-1)*4).basename($folder);
}
$folderList[$path] = $name;
}
$this->vars['folders'] = $folderList;
$this->vars['originalPath'] = Input::get('path');
return $this->makePartial('move-form');
} | [
"public",
"function",
"onLoadMovePopup",
"(",
")",
"{",
"$",
"this",
"->",
"abortIfReadOnly",
"(",
")",
";",
"$",
"exclude",
"=",
"Input",
"::",
"get",
"(",
"'exclude'",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"exclude",
")",
... | Show move item popup AJAX handler
@return array | [
"Show",
"move",
"item",
"popup",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L545-L575 | train | On load move popup | [
30522,
2270,
3853,
2006,
11066,
5302,
3726,
16340,
6279,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
11113,
11589,
10128,
16416,
5280,
2135,
1006,
1007,
1025,
1002,
23329,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
23329,
1005,
1010,
1031,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php | LogoutUrlGenerator.generateLogoutUrl | private function generateLogoutUrl($key, $referenceType)
{
list($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager) = $this->getListener($key);
if (null === $logoutPath) {
throw new \LogicException('Unable to generate the logout URL without a path.');
}
$parameters = null !== $csrfTokenManager ? [$csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)] : [];
if ('/' === $logoutPath[0]) {
if (!$this->requestStack) {
throw new \LogicException('Unable to generate the logout URL without a RequestStack.');
}
$request = $this->requestStack->getCurrentRequest();
$url = UrlGeneratorInterface::ABSOLUTE_URL === $referenceType ? $request->getUriForPath($logoutPath) : $request->getBaseUrl().$logoutPath;
if (!empty($parameters)) {
$url .= '?'.http_build_query($parameters, '', '&');
}
} else {
if (!$this->router) {
throw new \LogicException('Unable to generate the logout URL without a Router.');
}
$url = $this->router->generate($logoutPath, $parameters, $referenceType);
}
return $url;
} | php | private function generateLogoutUrl($key, $referenceType)
{
list($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager) = $this->getListener($key);
if (null === $logoutPath) {
throw new \LogicException('Unable to generate the logout URL without a path.');
}
$parameters = null !== $csrfTokenManager ? [$csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)] : [];
if ('/' === $logoutPath[0]) {
if (!$this->requestStack) {
throw new \LogicException('Unable to generate the logout URL without a RequestStack.');
}
$request = $this->requestStack->getCurrentRequest();
$url = UrlGeneratorInterface::ABSOLUTE_URL === $referenceType ? $request->getUriForPath($logoutPath) : $request->getBaseUrl().$logoutPath;
if (!empty($parameters)) {
$url .= '?'.http_build_query($parameters, '', '&');
}
} else {
if (!$this->router) {
throw new \LogicException('Unable to generate the logout URL without a Router.');
}
$url = $this->router->generate($logoutPath, $parameters, $referenceType);
}
return $url;
} | [
"private",
"function",
"generateLogoutUrl",
"(",
"$",
"key",
",",
"$",
"referenceType",
")",
"{",
"list",
"(",
"$",
"logoutPath",
",",
"$",
"csrfTokenId",
",",
"$",
"csrfParameter",
",",
"$",
"csrfTokenManager",
")",
"=",
"$",
"this",
"->",
"getListener",
... | Generates the logout URL for the firewall.
@param string|null $key The firewall key or null to use the current firewall key
@param int $referenceType The type of reference (one of the constants in UrlGeneratorInterface)
@return string The logout URL | [
"Generates",
"the",
"logout",
"URL",
"for",
"the",
"firewall",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/Logout/LogoutUrlGenerator.php#L97-L128 | train | Generate the logout URL | [
30522,
2797,
3853,
9699,
21197,
5833,
3126,
2140,
1006,
1002,
3145,
1010,
1002,
4431,
13874,
1007,
1063,
2862,
1006,
1002,
8154,
4904,
15069,
1010,
1002,
20116,
12881,
18715,
18595,
2094,
1010,
1002,
20116,
12881,
28689,
22828,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/API.php | API.setSiteSpecificUserAgentExcludeEnabled | public function setSiteSpecificUserAgentExcludeEnabled($enabled)
{
Piwik::checkUserHasSuperUserAccess();
// update option
Option::set(self::OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE, $enabled);
// make sure tracker cache will reflect change
Cache::deleteTrackerCache();
} | php | public function setSiteSpecificUserAgentExcludeEnabled($enabled)
{
Piwik::checkUserHasSuperUserAccess();
// update option
Option::set(self::OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE, $enabled);
// make sure tracker cache will reflect change
Cache::deleteTrackerCache();
} | [
"public",
"function",
"setSiteSpecificUserAgentExcludeEnabled",
"(",
"$",
"enabled",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"// update option",
"Option",
"::",
"set",
"(",
"self",
"::",
"OPTION_SITE_SPECIFIC_USER_AGENT_EXCLUDE_ENABLE",
",",... | Sets whether it should be allowed to exclude different user agents for different
websites.
@param bool $enabled | [
"Sets",
"whether",
"it",
"should",
"be",
"allowed",
"to",
"exclude",
"different",
"user",
"agents",
"for",
"different",
"websites",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L1080-L1089 | train | Set whether the user agent excludes the site specific user agent | [
30522,
2270,
3853,
4520,
7616,
5051,
6895,
8873,
7874,
6906,
11461,
10288,
20464,
12672,
8189,
23242,
1006,
1002,
9124,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpClient/Response/ResponseTrait.php | ResponseTrait.getContent | public function getContent(bool $throw = true): string
{
if ($this->initializer) {
($this->initializer)($this);
$this->initializer = null;
}
if ($throw) {
$this->checkStatusCode();
}
if (null === $this->content) {
$content = null;
$chunk = null;
foreach (self::stream([$this]) as $chunk) {
if (!$chunk->isLast()) {
$content .= $chunk->getContent();
}
}
if (null === $content) {
throw new TransportException('Cannot get the content of the response twice: the request was issued with option "buffer" set to false.');
}
return $content;
}
foreach (self::stream([$this]) as $chunk) {
// Chunks are buffered in $this->content already
}
rewind($this->content);
return stream_get_contents($this->content);
} | php | public function getContent(bool $throw = true): string
{
if ($this->initializer) {
($this->initializer)($this);
$this->initializer = null;
}
if ($throw) {
$this->checkStatusCode();
}
if (null === $this->content) {
$content = null;
$chunk = null;
foreach (self::stream([$this]) as $chunk) {
if (!$chunk->isLast()) {
$content .= $chunk->getContent();
}
}
if (null === $content) {
throw new TransportException('Cannot get the content of the response twice: the request was issued with option "buffer" set to false.');
}
return $content;
}
foreach (self::stream([$this]) as $chunk) {
// Chunks are buffered in $this->content already
}
rewind($this->content);
return stream_get_contents($this->content);
} | [
"public",
"function",
"getContent",
"(",
"bool",
"$",
"throw",
"=",
"true",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"initializer",
")",
"{",
"(",
"$",
"this",
"->",
"initializer",
")",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/Response/ResponseTrait.php#L94-L129 | train | Get the content of the response | [
30522,
2270,
3853,
2131,
8663,
6528,
2102,
1006,
22017,
2140,
1002,
5466,
1027,
2995,
1007,
1024,
5164,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3988,
17629,
1007,
1063,
1006,
1002,
2023,
1011,
1028,
3988,
17629,
1007,
1006,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Connectors/PostgresConnector.php | PostgresConnector.addSslOptions | protected function addSslOptions($dsn, array $config)
{
foreach (['sslmode', 'sslcert', 'sslkey', 'sslrootcert'] as $option) {
if (isset($config[$option])) {
$dsn .= ";{$option}={$config[$option]}";
}
}
return $dsn;
} | php | protected function addSslOptions($dsn, array $config)
{
foreach (['sslmode', 'sslcert', 'sslkey', 'sslrootcert'] as $option) {
if (isset($config[$option])) {
$dsn .= ";{$option}={$config[$option]}";
}
}
return $dsn;
} | [
"protected",
"function",
"addSslOptions",
"(",
"$",
"dsn",
",",
"array",
"$",
"config",
")",
"{",
"foreach",
"(",
"[",
"'sslmode'",
",",
"'sslcert'",
",",
"'sslkey'",
",",
"'sslrootcert'",
"]",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"isset",
"(",
"$... | Add the SSL options to the DSN.
@param string $dsn
@param array $config
@return string | [
"Add",
"the",
"SSL",
"options",
"to",
"the",
"DSN",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connectors/PostgresConnector.php#L166-L175 | train | Adds SSL options to the DSN | [
30522,
5123,
3853,
9909,
14540,
7361,
9285,
1006,
1002,
16233,
2078,
1010,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
18921,
6776,
1006,
1031,
1005,
7020,
13728,
10244,
1005,
1010,
1005,
7020,
23314,
5339,
1005,
1010,
1005,
7020,
28143,
2100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php | TranslationsCacheWarmer.warmUp | public function warmUp($cacheDir)
{
if (null === $this->translator) {
$this->translator = $this->container->get('translator');
}
if ($this->translator instanceof WarmableInterface) {
$this->translator->warmUp($cacheDir);
}
} | php | public function warmUp($cacheDir)
{
if (null === $this->translator) {
$this->translator = $this->container->get('translator');
}
if ($this->translator instanceof WarmableInterface) {
$this->translator->warmUp($cacheDir);
}
} | [
"public",
"function",
"warmUp",
"(",
"$",
"cacheDir",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"translator",
")",
"{",
"$",
"this",
"->",
"translator",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'translator'",
")",
";",
"}"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php#L39-L48 | train | Warms up the language files | [
30522,
2270,
3853,
4010,
6279,
1006,
1002,
17053,
4305,
2099,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
11403,
1007,
1063,
1002,
2023,
1011,
1028,
11403,
1027,
1002,
2023,
1011,
1028,
11661,
1011,
1028,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Blueprint.php | Blueprint.morphs | public function morphs($name, $indexName = null)
{
$this->string("{$name}_type");
$this->unsignedBigInteger("{$name}_id");
$this->index(["{$name}_type", "{$name}_id"], $indexName);
} | php | public function morphs($name, $indexName = null)
{
$this->string("{$name}_type");
$this->unsignedBigInteger("{$name}_id");
$this->index(["{$name}_type", "{$name}_id"], $indexName);
} | [
"public",
"function",
"morphs",
"(",
"$",
"name",
",",
"$",
"indexName",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"string",
"(",
"\"{$name}_type\"",
")",
";",
"$",
"this",
"->",
"unsignedBigInteger",
"(",
"\"{$name}_id\"",
")",
";",
"$",
"this",
"->",
... | Add the proper columns for a polymorphic table.
@param string $name
@param string|null $indexName
@return void | [
"Add",
"the",
"proper",
"columns",
"for",
"a",
"polymorphic",
"table",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Blueprint.php#L1202-L1209 | train | Define the morphs fields of the current context | [
30522,
2270,
3853,
22822,
18757,
1006,
1002,
2171,
1010,
1002,
5950,
18442,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
5164,
1006,
1000,
1063,
1002,
2171,
1065,
1035,
2828,
1000,
1007,
1025,
1002,
2023,
1011,
1028,
27121,
5638,
11528,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Exceptions/Handler.php | Handler.registerErrorViewPaths | protected function registerErrorViewPaths()
{
$paths = collect(config('view.paths'));
View::replaceNamespace('errors', $paths->map(function ($path) {
return "{$path}/errors";
})->push(__DIR__.'/views')->all());
} | php | protected function registerErrorViewPaths()
{
$paths = collect(config('view.paths'));
View::replaceNamespace('errors', $paths->map(function ($path) {
return "{$path}/errors";
})->push(__DIR__.'/views')->all());
} | [
"protected",
"function",
"registerErrorViewPaths",
"(",
")",
"{",
"$",
"paths",
"=",
"collect",
"(",
"config",
"(",
"'view.paths'",
")",
")",
";",
"View",
"::",
"replaceNamespace",
"(",
"'errors'",
",",
"$",
"paths",
"->",
"map",
"(",
"function",
"(",
"$",... | Register the error template hint paths.
@return void | [
"Register",
"the",
"error",
"template",
"hint",
"paths",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Exceptions/Handler.php#L391-L398 | train | Register error view paths | [
30522,
5123,
3853,
4236,
2121,
29165,
8584,
15069,
2015,
1006,
1007,
1063,
1002,
10425,
1027,
8145,
1006,
9530,
8873,
2290,
1006,
1005,
3193,
1012,
10425,
1005,
1007,
1007,
1025,
3193,
1024,
1024,
5672,
18442,
23058,
1006,
1005,
10697,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Scheduler/Scheduler.php | Scheduler.loadSavedJobs | public function loadSavedJobs()
{
$this->saved_jobs = [];
$saved_jobs = (array) Grav::instance()['config']->get('scheduler.custom_jobs', []);
foreach ($saved_jobs as $id => $j) {
$args = $j['args'] ?? [];
$id = Grav::instance()['inflector']->hyphenize($id);
$job = $this->addCommand($j['command'], $args, $id);
if (isset($j['at'])) {
$job->at($j['at']);
}
if (isset($j['output'])) {
$mode = isset($j['output_mode']) && $j['output_mode'] === 'append' ? true : false;
$job->output($j['output'], $mode);
}
if (isset($j['email'])) {
$job->email($j['email']);
}
// store in saved_jobs
$this->saved_jobs[] = $job;
}
return $this;
} | php | public function loadSavedJobs()
{
$this->saved_jobs = [];
$saved_jobs = (array) Grav::instance()['config']->get('scheduler.custom_jobs', []);
foreach ($saved_jobs as $id => $j) {
$args = $j['args'] ?? [];
$id = Grav::instance()['inflector']->hyphenize($id);
$job = $this->addCommand($j['command'], $args, $id);
if (isset($j['at'])) {
$job->at($j['at']);
}
if (isset($j['output'])) {
$mode = isset($j['output_mode']) && $j['output_mode'] === 'append' ? true : false;
$job->output($j['output'], $mode);
}
if (isset($j['email'])) {
$job->email($j['email']);
}
// store in saved_jobs
$this->saved_jobs[] = $job;
}
return $this;
} | [
"public",
"function",
"loadSavedJobs",
"(",
")",
"{",
"$",
"this",
"->",
"saved_jobs",
"=",
"[",
"]",
";",
"$",
"saved_jobs",
"=",
"(",
"array",
")",
"Grav",
"::",
"instance",
"(",
")",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'scheduler.custom_jobs'",
... | Load saved jobs from config/scheduler.yaml file | [
"Load",
"saved",
"jobs",
"from",
"config",
"/",
"scheduler",
".",
"yaml",
"file"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L53-L81 | train | Load saved jobs | [
30522,
2270,
3853,
15665,
10696,
2094,
5558,
5910,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
5552,
1035,
5841,
1027,
1031,
1033,
1025,
1002,
5552,
1035,
5841,
1027,
1006,
9140,
1007,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1031,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/Between.php | Zend_Validate_Between.isValid | public function isValid($value)
{
$this->_setValue($value);
if ($this->_inclusive) {
if ($this->_min > $value || $value > $this->_max) {
$this->_error(self::NOT_BETWEEN);
return false;
}
} else {
if ($this->_min >= $value || $value >= $this->_max) {
$this->_error(self::NOT_BETWEEN_STRICT);
return false;
}
}
return true;
} | php | public function isValid($value)
{
$this->_setValue($value);
if ($this->_inclusive) {
if ($this->_min > $value || $value > $this->_max) {
$this->_error(self::NOT_BETWEEN);
return false;
}
} else {
if ($this->_min >= $value || $value >= $this->_max) {
$this->_error(self::NOT_BETWEEN_STRICT);
return false;
}
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_setValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_inclusive",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_min",
">",
"$",
"value",
"||",
"$",
... | Defined by Zend_Validate_Interface
Returns true if and only if $value is between min and max options, inclusively
if inclusive option is true.
@param mixed $value
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Between.php#L206-L222 | train | Checks if the value is within the range of the range | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
3643,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
2275,
10175,
5657,
1006,
1002,
3643,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
18678,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.ancestor | public function ancestor($route, $path = null)
{
if ($path !== null) {
$page = $this->dispatch($route, true);
if ($page && $page->path() === $path) {
return $page;
}
$parent = $page ? $page->parent() : null;
if ($parent && !$parent->root()) {
return $this->ancestor($parent->route(), $path);
}
}
return null;
} | php | public function ancestor($route, $path = null)
{
if ($path !== null) {
$page = $this->dispatch($route, true);
if ($page && $page->path() === $path) {
return $page;
}
$parent = $page ? $page->parent() : null;
if ($parent && !$parent->root()) {
return $this->ancestor($parent->route(), $path);
}
}
return null;
} | [
"public",
"function",
"ancestor",
"(",
"$",
"route",
",",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"path",
"!==",
"null",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"route",
",",
"true",
")",
";",
"if",
"(",... | Get a page ancestor.
@param string $route The relative URL of the page
@param string $path The relative path of the ancestor folder
@return PageInterface|null | [
"Get",
"a",
"page",
"ancestor",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L419-L435 | train | Get ancestor page | [
30522,
2270,
3853,
13032,
1006,
1002,
2799,
1010,
1002,
4130,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
4130,
999,
1027,
1027,
19701,
1007,
1063,
1002,
3931,
1027,
1002,
2023,
1011,
1028,
18365,
1006,
1002,
2799,
1010,
2995,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Installation/Controller.php | Controller.setupSuperUser | function setupSuperUser()
{
$this->checkPiwikIsNotInstalled();
$superUserAlreadyExists = Access::doAsSuperUser(function () {
return count(APIUsersManager::getInstance()->getUsersHavingSuperUserAccess()) > 0;
});
if ($superUserAlreadyExists) {
$this->redirectToNextStep('setupSuperUser');
}
$view = new View(
'@Installation/setupSuperUser',
$this->getInstallationSteps(),
__FUNCTION__
);
$form = new FormSuperUser();
if ($form->validate()) {
try {
$this->createSuperUser($form->getSubmitValue('login'),
$form->getSubmitValue('password'),
$form->getSubmitValue('email'));
$email = $form->getSubmitValue('email');
$newsletterPiwikORG = $form->getSubmitValue('subscribe_newsletter_piwikorg');
$newsletterProfessionalServices = $form->getSubmitValue('subscribe_newsletter_professionalservices');
$this->registerNewsletter($email, $newsletterPiwikORG, $newsletterProfessionalServices);
$this->redirectToNextStep(__FUNCTION__);
} catch (Exception $e) {
$view->errorMessage = $e->getMessage();
}
}
$view->addForm($form);
return $view->render();
} | php | function setupSuperUser()
{
$this->checkPiwikIsNotInstalled();
$superUserAlreadyExists = Access::doAsSuperUser(function () {
return count(APIUsersManager::getInstance()->getUsersHavingSuperUserAccess()) > 0;
});
if ($superUserAlreadyExists) {
$this->redirectToNextStep('setupSuperUser');
}
$view = new View(
'@Installation/setupSuperUser',
$this->getInstallationSteps(),
__FUNCTION__
);
$form = new FormSuperUser();
if ($form->validate()) {
try {
$this->createSuperUser($form->getSubmitValue('login'),
$form->getSubmitValue('password'),
$form->getSubmitValue('email'));
$email = $form->getSubmitValue('email');
$newsletterPiwikORG = $form->getSubmitValue('subscribe_newsletter_piwikorg');
$newsletterProfessionalServices = $form->getSubmitValue('subscribe_newsletter_professionalservices');
$this->registerNewsletter($email, $newsletterPiwikORG, $newsletterProfessionalServices);
$this->redirectToNextStep(__FUNCTION__);
} catch (Exception $e) {
$view->errorMessage = $e->getMessage();
}
}
$view->addForm($form);
return $view->render();
} | [
"function",
"setupSuperUser",
"(",
")",
"{",
"$",
"this",
"->",
"checkPiwikIsNotInstalled",
"(",
")",
";",
"$",
"superUserAlreadyExists",
"=",
"Access",
"::",
"doAsSuperUser",
"(",
"function",
"(",
")",
"{",
"return",
"count",
"(",
"APIUsersManager",
"::",
"ge... | Installation Step 5: General Set-up (superuser login/password/email and subscriptions) | [
"Installation",
"Step",
"5",
":",
"General",
"Set",
"-",
"up",
"(",
"superuser",
"login",
"/",
"password",
"/",
"email",
"and",
"subscriptions",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/Controller.php#L254-L295 | train | Setup Super User | [
30522,
3853,
16437,
6342,
4842,
20330,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
4638,
8197,
9148,
14270,
17048,
7076,
9080,
3709,
1006,
1007,
1025,
1002,
3565,
20330,
2389,
16416,
5149,
10288,
5130,
1027,
3229,
1024,
1024,
2079,
12054,
627... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement/Pdo.php | Zend_Db_Statement_Pdo.nextRowset | public function nextRowset()
{
try {
return $this->_stmt->nextRowset();
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | php | public function nextRowset()
{
try {
return $this->_stmt->nextRowset();
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"nextRowset",
"(",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"_stmt",
"->",
"nextRowset",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"// require_once 'Zend/Db/Statement/Exception.php';",
"throw",
"new",... | Retrieves the next rowset (result set) for a SQL statement that has
multiple result sets. An example is a stored procedure that returns
the results of multiple queries.
@return bool
@throws Zend_Db_Statement_Exception | [
"Retrieves",
"the",
"next",
"rowset",
"(",
"result",
"set",
")",
"for",
"a",
"SQL",
"statement",
"that",
"has",
"multiple",
"result",
"sets",
".",
"An",
"example",
"is",
"a",
"stored",
"procedure",
"that",
"returns",
"the",
"results",
"of",
"multiple",
"qu... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Pdo.php#L375-L383 | train | Return the next rowset in the result set | [
30522,
2270,
3853,
2279,
10524,
13462,
1006,
1007,
1063,
3046,
1063,
2709,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1011,
1028,
2279,
10524,
13462,
1006,
1007,
1025,
1065,
4608,
1006,
22851,
8913,
2595,
24422,
1002,
1041,
1007,
1063,
1013... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.processAutoSpan | protected function processAutoSpan($fields)
{
$prevSpan = null;
foreach ($fields as $field) {
if (strtolower($field->span) === 'auto') {
if ($prevSpan === 'left') {
$field->span = 'right';
}
else {
$field->span = 'left';
}
}
$prevSpan = $field->span;
}
} | php | protected function processAutoSpan($fields)
{
$prevSpan = null;
foreach ($fields as $field) {
if (strtolower($field->span) === 'auto') {
if ($prevSpan === 'left') {
$field->span = 'right';
}
else {
$field->span = 'left';
}
}
$prevSpan = $field->span;
}
} | [
"protected",
"function",
"processAutoSpan",
"(",
"$",
"fields",
")",
"{",
"$",
"prevSpan",
"=",
"null",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"field",
"->",
"span",
")",
"===",
"'auto'",
... | Converts fields with a span set to 'auto' as either
'left' or 'right' depending on the previous field.
@return void | [
"Converts",
"fields",
"with",
"a",
"span",
"set",
"to",
"auto",
"as",
"either",
"left",
"or",
"right",
"depending",
"on",
"the",
"previous",
"field",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L654-L670 | train | Process auto span | [
30522,
5123,
3853,
2832,
4887,
13122,
9739,
1006,
1002,
4249,
1007,
1063,
1002,
3653,
15088,
9739,
1027,
19701,
1025,
18921,
6776,
1006,
1002,
4249,
2004,
1002,
2492,
1007,
1063,
2065,
1006,
2358,
5339,
12898,
13777,
1006,
1002,
2492,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Session/Middleware/StartSession.php | StartSession.storeCurrentUrl | protected function storeCurrentUrl(Request $request, $session)
{
if ($request->method() === 'GET' &&
$request->route() &&
! $request->ajax() &&
! $request->prefetch()) {
$session->setPreviousUrl($request->fullUrl());
}
} | php | protected function storeCurrentUrl(Request $request, $session)
{
if ($request->method() === 'GET' &&
$request->route() &&
! $request->ajax() &&
! $request->prefetch()) {
$session->setPreviousUrl($request->fullUrl());
}
} | [
"protected",
"function",
"storeCurrentUrl",
"(",
"Request",
"$",
"request",
",",
"$",
"session",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"method",
"(",
")",
"===",
"'GET'",
"&&",
"$",
"request",
"->",
"route",
"(",
")",
"&&",
"!",
"$",
"request",
... | Store the current URL for the request if necessary.
@param \Illuminate\Http\Request $request
@param \Illuminate\Contracts\Session\Session $session
@return void | [
"Store",
"the",
"current",
"URL",
"for",
"the",
"request",
"if",
"necessary",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Session/Middleware/StartSession.php#L134-L142 | train | Stores the current URL in the session | [
30522,
5123,
3853,
3573,
10841,
14343,
3372,
3126,
2140,
1006,
5227,
1002,
5227,
1010,
1002,
5219,
1007,
1063,
2065,
1006,
1002,
5227,
1011,
1028,
4118,
1006,
1007,
1027,
1027,
1027,
1005,
2131,
1005,
1004,
1004,
1002,
5227,
1011,
1028,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Referrers/Controller.php | Controller.getReferrerSparklineParams | private function getReferrerSparklineParams($referrerType)
{
$totalRow = $this->translator->translate('General_Total');
return array(
'columns' => array('nb_visits'),
'rows' => array(self::getTranslatedReferrerTypeLabel($referrerType), $totalRow),
'typeReferrer' => $referrerType,
'module' => $this->pluginName,
'action' => 'getReferrerType'
);
} | php | private function getReferrerSparklineParams($referrerType)
{
$totalRow = $this->translator->translate('General_Total');
return array(
'columns' => array('nb_visits'),
'rows' => array(self::getTranslatedReferrerTypeLabel($referrerType), $totalRow),
'typeReferrer' => $referrerType,
'module' => $this->pluginName,
'action' => 'getReferrerType'
);
} | [
"private",
"function",
"getReferrerSparklineParams",
"(",
"$",
"referrerType",
")",
"{",
"$",
"totalRow",
"=",
"$",
"this",
"->",
"translator",
"->",
"translate",
"(",
"'General_Total'",
")",
";",
"return",
"array",
"(",
"'columns'",
"=>",
"array",
"(",
"'nb_v... | Returns the URL for the sparkline of visits with a specific referrer type.
@param int $referrerType The referrer type. Referrer types are defined in Common class.
@return string The URL that can be used to get a sparkline image. | [
"Returns",
"the",
"URL",
"for",
"the",
"sparkline",
"of",
"visits",
"with",
"a",
"specific",
"referrer",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/Controller.php#L378-L389 | train | Returns the sparkline parameters for a specific referrer type | [
30522,
2797,
3853,
2131,
2890,
7512,
14544,
27694,
2243,
4179,
28689,
5244,
1006,
1002,
6523,
14544,
13874,
1007,
1063,
1002,
2561,
10524,
1027,
1002,
2023,
1011,
1028,
11403,
1011,
1028,
17637,
1006,
1005,
2236,
1035,
2561,
1005,
1007,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Worker.php | Worker.process | public function process($connectionName, $job, WorkerOptions $options)
{
try {
// First we will raise the before job event and determine if the job has already ran
// over its maximum attempt limits, which could primarily happen when this job is
// continually timing out and not actually throwing any exceptions from itself.
$this->raiseBeforeJobEvent($connectionName, $job);
$this->markJobAsFailedIfAlreadyExceedsMaxAttempts(
$connectionName, $job, (int) $options->maxTries
);
// Here we will fire off the job and let it process. We will catch any exceptions so
// they can be reported to the developers logs, etc. Once the job is finished the
// proper events will be fired to let any listeners know this job has finished.
$job->fire();
$this->raiseAfterJobEvent($connectionName, $job);
} catch (Exception $e) {
$this->handleJobException($connectionName, $job, $options, $e);
} catch (Throwable $e) {
$this->handleJobException(
$connectionName, $job, $options, new FatalThrowableError($e)
);
}
} | php | public function process($connectionName, $job, WorkerOptions $options)
{
try {
// First we will raise the before job event and determine if the job has already ran
// over its maximum attempt limits, which could primarily happen when this job is
// continually timing out and not actually throwing any exceptions from itself.
$this->raiseBeforeJobEvent($connectionName, $job);
$this->markJobAsFailedIfAlreadyExceedsMaxAttempts(
$connectionName, $job, (int) $options->maxTries
);
// Here we will fire off the job and let it process. We will catch any exceptions so
// they can be reported to the developers logs, etc. Once the job is finished the
// proper events will be fired to let any listeners know this job has finished.
$job->fire();
$this->raiseAfterJobEvent($connectionName, $job);
} catch (Exception $e) {
$this->handleJobException($connectionName, $job, $options, $e);
} catch (Throwable $e) {
$this->handleJobException(
$connectionName, $job, $options, new FatalThrowableError($e)
);
}
} | [
"public",
"function",
"process",
"(",
"$",
"connectionName",
",",
"$",
"job",
",",
"WorkerOptions",
"$",
"options",
")",
"{",
"try",
"{",
"// First we will raise the before job event and determine if the job has already ran",
"// over its maximum attempt limits, which could prima... | Process the given job from the queue.
@param string $connectionName
@param \Illuminate\Contracts\Queue\Job $job
@param \Illuminate\Queue\WorkerOptions $options
@return void
@throws \Throwable | [
"Process",
"the",
"given",
"job",
"from",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Worker.php#L312-L337 | train | Processes a job | [
30522,
2270,
3853,
2832,
1006,
1002,
4434,
18442,
1010,
1002,
3105,
1010,
7309,
7361,
9285,
1002,
7047,
1007,
1063,
3046,
1063,
1013,
1013,
2034,
2057,
2097,
5333,
1996,
2077,
3105,
2724,
1998,
5646,
2065,
1996,
3105,
2038,
2525,
2743,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter/Group.php | Group.startWith | public function startWith($label = '')
{
$label = $label ?: 'Start with';
$condition = [$this->column, 'like', "{$this->value}%"];
return $this->joinGroup($label, $condition);
} | php | public function startWith($label = '')
{
$label = $label ?: 'Start with';
$condition = [$this->column, 'like', "{$this->value}%"];
return $this->joinGroup($label, $condition);
} | [
"public",
"function",
"startWith",
"(",
"$",
"label",
"=",
"''",
")",
"{",
"$",
"label",
"=",
"$",
"label",
"?",
":",
"'Start with'",
";",
"$",
"condition",
"=",
"[",
"$",
"this",
"->",
"column",
",",
"'like'",
",",
"\"{$this->value}%\"",
"]",
";",
"... | Filter out records which starts with input query.
@param string $label
@return Group | [
"Filter",
"out",
"records",
"which",
"starts",
"with",
"input",
"query",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/Group.php#L235-L242 | train | Filter items that start with a given value | [
30522,
2270,
3853,
2707,
24415,
1006,
1002,
3830,
1027,
1005,
1005,
1007,
1063,
1002,
3830,
1027,
1002,
3830,
1029,
1024,
1005,
2707,
2007,
1005,
1025,
1002,
4650,
1027,
1031,
1002,
2023,
1011,
1028,
5930,
1010,
1005,
2066,
1005,
1010,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/FactoryBuilder.php | FactoryBuilder.stateAttributes | protected function stateAttributes($state, array $attributes)
{
$stateAttributes = $this->states[$this->class][$state];
if (! is_callable($stateAttributes)) {
return $stateAttributes;
}
return call_user_func(
$stateAttributes,
$this->faker, $attributes
);
} | php | protected function stateAttributes($state, array $attributes)
{
$stateAttributes = $this->states[$this->class][$state];
if (! is_callable($stateAttributes)) {
return $stateAttributes;
}
return call_user_func(
$stateAttributes,
$this->faker, $attributes
);
} | [
"protected",
"function",
"stateAttributes",
"(",
"$",
"state",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"stateAttributes",
"=",
"$",
"this",
"->",
"states",
"[",
"$",
"this",
"->",
"class",
"]",
"[",
"$",
"state",
"]",
";",
"if",
"(",
"!",
"is... | Get the state attributes.
@param string $state
@param array $attributes
@return array | [
"Get",
"the",
"state",
"attributes",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/FactoryBuilder.php#L339-L351 | train | Return the attributes of the state | [
30522,
5123,
3853,
2110,
19321,
3089,
8569,
4570,
1006,
1002,
2110,
1010,
9140,
1002,
12332,
1007,
1063,
1002,
2110,
19321,
3089,
8569,
4570,
1027,
1002,
2023,
1011,
1028,
2163,
1031,
1002,
2023,
1011,
1028,
2465,
1033,
1031,
1002,
2110,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.objectToArray | protected function objectToArray($object)
{
$class = get_class($object);
$info = new \ReflectionClass($object);
$this->commentMap[$class] = [];
$methods = [];
foreach ($info->getMethods() as $method) {
if (!$method->isPublic()) {
continue; // Only public
}
if ($method->class != $class) {
continue; // Only locals
}
$name = $method->getName();
if (in_array($name, $this->blockMethods)) {
continue; // Blocked methods
}
if (preg_match('/^on[A-Z]{1}[\w+]*$/', $name)) {
continue; // AJAX methods
}
if (preg_match('/^get[A-Z]{1}[\w+]*Options$/', $name)) {
continue; // getSomethingOptions
}
if (substr($name, 0, 1) == '_') {
continue; // Magic/hidden method
}
$name .= '()';
$methods[$name] = '___METHOD___|'.$name;
$this->commentMap[$name] = $this->evalDocBlock($method);
}
$vars = [];
foreach ($info->getProperties() as $property) {
if ($property->isStatic()) {
continue; // Only non-static
}
if (!$property->isPublic()) {
continue; // Only public
}
if ($property->class != $class) {
continue; // Only locals
}
$name = $property->getName();
$vars[$name] = $object->{$name};
$this->commentMap[$name] = $this->evalDocBlock($property);
}
return $methods + $vars;
} | php | protected function objectToArray($object)
{
$class = get_class($object);
$info = new \ReflectionClass($object);
$this->commentMap[$class] = [];
$methods = [];
foreach ($info->getMethods() as $method) {
if (!$method->isPublic()) {
continue; // Only public
}
if ($method->class != $class) {
continue; // Only locals
}
$name = $method->getName();
if (in_array($name, $this->blockMethods)) {
continue; // Blocked methods
}
if (preg_match('/^on[A-Z]{1}[\w+]*$/', $name)) {
continue; // AJAX methods
}
if (preg_match('/^get[A-Z]{1}[\w+]*Options$/', $name)) {
continue; // getSomethingOptions
}
if (substr($name, 0, 1) == '_') {
continue; // Magic/hidden method
}
$name .= '()';
$methods[$name] = '___METHOD___|'.$name;
$this->commentMap[$name] = $this->evalDocBlock($method);
}
$vars = [];
foreach ($info->getProperties() as $property) {
if ($property->isStatic()) {
continue; // Only non-static
}
if (!$property->isPublic()) {
continue; // Only public
}
if ($property->class != $class) {
continue; // Only locals
}
$name = $property->getName();
$vars[$name] = $object->{$name};
$this->commentMap[$name] = $this->evalDocBlock($property);
}
return $methods + $vars;
} | [
"protected",
"function",
"objectToArray",
"(",
"$",
"object",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"$",
"info",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"commentMap",
"[",
... | Returns a map of an object as an array, containing methods and properties.
@param mixed $object
@return array | [
"Returns",
"a",
"map",
"of",
"an",
"object",
"as",
"an",
"array",
"containing",
"methods",
"and",
"properties",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L453-L503 | train | Convert object to array | [
30522,
5123,
3853,
4874,
3406,
2906,
9447,
1006,
1002,
4874,
1007,
1063,
1002,
2465,
1027,
2131,
1035,
2465,
1006,
1002,
4874,
1007,
1025,
1002,
18558,
1027,
2047,
1032,
9185,
26266,
1006,
1002,
4874,
1007,
1025,
1002,
2023,
1011,
1028,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Ecommerce/Columns/Revenue.php | Revenue.onGoalConversion | public function onGoalConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
$defaultRevenue = $goalManager->getGoalColumn('revenue');
$revenue = $request->getGoalRevenue($defaultRevenue);
return $this->roundRevenueIfNeeded($revenue);
} | php | public function onGoalConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
$defaultRevenue = $goalManager->getGoalColumn('revenue');
$revenue = $request->getGoalRevenue($defaultRevenue);
return $this->roundRevenueIfNeeded($revenue);
} | [
"public",
"function",
"onGoalConversion",
"(",
"Request",
"$",
"request",
",",
"Visitor",
"$",
"visitor",
",",
"$",
"action",
",",
"GoalManager",
"$",
"goalManager",
")",
"{",
"$",
"defaultRevenue",
"=",
"$",
"goalManager",
"->",
"getGoalColumn",
"(",
"'revenu... | @param Request $request
@param Visitor $visitor
@param Action|null $action
@param GoalManager $goalManager
@return mixed|false | [
"@param",
"Request",
"$request",
"@param",
"Visitor",
"$visitor",
"@param",
"Action|null",
"$action",
"@param",
"GoalManager",
"$goalManager"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Ecommerce/Columns/Revenue.php#L38-L44 | train | This method is called when a Goal conversion is triggered. | [
30522,
2270,
3853,
2006,
3995,
2389,
8663,
27774,
1006,
5227,
1002,
5227,
1010,
10367,
1002,
10367,
1010,
1002,
2895,
1010,
3125,
24805,
4590,
1002,
3125,
24805,
4590,
1007,
1063,
1002,
12398,
2890,
8159,
5657,
1027,
1002,
3125,
24805,
4590... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
slimphp/Slim | Slim/Route.php | Route.prepare | public function prepare(ServerRequestInterface $request, array $arguments)
{
// Remove temp arguments
$this->setArguments($this->savedArguments);
// Add the route arguments
foreach ($arguments as $k => $v) {
$this->setArgument($k, $v, false);
}
} | php | public function prepare(ServerRequestInterface $request, array $arguments)
{
// Remove temp arguments
$this->setArguments($this->savedArguments);
// Add the route arguments
foreach ($arguments as $k => $v) {
$this->setArgument($k, $v, false);
}
} | [
"public",
"function",
"prepare",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"array",
"$",
"arguments",
")",
"{",
"// Remove temp arguments",
"$",
"this",
"->",
"setArguments",
"(",
"$",
"this",
"->",
"savedArguments",
")",
";",
"// Add the route arguments",... | {@inheritdoc} | [
"{"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Route.php#L256-L265 | train | Prepare the route | [
30522,
2270,
3853,
7374,
1006,
8241,
2890,
15500,
18447,
2121,
12172,
1002,
5227,
1010,
9140,
1002,
9918,
1007,
1063,
1013,
1013,
6366,
8915,
8737,
9918,
1002,
2023,
1011,
1028,
2275,
2906,
22850,
11187,
1006,
1002,
2023,
1011,
1028,
5552,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/API/Request.php | Request.getRequestArrayFromString | public static function getRequestArrayFromString($request, $defaultRequest = null)
{
if ($defaultRequest === null) {
$defaultRequest = self::getDefaultRequest();
$requestRaw = self::getRequestParametersGET();
if (!empty($requestRaw['segment'])) {
$defaultRequest['segment'] = $requestRaw['segment'];
}
if (!isset($defaultRequest['format_metrics'])) {
$defaultRequest['format_metrics'] = 'bc';
}
}
$requestArray = $defaultRequest;
if (!is_null($request)) {
if (is_array($request)) {
$requestParsed = $request;
} else {
$request = trim($request);
$request = str_replace(array("\n", "\t"), '', $request);
$requestParsed = UrlHelper::getArrayFromQueryString($request);
}
$requestArray = $requestParsed + $defaultRequest;
}
foreach ($requestArray as &$element) {
if (!is_array($element)) {
$element = trim($element);
}
}
return $requestArray;
} | php | public static function getRequestArrayFromString($request, $defaultRequest = null)
{
if ($defaultRequest === null) {
$defaultRequest = self::getDefaultRequest();
$requestRaw = self::getRequestParametersGET();
if (!empty($requestRaw['segment'])) {
$defaultRequest['segment'] = $requestRaw['segment'];
}
if (!isset($defaultRequest['format_metrics'])) {
$defaultRequest['format_metrics'] = 'bc';
}
}
$requestArray = $defaultRequest;
if (!is_null($request)) {
if (is_array($request)) {
$requestParsed = $request;
} else {
$request = trim($request);
$request = str_replace(array("\n", "\t"), '', $request);
$requestParsed = UrlHelper::getArrayFromQueryString($request);
}
$requestArray = $requestParsed + $defaultRequest;
}
foreach ($requestArray as &$element) {
if (!is_array($element)) {
$element = trim($element);
}
}
return $requestArray;
} | [
"public",
"static",
"function",
"getRequestArrayFromString",
"(",
"$",
"request",
",",
"$",
"defaultRequest",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"defaultRequest",
"===",
"null",
")",
"{",
"$",
"defaultRequest",
"=",
"self",
"::",
"getDefaultRequest",
"(",
... | Converts the supplied request string into an array of query paramater name/value
mappings. The current query parameters (everything in `$_GET` and `$_POST`) are
forwarded to request array before it is returned.
@param string|array|null $request The base request string or array, eg,
`'module=UserLanguage&action=getLanguage'`.
@param array $defaultRequest Default query parameters. If a query parameter is absent in `$request`, it will be loaded
from this. Defaults to `$_GET + $_POST`.
@return array | [
"Converts",
"the",
"supplied",
"request",
"string",
"into",
"an",
"array",
"of",
"query",
"paramater",
"name",
"/",
"value",
"mappings",
".",
"The",
"current",
"query",
"parameters",
"(",
"everything",
"in",
"$_GET",
"and",
"$_POST",
")",
"are",
"forwarded",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Request.php#L98-L134 | train | Returns an array of the request parameters from the GET or POST parameters | [
30522,
2270,
10763,
3853,
2131,
2890,
15500,
2906,
9447,
19699,
22225,
18886,
3070,
1006,
1002,
5227,
1010,
1002,
12398,
2890,
15500,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
12398,
2890,
15500,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Adapter/ChainAdapter.php | ChainAdapter.save | public function save(CacheItemInterface $item)
{
$saved = true;
$i = $this->adapterCount;
while ($i--) {
$saved = $this->adapters[$i]->save($item) && $saved;
}
return $saved;
} | php | public function save(CacheItemInterface $item)
{
$saved = true;
$i = $this->adapterCount;
while ($i--) {
$saved = $this->adapters[$i]->save($item) && $saved;
}
return $saved;
} | [
"public",
"function",
"save",
"(",
"CacheItemInterface",
"$",
"item",
")",
"{",
"$",
"saved",
"=",
"true",
";",
"$",
"i",
"=",
"$",
"this",
"->",
"adapterCount",
";",
"while",
"(",
"$",
"i",
"--",
")",
"{",
"$",
"saved",
"=",
"$",
"this",
"->",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/ChainAdapter.php#L241-L251 | train | Save CacheItem to Adapter | [
30522,
2270,
3853,
3828,
1006,
17053,
4221,
10020,
3334,
12172,
1002,
8875,
1007,
1063,
1002,
5552,
1027,
2995,
1025,
1002,
1045,
1027,
1002,
2023,
1011,
1028,
15581,
2121,
3597,
16671,
1025,
2096,
1006,
1002,
1045,
1011,
1011,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/FlexForm.php | FlexForm.getValue | public function getValue(string $name)
{
// Attempt to get value from the form data.
$value = $this->data ? $this->data[$name] : null;
// Return the form data or fall back to the object property.
return $value ?? $this->getObject()->value($name);
} | php | public function getValue(string $name)
{
// Attempt to get value from the form data.
$value = $this->data ? $this->data[$name] : null;
// Return the form data or fall back to the object property.
return $value ?? $this->getObject()->value($name);
} | [
"public",
"function",
"getValue",
"(",
"string",
"$",
"name",
")",
"{",
"// Attempt to get value from the form data.",
"$",
"value",
"=",
"$",
"this",
"->",
"data",
"?",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
":",
"null",
";",
"// Return the form ... | Get a value from the form.
Note: Used in form fields.
@param string $name
@return mixed | [
"Get",
"a",
"value",
"from",
"the",
"form",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/FlexForm.php#L100-L107 | train | Get the value of a form parameter. | [
30522,
2270,
3853,
2131,
10175,
5657,
1006,
5164,
1002,
2171,
1007,
1063,
1013,
1013,
3535,
2000,
2131,
3643,
2013,
1996,
2433,
2951,
1012,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
2951,
1029,
1002,
2023,
1011,
1028,
2951,
1031,
1002,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement/Mysqli.php | Zend_Db_Statement_Mysqli.errorInfo | public function errorInfo()
{
if (!$this->_stmt) {
return false;
}
return array(
substr($this->_stmt->sqlstate, 0, 5),
$this->_stmt->errno,
$this->_stmt->error,
);
} | php | public function errorInfo()
{
if (!$this->_stmt) {
return false;
}
return array(
substr($this->_stmt->sqlstate, 0, 5),
$this->_stmt->errno,
$this->_stmt->error,
);
} | [
"public",
"function",
"errorInfo",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_stmt",
")",
"{",
"return",
"false",
";",
"}",
"return",
"array",
"(",
"substr",
"(",
"$",
"this",
"->",
"_stmt",
"->",
"sqlstate",
",",
"0",
",",
"5",
")",
","... | Retrieves an array of error information, if any, associated with the
last operation on the statement handle.
@return array | [
"Retrieves",
"an",
"array",
"of",
"error",
"information",
"if",
"any",
"associated",
"with",
"the",
"last",
"operation",
"on",
"the",
"statement",
"handle",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Mysqli.php#L164-L174 | train | Returns an array with SQL error and the last error | [
30522,
2270,
3853,
7561,
2378,
14876,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1007,
1063,
2709,
6270,
1025,
1065,
2709,
9140,
1006,
4942,
3367,
2099,
1006,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Grammar.php | Grammar.wrapAliasedValue | protected function wrapAliasedValue($value, $prefixAlias = false)
{
$segments = preg_split('/\s+as\s+/i', $value);
// If we are wrapping a table we need to prefix the alias with the table prefix
// as well in order to generate proper syntax. If this is a column of course
// no prefix is necessary. The condition will be true when from wrapTable.
if ($prefixAlias) {
$segments[1] = $this->tablePrefix.$segments[1];
}
return $this->wrap(
$segments[0]).' as '.$this->wrapValue($segments[1]
);
} | php | protected function wrapAliasedValue($value, $prefixAlias = false)
{
$segments = preg_split('/\s+as\s+/i', $value);
// If we are wrapping a table we need to prefix the alias with the table prefix
// as well in order to generate proper syntax. If this is a column of course
// no prefix is necessary. The condition will be true when from wrapTable.
if ($prefixAlias) {
$segments[1] = $this->tablePrefix.$segments[1];
}
return $this->wrap(
$segments[0]).' as '.$this->wrapValue($segments[1]
);
} | [
"protected",
"function",
"wrapAliasedValue",
"(",
"$",
"value",
",",
"$",
"prefixAlias",
"=",
"false",
")",
"{",
"$",
"segments",
"=",
"preg_split",
"(",
"'/\\s+as\\s+/i'",
",",
"$",
"value",
")",
";",
"// If we are wrapping a table we need to prefix the alias with th... | Wrap a value that has an alias.
@param string $value
@param bool $prefixAlias
@return string | [
"Wrap",
"a",
"value",
"that",
"has",
"an",
"alias",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Grammar.php#L75-L89 | train | Wrap a value with an alias | [
30522,
5123,
3853,
10236,
22786,
6924,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
17576,
22786,
2015,
1027,
6270,
1007,
1063,
1002,
9214,
1027,
3653,
2290,
1035,
3975,
1006,
1005,
1013,
1032,
1055,
1009,
2004,
1032,
1055,
1009,
1013,
1045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter/AbstractFilter.php | AbstractFilter.variables | protected function variables()
{
return array_merge([
'id' => $this->id,
'name' => $this->formatName($this->column),
'label' => $this->label,
'value' => $this->value ?: $this->defaultValue,
'presenter' => $this->presenter(),
], $this->presenter()->variables());
} | php | protected function variables()
{
return array_merge([
'id' => $this->id,
'name' => $this->formatName($this->column),
'label' => $this->label,
'value' => $this->value ?: $this->defaultValue,
'presenter' => $this->presenter(),
], $this->presenter()->variables());
} | [
"protected",
"function",
"variables",
"(",
")",
"{",
"return",
"array_merge",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'name'",
"=>",
"$",
"this",
"->",
"formatName",
"(",
"$",
"this",
"->",
"column",
")",
",",
"'label'",
"=>",
"$",
"th... | Variables for filter view.
@return array | [
"Variables",
"for",
"filter",
"view",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/AbstractFilter.php#L466-L475 | train | Return the variables of the field | [
30522,
5123,
3853,
10857,
1006,
1007,
1063,
2709,
9140,
1035,
13590,
1006,
1031,
1005,
8909,
1005,
1027,
1028,
1002,
2023,
1011,
1028,
8909,
1010,
1005,
2171,
1005,
1027,
1028,
1002,
2023,
1011,
1028,
4289,
18442,
1006,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php | RepeatedTypeValidatorExtension.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
// Map errors to the first field
$errorMapping = function (Options $options) {
return ['.' => $options['first_name']];
};
$resolver->setDefaults([
'error_mapping' => $errorMapping,
]);
} | php | public function configureOptions(OptionsResolver $resolver)
{
// Map errors to the first field
$errorMapping = function (Options $options) {
return ['.' => $options['first_name']];
};
$resolver->setDefaults([
'error_mapping' => $errorMapping,
]);
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"// Map errors to the first field",
"$",
"errorMapping",
"=",
"function",
"(",
"Options",
"$",
"options",
")",
"{",
"return",
"[",
"'.'",
"=>",
"$",
"options",
"[",
"'fi... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php#L27-L37 | train | Configure the options resolver | [
30522,
2270,
3853,
9530,
8873,
27390,
8780,
16790,
2015,
1006,
7047,
6072,
4747,
6299,
1002,
10663,
2099,
1007,
1063,
1013,
1013,
4949,
10697,
2000,
1996,
2034,
2492,
1002,
7561,
2863,
14853,
1027,
3853,
1006,
7047,
1002,
7047,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/HandlerStack.php | HandlerStack.push | public function push(callable $middleware, $name = '')
{
$this->stack[] = [$middleware, $name];
$this->cached = null;
} | php | public function push(callable $middleware, $name = '')
{
$this->stack[] = [$middleware, $name];
$this->cached = null;
} | [
"public",
"function",
"push",
"(",
"callable",
"$",
"middleware",
",",
"$",
"name",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"stack",
"[",
"]",
"=",
"[",
"$",
"middleware",
",",
"$",
"name",
"]",
";",
"$",
"this",
"->",
"cached",
"=",
"null",
";",... | Push a middleware to the top of the stack.
@param callable $middleware Middleware function
@param string $name Name to register for this middleware. | [
"Push",
"a",
"middleware",
"to",
"the",
"top",
"of",
"the",
"stack",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/HandlerStack.php#L139-L143 | train | Push a middleware onto the stack | [
30522,
2270,
3853,
5245,
1006,
2655,
3085,
1002,
2690,
8059,
1010,
1002,
2171,
1027,
1005,
1005,
1007,
1063,
1002,
2023,
1011,
1028,
9991,
1031,
1033,
1027,
1031,
1002,
2690,
8059,
1010,
1002,
2171,
1033,
1025,
1002,
2023,
1011,
1028,
170... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Hashing/HashManager.php | HashManager.check | public function check($value, $hashedValue, array $options = [])
{
return $this->driver()->check($value, $hashedValue, $options);
} | php | public function check($value, $hashedValue, array $options = [])
{
return $this->driver()->check($value, $hashedValue, $options);
} | [
"public",
"function",
"check",
"(",
"$",
"value",
",",
"$",
"hashedValue",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"driver",
"(",
")",
"->",
"check",
"(",
"$",
"value",
",",
"$",
"hashedValue",
",",
"$",
... | Check the given plain value against a hash.
@param string $value
@param string $hashedValue
@param array $options
@return bool | [
"Check",
"the",
"given",
"plain",
"value",
"against",
"a",
"hash",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Hashing/HashManager.php#L71-L74 | train | Checks if a value is valid for the current context. | [
30522,
2270,
3853,
4638,
1006,
1002,
3643,
1010,
1002,
23325,
2098,
10175,
5657,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4062,
1006,
1007,
1011,
1028,
4638,
1006,
1002,
3643,
1010,
1002,
23325,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Writable/Maildir.php | Zend_Mail_Storage_Writable_Maildir.getQuota | public function getQuota($fromStorage = false) {
if ($fromStorage) {
$fh = @fopen($this->_rootdir . 'maildirsize', 'r');
if (!$fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot open maildirsize');
}
$definition = fgets($fh);
fclose($fh);
$definition = explode(',', trim($definition));
$quota = array();
foreach ($definition as $member) {
$key = $member[strlen($member) - 1];
if ($key == 'S' || $key == 'C') {
$key = $key == 'C' ? 'count' : 'size';
}
$quota[$key] = substr($member, 0, -1);
}
return $quota;
}
return $this->_quota;
} | php | public function getQuota($fromStorage = false) {
if ($fromStorage) {
$fh = @fopen($this->_rootdir . 'maildirsize', 'r');
if (!$fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot open maildirsize');
}
$definition = fgets($fh);
fclose($fh);
$definition = explode(',', trim($definition));
$quota = array();
foreach ($definition as $member) {
$key = $member[strlen($member) - 1];
if ($key == 'S' || $key == 'C') {
$key = $key == 'C' ? 'count' : 'size';
}
$quota[$key] = substr($member, 0, -1);
}
return $quota;
}
return $this->_quota;
} | [
"public",
"function",
"getQuota",
"(",
"$",
"fromStorage",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fromStorage",
")",
"{",
"$",
"fh",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"_rootdir",
".",
"'maildirsize'",
",",
"'r'",
")",
";",
"if",
"(",
"!"... | get currently set quota
@see Zend_Mail_Storage_Writable_Maildir::setQuota()
@return bool|array | [
"get",
"currently",
"set",
"quota"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L835-L860 | train | Get quota of all mails | [
30522,
2270,
3853,
2131,
28940,
17287,
1006,
1002,
2013,
23809,
4270,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2013,
23809,
4270,
1007,
1063,
1002,
1042,
2232,
1027,
1030,
1042,
26915,
1006,
1002,
2023,
1011,
1028,
1035,
7117,
4305,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/UpdateManager.php | UpdateManager.init | protected function init()
{
$this->pluginManager = PluginManager::instance();
$this->themeManager = class_exists(ThemeManager::class) ? ThemeManager::instance() : null;
$this->versionManager = VersionManager::instance();
$this->tempDirectory = temp_path();
$this->baseDirectory = base_path();
$this->disableCoreUpdates = Config::get('cms.disableCoreUpdates', false);
$this->bindContainerObjects();
/*
* Ensure temp directory exists
*/
if (!File::isDirectory($this->tempDirectory)) {
File::makeDirectory($this->tempDirectory, 0777, true);
}
} | php | protected function init()
{
$this->pluginManager = PluginManager::instance();
$this->themeManager = class_exists(ThemeManager::class) ? ThemeManager::instance() : null;
$this->versionManager = VersionManager::instance();
$this->tempDirectory = temp_path();
$this->baseDirectory = base_path();
$this->disableCoreUpdates = Config::get('cms.disableCoreUpdates', false);
$this->bindContainerObjects();
/*
* Ensure temp directory exists
*/
if (!File::isDirectory($this->tempDirectory)) {
File::makeDirectory($this->tempDirectory, 0777, true);
}
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"pluginManager",
"=",
"PluginManager",
"::",
"instance",
"(",
")",
";",
"$",
"this",
"->",
"themeManager",
"=",
"class_exists",
"(",
"ThemeManager",
"::",
"class",
")",
"?",
"ThemeManager",
... | Initialize this singleton. | [
"Initialize",
"this",
"singleton",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/UpdateManager.php#L100-L116 | train | Initializes the object | [
30522,
5123,
3853,
1999,
4183,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
13354,
2378,
24805,
4590,
1027,
13354,
2378,
24805,
4590,
1024,
1024,
6013,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
4323,
24805,
4590,
1027,
2465,
1035,
6526,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.parent | public function parent(PageInterface $var = null)
{
if ($var) {
$this->parent = $var->path();
return $var;
}
/** @var Pages $pages */
$pages = Grav::instance()['pages'];
return $pages->get($this->parent);
} | php | public function parent(PageInterface $var = null)
{
if ($var) {
$this->parent = $var->path();
return $var;
}
/** @var Pages $pages */
$pages = Grav::instance()['pages'];
return $pages->get($this->parent);
} | [
"public",
"function",
"parent",
"(",
"PageInterface",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"var",
")",
"{",
"$",
"this",
"->",
"parent",
"=",
"$",
"var",
"->",
"path",
"(",
")",
";",
"return",
"$",
"var",
";",
"}",
"/** @var Pages $pa... | Gets and Sets the parent object for this page
@param PageInterface $var the parent page object
@return PageInterface|null the parent page object if it exists. | [
"Gets",
"and",
"Sets",
"the",
"parent",
"object",
"for",
"this",
"page"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L2366-L2378 | train | Get parent page | [
30522,
2270,
3853,
6687,
1006,
3931,
18447,
2121,
12172,
1002,
13075,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
13075,
1007,
1063,
1002,
2023,
1011,
1028,
6687,
1027,
1002,
13075,
1011,
1028,
4130,
1006,
1007,
1025,
2709,
1002,
13075,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/PropertyAccess/PropertyAccessor.php | PropertyAccessor.readPropertiesUntil | private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath, $lastIndex, $ignoreInvalidIndices = true)
{
if (!\is_object($zval[self::VALUE]) && !\is_array($zval[self::VALUE])) {
throw new UnexpectedTypeException($zval[self::VALUE], $propertyPath, 0);
}
// Add the root object to the list
$propertyValues = [$zval];
for ($i = 0; $i < $lastIndex; ++$i) {
$property = $propertyPath->getElement($i);
$isIndex = $propertyPath->isIndex($i);
if ($isIndex) {
// Create missing nested arrays on demand
if (($zval[self::VALUE] instanceof \ArrayAccess && !$zval[self::VALUE]->offsetExists($property)) ||
(\is_array($zval[self::VALUE]) && !isset($zval[self::VALUE][$property]) && !\array_key_exists($property, $zval[self::VALUE]))
) {
if (!$ignoreInvalidIndices) {
if (!\is_array($zval[self::VALUE])) {
if (!$zval[self::VALUE] instanceof \Traversable) {
throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s".', $property, (string) $propertyPath));
}
$zval[self::VALUE] = iterator_to_array($zval[self::VALUE]);
}
throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s". Available indices are "%s".', $property, (string) $propertyPath, print_r(array_keys($zval[self::VALUE]), true)));
}
if ($i + 1 < $propertyPath->getLength()) {
if (isset($zval[self::REF])) {
$zval[self::VALUE][$property] = [];
$zval[self::REF] = $zval[self::VALUE];
} else {
$zval[self::VALUE] = [$property => []];
}
}
}
$zval = $this->readIndex($zval, $property);
} else {
$zval = $this->readProperty($zval, $property, $this->ignoreInvalidProperty);
}
// the final value of the path must not be validated
if ($i + 1 < $propertyPath->getLength() && !\is_object($zval[self::VALUE]) && !\is_array($zval[self::VALUE])) {
throw new UnexpectedTypeException($zval[self::VALUE], $propertyPath, $i + 1);
}
if (isset($zval[self::REF]) && (0 === $i || isset($propertyValues[$i - 1][self::IS_REF_CHAINED]))) {
// Set the IS_REF_CHAINED flag to true if:
// current property is passed by reference and
// it is the first element in the property path or
// the IS_REF_CHAINED flag of its parent element is true
// Basically, this flag is true only when the reference chain from the top element to current element is not broken
$zval[self::IS_REF_CHAINED] = true;
}
$propertyValues[] = $zval;
}
return $propertyValues;
} | php | private function readPropertiesUntil($zval, PropertyPathInterface $propertyPath, $lastIndex, $ignoreInvalidIndices = true)
{
if (!\is_object($zval[self::VALUE]) && !\is_array($zval[self::VALUE])) {
throw new UnexpectedTypeException($zval[self::VALUE], $propertyPath, 0);
}
// Add the root object to the list
$propertyValues = [$zval];
for ($i = 0; $i < $lastIndex; ++$i) {
$property = $propertyPath->getElement($i);
$isIndex = $propertyPath->isIndex($i);
if ($isIndex) {
// Create missing nested arrays on demand
if (($zval[self::VALUE] instanceof \ArrayAccess && !$zval[self::VALUE]->offsetExists($property)) ||
(\is_array($zval[self::VALUE]) && !isset($zval[self::VALUE][$property]) && !\array_key_exists($property, $zval[self::VALUE]))
) {
if (!$ignoreInvalidIndices) {
if (!\is_array($zval[self::VALUE])) {
if (!$zval[self::VALUE] instanceof \Traversable) {
throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s".', $property, (string) $propertyPath));
}
$zval[self::VALUE] = iterator_to_array($zval[self::VALUE]);
}
throw new NoSuchIndexException(sprintf('Cannot read index "%s" while trying to traverse path "%s". Available indices are "%s".', $property, (string) $propertyPath, print_r(array_keys($zval[self::VALUE]), true)));
}
if ($i + 1 < $propertyPath->getLength()) {
if (isset($zval[self::REF])) {
$zval[self::VALUE][$property] = [];
$zval[self::REF] = $zval[self::VALUE];
} else {
$zval[self::VALUE] = [$property => []];
}
}
}
$zval = $this->readIndex($zval, $property);
} else {
$zval = $this->readProperty($zval, $property, $this->ignoreInvalidProperty);
}
// the final value of the path must not be validated
if ($i + 1 < $propertyPath->getLength() && !\is_object($zval[self::VALUE]) && !\is_array($zval[self::VALUE])) {
throw new UnexpectedTypeException($zval[self::VALUE], $propertyPath, $i + 1);
}
if (isset($zval[self::REF]) && (0 === $i || isset($propertyValues[$i - 1][self::IS_REF_CHAINED]))) {
// Set the IS_REF_CHAINED flag to true if:
// current property is passed by reference and
// it is the first element in the property path or
// the IS_REF_CHAINED flag of its parent element is true
// Basically, this flag is true only when the reference chain from the top element to current element is not broken
$zval[self::IS_REF_CHAINED] = true;
}
$propertyValues[] = $zval;
}
return $propertyValues;
} | [
"private",
"function",
"readPropertiesUntil",
"(",
"$",
"zval",
",",
"PropertyPathInterface",
"$",
"propertyPath",
",",
"$",
"lastIndex",
",",
"$",
"ignoreInvalidIndices",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"\\",
"is_object",
"(",
"$",
"zval",
"[",
"self... | Reads the path from an object up to a given path index.
@param array $zval The array containing the object or array to read from
@param PropertyPathInterface $propertyPath The property path to read
@param int $lastIndex The index up to which should be read
@param bool $ignoreInvalidIndices Whether to ignore invalid indices or throw an exception
@return array The values read in the path
@throws UnexpectedTypeException if a value within the path is neither object nor array
@throws NoSuchIndexException If a non-existing index is accessed | [
"Reads",
"the",
"path",
"from",
"an",
"object",
"up",
"to",
"a",
"given",
"path",
"index",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L276-L339 | train | Read all properties until the last index | [
30522,
2797,
3853,
3191,
21572,
4842,
7368,
16671,
4014,
1006,
1002,
1062,
10175,
1010,
3200,
15069,
18447,
2121,
12172,
1002,
3200,
15069,
1010,
1002,
2197,
22254,
10288,
1010,
1002,
8568,
2378,
10175,
28173,
16089,
9623,
1027,
2995,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php | TransformsRequest.cleanArray | protected function cleanArray(array $data, $keyPrefix = '')
{
return collect($data)->map(function ($value, $key) use ($keyPrefix) {
return $this->cleanValue($keyPrefix.$key, $value);
})->all();
} | php | protected function cleanArray(array $data, $keyPrefix = '')
{
return collect($data)->map(function ($value, $key) use ($keyPrefix) {
return $this->cleanValue($keyPrefix.$key, $value);
})->all();
} | [
"protected",
"function",
"cleanArray",
"(",
"array",
"$",
"data",
",",
"$",
"keyPrefix",
"=",
"''",
")",
"{",
"return",
"collect",
"(",
"$",
"data",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"use",
"(",
"$",
"keyPr... | Clean the data in the given array.
@param array $data
@param string $keyPrefix
@return array | [
"Clean",
"the",
"data",
"in",
"the",
"given",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php#L59-L64 | train | Clean an array of values | [
30522,
5123,
3853,
4550,
2906,
9447,
1006,
9140,
1002,
2951,
1010,
1002,
3145,
28139,
8873,
2595,
1027,
1005,
1005,
1007,
1063,
2709,
8145,
1006,
1002,
2951,
1007,
1011,
1028,
4949,
1006,
3853,
1006,
1002,
3643,
1010,
1002,
3145,
1007,
22... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Mime/MimeTypes.php | MimeTypes.isGuesserSupported | public function isGuesserSupported(): bool
{
foreach ($this->guessers as $guesser) {
if ($guesser->isGuesserSupported()) {
return true;
}
}
return false;
} | php | public function isGuesserSupported(): bool
{
foreach ($this->guessers as $guesser) {
if ($guesser->isGuesserSupported()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isGuesserSupported",
"(",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"guessers",
"as",
"$",
"guesser",
")",
"{",
"if",
"(",
"$",
"guesser",
"->",
"isGuesserSupported",
"(",
")",
")",
"{",
"return",
"true",
";",
"}"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/MimeTypes.php#L110-L119 | train | Returns true if the guesser is supported. | [
30522,
2270,
3853,
2003,
22967,
8043,
6342,
9397,
15613,
1006,
1007,
1024,
22017,
2140,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
3984,
2545,
2004,
1002,
3984,
2121,
1007,
1063,
2065,
1006,
1002,
3984,
2121,
1011,
1028,
2003,
22967,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
php-ai/php-ml | src/Classification/DecisionTree.php | DecisionTree.getSplitNodesByColumn | protected function getSplitNodesByColumn(int $column, DecisionTreeLeaf $node): array
{
if ($node->isTerminal) {
return [];
}
$nodes = [];
if ($node->columnIndex === $column) {
$nodes[] = $node;
}
$lNodes = [];
$rNodes = [];
if ($node->leftLeaf !== null) {
$lNodes = $this->getSplitNodesByColumn($column, $node->leftLeaf);
}
if ($node->rightLeaf !== null) {
$rNodes = $this->getSplitNodesByColumn($column, $node->rightLeaf);
}
return array_merge($nodes, $lNodes, $rNodes);
} | php | protected function getSplitNodesByColumn(int $column, DecisionTreeLeaf $node): array
{
if ($node->isTerminal) {
return [];
}
$nodes = [];
if ($node->columnIndex === $column) {
$nodes[] = $node;
}
$lNodes = [];
$rNodes = [];
if ($node->leftLeaf !== null) {
$lNodes = $this->getSplitNodesByColumn($column, $node->leftLeaf);
}
if ($node->rightLeaf !== null) {
$rNodes = $this->getSplitNodesByColumn($column, $node->rightLeaf);
}
return array_merge($nodes, $lNodes, $rNodes);
} | [
"protected",
"function",
"getSplitNodesByColumn",
"(",
"int",
"$",
"column",
",",
"DecisionTreeLeaf",
"$",
"node",
")",
":",
"array",
"{",
"if",
"(",
"$",
"node",
"->",
"isTerminal",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"nodes",
"=",
"[",
"]",
... | Collects and returns an array of internal nodes that use the given
column as a split criterion | [
"Collects",
"and",
"returns",
"an",
"array",
"of",
"internal",
"nodes",
"that",
"use",
"the",
"given",
"column",
"as",
"a",
"split",
"criterion"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/DecisionTree.php#L440-L462 | train | Returns the split nodes by a given column | [
30522,
5123,
3853,
4152,
24759,
4183,
3630,
6155,
3762,
25778,
2819,
2078,
1006,
20014,
1002,
5930,
1010,
3247,
13334,
19213,
1002,
13045,
1007,
1024,
9140,
1063,
2065,
1006,
1002,
13045,
1011,
1028,
21541,
2121,
22311,
2140,
1007,
1063,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Sqlite.php | Zend_Cache_Backend_Sqlite.touch | public function touch($id, $extraLifetime)
{
$sql = "SELECT expire FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
$res = $this->_query($sql);
if (!$res) {
return false;
}
$expire = @sqlite_fetch_single($res);
$newExpire = $expire + $extraLifetime;
$res = $this->_query("UPDATE cache SET lastModified=" . time() . ", expire=$newExpire WHERE id='$id'");
if ($res) {
return true;
} else {
return false;
}
} | php | public function touch($id, $extraLifetime)
{
$sql = "SELECT expire FROM cache WHERE id='$id' AND (expire=0 OR expire>" . time() . ')';
$res = $this->_query($sql);
if (!$res) {
return false;
}
$expire = @sqlite_fetch_single($res);
$newExpire = $expire + $extraLifetime;
$res = $this->_query("UPDATE cache SET lastModified=" . time() . ", expire=$newExpire WHERE id='$id'");
if ($res) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"touch",
"(",
"$",
"id",
",",
"$",
"extraLifetime",
")",
"{",
"$",
"sql",
"=",
"\"SELECT expire FROM cache WHERE id='$id' AND (expire=0 OR expire>\"",
".",
"time",
"(",
")",
".",
"')'",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"_query",
... | Give (if possible) an extra lifetime to the given cache id
@param string $id cache id
@param int $extraLifetime
@return boolean true if ok | [
"Give",
"(",
"if",
"possible",
")",
"an",
"extra",
"lifetime",
"to",
"the",
"given",
"cache",
"id"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Sqlite.php#L425-L440 | train | touch the cache | [
30522,
2270,
3853,
3543,
1006,
1002,
8909,
1010,
1002,
4469,
15509,
7292,
1007,
1063,
1002,
29296,
1027,
1000,
7276,
4654,
20781,
2013,
17053,
2073,
8909,
1027,
1005,
1002,
8909,
1005,
1998,
1006,
4654,
20781,
1027,
1014,
2030,
4654,
20781,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/FontMetrics.php | FontMetrics.getFont | public function getFont($familyRaw, $subtypeRaw = "normal")
{
static $cache = array();
if (isset($cache[$familyRaw][$subtypeRaw])) {
return $cache[$familyRaw][$subtypeRaw];
}
/* Allow calling for various fonts in search path. Therefore not immediately
* return replacement on non match.
* Only when called with NULL try replacement.
* When this is also missing there is really trouble.
* If only the subtype fails, nevertheless return failure.
* Only on checking the fallback font, check various subtypes on same font.
*/
$subtype = strtolower($subtypeRaw);
if ($familyRaw) {
$family = str_replace(array("'", '"'), "", strtolower($familyRaw));
if (isset($this->fontLookup[$family][$subtype])) {
return $cache[$familyRaw][$subtypeRaw] = $this->fontLookup[$family][$subtype];
}
return null;
}
$family = "serif";
if (isset($this->fontLookup[$family][$subtype])) {
return $cache[$familyRaw][$subtypeRaw] = $this->fontLookup[$family][$subtype];
}
if (!isset($this->fontLookup[$family])) {
return null;
}
$family = $this->fontLookup[$family];
foreach ($family as $sub => $font) {
if (strpos($subtype, $sub) !== false) {
return $cache[$familyRaw][$subtypeRaw] = $font;
}
}
if ($subtype !== "normal") {
foreach ($family as $sub => $font) {
if ($sub !== "normal") {
return $cache[$familyRaw][$subtypeRaw] = $font;
}
}
}
$subtype = "normal";
if (isset($family[$subtype])) {
return $cache[$familyRaw][$subtypeRaw] = $family[$subtype];
}
return null;
} | php | public function getFont($familyRaw, $subtypeRaw = "normal")
{
static $cache = array();
if (isset($cache[$familyRaw][$subtypeRaw])) {
return $cache[$familyRaw][$subtypeRaw];
}
/* Allow calling for various fonts in search path. Therefore not immediately
* return replacement on non match.
* Only when called with NULL try replacement.
* When this is also missing there is really trouble.
* If only the subtype fails, nevertheless return failure.
* Only on checking the fallback font, check various subtypes on same font.
*/
$subtype = strtolower($subtypeRaw);
if ($familyRaw) {
$family = str_replace(array("'", '"'), "", strtolower($familyRaw));
if (isset($this->fontLookup[$family][$subtype])) {
return $cache[$familyRaw][$subtypeRaw] = $this->fontLookup[$family][$subtype];
}
return null;
}
$family = "serif";
if (isset($this->fontLookup[$family][$subtype])) {
return $cache[$familyRaw][$subtypeRaw] = $this->fontLookup[$family][$subtype];
}
if (!isset($this->fontLookup[$family])) {
return null;
}
$family = $this->fontLookup[$family];
foreach ($family as $sub => $font) {
if (strpos($subtype, $sub) !== false) {
return $cache[$familyRaw][$subtypeRaw] = $font;
}
}
if ($subtype !== "normal") {
foreach ($family as $sub => $font) {
if ($sub !== "normal") {
return $cache[$familyRaw][$subtypeRaw] = $font;
}
}
}
$subtype = "normal";
if (isset($family[$subtype])) {
return $cache[$familyRaw][$subtypeRaw] = $family[$subtype];
}
return null;
} | [
"public",
"function",
"getFont",
"(",
"$",
"familyRaw",
",",
"$",
"subtypeRaw",
"=",
"\"normal\"",
")",
"{",
"static",
"$",
"cache",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
"$",
"familyRaw",
"]",
"[",
"$",
"subtypeRaw... | Resolves a font family & subtype into an actual font file
Subtype can be one of 'normal', 'bold', 'italic' or 'bold_italic'. If
the particular font family has no suitable font file, the default font
({@link Options::defaultFont}) is used. The font file returned
is the absolute pathname to the font file on the system.
@param string $familyRaw
@param string $subtypeRaw
@return string | [
"Resolves",
"a",
"font",
"family",
"&",
"subtype",
"into",
"an",
"actual",
"font",
"file",
"Subtype",
"can",
"be",
"one",
"of",
"normal",
"bold",
"italic",
"or",
"bold_italic",
".",
"If",
"the",
"particular",
"font",
"family",
"has",
"no",
"suitable",
"fon... | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FontMetrics.php#L336-L397 | train | Returns font object | [
30522,
2270,
3853,
2131,
14876,
3372,
1006,
1002,
2155,
2527,
2860,
1010,
1002,
4942,
13874,
2527,
2860,
1027,
1000,
3671,
1000,
1007,
1063,
10763,
1002,
17053,
1027,
9140,
1006,
1007,
1025,
2065,
1006,
26354,
3388,
1006,
1002,
17053,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Cache.php | Cache.getCacheWebsiteAttributes | public static function getCacheWebsiteAttributes($idSite)
{
if ('all' == $idSite) {
return array();
}
$idSite = (int) $idSite;
if ($idSite <= 0) {
return array();
}
$cache = self::getCache();
$cacheId = $idSite;
$cacheContent = $cache->fetch($cacheId);
if (false !== $cacheContent) {
return $cacheContent;
}
Tracker::initCorePiwikInTrackerMode();
$content = array();
Access::doAsSuperUser(function () use (&$content, $idSite) {
/**
* Triggered to get the attributes of a site entity that might be used by the
* Tracker.
*
* Plugins add new site attributes for use in other tracking events must
* use this event to put those attributes in the Tracker Cache.
*
* **Example**
*
* public function getSiteAttributes($content, $idSite)
* {
* $sql = "SELECT info FROM " . Common::prefixTable('myplugin_extra_site_info') . " WHERE idsite = ?";
* $content['myplugin_site_data'] = Db::fetchOne($sql, array($idSite));
* }
*
* @param array &$content Array mapping of site attribute names with values.
* @param int $idSite The site ID to get attributes for.
*/
Piwik::postEvent('Tracker.Cache.getSiteAttributes', array(&$content, $idSite));
Common::printDebug("Website $idSite tracker cache was re-created.");
});
// if nothing is returned from the plugins, we don't save the content
// this is not expected: all websites are expected to have at least one URL
if (!empty($content)) {
$cache->save($cacheId, $content, self::getTtl());
}
Tracker::restoreTrackerPlugins();
return $content;
} | php | public static function getCacheWebsiteAttributes($idSite)
{
if ('all' == $idSite) {
return array();
}
$idSite = (int) $idSite;
if ($idSite <= 0) {
return array();
}
$cache = self::getCache();
$cacheId = $idSite;
$cacheContent = $cache->fetch($cacheId);
if (false !== $cacheContent) {
return $cacheContent;
}
Tracker::initCorePiwikInTrackerMode();
$content = array();
Access::doAsSuperUser(function () use (&$content, $idSite) {
/**
* Triggered to get the attributes of a site entity that might be used by the
* Tracker.
*
* Plugins add new site attributes for use in other tracking events must
* use this event to put those attributes in the Tracker Cache.
*
* **Example**
*
* public function getSiteAttributes($content, $idSite)
* {
* $sql = "SELECT info FROM " . Common::prefixTable('myplugin_extra_site_info') . " WHERE idsite = ?";
* $content['myplugin_site_data'] = Db::fetchOne($sql, array($idSite));
* }
*
* @param array &$content Array mapping of site attribute names with values.
* @param int $idSite The site ID to get attributes for.
*/
Piwik::postEvent('Tracker.Cache.getSiteAttributes', array(&$content, $idSite));
Common::printDebug("Website $idSite tracker cache was re-created.");
});
// if nothing is returned from the plugins, we don't save the content
// this is not expected: all websites are expected to have at least one URL
if (!empty($content)) {
$cache->save($cacheId, $content, self::getTtl());
}
Tracker::restoreTrackerPlugins();
return $content;
} | [
"public",
"static",
"function",
"getCacheWebsiteAttributes",
"(",
"$",
"idSite",
")",
"{",
"if",
"(",
"'all'",
"==",
"$",
"idSite",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"idSite",
"=",
"(",
"int",
")",
"$",
"idSite",
";",
"if",
"(",
... | Returns array containing data about the website: goals, URLs, etc.
@param int $idSite
@return array | [
"Returns",
"array",
"containing",
"data",
"about",
"the",
"website",
":",
"goals",
"URLs",
"etc",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Cache.php#L57-L111 | train | Get the cache website attributes | [
30522,
2270,
10763,
3853,
2131,
3540,
5403,
8545,
5910,
4221,
19321,
3089,
8569,
4570,
1006,
1002,
8909,
28032,
2063,
1007,
1063,
30524,
1002,
8909,
28032,
2063,
1007,
1063,
2709,
9140,
1006,
1007,
1025,
1065,
1002,
8909,
28032,
2063,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/controllers/Updates.php | Updates.onForceUpdate | public function onForceUpdate()
{
try {
$manager = UpdateManager::instance();
$result = $manager->requestUpdateList(true);
$coreHash = array_get($result, 'core.hash', false);
$coreBuild = array_get($result, 'core.build', false);
$core = [$coreHash, $coreBuild];
$plugins = [];
$pluginList = array_get($result, 'plugins', []);
foreach ($pluginList as $code => $plugin) {
$plugins[$code] = array_get($plugin, 'hash', null);
}
$themes = [];
$themeList = array_get($result, 'themes', []);
foreach ($themeList as $code => $theme) {
$themes[$code] = array_get($theme, 'hash', null);
}
/*
* Update steps
*/
$updateSteps = $this->buildUpdateSteps($core, $plugins, $themes, false);
/*
* Finish up
*/
$updateSteps[] = [
'code' => 'completeUpdate',
'label' => Lang::get('system::lang.updates.update_completing'),
];
$this->vars['updateSteps'] = $updateSteps;
}
catch (Exception $ex) {
$this->handleError($ex);
}
return $this->makePartial('execute');
} | php | public function onForceUpdate()
{
try {
$manager = UpdateManager::instance();
$result = $manager->requestUpdateList(true);
$coreHash = array_get($result, 'core.hash', false);
$coreBuild = array_get($result, 'core.build', false);
$core = [$coreHash, $coreBuild];
$plugins = [];
$pluginList = array_get($result, 'plugins', []);
foreach ($pluginList as $code => $plugin) {
$plugins[$code] = array_get($plugin, 'hash', null);
}
$themes = [];
$themeList = array_get($result, 'themes', []);
foreach ($themeList as $code => $theme) {
$themes[$code] = array_get($theme, 'hash', null);
}
/*
* Update steps
*/
$updateSteps = $this->buildUpdateSteps($core, $plugins, $themes, false);
/*
* Finish up
*/
$updateSteps[] = [
'code' => 'completeUpdate',
'label' => Lang::get('system::lang.updates.update_completing'),
];
$this->vars['updateSteps'] = $updateSteps;
}
catch (Exception $ex) {
$this->handleError($ex);
}
return $this->makePartial('execute');
} | [
"public",
"function",
"onForceUpdate",
"(",
")",
"{",
"try",
"{",
"$",
"manager",
"=",
"UpdateManager",
"::",
"instance",
"(",
")",
";",
"$",
"result",
"=",
"$",
"manager",
"->",
"requestUpdateList",
"(",
"true",
")",
";",
"$",
"coreHash",
"=",
"array_ge... | Contacts the update server for a list of necessary updates. | [
"Contacts",
"the",
"update",
"server",
"for",
"a",
"list",
"of",
"necessary",
"updates",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/controllers/Updates.php#L417-L459 | train | Force update action | [
30522,
2270,
3853,
2006,
14821,
6279,
13701,
1006,
1007,
1063,
3046,
1063,
1002,
3208,
1027,
10651,
24805,
4590,
1024,
1024,
6013,
1006,
1007,
1025,
1002,
2765,
1027,
1002,
3208,
1011,
1028,
5227,
6279,
13701,
9863,
1006,
2995,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Protocols/Http.php | Http.sessionStart | public static function sessionStart()
{
if (PHP_SAPI != 'cli') {
return session_start();
}
self::tryGcSessions();
if (HttpCache::$instance->sessionStarted) {
Worker::safeEcho("already sessionStarted\n");
return true;
}
HttpCache::$instance->sessionStarted = true;
// Generate a SID.
if (!isset($_COOKIE[HttpCache::$sessionName]) || !is_file(HttpCache::$sessionPath . '/ses_' . $_COOKIE[HttpCache::$sessionName])) {
// Create a unique session_id and the associated file name.
while (true) {
$session_id = static::sessionCreateId();
if (!is_file($file_name = HttpCache::$sessionPath . '/ses_' . $session_id)) break;
}
HttpCache::$instance->sessionFile = $file_name;
return self::setcookie(
HttpCache::$sessionName
, $session_id
, ini_get('session.cookie_lifetime')
, ini_get('session.cookie_path')
, ini_get('session.cookie_domain')
, ini_get('session.cookie_secure')
, ini_get('session.cookie_httponly')
);
}
if (!HttpCache::$instance->sessionFile) {
HttpCache::$instance->sessionFile = HttpCache::$sessionPath . '/ses_' . $_COOKIE[HttpCache::$sessionName];
}
// Read session from session file.
if (HttpCache::$instance->sessionFile) {
$raw = file_get_contents(HttpCache::$instance->sessionFile);
if ($raw) {
$_SESSION = unserialize($raw);
}
}
return true;
} | php | public static function sessionStart()
{
if (PHP_SAPI != 'cli') {
return session_start();
}
self::tryGcSessions();
if (HttpCache::$instance->sessionStarted) {
Worker::safeEcho("already sessionStarted\n");
return true;
}
HttpCache::$instance->sessionStarted = true;
// Generate a SID.
if (!isset($_COOKIE[HttpCache::$sessionName]) || !is_file(HttpCache::$sessionPath . '/ses_' . $_COOKIE[HttpCache::$sessionName])) {
// Create a unique session_id and the associated file name.
while (true) {
$session_id = static::sessionCreateId();
if (!is_file($file_name = HttpCache::$sessionPath . '/ses_' . $session_id)) break;
}
HttpCache::$instance->sessionFile = $file_name;
return self::setcookie(
HttpCache::$sessionName
, $session_id
, ini_get('session.cookie_lifetime')
, ini_get('session.cookie_path')
, ini_get('session.cookie_domain')
, ini_get('session.cookie_secure')
, ini_get('session.cookie_httponly')
);
}
if (!HttpCache::$instance->sessionFile) {
HttpCache::$instance->sessionFile = HttpCache::$sessionPath . '/ses_' . $_COOKIE[HttpCache::$sessionName];
}
// Read session from session file.
if (HttpCache::$instance->sessionFile) {
$raw = file_get_contents(HttpCache::$instance->sessionFile);
if ($raw) {
$_SESSION = unserialize($raw);
}
}
return true;
} | [
"public",
"static",
"function",
"sessionStart",
"(",
")",
"{",
"if",
"(",
"PHP_SAPI",
"!=",
"'cli'",
")",
"{",
"return",
"session_start",
"(",
")",
";",
"}",
"self",
"::",
"tryGcSessions",
"(",
")",
";",
"if",
"(",
"HttpCache",
"::",
"$",
"instance",
"... | sessionStart
@return bool | [
"sessionStart"
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Http.php#L444-L486 | train | Start session. | [
30522,
2270,
10763,
3853,
6521,
7559,
2102,
1006,
1007,
1063,
2065,
1006,
25718,
1035,
20066,
2072,
999,
1027,
1005,
18856,
2072,
1005,
1007,
1063,
2709,
5219,
1035,
2707,
1006,
1007,
1025,
1065,
2969,
1024,
1024,
3046,
18195,
8583,
27466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.validateMimes | public function validateMimes($attribute, $value, $parameters)
{
if (! $this->isValidFileInstance($value)) {
return false;
}
if ($this->shouldBlockPhpUpload($value, $parameters)) {
return false;
}
return $value->getPath() !== '' && in_array($value->guessExtension(), $parameters);
} | php | public function validateMimes($attribute, $value, $parameters)
{
if (! $this->isValidFileInstance($value)) {
return false;
}
if ($this->shouldBlockPhpUpload($value, $parameters)) {
return false;
}
return $value->getPath() !== '' && in_array($value->guessExtension(), $parameters);
} | [
"public",
"function",
"validateMimes",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidFileInstance",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$"... | Validate the guessed extension of a file upload is in a set of file extensions.
@param string $attribute
@param mixed $value
@param array $parameters
@return bool | [
"Validate",
"the",
"guessed",
"extension",
"of",
"a",
"file",
"upload",
"is",
"in",
"a",
"set",
"of",
"file",
"extensions",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L1133-L1144 | train | Validate the file extension | [
30522,
2270,
3853,
9398,
3686,
4328,
7834,
1006,
1002,
17961,
1010,
1002,
3643,
1010,
1002,
11709,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2003,
10175,
3593,
8873,
19856,
12693,
3401,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Config/Writer/Yaml.php | Zend_Config_Writer_Yaml._encodeYaml | protected static function _encodeYaml($indent, $data)
{
reset($data);
$result = "";
$numeric = is_numeric(key($data));
foreach($data as $key => $value) {
if(is_array($value)) {
$encoded = "\n".self::_encodeYaml($indent+1, $value);
} else {
$encoded = (string)$value."\n";
}
$result .= str_repeat(" ", $indent).($numeric?"- ":"$key: ").$encoded;
}
return $result;
} | php | protected static function _encodeYaml($indent, $data)
{
reset($data);
$result = "";
$numeric = is_numeric(key($data));
foreach($data as $key => $value) {
if(is_array($value)) {
$encoded = "\n".self::_encodeYaml($indent+1, $value);
} else {
$encoded = (string)$value."\n";
}
$result .= str_repeat(" ", $indent).($numeric?"- ":"$key: ").$encoded;
}
return $result;
} | [
"protected",
"static",
"function",
"_encodeYaml",
"(",
"$",
"indent",
",",
"$",
"data",
")",
"{",
"reset",
"(",
"$",
"data",
")",
";",
"$",
"result",
"=",
"\"\"",
";",
"$",
"numeric",
"=",
"is_numeric",
"(",
"key",
"(",
"$",
"data",
")",
")",
";",
... | Service function for encoding YAML
@param int $indent Current indent level
@param array $data Data to encode
@return string | [
"Service",
"function",
"for",
"encoding",
"YAML"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer/Yaml.php#L128-L143 | train | Encode the array to YAML format | [
30522,
5123,
10763,
3853,
1035,
4372,
16044,
14852,
2140,
1006,
1002,
27427,
4765,
1010,
1002,
2951,
1007,
1063,
25141,
1006,
1002,
2951,
1007,
1025,
1002,
2765,
1027,
1000,
1000,
1025,
1002,
30524,
2969,
1024,
1024,
1035,
4372,
16044,
1485... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php | ThumbnailImageMedium.bubble | protected function bubble($method, array $arguments = [], $testLinked = true)
{
if (!$testLinked || $this->linked) {
return $this->parent ? call_user_func_array(array($this->parent, $method), $arguments) : $this;
}
return call_user_func_array(array($this, 'parent::' . $method), $arguments);
} | php | protected function bubble($method, array $arguments = [], $testLinked = true)
{
if (!$testLinked || $this->linked) {
return $this->parent ? call_user_func_array(array($this->parent, $method), $arguments) : $this;
}
return call_user_func_array(array($this, 'parent::' . $method), $arguments);
} | [
"protected",
"function",
"bubble",
"(",
"$",
"method",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
",",
"$",
"testLinked",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"testLinked",
"||",
"$",
"this",
"->",
"linked",
")",
"{",
"return",
"$",
"thi... | Bubble a function call up to either the superclass function or the parent Medium instance
@param string $method
@param array $arguments
@param bool $testLinked
@return Medium | [
"Bubble",
"a",
"function",
"call",
"up",
"to",
"either",
"the",
"superclass",
"function",
"or",
"the",
"parent",
"Medium",
"instance"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php#L124-L131 | train | Bubble the method to the parent class | [
30522,
5123,
3853,
11957,
1006,
1002,
4118,
1010,
9140,
1002,
9918,
1027,
1031,
1033,
1010,
1002,
3231,
13767,
2098,
1027,
2995,
1007,
1063,
2065,
1006,
999,
1002,
3231,
13767,
2098,
1064,
1064,
1002,
2023,
1011,
1028,
5799,
1007,
1063,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Worker.php | Worker.acceptUdpConnection | public function acceptUdpConnection($socket)
{
set_error_handler(function(){});
$recv_buffer = stream_socket_recvfrom($socket, static::MAX_UDP_PACKAGE_SIZE, 0, $remote_address);
restore_error_handler();
if (false === $recv_buffer || empty($remote_address)) {
return false;
}
// UdpConnection.
$connection = new UdpConnection($socket, $remote_address);
$connection->protocol = $this->protocol;
if ($this->onMessage) {
try {
if ($this->protocol !== null) {
/** @var \Workerman\Protocols\ProtocolInterface $parser */
$parser = $this->protocol;
if(method_exists($parser,'input')){
while($recv_buffer !== ''){
$len = $parser::input($recv_buffer, $connection);
if($len == 0)
return true;
$package = substr($recv_buffer,0,$len);
$recv_buffer = substr($recv_buffer,$len);
$data = $parser::decode($package,$connection);
if ($data === false)
continue;
call_user_func($this->onMessage, $connection, $data);
}
}else{
$data = $parser::decode($recv_buffer, $connection);
// Discard bad packets.
if ($data === false)
return true;
call_user_func($this->onMessage, $connection, $data);
}
}else{
call_user_func($this->onMessage, $connection, $recv_buffer);
}
ConnectionInterface::$statistics['total_request']++;
} catch (\Exception $e) {
static::log($e);
exit(250);
} catch (\Error $e) {
static::log($e);
exit(250);
}
}
return true;
} | php | public function acceptUdpConnection($socket)
{
set_error_handler(function(){});
$recv_buffer = stream_socket_recvfrom($socket, static::MAX_UDP_PACKAGE_SIZE, 0, $remote_address);
restore_error_handler();
if (false === $recv_buffer || empty($remote_address)) {
return false;
}
// UdpConnection.
$connection = new UdpConnection($socket, $remote_address);
$connection->protocol = $this->protocol;
if ($this->onMessage) {
try {
if ($this->protocol !== null) {
/** @var \Workerman\Protocols\ProtocolInterface $parser */
$parser = $this->protocol;
if(method_exists($parser,'input')){
while($recv_buffer !== ''){
$len = $parser::input($recv_buffer, $connection);
if($len == 0)
return true;
$package = substr($recv_buffer,0,$len);
$recv_buffer = substr($recv_buffer,$len);
$data = $parser::decode($package,$connection);
if ($data === false)
continue;
call_user_func($this->onMessage, $connection, $data);
}
}else{
$data = $parser::decode($recv_buffer, $connection);
// Discard bad packets.
if ($data === false)
return true;
call_user_func($this->onMessage, $connection, $data);
}
}else{
call_user_func($this->onMessage, $connection, $recv_buffer);
}
ConnectionInterface::$statistics['total_request']++;
} catch (\Exception $e) {
static::log($e);
exit(250);
} catch (\Error $e) {
static::log($e);
exit(250);
}
}
return true;
} | [
"public",
"function",
"acceptUdpConnection",
"(",
"$",
"socket",
")",
"{",
"set_error_handler",
"(",
"function",
"(",
")",
"{",
"}",
")",
";",
"$",
"recv_buffer",
"=",
"stream_socket_recvfrom",
"(",
"$",
"socket",
",",
"static",
"::",
"MAX_UDP_PACKAGE_SIZE",
"... | For udp package.
@param resource $socket
@return bool | [
"For",
"udp",
"package",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L2441-L2489 | train | Accept UDP Connection | [
30522,
2270,
3853,
5138,
6784,
15042,
18256,
7542,
1006,
1002,
22278,
1007,
1063,
2275,
1035,
7561,
1035,
28213,
1006,
3853,
1006,
1007,
1063,
1065,
1007,
1025,
1002,
28667,
2615,
1035,
17698,
1027,
5460,
1035,
22278,
1035,
28667,
30524,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Http.php | Http.truncateStr | private static function truncateStr($str, $limit)
{
if (strlen($str) > $limit) {
return substr($str, 0, $limit) . '...';
}
return $str;
} | php | private static function truncateStr($str, $limit)
{
if (strlen($str) > $limit) {
return substr($str, 0, $limit) . '...';
}
return $str;
} | [
"private",
"static",
"function",
"truncateStr",
"(",
"$",
"str",
",",
"$",
"limit",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"str",
")",
">",
"$",
"limit",
")",
"{",
"return",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"$",
"limit",
")",
".",
"'... | Utility function that truncates a string to an arbitrary limit.
@param string $str The string to truncate.
@param int $limit The maximum length of the truncated string.
@return string | [
"Utility",
"function",
"that",
"truncates",
"a",
"string",
"to",
"an",
"arbitrary",
"limit",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Http.php#L859-L865 | train | Truncates a string to a maximum length | [
30522,
2797,
10763,
3853,
19817,
4609,
16280,
3367,
2099,
1006,
1002,
2358,
2099,
1010,
1002,
5787,
1007,
1063,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
2358,
2099,
1007,
1028,
1002,
5787,
1007,
1063,
2709,
4942,
3367,
2099,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Libmemcached.php | Zend_Cache_Backend_Libmemcached.save | public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
// ZF-8856: using set because add needs a second request if item already exists
$result = @$this->_memcache->set($id, array($data, time(), $lifetime), $lifetime);
if ($result === false) {
$rsCode = $this->_memcache->getResultCode();
$rsMsg = $this->_memcache->getResultMessage();
$this->_log("Memcached::set() failed: [{$rsCode}] {$rsMsg}");
}
if (count($tags) > 0) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
}
return $result;
} | php | public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
// ZF-8856: using set because add needs a second request if item already exists
$result = @$this->_memcache->set($id, array($data, time(), $lifetime), $lifetime);
if ($result === false) {
$rsCode = $this->_memcache->getResultCode();
$rsMsg = $this->_memcache->getResultMessage();
$this->_log("Memcached::set() failed: [{$rsCode}] {$rsMsg}");
}
if (count($tags) > 0) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_LIBMEMCACHED_BACKEND);
}
return $result;
} | [
"public",
"function",
"save",
"(",
"$",
"data",
",",
"$",
"id",
",",
"$",
"tags",
"=",
"array",
"(",
")",
",",
"$",
"specificLifetime",
"=",
"false",
")",
"{",
"$",
"lifetime",
"=",
"$",
"this",
"->",
"getLifetime",
"(",
"$",
"specificLifetime",
")",... | Save some string datas into a cache record
Note : $data is always "string" (serialization is done by the
core not by the backend)
@param string $data Datas to cache
@param string $id Cache id
@param array $tags Array of strings, the cache record will be tagged by each string entry
@param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
@return boolean True if no problem | [
"Save",
"some",
"string",
"datas",
"into",
"a",
"cache",
"record"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Libmemcached.php#L200-L217 | train | Save data into cache | [
30522,
2270,
3853,
3828,
1006,
1002,
2951,
1010,
1002,
8909,
1010,
1002,
22073,
1027,
9140,
1006,
1007,
1010,
1002,
3563,
15509,
7292,
1027,
6270,
1007,
1063,
1002,
6480,
1027,
1002,
2023,
1011,
1028,
2131,
15509,
7292,
1006,
1002,
3563,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/Abstract.php | Zend_Validate_Abstract.getTranslator | public function getTranslator()
{
if ($this->translatorIsDisabled()) {
return null;
}
if (null === $this->_translator) {
return self::getDefaultTranslator();
}
return $this->_translator;
} | php | public function getTranslator()
{
if ($this->translatorIsDisabled()) {
return null;
}
if (null === $this->_translator) {
return self::getDefaultTranslator();
}
return $this->_translator;
} | [
"public",
"function",
"getTranslator",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"translatorIsDisabled",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"_translator",
")",
"{",
"return",
"self",
"::",
... | Return translation object
@return Zend_Translate_Adapter|null | [
"Return",
"translation",
"object"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Abstract.php#L342-L353 | train | Returns the current translator | [
30522,
2270,
3853,
2131,
6494,
3619,
20051,
2953,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11403,
2483,
10521,
3085,
2094,
1006,
1007,
1007,
1063,
2709,
19701,
1025,
1065,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field/Text.php | Text.datalist | public function datalist($entries = [])
{
$this->defaultAttribute('list', "list-{$this->id}");
$datalist = "<datalist id=\"list-{$this->id}\">";
foreach ($entries as $k => $v) {
$datalist .= "<option value=\"{$k}\">{$v}</option>";
}
$datalist .= '</datalist>';
return $this->append($datalist);
} | php | public function datalist($entries = [])
{
$this->defaultAttribute('list', "list-{$this->id}");
$datalist = "<datalist id=\"list-{$this->id}\">";
foreach ($entries as $k => $v) {
$datalist .= "<option value=\"{$k}\">{$v}</option>";
}
$datalist .= '</datalist>';
return $this->append($datalist);
} | [
"public",
"function",
"datalist",
"(",
"$",
"entries",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"defaultAttribute",
"(",
"'list'",
",",
"\"list-{$this->id}\"",
")",
";",
"$",
"datalist",
"=",
"\"<datalist id=\\\"list-{$this->id}\\\">\"",
";",
"foreach",
"(",
... | Add datalist element to Text input.
@param array $entries
@return $this | [
"Add",
"datalist",
"element",
"to",
"Text",
"input",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/Text.php#L124-L135 | train | Append datalist to the page | [
30522,
2270,
3853,
2951,
9863,
1006,
1002,
10445,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
12398,
19321,
3089,
8569,
2618,
1006,
1005,
2862,
1005,
1010,
1000,
2862,
1011,
1063,
1002,
2023,
1011,
1028,
8909,
1065,
1000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php | ErrorChunk.isLast | public function isLast(): bool
{
$this->didThrow = true;
throw new TransportException($this->errorMessage, 0, $this->error);
} | php | public function isLast(): bool
{
$this->didThrow = true;
throw new TransportException($this->errorMessage, 0, $this->error);
} | [
"public",
"function",
"isLast",
"(",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"didThrow",
"=",
"true",
";",
"throw",
"new",
"TransportException",
"(",
"$",
"this",
"->",
"errorMessage",
",",
"0",
",",
"$",
"this",
"->",
"error",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php#L62-L66 | train | Is this the last entry? | [
30522,
2270,
3853,
25340,
3367,
1006,
1007,
1024,
22017,
2140,
1063,
1002,
2023,
1011,
1028,
2106,
2705,
10524,
1027,
2995,
1025,
5466,
2047,
3665,
10288,
24422,
1006,
1002,
2023,
1011,
1028,
7561,
7834,
3736,
3351,
1010,
1014,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/Common2.php | HTML_Common2.setOption | public static function setOption($nameOrOptions, $value = null)
{
if (is_array($nameOrOptions)) {
foreach ($nameOrOptions as $k => $v) {
self::setOption($k, $v);
}
} else {
$linebreaks = array('win' => "\15\12", 'unix' => "\12", 'mac' => "\15");
if ('linebreak' == $nameOrOptions && isset($linebreaks[$value])) {
$value = $linebreaks[$value];
}
self::$_options[$nameOrOptions] = $value;
}
} | php | public static function setOption($nameOrOptions, $value = null)
{
if (is_array($nameOrOptions)) {
foreach ($nameOrOptions as $k => $v) {
self::setOption($k, $v);
}
} else {
$linebreaks = array('win' => "\15\12", 'unix' => "\12", 'mac' => "\15");
if ('linebreak' == $nameOrOptions && isset($linebreaks[$value])) {
$value = $linebreaks[$value];
}
self::$_options[$nameOrOptions] = $value;
}
} | [
"public",
"static",
"function",
"setOption",
"(",
"$",
"nameOrOptions",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"nameOrOptions",
")",
")",
"{",
"foreach",
"(",
"$",
"nameOrOptions",
"as",
"$",
"k",
"=>",
"$",
"v",
"... | Sets global option(s)
@param string|array Option name or array ('option name' => 'option value')
@param mixed Option value, if first argument is not an array | [
"Sets",
"global",
"option",
"(",
"s",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/Common2.php#L108-L121 | train | Set the options for the current process | [
30522,
2270,
10763,
3853,
2275,
7361,
3508,
1006,
1002,
2171,
14604,
16790,
2015,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2171,
14604,
16790,
2015,
1007,
1007,
1063,
18921,
6776,
1006,
1002,
2171... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/View.php | View.render | public function render()
{
try {
$this->currentModule = Piwik::getModule();
$this->currentAction = Piwik::getAction();
$this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
$this->token_auth = Piwik::getCurrentUserTokenAuth();
$this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$this->userIsAnonymous = Piwik::isUserIsAnonymous();
$this->userIsSuperUser = Piwik::hasUserSuperUserAccess();
$this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
$this->showUpdateNotificationToUser = !SettingsPiwik::isShowUpdateNotificationToSuperUsersOnlyEnabled() || Piwik::hasUserSuperUserAccess();
$this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
$this->isWidget = Common::getRequestVar('widget', 0, 'int');
$this->isMultiServerEnvironment = SettingsPiwik::isMultiServerEnvironment();
$this->isInternetEnabled = SettingsPiwik::isInternetEnabled();
$this->shouldPropagateTokenAuth = $this->shouldPropagateTokenAuthInAjaxRequests();
$piwikAds = StaticContainer::get('Piwik\ProfessionalServices\Advertising');
$this->areAdsForProfessionalServicesEnabled = $piwikAds->areAdsForProfessionalServicesEnabled();
if (Development::isEnabled()) {
$cacheBuster = rand(0, 10000);
} else {
$cacheBuster = UIAssetCacheBuster::getInstance()->piwikVersionBasedCacheBuster();
}
$this->cacheBuster = $cacheBuster;
$this->loginModule = Piwik::getLoginPluginName();
$user = APIUsersManager::getInstance()->getUser($this->userLogin);
$this->userAlias = $user['alias'];
} catch (Exception $e) {
Log::debug($e);
// can fail, for example at installation (no plugin loaded yet)
}
ProxyHttp::overrideCacheControlHeaders('no-store');
Common::sendHeader('Content-Type: ' . $this->contentType);
// always sending this header, sometimes empty, to ensure that Dashboard embed loads
// - when calling sendHeader() multiple times, the last one prevails
if(!empty($this->xFrameOptions)) {
Common::sendHeader('X-Frame-Options: ' . (string)$this->xFrameOptions);
}
return $this->renderTwigTemplate();
} | php | public function render()
{
try {
$this->currentModule = Piwik::getModule();
$this->currentAction = Piwik::getAction();
$this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
$this->token_auth = Piwik::getCurrentUserTokenAuth();
$this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$this->userIsAnonymous = Piwik::isUserIsAnonymous();
$this->userIsSuperUser = Piwik::hasUserSuperUserAccess();
$this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
$this->showUpdateNotificationToUser = !SettingsPiwik::isShowUpdateNotificationToSuperUsersOnlyEnabled() || Piwik::hasUserSuperUserAccess();
$this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
$this->isWidget = Common::getRequestVar('widget', 0, 'int');
$this->isMultiServerEnvironment = SettingsPiwik::isMultiServerEnvironment();
$this->isInternetEnabled = SettingsPiwik::isInternetEnabled();
$this->shouldPropagateTokenAuth = $this->shouldPropagateTokenAuthInAjaxRequests();
$piwikAds = StaticContainer::get('Piwik\ProfessionalServices\Advertising');
$this->areAdsForProfessionalServicesEnabled = $piwikAds->areAdsForProfessionalServicesEnabled();
if (Development::isEnabled()) {
$cacheBuster = rand(0, 10000);
} else {
$cacheBuster = UIAssetCacheBuster::getInstance()->piwikVersionBasedCacheBuster();
}
$this->cacheBuster = $cacheBuster;
$this->loginModule = Piwik::getLoginPluginName();
$user = APIUsersManager::getInstance()->getUser($this->userLogin);
$this->userAlias = $user['alias'];
} catch (Exception $e) {
Log::debug($e);
// can fail, for example at installation (no plugin loaded yet)
}
ProxyHttp::overrideCacheControlHeaders('no-store');
Common::sendHeader('Content-Type: ' . $this->contentType);
// always sending this header, sometimes empty, to ensure that Dashboard embed loads
// - when calling sendHeader() multiple times, the last one prevails
if(!empty($this->xFrameOptions)) {
Common::sendHeader('X-Frame-Options: ' . (string)$this->xFrameOptions);
}
return $this->renderTwigTemplate();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"currentModule",
"=",
"Piwik",
"::",
"getModule",
"(",
")",
";",
"$",
"this",
"->",
"currentAction",
"=",
"Piwik",
"::",
"getAction",
"(",
")",
";",
"$",
"this",
"->",
"url... | Renders the current view. Also sends the stored 'Content-Type' HTML header.
See {@link setContentType()}.
@return string Generated template. | [
"Renders",
"the",
"current",
"view",
".",
"Also",
"sends",
"the",
"stored",
"Content",
"-",
"Type",
"HTML",
"header",
".",
"See",
"{",
"@link",
"setContentType",
"()",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/View.php#L238-L287 | train | renders the page | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
3046,
1063,
1002,
2023,
1011,
1028,
2783,
5302,
8566,
2571,
1027,
14255,
9148,
2243,
1024,
1024,
2131,
5302,
8566,
2571,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
2783,
18908,
3258,
1027,
14255,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/QueueServiceProvider.php | QueueServiceProvider.registerOpisSecurityKey | protected function registerOpisSecurityKey()
{
if (Str::startsWith($key = $this->app['config']->get('app.key'), 'base64:')) {
$key = base64_decode(substr($key, 7));
}
SerializableClosure::setSecretKey($key);
} | php | protected function registerOpisSecurityKey()
{
if (Str::startsWith($key = $this->app['config']->get('app.key'), 'base64:')) {
$key = base64_decode(substr($key, 7));
}
SerializableClosure::setSecretKey($key);
} | [
"protected",
"function",
"registerOpisSecurityKey",
"(",
")",
"{",
"if",
"(",
"Str",
"::",
"startsWith",
"(",
"$",
"key",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'app.key'",
")",
",",
"'base64:'",
")",
")",
"{",
"$",
"... | Configure Opis Closure signing for security.
@return void | [
"Configure",
"Opis",
"Closure",
"signing",
"for",
"security",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/QueueServiceProvider.php#L216-L223 | train | Register Opis Security Key | [
30522,
5123,
3853,
4236,
7361,
23491,
10841,
15780,
14839,
1006,
1007,
1063,
2065,
1006,
2358,
2099,
1024,
1024,
4627,
24415,
1006,
1002,
3145,
1027,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
9530,
8873,
2290,
1005,
1033,
1011,
1028,
2131,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php | IntegerType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'grouping' => false,
// Integer cast rounds towards 0, so do the same when displaying fractions
'rounding_mode' => IntegerToLocalizedStringTransformer::ROUND_DOWN,
'compound' => false,
]);
$resolver->setAllowedValues('rounding_mode', [
IntegerToLocalizedStringTransformer::ROUND_FLOOR,
IntegerToLocalizedStringTransformer::ROUND_DOWN,
IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN,
IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN,
IntegerToLocalizedStringTransformer::ROUND_HALF_UP,
IntegerToLocalizedStringTransformer::ROUND_UP,
IntegerToLocalizedStringTransformer::ROUND_CEILING,
]);
$resolver->setDefined('scale');
$resolver->setAllowedTypes('scale', ['null', 'int']);
$resolver->setDeprecated('scale');
} | php | public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'grouping' => false,
// Integer cast rounds towards 0, so do the same when displaying fractions
'rounding_mode' => IntegerToLocalizedStringTransformer::ROUND_DOWN,
'compound' => false,
]);
$resolver->setAllowedValues('rounding_mode', [
IntegerToLocalizedStringTransformer::ROUND_FLOOR,
IntegerToLocalizedStringTransformer::ROUND_DOWN,
IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN,
IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN,
IntegerToLocalizedStringTransformer::ROUND_HALF_UP,
IntegerToLocalizedStringTransformer::ROUND_UP,
IntegerToLocalizedStringTransformer::ROUND_CEILING,
]);
$resolver->setDefined('scale');
$resolver->setAllowedTypes('scale', ['null', 'int']);
$resolver->setDeprecated('scale');
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setDefaults",
"(",
"[",
"'grouping'",
"=>",
"false",
",",
"// Integer cast rounds towards 0, so do the same when displaying fractions",
"'rounding_mode'",
"=... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/IntegerType.php#L44-L66 | train | Configure the options for the parser | [
30522,
2270,
3853,
9530,
8873,
27390,
8780,
16790,
2015,
1006,
7047,
6072,
4747,
6299,
1002,
10663,
2099,
1007,
1063,
1002,
10663,
2099,
1011,
1028,
2275,
3207,
7011,
11314,
2015,
1006,
1031,
1005,
19765,
1005,
1027,
1028,
6270,
1010,
1013,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php | RequestDataCollector.parseController | protected function parseController($controller)
{
if (\is_string($controller) && false !== strpos($controller, '::')) {
$controller = explode('::', $controller);
}
if (\is_array($controller)) {
try {
$r = new \ReflectionMethod($controller[0], $controller[1]);
return [
'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
'method' => $controller[1],
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
];
} catch (\ReflectionException $e) {
if (\is_callable($controller)) {
// using __call or __callStatic
return [
'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
'method' => $controller[1],
'file' => 'n/a',
'line' => 'n/a',
];
}
}
}
if ($controller instanceof \Closure) {
$r = new \ReflectionFunction($controller);
$controller = [
'class' => $r->getName(),
'method' => null,
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
];
if (false !== strpos($r->name, '{closure}')) {
return $controller;
}
$controller['method'] = $r->name;
if ($class = $r->getClosureScopeClass()) {
$controller['class'] = $class->name;
} else {
return $r->name;
}
return $controller;
}
if (\is_object($controller)) {
$r = new \ReflectionClass($controller);
return [
'class' => $r->getName(),
'method' => null,
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
];
}
return \is_string($controller) ? $controller : 'n/a';
} | php | protected function parseController($controller)
{
if (\is_string($controller) && false !== strpos($controller, '::')) {
$controller = explode('::', $controller);
}
if (\is_array($controller)) {
try {
$r = new \ReflectionMethod($controller[0], $controller[1]);
return [
'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
'method' => $controller[1],
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
];
} catch (\ReflectionException $e) {
if (\is_callable($controller)) {
// using __call or __callStatic
return [
'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
'method' => $controller[1],
'file' => 'n/a',
'line' => 'n/a',
];
}
}
}
if ($controller instanceof \Closure) {
$r = new \ReflectionFunction($controller);
$controller = [
'class' => $r->getName(),
'method' => null,
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
];
if (false !== strpos($r->name, '{closure}')) {
return $controller;
}
$controller['method'] = $r->name;
if ($class = $r->getClosureScopeClass()) {
$controller['class'] = $class->name;
} else {
return $r->name;
}
return $controller;
}
if (\is_object($controller)) {
$r = new \ReflectionClass($controller);
return [
'class' => $r->getName(),
'method' => null,
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
];
}
return \is_string($controller) ? $controller : 'n/a';
} | [
"protected",
"function",
"parseController",
"(",
"$",
"controller",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"controller",
")",
"&&",
"false",
"!==",
"strpos",
"(",
"$",
"controller",
",",
"'::'",
")",
")",
"{",
"$",
"controller",
"=",
"explode"... | Parse a controller.
@param mixed $controller The controller to parse
@return array|string An array of controller data or a simple string | [
"Parse",
"a",
"controller",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php#L398-L463 | train | Parse controller string | [
30522,
5123,
3853,
11968,
3366,
8663,
13181,
10820,
1006,
1002,
11486,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
5164,
1006,
1002,
11486,
1007,
1004,
1004,
6270,
999,
1027,
1027,
2358,
14536,
2891,
1006,
1002,
11486,
1010,
1005,
1024,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Jobs/Job.php | Job.failed | protected function failed($e)
{
$payload = $this->payload();
[$class, $method] = JobName::parse($payload['job']);
if (method_exists($this->instance = $this->resolve($class), 'failed')) {
$this->instance->failed($payload['data'], $e);
}
} | php | protected function failed($e)
{
$payload = $this->payload();
[$class, $method] = JobName::parse($payload['job']);
if (method_exists($this->instance = $this->resolve($class), 'failed')) {
$this->instance->failed($payload['data'], $e);
}
} | [
"protected",
"function",
"failed",
"(",
"$",
"e",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"payload",
"(",
")",
";",
"[",
"$",
"class",
",",
"$",
"method",
"]",
"=",
"JobName",
"::",
"parse",
"(",
"$",
"payload",
"[",
"'job'",
"]",
")",
... | Process an exception that caused the job to fail.
@param \Throwable|null $e
@return void | [
"Process",
"an",
"exception",
"that",
"caused",
"the",
"job",
"to",
"fail",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Jobs/Job.php#L194-L203 | train | Handle failed job | [
30522,
5123,
3853,
3478,
1006,
1002,
1041,
1007,
1063,
1002,
18093,
1027,
1002,
2023,
1011,
1028,
18093,
1006,
1007,
1025,
1031,
1002,
2465,
1010,
1002,
4118,
1033,
1027,
3105,
18442,
1024,
1024,
11968,
3366,
1006,
1002,
18093,
1031,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/Concerns/InteractsWithContentTypes.php | InteractsWithContentTypes.format | public function format($default = 'html')
{
foreach ($this->getAcceptableContentTypes() as $type) {
if ($format = $this->getFormat($type)) {
return $format;
}
}
return $default;
} | php | public function format($default = 'html')
{
foreach ($this->getAcceptableContentTypes() as $type) {
if ($format = $this->getFormat($type)) {
return $format;
}
}
return $default;
} | [
"public",
"function",
"format",
"(",
"$",
"default",
"=",
"'html'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAcceptableContentTypes",
"(",
")",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"format",
"=",
"$",
"this",
"->",
"getFormat",
"(",
"... | Get the data format expected in the response.
@param string $default
@return string | [
"Get",
"the",
"data",
"format",
"expected",
"in",
"the",
"response",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php#L161-L170 | train | Returns the format of the response | [
30522,
2270,
3853,
4289,
1006,
1002,
12398,
1027,
1005,
16129,
1005,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
6305,
3401,
22799,
3468,
8663,
6528,
15353,
10374,
1006,
1007,
2004,
1002,
2828,
1007,
1063,
2065,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/behaviors/ReorderController.php | ReorderController.validateModel | protected function validateModel()
{
$model = $this->controller->reorderGetModel();
$modelTraits = class_uses($model);
if (isset($modelTraits[\October\Rain\Database\Traits\Sortable::class])) {
$this->sortMode = 'simple';
}
elseif (isset($modelTraits[\October\Rain\Database\Traits\NestedTree::class])) {
$this->sortMode = 'nested';
$this->showTree = true;
}
else {
throw new ApplicationException('The model must implement the NestedTree or Sortable traits.');
}
return $model;
} | php | protected function validateModel()
{
$model = $this->controller->reorderGetModel();
$modelTraits = class_uses($model);
if (isset($modelTraits[\October\Rain\Database\Traits\Sortable::class])) {
$this->sortMode = 'simple';
}
elseif (isset($modelTraits[\October\Rain\Database\Traits\NestedTree::class])) {
$this->sortMode = 'nested';
$this->showTree = true;
}
else {
throw new ApplicationException('The model must implement the NestedTree or Sortable traits.');
}
return $model;
} | [
"protected",
"function",
"validateModel",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"controller",
"->",
"reorderGetModel",
"(",
")",
";",
"$",
"modelTraits",
"=",
"class_uses",
"(",
"$",
"model",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"mode... | Validate the supplied form model.
@return void | [
"Validate",
"the",
"supplied",
"form",
"model",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/ReorderController.php#L207-L224 | train | Validate model. | [
30522,
5123,
3853,
9398,
3686,
5302,
9247,
1006,
1007,
1063,
1002,
2944,
1027,
1002,
2023,
1011,
1028,
11486,
1011,
1028,
2128,
8551,
2121,
18150,
5302,
9247,
1006,
1007,
1025,
1002,
2944,
6494,
12762,
1027,
2465,
1035,
3594,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Console/PublishCommand.php | PublishCommand.handle | public function handle()
{
$force = $this->option('force');
$options = ['--provider' => 'Encore\Admin\AdminServiceProvider'];
if ($force == true) {
$options['--force'] = true;
}
$this->call('vendor:publish', $options);
$this->call('view:clear');
} | php | public function handle()
{
$force = $this->option('force');
$options = ['--provider' => 'Encore\Admin\AdminServiceProvider'];
if ($force == true) {
$options['--force'] = true;
}
$this->call('vendor:publish', $options);
$this->call('view:clear');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"force",
"=",
"$",
"this",
"->",
"option",
"(",
"'force'",
")",
";",
"$",
"options",
"=",
"[",
"'--provider'",
"=>",
"'Encore\\Admin\\AdminServiceProvider'",
"]",
";",
"if",
"(",
"$",
"force",
"==",
"tr... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/PublishCommand.php#L28-L37 | train | Publishes all the views and all the views | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
2486,
1027,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
2486,
1005,
1007,
1025,
1002,
7047,
1027,
1031,
1005,
1011,
1011,
10802,
1005,
1027,
1028,
1005,
19493,
1032,
4748,
10020,
1032,
4748,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Connection.php | Connection.pretend | public function pretend(Closure $callback)
{
return $this->withFreshQueryLog(function () use ($callback) {
$this->pretending = true;
// Basically to make the database connection "pretend", we will just return
// the default values for all the query methods, then we will return an
// array of queries that were "executed" within the Closure callback.
$callback($this);
$this->pretending = false;
return $this->queryLog;
});
} | php | public function pretend(Closure $callback)
{
return $this->withFreshQueryLog(function () use ($callback) {
$this->pretending = true;
// Basically to make the database connection "pretend", we will just return
// the default values for all the query methods, then we will return an
// array of queries that were "executed" within the Closure callback.
$callback($this);
$this->pretending = false;
return $this->queryLog;
});
} | [
"public",
"function",
"pretend",
"(",
"Closure",
"$",
"callback",
")",
"{",
"return",
"$",
"this",
"->",
"withFreshQueryLog",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"pretending",
"=",
"true",
";",
"// Basical... | Execute the given callback in "dry run" mode.
@param \Closure $callback
@return array | [
"Execute",
"the",
"given",
"callback",
"in",
"dry",
"run",
"mode",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connection.php#L520-L534 | train | Returns the query log with the fresh query log | [
30522,
2270,
3853,
9811,
1006,
8503,
1002,
2655,
5963,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2007,
19699,
9953,
4226,
23320,
8649,
1006,
3853,
1006,
1007,
2224,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
2023,
1011,
1028,
12097,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Common.php | Common.getRandomInt | public static function getRandomInt($min = 0, $max = null)
{
$rand = null;
if (function_exists('random_int')) {
try {
if (!isset($max)) {
$max = PHP_INT_MAX;
}
$rand = random_int($min, $max);
} catch (Exception $e) {
// If none of the crypto sources are available, an Exception will be thrown.
$rand = null;
}
}
if (!isset($rand)) {
if (function_exists('mt_rand')) {
if (!isset($max)) {
$max = mt_getrandmax();
}
$rand = mt_rand($min, $max);
} else {
if (!isset($max)) {
$max = getrandmax();
}
$rand = rand($min, $max);
}
}
return $rand;
} | php | public static function getRandomInt($min = 0, $max = null)
{
$rand = null;
if (function_exists('random_int')) {
try {
if (!isset($max)) {
$max = PHP_INT_MAX;
}
$rand = random_int($min, $max);
} catch (Exception $e) {
// If none of the crypto sources are available, an Exception will be thrown.
$rand = null;
}
}
if (!isset($rand)) {
if (function_exists('mt_rand')) {
if (!isset($max)) {
$max = mt_getrandmax();
}
$rand = mt_rand($min, $max);
} else {
if (!isset($max)) {
$max = getrandmax();
}
$rand = rand($min, $max);
}
}
return $rand;
} | [
"public",
"static",
"function",
"getRandomInt",
"(",
"$",
"min",
"=",
"0",
",",
"$",
"max",
"=",
"null",
")",
"{",
"$",
"rand",
"=",
"null",
";",
"if",
"(",
"function_exists",
"(",
"'random_int'",
")",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isset",... | Generates a random integer
@param int $min
@param null|int $max Defaults to max int value
@return int|null | [
"Generates",
"a",
"random",
"integer"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Common.php#L565-L597 | train | Returns a random integer from the system | [
30522,
2270,
10763,
3853,
2131,
13033,
20936,
3372,
1006,
1002,
8117,
1027,
1014,
1010,
1002,
4098,
1027,
19701,
1007,
1063,
1002,
14566,
1027,
19701,
1025,
2065,
1006,
3853,
1035,
6526,
1006,
1005,
6721,
1035,
20014,
1005,
1007,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Worker.php | Worker.initWorkers | protected static function initWorkers()
{
if (static::$_OS !== OS_TYPE_LINUX) {
return;
}
foreach (static::$_workers as $worker) {
// Worker name.
if (empty($worker->name)) {
$worker->name = 'none';
}
// Get unix user of the worker process.
if (empty($worker->user)) {
$worker->user = static::getCurrentUser();
} else {
if (posix_getuid() !== 0 && $worker->user != static::getCurrentUser()) {
static::log('Warning: You must have the root privileges to change uid and gid.');
}
}
// Socket name.
$worker->socket = $worker->getSocketName();
// Status name.
$worker->status = '<g> [OK] </g>';
// Get column mapping for UI
foreach(static::getUiColumns() as $column_name => $prop){
!isset($worker->{$prop}) && $worker->{$prop}= 'NNNN';
$prop_length = strlen($worker->{$prop});
$key = '_max' . ucfirst(strtolower($column_name)) . 'NameLength';
static::$$key = max(static::$$key, $prop_length);
}
// Listen.
if (!$worker->reusePort) {
$worker->listen();
}
}
} | php | protected static function initWorkers()
{
if (static::$_OS !== OS_TYPE_LINUX) {
return;
}
foreach (static::$_workers as $worker) {
// Worker name.
if (empty($worker->name)) {
$worker->name = 'none';
}
// Get unix user of the worker process.
if (empty($worker->user)) {
$worker->user = static::getCurrentUser();
} else {
if (posix_getuid() !== 0 && $worker->user != static::getCurrentUser()) {
static::log('Warning: You must have the root privileges to change uid and gid.');
}
}
// Socket name.
$worker->socket = $worker->getSocketName();
// Status name.
$worker->status = '<g> [OK] </g>';
// Get column mapping for UI
foreach(static::getUiColumns() as $column_name => $prop){
!isset($worker->{$prop}) && $worker->{$prop}= 'NNNN';
$prop_length = strlen($worker->{$prop});
$key = '_max' . ucfirst(strtolower($column_name)) . 'NameLength';
static::$$key = max(static::$$key, $prop_length);
}
// Listen.
if (!$worker->reusePort) {
$worker->listen();
}
}
} | [
"protected",
"static",
"function",
"initWorkers",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"_OS",
"!==",
"OS_TYPE_LINUX",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"static",
"::",
"$",
"_workers",
"as",
"$",
"worker",
")",
"{",
"// Worker name.... | Init All worker instances.
@return void | [
"Init",
"All",
"worker",
"instances",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L610-L649 | train | Initializes workers. | [
30522,
5123,
10763,
3853,
1999,
4183,
6198,
2545,
1006,
1007,
1063,
2065,
1006,
10763,
1024,
1024,
1002,
1035,
9808,
999,
1027,
1027,
9808,
1035,
2828,
1035,
11603,
1007,
1063,
2709,
1025,
1065,
18921,
6776,
1006,
10763,
1024,
1024,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Bootstrap/HandleExceptions.php | HandleExceptions.renderHttpResponse | protected function renderHttpResponse(Exception $e)
{
$this->getExceptionHandler()->render($this->app['request'], $e)->send();
} | php | protected function renderHttpResponse(Exception $e)
{
$this->getExceptionHandler()->render($this->app['request'], $e)->send();
} | [
"protected",
"function",
"renderHttpResponse",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"getExceptionHandler",
"(",
")",
"->",
"render",
"(",
"$",
"this",
"->",
"app",
"[",
"'request'",
"]",
",",
"$",
"e",
")",
"->",
"send",
"(",
")",
... | Render an exception as an HTTP response and send it.
@param \Exception $e
@return void | [
"Render",
"an",
"exception",
"as",
"an",
"HTTP",
"response",
"and",
"send",
"it",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php#L110-L113 | train | Render HTTP Response | [
30522,
5123,
3853,
17552,
11039,
25856,
6072,
26029,
3366,
1006,
6453,
1002,
1041,
1007,
1063,
1002,
2023,
1011,
1028,
2131,
10288,
24422,
11774,
3917,
1006,
1007,
1011,
1028,
17552,
1006,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
5227,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/HandlerStack.php | HandlerStack.debugCallable | private function debugCallable($fn)
{
if (is_string($fn)) {
return "callable({$fn})";
}
if (is_array($fn)) {
return is_string($fn[0])
? "callable({$fn[0]}::{$fn[1]})"
: "callable(['" . get_class($fn[0]) . "', '{$fn[1]}'])";
}
return 'callable(' . spl_object_hash($fn) . ')';
} | php | private function debugCallable($fn)
{
if (is_string($fn)) {
return "callable({$fn})";
}
if (is_array($fn)) {
return is_string($fn[0])
? "callable({$fn[0]}::{$fn[1]})"
: "callable(['" . get_class($fn[0]) . "', '{$fn[1]}'])";
}
return 'callable(' . spl_object_hash($fn) . ')';
} | [
"private",
"function",
"debugCallable",
"(",
"$",
"fn",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"fn",
")",
")",
"{",
"return",
"\"callable({$fn})\"",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"fn",
")",
")",
"{",
"return",
"is_string",
"(",
"$",... | Provides a debug string for a given callable.
@param array|callable $fn Function to write as a string.
@return string | [
"Provides",
"a",
"debug",
"string",
"for",
"a",
"given",
"callable",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/HandlerStack.php#L259-L272 | train | Debug function for callable | [
30522,
2797,
3853,
2139,
8569,
18195,
25425,
3468,
1006,
1002,
1042,
2078,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
1042,
2078,
1007,
1007,
1063,
2709,
1000,
2655,
3085,
1006,
1063,
1002,
1042,
2078,
1065,
1007,
1000,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Constraint.php | Constraint.getErrorName | public static function getErrorName($errorCode)
{
if (!isset(static::$errorNames[$errorCode])) {
throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, \get_called_class()));
}
return static::$errorNames[$errorCode];
} | php | public static function getErrorName($errorCode)
{
if (!isset(static::$errorNames[$errorCode])) {
throw new InvalidArgumentException(sprintf('The error code "%s" does not exist for constraint of type "%s".', $errorCode, \get_called_class()));
}
return static::$errorNames[$errorCode];
} | [
"public",
"static",
"function",
"getErrorName",
"(",
"$",
"errorCode",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"errorNames",
"[",
"$",
"errorCode",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
... | Returns the name of the given error code.
@param string $errorCode The error code
@return string The name of the error code
@throws InvalidArgumentException If the error code does not exist | [
"Returns",
"the",
"name",
"of",
"the",
"given",
"error",
"code",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraint.php#L70-L77 | train | Get the name of the error code | [
30522,
2270,
10763,
3853,
2131,
2121,
29165,
18442,
1006,
1002,
7561,
16044,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
10763,
1024,
1024,
1002,
7561,
18442,
2015,
1031,
1002,
7561,
16044,
1033,
1007,
1007,
1063,
5466,
2047,
19528,
290... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Referrers/Columns/Base.php | Base.detectReferrerSocialNetwork | protected function detectReferrerSocialNetwork()
{
$cache = \Piwik\Cache::getTransientCache();
$cacheKey = 'cachedReferrerSocialNetworks';
$cachedReferrerSocialNetworks = [];
if ($cache->contains($cacheKey)) {
$cachedReferrerSocialNetworks = $cache->fetch($cacheKey);
}
$socialNetworkName = false;
if (isset($cachedReferrerSocialNetworks[$this->referrerUrl])) {
$socialNetworkName = $cachedReferrerSocialNetworks[$this->referrerUrl];
} else {
if (SocialNetworkDetection::getInstance()->isSocialUrl($this->referrerUrl)) {
$socialNetworkName = SocialNetworkDetection::getInstance()->getSocialNetworkFromDomain($this->referrerUrl);
}
/**
* Triggered when detecting the social network of a referrer URL.
*
* Plugins can use this event to provide custom social network detection
* logic.
*
* @param string|false &$socialNetworkName Name of the social network, or false if none detected
*
* This parameter is initialized to the results
* of Matomo's default social network detection
* logic.
* @param string referrerUrl The referrer URL from the tracking request.
*/
Piwik::postEvent('Tracker.detectReferrerSocialNetwork', array(&$socialNetworkName, $this->referrerUrl));
$cachedReferrerSocialNetworks[$this->referrerUrl] = $socialNetworkName;
$cache->save($cacheKey, $cachedReferrerSocialNetworks);
}
if ($socialNetworkName === false) {
return false;
}
$this->typeReferrerAnalyzed = Common::REFERRER_TYPE_SOCIAL_NETWORK;
$this->nameReferrerAnalyzed = $socialNetworkName;
$this->keywordReferrerAnalyzed = '';
return true;
} | php | protected function detectReferrerSocialNetwork()
{
$cache = \Piwik\Cache::getTransientCache();
$cacheKey = 'cachedReferrerSocialNetworks';
$cachedReferrerSocialNetworks = [];
if ($cache->contains($cacheKey)) {
$cachedReferrerSocialNetworks = $cache->fetch($cacheKey);
}
$socialNetworkName = false;
if (isset($cachedReferrerSocialNetworks[$this->referrerUrl])) {
$socialNetworkName = $cachedReferrerSocialNetworks[$this->referrerUrl];
} else {
if (SocialNetworkDetection::getInstance()->isSocialUrl($this->referrerUrl)) {
$socialNetworkName = SocialNetworkDetection::getInstance()->getSocialNetworkFromDomain($this->referrerUrl);
}
/**
* Triggered when detecting the social network of a referrer URL.
*
* Plugins can use this event to provide custom social network detection
* logic.
*
* @param string|false &$socialNetworkName Name of the social network, or false if none detected
*
* This parameter is initialized to the results
* of Matomo's default social network detection
* logic.
* @param string referrerUrl The referrer URL from the tracking request.
*/
Piwik::postEvent('Tracker.detectReferrerSocialNetwork', array(&$socialNetworkName, $this->referrerUrl));
$cachedReferrerSocialNetworks[$this->referrerUrl] = $socialNetworkName;
$cache->save($cacheKey, $cachedReferrerSocialNetworks);
}
if ($socialNetworkName === false) {
return false;
}
$this->typeReferrerAnalyzed = Common::REFERRER_TYPE_SOCIAL_NETWORK;
$this->nameReferrerAnalyzed = $socialNetworkName;
$this->keywordReferrerAnalyzed = '';
return true;
} | [
"protected",
"function",
"detectReferrerSocialNetwork",
"(",
")",
"{",
"$",
"cache",
"=",
"\\",
"Piwik",
"\\",
"Cache",
"::",
"getTransientCache",
"(",
")",
";",
"$",
"cacheKey",
"=",
"'cachedReferrerSocialNetworks'",
";",
"$",
"cachedReferrerSocialNetworks",
"=",
... | Social network detection
@return bool | [
"Social",
"network",
"detection"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/Columns/Base.php#L201-L246 | train | Detects if the referrer URL is a social network | [
30522,
5123,
3853,
11487,
2890,
7512,
14544,
6499,
13247,
7159,
6198,
1006,
1007,
1063,
1002,
17053,
1027,
1032,
14255,
9148,
2243,
1032,
17053,
1024,
1024,
2131,
6494,
3619,
11638,
3540,
5403,
1006,
1007,
1025,
1002,
17053,
14839,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Request.php | Request.getMimeType | public function getMimeType($format)
{
if (null === static::$formats) {
static::initializeFormats();
}
return isset(static::$formats[$format]) ? static::$formats[$format][0] : null;
} | php | public function getMimeType($format)
{
if (null === static::$formats) {
static::initializeFormats();
}
return isset(static::$formats[$format]) ? static::$formats[$format][0] : null;
} | [
"public",
"function",
"getMimeType",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"null",
"===",
"static",
"::",
"$",
"formats",
")",
"{",
"static",
"::",
"initializeFormats",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"static",
"::",
"$",
"formats",
"[",... | Gets the mime type associated with the format.
@param string $format The format
@return string|null The associated mime type (null if not found) | [
"Gets",
"the",
"mime",
"type",
"associated",
"with",
"the",
"format",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Request.php#L1269-L1276 | train | Returns the mime type of the given format | [
30522,
2270,
3853,
2131,
4328,
11368,
18863,
1006,
1002,
4289,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
10763,
1024,
1024,
1002,
11630,
1007,
1063,
10763,
1024,
1024,
3988,
4697,
14192,
11149,
1006,
1007,
1025,
1065,
2709,
26354,
33... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/Archiver.php | Archiver.makeRegionCityLabelsUnique | private function makeRegionCityLabelsUnique(&$row)
{
// remove the location separator from the region/city/country we get from the query
foreach ($this->dimensions as $column) {
$row[$column] = str_replace(self::LOCATION_SEPARATOR, '', $row[$column]);
}
if (!empty($row[self::REGION_FIELD])) {
$row[self::REGION_FIELD] = $row[self::REGION_FIELD] . self::LOCATION_SEPARATOR . $row[self::COUNTRY_FIELD];
}
if (!empty($row[self::CITY_FIELD])) {
$row[self::CITY_FIELD] = $row[self::CITY_FIELD] . self::LOCATION_SEPARATOR . $row[self::REGION_FIELD];
}
} | php | private function makeRegionCityLabelsUnique(&$row)
{
// remove the location separator from the region/city/country we get from the query
foreach ($this->dimensions as $column) {
$row[$column] = str_replace(self::LOCATION_SEPARATOR, '', $row[$column]);
}
if (!empty($row[self::REGION_FIELD])) {
$row[self::REGION_FIELD] = $row[self::REGION_FIELD] . self::LOCATION_SEPARATOR . $row[self::COUNTRY_FIELD];
}
if (!empty($row[self::CITY_FIELD])) {
$row[self::CITY_FIELD] = $row[self::CITY_FIELD] . self::LOCATION_SEPARATOR . $row[self::REGION_FIELD];
}
} | [
"private",
"function",
"makeRegionCityLabelsUnique",
"(",
"&",
"$",
"row",
")",
"{",
"// remove the location separator from the region/city/country we get from the query",
"foreach",
"(",
"$",
"this",
"->",
"dimensions",
"as",
"$",
"column",
")",
"{",
"$",
"row",
"[",
... | Makes sure the region and city of a query row are unique.
@param array $row | [
"Makes",
"sure",
"the",
"region",
"and",
"city",
"of",
"a",
"query",
"row",
"are",
"unique",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/Archiver.php#L103-L117 | train | Make the region city labels unique | [
30522,
2797,
3853,
9338,
13910,
3258,
12972,
20470,
9050,
19496,
4226,
1006,
1004,
1002,
5216,
1007,
1063,
1013,
1013,
6366,
1996,
3295,
19802,
25879,
2953,
2013,
1996,
2555,
1013,
2103,
1013,
2406,
2057,
2131,
2013,
1996,
23032,
18921,
677... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormWidgetBase.php | FormWidgetBase.getLoadValue | public function getLoadValue()
{
if ($this->formField->value !== null) {
return $this->formField->value;
}
$defaultValue = !$this->model->exists
? $this->formField->getDefaultFromData($this->data ?: $this->model)
: null;
return $this->formField->getValueFromData($this->data ?: $this->model, $defaultValue);
} | php | public function getLoadValue()
{
if ($this->formField->value !== null) {
return $this->formField->value;
}
$defaultValue = !$this->model->exists
? $this->formField->getDefaultFromData($this->data ?: $this->model)
: null;
return $this->formField->getValueFromData($this->data ?: $this->model, $defaultValue);
} | [
"public",
"function",
"getLoadValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formField",
"->",
"value",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"formField",
"->",
"value",
";",
"}",
"$",
"defaultValue",
"=",
"!",
"$",
"this",
"->... | Returns the value for this form field,
supports nesting via HTML array.
@return string | [
"Returns",
"the",
"value",
"for",
"this",
"form",
"field",
"supports",
"nesting",
"via",
"HTML",
"array",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormWidgetBase.php#L140-L151 | train | Get Load Value | [
30522,
2270,
3853,
2131,
11066,
10175,
5657,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2433,
3790,
1011,
1028,
3643,
999,
1027,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2433,
3790,
1011,
1028,
3643,
1025,
1065,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/FileIntegrity.php | FileIntegrity.getFileIntegrityInformation | public static function getFileIntegrityInformation()
{
$messages = array();
$manifest = PIWIK_INCLUDE_PATH . '/config/manifest.inc.php';
if (file_exists($manifest)) {
require_once $manifest;
}
if (!class_exists('Piwik\\Manifest')) {
$messages[] = Piwik::translate('General_WarningFileIntegrityNoManifest')
. '<br/>'
. Piwik::translate('General_WarningFileIntegrityNoManifestDeployingFromGit');
return array(
$success = false,
$messages
);
}
$messages = self::getMessagesDirectoriesFoundButNotExpected($messages);
$messages = self::getMessagesFilesFoundButNotExpected($messages);
$messages = self::getMessagesFilesMismatch($messages);
return array(
$success = empty($messages),
$messages
);
} | php | public static function getFileIntegrityInformation()
{
$messages = array();
$manifest = PIWIK_INCLUDE_PATH . '/config/manifest.inc.php';
if (file_exists($manifest)) {
require_once $manifest;
}
if (!class_exists('Piwik\\Manifest')) {
$messages[] = Piwik::translate('General_WarningFileIntegrityNoManifest')
. '<br/>'
. Piwik::translate('General_WarningFileIntegrityNoManifestDeployingFromGit');
return array(
$success = false,
$messages
);
}
$messages = self::getMessagesDirectoriesFoundButNotExpected($messages);
$messages = self::getMessagesFilesFoundButNotExpected($messages);
$messages = self::getMessagesFilesMismatch($messages);
return array(
$success = empty($messages),
$messages
);
} | [
"public",
"static",
"function",
"getFileIntegrityInformation",
"(",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"$",
"manifest",
"=",
"PIWIK_INCLUDE_PATH",
".",
"'/config/manifest.inc.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"manifest",
")",
... | Get file integrity information
@return array(bool $success, array $messages) | [
"Get",
"file",
"integrity",
"information"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FileIntegrity.php#L24-L56 | train | Returns an array with all the information about the file integrity | [
30522,
2270,
10763,
3853,
2131,
8873,
19856,
2618,
16523,
3012,
2378,
14192,
3370,
1006,
1007,
1063,
1002,
7696,
1027,
9140,
1006,
1007,
1025,
1002,
19676,
1027,
14255,
9148,
2243,
1035,
2421,
1035,
4130,
1012,
1005,
1013,
9530,
8873,
2290,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php | AccessDecisionManager.decide | public function decide(TokenInterface $token, array $attributes, $object = null)
{
return $this->{$this->strategy}($token, $attributes, $object);
} | php | public function decide(TokenInterface $token, array $attributes, $object = null)
{
return $this->{$this->strategy}($token, $attributes, $object);
} | [
"public",
"function",
"decide",
"(",
"TokenInterface",
"$",
"token",
",",
"array",
"$",
"attributes",
",",
"$",
"object",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"strategy",
"}",
"(",
"$",
"token",
",",
"$",
"attri... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php#L58-L61 | train | Decides whether a token should be evaluated or not | [
30522,
2270,
3853,
5630,
1006,
19204,
18447,
2121,
12172,
1002,
19204,
1010,
9140,
1002,
12332,
1010,
1002,
4874,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
1063,
1002,
2023,
1011,
1028,
5656,
1065,
1006,
1002,
19204,
1010,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/Limiters/DurationLimiterBuilder.php | DurationLimiterBuilder.then | public function then(callable $callback, callable $failure = null)
{
try {
return (new DurationLimiter(
$this->connection, $this->name, $this->maxLocks, $this->decay
))->block($this->timeout, $callback);
} catch (LimiterTimeoutException $e) {
if ($failure) {
return $failure($e);
}
throw $e;
}
} | php | public function then(callable $callback, callable $failure = null)
{
try {
return (new DurationLimiter(
$this->connection, $this->name, $this->maxLocks, $this->decay
))->block($this->timeout, $callback);
} catch (LimiterTimeoutException $e) {
if ($failure) {
return $failure($e);
}
throw $e;
}
} | [
"public",
"function",
"then",
"(",
"callable",
"$",
"callback",
",",
"callable",
"$",
"failure",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"(",
"new",
"DurationLimiter",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"name",
",",
"$",... | Execute the given callback if a lock is obtained, otherwise call the failure callback.
@param callable $callback
@param callable|null $failure
@return mixed
@throws \Illuminate\Contracts\Redis\LimiterTimeoutException | [
"Execute",
"the",
"given",
"callback",
"if",
"a",
"lock",
"is",
"obtained",
"otherwise",
"call",
"the",
"failure",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Limiters/DurationLimiterBuilder.php#L108-L121 | train | Blocks until the timeout occurs. | [
30522,
2270,
3853,
2059,
1006,
2655,
3085,
1002,
2655,
5963,
1010,
2655,
3085,
1002,
4945,
1027,
19701,
1007,
1063,
3046,
1063,
2709,
1006,
2047,
9367,
17960,
21646,
1006,
1002,
2023,
1011,
1028,
4434,
1010,
1002,
2023,
1011,
1028,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/RedisServiceProvider.php | RedisServiceProvider.register | public function register()
{
$this->app->singleton('redis', function ($app) {
$config = $app->make('config')->get('database.redis', []);
return new RedisManager($app, Arr::pull($config, 'client', 'predis'), $config);
});
$this->app->bind('redis.connection', function ($app) {
return $app['redis']->connection();
});
} | php | public function register()
{
$this->app->singleton('redis', function ($app) {
$config = $app->make('config')->get('database.redis', []);
return new RedisManager($app, Arr::pull($config, 'client', 'predis'), $config);
});
$this->app->bind('redis.connection', function ($app) {
return $app['redis']->connection();
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'redis'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
"->",
"get",
"(",
"'databa... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/RedisServiceProvider.php#L16-L27 | train | Register the Redis Manager | [
30522,
2270,
3853,
4236,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
10439,
1011,
1028,
28159,
1006,
1005,
2417,
2483,
1005,
1010,
3853,
1006,
1002,
10439,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
1002,
10439,
1011,
1028,
2191,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/FilesystemAdapter.php | FilesystemAdapter.getLocalUrl | protected function getLocalUrl($path)
{
$config = $this->driver->getConfig();
// If an explicit base URL has been set on the disk configuration then we will use
// it as the base URL instead of the default path. This allows the developer to
// have full control over the base path for this filesystem's generated URLs.
if ($config->has('url')) {
return $this->concatPathToUrl($config->get('url'), $path);
}
$path = '/storage/'.$path;
// If the path contains "storage/public", it probably means the developer is using
// the default disk to generate the path instead of the "public" disk like they
// are really supposed to use. We will remove the public from this path here.
if (Str::contains($path, '/storage/public/')) {
return Str::replaceFirst('/public/', '/', $path);
}
return $path;
} | php | protected function getLocalUrl($path)
{
$config = $this->driver->getConfig();
// If an explicit base URL has been set on the disk configuration then we will use
// it as the base URL instead of the default path. This allows the developer to
// have full control over the base path for this filesystem's generated URLs.
if ($config->has('url')) {
return $this->concatPathToUrl($config->get('url'), $path);
}
$path = '/storage/'.$path;
// If the path contains "storage/public", it probably means the developer is using
// the default disk to generate the path instead of the "public" disk like they
// are really supposed to use. We will remove the public from this path here.
if (Str::contains($path, '/storage/public/')) {
return Str::replaceFirst('/public/', '/', $path);
}
return $path;
} | [
"protected",
"function",
"getLocalUrl",
"(",
"$",
"path",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"driver",
"->",
"getConfig",
"(",
")",
";",
"// If an explicit base URL has been set on the disk configuration then we will use",
"// it as the base URL instead of the... | Get the URL for the file at the given path.
@param string $path
@return string | [
"Get",
"the",
"URL",
"for",
"the",
"file",
"at",
"the",
"given",
"path",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/FilesystemAdapter.php#L477-L498 | train | Get local path | [
30522,
5123,
3853,
2131,
4135,
9289,
3126,
2140,
1006,
1002,
4130,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
1002,
2023,
1011,
1028,
4062,
1011,
1028,
2131,
8663,
8873,
2290,
1006,
1007,
1025,
1013,
1013,
2065,
2019,
13216,
2918,
24471,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php | PercentToLocalizedStringTransformer.getNumberFormatter | protected function getNumberFormatter()
{
$formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->scale);
return $formatter;
} | php | protected function getNumberFormatter()
{
$formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->scale);
return $formatter;
} | [
"protected",
"function",
"getNumberFormatter",
"(",
")",
"{",
"$",
"formatter",
"=",
"new",
"\\",
"NumberFormatter",
"(",
"\\",
"Locale",
"::",
"getDefault",
"(",
")",
",",
"\\",
"NumberFormatter",
"::",
"DECIMAL",
")",
";",
"$",
"formatter",
"->",
"setAttri... | Returns a preconfigured \NumberFormatter instance.
@return \NumberFormatter | [
"Returns",
"a",
"preconfigured",
"\\",
"NumberFormatter",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php#L177-L184 | train | Get NumberFormatter instance | [
30522,
5123,
3853,
2131,
19172,
5677,
14192,
20097,
1006,
1007,
1063,
1002,
4289,
3334,
1027,
2047,
1032,
2193,
14192,
20097,
1006,
1032,
2334,
2063,
1024,
1024,
2131,
3207,
7011,
11314,
1006,
1007,
1010,
1032,
2193,
14192,
20097,
1024,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Log/LogManager.php | LogManager.stack | public function stack(array $channels, $channel = null)
{
return new Logger(
$this->createStackDriver(compact('channels', 'channel')),
$this->app['events']
);
} | php | public function stack(array $channels, $channel = null)
{
return new Logger(
$this->createStackDriver(compact('channels', 'channel')),
$this->app['events']
);
} | [
"public",
"function",
"stack",
"(",
"array",
"$",
"channels",
",",
"$",
"channel",
"=",
"null",
")",
"{",
"return",
"new",
"Logger",
"(",
"$",
"this",
"->",
"createStackDriver",
"(",
"compact",
"(",
"'channels'",
",",
"'channel'",
")",
")",
",",
"$",
"... | Create a new, on-demand aggregate logger instance.
@param array $channels
@param string|null $channel
@return \Psr\Log\LoggerInterface | [
"Create",
"a",
"new",
"on",
"-",
"demand",
"aggregate",
"logger",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Log/LogManager.php#L63-L69 | train | Create a new logger with the given channels and channel | [
30522,
2270,
3853,
9991,
1006,
9140,
1002,
6833,
1010,
1002,
3149,
1027,
19701,
1007,
1063,
2709,
2047,
8833,
4590,
1006,
1002,
2023,
1011,
1028,
9005,
2696,
3600,
23663,
2099,
1006,
9233,
1006,
1005,
6833,
1005,
1010,
1005,
3149,
1005,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php | Configuration.tolerates | public function tolerates(array $deprecations)
{
$deprecationCounts = array_filter($deprecations, function ($key) {
return false !== strpos($key, 'Count') && false === strpos($key, 'legacy');
}, ARRAY_FILTER_USE_KEY);
if (array_sum($deprecationCounts) > $this->thresholds['total']) {
return false;
}
foreach (['self', 'direct', 'indirect'] as $deprecationType) {
if ($deprecationCounts['remaining '.$deprecationType.'Count'] > $this->thresholds[$deprecationType]) {
return false;
}
}
return true;
} | php | public function tolerates(array $deprecations)
{
$deprecationCounts = array_filter($deprecations, function ($key) {
return false !== strpos($key, 'Count') && false === strpos($key, 'legacy');
}, ARRAY_FILTER_USE_KEY);
if (array_sum($deprecationCounts) > $this->thresholds['total']) {
return false;
}
foreach (['self', 'direct', 'indirect'] as $deprecationType) {
if ($deprecationCounts['remaining '.$deprecationType.'Count'] > $this->thresholds[$deprecationType]) {
return false;
}
}
return true;
} | [
"public",
"function",
"tolerates",
"(",
"array",
"$",
"deprecations",
")",
"{",
"$",
"deprecationCounts",
"=",
"array_filter",
"(",
"$",
"deprecations",
",",
"function",
"(",
"$",
"key",
")",
"{",
"return",
"false",
"!==",
"strpos",
"(",
"$",
"key",
",",
... | @param mixed[] $deprecations
@return bool | [
"@param",
"mixed",
"[]",
"$deprecations"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php#L91-L107 | train | Checks if the deprecation counts are not more than the threshold | [
30522,
2270,
3853,
19242,
2015,
1006,
30524,
1027,
1027,
2358,
14536,
2891,
1006,
1002,
3145,
1010,
1005,
4175,
1005,
1007,
1004,
1004,
6270,
1027,
1027,
1027,
2358,
14536,
2891,
1006,
1002,
3145,
1010,
1005,
8027,
1005,
1007,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail.php | Zend_Mail.setFromToDefaultFrom | public function setFromToDefaultFrom() {
$from = self::getDefaultFrom();
if($from === null) {
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception(
'No default From Address set to use');
}
$this->setFrom($from['email'], $from['name']);
return $this;
} | php | public function setFromToDefaultFrom() {
$from = self::getDefaultFrom();
if($from === null) {
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception(
'No default From Address set to use');
}
$this->setFrom($from['email'], $from['name']);
return $this;
} | [
"public",
"function",
"setFromToDefaultFrom",
"(",
")",
"{",
"$",
"from",
"=",
"self",
"::",
"getDefaultFrom",
"(",
")",
";",
"if",
"(",
"$",
"from",
"===",
"null",
")",
"{",
"// require_once 'Zend/Mail/Exception.php';",
"throw",
"new",
"Zend_Mail_Exception",
"(... | Sets From-name and -email based on the defaults
@return Zend_Mail Provides fluent interface | [
"Sets",
"From",
"-",
"name",
"and",
"-",
"email",
"based",
"on",
"the",
"defaults"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L800-L811 | train | Set From To Default From Address | [
30522,
2270,
3853,
2275,
19699,
5358,
3406,
3207,
7011,
11314,
19699,
5358,
1006,
1007,
1063,
1002,
2013,
1027,
2969,
1024,
1024,
2131,
3207,
7011,
11314,
19699,
5358,
1006,
1007,
1025,
2065,
1006,
1002,
2013,
1027,
1027,
1027,
19701,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/File/Extension.php | Zend_Validate_File_Extension._throw | protected function _throw($file, $errorType)
{
if (null !== $file) {
$this->_value = $file['name'];
}
$this->_error($errorType);
return false;
} | php | protected function _throw($file, $errorType)
{
if (null !== $file) {
$this->_value = $file['name'];
}
$this->_error($errorType);
return false;
} | [
"protected",
"function",
"_throw",
"(",
"$",
"file",
",",
"$",
"errorType",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"_value",
"=",
"$",
"file",
"[",
"'name'",
"]",
";",
"}",
"$",
"this",
"->",
"_error",
"(",
... | Throws an error of the given type
@param string $file
@param string $errorType
@return false | [
"Throws",
"an",
"error",
"of",
"the",
"given",
"type"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/File/Extension.php#L223-L231 | train | Throws an exception if the error type is not a string | [
30522,
5123,
3853,
1035,
5466,
1006,
1002,
5371,
1010,
1002,
7561,
13874,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
5371,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
3643,
1027,
1002,
5371,
1031,
1005,
2171,
1005,
1033,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Application.php | Application.databasePath | public function databasePath($path = '')
{
return ($this->databasePath ?: $this->basePath.DIRECTORY_SEPARATOR.'database').($path ? DIRECTORY_SEPARATOR.$path : $path);
} | php | public function databasePath($path = '')
{
return ($this->databasePath ?: $this->basePath.DIRECTORY_SEPARATOR.'database').($path ? DIRECTORY_SEPARATOR.$path : $path);
} | [
"public",
"function",
"databasePath",
"(",
"$",
"path",
"=",
"''",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"databasePath",
"?",
":",
"$",
"this",
"->",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"'database'",
")",
".",
"(",
"$",
"path",
"?",
"DIR... | Get the path to the database directory.
@param string $path Optionally, a path to append to the database path
@return string | [
"Get",
"the",
"path",
"to",
"the",
"database",
"directory",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Application.php#L363-L366 | train | Return the path to the database directory | [
30522,
2270,
3853,
7809,
15069,
1006,
1002,
4130,
1027,
1005,
1005,
1007,
1063,
30524,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/Card/CoinClient.php | CoinClient.confirm | public function confirm(string $cardId, string $orderId, int $quantity)
{
return $this->httpPostJson('card/pay/confirm', [
'card_id' => $cardId,
'order_id' => $orderId,
'quantity' => $quantity,
]);
} | php | public function confirm(string $cardId, string $orderId, int $quantity)
{
return $this->httpPostJson('card/pay/confirm', [
'card_id' => $cardId,
'order_id' => $orderId,
'quantity' => $quantity,
]);
} | [
"public",
"function",
"confirm",
"(",
"string",
"$",
"cardId",
",",
"string",
"$",
"orderId",
",",
"int",
"$",
"quantity",
")",
"{",
"return",
"$",
"this",
"->",
"httpPostJson",
"(",
"'card/pay/confirm'",
",",
"[",
"'card_id'",
"=>",
"$",
"cardId",
",",
... | @param string $cardId
@param string $orderId
@param int $quantity
@return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string | [
"@param",
"string",
"$cardId",
"@param",
"string",
"$orderId",
"@param",
"int",
"$quantity"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Card/CoinClient.php#L92-L99 | train | Confirm a card | [
30522,
2270,
3853,
12210,
1006,
5164,
1002,
4003,
3593,
1010,
5164,
1002,
2344,
3593,
1010,
20014,
1002,
11712,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
8299,
19894,
22578,
2239,
1006,
1005,
4003,
1013,
3477,
1013,
12210,
1005,
1010,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormField.php | FormField.getAttributes | public function getAttributes($position = 'field', $htmlBuild = true)
{
$result = array_get($this->attributes, $position, []);
$result = $this->filterAttributes($result, $position);
return $htmlBuild ? Html::attributes($result) : $result;
} | php | public function getAttributes($position = 'field', $htmlBuild = true)
{
$result = array_get($this->attributes, $position, []);
$result = $this->filterAttributes($result, $position);
return $htmlBuild ? Html::attributes($result) : $result;
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"position",
"=",
"'field'",
",",
"$",
"htmlBuild",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"array_get",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"position",
",",
"[",
"]",
")",
";",
"$",
"res... | Returns the attributes for this field at a given position.
@param string $position
@return array | [
"Returns",
"the",
"attributes",
"for",
"this",
"field",
"at",
"a",
"given",
"position",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L423-L429 | train | Get attributes of field | [
30522,
2270,
3853,
2131,
19321,
3089,
8569,
4570,
1006,
1002,
2597,
1027,
1005,
2492,
1005,
1010,
1002,
16129,
8569,
4014,
2094,
1027,
2995,
1007,
1063,
1002,
2765,
1027,
9140,
1035,
2131,
1006,
1002,
2023,
1011,
1028,
12332,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/VarDumper/Dumper/CliDumper.php | CliDumper.dumpString | public function dumpString(Cursor $cursor, $str, $bin, $cut)
{
$this->dumpKey($cursor);
$attr = $cursor->attr;
if ($bin) {
$str = $this->utf8Encode($str);
}
if ('' === $str) {
$this->line .= '""';
$this->endValue($cursor);
} else {
$attr += [
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
'binary' => $bin,
];
$str = explode("\n", $str);
if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) {
unset($str[1]);
$str[0] .= "\n";
}
$m = \count($str) - 1;
$i = $lineCut = 0;
if (self::DUMP_STRING_LENGTH & $this->flags) {
$this->line .= '('.$attr['length'].') ';
}
if ($bin) {
$this->line .= 'b';
}
if ($m) {
$this->line .= '"""';
$this->dumpLine($cursor->depth);
} else {
$this->line .= '"';
}
foreach ($str as $str) {
if ($i < $m) {
$str .= "\n";
}
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) {
$str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8');
$lineCut = $len - $this->maxStringWidth;
}
if ($m && 0 < $cursor->depth) {
$this->line .= $this->indentPad;
}
if ('' !== $str) {
$this->line .= $this->style('str', $str, $attr);
}
if ($i++ == $m) {
if ($m) {
if ('' !== $str) {
$this->dumpLine($cursor->depth);
if (0 < $cursor->depth) {
$this->line .= $this->indentPad;
}
}
$this->line .= '"""';
} else {
$this->line .= '"';
}
if ($cut < 0) {
$this->line .= '…';
$lineCut = 0;
} elseif ($cut) {
$lineCut += $cut;
}
}
if ($lineCut) {
$this->line .= '…'.$lineCut;
$lineCut = 0;
}
if ($i > $m) {
$this->endValue($cursor);
} else {
$this->dumpLine($cursor->depth);
}
}
}
} | php | public function dumpString(Cursor $cursor, $str, $bin, $cut)
{
$this->dumpKey($cursor);
$attr = $cursor->attr;
if ($bin) {
$str = $this->utf8Encode($str);
}
if ('' === $str) {
$this->line .= '""';
$this->endValue($cursor);
} else {
$attr += [
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
'binary' => $bin,
];
$str = explode("\n", $str);
if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) {
unset($str[1]);
$str[0] .= "\n";
}
$m = \count($str) - 1;
$i = $lineCut = 0;
if (self::DUMP_STRING_LENGTH & $this->flags) {
$this->line .= '('.$attr['length'].') ';
}
if ($bin) {
$this->line .= 'b';
}
if ($m) {
$this->line .= '"""';
$this->dumpLine($cursor->depth);
} else {
$this->line .= '"';
}
foreach ($str as $str) {
if ($i < $m) {
$str .= "\n";
}
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) {
$str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8');
$lineCut = $len - $this->maxStringWidth;
}
if ($m && 0 < $cursor->depth) {
$this->line .= $this->indentPad;
}
if ('' !== $str) {
$this->line .= $this->style('str', $str, $attr);
}
if ($i++ == $m) {
if ($m) {
if ('' !== $str) {
$this->dumpLine($cursor->depth);
if (0 < $cursor->depth) {
$this->line .= $this->indentPad;
}
}
$this->line .= '"""';
} else {
$this->line .= '"';
}
if ($cut < 0) {
$this->line .= '…';
$lineCut = 0;
} elseif ($cut) {
$lineCut += $cut;
}
}
if ($lineCut) {
$this->line .= '…'.$lineCut;
$lineCut = 0;
}
if ($i > $m) {
$this->endValue($cursor);
} else {
$this->dumpLine($cursor->depth);
}
}
}
} | [
"public",
"function",
"dumpString",
"(",
"Cursor",
"$",
"cursor",
",",
"$",
"str",
",",
"$",
"bin",
",",
"$",
"cut",
")",
"{",
"$",
"this",
"->",
"dumpKey",
"(",
"$",
"cursor",
")",
";",
"$",
"attr",
"=",
"$",
"cursor",
"->",
"attr",
";",
"if",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Dumper/CliDumper.php#L186-L269 | train | Dumps a string | [
30522,
2270,
3853,
15653,
3367,
4892,
1006,
12731,
25301,
2099,
1002,
12731,
25301,
2099,
1010,
1002,
2358,
2099,
1010,
1002,
8026,
1010,
1002,
3013,
1007,
1063,
1002,
2023,
1011,
1028,
15653,
14839,
1006,
1002,
12731,
25301,
2099,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.