repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php | AbstractSessionHandler.write | public function write($sessionId, $data)
{
if (null === $this->igbinaryEmptyData) {
// see https://github.com/igbinary/igbinary/issues/146
$this->igbinaryEmptyData = \function_exists('igbinary_serialize') ? igbinary_serialize([]) : '';
}
if ('' === $data || $this->igbinaryEmptyData === $data) {
return $this->destroy($sessionId);
}
$this->newSessionId = null;
return $this->doWrite($sessionId, $data);
} | php | public function write($sessionId, $data)
{
if (null === $this->igbinaryEmptyData) {
// see https://github.com/igbinary/igbinary/issues/146
$this->igbinaryEmptyData = \function_exists('igbinary_serialize') ? igbinary_serialize([]) : '';
}
if ('' === $data || $this->igbinaryEmptyData === $data) {
return $this->destroy($sessionId);
}
$this->newSessionId = null;
return $this->doWrite($sessionId, $data);
} | [
"public",
"function",
"write",
"(",
"$",
"sessionId",
",",
"$",
"data",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"igbinaryEmptyData",
")",
"{",
"// see https://github.com/igbinary/igbinary/issues/146",
"$",
"this",
"->",
"igbinaryEmptyData",
"=",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php#L103-L115 | train | Write session data | [
30522,
2270,
3853,
4339,
1006,
1002,
5219,
3593,
1010,
1002,
2951,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
1045,
18259,
3981,
2854,
6633,
13876,
25688,
6790,
1007,
1063,
1013,
1013,
2156,
16770,
1024,
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... |
z-song/laravel-admin | src/Show.php | Show.addField | protected function addField($name, $label = '')
{
$field = new Field($name, $label);
$field->setParent($this);
$this->overwriteExistingField($name);
return tap($field, function ($field) {
$this->fields->push($field);
});
} | php | protected function addField($name, $label = '')
{
$field = new Field($name, $label);
$field->setParent($this);
$this->overwriteExistingField($name);
return tap($field, function ($field) {
$this->fields->push($field);
});
} | [
"protected",
"function",
"addField",
"(",
"$",
"name",
",",
"$",
"label",
"=",
"''",
")",
"{",
"$",
"field",
"=",
"new",
"Field",
"(",
"$",
"name",
",",
"$",
"label",
")",
";",
"$",
"field",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"$",
"... | Add a model field to show.
@param string $name
@param string $label
@return Field | [
"Add",
"a",
"model",
"field",
"to",
"show",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show.php#L218-L229 | train | Add a field to the fields list. | [
30522,
5123,
3853,
5587,
3790,
1006,
1002,
2171,
1010,
1002,
3830,
1027,
1005,
1005,
1007,
1063,
1002,
2492,
1027,
2047,
2492,
1006,
1002,
2171,
1010,
1002,
3830,
1007,
1025,
1002,
2492,
1011,
1028,
2275,
19362,
4765,
1006,
1002,
2023,
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/Menu/MenuAbstract.php | MenuAbstract.rename | public function rename($mainMenuOriginal, $subMenuOriginal, $mainMenuRenamed, $subMenuRenamed)
{
$this->renames[] = array($mainMenuOriginal, $subMenuOriginal,
$mainMenuRenamed, $subMenuRenamed);
} | php | public function rename($mainMenuOriginal, $subMenuOriginal, $mainMenuRenamed, $subMenuRenamed)
{
$this->renames[] = array($mainMenuOriginal, $subMenuOriginal,
$mainMenuRenamed, $subMenuRenamed);
} | [
"public",
"function",
"rename",
"(",
"$",
"mainMenuOriginal",
",",
"$",
"subMenuOriginal",
",",
"$",
"mainMenuRenamed",
",",
"$",
"subMenuRenamed",
")",
"{",
"$",
"this",
"->",
"renames",
"[",
"]",
"=",
"array",
"(",
"$",
"mainMenuOriginal",
",",
"$",
"sub... | Renames a single menu entry.
@param $mainMenuOriginal
@param $subMenuOriginal
@param $mainMenuRenamed
@param $subMenuRenamed
@api | [
"Renames",
"a",
"single",
"menu",
"entry",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Menu/MenuAbstract.php#L206-L210 | train | Renames the main menu and the sub menu | [
30522,
2270,
3853,
14916,
14074,
1006,
1002,
2364,
3549,
19098,
3089,
24965,
1010,
1002,
4942,
3549,
19098,
3089,
24965,
1010,
1002,
2364,
3549,
5397,
18442,
2094,
1010,
1002,
4942,
3549,
5397,
18442,
2094,
1007,
1063,
1002,
2023,
1011,
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... |
dompdf/dompdf | src/Adapter/GD.php | GD.circle | public function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false)
{
// Scale by the AA factor and DPI
$x = $this->_upscale($x);
$y = $this->_upscale($y);
$r = $this->_upscale($r);
$c = $this->_allocate_color($color);
// Convert the style array if required
if (is_array($style) && count($style) > 0 && !$fill) {
$gd_style = array();
foreach ($style as $length) {
for ($i = 0; $i < $length; $i++) {
$gd_style[] = $c;
}
}
if (!empty($gd_style)) {
imagesetstyle($this->get_image(), $gd_style);
$c = IMG_COLOR_STYLED;
}
}
imagesetthickness($this->get_image(), $width);
if ($fill) {
imagefilledellipse($this->get_image(), $x, $y, $r, $r, $c);
} else {
imageellipse($this->get_image(), $x, $y, $r, $r, $c);
}
} | php | public function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false)
{
// Scale by the AA factor and DPI
$x = $this->_upscale($x);
$y = $this->_upscale($y);
$r = $this->_upscale($r);
$c = $this->_allocate_color($color);
// Convert the style array if required
if (is_array($style) && count($style) > 0 && !$fill) {
$gd_style = array();
foreach ($style as $length) {
for ($i = 0; $i < $length; $i++) {
$gd_style[] = $c;
}
}
if (!empty($gd_style)) {
imagesetstyle($this->get_image(), $gd_style);
$c = IMG_COLOR_STYLED;
}
}
imagesetthickness($this->get_image(), $width);
if ($fill) {
imagefilledellipse($this->get_image(), $x, $y, $r, $r, $c);
} else {
imageellipse($this->get_image(), $x, $y, $r, $r, $c);
}
} | [
"public",
"function",
"circle",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"r",
",",
"$",
"color",
",",
"$",
"width",
"=",
"null",
",",
"$",
"style",
"=",
"null",
",",
"$",
"fill",
"=",
"false",
")",
"{",
"// Scale by the AA factor and DPI",
"$",
"x",... | Draws a circle at $x,$y with radius $r
See {@link Style::munge_color()} for the format of the color array.
See {@link Cpdf::setLineStyle()} for a description of the $style
parameter (aka dash)
@param float $x
@param float $y
@param float $r
@param array $color
@param float $width
@param array $style
@param bool $fill Fills the circle if true | [
"Draws",
"a",
"circle",
"at",
"$x",
"$y",
"with",
"radius",
"$r"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L671-L703 | train | Central method to create a circle | [
30522,
2270,
3853,
4418,
1006,
1002,
1060,
1010,
1002,
1061,
1010,
1002,
1054,
1010,
1002,
3609,
1010,
1002,
9381,
1027,
19701,
1010,
1002,
2806,
1027,
19701,
1010,
1002,
6039,
1027,
6270,
1007,
1063,
1013,
1013,
4094,
2011,
1996,
9779,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
laravel/framework | src/Illuminate/Http/Resources/Json/PaginatedResourceResponse.php | PaginatedResourceResponse.paginationLinks | protected function paginationLinks($paginated)
{
return [
'first' => $paginated['first_page_url'] ?? null,
'last' => $paginated['last_page_url'] ?? null,
'prev' => $paginated['prev_page_url'] ?? null,
'next' => $paginated['next_page_url'] ?? null,
];
} | php | protected function paginationLinks($paginated)
{
return [
'first' => $paginated['first_page_url'] ?? null,
'last' => $paginated['last_page_url'] ?? null,
'prev' => $paginated['prev_page_url'] ?? null,
'next' => $paginated['next_page_url'] ?? null,
];
} | [
"protected",
"function",
"paginationLinks",
"(",
"$",
"paginated",
")",
"{",
"return",
"[",
"'first'",
"=>",
"$",
"paginated",
"[",
"'first_page_url'",
"]",
"??",
"null",
",",
"'last'",
"=>",
"$",
"paginated",
"[",
"'last_page_url'",
"]",
"??",
"null",
",",
... | Get the pagination links for the response.
@param array $paginated
@return array | [
"Get",
"the",
"pagination",
"links",
"for",
"the",
"response",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Resources/Json/PaginatedResourceResponse.php#L56-L64 | train | Return an array of pagination links | [
30522,
5123,
3853,
6643,
20876,
3508,
13767,
2015,
1006,
1002,
6643,
20876,
3064,
1007,
1063,
2709,
1031,
1005,
2034,
1005,
1027,
1028,
1002,
6643,
20876,
3064,
1031,
1005,
2034,
1035,
3931,
1035,
24471,
2140,
1005,
1033,
1029,
1029,
19701,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ValidatorTypeGuesser.php | ValidatorTypeGuesser.guessMaxLength | public function guessMaxLength($class, $property)
{
return $this->guess($class, $property, function (Constraint $constraint) {
return $this->guessMaxLengthForConstraint($constraint);
});
} | php | public function guessMaxLength($class, $property)
{
return $this->guess($class, $property, function (Constraint $constraint) {
return $this->guessMaxLengthForConstraint($constraint);
});
} | [
"public",
"function",
"guessMaxLength",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"return",
"$",
"this",
"->",
"guess",
"(",
"$",
"class",
",",
"$",
"property",
",",
"function",
"(",
"Constraint",
"$",
"constraint",
")",
"{",
"return",
"$",
"t... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php#L56-L61 | train | Guesses the maximum length of a property for a given class and property. | [
30522,
2270,
3853,
3984,
17848,
7770,
13512,
2232,
1006,
1002,
2465,
1010,
1002,
3200,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
3984,
1006,
1002,
2465,
1010,
1002,
3200,
1010,
3853,
1006,
27142,
1002,
27142,
1007,
1063,
2709,
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... |
octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.registerBackendSettings | protected function registerBackendSettings()
{
Event::listen('system.settings.extendItems', function ($manager) {
\System\Models\LogSetting::filterSettingItems($manager);
});
SettingsManager::instance()->registerCallback(function ($manager) {
$manager->registerSettingItems('October.System', [
'updates' => [
'label' => 'system::lang.updates.menu_label',
'description' => 'system::lang.updates.menu_description',
'category' => SettingsManager::CATEGORY_SYSTEM,
'icon' => 'icon-cloud-download',
'url' => Backend::url('system/updates'),
'permissions' => ['system.manage_updates'],
'order' => 300
],
'administrators' => [
'label' => 'backend::lang.user.menu_label',
'description' => 'backend::lang.user.menu_description',
'category' => SettingsManager::CATEGORY_SYSTEM,
'icon' => 'icon-users',
'url' => Backend::url('backend/users'),
'permissions' => ['backend.manage_users'],
'order' => 400
],
'mail_templates' => [
'label' => 'system::lang.mail_templates.menu_label',
'description' => 'system::lang.mail_templates.menu_description',
'category' => SettingsManager::CATEGORY_MAIL,
'icon' => 'icon-envelope-square',
'url' => Backend::url('system/mailtemplates'),
'permissions' => ['system.manage_mail_templates'],
'order' => 610
],
'mail_settings' => [
'label' => 'system::lang.mail.menu_label',
'description' => 'system::lang.mail.menu_description',
'category' => SettingsManager::CATEGORY_MAIL,
'icon' => 'icon-envelope',
'class' => 'System\Models\MailSetting',
'permissions' => ['system.manage_mail_settings'],
'order' => 620
],
'mail_brand_settings' => [
'label' => 'system::lang.mail_brand.menu_label',
'description' => 'system::lang.mail_brand.menu_description',
'category' => SettingsManager::CATEGORY_MAIL,
'icon' => 'icon-paint-brush',
'url' => Backend::url('system/mailbrandsettings'),
'permissions' => ['system.manage_mail_templates'],
'order' => 630
],
'event_logs' => [
'label' => 'system::lang.event_log.menu_label',
'description' => 'system::lang.event_log.menu_description',
'category' => SettingsManager::CATEGORY_LOGS,
'icon' => 'icon-exclamation-triangle',
'url' => Backend::url('system/eventlogs'),
'permissions' => ['system.access_logs'],
'order' => 900,
'keywords' => 'error exception'
],
'request_logs' => [
'label' => 'system::lang.request_log.menu_label',
'description' => 'system::lang.request_log.menu_description',
'category' => SettingsManager::CATEGORY_LOGS,
'icon' => 'icon-file-o',
'url' => Backend::url('system/requestlogs'),
'permissions' => ['system.access_logs'],
'order' => 910,
'keywords' => '404 error'
],
'log_settings' => [
'label' => 'system::lang.log.menu_label',
'description' => 'system::lang.log.menu_description',
'category' => SettingsManager::CATEGORY_LOGS,
'icon' => 'icon-dot-circle-o',
'class' => 'System\Models\LogSetting',
'permissions' => ['system.manage_logs'],
'order' => 990
],
]);
});
} | php | protected function registerBackendSettings()
{
Event::listen('system.settings.extendItems', function ($manager) {
\System\Models\LogSetting::filterSettingItems($manager);
});
SettingsManager::instance()->registerCallback(function ($manager) {
$manager->registerSettingItems('October.System', [
'updates' => [
'label' => 'system::lang.updates.menu_label',
'description' => 'system::lang.updates.menu_description',
'category' => SettingsManager::CATEGORY_SYSTEM,
'icon' => 'icon-cloud-download',
'url' => Backend::url('system/updates'),
'permissions' => ['system.manage_updates'],
'order' => 300
],
'administrators' => [
'label' => 'backend::lang.user.menu_label',
'description' => 'backend::lang.user.menu_description',
'category' => SettingsManager::CATEGORY_SYSTEM,
'icon' => 'icon-users',
'url' => Backend::url('backend/users'),
'permissions' => ['backend.manage_users'],
'order' => 400
],
'mail_templates' => [
'label' => 'system::lang.mail_templates.menu_label',
'description' => 'system::lang.mail_templates.menu_description',
'category' => SettingsManager::CATEGORY_MAIL,
'icon' => 'icon-envelope-square',
'url' => Backend::url('system/mailtemplates'),
'permissions' => ['system.manage_mail_templates'],
'order' => 610
],
'mail_settings' => [
'label' => 'system::lang.mail.menu_label',
'description' => 'system::lang.mail.menu_description',
'category' => SettingsManager::CATEGORY_MAIL,
'icon' => 'icon-envelope',
'class' => 'System\Models\MailSetting',
'permissions' => ['system.manage_mail_settings'],
'order' => 620
],
'mail_brand_settings' => [
'label' => 'system::lang.mail_brand.menu_label',
'description' => 'system::lang.mail_brand.menu_description',
'category' => SettingsManager::CATEGORY_MAIL,
'icon' => 'icon-paint-brush',
'url' => Backend::url('system/mailbrandsettings'),
'permissions' => ['system.manage_mail_templates'],
'order' => 630
],
'event_logs' => [
'label' => 'system::lang.event_log.menu_label',
'description' => 'system::lang.event_log.menu_description',
'category' => SettingsManager::CATEGORY_LOGS,
'icon' => 'icon-exclamation-triangle',
'url' => Backend::url('system/eventlogs'),
'permissions' => ['system.access_logs'],
'order' => 900,
'keywords' => 'error exception'
],
'request_logs' => [
'label' => 'system::lang.request_log.menu_label',
'description' => 'system::lang.request_log.menu_description',
'category' => SettingsManager::CATEGORY_LOGS,
'icon' => 'icon-file-o',
'url' => Backend::url('system/requestlogs'),
'permissions' => ['system.access_logs'],
'order' => 910,
'keywords' => '404 error'
],
'log_settings' => [
'label' => 'system::lang.log.menu_label',
'description' => 'system::lang.log.menu_description',
'category' => SettingsManager::CATEGORY_LOGS,
'icon' => 'icon-dot-circle-o',
'class' => 'System\Models\LogSetting',
'permissions' => ['system.manage_logs'],
'order' => 990
],
]);
});
} | [
"protected",
"function",
"registerBackendSettings",
"(",
")",
"{",
"Event",
"::",
"listen",
"(",
"'system.settings.extendItems'",
",",
"function",
"(",
"$",
"manager",
")",
"{",
"\\",
"System",
"\\",
"Models",
"\\",
"LogSetting",
"::",
"filterSettingItems",
"(",
... | /*
Register settings | [
"/",
"*",
"Register",
"settings"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L421-L505 | train | Registers the backend settings | [
30522,
5123,
3853,
4236,
5963,
10497,
21678,
8613,
1006,
1007,
1063,
2724,
1024,
1024,
4952,
1006,
1005,
2291,
1012,
10906,
1012,
7949,
4221,
5244,
1005,
1010,
3853,
1006,
1002,
3208,
1007,
1063,
1032,
2291,
1032,
4275,
1032,
15664,
18319,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Presenter/Select.php | Select.ajax | public function ajax($resourceUrl, $idField = 'id', $textField = 'text')
{
$configs = array_merge([
'allowClear' => true,
'placeholder' => trans('admin.choose'),
'minimumInputLength' => 1,
], $this->config);
$configs = json_encode($configs);
$configs = substr($configs, 1, strlen($configs) - 2);
$this->script = <<<EOT
$(".{$this->getElementClass()}").select2({
ajax: {
url: "$resourceUrl",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term,
page: params.page
};
},
processResults: function (data, params) {
params.page = params.page || 1;
return {
results: $.map(data.data, function (d) {
d.id = d.$idField;
d.text = d.$textField;
return d;
}),
pagination: {
more: data.next_page_url
}
};
},
cache: true
},
$configs,
escapeMarkup: function (markup) {
return markup;
}
});
EOT;
} | php | public function ajax($resourceUrl, $idField = 'id', $textField = 'text')
{
$configs = array_merge([
'allowClear' => true,
'placeholder' => trans('admin.choose'),
'minimumInputLength' => 1,
], $this->config);
$configs = json_encode($configs);
$configs = substr($configs, 1, strlen($configs) - 2);
$this->script = <<<EOT
$(".{$this->getElementClass()}").select2({
ajax: {
url: "$resourceUrl",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term,
page: params.page
};
},
processResults: function (data, params) {
params.page = params.page || 1;
return {
results: $.map(data.data, function (d) {
d.id = d.$idField;
d.text = d.$textField;
return d;
}),
pagination: {
more: data.next_page_url
}
};
},
cache: true
},
$configs,
escapeMarkup: function (markup) {
return markup;
}
});
EOT;
} | [
"public",
"function",
"ajax",
"(",
"$",
"resourceUrl",
",",
"$",
"idField",
"=",
"'id'",
",",
"$",
"textField",
"=",
"'text'",
")",
"{",
"$",
"configs",
"=",
"array_merge",
"(",
"[",
"'allowClear'",
"=>",
"true",
",",
"'placeholder'",
"=>",
"trans",
"(",... | Load options from ajax.
@param string $resourceUrl
@param $idField
@param $textField | [
"Load",
"options",
"from",
"ajax",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/Presenter/Select.php#L193-L240 | train | Ajax select2 ajax | [
30522,
2270,
3853,
18176,
1006,
1002,
7692,
3126,
2140,
1010,
1002,
24011,
12891,
1027,
1005,
8909,
1005,
1010,
1002,
3793,
3790,
1027,
1005,
3793,
1005,
1007,
1063,
1002,
9530,
8873,
5620,
1027,
9140,
1035,
13590,
1006,
1031,
1005,
3499,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Serializer/Normalizer/PropertyNormalizer.php | PropertyNormalizer.getReflectionProperty | private function getReflectionProperty($classOrObject, string $attribute): \ReflectionProperty
{
$reflectionClass = new \ReflectionClass($classOrObject);
while (true) {
try {
return $reflectionClass->getProperty($attribute);
} catch (\ReflectionException $e) {
if (!$reflectionClass = $reflectionClass->getParentClass()) {
throw $e;
}
}
}
} | php | private function getReflectionProperty($classOrObject, string $attribute): \ReflectionProperty
{
$reflectionClass = new \ReflectionClass($classOrObject);
while (true) {
try {
return $reflectionClass->getProperty($attribute);
} catch (\ReflectionException $e) {
if (!$reflectionClass = $reflectionClass->getParentClass()) {
throw $e;
}
}
}
} | [
"private",
"function",
"getReflectionProperty",
"(",
"$",
"classOrObject",
",",
"string",
"$",
"attribute",
")",
":",
"\\",
"ReflectionProperty",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"classOrObject",
")",
";",
"while",
"(",... | @param string|object $classOrObject
@throws \ReflectionException | [
"@param",
"string|object",
"$classOrObject"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php#L165-L177 | train | Get reflection property | [
30522,
2797,
3853,
2131,
2890,
21031,
7542,
21572,
4842,
3723,
1006,
1002,
2465,
14604,
2497,
20614,
1010,
5164,
1002,
17961,
1007,
1024,
1032,
9185,
21572,
4842,
3723,
1063,
1002,
9185,
26266,
1027,
2047,
1032,
9185,
26266,
1006,
1002,
246... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/classes/Theme.php | Theme.setActiveTheme | public static function setActiveTheme($code)
{
self::resetCache();
Parameter::set(self::ACTIVE_KEY, $code);
/**
* @event cms.theme.setActiveTheme
* Fires when the active theme has been changed.
*
* If a value is returned from this halting event, it will be used as the active
* theme code. Example usage:
*
* Event::listen('cms.theme.setActiveTheme', function($code) {
* \Log::info("Theme has been changed to $code");
* });
*
*/
Event::fire('cms.theme.setActiveTheme', compact('code'));
} | php | public static function setActiveTheme($code)
{
self::resetCache();
Parameter::set(self::ACTIVE_KEY, $code);
/**
* @event cms.theme.setActiveTheme
* Fires when the active theme has been changed.
*
* If a value is returned from this halting event, it will be used as the active
* theme code. Example usage:
*
* Event::listen('cms.theme.setActiveTheme', function($code) {
* \Log::info("Theme has been changed to $code");
* });
*
*/
Event::fire('cms.theme.setActiveTheme', compact('code'));
} | [
"public",
"static",
"function",
"setActiveTheme",
"(",
"$",
"code",
")",
"{",
"self",
"::",
"resetCache",
"(",
")",
";",
"Parameter",
"::",
"set",
"(",
"self",
"::",
"ACTIVE_KEY",
",",
"$",
"code",
")",
";",
"/**\n * @event cms.theme.setActiveTheme\n ... | Sets the active theme.
The active theme code is stored in the database and overrides the configuration cms.activeTheme parameter.
@param string $code Specifies the active theme code. | [
"Sets",
"the",
"active",
"theme",
".",
"The",
"active",
"theme",
"code",
"is",
"stored",
"in",
"the",
"database",
"and",
"overrides",
"the",
"configuration",
"cms",
".",
"activeTheme",
"parameter",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Theme.php#L222-L241 | train | Sets the active theme code | [
30522,
2270,
10763,
3853,
2275,
19620,
10760,
4168,
1006,
1002,
3642,
1007,
1063,
2969,
1024,
1024,
25141,
3540,
5403,
1006,
1007,
1025,
16381,
1024,
1024,
2275,
1006,
2969,
1024,
1024,
3161,
1035,
3145,
1010,
1002,
3642,
1007,
1025,
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... |
matomo-org/matomo | libs/HTML/QuickForm2/Rule/Regex.php | HTML_QuickForm2_Rule_Regex.validateOwner | protected function validateOwner()
{
$value = $this->owner->getValue();
if ($this->owner instanceof HTML_QuickForm2_Element_InputFile) {
if (!isset($value['error']) || UPLOAD_ERR_NO_FILE == $value['error']) {
return true;
}
$value = $value['name'];
} elseif (!strlen($value)) {
return true;
}
return preg_match($this->getConfig() . 'D', $value);
} | php | protected function validateOwner()
{
$value = $this->owner->getValue();
if ($this->owner instanceof HTML_QuickForm2_Element_InputFile) {
if (!isset($value['error']) || UPLOAD_ERR_NO_FILE == $value['error']) {
return true;
}
$value = $value['name'];
} elseif (!strlen($value)) {
return true;
}
return preg_match($this->getConfig() . 'D', $value);
} | [
"protected",
"function",
"validateOwner",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"owner",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"instanceof",
"HTML_QuickForm2_Element_InputFile",
")",
"{",
"if",
"(",
"!",
"... | Validates the owner element
@return bool whether element's value matches given regular expression | [
"Validates",
"the",
"owner",
"element"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule/Regex.php#L79-L91 | train | Validate owner value | [
30522,
5123,
3853,
9398,
3686,
12384,
2121,
1006,
1007,
1063,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
3954,
1011,
1028,
2131,
10175,
5657,
1006,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
3954,
6013,
11253,
16129,
1035,
4248,
14192,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Controllers/AuthController.php | AuthController.getLogout | public function getLogout(Request $request)
{
$this->guard()->logout();
$request->session()->invalidate();
return redirect(config('admin.route.prefix'));
} | php | public function getLogout(Request $request)
{
$this->guard()->logout();
$request->session()->invalidate();
return redirect(config('admin.route.prefix'));
} | [
"public",
"function",
"getLogout",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"guard",
"(",
")",
"->",
"logout",
"(",
")",
";",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"invalidate",
"(",
")",
";",
"return",
"redirect",
"(",... | User logout.
@return Redirect | [
"User",
"logout",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Controllers/AuthController.php#L79-L86 | train | Logout and invalidate session | [
30522,
2270,
3853,
2131,
21197,
5833,
1006,
5227,
1002,
5227,
1007,
1063,
1002,
2023,
1011,
1028,
3457,
1006,
1007,
1011,
1028,
8154,
4904,
1006,
1007,
1025,
1002,
5227,
1011,
1028,
5219,
1006,
1007,
1011,
1028,
19528,
3686,
1006,
1007,
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 | plugins/Login/PasswordResetter.php | PasswordResetter.generateSecureHash | protected function generateSecureHash($hashIdentifier, $data)
{
// mitigate rainbow table attack
$halfDataLen = strlen($data) / 2;
$stringToHash = $hashIdentifier
. substr($data, 0, $halfDataLen)
. $this->getSalt()
. substr($data, $halfDataLen)
;
return $this->hashData($stringToHash);
} | php | protected function generateSecureHash($hashIdentifier, $data)
{
// mitigate rainbow table attack
$halfDataLen = strlen($data) / 2;
$stringToHash = $hashIdentifier
. substr($data, 0, $halfDataLen)
. $this->getSalt()
. substr($data, $halfDataLen)
;
return $this->hashData($stringToHash);
} | [
"protected",
"function",
"generateSecureHash",
"(",
"$",
"hashIdentifier",
",",
"$",
"data",
")",
"{",
"// mitigate rainbow table attack",
"$",
"halfDataLen",
"=",
"strlen",
"(",
"$",
"data",
")",
"/",
"2",
";",
"$",
"stringToHash",
"=",
"$",
"hashIdentifier",
... | Generates a hash using a hash "identifier" and some data to hash. The hash identifier is
a string that differentiates the hash in some way.
We can't get the identifier back from a hash but we can tell if a hash is the hash for
a specific identifier by computing a hash for the identifier and comparing with the
first hash.
@param string $hashIdentifier A unique string that identifies the hash in some way, can,
for example, be user information or can contain an expiration date,
or whatever.
@param string $data Any data that needs to be hashed securely, ie, a password.
@return string The hash string. | [
"Generates",
"a",
"hash",
"using",
"a",
"hash",
"identifier",
"and",
"some",
"data",
"to",
"hash",
".",
"The",
"hash",
"identifier",
"is",
"a",
"string",
"that",
"differentiates",
"the",
"hash",
"in",
"some",
"way",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/PasswordResetter.php#L305-L317 | train | Generate a secure hash for the given hash identifier and data | [
30522,
5123,
3853,
19421,
29150,
14949,
2232,
1006,
1002,
23325,
5178,
16778,
8873,
2121,
1010,
1002,
2951,
1007,
1063,
1013,
1013,
10210,
28731,
10098,
2795,
2886,
1002,
2431,
2850,
22059,
2078,
1027,
2358,
20927,
2078,
1006,
1002,
2951,
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... |
slimphp/Slim | Slim/Handlers/AbstractError.php | AbstractError.writeToErrorLog | protected function writeToErrorLog($throwable)
{
if ($this->displayErrorDetails) {
return;
}
$message = 'Slim Application Error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
while ($throwable = $throwable->getPrevious()) {
$message .= PHP_EOL . 'Previous error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
}
$message .= PHP_EOL . 'View in rendered output by enabling the "displayErrorDetails" setting.' . PHP_EOL;
$this->logError($message);
} | php | protected function writeToErrorLog($throwable)
{
if ($this->displayErrorDetails) {
return;
}
$message = 'Slim Application Error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
while ($throwable = $throwable->getPrevious()) {
$message .= PHP_EOL . 'Previous error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
}
$message .= PHP_EOL . 'View in rendered output by enabling the "displayErrorDetails" setting.' . PHP_EOL;
$this->logError($message);
} | [
"protected",
"function",
"writeToErrorLog",
"(",
"$",
"throwable",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"displayErrorDetails",
")",
"{",
"return",
";",
"}",
"$",
"message",
"=",
"'Slim Application Error:'",
".",
"PHP_EOL",
";",
"$",
"message",
".=",
"$",
... | Write to the error log if displayErrorDetails is false
@param Exception|Throwable $throwable
@return void | [
"Write",
"to",
"the",
"error",
"log",
"if",
"displayErrorDetails",
"is",
"false"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Handlers/AbstractError.php#L35-L51 | train | Write the throwable to the error log | [
30522,
5123,
3853,
4339,
3406,
2121,
29165,
21197,
1006,
1002,
5466,
3085,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
4653,
2121,
29165,
3207,
22081,
1007,
1063,
2709,
1025,
1065,
1002,
4471,
1027,
1005,
11754,
4646,
7561,
1024,
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... |
symfony/symfony | src/Symfony/Component/Serializer/Encoder/XmlEncoder.php | XmlEncoder.parseXmlAttributes | private function parseXmlAttributes(\DOMNode $node, array $context = []): array
{
if (!$node->hasAttributes()) {
return [];
}
$data = [];
$typeCastAttributes = (bool) ($context[self::TYPE_CASE_ATTRIBUTES] ?? $this->defaultContext[self::TYPE_CASE_ATTRIBUTES]);
foreach ($node->attributes as $attr) {
if (!is_numeric($attr->nodeValue) || !$typeCastAttributes) {
$data['@'.$attr->nodeName] = $attr->nodeValue;
continue;
}
if (false !== $val = filter_var($attr->nodeValue, FILTER_VALIDATE_INT)) {
$data['@'.$attr->nodeName] = $val;
continue;
}
$data['@'.$attr->nodeName] = (float) $attr->nodeValue;
}
return $data;
} | php | private function parseXmlAttributes(\DOMNode $node, array $context = []): array
{
if (!$node->hasAttributes()) {
return [];
}
$data = [];
$typeCastAttributes = (bool) ($context[self::TYPE_CASE_ATTRIBUTES] ?? $this->defaultContext[self::TYPE_CASE_ATTRIBUTES]);
foreach ($node->attributes as $attr) {
if (!is_numeric($attr->nodeValue) || !$typeCastAttributes) {
$data['@'.$attr->nodeName] = $attr->nodeValue;
continue;
}
if (false !== $val = filter_var($attr->nodeValue, FILTER_VALIDATE_INT)) {
$data['@'.$attr->nodeName] = $val;
continue;
}
$data['@'.$attr->nodeName] = (float) $attr->nodeValue;
}
return $data;
} | [
"private",
"function",
"parseXmlAttributes",
"(",
"\\",
"DOMNode",
"$",
"node",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"node",
"->",
"hasAttributes",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}... | Parse the input DOMNode attributes into an array. | [
"Parse",
"the",
"input",
"DOMNode",
"attributes",
"into",
"an",
"array",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php#L332-L358 | train | Parse xml attributes | [
30522,
2797,
3853,
11968,
3366,
2595,
19968,
19321,
3089,
8569,
4570,
1006,
1032,
14383,
3630,
3207,
1002,
13045,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1024,
9140,
1063,
2065,
1006,
999,
1002,
13045,
1011,
1028,
2038,
19321,
3089,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Select.php | Zend_Db_Select.group | public function group($spec)
{
if (!is_array($spec)) {
$spec = array($spec);
}
foreach ($spec as $val) {
if (preg_match('/\(.*\)/', (string) $val)) {
$val = new Zend_Db_Expr($val);
}
$this->_parts[self::GROUP][] = $val;
}
return $this;
} | php | public function group($spec)
{
if (!is_array($spec)) {
$spec = array($spec);
}
foreach ($spec as $val) {
if (preg_match('/\(.*\)/', (string) $val)) {
$val = new Zend_Db_Expr($val);
}
$this->_parts[self::GROUP][] = $val;
}
return $this;
} | [
"public",
"function",
"group",
"(",
"$",
"spec",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"spec",
"=",
"array",
"(",
"$",
"spec",
")",
";",
"}",
"foreach",
"(",
"$",
"spec",
"as",
"$",
"val",
")",
"{",
"if",... | Adds grouping to the query.
@param array|string $spec The column(s) to group by.
@return Zend_Db_Select This Zend_Db_Select object. | [
"Adds",
"grouping",
"to",
"the",
"query",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L505-L519 | train | Add a group to the query | [
30522,
2270,
3853,
2177,
1006,
1002,
28699,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
28699,
1007,
1007,
1063,
1002,
28699,
1027,
9140,
1006,
1002,
28699,
1007,
1025,
1065,
18921,
6776,
1006,
1002,
28699,
2004,
1002,
11748,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Diagnostics/Diagnostic/RequiredPhpSetting.php | RequiredPhpSetting.check | public function check()
{
$currentValue = (int) ini_get($this->setting);
$return = false;
foreach($this->requiredValues as $key => $requiredValue){
$this->requiredValues[$key]['isValid'] = version_compare($currentValue, $requiredValue['requiredValue'], $requiredValue['operator']);
if($this->requiredValues[$key]['isValid']){
$return = true;
}
}
return $return;
} | php | public function check()
{
$currentValue = (int) ini_get($this->setting);
$return = false;
foreach($this->requiredValues as $key => $requiredValue){
$this->requiredValues[$key]['isValid'] = version_compare($currentValue, $requiredValue['requiredValue'], $requiredValue['operator']);
if($this->requiredValues[$key]['isValid']){
$return = true;
}
}
return $return;
} | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"currentValue",
"=",
"(",
"int",
")",
"ini_get",
"(",
"$",
"this",
"->",
"setting",
")",
";",
"$",
"return",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"requiredValues",
"as",
"$",
"key",
... | Checks required values against php.ini value.
@return bool | [
"Checks",
"required",
"values",
"against",
"php",
".",
"ini",
"value",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Diagnostics/Diagnostic/RequiredPhpSetting.php#L78-L92 | train | Check if required values are valid | [
30522,
2270,
3853,
4638,
1006,
1007,
1063,
1002,
2783,
10175,
5657,
1027,
1006,
20014,
1007,
1999,
2072,
1035,
2131,
1006,
1002,
2023,
1011,
1028,
4292,
1007,
1025,
1002,
2709,
1027,
6270,
1025,
18921,
6776,
1006,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | HasAttributes.attributesToArray | public function attributesToArray()
{
// If an attribute is a date, we will cast it to a string after converting it
// to a DateTime / Carbon instance. This is so we will get some consistent
// formatting while accessing attributes vs. arraying / JSONing a model.
$attributes = $this->addDateAttributesToArray(
$attributes = $this->getArrayableAttributes()
);
$attributes = $this->addMutatedAttributesToArray(
$attributes, $mutatedAttributes = $this->getMutatedAttributes()
);
// Next we will handle any casts that have been setup for this model and cast
// the values to their appropriate type. If the attribute has a mutator we
// will not perform the cast on those attributes to avoid any confusion.
$attributes = $this->addCastAttributesToArray(
$attributes, $mutatedAttributes
);
// Here we will grab all of the appended, calculated attributes to this model
// as these attributes are not really in the attributes array, but are run
// when we need to array or JSON the model for convenience to the coder.
foreach ($this->getArrayableAppends() as $key) {
$attributes[$key] = $this->mutateAttributeForArray($key, null);
}
return $attributes;
} | php | public function attributesToArray()
{
// If an attribute is a date, we will cast it to a string after converting it
// to a DateTime / Carbon instance. This is so we will get some consistent
// formatting while accessing attributes vs. arraying / JSONing a model.
$attributes = $this->addDateAttributesToArray(
$attributes = $this->getArrayableAttributes()
);
$attributes = $this->addMutatedAttributesToArray(
$attributes, $mutatedAttributes = $this->getMutatedAttributes()
);
// Next we will handle any casts that have been setup for this model and cast
// the values to their appropriate type. If the attribute has a mutator we
// will not perform the cast on those attributes to avoid any confusion.
$attributes = $this->addCastAttributesToArray(
$attributes, $mutatedAttributes
);
// Here we will grab all of the appended, calculated attributes to this model
// as these attributes are not really in the attributes array, but are run
// when we need to array or JSON the model for convenience to the coder.
foreach ($this->getArrayableAppends() as $key) {
$attributes[$key] = $this->mutateAttributeForArray($key, null);
}
return $attributes;
} | [
"public",
"function",
"attributesToArray",
"(",
")",
"{",
"// If an attribute is a date, we will cast it to a string after converting it",
"// to a DateTime / Carbon instance. This is so we will get some consistent",
"// formatting while accessing attributes vs. arraying / JSONing a model.",
"$",
... | Convert the model's attributes to an array.
@return array | [
"Convert",
"the",
"model",
"s",
"attributes",
"to",
"an",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L87-L115 | train | Returns the attributes array | [
30522,
2270,
3853,
12332,
3406,
2906,
9447,
1006,
1007,
1063,
1013,
1013,
2065,
2019,
17961,
2003,
1037,
3058,
1010,
2057,
2097,
3459,
2009,
2000,
1037,
5164,
2044,
16401,
2009,
1013,
1013,
2000,
1037,
3058,
7292,
1013,
6351,
6013,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Plugin/Report.php | Report.getMetricsRequiredForReport | public function getMetricsRequiredForReport($allMetrics = null, $restrictToColumns = null)
{
if (empty($allMetrics)) {
$allMetrics = $this->metrics;
}
if (empty($restrictToColumns)) {
$restrictToColumns = array_merge($allMetrics, array_keys($this->getProcessedMetrics()));
}
$restrictToColumns = array_unique($restrictToColumns);
$processedMetricsById = $this->getProcessedMetricsById();
$metricsSet = array_flip($allMetrics);
$metrics = array();
foreach ($restrictToColumns as $column) {
if (isset($processedMetricsById[$column])) {
$metrics = array_merge($metrics, $processedMetricsById[$column]->getDependentMetrics());
} elseif (isset($metricsSet[$column])) {
$metrics[] = $column;
}
}
return array_unique($metrics);
} | php | public function getMetricsRequiredForReport($allMetrics = null, $restrictToColumns = null)
{
if (empty($allMetrics)) {
$allMetrics = $this->metrics;
}
if (empty($restrictToColumns)) {
$restrictToColumns = array_merge($allMetrics, array_keys($this->getProcessedMetrics()));
}
$restrictToColumns = array_unique($restrictToColumns);
$processedMetricsById = $this->getProcessedMetricsById();
$metricsSet = array_flip($allMetrics);
$metrics = array();
foreach ($restrictToColumns as $column) {
if (isset($processedMetricsById[$column])) {
$metrics = array_merge($metrics, $processedMetricsById[$column]->getDependentMetrics());
} elseif (isset($metricsSet[$column])) {
$metrics[] = $column;
}
}
return array_unique($metrics);
} | [
"public",
"function",
"getMetricsRequiredForReport",
"(",
"$",
"allMetrics",
"=",
"null",
",",
"$",
"restrictToColumns",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"allMetrics",
")",
")",
"{",
"$",
"allMetrics",
"=",
"$",
"this",
"->",
"metrics",... | Returns the list of metrics required at minimum for a report factoring in the columns requested by
the report requester.
This will return all the metrics requested (or all the metrics in the report if nothing is requested)
**plus** the metrics required to calculate the requested processed metrics.
This method should be used in **Plugin.get** API methods.
@param string[]|null $allMetrics The list of all available unprocessed metrics. Defaults to this report's
metrics.
@param string[]|null $restrictToColumns The requested columns.
@return string[] | [
"Returns",
"the",
"list",
"of",
"metrics",
"required",
"at",
"minimum",
"for",
"a",
"report",
"factoring",
"in",
"the",
"columns",
"requested",
"by",
"the",
"report",
"requester",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Report.php#L401-L424 | train | Returns the list of metrics required for a report | [
30522,
2270,
3853,
2131,
12589,
21338,
2063,
15549,
5596,
29278,
2890,
6442,
1006,
1002,
2035,
12589,
2015,
1027,
19701,
1010,
1002,
21573,
3406,
25778,
2819,
3619,
1027,
19701,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2035,
12589,
2015,
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/DependencyInjection/Compiler/RemovePrivateAliasesPass.php | RemovePrivateAliasesPass.process | public function process(ContainerBuilder $container)
{
foreach ($container->getAliases() as $id => $alias) {
if ($alias->isPublic()) {
continue;
}
$container->removeAlias($id);
$container->log($this, sprintf('Removed service "%s"; reason: private alias.', $id));
}
} | php | public function process(ContainerBuilder $container)
{
foreach ($container->getAliases() as $id => $alias) {
if ($alias->isPublic()) {
continue;
}
$container->removeAlias($id);
$container->log($this, sprintf('Removed service "%s"; reason: private alias.', $id));
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"container",
"->",
"getAliases",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"alias",
")",
"{",
"if",
"(",
"$",
"alias",
"->",
"isPublic",
"(",
")",
... | Removes private aliases from the ContainerBuilder. | [
"Removes",
"private",
"aliases",
"from",
"the",
"ContainerBuilder",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/RemovePrivateAliasesPass.php#L28-L38 | train | Remove private aliases | [
30522,
2270,
3853,
2832,
1006,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
18921,
6776,
1006,
1002,
11661,
1011,
1028,
2131,
22786,
8583,
1006,
1007,
2004,
1002,
8909,
1027,
1028,
1002,
14593,
1007,
1063,
2065,
1006,
1002,
14593,
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... |
symfony/symfony | src/Symfony/Component/Console/Input/ArgvInput.php | ArgvInput.parseArgument | private function parseArgument($token)
{
$c = \count($this->arguments);
// if input is expecting another argument, add it
if ($this->definition->hasArgument($c)) {
$arg = $this->definition->getArgument($c);
$this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
// if last argument isArray(), append token to last argument
} elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
$arg = $this->definition->getArgument($c - 1);
$this->arguments[$arg->getName()][] = $token;
// unexpected argument
} else {
$all = $this->definition->getArguments();
if (\count($all)) {
throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
}
throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
}
} | php | private function parseArgument($token)
{
$c = \count($this->arguments);
// if input is expecting another argument, add it
if ($this->definition->hasArgument($c)) {
$arg = $this->definition->getArgument($c);
$this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;
// if last argument isArray(), append token to last argument
} elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
$arg = $this->definition->getArgument($c - 1);
$this->arguments[$arg->getName()][] = $token;
// unexpected argument
} else {
$all = $this->definition->getArguments();
if (\count($all)) {
throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
}
throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
}
} | [
"private",
"function",
"parseArgument",
"(",
"$",
"token",
")",
"{",
"$",
"c",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"arguments",
")",
";",
"// if input is expecting another argument, add it",
"if",
"(",
"$",
"this",
"->",
"definition",
"->",
"hasArgumen... | Parses an argument.
@param string $token The current token
@throws RuntimeException When too many arguments are given | [
"Parses",
"an",
"argument",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Input/ArgvInput.php#L165-L188 | train | Parse argument and add it to arguments array | [
30522,
2797,
3853,
11968,
17310,
10623,
27417,
2102,
1006,
1002,
19204,
1007,
1063,
1002,
1039,
1027,
1032,
4175,
1006,
1002,
2023,
1011,
1028,
9918,
1007,
1025,
1013,
1013,
2065,
7953,
2003,
8074,
2178,
6685,
1010,
5587,
2009,
2065,
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/Framework/Flex/Storage/FolderStorage.php | FolderStorage.getStoragePath | public function getStoragePath(string $key = null): string
{
if (null === $key) {
$path = $this->dataFolder;
} else {
$path = sprintf($this->dataPattern, $this->dataFolder, $key, substr($key, 0, 2));
}
return $path;
} | php | public function getStoragePath(string $key = null): string
{
if (null === $key) {
$path = $this->dataFolder;
} else {
$path = sprintf($this->dataPattern, $this->dataFolder, $key, substr($key, 0, 2));
}
return $path;
} | [
"public",
"function",
"getStoragePath",
"(",
"string",
"$",
"key",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"dataFolder",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"... | {@inheritdoc}
@see FlexStorageInterface::getStoragePath() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/Storage/FolderStorage.php#L214-L223 | train | Get the path to the data file | [
30522,
2270,
3853,
4152,
4263,
4270,
15069,
1006,
5164,
1002,
3145,
1027,
19701,
1007,
1024,
5164,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
3145,
1007,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
2951,
10371,
2121,
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 | core/Db/Schema/Mysql.php | Mysql.getTablesInstalled | public function getTablesInstalled($forceReload = true)
{
if (is_null($this->tablesInstalled)
|| $forceReload === true
) {
$db = $this->getDb();
$prefixTables = $this->getTablePrefixEscaped();
$allTables = $this->getAllExistingTables($prefixTables);
// all the tables to be installed
$allMyTables = $this->getTablesNames();
// we get the intersection between all the tables in the DB and the tables to be installed
$tablesInstalled = array_intersect($allMyTables, $allTables);
// at this point we have the static list of core tables, but let's add the monthly archive tables
$allArchiveNumeric = $db->fetchCol("SHOW TABLES LIKE '" . $prefixTables . "archive_numeric%'");
$allArchiveBlob = $db->fetchCol("SHOW TABLES LIKE '" . $prefixTables . "archive_blob%'");
$allTablesReallyInstalled = array_merge($tablesInstalled, $allArchiveNumeric, $allArchiveBlob);
$this->tablesInstalled = $allTablesReallyInstalled;
}
return $this->tablesInstalled;
} | php | public function getTablesInstalled($forceReload = true)
{
if (is_null($this->tablesInstalled)
|| $forceReload === true
) {
$db = $this->getDb();
$prefixTables = $this->getTablePrefixEscaped();
$allTables = $this->getAllExistingTables($prefixTables);
// all the tables to be installed
$allMyTables = $this->getTablesNames();
// we get the intersection between all the tables in the DB and the tables to be installed
$tablesInstalled = array_intersect($allMyTables, $allTables);
// at this point we have the static list of core tables, but let's add the monthly archive tables
$allArchiveNumeric = $db->fetchCol("SHOW TABLES LIKE '" . $prefixTables . "archive_numeric%'");
$allArchiveBlob = $db->fetchCol("SHOW TABLES LIKE '" . $prefixTables . "archive_blob%'");
$allTablesReallyInstalled = array_merge($tablesInstalled, $allArchiveNumeric, $allArchiveBlob);
$this->tablesInstalled = $allTablesReallyInstalled;
}
return $this->tablesInstalled;
} | [
"public",
"function",
"getTablesInstalled",
"(",
"$",
"forceReload",
"=",
"true",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"tablesInstalled",
")",
"||",
"$",
"forceReload",
"===",
"true",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"get... | Get list of tables installed
@param bool $forceReload Invalidate cache
@return array installed Tables | [
"Get",
"list",
"of",
"tables",
"installed"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Schema/Mysql.php#L382-L408 | train | Get all tables to be installed | [
30522,
2270,
3853,
2131,
10880,
11493,
9153,
11001,
1006,
1002,
2486,
16570,
10441,
2094,
1027,
2995,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
7251,
7076,
9080,
3709,
1007,
1064,
1064,
1002,
2486,
16570,
1044... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DataCollector/TranslationDataCollector.php | TranslationDataCollector.lateCollect | public function lateCollect()
{
$messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());
$this->data = $this->computeCount($messages);
$this->data['messages'] = $messages;
$this->data['locale'] = $this->translator->getLocale();
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
$this->data = $this->cloneVar($this->data);
} | php | public function lateCollect()
{
$messages = $this->sanitizeCollectedMessages($this->translator->getCollectedMessages());
$this->data = $this->computeCount($messages);
$this->data['messages'] = $messages;
$this->data['locale'] = $this->translator->getLocale();
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
$this->data = $this->cloneVar($this->data);
} | [
"public",
"function",
"lateCollect",
"(",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"sanitizeCollectedMessages",
"(",
"$",
"this",
"->",
"translator",
"->",
"getCollectedMessages",
"(",
")",
")",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php#L35-L46 | train | Late collect the messages and locale | [
30522,
2270,
3853,
2397,
26895,
22471,
1006,
1007,
1063,
1002,
7696,
1027,
1002,
2023,
1011,
1028,
2624,
25090,
4371,
26895,
22471,
2098,
7834,
3736,
8449,
1006,
1002,
2023,
1011,
1028,
11403,
1011,
1028,
2131,
26895,
22471,
2098,
7834,
373... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Config/ResourceCheckerConfigCacheFactory.php | ResourceCheckerConfigCacheFactory.cache | public function cache($file, $callback)
{
if (!\is_callable($callback)) {
throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback)));
}
$cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers);
if (!$cache->isFresh()) {
$callback($cache);
}
return $cache;
} | php | public function cache($file, $callback)
{
if (!\is_callable($callback)) {
throw new \InvalidArgumentException(sprintf('Invalid type for callback argument. Expected callable, but got "%s".', \gettype($callback)));
}
$cache = new ResourceCheckerConfigCache($file, $this->resourceCheckers);
if (!$cache->isFresh()) {
$callback($cache);
}
return $cache;
} | [
"public",
"function",
"cache",
"(",
"$",
"file",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"\\",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid type for callback argu... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/ResourceCheckerConfigCacheFactory.php#L35-L47 | train | Cache a config file with resource checkers | [
30522,
2270,
3853,
17053,
1006,
1002,
5371,
1010,
1002,
2655,
5963,
1007,
1063,
2065,
1006,
999,
1032,
2003,
1035,
2655,
3085,
1006,
1002,
2655,
5963,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422,
1006,
9043,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Adapter/CPDF.php | CPDF.stream | public function stream($filename = "document.pdf", $options = array())
{
if (headers_sent()) {
die("Unable to stream pdf: headers already sent");
}
if (!isset($options["compress"])) $options["compress"] = true;
if (!isset($options["Attachment"])) $options["Attachment"] = true;
$this->_add_page_text();
$debug = !$options['compress'];
$tmp = ltrim($this->_pdf->output($debug));
header("Cache-Control: private");
header("Content-Type: application/pdf");
header("Content-Length: " . mb_strlen($tmp, "8bit"));
$filename = str_replace(array("\n", "'"), "", basename($filename, ".pdf")) . ".pdf";
$attachment = $options["Attachment"] ? "attachment" : "inline";
header(Helpers::buildContentDispositionHeader($attachment, $filename));
echo $tmp;
flush();
} | php | public function stream($filename = "document.pdf", $options = array())
{
if (headers_sent()) {
die("Unable to stream pdf: headers already sent");
}
if (!isset($options["compress"])) $options["compress"] = true;
if (!isset($options["Attachment"])) $options["Attachment"] = true;
$this->_add_page_text();
$debug = !$options['compress'];
$tmp = ltrim($this->_pdf->output($debug));
header("Cache-Control: private");
header("Content-Type: application/pdf");
header("Content-Length: " . mb_strlen($tmp, "8bit"));
$filename = str_replace(array("\n", "'"), "", basename($filename, ".pdf")) . ".pdf";
$attachment = $options["Attachment"] ? "attachment" : "inline";
header(Helpers::buildContentDispositionHeader($attachment, $filename));
echo $tmp;
flush();
} | [
"public",
"function",
"stream",
"(",
"$",
"filename",
"=",
"\"document.pdf\"",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"die",
"(",
"\"Unable to stream pdf: headers already sent\"",
")",
";",
"}",
... | Streams the PDF to the client.
@param string $filename The filename to present to the client.
@param array $options Associative array: 'compress' => 1 or 0 (default 1); 'Attachment' => 1 or 0 (default 1). | [
"Streams",
"the",
"PDF",
"to",
"the",
"client",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/CPDF.php#L1132-L1156 | train | Streams the pdf to the browser | [
30522,
2270,
3853,
5460,
1006,
1002,
5371,
18442,
1027,
1000,
6254,
1012,
11135,
1000,
1010,
1002,
7047,
1027,
9140,
1006,
1007,
30524,
20346,
2015,
1035,
2741,
1006,
1007,
1007,
1063,
3280,
1006,
1000,
4039,
2000,
5460,
11135,
1024,
20346,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.comment | public function comment($text, $position = 'below', $isHtml = null)
{
$this->comment = $text;
$this->commentPosition = $position;
if ($isHtml !== null) {
$this->commentHtml = $isHtml;
}
return $this;
} | php | public function comment($text, $position = 'below', $isHtml = null)
{
$this->comment = $text;
$this->commentPosition = $position;
if ($isHtml !== null) {
$this->commentHtml = $isHtml;
}
return $this;
} | [
"public",
"function",
"comment",
"(",
"$",
"text",
",",
"$",
"position",
"=",
"'below'",
",",
"$",
"isHtml",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"comment",
"=",
"$",
"text",
";",
"$",
"this",
"->",
"commentPosition",
"=",
"$",
"position",
";",
... | Adds a text comment above or below the field.
@param string $text Specifies a comment text.
@param string $position Specifies a comment position.
@param bool $isHtml Set to true if you use HTML formatting in the comment
Supported values are 'below' and 'above' | [
"Adds",
"a",
"text",
"comment",
"above",
"or",
"below",
"the",
"field",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L350-L360 | train | Set Comment Text Position and HTML | [
30522,
2270,
3853,
7615,
1006,
1002,
3793,
1010,
1002,
2597,
1027,
1005,
2917,
1005,
1010,
1002,
2003,
11039,
19968,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
7615,
1027,
1002,
3793,
1025,
1002,
2023,
1011,
1028,
7615,
26994,
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/HttpClient/Response/CurlResponse.php | CurlResponse.parseHeaderLine | private static function parseHeaderLine($ch, string $data, array &$info, array &$headers, ?array $options, CurlClientState $multi, int $id, ?string &$location, ?callable $resolveRedirect, ?LoggerInterface $logger): int
{
if (!\in_array($waitFor = @curl_getinfo($ch, CURLINFO_PRIVATE), ['headers', 'destruct'], true)) {
return \strlen($data); // Ignore HTTP trailers
}
if ("\r\n" !== $data) {
// Regular header line: add it to the list
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
if (0 === strpos($data, 'HTTP') && 300 <= $info['http_code'] && $info['http_code'] < 400) {
if (curl_getinfo($ch, CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
} elseif (303 === $info['http_code'] || ('POST' === $info['http_method'] && \in_array($info['http_code'], [301, 302], true))) {
$info['http_method'] = 'HEAD' === $info['http_method'] ? 'HEAD' : 'GET';
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
}
}
if (0 === stripos($data, 'Location:')) {
$location = trim(substr($data, 9, -2));
}
return \strlen($data);
}
// End of headers: handle redirects and add to the activity list
$statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$info['redirect_url'] = null;
if (300 <= $statusCode && $statusCode < 400 && null !== $location) {
$info['redirect_url'] = $resolveRedirect($ch, $location);
$url = parse_url($location ?? ':');
if (isset($url['host']) && null !== $ip = $multi->dnsCache->hostnames[$url['host'] = strtolower($url['host'])] ?? null) {
// Populate DNS cache for redirects if needed
$port = $url['port'] ?? ('http' === ($url['scheme'] ?? parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL), PHP_URL_SCHEME)) ? 80 : 443);
curl_setopt($ch, CURLOPT_RESOLVE, ["{$url['host']}:$port:$ip"]);
$multi->dnsCache->removals["-{$url['host']}:$port"] = "-{$url['host']}:$port";
}
}
$location = null;
if ($statusCode < 300 || 400 <= $statusCode || curl_getinfo($ch, CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) {
// Headers and redirects completed, time to get the response's body
$multi->handlesActivity[$id] = [new FirstChunk()];
if ('destruct' === $waitFor) {
return 0;
}
if ($certinfo = curl_getinfo($ch, CURLINFO_CERTINFO)) {
$info['peer_certificate_chain'] = array_map('openssl_x509_read', array_column($certinfo, 'Cert'));
}
curl_setopt($ch, CURLOPT_PRIVATE, 'content');
} elseif (null !== $info['redirect_url'] && $logger) {
$logger->info(sprintf('Redirecting: "%s %s"', $info['http_code'], $info['redirect_url']));
}
return \strlen($data);
} | php | private static function parseHeaderLine($ch, string $data, array &$info, array &$headers, ?array $options, CurlClientState $multi, int $id, ?string &$location, ?callable $resolveRedirect, ?LoggerInterface $logger): int
{
if (!\in_array($waitFor = @curl_getinfo($ch, CURLINFO_PRIVATE), ['headers', 'destruct'], true)) {
return \strlen($data); // Ignore HTTP trailers
}
if ("\r\n" !== $data) {
// Regular header line: add it to the list
self::addResponseHeaders([substr($data, 0, -2)], $info, $headers);
if (0 === strpos($data, 'HTTP') && 300 <= $info['http_code'] && $info['http_code'] < 400) {
if (curl_getinfo($ch, CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
} elseif (303 === $info['http_code'] || ('POST' === $info['http_method'] && \in_array($info['http_code'], [301, 302], true))) {
$info['http_method'] = 'HEAD' === $info['http_method'] ? 'HEAD' : 'GET';
curl_setopt($ch, CURLOPT_POSTFIELDS, '');
}
}
if (0 === stripos($data, 'Location:')) {
$location = trim(substr($data, 9, -2));
}
return \strlen($data);
}
// End of headers: handle redirects and add to the activity list
$statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$info['redirect_url'] = null;
if (300 <= $statusCode && $statusCode < 400 && null !== $location) {
$info['redirect_url'] = $resolveRedirect($ch, $location);
$url = parse_url($location ?? ':');
if (isset($url['host']) && null !== $ip = $multi->dnsCache->hostnames[$url['host'] = strtolower($url['host'])] ?? null) {
// Populate DNS cache for redirects if needed
$port = $url['port'] ?? ('http' === ($url['scheme'] ?? parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL), PHP_URL_SCHEME)) ? 80 : 443);
curl_setopt($ch, CURLOPT_RESOLVE, ["{$url['host']}:$port:$ip"]);
$multi->dnsCache->removals["-{$url['host']}:$port"] = "-{$url['host']}:$port";
}
}
$location = null;
if ($statusCode < 300 || 400 <= $statusCode || curl_getinfo($ch, CURLINFO_REDIRECT_COUNT) === $options['max_redirects']) {
// Headers and redirects completed, time to get the response's body
$multi->handlesActivity[$id] = [new FirstChunk()];
if ('destruct' === $waitFor) {
return 0;
}
if ($certinfo = curl_getinfo($ch, CURLINFO_CERTINFO)) {
$info['peer_certificate_chain'] = array_map('openssl_x509_read', array_column($certinfo, 'Cert'));
}
curl_setopt($ch, CURLOPT_PRIVATE, 'content');
} elseif (null !== $info['redirect_url'] && $logger) {
$logger->info(sprintf('Redirecting: "%s %s"', $info['http_code'], $info['redirect_url']));
}
return \strlen($data);
} | [
"private",
"static",
"function",
"parseHeaderLine",
"(",
"$",
"ch",
",",
"string",
"$",
"data",
",",
"array",
"&",
"$",
"info",
",",
"array",
"&",
"$",
"headers",
",",
"?",
"array",
"$",
"options",
",",
"CurlClientState",
"$",
"multi",
",",
"int",
"$",... | Parses header lines as curl yields them to us. | [
"Parses",
"header",
"lines",
"as",
"curl",
"yields",
"them",
"to",
"us",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/Response/CurlResponse.php#L266-L328 | train | Parse header line | [
30522,
2797,
10763,
3853,
11968,
3366,
4974,
2121,
4179,
1006,
1002,
10381,
1010,
5164,
1002,
2951,
1010,
9140,
1004,
1002,
18558,
1010,
9140,
1004,
1002,
20346,
2015,
1010,
1029,
9140,
1002,
7047,
1010,
15390,
20464,
11638,
9153,
2618,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/classes/Router.php | Router.findByUrl | public function findByUrl($url)
{
$this->url = $url;
$url = RouterHelper::normalizeUrl($url);
/**
* @event cms.router.beforeRoute
* Fires before the CMS Router handles a route
*
* Example usage:
*
* Event::listen('cms.router.beforeRoute', function ((string) $url, (\Cms\Classes\Router) $thisRouterInstance) {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* });
*
*/
$apiResult = Event::fire('cms.router.beforeRoute', [$url, $this], true);
if ($apiResult !== null) {
return $apiResult;
}
for ($pass = 1; $pass <= 2; $pass++) {
$fileName = null;
$urlList = [];
$cacheable = Config::get('cms.enableRoutesCache');
if ($cacheable) {
$fileName = $this->getCachedUrlFileName($url, $urlList);
if (is_array($fileName)) {
list($fileName, $this->parameters) = $fileName;
}
}
/*
* Find the page by URL and cache the route
*/
if (!$fileName) {
$router = $this->getRouterObject();
if ($router->match($url)) {
$this->parameters = $router->getParameters();
$fileName = $router->matchedRoute();
if ($cacheable) {
if (!$urlList || !is_array($urlList)) {
$urlList = [];
}
$urlList[$url] = !empty($this->parameters)
? [$fileName, $this->parameters]
: $fileName;
$key = $this->getUrlListCacheKey();
Cache::put(
$key,
base64_encode(serialize($urlList)),
Config::get('cms.urlCacheTtl', 1)
);
}
}
}
/*
* Return the page
*/
if ($fileName) {
if (($page = Page::loadCached($this->theme, $fileName)) === null) {
/*
* If the page was not found on the disk, clear the URL cache
* and repeat the routing process.
*/
if ($pass == 1) {
$this->clearCache();
continue;
}
return null;
}
return $page;
}
return null;
}
} | php | public function findByUrl($url)
{
$this->url = $url;
$url = RouterHelper::normalizeUrl($url);
/**
* @event cms.router.beforeRoute
* Fires before the CMS Router handles a route
*
* Example usage:
*
* Event::listen('cms.router.beforeRoute', function ((string) $url, (\Cms\Classes\Router) $thisRouterInstance) {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* });
*
*/
$apiResult = Event::fire('cms.router.beforeRoute', [$url, $this], true);
if ($apiResult !== null) {
return $apiResult;
}
for ($pass = 1; $pass <= 2; $pass++) {
$fileName = null;
$urlList = [];
$cacheable = Config::get('cms.enableRoutesCache');
if ($cacheable) {
$fileName = $this->getCachedUrlFileName($url, $urlList);
if (is_array($fileName)) {
list($fileName, $this->parameters) = $fileName;
}
}
/*
* Find the page by URL and cache the route
*/
if (!$fileName) {
$router = $this->getRouterObject();
if ($router->match($url)) {
$this->parameters = $router->getParameters();
$fileName = $router->matchedRoute();
if ($cacheable) {
if (!$urlList || !is_array($urlList)) {
$urlList = [];
}
$urlList[$url] = !empty($this->parameters)
? [$fileName, $this->parameters]
: $fileName;
$key = $this->getUrlListCacheKey();
Cache::put(
$key,
base64_encode(serialize($urlList)),
Config::get('cms.urlCacheTtl', 1)
);
}
}
}
/*
* Return the page
*/
if ($fileName) {
if (($page = Page::loadCached($this->theme, $fileName)) === null) {
/*
* If the page was not found on the disk, clear the URL cache
* and repeat the routing process.
*/
if ($pass == 1) {
$this->clearCache();
continue;
}
return null;
}
return $page;
}
return null;
}
} | [
"public",
"function",
"findByUrl",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"$",
"url",
"=",
"RouterHelper",
"::",
"normalizeUrl",
"(",
"$",
"url",
")",
";",
"/**\n * @event cms.router.beforeRoute\n * Fires befor... | Finds a page by its URL. Returns the page object and sets the $parameters property.
@param string $url The requested URL string.
@return \Cms\Classes\Page Returns \Cms\Classes\Page object or null if the page cannot be found. | [
"Finds",
"a",
"page",
"by",
"its",
"URL",
".",
"Returns",
"the",
"page",
"object",
"and",
"sets",
"the",
"$parameters",
"property",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Router.php#L77-L161 | train | Find a page by URL | [
30522,
2270,
3853,
2424,
3762,
3126,
2140,
1006,
1002,
24471,
2140,
1007,
1063,
1002,
2023,
1011,
1028,
24471,
2140,
1027,
1002,
24471,
2140,
1025,
1002,
24471,
2140,
1027,
2799,
25032,
2884,
4842,
1024,
1024,
3671,
4697,
3126,
2140,
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... |
laravel/framework | src/Illuminate/Auth/SessionGuard.php | SessionGuard.recaller | protected function recaller()
{
if (is_null($this->request)) {
return;
}
if ($recaller = $this->request->cookies->get($this->getRecallerName())) {
return new Recaller($recaller);
}
} | php | protected function recaller()
{
if (is_null($this->request)) {
return;
}
if ($recaller = $this->request->cookies->get($this->getRecallerName())) {
return new Recaller($recaller);
}
} | [
"protected",
"function",
"recaller",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"request",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"recaller",
"=",
"$",
"this",
"->",
"request",
"->",
"cookies",
"->",
"get",
"(",
"$",
... | Get the decrypted recaller cookie for the request.
@return \Illuminate\Auth\Recaller|null | [
"Get",
"the",
"decrypted",
"recaller",
"cookie",
"for",
"the",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/SessionGuard.php#L180-L189 | train | Get the recaller object | [
30522,
5123,
3853,
9131,
2121,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
5227,
1007,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
1002,
9131,
2121,
1027,
1002,
2023,
1011,
1028,
5227,
1011,
1028,
16324,
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/DataTable.php | DataTable.makeFromIndexedArray | public static function makeFromIndexedArray($array, $subtablePerLabel = null)
{
$table = new DataTable();
foreach ($array as $label => $row) {
$cleanRow = array();
// Support the case of an $array of single values
if (!is_array($row)) {
$row = array('value' => $row);
}
// Put the 'label' column first
$cleanRow[Row::COLUMNS] = array('label' => $label) + $row;
// Assign subtable if specified
if (isset($subtablePerLabel[$label])) {
$cleanRow[Row::DATATABLE_ASSOCIATED] = $subtablePerLabel[$label];
}
$table->addRow(new Row($cleanRow));
}
return $table;
} | php | public static function makeFromIndexedArray($array, $subtablePerLabel = null)
{
$table = new DataTable();
foreach ($array as $label => $row) {
$cleanRow = array();
// Support the case of an $array of single values
if (!is_array($row)) {
$row = array('value' => $row);
}
// Put the 'label' column first
$cleanRow[Row::COLUMNS] = array('label' => $label) + $row;
// Assign subtable if specified
if (isset($subtablePerLabel[$label])) {
$cleanRow[Row::DATATABLE_ASSOCIATED] = $subtablePerLabel[$label];
}
$table->addRow(new Row($cleanRow));
}
return $table;
} | [
"public",
"static",
"function",
"makeFromIndexedArray",
"(",
"$",
"array",
",",
"$",
"subtablePerLabel",
"=",
"null",
")",
"{",
"$",
"table",
"=",
"new",
"DataTable",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"label",
"=>",
"$",
"row",
")... | Rewrites the input `$array`
array (
LABEL => array(col1 => X, col2 => Y),
LABEL2 => array(col1 => X, col2 => Y),
)
to a DataTable with rows that look like:
array (
array( Row::COLUMNS => array('label' => LABEL, col1 => X, col2 => Y)),
array( Row::COLUMNS => array('label' => LABEL2, col1 => X, col2 => Y)),
)
Will also convert arrays like:
array (
LABEL => X,
LABEL2 => Y,
)
to:
array (
array( Row::COLUMNS => array('label' => LABEL, 'value' => X)),
array( Row::COLUMNS => array('label' => LABEL2, 'value' => Y)),
)
@param array $array Indexed array, two formats supported, see above.
@param array|null $subtablePerLabel An array mapping label values with DataTable instances to associate as a subtable.
@return \Piwik\DataTable | [
"Rewrites",
"the",
"input",
"$array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L1560-L1579 | train | Makes a DataTable from an indexed array | [
30522,
2270,
10763,
3853,
2191,
19699,
20936,
13629,
19068,
2906,
9447,
1006,
1002,
9140,
1010,
1002,
4942,
10880,
4842,
20470,
2884,
1027,
19701,
1007,
1063,
1002,
2795,
1027,
2047,
2951,
10880,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/WebProfilerBundle/EventListener/WebDebugToolbarListener.php | WebDebugToolbarListener.injectToolbar | protected function injectToolbar(Response $response, Request $request, array $nonces)
{
$content = $response->getContent();
$pos = strripos($content, '</body>');
if (false !== $pos) {
$toolbar = "\n".str_replace("\n", '', $this->twig->render(
'@WebProfiler/Profiler/toolbar_js.html.twig',
[
'excluded_ajax_paths' => $this->excludedAjaxPaths,
'token' => $response->headers->get('X-Debug-Token'),
'request' => $request,
'csp_script_nonce' => isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null,
'csp_style_nonce' => isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null,
]
))."\n";
$content = substr($content, 0, $pos).$toolbar.substr($content, $pos);
$response->setContent($content);
}
} | php | protected function injectToolbar(Response $response, Request $request, array $nonces)
{
$content = $response->getContent();
$pos = strripos($content, '</body>');
if (false !== $pos) {
$toolbar = "\n".str_replace("\n", '', $this->twig->render(
'@WebProfiler/Profiler/toolbar_js.html.twig',
[
'excluded_ajax_paths' => $this->excludedAjaxPaths,
'token' => $response->headers->get('X-Debug-Token'),
'request' => $request,
'csp_script_nonce' => isset($nonces['csp_script_nonce']) ? $nonces['csp_script_nonce'] : null,
'csp_style_nonce' => isset($nonces['csp_style_nonce']) ? $nonces['csp_style_nonce'] : null,
]
))."\n";
$content = substr($content, 0, $pos).$toolbar.substr($content, $pos);
$response->setContent($content);
}
} | [
"protected",
"function",
"injectToolbar",
"(",
"Response",
"$",
"response",
",",
"Request",
"$",
"request",
",",
"array",
"$",
"nonces",
")",
"{",
"$",
"content",
"=",
"$",
"response",
"->",
"getContent",
"(",
")",
";",
"$",
"pos",
"=",
"strripos",
"(",
... | Injects the web debug toolbar into the given Response. | [
"Injects",
"the",
"web",
"debug",
"toolbar",
"into",
"the",
"given",
"Response",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php#L118-L137 | train | Injects the toolbar into the response | [
30522,
5123,
3853,
1999,
20614,
3406,
4747,
8237,
1006,
3433,
1002,
3433,
1010,
5227,
1002,
5227,
1010,
9140,
1002,
2512,
9623,
1007,
1063,
1002,
4180,
1027,
1002,
3433,
1011,
1028,
2131,
8663,
6528,
2102,
1006,
1007,
1025,
1002,
13433,
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/Bundle/SecurityBundle/EventListener/VoteListener.php | VoteListener.onVoterVote | public function onVoterVote(VoteEvent $event)
{
$this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote());
} | php | public function onVoterVote(VoteEvent $event)
{
$this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote());
} | [
"public",
"function",
"onVoterVote",
"(",
"VoteEvent",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"traceableAccessDecisionManager",
"->",
"addVoterVote",
"(",
"$",
"event",
"->",
"getVoter",
"(",
")",
",",
"$",
"event",
"->",
"getAttributes",
"(",
")",
",",
... | Event dispatched by a voter during access manager decision.
@param VoteEvent $event event with voter data | [
"Event",
"dispatched",
"by",
"a",
"voter",
"during",
"access",
"manager",
"decision",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php#L39-L42 | train | Add a vote to the traceableAccess decision manager | [
30522,
2270,
3853,
2006,
22994,
2121,
22994,
2063,
1006,
3789,
18697,
3372,
1002,
2724,
1007,
1063,
1002,
2023,
1011,
1028,
7637,
3085,
6305,
9623,
16150,
8586,
19969,
24805,
4590,
1011,
1028,
5587,
22994,
2121,
22994,
2063,
1006,
1002,
272... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Translation/Translator.php | Translator.sortReplacements | protected function sortReplacements(array $replace)
{
return (new Collection($replace))->sortBy(function ($value, $key) {
return mb_strlen($key) * -1;
})->all();
} | php | protected function sortReplacements(array $replace)
{
return (new Collection($replace))->sortBy(function ($value, $key) {
return mb_strlen($key) * -1;
})->all();
} | [
"protected",
"function",
"sortReplacements",
"(",
"array",
"$",
"replace",
")",
"{",
"return",
"(",
"new",
"Collection",
"(",
"$",
"replace",
")",
")",
"->",
"sortBy",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"return",
"mb_strlen",
... | Sort the replacements array.
@param array $replace
@return array | [
"Sort",
"the",
"replacements",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Translation/Translator.php#L283-L288 | train | Sort replacement array by length | [
30522,
5123,
3853,
4066,
2890,
24759,
10732,
8163,
1006,
9140,
1002,
5672,
1007,
1063,
2709,
1006,
2047,
3074,
1006,
1002,
5672,
1007,
1007,
1011,
1028,
4066,
3762,
1006,
3853,
1006,
1002,
3643,
1010,
1002,
3145,
1007,
1063,
2709,
16914,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/FrameReflower/Block.php | Block.calculate_auto_width | public function calculate_auto_width()
{
$width = 0;
foreach ($this->_frame->get_line_boxes() as $line) {
$line_width = 0;
foreach ($line->get_frames() as $frame) {
if ($frame->get_original_style()->width == 'auto') {
$line_width += $frame->calculate_auto_width();
} else {
$line_width += $frame->get_margin_width();
}
}
$width = max($line_width, $width);
}
$this->_frame->get_style()->width = $width;
return $this->_frame->get_margin_width();
} | php | public function calculate_auto_width()
{
$width = 0;
foreach ($this->_frame->get_line_boxes() as $line) {
$line_width = 0;
foreach ($line->get_frames() as $frame) {
if ($frame->get_original_style()->width == 'auto') {
$line_width += $frame->calculate_auto_width();
} else {
$line_width += $frame->get_margin_width();
}
}
$width = max($line_width, $width);
}
$this->_frame->get_style()->width = $width;
return $this->_frame->get_margin_width();
} | [
"public",
"function",
"calculate_auto_width",
"(",
")",
"{",
"$",
"width",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"_frame",
"->",
"get_line_boxes",
"(",
")",
"as",
"$",
"line",
")",
"{",
"$",
"line_width",
"=",
"0",
";",
"foreach",
"(",
"$... | Determine current frame width based on contents
@return float | [
"Determine",
"current",
"frame",
"width",
"based",
"on",
"contents"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameReflower/Block.php#L926-L947 | train | Calculates the auto width of the frame | [
30522,
2270,
3853,
18422,
1035,
8285,
1035,
9381,
1006,
30524,
9381,
1027,
1014,
1025,
18921,
6776,
1006,
1002,
2240,
1011,
1028,
2131,
1035,
11048,
1006,
1007,
2004,
1002,
4853,
1007,
1063,
2065,
1006,
1002,
4853,
1011,
1028,
2131,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Assets/Traits/LegacyAssetsTrait.php | LegacyAssetsTrait.addDeferJs | public function addDeferJs($asset, $priority = 10, $pipeline = true, $group = 'head')
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use dynamic method with [\'loading\' => \'defer\']', E_USER_DEPRECATED);
return $this->addJs($asset, $priority, $pipeline, 'defer', $group);
} | php | public function addDeferJs($asset, $priority = 10, $pipeline = true, $group = 'head')
{
user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use dynamic method with [\'loading\' => \'defer\']', E_USER_DEPRECATED);
return $this->addJs($asset, $priority, $pipeline, 'defer', $group);
} | [
"public",
"function",
"addDeferJs",
"(",
"$",
"asset",
",",
"$",
"priority",
"=",
"10",
",",
"$",
"pipeline",
"=",
"true",
",",
"$",
"group",
"=",
"'head'",
")",
"{",
"user_error",
"(",
"__CLASS__",
".",
"'::'",
".",
"__FUNCTION__",
".",
"'() is deprecat... | Convenience wrapper for deferred loading of JavaScript
@param string|array $asset
@param int $priority
@param bool $pipeline
@param string $group name of the group
@return \Grav\Common\Assets
@deprecated Please use dynamic method with ['loading' => 'defer']. | [
"Convenience",
"wrapper",
"for",
"deferred",
"loading",
"of",
"JavaScript"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php#L118-L123 | train | Adds a JavaScript file to the page with deferred loading | [
30522,
2270,
3853,
5587,
3207,
7512,
22578,
1006,
1002,
11412,
1010,
1002,
9470,
1027,
2184,
1010,
1002,
13117,
1027,
2995,
1010,
1002,
2177,
1027,
1005,
2132,
1005,
1007,
1063,
5310,
1035,
7561,
1006,
1035,
1035,
2465,
1035,
1035,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Registry.php | Zend_Registry.get | public static function get($index)
{
$instance = self::getInstance();
if (!$instance->offsetExists($index)) {
// require_once 'Zend/Exception.php';
// debug_print_backtrace();
throw new Zend_Exception("No entry is registered for key '$index'" );
}
return $instance->offsetGet($index);
} | php | public static function get($index)
{
$instance = self::getInstance();
if (!$instance->offsetExists($index)) {
// require_once 'Zend/Exception.php';
// debug_print_backtrace();
throw new Zend_Exception("No entry is registered for key '$index'" );
}
return $instance->offsetGet($index);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"index",
")",
"{",
"$",
"instance",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"instance",
"->",
"offsetExists",
"(",
"$",
"index",
")",
")",
"{",
"// require_once 'Zend/Exceptio... | getter method, basically same as offsetGet().
This method can be called from an object of type Zend_Registry, or it
can be called statically. In the latter case, it uses the default
static instance stored in the class.
@param string $index - get the value associated with $index
@return mixed
@throws Zend_Exception if no entry is registerd for $index. | [
"getter",
"method",
"basically",
"same",
"as",
"offsetGet",
"()",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Registry.php#L141-L152 | train | Get an entry from the registry | [
30522,
2270,
10763,
3853,
2131,
1006,
1002,
5950,
1007,
1063,
1002,
6013,
1027,
2969,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1025,
2065,
1006,
999,
1002,
6013,
1011,
1028,
16396,
10288,
5130,
1006,
1002,
5950,
1007,
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... |
matomo-org/matomo | plugins/MobileMessaging/Controller.php | Controller.index | public function index()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@MobileMessaging/index');
$this->setManageVariables($view);
return $view->render();
} | php | public function index()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@MobileMessaging/index');
$this->setManageVariables($view);
return $view->render();
} | [
"public",
"function",
"index",
"(",
")",
"{",
"Piwik",
"::",
"checkUserIsNotAnonymous",
"(",
")",
";",
"$",
"view",
"=",
"new",
"View",
"(",
"'@MobileMessaging/index'",
")",
";",
"$",
"this",
"->",
"setManageVariables",
"(",
"$",
"view",
")",
";",
"return"... | Mobile Messaging Settings tab :
- set delegated management
- provide & validate SMS API credential
- add & activate phone numbers
- check remaining credits | [
"Mobile",
"Messaging",
"Settings",
"tab",
":",
"-",
"set",
"delegated",
"management",
"-",
"provide",
"&",
"validate",
"SMS",
"API",
"credential",
"-",
"add",
"&",
"activate",
"phone",
"numbers",
"-",
"check",
"remaining",
"credits"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/Controller.php#L51-L59 | train | Returns the HTML code of the MobileMessaging index page. | [
30522,
2270,
3853,
5950,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
2483,
17048,
6761,
4890,
27711,
1006,
1007,
1025,
1002,
3193,
1027,
2047,
3193,
1006,
1005,
1030,
4684,
7834,
3736,
4726,
1013,
5950,
1005,
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... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.createBody | public function createBody()
{
$body = '';
//Create unique IDs and preset boundaries
$this->uniqueid = $this->generateId();
$this->boundary[1] = 'b1_' . $this->uniqueid;
$this->boundary[2] = 'b2_' . $this->uniqueid;
$this->boundary[3] = 'b3_' . $this->uniqueid;
if ($this->sign_key_file) {
$body .= $this->getMailMIME() . static::$LE;
}
$this->setWordWrap();
$bodyEncoding = $this->Encoding;
$bodyCharSet = $this->CharSet;
//Can we do a 7-bit downgrade?
if (static::ENCODING_8BIT == $bodyEncoding and !$this->has8bitChars($this->Body)) {
$bodyEncoding = static::ENCODING_7BIT;
//All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
$bodyCharSet = 'us-ascii';
}
//If lines are too long, and we're not already using an encoding that will shorten them,
//change to quoted-printable transfer encoding for the body part only
if (static::ENCODING_BASE64 != $this->Encoding and static::hasLineLongerThanMax($this->Body)) {
$bodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
}
$altBodyEncoding = $this->Encoding;
$altBodyCharSet = $this->CharSet;
//Can we do a 7-bit downgrade?
if (static::ENCODING_8BIT == $altBodyEncoding and !$this->has8bitChars($this->AltBody)) {
$altBodyEncoding = static::ENCODING_7BIT;
//All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
$altBodyCharSet = 'us-ascii';
}
//If lines are too long, and we're not already using an encoding that will shorten them,
//change to quoted-printable transfer encoding for the alt body part only
if (static::ENCODING_BASE64 != $altBodyEncoding and static::hasLineLongerThanMax($this->AltBody)) {
$altBodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
}
//Use this as a preamble in all multipart message types
$mimepre = 'This is a multi-part message in MIME format.' . static::$LE;
switch ($this->message_type) {
case 'inline':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[1]);
break;
case 'attach':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'inline_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
$body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
if (!empty($this->Ical)) {
$body .= $this->getBoundary($this->boundary[1], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=REQUEST', '');
$body .= $this->encodeString($this->Ical, $this->Encoding);
$body .= static::$LE;
}
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_inline':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
$body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= static::$LE;
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
if (!empty($this->Ical)) {
$body .= $this->getBoundary($this->boundary[2], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=REQUEST', '');
$body .= $this->encodeString($this->Ical, $this->Encoding);
}
$body .= $this->endBoundary($this->boundary[2]);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt_inline_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->textLine('--' . $this->boundary[2]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[3] . '";');
$body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[3], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[3]);
$body .= static::$LE;
$body .= $this->endBoundary($this->boundary[2]);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
default:
// Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types
//Reset the `Encoding` property in case we changed it for line length reasons
$this->Encoding = $bodyEncoding;
$body .= $this->encodeString($this->Body, $this->Encoding);
break;
}
if ($this->isError()) {
$body = '';
if ($this->exceptions) {
throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);
}
} elseif ($this->sign_key_file) {
try {
if (!defined('PKCS7_TEXT')) {
throw new Exception($this->lang('extension_missing') . 'openssl');
}
$file = fopen('php://temp', 'rb+');
$signed = fopen('php://temp', 'rb+');
fwrite($file, $body);
//Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
if (empty($this->sign_extracerts_file)) {
$sign = @openssl_pkcs7_sign(
$file,
$signed,
'file://' . realpath($this->sign_cert_file),
['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
[]
);
} else {
$sign = @openssl_pkcs7_sign(
$file,
$signed,
'file://' . realpath($this->sign_cert_file),
['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
[],
PKCS7_DETACHED,
$this->sign_extracerts_file
);
}
fclose($file);
if ($sign) {
$body = file_get_contents($signed);
fclose($signed);
//The message returned by openssl contains both headers and body, so need to split them up
$parts = explode("\n\n", $body, 2);
$this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
$body = $parts[1];
} else {
fclose($signed);
throw new Exception($this->lang('signing') . openssl_error_string());
}
} catch (Exception $exc) {
$body = '';
if ($this->exceptions) {
throw $exc;
}
}
}
return $body;
} | php | public function createBody()
{
$body = '';
//Create unique IDs and preset boundaries
$this->uniqueid = $this->generateId();
$this->boundary[1] = 'b1_' . $this->uniqueid;
$this->boundary[2] = 'b2_' . $this->uniqueid;
$this->boundary[3] = 'b3_' . $this->uniqueid;
if ($this->sign_key_file) {
$body .= $this->getMailMIME() . static::$LE;
}
$this->setWordWrap();
$bodyEncoding = $this->Encoding;
$bodyCharSet = $this->CharSet;
//Can we do a 7-bit downgrade?
if (static::ENCODING_8BIT == $bodyEncoding and !$this->has8bitChars($this->Body)) {
$bodyEncoding = static::ENCODING_7BIT;
//All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
$bodyCharSet = 'us-ascii';
}
//If lines are too long, and we're not already using an encoding that will shorten them,
//change to quoted-printable transfer encoding for the body part only
if (static::ENCODING_BASE64 != $this->Encoding and static::hasLineLongerThanMax($this->Body)) {
$bodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
}
$altBodyEncoding = $this->Encoding;
$altBodyCharSet = $this->CharSet;
//Can we do a 7-bit downgrade?
if (static::ENCODING_8BIT == $altBodyEncoding and !$this->has8bitChars($this->AltBody)) {
$altBodyEncoding = static::ENCODING_7BIT;
//All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
$altBodyCharSet = 'us-ascii';
}
//If lines are too long, and we're not already using an encoding that will shorten them,
//change to quoted-printable transfer encoding for the alt body part only
if (static::ENCODING_BASE64 != $altBodyEncoding and static::hasLineLongerThanMax($this->AltBody)) {
$altBodyEncoding = static::ENCODING_QUOTED_PRINTABLE;
}
//Use this as a preamble in all multipart message types
$mimepre = 'This is a multi-part message in MIME format.' . static::$LE;
switch ($this->message_type) {
case 'inline':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[1]);
break;
case 'attach':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'inline_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
$body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[1], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
if (!empty($this->Ical)) {
$body .= $this->getBoundary($this->boundary[1], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=REQUEST', '');
$body .= $this->encodeString($this->Ical, $this->Encoding);
$body .= static::$LE;
}
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_inline':
$body .= $mimepre;
$body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '";');
$body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[2]);
$body .= static::$LE;
$body .= $this->endBoundary($this->boundary[1]);
break;
case 'alt_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
if (!empty($this->Ical)) {
$body .= $this->getBoundary($this->boundary[2], '', static::CONTENT_TYPE_TEXT_CALENDAR . '; method=REQUEST', '');
$body .= $this->encodeString($this->Ical, $this->Encoding);
}
$body .= $this->endBoundary($this->boundary[2]);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
case 'alt_inline_attach':
$body .= $mimepre;
$body .= $this->textLine('--' . $this->boundary[1]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_ALTERNATIVE . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[2] . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, static::CONTENT_TYPE_PLAINTEXT, $altBodyEncoding);
$body .= $this->encodeString($this->AltBody, $altBodyEncoding);
$body .= static::$LE;
$body .= $this->textLine('--' . $this->boundary[2]);
$body .= $this->headerLine('Content-Type', static::CONTENT_TYPE_MULTIPART_RELATED . ';');
$body .= $this->textLine(' boundary="' . $this->boundary[3] . '";');
$body .= $this->textLine(' type="' . static::CONTENT_TYPE_TEXT_HTML . '"');
$body .= static::$LE;
$body .= $this->getBoundary($this->boundary[3], $bodyCharSet, static::CONTENT_TYPE_TEXT_HTML, $bodyEncoding);
$body .= $this->encodeString($this->Body, $bodyEncoding);
$body .= static::$LE;
$body .= $this->attachAll('inline', $this->boundary[3]);
$body .= static::$LE;
$body .= $this->endBoundary($this->boundary[2]);
$body .= static::$LE;
$body .= $this->attachAll('attachment', $this->boundary[1]);
break;
default:
// Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types
//Reset the `Encoding` property in case we changed it for line length reasons
$this->Encoding = $bodyEncoding;
$body .= $this->encodeString($this->Body, $this->Encoding);
break;
}
if ($this->isError()) {
$body = '';
if ($this->exceptions) {
throw new Exception($this->lang('empty_message'), self::STOP_CRITICAL);
}
} elseif ($this->sign_key_file) {
try {
if (!defined('PKCS7_TEXT')) {
throw new Exception($this->lang('extension_missing') . 'openssl');
}
$file = fopen('php://temp', 'rb+');
$signed = fopen('php://temp', 'rb+');
fwrite($file, $body);
//Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
if (empty($this->sign_extracerts_file)) {
$sign = @openssl_pkcs7_sign(
$file,
$signed,
'file://' . realpath($this->sign_cert_file),
['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
[]
);
} else {
$sign = @openssl_pkcs7_sign(
$file,
$signed,
'file://' . realpath($this->sign_cert_file),
['file://' . realpath($this->sign_key_file), $this->sign_key_pass],
[],
PKCS7_DETACHED,
$this->sign_extracerts_file
);
}
fclose($file);
if ($sign) {
$body = file_get_contents($signed);
fclose($signed);
//The message returned by openssl contains both headers and body, so need to split them up
$parts = explode("\n\n", $body, 2);
$this->MIMEHeader .= $parts[0] . static::$LE . static::$LE;
$body = $parts[1];
} else {
fclose($signed);
throw new Exception($this->lang('signing') . openssl_error_string());
}
} catch (Exception $exc) {
$body = '';
if ($this->exceptions) {
throw $exc;
}
}
}
return $body;
} | [
"public",
"function",
"createBody",
"(",
")",
"{",
"$",
"body",
"=",
"''",
";",
"//Create unique IDs and preset boundaries",
"$",
"this",
"->",
"uniqueid",
"=",
"$",
"this",
"->",
"generateId",
"(",
")",
";",
"$",
"this",
"->",
"boundary",
"[",
"1",
"]",
... | Assemble the message body.
Returns an empty string on failure.
@throws Exception
@return string The assembled message body | [
"Assemble",
"the",
"message",
"body",
".",
"Returns",
"an",
"empty",
"string",
"on",
"failure",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L2509-L2720 | train | Create the body part of the message | [
30522,
2270,
3853,
3443,
23684,
1006,
1007,
1063,
1002,
2303,
1027,
1005,
1005,
1025,
1013,
1013,
3443,
4310,
8909,
2015,
1998,
3653,
13462,
7372,
1002,
2023,
1011,
1028,
4310,
3593,
1027,
1002,
2023,
1011,
1028,
9699,
3593,
1006,
1007,
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... |
overtrue/wechat | src/Kernel/Log/LogManager.php | LogManager.resolve | protected function resolve($name)
{
$config = $this->app['config']->get(\sprintf('log.channels.%s', $name));
if (is_null($config)) {
throw new \InvalidArgumentException(\sprintf('Log [%s] is not defined.', $name));
}
if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config);
}
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
}
throw new \InvalidArgumentException(\sprintf('Driver [%s] is not supported.', $config['driver']));
} | php | protected function resolve($name)
{
$config = $this->app['config']->get(\sprintf('log.channels.%s', $name));
if (is_null($config)) {
throw new \InvalidArgumentException(\sprintf('Log [%s] is not defined.', $name));
}
if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config);
}
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
}
throw new \InvalidArgumentException(\sprintf('Driver [%s] is not supported.', $config['driver']));
} | [
"protected",
"function",
"resolve",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"\\",
"sprintf",
"(",
"'log.channels.%s'",
",",
"$",
"name",
")",
")",
";",
"if",
"(",
"is_null",
... | Resolve the given log instance by name.
@param string $name
@return \Psr\Log\LoggerInterface
@throws \InvalidArgumentException | [
"Resolve",
"the",
"given",
"log",
"instance",
"by",
"name",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/Log/LogManager.php#L145-L164 | train | Resolves the log channel | [
30522,
5123,
3853,
10663,
1006,
1002,
2171,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
9530,
8873,
2290,
1005,
1033,
1011,
1028,
2131,
1006,
1032,
9043,
2546,
1006,
1005,
8833,
1012,
6833,
1012,
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... |
octobercms/october | modules/backend/formwidgets/RecordFinder.php | RecordFinder.prepareVars | public function prepareVars()
{
$this->relationModel = $this->getLoadValue();
if ($this->formField->disabled) {
$this->previewMode = true;
}
$this->vars['value'] = $this->getKeyValue();
$this->vars['field'] = $this->formField;
$this->vars['nameValue'] = $this->getNameValue();
$this->vars['descriptionValue'] = $this->getDescriptionValue();
$this->vars['listWidget'] = $this->listWidget;
$this->vars['searchWidget'] = $this->searchWidget;
$this->vars['title'] = $this->title;
$this->vars['prompt'] = str_replace('%s', '<i class="icon-th-list"></i>', e(trans($this->prompt)));
} | php | public function prepareVars()
{
$this->relationModel = $this->getLoadValue();
if ($this->formField->disabled) {
$this->previewMode = true;
}
$this->vars['value'] = $this->getKeyValue();
$this->vars['field'] = $this->formField;
$this->vars['nameValue'] = $this->getNameValue();
$this->vars['descriptionValue'] = $this->getDescriptionValue();
$this->vars['listWidget'] = $this->listWidget;
$this->vars['searchWidget'] = $this->searchWidget;
$this->vars['title'] = $this->title;
$this->vars['prompt'] = str_replace('%s', '<i class="icon-th-list"></i>', e(trans($this->prompt)));
} | [
"public",
"function",
"prepareVars",
"(",
")",
"{",
"$",
"this",
"->",
"relationModel",
"=",
"$",
"this",
"->",
"getLoadValue",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"formField",
"->",
"disabled",
")",
"{",
"$",
"this",
"->",
"previewMode",
"=",... | Prepares the list data | [
"Prepares",
"the",
"list",
"data"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/RecordFinder.php#L208-L224 | train | Prepares the form field variables | [
30522,
2270,
3853,
7374,
10755,
2015,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
7189,
5302,
9247,
1027,
1002,
2023,
1011,
1028,
2131,
11066,
10175,
5657,
1006,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
2433,
3790,
1011,
1028,
9776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/TwoFactorAuth/Controller.php | Controller.setupTwoFactorAuth | public function setupTwoFactorAuth($standalone = false)
{
$this->validator->checkCanUseTwoFa();
if ($standalone) {
$view = new View('@TwoFactorAuth/setupTwoFactorAuthStandalone');
$this->setBasicVariablesView($view);
$view->submitAction = 'onLoginSetupTwoFactorAuth';
} else {
$view = new View('@TwoFactorAuth/setupTwoFactorAuth');
$this->setGeneralVariablesView($view);
$view->submitAction = 'setupTwoFactorAuth';
$redirectParams = array('module' => 'TwoFactorAuth', 'action' => 'setupTwoFactorAuth');
if (!$this->passwordVerify->requirePasswordVerified($redirectParams)) {
// should usually not go in here but redirect instead
throw new Exception('You have to verify your password first.');
}
}
$session = $this->make2faSession();
if (empty($session->secret)) {
$session->secret = $this->twoFa->generateSecret();
}
$secret = $session->secret;
$session->setExpirationSeconds(60 * 15, 'secret');
$authCode = Common::getRequestVar('authCode', '', 'string');
$authCodeNonce = Common::getRequestVar('authCodeNonce', '', 'string');
$hasSubmittedForm = !empty($authCodeNonce) || !empty($authCode);
$accessErrorString = '';
$login = Piwik::getCurrentUserLogin();
if (!empty($secret) && !empty($authCode)
&& Nonce::verifyNonce(self::AUTH_CODE_NONCE, $authCodeNonce)) {
if ($this->twoFa->validateAuthCodeDuringSetup(trim($authCode), $secret)) {
$this->twoFa->saveSecret($login, $secret);
$fingerprint = new SessionFingerprint();
$fingerprint->setTwoFactorAuthenticationVerified();
unset($session->secret);
$this->passwordVerify->forgetVerifiedPassword();
Piwik::postEvent('TwoFactorAuth.enabled', array($login));
if ($standalone) {
$this->redirectToIndex('CoreHome', 'index');
return;
}
$view = new View('@TwoFactorAuth/setupFinished');
$this->setGeneralVariablesView($view);
return $view->render();
} else {
$accessErrorString = Piwik::translate('TwoFactorAuth_WrongAuthCodeTryAgain');
}
} elseif (!$standalone) {
// the user has not posted the form... at least not with a valid nonce... we make sure the password verify
// is valid for at least another 15 minutes and if not, ask for another password confirmation to avoid
// the user may be posting a valid auth code after rendering this screen but the password verify is invalid
// by then.
$redirectParams = array('module' => 'TwoFactorAuth', 'action' => 'setupTwoFactorAuth');
if (!$this->passwordVerify->requirePasswordVerifiedRecently($redirectParams)) {
throw new Exception('You have to verify your password first.');
}
}
if (!$this->recoveryCodeDao->getAllRecoveryCodesForLogin($login)
|| (!$hasSubmittedForm && !$this->twoFa->isUserUsingTwoFactorAuthentication($login))) {
// we cannot generate new codes after form has been submitted and user is not yet using 2fa cause we would
// change recovery codes in the background without the user noticing... we cannot simply do this:
// if !getAllRecoveryCodesForLogin => createRecoveryCodesForLogin. Because it could be a security issue that
// user might start the setup but never finishes. Before setting up 2fa the first time we have to change
// the recovery codes
$this->recoveryCodeDao->createRecoveryCodesForLogin($login);
}
$view->title = $this->settings->twoFactorAuthTitle->getValue();
$view->description = $login;
$view->authCodeNonce = Nonce::getNonce(self::AUTH_CODE_NONCE);
$view->AccessErrorString = $accessErrorString;
$view->isAlreadyUsing2fa = $this->twoFa->isUserUsingTwoFactorAuthentication($login);
$view->newSecret = $secret;
$view->twoFaBarCodeSetupUrl = $this->getTwoFaBarCodeSetupUrl($secret);
$view->codes = $this->recoveryCodeDao->getAllRecoveryCodesForLogin($login);
$view->standalone = $standalone;
return $view->render();
} | php | public function setupTwoFactorAuth($standalone = false)
{
$this->validator->checkCanUseTwoFa();
if ($standalone) {
$view = new View('@TwoFactorAuth/setupTwoFactorAuthStandalone');
$this->setBasicVariablesView($view);
$view->submitAction = 'onLoginSetupTwoFactorAuth';
} else {
$view = new View('@TwoFactorAuth/setupTwoFactorAuth');
$this->setGeneralVariablesView($view);
$view->submitAction = 'setupTwoFactorAuth';
$redirectParams = array('module' => 'TwoFactorAuth', 'action' => 'setupTwoFactorAuth');
if (!$this->passwordVerify->requirePasswordVerified($redirectParams)) {
// should usually not go in here but redirect instead
throw new Exception('You have to verify your password first.');
}
}
$session = $this->make2faSession();
if (empty($session->secret)) {
$session->secret = $this->twoFa->generateSecret();
}
$secret = $session->secret;
$session->setExpirationSeconds(60 * 15, 'secret');
$authCode = Common::getRequestVar('authCode', '', 'string');
$authCodeNonce = Common::getRequestVar('authCodeNonce', '', 'string');
$hasSubmittedForm = !empty($authCodeNonce) || !empty($authCode);
$accessErrorString = '';
$login = Piwik::getCurrentUserLogin();
if (!empty($secret) && !empty($authCode)
&& Nonce::verifyNonce(self::AUTH_CODE_NONCE, $authCodeNonce)) {
if ($this->twoFa->validateAuthCodeDuringSetup(trim($authCode), $secret)) {
$this->twoFa->saveSecret($login, $secret);
$fingerprint = new SessionFingerprint();
$fingerprint->setTwoFactorAuthenticationVerified();
unset($session->secret);
$this->passwordVerify->forgetVerifiedPassword();
Piwik::postEvent('TwoFactorAuth.enabled', array($login));
if ($standalone) {
$this->redirectToIndex('CoreHome', 'index');
return;
}
$view = new View('@TwoFactorAuth/setupFinished');
$this->setGeneralVariablesView($view);
return $view->render();
} else {
$accessErrorString = Piwik::translate('TwoFactorAuth_WrongAuthCodeTryAgain');
}
} elseif (!$standalone) {
// the user has not posted the form... at least not with a valid nonce... we make sure the password verify
// is valid for at least another 15 minutes and if not, ask for another password confirmation to avoid
// the user may be posting a valid auth code after rendering this screen but the password verify is invalid
// by then.
$redirectParams = array('module' => 'TwoFactorAuth', 'action' => 'setupTwoFactorAuth');
if (!$this->passwordVerify->requirePasswordVerifiedRecently($redirectParams)) {
throw new Exception('You have to verify your password first.');
}
}
if (!$this->recoveryCodeDao->getAllRecoveryCodesForLogin($login)
|| (!$hasSubmittedForm && !$this->twoFa->isUserUsingTwoFactorAuthentication($login))) {
// we cannot generate new codes after form has been submitted and user is not yet using 2fa cause we would
// change recovery codes in the background without the user noticing... we cannot simply do this:
// if !getAllRecoveryCodesForLogin => createRecoveryCodesForLogin. Because it could be a security issue that
// user might start the setup but never finishes. Before setting up 2fa the first time we have to change
// the recovery codes
$this->recoveryCodeDao->createRecoveryCodesForLogin($login);
}
$view->title = $this->settings->twoFactorAuthTitle->getValue();
$view->description = $login;
$view->authCodeNonce = Nonce::getNonce(self::AUTH_CODE_NONCE);
$view->AccessErrorString = $accessErrorString;
$view->isAlreadyUsing2fa = $this->twoFa->isUserUsingTwoFactorAuthentication($login);
$view->newSecret = $secret;
$view->twoFaBarCodeSetupUrl = $this->getTwoFaBarCodeSetupUrl($secret);
$view->codes = $this->recoveryCodeDao->getAllRecoveryCodesForLogin($login);
$view->standalone = $standalone;
return $view->render();
} | [
"public",
"function",
"setupTwoFactorAuth",
"(",
"$",
"standalone",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"validator",
"->",
"checkCanUseTwoFa",
"(",
")",
";",
"if",
"(",
"$",
"standalone",
")",
"{",
"$",
"view",
"=",
"new",
"View",
"(",
"'@TwoFacto... | Action to setup two factor authentication
@return string
@throws \Exception | [
"Action",
"to",
"setup",
"two",
"factor",
"authentication"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/TwoFactorAuth/Controller.php#L165-L254 | train | Setup TwoFactorAuth. | [
30522,
2270,
3853,
16437,
2102,
12155,
7011,
16761,
4887,
2705,
1006,
1002,
26609,
1027,
6270,
1007,
1063,
1002,
2023,
1011,
1028,
9398,
8844,
1011,
1028,
4638,
9336,
8557,
2102,
12155,
7011,
1006,
1007,
1025,
2065,
1006,
1002,
26609,
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 | core/Menu/MenuAdmin.php | MenuAdmin.getMenu | public function getMenu()
{
if (!$this->menu) {
foreach ($this->getAllMenus() as $menu) {
$menu->configureAdminMenu($this);
}
}
return parent::getMenu();
} | php | public function getMenu()
{
if (!$this->menu) {
foreach ($this->getAllMenus() as $menu) {
$menu->configureAdminMenu($this);
}
}
return parent::getMenu();
} | [
"public",
"function",
"getMenu",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"menu",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAllMenus",
"(",
")",
"as",
"$",
"menu",
")",
"{",
"$",
"menu",
"->",
"configureAdminMenu",
"(",
"$",
"this",... | Triggers the Menu.MenuAdmin.addItems hook and returns the admin menu.
@return Array | [
"Triggers",
"the",
"Menu",
".",
"MenuAdmin",
".",
"addItems",
"hook",
"and",
"returns",
"the",
"admin",
"menu",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Menu/MenuAdmin.php#L114-L124 | train | Get Admin Menu | [
30522,
2270,
3853,
2131,
3549,
2226,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
12183,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
8095,
3549,
2271,
1006,
1007,
2004,
1002,
12183,
1007,
1063,
1002,
12183,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Container/Container.php | Container.build | public function build($concrete)
{
// If the concrete type is actually a Closure, we will just execute it and
// hand back the results of the functions, which allows functions to be
// used as resolvers for more fine-tuned resolution of these objects.
if ($concrete instanceof Closure) {
return $concrete($this, $this->getLastParameterOverride());
}
$reflector = new ReflectionClass($concrete);
// If the type is not instantiable, the developer is attempting to resolve
// an abstract type such as an Interface or Abstract Class and there is
// no binding registered for the abstractions so we need to bail out.
if (! $reflector->isInstantiable()) {
return $this->notInstantiable($concrete);
}
$this->buildStack[] = $concrete;
$constructor = $reflector->getConstructor();
// If there are no constructors, that means there are no dependencies then
// we can just resolve the instances of the objects right away, without
// resolving any other types or dependencies out of these containers.
if (is_null($constructor)) {
array_pop($this->buildStack);
return new $concrete;
}
$dependencies = $constructor->getParameters();
// Once we have all the constructor's parameters we can create each of the
// dependency instances and then use the reflection instances to make a
// new instance of this class, injecting the created dependencies in.
$instances = $this->resolveDependencies(
$dependencies
);
array_pop($this->buildStack);
return $reflector->newInstanceArgs($instances);
} | php | public function build($concrete)
{
// If the concrete type is actually a Closure, we will just execute it and
// hand back the results of the functions, which allows functions to be
// used as resolvers for more fine-tuned resolution of these objects.
if ($concrete instanceof Closure) {
return $concrete($this, $this->getLastParameterOverride());
}
$reflector = new ReflectionClass($concrete);
// If the type is not instantiable, the developer is attempting to resolve
// an abstract type such as an Interface or Abstract Class and there is
// no binding registered for the abstractions so we need to bail out.
if (! $reflector->isInstantiable()) {
return $this->notInstantiable($concrete);
}
$this->buildStack[] = $concrete;
$constructor = $reflector->getConstructor();
// If there are no constructors, that means there are no dependencies then
// we can just resolve the instances of the objects right away, without
// resolving any other types or dependencies out of these containers.
if (is_null($constructor)) {
array_pop($this->buildStack);
return new $concrete;
}
$dependencies = $constructor->getParameters();
// Once we have all the constructor's parameters we can create each of the
// dependency instances and then use the reflection instances to make a
// new instance of this class, injecting the created dependencies in.
$instances = $this->resolveDependencies(
$dependencies
);
array_pop($this->buildStack);
return $reflector->newInstanceArgs($instances);
} | [
"public",
"function",
"build",
"(",
"$",
"concrete",
")",
"{",
"// If the concrete type is actually a Closure, we will just execute it and",
"// hand back the results of the functions, which allows functions to be",
"// used as resolvers for more fine-tuned resolution of these objects.",
"if",... | Instantiate a concrete instance of the given type.
@param string $concrete
@return mixed
@throws \Illuminate\Contracts\Container\BindingResolutionException | [
"Instantiate",
"a",
"concrete",
"instance",
"of",
"the",
"given",
"type",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L781-L824 | train | Builds the object of the given type. | [
30522,
2270,
3853,
3857,
1006,
1002,
5509,
1007,
1063,
1013,
1013,
2065,
1996,
5509,
2828,
2003,
2941,
1037,
8503,
1010,
2057,
2097,
2074,
15389,
2009,
1998,
1013,
1013,
2192,
2067,
1996,
3463,
1997,
1996,
4972,
1010,
2029,
4473,
4972,
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... |
octobercms/october | modules/backend/behaviors/ListController.php | ListController.listGetConfig | public function listGetConfig($definition = null)
{
if (!$definition) {
$definition = $this->primaryDefinition;
}
if (!$config = array_get($this->listConfig, $definition)) {
$config = $this->listConfig[$definition] = $this->makeConfig($this->listDefinitions[$definition], $this->requiredConfig);
}
return $config;
} | php | public function listGetConfig($definition = null)
{
if (!$definition) {
$definition = $this->primaryDefinition;
}
if (!$config = array_get($this->listConfig, $definition)) {
$config = $this->listConfig[$definition] = $this->makeConfig($this->listDefinitions[$definition], $this->requiredConfig);
}
return $config;
} | [
"public",
"function",
"listGetConfig",
"(",
"$",
"definition",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"definition",
")",
"{",
"$",
"definition",
"=",
"$",
"this",
"->",
"primaryDefinition",
";",
"}",
"if",
"(",
"!",
"$",
"config",
"=",
"array_get"... | Returns the configuration used by this behavior.
@return \Backend\Classes\WidgetBase | [
"Returns",
"the",
"configuration",
"used",
"by",
"this",
"behavior",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/ListController.php#L434-L445 | train | Get config from list definition | [
30522,
2270,
3853,
2862,
18150,
8663,
8873,
2290,
1006,
1002,
6210,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1002,
6210,
1007,
1063,
1002,
6210,
1027,
1002,
2023,
1011,
1028,
3078,
3207,
16294,
22753,
1025,
1065,
2065,
1006,
999,
1002,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/PrivacyManager/PrivacyManager.php | PrivacyManager.shouldPurgeData | private function shouldPurgeData($settings, $lastRanOption, $setting)
{
// Log deletion may not run until it is once rescheduled (initial run). This is the
// only way to guarantee the calculated next scheduled deletion time.
$initialDelete = Option::get(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL);
if (empty($initialDelete)) {
Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
return false;
}
// Make sure, log purging is allowed to run now
$lastDelete = Option::get($lastRanOption);
$deleteIntervalDays = $settings[$setting];
$deleteIntervalSeconds = $this->getDeleteIntervalInSeconds($deleteIntervalDays);
if ($lastDelete === false ||
$lastDelete === '' ||
((int)$lastDelete + $deleteIntervalSeconds) <= time()
) {
return true;
} else // not time to run data purge
{
return false;
}
} | php | private function shouldPurgeData($settings, $lastRanOption, $setting)
{
// Log deletion may not run until it is once rescheduled (initial run). This is the
// only way to guarantee the calculated next scheduled deletion time.
$initialDelete = Option::get(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL);
if (empty($initialDelete)) {
Option::set(self::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL, 1);
return false;
}
// Make sure, log purging is allowed to run now
$lastDelete = Option::get($lastRanOption);
$deleteIntervalDays = $settings[$setting];
$deleteIntervalSeconds = $this->getDeleteIntervalInSeconds($deleteIntervalDays);
if ($lastDelete === false ||
$lastDelete === '' ||
((int)$lastDelete + $deleteIntervalSeconds) <= time()
) {
return true;
} else // not time to run data purge
{
return false;
}
} | [
"private",
"function",
"shouldPurgeData",
"(",
"$",
"settings",
",",
"$",
"lastRanOption",
",",
"$",
"setting",
")",
"{",
"// Log deletion may not run until it is once rescheduled (initial run). This is the",
"// only way to guarantee the calculated next scheduled deletion time.",
"$... | Returns true if one of the purge data tasks should run now, false if it shouldn't. | [
"Returns",
"true",
"if",
"one",
"of",
"the",
"purge",
"data",
"tasks",
"should",
"run",
"now",
"false",
"if",
"it",
"shouldn",
"t",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L565-L589 | train | Check if data should be purged | [
30522,
2797,
3853,
2323,
5311,
5999,
6790,
1006,
1002,
10906,
1010,
1002,
2197,
20770,
16790,
1010,
1002,
4292,
1007,
1063,
1013,
1013,
8833,
3972,
20624,
2239,
2089,
2025,
2448,
2127,
2009,
2003,
2320,
24501,
7690,
18696,
1006,
3988,
2448,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Console/AppNameCommand.php | AppNameCommand.handle | public function handle()
{
$this->currentRoot = trim($this->laravel->getNamespace(), '\\');
$this->setAppDirectoryNamespace();
$this->setBootstrapNamespaces();
$this->setConfigNamespaces();
$this->setComposerNamespace();
$this->setDatabaseFactoryNamespaces();
$this->info('Application namespace set!');
$this->composer->dumpAutoloads();
$this->call('optimize:clear');
} | php | public function handle()
{
$this->currentRoot = trim($this->laravel->getNamespace(), '\\');
$this->setAppDirectoryNamespace();
$this->setBootstrapNamespaces();
$this->setConfigNamespaces();
$this->setComposerNamespace();
$this->setDatabaseFactoryNamespaces();
$this->info('Application namespace set!');
$this->composer->dumpAutoloads();
$this->call('optimize:clear');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"this",
"->",
"currentRoot",
"=",
"trim",
"(",
"$",
"this",
"->",
"laravel",
"->",
"getNamespace",
"(",
")",
",",
"'\\\\'",
")",
";",
"$",
"this",
"->",
"setAppDirectoryNamespace",
"(",
")",
";",
"$",... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/AppNameCommand.php#L68-L83 | train | Set the application namespace | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2783,
3217,
4140,
1027,
12241,
1006,
1002,
2023,
1011,
1028,
13679,
15985,
1011,
1028,
2131,
18442,
23058,
1006,
1007,
1010,
1005,
1032,
1032,
1005,
1007,
1025,
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... |
matomo-org/matomo | core/Metrics/Formatter.php | Formatter.getPrettyTimeFromSeconds | public function getPrettyTimeFromSeconds($numberOfSeconds, $displayTimeAsSentence = false, $round = false)
{
$numberOfSeconds = $round ? (int)$numberOfSeconds : (float)$numberOfSeconds;
$isNegative = false;
if ($numberOfSeconds < 0) {
$numberOfSeconds = -1 * $numberOfSeconds;
$isNegative = true;
}
// Display 01:45:17 time format
if ($displayTimeAsSentence === false) {
$days = floor($numberOfSeconds / 86400);
$hours = floor(($reminder = ($numberOfSeconds - $days * 86400)) / 3600);
$minutes = floor(($reminder = ($reminder - $hours * 3600)) / 60);
$seconds = floor($reminder - $minutes * 60);
if ($days == 0) {
$time = sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
} else {
$time = sprintf(Piwik::translate('Intl_NDays'), $days) . " " . sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
}
$centiSeconds = ($numberOfSeconds * 100) % 100;
if ($centiSeconds) {
$time .= '.' . sprintf("%02s", $centiSeconds);
}
if ($isNegative) {
$time = '-' . $time;
}
return $time;
}
$secondsInYear = 86400 * 365.25;
$years = floor($numberOfSeconds / $secondsInYear);
$minusYears = $numberOfSeconds - $years * $secondsInYear;
$days = floor($minusYears / 86400);
$minusDays = $numberOfSeconds - $days * 86400;
$hours = floor($minusDays / 3600);
$minusDaysAndHours = $minusDays - $hours * 3600;
$minutes = floor($minusDaysAndHours / 60);
$seconds = $minusDaysAndHours - $minutes * 60;
$precision = ($seconds > 0 && $seconds < 0.01 ? 3 : 2);
$seconds = NumberFormatter::getInstance()->formatNumber(round($seconds, $precision), $precision);
if ($years > 0) {
$return = sprintf(Piwik::translate('General_YearsDays'), $years, $days);
} elseif ($days > 0) {
$return = sprintf(Piwik::translate('General_DaysHours'), $days, $hours);
} elseif ($hours > 0) {
$return = sprintf(Piwik::translate('General_HoursMinutes'), $hours, $minutes);
} elseif ($minutes > 0) {
$return = sprintf(Piwik::translate('General_MinutesSeconds'), $minutes, $seconds);
} else {
$return = sprintf(Piwik::translate('Intl_NSecondsShort'), $seconds);
}
if ($isNegative) {
$return = '-' . $return;
}
return $return;
} | php | public function getPrettyTimeFromSeconds($numberOfSeconds, $displayTimeAsSentence = false, $round = false)
{
$numberOfSeconds = $round ? (int)$numberOfSeconds : (float)$numberOfSeconds;
$isNegative = false;
if ($numberOfSeconds < 0) {
$numberOfSeconds = -1 * $numberOfSeconds;
$isNegative = true;
}
// Display 01:45:17 time format
if ($displayTimeAsSentence === false) {
$days = floor($numberOfSeconds / 86400);
$hours = floor(($reminder = ($numberOfSeconds - $days * 86400)) / 3600);
$minutes = floor(($reminder = ($reminder - $hours * 3600)) / 60);
$seconds = floor($reminder - $minutes * 60);
if ($days == 0) {
$time = sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
} else {
$time = sprintf(Piwik::translate('Intl_NDays'), $days) . " " . sprintf("%02s", $hours) . ':' . sprintf("%02s", $minutes) . ':' . sprintf("%02s", $seconds);
}
$centiSeconds = ($numberOfSeconds * 100) % 100;
if ($centiSeconds) {
$time .= '.' . sprintf("%02s", $centiSeconds);
}
if ($isNegative) {
$time = '-' . $time;
}
return $time;
}
$secondsInYear = 86400 * 365.25;
$years = floor($numberOfSeconds / $secondsInYear);
$minusYears = $numberOfSeconds - $years * $secondsInYear;
$days = floor($minusYears / 86400);
$minusDays = $numberOfSeconds - $days * 86400;
$hours = floor($minusDays / 3600);
$minusDaysAndHours = $minusDays - $hours * 3600;
$minutes = floor($minusDaysAndHours / 60);
$seconds = $minusDaysAndHours - $minutes * 60;
$precision = ($seconds > 0 && $seconds < 0.01 ? 3 : 2);
$seconds = NumberFormatter::getInstance()->formatNumber(round($seconds, $precision), $precision);
if ($years > 0) {
$return = sprintf(Piwik::translate('General_YearsDays'), $years, $days);
} elseif ($days > 0) {
$return = sprintf(Piwik::translate('General_DaysHours'), $days, $hours);
} elseif ($hours > 0) {
$return = sprintf(Piwik::translate('General_HoursMinutes'), $hours, $minutes);
} elseif ($minutes > 0) {
$return = sprintf(Piwik::translate('General_MinutesSeconds'), $minutes, $seconds);
} else {
$return = sprintf(Piwik::translate('Intl_NSecondsShort'), $seconds);
}
if ($isNegative) {
$return = '-' . $return;
}
return $return;
} | [
"public",
"function",
"getPrettyTimeFromSeconds",
"(",
"$",
"numberOfSeconds",
",",
"$",
"displayTimeAsSentence",
"=",
"false",
",",
"$",
"round",
"=",
"false",
")",
"{",
"$",
"numberOfSeconds",
"=",
"$",
"round",
"?",
"(",
"int",
")",
"$",
"numberOfSeconds",
... | Returns a prettified time value (in seconds).
@param int $numberOfSeconds The number of seconds.
@param bool $displayTimeAsSentence If set to true, will output `"5min 17s"`, if false `"00:05:17"`.
@param bool $round Whether to round to the nearest second or not.
@return string
@api | [
"Returns",
"a",
"prettified",
"time",
"value",
"(",
"in",
"seconds",
")",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Metrics/Formatter.php#L63-L126 | train | Returns a human readable time string from seconds | [
30522,
2270,
3853,
2131,
28139,
15353,
7292,
19699,
22225,
8586,
15422,
30524,
1063,
1002,
2193,
11253,
3366,
8663,
5104,
1027,
1002,
2461,
1029,
1006,
20014,
1007,
1002,
2193,
11253,
3366,
8663,
5104,
1024,
1006,
14257,
1007,
1002,
2193,
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/Plugin/Manager.php | Manager.findComponents | public function findComponents($componentName, $expectedSubclass)
{
$plugins = $this->getPluginsLoadedAndActivated();
$components = array();
foreach ($plugins as $plugin) {
$component = $plugin->findComponent($componentName, $expectedSubclass);
if (!empty($component)) {
$components[] = $component;
}
}
return $components;
} | php | public function findComponents($componentName, $expectedSubclass)
{
$plugins = $this->getPluginsLoadedAndActivated();
$components = array();
foreach ($plugins as $plugin) {
$component = $plugin->findComponent($componentName, $expectedSubclass);
if (!empty($component)) {
$components[] = $component;
}
}
return $components;
} | [
"public",
"function",
"findComponents",
"(",
"$",
"componentName",
",",
"$",
"expectedSubclass",
")",
"{",
"$",
"plugins",
"=",
"$",
"this",
"->",
"getPluginsLoadedAndActivated",
"(",
")",
";",
"$",
"components",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
... | Tries to find the given components such as a Menu or Tasks implemented by plugins.
This method won't cache the found components. If you need to find the same component multiple times you might
want to cache the result to save a tiny bit of time.
@param string $componentName The name of the component you want to look for. In case you request a
component named 'Menu' it'll look for a file named 'Menu.php' within the
root of all plugin folders that implement a class named
Piwik\Plugin\$PluginName\Menu.
@param string $expectedSubclass If not empty, a check will be performed whether a found file extends the
given subclass. If the requested file exists but does not extend this class
a warning will be shown to advice a developer to extend this certain class.
@return \stdClass[] | [
"Tries",
"to",
"find",
"the",
"given",
"components",
"such",
"as",
"a",
"Menu",
"or",
"Tasks",
"implemented",
"by",
"plugins",
".",
"This",
"method",
"won",
"t",
"cache",
"the",
"found",
"components",
".",
"If",
"you",
"need",
"to",
"find",
"the",
"same"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Manager.php#L520-L534 | train | Find all components that match the given component name and expected subclass | [
30522,
2270,
3853,
2424,
9006,
29513,
7666,
1006,
1002,
6922,
18442,
1010,
1002,
3517,
6342,
9818,
27102,
1007,
1063,
1002,
13354,
7076,
1027,
1002,
2023,
1011,
1028,
2131,
24759,
15916,
7076,
17468,
13832,
6593,
21967,
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... |
getgrav/grav | system/src/Grav/Console/Gpm/InstallCommand.php | InstallCommand.processGpm | private function processGpm($package, $is_update = false)
{
$version = isset($package->available) ? $package->available : $package->version;
$license = Licenses::get($package->slug);
$this->output->writeln("Preparing to install <cyan>{$package->name}</cyan> [v{$version}]");
$this->output->write(' |- Downloading package... 0%');
$this->file = $this->downloadPackage($package, $license);
if (!$this->file) {
$this->output->writeln(" '- <red>Installation failed or aborted.</red>");
$this->output->writeln('');
return false;
}
$this->output->write(' |- Checking destination... ');
$checks = $this->checkDestination($package);
if (!$checks) {
$this->output->writeln(" '- <red>Installation failed or aborted.</red>");
$this->output->writeln('');
} else {
$this->output->write(' |- Installing package... ');
$installation = $this->installPackage($package, $is_update);
if (!$installation) {
$this->output->writeln(" '- <red>Installation failed or aborted.</red>");
$this->output->writeln('');
} else {
$this->output->writeln(" '- <green>Success!</green> ");
$this->output->writeln('');
return true;
}
}
return false;
} | php | private function processGpm($package, $is_update = false)
{
$version = isset($package->available) ? $package->available : $package->version;
$license = Licenses::get($package->slug);
$this->output->writeln("Preparing to install <cyan>{$package->name}</cyan> [v{$version}]");
$this->output->write(' |- Downloading package... 0%');
$this->file = $this->downloadPackage($package, $license);
if (!$this->file) {
$this->output->writeln(" '- <red>Installation failed or aborted.</red>");
$this->output->writeln('');
return false;
}
$this->output->write(' |- Checking destination... ');
$checks = $this->checkDestination($package);
if (!$checks) {
$this->output->writeln(" '- <red>Installation failed or aborted.</red>");
$this->output->writeln('');
} else {
$this->output->write(' |- Installing package... ');
$installation = $this->installPackage($package, $is_update);
if (!$installation) {
$this->output->writeln(" '- <red>Installation failed or aborted.</red>");
$this->output->writeln('');
} else {
$this->output->writeln(" '- <green>Success!</green> ");
$this->output->writeln('');
return true;
}
}
return false;
} | [
"private",
"function",
"processGpm",
"(",
"$",
"package",
",",
"$",
"is_update",
"=",
"false",
")",
"{",
"$",
"version",
"=",
"isset",
"(",
"$",
"package",
"->",
"available",
")",
"?",
"$",
"package",
"->",
"available",
":",
"$",
"package",
"->",
"vers... | @param Package $package
@param bool $is_update
@return bool | [
"@param",
"Package",
"$package",
"@param",
"bool",
"$is_update"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/Gpm/InstallCommand.php#L512-L550 | train | Process GPM package | [
30522,
2797,
3853,
2832,
21600,
2213,
1006,
1002,
7427,
1010,
1002,
2003,
1035,
10651,
1027,
6270,
1007,
1063,
1002,
2544,
1027,
26354,
3388,
1006,
1002,
7427,
1011,
1028,
2800,
1007,
1029,
1002,
7427,
1011,
1028,
2800,
1024,
1002,
7427,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/QuickForm2/Factory.php | HTML_QuickForm2_Factory.createElement | public static function createElement($type, $name = null, $attributes = null,
array $data = array())
{
$type = strtolower($type);
if (!isset(self::$elementTypes[$type])) {
throw new HTML_QuickForm2_InvalidArgumentException("Element type '$type' is not known");
}
list($className, $includeFile) = self::$elementTypes[$type];
if (!class_exists($className)) {
HTML_QuickForm2_Loader::loadClass($className, $includeFile);
}
return new $className($name, $attributes, $data);
} | php | public static function createElement($type, $name = null, $attributes = null,
array $data = array())
{
$type = strtolower($type);
if (!isset(self::$elementTypes[$type])) {
throw new HTML_QuickForm2_InvalidArgumentException("Element type '$type' is not known");
}
list($className, $includeFile) = self::$elementTypes[$type];
if (!class_exists($className)) {
HTML_QuickForm2_Loader::loadClass($className, $includeFile);
}
return new $className($name, $attributes, $data);
} | [
"public",
"static",
"function",
"createElement",
"(",
"$",
"type",
",",
"$",
"name",
"=",
"null",
",",
"$",
"attributes",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")... | Creates a new element object of the given type
@param string Type name (treated case-insensitively)
@param mixed Element name (passed to element's constructor)
@param mixed Element attributes (passed to element's constructor)
@param array Element-specific data (passed to element's constructor)
@return HTML_QuickForm2_Node A created element
@throws HTML_QuickForm2_InvalidArgumentException If type name is unknown
@throws HTML_QuickForm2_NotFoundException If class for the element can
not be found and/or loaded from file | [
"Creates",
"a",
"new",
"element",
"object",
"of",
"the",
"given",
"type"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Factory.php#L161-L173 | train | Creates an element of the given type | [
30522,
2270,
10763,
3853,
3443,
12260,
3672,
1006,
1002,
2828,
1010,
1002,
2171,
1027,
19701,
1010,
1002,
12332,
1027,
19701,
1010,
9140,
1002,
2951,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
2828,
1027,
2358,
5339,
12898,
13777,
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... |
laravel/framework | src/Illuminate/Cache/CacheManager.php | CacheManager.createDynamodbDriver | protected function createDynamodbDriver(array $config)
{
$dynamoConfig = [
'region' => $config['region'],
'version' => 'latest',
];
if ($config['key'] && $config['secret']) {
$dynamoConfig['credentials'] = Arr::only(
$config, ['key', 'secret', 'token']
);
}
return $this->repository(
new DynamoDbStore(
new DynamoDbClient($dynamoConfig),
$config['table'],
$config['attributes']['key'] ?? 'key',
$config['attributes']['value'] ?? 'value',
$config['attributes']['expiration'] ?? 'expires_at',
$this->getPrefix($config)
)
);
} | php | protected function createDynamodbDriver(array $config)
{
$dynamoConfig = [
'region' => $config['region'],
'version' => 'latest',
];
if ($config['key'] && $config['secret']) {
$dynamoConfig['credentials'] = Arr::only(
$config, ['key', 'secret', 'token']
);
}
return $this->repository(
new DynamoDbStore(
new DynamoDbClient($dynamoConfig),
$config['table'],
$config['attributes']['key'] ?? 'key',
$config['attributes']['value'] ?? 'value',
$config['attributes']['expiration'] ?? 'expires_at',
$this->getPrefix($config)
)
);
} | [
"protected",
"function",
"createDynamodbDriver",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"dynamoConfig",
"=",
"[",
"'region'",
"=>",
"$",
"config",
"[",
"'region'",
"]",
",",
"'version'",
"=>",
"'latest'",
",",
"]",
";",
"if",
"(",
"$",
"config",
"["... | Create an instance of the DynamoDB cache driver.
@param array $config
@return \Illuminate\Cache\Repository | [
"Create",
"an",
"instance",
"of",
"the",
"DynamoDB",
"cache",
"driver",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/CacheManager.php#L227-L250 | train | Create a Dynamodb driver | [
30522,
5123,
3853,
2580,
18279,
5302,
18939,
23663,
2099,
1006,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
17205,
8663,
8873,
2290,
1027,
1031,
1005,
2555,
1005,
1027,
1028,
1002,
9530,
8873,
2290,
1031,
1005,
2555,
1005,
1033,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Relations/MorphToMany.php | MorphToMany.baseAttachRecord | protected function baseAttachRecord($id, $timed)
{
return Arr::add(
parent::baseAttachRecord($id, $timed), $this->morphType, $this->morphClass
);
} | php | protected function baseAttachRecord($id, $timed)
{
return Arr::add(
parent::baseAttachRecord($id, $timed), $this->morphType, $this->morphClass
);
} | [
"protected",
"function",
"baseAttachRecord",
"(",
"$",
"id",
",",
"$",
"timed",
")",
"{",
"return",
"Arr",
"::",
"add",
"(",
"parent",
"::",
"baseAttachRecord",
"(",
"$",
"id",
",",
"$",
"timed",
")",
",",
"$",
"this",
"->",
"morphType",
",",
"$",
"t... | Create a new pivot attachment record.
@param int $id
@param bool $timed
@return array | [
"Create",
"a",
"new",
"pivot",
"attachment",
"record",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php#L96-L101 | train | Base attach record | [
30522,
5123,
3853,
2918,
19321,
6776,
2890,
27108,
2094,
1006,
1002,
8909,
1010,
1002,
22313,
1007,
1063,
2709,
12098,
2099,
1024,
1024,
5587,
1006,
6687,
1024,
1024,
2918,
19321,
6776,
2890,
27108,
2094,
1006,
1002,
8909,
1010,
1002,
22313... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getSitesWithAtLeastViewAccess | public function getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin = false)
{
$sitesId = $this->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
return $this->getSitesFromIds($sitesId, $limit);
} | php | public function getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin = false)
{
$sitesId = $this->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
return $this->getSitesFromIds($sitesId, $limit);
} | [
"public",
"function",
"getSitesWithAtLeastViewAccess",
"(",
"$",
"limit",
"=",
"false",
",",
"$",
"_restrictSitesToLogin",
"=",
"false",
")",
"{",
"$",
"sitesId",
"=",
"$",
"this",
"->",
"getSitesIdWithAtLeastViewAccess",
"(",
"$",
"_restrictSitesToLogin",
")",
";... | Returns the list of websites with the 'view' or 'admin' access for the current user.
For the superUser it returns all the websites in the database.
@param bool|int $limit Specify max number of sites to return
@param bool $_restrictSitesToLogin Hack necessary when running scheduled tasks, where "Super User" is forced, but sometimes not desired, see #3017
@return array array for each site, an array of information (idsite, name, main_url, etc.) | [
"Returns",
"the",
"list",
"of",
"websites",
"with",
"the",
"view",
"or",
"admin",
"access",
"for",
"the",
"current",
"user",
".",
"For",
"the",
"superUser",
"it",
"returns",
"all",
"the",
"websites",
"in",
"the",
"database",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L390-L394 | train | Get all the sites with view access for the current user. | [
30522,
2270,
3853,
4152,
7616,
24415,
4017,
19738,
3367,
8584,
6305,
9623,
2015,
1006,
1002,
5787,
1027,
6270,
1010,
1002,
1035,
21573,
28032,
4355,
12898,
11528,
1027,
6270,
1007,
1063,
1002,
4573,
3593,
1027,
1002,
2023,
1011,
1028,
4152,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/SegmentEditor/Services/StoredSegmentService.php | StoredSegmentService.getAllSegmentsAndIgnoreVisibility | public function getAllSegmentsAndIgnoreVisibility()
{
$cacheKey = 'SegmentEditor.getAllSegmentsAndIgnoreVisibility';
if (!$this->transientCache->contains($cacheKey)) {
$result = $this->model->getAllSegmentsAndIgnoreVisibility();
$this->transientCache->save($cacheKey, $result);
}
return $this->transientCache->fetch($cacheKey);
} | php | public function getAllSegmentsAndIgnoreVisibility()
{
$cacheKey = 'SegmentEditor.getAllSegmentsAndIgnoreVisibility';
if (!$this->transientCache->contains($cacheKey)) {
$result = $this->model->getAllSegmentsAndIgnoreVisibility();
$this->transientCache->save($cacheKey, $result);
}
return $this->transientCache->fetch($cacheKey);
} | [
"public",
"function",
"getAllSegmentsAndIgnoreVisibility",
"(",
")",
"{",
"$",
"cacheKey",
"=",
"'SegmentEditor.getAllSegmentsAndIgnoreVisibility'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"transientCache",
"->",
"contains",
"(",
"$",
"cacheKey",
")",
")",
"{",
"$... | Returns all stored segments that haven't been deleted.
@return array | [
"Returns",
"all",
"stored",
"segments",
"that",
"haven",
"t",
"been",
"deleted",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SegmentEditor/Services/StoredSegmentService.php#L41-L50 | train | Get All Segments And Ignore Visibility | [
30522,
2270,
3853,
2131,
8095,
3366,
21693,
11187,
5685,
23773,
5686,
11365,
13464,
1006,
1007,
1063,
1002,
17053,
14839,
1027,
1005,
6903,
2098,
15660,
1012,
2131,
8095,
3366,
21693,
11187,
5685,
23773,
5686,
11365,
13464,
1005,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getRawSegmentFromRequest | public static function getRawSegmentFromRequest()
{
// we need the URL encoded segment parameter, we fetch it from _SERVER['QUERY_STRING'] instead of default URL decoded _GET
$segmentRaw = false;
$segment = Common::getRequestVar('segment', '', 'string');
if (!empty($segment)) {
$request = Request::getRequestParametersGET();
if (!empty($request['segment'])) {
$segmentRaw = $request['segment'];
}
}
return $segmentRaw;
} | php | public static function getRawSegmentFromRequest()
{
// we need the URL encoded segment parameter, we fetch it from _SERVER['QUERY_STRING'] instead of default URL decoded _GET
$segmentRaw = false;
$segment = Common::getRequestVar('segment', '', 'string');
if (!empty($segment)) {
$request = Request::getRequestParametersGET();
if (!empty($request['segment'])) {
$segmentRaw = $request['segment'];
}
}
return $segmentRaw;
} | [
"public",
"static",
"function",
"getRawSegmentFromRequest",
"(",
")",
"{",
"// we need the URL encoded segment parameter, we fetch it from _SERVER['QUERY_STRING'] instead of default URL decoded _GET",
"$",
"segmentRaw",
"=",
"false",
";",
"$",
"segment",
"=",
"Common",
"::",
"get... | Returns the segment query parameter from the original request, without modifications.
@return array|bool | [
"Returns",
"the",
"segment",
"query",
"parameter",
"from",
"the",
"original",
"request",
"without",
"modifications",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Request.php#L591-L603 | train | Returns the raw segment parameter from the request | [
30522,
2270,
10763,
3853,
2131,
2527,
9333,
13910,
3672,
19699,
5358,
2890,
15500,
1006,
1007,
1063,
1013,
1013,
2057,
2342,
1996,
24471,
2140,
12359,
6903,
16381,
1010,
2057,
18584,
2009,
2013,
1035,
8241,
1031,
1005,
23032,
1035,
5164,
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... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.cachePageContent | public function cachePageContent()
{
$cache = Grav::instance()['cache'];
$cache_id = md5('page' . $this->id());
$cache->save($cache_id, ['content' => $this->content, 'content_meta' => $this->content_meta]);
} | php | public function cachePageContent()
{
$cache = Grav::instance()['cache'];
$cache_id = md5('page' . $this->id());
$cache->save($cache_id, ['content' => $this->content, 'content_meta' => $this->content_meta]);
} | [
"public",
"function",
"cachePageContent",
"(",
")",
"{",
"$",
"cache",
"=",
"Grav",
"::",
"instance",
"(",
")",
"[",
"'cache'",
"]",
";",
"$",
"cache_id",
"=",
"md5",
"(",
"'page'",
".",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"cache",
... | Fires the onPageContentProcessed event, and caches the page content using a unique ID for the page | [
"Fires",
"the",
"onPageContentProcessed",
"event",
"and",
"caches",
"the",
"page",
"content",
"using",
"a",
"unique",
"ID",
"for",
"the",
"page"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L857-L862 | train | Cache page content | [
30522,
2270,
3853,
17053,
13704,
8663,
6528,
2102,
1006,
1007,
1063,
1002,
17053,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1031,
1005,
17053,
1005,
1033,
1025,
1002,
17053,
1035,
8909,
1027,
9108,
2629,
1006,
1005,
3931,
1005,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ParameterBagUtils.php | ParameterBagUtils.getRequestParameterValue | public static function getRequestParameterValue(Request $request, $path)
{
if (false === $pos = strpos($path, '[')) {
return $request->get($path);
}
$root = substr($path, 0, $pos);
if (null === $value = $request->get($root)) {
return;
}
if (null === self::$propertyAccessor) {
self::$propertyAccessor = PropertyAccess::createPropertyAccessor();
}
try {
return self::$propertyAccessor->getValue($value, substr($path, $pos));
} catch (AccessException $e) {
return;
}
} | php | public static function getRequestParameterValue(Request $request, $path)
{
if (false === $pos = strpos($path, '[')) {
return $request->get($path);
}
$root = substr($path, 0, $pos);
if (null === $value = $request->get($root)) {
return;
}
if (null === self::$propertyAccessor) {
self::$propertyAccessor = PropertyAccess::createPropertyAccessor();
}
try {
return self::$propertyAccessor->getValue($value, substr($path, $pos));
} catch (AccessException $e) {
return;
}
} | [
"public",
"static",
"function",
"getRequestParameterValue",
"(",
"Request",
"$",
"request",
",",
"$",
"path",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"path",
",",
"'['",
")",
")",
"{",
"return",
"$",
"request",
"->",
... | Returns a request "parameter" value.
Paths like foo[bar] will be evaluated to find deeper items in nested data structures.
@param Request $request The request
@param string $path The key
@return mixed
@throws InvalidArgumentException when the given path is malformed | [
"Returns",
"a",
"request",
"parameter",
"value",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/ParameterBagUtils.php#L74-L95 | train | Get request parameter value | [
30522,
2270,
10763,
3853,
2131,
2890,
15500,
28689,
22828,
10175,
5657,
1006,
5227,
1002,
5227,
1010,
1002,
4130,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
1002,
13433,
2015,
1027,
2358,
14536,
2891,
1006,
1002,
4130,
1010,
1005,
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 | plugins/Goals/Goals.php | Goals.getReportMetadataEnd | public function getReportMetadataEnd(&$reports, $info)
{
// Processed in AddColumnsProcessedMetricsGoal
// These metrics will also be available for some reports, for each goal
// Example: Conversion rate for Goal 2 for the keyword 'piwik'
$goalProcessedMetrics = array(
'revenue_per_visit' => Piwik::translate('General_ColumnValuePerVisit'),
);
$goalMetrics = array(
'nb_conversions' => Piwik::translate('Goals_ColumnConversions'),
'conversion_rate' => Piwik::translate('General_ColumnConversionRate'),
'revenue' => Piwik::translate('General_ColumnRevenue')
);
$reportsWithGoals = self::getAllReportsWithGoalMetrics();
foreach ($reportsWithGoals as $reportWithGoals) {
// Select this report from the API metadata array
// and add the Goal metrics to it
foreach ($reports as &$apiReportToUpdate) {
if ($apiReportToUpdate['module'] == $reportWithGoals['module']
&& $apiReportToUpdate['action'] == $reportWithGoals['action']
&& empty($apiReportToUpdate['parameters'])) {
$apiReportToUpdate['metricsGoal'] = $goalMetrics;
$apiReportToUpdate['processedMetricsGoal'] = $goalProcessedMetrics;
break;
}
}
}
} | php | public function getReportMetadataEnd(&$reports, $info)
{
// Processed in AddColumnsProcessedMetricsGoal
// These metrics will also be available for some reports, for each goal
// Example: Conversion rate for Goal 2 for the keyword 'piwik'
$goalProcessedMetrics = array(
'revenue_per_visit' => Piwik::translate('General_ColumnValuePerVisit'),
);
$goalMetrics = array(
'nb_conversions' => Piwik::translate('Goals_ColumnConversions'),
'conversion_rate' => Piwik::translate('General_ColumnConversionRate'),
'revenue' => Piwik::translate('General_ColumnRevenue')
);
$reportsWithGoals = self::getAllReportsWithGoalMetrics();
foreach ($reportsWithGoals as $reportWithGoals) {
// Select this report from the API metadata array
// and add the Goal metrics to it
foreach ($reports as &$apiReportToUpdate) {
if ($apiReportToUpdate['module'] == $reportWithGoals['module']
&& $apiReportToUpdate['action'] == $reportWithGoals['action']
&& empty($apiReportToUpdate['parameters'])) {
$apiReportToUpdate['metricsGoal'] = $goalMetrics;
$apiReportToUpdate['processedMetricsGoal'] = $goalProcessedMetrics;
break;
}
}
}
} | [
"public",
"function",
"getReportMetadataEnd",
"(",
"&",
"$",
"reports",
",",
"$",
"info",
")",
"{",
"// Processed in AddColumnsProcessedMetricsGoal",
"// These metrics will also be available for some reports, for each goal",
"// Example: Conversion rate for Goal 2 for the keyword 'piwik'... | Returns the Metadata for the Goals plugin API.
The API returns general Goal metrics: conv, conv rate and revenue globally
and for each goal.
Also, this will update metadata of all other reports that have Goal segmentation | [
"Returns",
"the",
"Metadata",
"for",
"the",
"Goals",
"plugin",
"API",
".",
"The",
"API",
"returns",
"general",
"Goal",
"metrics",
":",
"conv",
"conv",
"rate",
"and",
"revenue",
"globally",
"and",
"for",
"each",
"goal",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Goals/Goals.php#L244-L274 | train | This method is called when the report metadata end is called. | [
30522,
2270,
3853,
2131,
2890,
6442,
11368,
8447,
2696,
10497,
1006,
1004,
1002,
4311,
1010,
1002,
18558,
1007,
1063,
1013,
1013,
13995,
1999,
5587,
25778,
2819,
3619,
21572,
9623,
6924,
12589,
28745,
10441,
2140,
1013,
1013,
2122,
12046,
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/NativeRequestHandler.php | NativeRequestHandler.handleRequest | public function handleRequest(FormInterface $form, $request = null)
{
if (null !== $request) {
throw new UnexpectedTypeException($request, 'null');
}
$name = $form->getName();
$method = $form->getConfig()->getMethod();
if ($method !== self::getRequestMethod()) {
return;
}
// For request methods that must not have a request body we fetch data
// from the query string. Otherwise we look for data in the request body.
if ('GET' === $method || 'HEAD' === $method || 'TRACE' === $method) {
if ('' === $name) {
$data = $_GET;
} else {
// Don't submit GET requests if the form's name does not exist
// in the request
if (!isset($_GET[$name])) {
return;
}
$data = $_GET[$name];
}
} else {
// Mark the form with an error if the uploaded size was too large
// This is done here and not in FormValidator because $_POST is
// empty when that error occurs. Hence the form is never submitted.
if ($this->serverParams->hasPostMaxSizeBeenExceeded()) {
// Submit the form, but don't clear the default values
$form->submit(null, false);
$form->addError(new FormError(
$form->getConfig()->getOption('upload_max_size_message')(),
null,
['{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize()]
));
return;
}
$fixedFiles = [];
foreach ($_FILES as $fileKey => $file) {
$fixedFiles[$fileKey] = self::stripEmptyFiles(self::fixPhpFilesArray($file));
}
if ('' === $name) {
$params = $_POST;
$files = $fixedFiles;
} elseif (\array_key_exists($name, $_POST) || \array_key_exists($name, $fixedFiles)) {
$default = $form->getConfig()->getCompound() ? [] : null;
$params = \array_key_exists($name, $_POST) ? $_POST[$name] : $default;
$files = \array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default;
} else {
// Don't submit the form if it is not present in the request
return;
}
if (\is_array($params) && \is_array($files)) {
$data = array_replace_recursive($params, $files);
} else {
$data = $params ?: $files;
}
}
// Don't auto-submit the form unless at least one field is present.
if ('' === $name && \count(array_intersect_key($data, $form->all())) <= 0) {
return;
}
if (\is_array($data) && \array_key_exists('_method', $data) && $method === $data['_method'] && !$form->has('_method')) {
unset($data['_method']);
}
$form->submit($data, 'PATCH' !== $method);
} | php | public function handleRequest(FormInterface $form, $request = null)
{
if (null !== $request) {
throw new UnexpectedTypeException($request, 'null');
}
$name = $form->getName();
$method = $form->getConfig()->getMethod();
if ($method !== self::getRequestMethod()) {
return;
}
// For request methods that must not have a request body we fetch data
// from the query string. Otherwise we look for data in the request body.
if ('GET' === $method || 'HEAD' === $method || 'TRACE' === $method) {
if ('' === $name) {
$data = $_GET;
} else {
// Don't submit GET requests if the form's name does not exist
// in the request
if (!isset($_GET[$name])) {
return;
}
$data = $_GET[$name];
}
} else {
// Mark the form with an error if the uploaded size was too large
// This is done here and not in FormValidator because $_POST is
// empty when that error occurs. Hence the form is never submitted.
if ($this->serverParams->hasPostMaxSizeBeenExceeded()) {
// Submit the form, but don't clear the default values
$form->submit(null, false);
$form->addError(new FormError(
$form->getConfig()->getOption('upload_max_size_message')(),
null,
['{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize()]
));
return;
}
$fixedFiles = [];
foreach ($_FILES as $fileKey => $file) {
$fixedFiles[$fileKey] = self::stripEmptyFiles(self::fixPhpFilesArray($file));
}
if ('' === $name) {
$params = $_POST;
$files = $fixedFiles;
} elseif (\array_key_exists($name, $_POST) || \array_key_exists($name, $fixedFiles)) {
$default = $form->getConfig()->getCompound() ? [] : null;
$params = \array_key_exists($name, $_POST) ? $_POST[$name] : $default;
$files = \array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default;
} else {
// Don't submit the form if it is not present in the request
return;
}
if (\is_array($params) && \is_array($files)) {
$data = array_replace_recursive($params, $files);
} else {
$data = $params ?: $files;
}
}
// Don't auto-submit the form unless at least one field is present.
if ('' === $name && \count(array_intersect_key($data, $form->all())) <= 0) {
return;
}
if (\is_array($data) && \array_key_exists('_method', $data) && $method === $data['_method'] && !$form->has('_method')) {
unset($data['_method']);
}
$form->submit($data, 'PATCH' !== $method);
} | [
"public",
"function",
"handleRequest",
"(",
"FormInterface",
"$",
"form",
",",
"$",
"request",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"request",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"request",
",",
"'null'",
")",
... | {@inheritdoc}
@throws Exception\UnexpectedTypeException If the $request is not null | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/NativeRequestHandler.php#L47-L125 | train | This method is called by the FormValidator to handle the request. | [
30522,
2270,
3853,
28213,
2063,
15500,
1006,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
1002,
5227,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
5227,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
522... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DependencyInjection/Loader/XmlFileLoader.php | XmlFileLoader.getServiceDefaults | private function getServiceDefaults(\DOMDocument $xml, $file)
{
$xpath = new \DOMXPath($xml);
$xpath->registerNamespace('container', self::NS);
if (null === $defaultsNode = $xpath->query('//container:services/container:defaults')->item(0)) {
return [];
}
$bindings = [];
foreach ($this->getArgumentsAsPhp($defaultsNode, 'bind', $file) as $argument => $value) {
$bindings[$argument] = new BoundArgument($value, true, BoundArgument::DEFAULTS_BINDING, $file);
}
$defaults = [
'tags' => $this->getChildren($defaultsNode, 'tag'),
'bind' => $bindings,
];
foreach ($defaults['tags'] as $tag) {
if ('' === $tag->getAttribute('name')) {
throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file));
}
}
if ($defaultsNode->hasAttribute('autowire')) {
$defaults['autowire'] = XmlUtils::phpize($defaultsNode->getAttribute('autowire'));
}
if ($defaultsNode->hasAttribute('public')) {
$defaults['public'] = XmlUtils::phpize($defaultsNode->getAttribute('public'));
}
if ($defaultsNode->hasAttribute('autoconfigure')) {
$defaults['autoconfigure'] = XmlUtils::phpize($defaultsNode->getAttribute('autoconfigure'));
}
return $defaults;
} | php | private function getServiceDefaults(\DOMDocument $xml, $file)
{
$xpath = new \DOMXPath($xml);
$xpath->registerNamespace('container', self::NS);
if (null === $defaultsNode = $xpath->query('//container:services/container:defaults')->item(0)) {
return [];
}
$bindings = [];
foreach ($this->getArgumentsAsPhp($defaultsNode, 'bind', $file) as $argument => $value) {
$bindings[$argument] = new BoundArgument($value, true, BoundArgument::DEFAULTS_BINDING, $file);
}
$defaults = [
'tags' => $this->getChildren($defaultsNode, 'tag'),
'bind' => $bindings,
];
foreach ($defaults['tags'] as $tag) {
if ('' === $tag->getAttribute('name')) {
throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file));
}
}
if ($defaultsNode->hasAttribute('autowire')) {
$defaults['autowire'] = XmlUtils::phpize($defaultsNode->getAttribute('autowire'));
}
if ($defaultsNode->hasAttribute('public')) {
$defaults['public'] = XmlUtils::phpize($defaultsNode->getAttribute('public'));
}
if ($defaultsNode->hasAttribute('autoconfigure')) {
$defaults['autoconfigure'] = XmlUtils::phpize($defaultsNode->getAttribute('autoconfigure'));
}
return $defaults;
} | [
"private",
"function",
"getServiceDefaults",
"(",
"\\",
"DOMDocument",
"$",
"xml",
",",
"$",
"file",
")",
"{",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"xml",
")",
";",
"$",
"xpath",
"->",
"registerNamespace",
"(",
"'container'",
",",
"self"... | Get service defaults.
@return array | [
"Get",
"service",
"defaults",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php#L170-L206 | train | Get service defaults | [
30522,
2797,
3853,
4152,
2121,
7903,
14728,
7011,
11314,
2015,
1006,
1032,
14383,
3527,
24894,
4765,
1002,
20950,
1010,
1002,
5371,
1007,
1063,
1002,
26726,
8988,
1027,
2047,
1032,
14383,
2595,
15069,
1006,
1002,
20950,
1007,
1025,
1002,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Cache/DynamoDbStore.php | DynamoDbStore.putMany | public function putMany(array $values, $seconds)
{
$expiration = $this->toTimestamp($seconds);
$this->dynamo->batchWriteItem([
'RequestItems' => [
$this->table => collect($values)->map(function ($value, $key) use ($expiration) {
return [
'PutRequest' => [
'Item' => [
$this->keyAttribute => [
'S' => $this->prefix.$key,
],
$this->valueAttribute => [
$this->type($value) => $this->serialize($value),
],
$this->expirationAttribute => [
'N' => (string) $expiration,
],
],
],
];
})->values()->all(),
],
]);
return true;
} | php | public function putMany(array $values, $seconds)
{
$expiration = $this->toTimestamp($seconds);
$this->dynamo->batchWriteItem([
'RequestItems' => [
$this->table => collect($values)->map(function ($value, $key) use ($expiration) {
return [
'PutRequest' => [
'Item' => [
$this->keyAttribute => [
'S' => $this->prefix.$key,
],
$this->valueAttribute => [
$this->type($value) => $this->serialize($value),
],
$this->expirationAttribute => [
'N' => (string) $expiration,
],
],
],
];
})->values()->all(),
],
]);
return true;
} | [
"public",
"function",
"putMany",
"(",
"array",
"$",
"values",
",",
"$",
"seconds",
")",
"{",
"$",
"expiration",
"=",
"$",
"this",
"->",
"toTimestamp",
"(",
"$",
"seconds",
")",
";",
"$",
"this",
"->",
"dynamo",
"->",
"batchWriteItem",
"(",
"[",
"'Reque... | Store multiple items in the cache for a given number of $seconds.
@param array $values
@param int $seconds
@return bool | [
"Store",
"multiple",
"items",
"in",
"the",
"cache",
"for",
"a",
"given",
"number",
"of",
"$seconds",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/DynamoDbStore.php#L219-L246 | train | Put many items into the cache | [
30522,
2270,
3853,
2404,
2386,
2100,
1006,
9140,
1002,
5300,
1010,
1002,
3823,
1007,
1063,
1002,
4654,
16781,
1027,
1002,
2023,
1011,
1028,
2000,
7292,
9153,
8737,
1006,
1002,
3823,
1007,
1025,
1002,
2023,
1011,
1028,
17205,
1011,
1028,
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/Routing/Route.php | Route.setOption | public function setOption($name, $value)
{
$this->options[$name] = $value;
$this->compiled = null;
return $this;
} | php | public function setOption($name, $value)
{
$this->options[$name] = $value;
$this->compiled = null;
return $this;
} | [
"public",
"function",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"compiled",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | Sets an option value.
This method implements a fluent interface.
@param string $name An option name
@param mixed $value The option value
@return $this | [
"Sets",
"an",
"option",
"value",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Route.php#L310-L316 | train | Set an option value | [
30522,
2270,
3853,
2275,
7361,
3508,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
1002,
2023,
1011,
1028,
7047,
1031,
1002,
2171,
1033,
1027,
1002,
3643,
1025,
1002,
2023,
1011,
1028,
9227,
1027,
19701,
1025,
2709,
1002,
2023,
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/View/Compilers/BladeCompiler.php | BladeCompiler.callCustomDirective | protected function callCustomDirective($name, $value)
{
if (Str::startsWith($value, '(') && Str::endsWith($value, ')')) {
$value = Str::substr($value, 1, -1);
}
return call_user_func($this->customDirectives[$name], trim($value));
} | php | protected function callCustomDirective($name, $value)
{
if (Str::startsWith($value, '(') && Str::endsWith($value, ')')) {
$value = Str::substr($value, 1, -1);
}
return call_user_func($this->customDirectives[$name], trim($value));
} | [
"protected",
"function",
"callCustomDirective",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"Str",
"::",
"startsWith",
"(",
"$",
"value",
",",
"'('",
")",
"&&",
"Str",
"::",
"endsWith",
"(",
"$",
"value",
",",
"')'",
")",
")",
"{",
"$... | Call the given directive with the given value.
@param string $name
@param string|null $value
@return string | [
"Call",
"the",
"given",
"directive",
"with",
"the",
"given",
"value",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Compilers/BladeCompiler.php#L376-L383 | train | Call the custom directive | [
30522,
5123,
3853,
2655,
7874,
20389,
4305,
2890,
15277,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
2358,
2099,
1024,
1024,
4627,
24415,
1006,
1002,
3643,
1010,
1005,
1006,
1005,
1007,
1004,
1004,
2358,
2099,
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... |
symfony/symfony | src/Symfony/Component/Console/Style/SymfonyStyle.php | SymfonyStyle.choice | public function choice($question, array $choices, $default = null)
{
if (null !== $default) {
$values = array_flip($choices);
$default = $values[$default];
}
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
} | php | public function choice($question, array $choices, $default = null)
{
if (null !== $default) {
$values = array_flip($choices);
$default = $values[$default];
}
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
} | [
"public",
"function",
"choice",
"(",
"$",
"question",
",",
"array",
"$",
"choices",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"default",
")",
"{",
"$",
"values",
"=",
"array_flip",
"(",
"$",
"choices",
")",
";",
"$"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Style/SymfonyStyle.php#L228-L236 | train | Ask the user for a choice | [
30522,
2270,
3853,
3601,
1006,
1002,
3160,
1010,
9140,
1002,
9804,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
12398,
1007,
1063,
1002,
5300,
1027,
9140,
1035,
11238,
1006,
1002,
9804,
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... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php | FilesystemLoader.load | public function load(TemplateReferenceInterface $template)
{
try {
$file = $this->locator->locate($template);
} catch (\InvalidArgumentException $e) {
return false;
}
return new FileStorage($file);
} | php | public function load(TemplateReferenceInterface $template)
{
try {
$file = $this->locator->locate($template);
} catch (\InvalidArgumentException $e) {
return false;
}
return new FileStorage($file);
} | [
"public",
"function",
"load",
"(",
"TemplateReferenceInterface",
"$",
"template",
")",
"{",
"try",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"locator",
"->",
"locate",
"(",
"$",
"template",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php#L40-L49 | train | Load a template file | [
30522,
2270,
3853,
7170,
1006,
23561,
2890,
25523,
18447,
2121,
12172,
1002,
23561,
1007,
1063,
3046,
1063,
1002,
5371,
1027,
1002,
2023,
1011,
1028,
8840,
11266,
2953,
1011,
1028,
12453,
1006,
1002,
23561,
1007,
1025,
1065,
4608,
1006,
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... |
getgrav/grav | system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php | AssetUtilsTrait.renderQueryString | protected function renderQueryString($asset = null)
{
$querystring = '';
$asset = $asset ?? $this->asset;
if (!empty($this->query)) {
if (Utils::contains($asset, '?')) {
$querystring .= '&' . $this->query;
} else {
$querystring .= '?' . $this->query;
}
}
if ($this->timestamp) {
if (Utils::contains($asset, '?') || $querystring) {
$querystring .= '&' . $this->timestamp;
} else {
$querystring .= '?' . $this->timestamp;
}
}
return $querystring;
} | php | protected function renderQueryString($asset = null)
{
$querystring = '';
$asset = $asset ?? $this->asset;
if (!empty($this->query)) {
if (Utils::contains($asset, '?')) {
$querystring .= '&' . $this->query;
} else {
$querystring .= '?' . $this->query;
}
}
if ($this->timestamp) {
if (Utils::contains($asset, '?') || $querystring) {
$querystring .= '&' . $this->timestamp;
} else {
$querystring .= '?' . $this->timestamp;
}
}
return $querystring;
} | [
"protected",
"function",
"renderQueryString",
"(",
"$",
"asset",
"=",
"null",
")",
"{",
"$",
"querystring",
"=",
"''",
";",
"$",
"asset",
"=",
"$",
"asset",
"??",
"$",
"this",
"->",
"asset",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"qu... | Render Querystring
@param string $asset
@return string | [
"Render",
"Querystring"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Assets/Traits/AssetUtilsTrait.php#L158-L181 | train | Render Query String | [
30522,
5123,
3853,
17552,
4226,
24769,
18886,
3070,
1006,
1002,
11412,
1027,
19701,
1007,
1063,
1002,
23032,
3367,
4892,
1027,
1005,
1005,
1025,
1002,
11412,
1027,
1002,
11412,
1029,
1029,
1002,
2023,
1011,
1028,
11412,
1025,
2065,
1006,
99... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.booted | public function booted($callback)
{
$this->bootedCallbacks[] = $callback;
if ($this->isBooted()) {
$this->fireAppCallbacks([$callback]);
}
} | php | public function booted($callback)
{
$this->bootedCallbacks[] = $callback;
if ($this->isBooted()) {
$this->fireAppCallbacks([$callback]);
}
} | [
"public",
"function",
"booted",
"(",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"bootedCallbacks",
"[",
"]",
"=",
"$",
"callback",
";",
"if",
"(",
"$",
"this",
"->",
"isBooted",
"(",
")",
")",
"{",
"$",
"this",
"->",
"fireAppCallbacks",
"(",
"[",
... | Register a new "booted" listener.
@param callable $callback
@return void | [
"Register",
"a",
"new",
"booted",
"listener",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Application.php#L838-L845 | train | Booted callback function | [
30522,
2270,
3853,
9573,
2098,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
2023,
1011,
1028,
9573,
2098,
9289,
20850,
8684,
2015,
1031,
1033,
1027,
1002,
2655,
5963,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
27927,
2098,
1006,
1007,
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/Serializer/Serializer.php | Serializer.normalize | public function normalize($data, $format = null, array $context = [])
{
// If a normalizer supports the given data, use it
if ($normalizer = $this->getNormalizer($data, $format, $context)) {
return $normalizer->normalize($data, $format, $context);
}
if (null === $data || is_scalar($data)) {
return $data;
}
if (\is_array($data) || $data instanceof \Traversable) {
$normalized = [];
foreach ($data as $key => $val) {
$normalized[$key] = $this->normalize($val, $format, $context);
}
return $normalized;
}
if (\is_object($data)) {
if (!$this->normalizers) {
throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
}
throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data)));
}
throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true)));
} | php | public function normalize($data, $format = null, array $context = [])
{
// If a normalizer supports the given data, use it
if ($normalizer = $this->getNormalizer($data, $format, $context)) {
return $normalizer->normalize($data, $format, $context);
}
if (null === $data || is_scalar($data)) {
return $data;
}
if (\is_array($data) || $data instanceof \Traversable) {
$normalized = [];
foreach ($data as $key => $val) {
$normalized[$key] = $this->normalize($val, $format, $context);
}
return $normalized;
}
if (\is_object($data)) {
if (!$this->normalizers) {
throw new LogicException('You must register at least one normalizer to be able to normalize objects.');
}
throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data)));
}
throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true)));
} | [
"public",
"function",
"normalize",
"(",
"$",
"data",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"// If a normalizer supports the given data, use it",
"if",
"(",
"$",
"normalizer",
"=",
"$",
"this",
"->",
"getNorma... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Serializer.php#L148-L177 | train | Normalize the given data | [
30522,
2270,
3853,
3671,
4697,
1006,
1002,
2951,
1010,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
1013,
1013,
2065,
1037,
3671,
17629,
6753,
1996,
2445,
2951,
1010,
2224,
2009,
2065,
1006,
1002,
3671,
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... |
getgrav/grav | system/src/Grav/Common/Page/Medium/Medium.php | Medium.url | public function url($reset = true)
{
$output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $this->get('filepath'));
$locator = Grav::instance()['locator'];
if ($locator->isStream($output)) {
$output = $locator->findResource($output, false);
}
if ($reset) {
$this->reset();
}
return trim(Grav::instance()['base_url'] . '/' . $this->urlQuerystring($output), '\\');
} | php | public function url($reset = true)
{
$output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $this->get('filepath'));
$locator = Grav::instance()['locator'];
if ($locator->isStream($output)) {
$output = $locator->findResource($output, false);
}
if ($reset) {
$this->reset();
}
return trim(Grav::instance()['base_url'] . '/' . $this->urlQuerystring($output), '\\');
} | [
"public",
"function",
"url",
"(",
"$",
"reset",
"=",
"true",
")",
"{",
"$",
"output",
"=",
"preg_replace",
"(",
"'|^'",
".",
"preg_quote",
"(",
"GRAV_ROOT",
",",
"'|'",
")",
".",
"'|'",
",",
"''",
",",
"$",
"this",
"->",
"get",
"(",
"'filepath'",
"... | Return URL to file.
@param bool $reset
@return string | [
"Return",
"URL",
"to",
"file",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/Medium.php#L265-L279 | train | Return the URL of the file | [
30522,
2270,
3853,
24471,
2140,
1006,
1002,
25141,
1027,
2995,
1007,
1063,
1002,
6434,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
1064,
1034,
1005,
1012,
3653,
2290,
1035,
14686,
1006,
24665,
11431,
1035,
7117,
1010,
1005,
1064,
1005,
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/HTML/QuickForm2/Renderer.php | HTML_QuickForm2_Renderer.getOption | public function getOption($name = null)
{
if (null === $name) {
return $this->options;
} elseif (!array_key_exists($name, $this->options)) {
throw new HTML_QuickForm2_NotFoundException(
"Unknown option '{$name}'"
);
}
return $this->options[$name];
} | php | public function getOption($name = null)
{
if (null === $name) {
return $this->options;
} elseif (!array_key_exists($name, $this->options)) {
throw new HTML_QuickForm2_NotFoundException(
"Unknown option '{$name}'"
);
}
return $this->options[$name];
} | [
"public",
"function",
"getOption",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"options",
";",
"}",
"elseif",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this... | Returns the value(s) of the renderer option(s)
@param string parameter name
@return mixed value of $name parameter, array of all configuration
parameters if $name is not given
@throws HTML_QuickForm2_NotFoundException in case of unknown option | [
"Returns",
"the",
"value",
"(",
"s",
")",
"of",
"the",
"renderer",
"option",
"(",
"s",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer.php#L268-L278 | train | Get option value | [
30522,
2270,
3853,
2131,
7361,
3508,
1006,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2171,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7047,
1025,
1065,
2842,
10128,
1006,
999,
9140,
1035,
3145,
1035,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Relations/Concerns/InteractsWithPivotTable.php | InteractsWithPivotTable.baseAttachRecord | protected function baseAttachRecord($id, $timed)
{
$record[$this->relatedPivotKey] = $id;
$record[$this->foreignPivotKey] = $this->parent->{$this->parentKey};
// If the record needs to have creation and update timestamps, we will make
// them by calling the parent model's "freshTimestamp" method which will
// provide us with a fresh timestamp in this model's preferred format.
if ($timed) {
$record = $this->addTimestampsToAttachment($record);
}
foreach ($this->pivotValues as $value) {
$record[$value['column']] = $value['value'];
}
return $record;
} | php | protected function baseAttachRecord($id, $timed)
{
$record[$this->relatedPivotKey] = $id;
$record[$this->foreignPivotKey] = $this->parent->{$this->parentKey};
// If the record needs to have creation and update timestamps, we will make
// them by calling the parent model's "freshTimestamp" method which will
// provide us with a fresh timestamp in this model's preferred format.
if ($timed) {
$record = $this->addTimestampsToAttachment($record);
}
foreach ($this->pivotValues as $value) {
$record[$value['column']] = $value['value'];
}
return $record;
} | [
"protected",
"function",
"baseAttachRecord",
"(",
"$",
"id",
",",
"$",
"timed",
")",
"{",
"$",
"record",
"[",
"$",
"this",
"->",
"relatedPivotKey",
"]",
"=",
"$",
"id",
";",
"$",
"record",
"[",
"$",
"this",
"->",
"foreignPivotKey",
"]",
"=",
"$",
"th... | Create a new pivot attachment record.
@param int $id
@param bool $timed
@return array | [
"Create",
"a",
"new",
"pivot",
"attachment",
"record",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php#L338-L356 | train | baseAttachRecord - base implementation of baseAttachRecord | [
30522,
5123,
3853,
2918,
19321,
6776,
2890,
27108,
2094,
1006,
1002,
8909,
1010,
1002,
22313,
1007,
1063,
1002,
2501,
1031,
1002,
2023,
1011,
1028,
3141,
8197,
22994,
14839,
1033,
1027,
1002,
8909,
1025,
1002,
2501,
1031,
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... |
matomo-org/matomo | core/Period/Month.php | Month.processOptimalSubperiods | protected function processOptimalSubperiods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate)
|| $startDate == $endDate
) {
$week = new Week($startDate);
$startOfWeek = $week->getDateStart();
$endOfWeek = $week->getDateEnd();
if ($endOfWeek->isLater($endDate)) {
$this->fillDayPeriods($startDate, $endDate);
} elseif ($startOfWeek == $startDate) {
$this->addSubperiod($week);
} else {
$this->fillDayPeriods($startDate, $endOfWeek);
}
$startDate = $endOfWeek->addDay(1);
}
} | php | protected function processOptimalSubperiods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate)
|| $startDate == $endDate
) {
$week = new Week($startDate);
$startOfWeek = $week->getDateStart();
$endOfWeek = $week->getDateEnd();
if ($endOfWeek->isLater($endDate)) {
$this->fillDayPeriods($startDate, $endDate);
} elseif ($startOfWeek == $startDate) {
$this->addSubperiod($week);
} else {
$this->fillDayPeriods($startDate, $endOfWeek);
}
$startDate = $endOfWeek->addDay(1);
}
} | [
"protected",
"function",
"processOptimalSubperiods",
"(",
"$",
"startDate",
",",
"$",
"endDate",
")",
"{",
"while",
"(",
"$",
"startDate",
"->",
"isEarlier",
"(",
"$",
"endDate",
")",
"||",
"$",
"startDate",
"==",
"$",
"endDate",
")",
"{",
"$",
"week",
"... | Determine which kind of period is best to use.
See Range.test.php
@param Date $startDate
@param Date $endDate | [
"Determine",
"which",
"kind",
"of",
"period",
"is",
"best",
"to",
"use",
".",
"See",
"Range",
".",
"test",
".",
"php"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Period/Month.php#L83-L102 | train | Process Optimal Subperiods | [
30522,
5123,
3853,
2832,
7361,
3775,
9067,
6342,
2497,
4842,
3695,
5104,
1006,
1002,
2707,
13701,
1010,
1002,
2203,
13701,
1007,
1063,
2096,
1006,
1002,
2707,
13701,
1011,
1028,
2003,
14644,
14355,
1006,
1002,
2203,
13701,
1007,
1064,
1064,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/GPM/GPM.php | GPM.getInstallable | public function getInstallable($list_type_installed = ['plugins' => true, 'themes' => true])
{
$items = ['total' => 0];
foreach ($list_type_installed as $type => $type_installed) {
if ($type_installed === false) {
continue;
}
$methodInstallableType = 'getInstalled' . ucfirst($type);
$to_install = $this->$methodInstallableType();
$items[$type] = $to_install;
$items['total'] += count($to_install);
}
return $items;
} | php | public function getInstallable($list_type_installed = ['plugins' => true, 'themes' => true])
{
$items = ['total' => 0];
foreach ($list_type_installed as $type => $type_installed) {
if ($type_installed === false) {
continue;
}
$methodInstallableType = 'getInstalled' . ucfirst($type);
$to_install = $this->$methodInstallableType();
$items[$type] = $to_install;
$items['total'] += count($to_install);
}
return $items;
} | [
"public",
"function",
"getInstallable",
"(",
"$",
"list_type_installed",
"=",
"[",
"'plugins'",
"=>",
"true",
",",
"'themes'",
"=>",
"true",
"]",
")",
"{",
"$",
"items",
"=",
"[",
"'total'",
"=>",
"0",
"]",
";",
"foreach",
"(",
"$",
"list_type_installed",
... | Returns the Locally installable packages
@param array $list_type_installed
@return array The installed packages | [
"Returns",
"the",
"Locally",
"installable",
"packages"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/GPM.php#L83-L96 | train | Get Installable Types | [
30522,
2270,
3853,
2131,
7076,
9080,
20470,
2571,
1006,
1002,
2862,
1035,
2828,
1035,
5361,
1027,
1031,
1005,
13354,
7076,
1005,
1027,
1028,
2995,
1010,
1005,
6991,
1005,
1027,
1028,
2995,
1033,
1007,
1063,
1002,
5167,
1027,
1031,
1005,
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 | Protocols/Ws.php | Ws.sendHandshake | public static function sendHandshake($connection)
{
if (!empty($connection->handshakeStep)) {
return;
}
// Get Host.
$port = $connection->getRemotePort();
$host = $port === 80 ? $connection->getRemoteHost() : $connection->getRemoteHost() . ':' . $port;
// Handshake header.
$connection->websocketSecKey = base64_encode(md5(mt_rand(), true));
$user_header = isset($connection->headers) ? $connection->headers :
(isset($connection->wsHttpHeader) ? $connection->wsHttpHeader : null);
$user_header_str = '';
if (!empty($user_header)) {
if (is_array($user_header)){
foreach($user_header as $k=>$v){
$user_header_str .= "$k: $v\r\n";
}
} else {
$user_header_str .= $user_header;
}
$user_header_str = "\r\n".trim($user_header_str);
}
$header = 'GET ' . $connection->getRemoteURI() . " HTTP/1.1\r\n".
(!preg_match("/\nHost:/i", $user_header_str) ? "Host: $host\r\n" : '').
"Connection: Upgrade\r\n".
"Upgrade: websocket\r\n".
"Origin: ". (isset($connection->websocketOrigin) ? $connection->websocketOrigin : '*') ."\r\n".
(isset($connection->WSClientProtocol)?"Sec-WebSocket-Protocol: ".$connection->WSClientProtocol."\r\n":'').
"Sec-WebSocket-Version: 13\r\n".
"Sec-WebSocket-Key: " . $connection->websocketSecKey . $user_header_str . "\r\n\r\n";
$connection->send($header, true);
$connection->handshakeStep = 1;
$connection->websocketCurrentFrameLength = 0;
$connection->websocketDataBuffer = '';
$connection->tmpWebsocketData = '';
} | php | public static function sendHandshake($connection)
{
if (!empty($connection->handshakeStep)) {
return;
}
// Get Host.
$port = $connection->getRemotePort();
$host = $port === 80 ? $connection->getRemoteHost() : $connection->getRemoteHost() . ':' . $port;
// Handshake header.
$connection->websocketSecKey = base64_encode(md5(mt_rand(), true));
$user_header = isset($connection->headers) ? $connection->headers :
(isset($connection->wsHttpHeader) ? $connection->wsHttpHeader : null);
$user_header_str = '';
if (!empty($user_header)) {
if (is_array($user_header)){
foreach($user_header as $k=>$v){
$user_header_str .= "$k: $v\r\n";
}
} else {
$user_header_str .= $user_header;
}
$user_header_str = "\r\n".trim($user_header_str);
}
$header = 'GET ' . $connection->getRemoteURI() . " HTTP/1.1\r\n".
(!preg_match("/\nHost:/i", $user_header_str) ? "Host: $host\r\n" : '').
"Connection: Upgrade\r\n".
"Upgrade: websocket\r\n".
"Origin: ". (isset($connection->websocketOrigin) ? $connection->websocketOrigin : '*') ."\r\n".
(isset($connection->WSClientProtocol)?"Sec-WebSocket-Protocol: ".$connection->WSClientProtocol."\r\n":'').
"Sec-WebSocket-Version: 13\r\n".
"Sec-WebSocket-Key: " . $connection->websocketSecKey . $user_header_str . "\r\n\r\n";
$connection->send($header, true);
$connection->handshakeStep = 1;
$connection->websocketCurrentFrameLength = 0;
$connection->websocketDataBuffer = '';
$connection->tmpWebsocketData = '';
} | [
"public",
"static",
"function",
"sendHandshake",
"(",
"$",
"connection",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"connection",
"->",
"handshakeStep",
")",
")",
"{",
"return",
";",
"}",
"// Get Host.",
"$",
"port",
"=",
"$",
"connection",
"->",
"getR... | Send websocket handshake.
@param \Workerman\Connection\TcpConnection $connection
@return void | [
"Send",
"websocket",
"handshake",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Ws.php#L359-L395 | train | Send WebSocket handshake | [
30522,
2270,
10763,
3853,
4604,
11774,
7377,
3489,
1006,
1002,
4434,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
4434,
1011,
1028,
2398,
20459,
4355,
13699,
1007,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
2131,
3677,
1012,
1002,
3417,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.php | Filter.urlWithoutFilters | public function urlWithoutFilters()
{
/** @var Collection $columns */
$columns = collect($this->filters)->map->getColumn()->flatten();
$pageKey = 'page';
if ($gridName = $this->model->getGrid()->getName()) {
$pageKey = "{$gridName}_{$pageKey}";
}
$columns->push($pageKey);
$groupNames = collect($this->filters)->filter(function ($filter) {
return $filter instanceof Group;
})->map(function (AbstractFilter $filter) {
return "{$filter->getId()}_group";
});
return $this->fullUrlWithoutQuery(
$columns->merge($groupNames)
);
} | php | public function urlWithoutFilters()
{
/** @var Collection $columns */
$columns = collect($this->filters)->map->getColumn()->flatten();
$pageKey = 'page';
if ($gridName = $this->model->getGrid()->getName()) {
$pageKey = "{$gridName}_{$pageKey}";
}
$columns->push($pageKey);
$groupNames = collect($this->filters)->filter(function ($filter) {
return $filter instanceof Group;
})->map(function (AbstractFilter $filter) {
return "{$filter->getId()}_group";
});
return $this->fullUrlWithoutQuery(
$columns->merge($groupNames)
);
} | [
"public",
"function",
"urlWithoutFilters",
"(",
")",
"{",
"/** @var Collection $columns */",
"$",
"columns",
"=",
"collect",
"(",
"$",
"this",
"->",
"filters",
")",
"->",
"map",
"->",
"getColumn",
"(",
")",
"->",
"flatten",
"(",
")",
";",
"$",
"pageKey",
"... | Get url without filter queryString.
@return string | [
"Get",
"url",
"without",
"filter",
"queryString",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter.php#L545-L567 | train | Return the full URL without the filters | [
30522,
2270,
3853,
24471,
2140,
24415,
5833,
8873,
21928,
2015,
1006,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
3074,
1002,
7753,
1008,
1013,
1002,
7753,
1027,
8145,
1006,
1002,
2023,
1011,
1028,
17736,
1007,
1011,
1028,
4949,
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/Finder/Iterator/PathFilterIterator.php | PathFilterIterator.accept | public function accept()
{
$filename = $this->current()->getRelativePathname();
if ('\\' === \DIRECTORY_SEPARATOR) {
$filename = str_replace('\\', '/', $filename);
}
return $this->isAccepted($filename);
} | php | public function accept()
{
$filename = $this->current()->getRelativePathname();
if ('\\' === \DIRECTORY_SEPARATOR) {
$filename = str_replace('\\', '/', $filename);
}
return $this->isAccepted($filename);
} | [
"public",
"function",
"accept",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"current",
"(",
")",
"->",
"getRelativePathname",
"(",
")",
";",
"if",
"(",
"'\\\\'",
"===",
"\\",
"DIRECTORY_SEPARATOR",
")",
"{",
"$",
"filename",
"=",
"str_replace... | Filters the iterator values.
@return bool true if the value should be kept, false otherwise | [
"Filters",
"the",
"iterator",
"values",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php#L27-L36 | train | Accept the current page | [
30522,
2270,
3853,
5138,
1006,
1007,
1063,
1002,
5371,
18442,
1027,
1002,
2023,
1011,
1028,
2783,
1006,
1007,
1011,
1028,
2131,
16570,
8082,
15069,
18442,
1006,
1007,
1025,
2065,
1006,
1005,
1032,
1032,
1005,
1027,
1027,
1027,
1032,
14176,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Console/Helper/ProgressIndicator.php | ProgressIndicator.advance | public function advance()
{
if (!$this->started) {
throw new LogicException('Progress indicator has not yet been started.');
}
if (!$this->output->isDecorated()) {
return;
}
$currentTime = $this->getCurrentTimeInMilliseconds();
if ($currentTime < $this->indicatorUpdateTime) {
return;
}
$this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
++$this->indicatorCurrent;
$this->display();
} | php | public function advance()
{
if (!$this->started) {
throw new LogicException('Progress indicator has not yet been started.');
}
if (!$this->output->isDecorated()) {
return;
}
$currentTime = $this->getCurrentTimeInMilliseconds();
if ($currentTime < $this->indicatorUpdateTime) {
return;
}
$this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
++$this->indicatorCurrent;
$this->display();
} | [
"public",
"function",
"advance",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Progress indicator has not yet been started.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"output",
"->... | Advances the indicator. | [
"Advances",
"the",
"indicator",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/ProgressIndicator.php#L101-L121 | train | Advance the indicator | [
30522,
2270,
3853,
5083,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2318,
1007,
1063,
5466,
2047,
7961,
10288,
24422,
1006,
1005,
5082,
17245,
2038,
2025,
2664,
2042,
2318,
1012,
1005,
1007,
1025,
1065,
2065,
30524,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/RelationController.php | RelationController.initRelation | public function initRelation($model, $field = null)
{
if ($field == null) {
$field = post(self::PARAM_FIELD);
}
$this->config = $this->originalConfig;
$this->model = $model;
$this->field = $field;
if ($field == null) {
return;
}
if (!$this->model) {
throw new ApplicationException(Lang::get(
'backend::lang.relation.missing_model',
['class'=>get_class($this->controller)]
));
}
if (!$this->model instanceof Model) {
throw new ApplicationException(Lang::get(
'backend::lang.model.invalid_class',
['model'=>get_class($this->model), 'class'=>get_class($this->controller)]
));
}
if (!$this->getConfig($field)) {
throw new ApplicationException(Lang::get('backend::lang.relation.missing_definition', compact('field')));
}
if ($extraConfig = post(self::PARAM_EXTRA_CONFIG)) {
$this->applyExtraConfig($extraConfig);
}
$this->alias = camel_case('relation ' . $field);
$this->config = $this->makeConfig($this->getConfig($field), $this->requiredRelationProperties);
$this->controller->relationExtendConfig($this->config, $this->field, $this->model);
/*
* Relationship details
*/
$this->relationName = $field;
$this->relationType = $this->model->getRelationType($field);
$this->relationObject = $this->model->{$field}();
$this->relationModel = $this->relationObject->getRelated();
$this->manageId = post('manage_id');
$this->foreignId = post('foreign_id');
$this->readOnly = $this->getConfig('readOnly');
$this->deferredBinding = $this->getConfig('deferredBinding') || !$this->model->exists;
$this->viewMode = $this->evalViewMode();
$this->manageMode = $this->evalManageMode();
$this->manageTitle = $this->evalManageTitle();
$this->toolbarButtons = $this->evalToolbarButtons();
/*
* Toolbar widget
*/
if ($this->toolbarWidget = $this->makeToolbarWidget()) {
$this->toolbarWidget->bindToController();
}
/*
* Search widget
*/
if ($this->searchWidget = $this->makeSearchWidget()) {
$this->searchWidget->bindToController();
}
/*
* View widget
*/
if ($this->viewWidget = $this->makeViewWidget()) {
$this->controller->relationExtendViewWidget($this->viewWidget, $this->field, $this->model);
$this->viewWidget->bindToController();
}
/*
* Manage widget
*/
if ($this->manageWidget = $this->makeManageWidget()) {
$this->controller->relationExtendManageWidget($this->manageWidget, $this->field, $this->model);
$this->manageWidget->bindToController();
}
/*
* Pivot widget
*/
if ($this->manageMode == 'pivot' && $this->pivotWidget = $this->makePivotWidget()) {
$this->controller->relationExtendPivotWidget($this->pivotWidget, $this->field, $this->model);
$this->pivotWidget->bindToController();
}
} | php | public function initRelation($model, $field = null)
{
if ($field == null) {
$field = post(self::PARAM_FIELD);
}
$this->config = $this->originalConfig;
$this->model = $model;
$this->field = $field;
if ($field == null) {
return;
}
if (!$this->model) {
throw new ApplicationException(Lang::get(
'backend::lang.relation.missing_model',
['class'=>get_class($this->controller)]
));
}
if (!$this->model instanceof Model) {
throw new ApplicationException(Lang::get(
'backend::lang.model.invalid_class',
['model'=>get_class($this->model), 'class'=>get_class($this->controller)]
));
}
if (!$this->getConfig($field)) {
throw new ApplicationException(Lang::get('backend::lang.relation.missing_definition', compact('field')));
}
if ($extraConfig = post(self::PARAM_EXTRA_CONFIG)) {
$this->applyExtraConfig($extraConfig);
}
$this->alias = camel_case('relation ' . $field);
$this->config = $this->makeConfig($this->getConfig($field), $this->requiredRelationProperties);
$this->controller->relationExtendConfig($this->config, $this->field, $this->model);
/*
* Relationship details
*/
$this->relationName = $field;
$this->relationType = $this->model->getRelationType($field);
$this->relationObject = $this->model->{$field}();
$this->relationModel = $this->relationObject->getRelated();
$this->manageId = post('manage_id');
$this->foreignId = post('foreign_id');
$this->readOnly = $this->getConfig('readOnly');
$this->deferredBinding = $this->getConfig('deferredBinding') || !$this->model->exists;
$this->viewMode = $this->evalViewMode();
$this->manageMode = $this->evalManageMode();
$this->manageTitle = $this->evalManageTitle();
$this->toolbarButtons = $this->evalToolbarButtons();
/*
* Toolbar widget
*/
if ($this->toolbarWidget = $this->makeToolbarWidget()) {
$this->toolbarWidget->bindToController();
}
/*
* Search widget
*/
if ($this->searchWidget = $this->makeSearchWidget()) {
$this->searchWidget->bindToController();
}
/*
* View widget
*/
if ($this->viewWidget = $this->makeViewWidget()) {
$this->controller->relationExtendViewWidget($this->viewWidget, $this->field, $this->model);
$this->viewWidget->bindToController();
}
/*
* Manage widget
*/
if ($this->manageWidget = $this->makeManageWidget()) {
$this->controller->relationExtendManageWidget($this->manageWidget, $this->field, $this->model);
$this->manageWidget->bindToController();
}
/*
* Pivot widget
*/
if ($this->manageMode == 'pivot' && $this->pivotWidget = $this->makePivotWidget()) {
$this->controller->relationExtendPivotWidget($this->pivotWidget, $this->field, $this->model);
$this->pivotWidget->bindToController();
}
} | [
"public",
"function",
"initRelation",
"(",
"$",
"model",
",",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"field",
"==",
"null",
")",
"{",
"$",
"field",
"=",
"post",
"(",
"self",
"::",
"PARAM_FIELD",
")",
";",
"}",
"$",
"this",
"->",
"co... | Prepare the widgets used by this behavior
@param Model $model
@param string $field
@return void | [
"Prepare",
"the",
"widgets",
"used",
"by",
"this",
"behavior"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/RelationController.php#L291-L385 | train | Initializes the related model and field | [
30522,
2270,
3853,
1999,
4183,
16570,
3370,
1006,
1002,
2944,
1010,
1002,
2492,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2492,
1027,
1027,
19701,
1007,
1063,
1002,
2492,
1027,
2695,
1006,
2969,
1024,
1024,
11498,
2213,
1035,
2492,
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/Redis/Connections/PhpRedisConnection.php | PhpRedisConnection.blpop | public function blpop(...$arguments)
{
$result = $this->command('blpop', $arguments);
return empty($result) ? null : $result;
} | php | public function blpop(...$arguments)
{
$result = $this->command('blpop', $arguments);
return empty($result) ? null : $result;
} | [
"public",
"function",
"blpop",
"(",
"...",
"$",
"arguments",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"command",
"(",
"'blpop'",
",",
"$",
"arguments",
")",
";",
"return",
"empty",
"(",
"$",
"result",
")",
"?",
"null",
":",
"$",
"result",
"... | Removes and returns the first element of the list stored at key.
@param dynamic $arguments
@return array|null | [
"Removes",
"and",
"returns",
"the",
"first",
"element",
"of",
"the",
"list",
"stored",
"at",
"key",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Connections/PhpRedisConnection.php#L165-L170 | train | Returns the next set of entries from the list | [
30522,
2270,
3853,
1038,
14277,
7361,
1006,
1012,
1012,
1012,
1002,
9918,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
3094,
1006,
1005,
1038,
14277,
7361,
1005,
1010,
1002,
9918,
1007,
1025,
2709,
4064,
1006,
1002,
2765,
1007,
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/Deprecation.php | Deprecation.isLegacy | public function isLegacy($utilPrefix)
{
$test = $utilPrefix.'Test';
$class = $this->originatingClass();
$method = $this->originatingMethod();
return 0 === strpos($method, 'testLegacy')
|| 0 === strpos($method, 'provideLegacy')
|| 0 === strpos($method, 'getLegacy')
|| strpos($class, '\Legacy')
|| \in_array('legacy', $test::getGroups($class, $method), true);
} | php | public function isLegacy($utilPrefix)
{
$test = $utilPrefix.'Test';
$class = $this->originatingClass();
$method = $this->originatingMethod();
return 0 === strpos($method, 'testLegacy')
|| 0 === strpos($method, 'provideLegacy')
|| 0 === strpos($method, 'getLegacy')
|| strpos($class, '\Legacy')
|| \in_array('legacy', $test::getGroups($class, $method), true);
} | [
"public",
"function",
"isLegacy",
"(",
"$",
"utilPrefix",
")",
"{",
"$",
"test",
"=",
"$",
"utilPrefix",
".",
"'Test'",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"originatingClass",
"(",
")",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"originatingMet... | @param string $utilPrefix
@return bool | [
"@param",
"string",
"$utilPrefix"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php#L146-L157 | train | return true if the class implements the legacy method | [
30522,
2270,
3853,
8842,
3654,
5666,
1006,
1002,
21183,
4014,
28139,
8873,
2595,
1007,
1063,
1002,
3231,
1027,
1002,
21183,
4014,
28139,
8873,
2595,
1012,
1005,
3231,
1005,
1025,
1002,
2465,
30524,
1027,
1027,
1027,
2358,
14536,
2891,
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... |
laravel/framework | src/Illuminate/Validation/ValidationRuleParser.php | ValidationRuleParser.explode | public function explode($rules)
{
$this->implicitAttributes = [];
$rules = $this->explodeRules($rules);
return (object) [
'rules' => $rules,
'implicitAttributes' => $this->implicitAttributes,
];
} | php | public function explode($rules)
{
$this->implicitAttributes = [];
$rules = $this->explodeRules($rules);
return (object) [
'rules' => $rules,
'implicitAttributes' => $this->implicitAttributes,
];
} | [
"public",
"function",
"explode",
"(",
"$",
"rules",
")",
"{",
"$",
"this",
"->",
"implicitAttributes",
"=",
"[",
"]",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"explodeRules",
"(",
"$",
"rules",
")",
";",
"return",
"(",
"object",
")",
"[",
"'rules'"... | Parse the human-friendly rules into a full rules array for the validator.
@param array $rules
@return \stdClass | [
"Parse",
"the",
"human",
"-",
"friendly",
"rules",
"into",
"a",
"full",
"rules",
"array",
"for",
"the",
"validator",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/ValidationRuleParser.php#L45-L55 | train | Explode the rules into an array | [
30522,
2270,
3853,
15044,
1006,
1002,
3513,
1007,
1063,
1002,
2023,
1011,
1028,
24655,
19321,
3089,
8569,
4570,
1027,
1031,
1033,
1025,
1002,
3513,
1027,
1002,
2023,
1011,
1028,
15044,
6820,
4244,
1006,
1002,
3513,
1007,
1025,
2709,
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... |
php-ai/php-ml | src/Classification/Linear/LogisticRegression.php | LogisticRegression.runConjugateGradient | protected function runConjugateGradient(array $samples, array $targets, Closure $gradientFunc): void
{
if ($this->optimizer === null) {
$this->optimizer = (new ConjugateGradient($this->featureCount))
->setMaxIterations($this->maxIterations);
}
$this->weights = $this->optimizer->runOptimization($samples, $targets, $gradientFunc);
$this->costValues = $this->optimizer->getCostValues();
} | php | protected function runConjugateGradient(array $samples, array $targets, Closure $gradientFunc): void
{
if ($this->optimizer === null) {
$this->optimizer = (new ConjugateGradient($this->featureCount))
->setMaxIterations($this->maxIterations);
}
$this->weights = $this->optimizer->runOptimization($samples, $targets, $gradientFunc);
$this->costValues = $this->optimizer->getCostValues();
} | [
"protected",
"function",
"runConjugateGradient",
"(",
"array",
"$",
"samples",
",",
"array",
"$",
"targets",
",",
"Closure",
"$",
"gradientFunc",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"optimizer",
"===",
"null",
")",
"{",
"$",
"this",
"->"... | Executes Conjugate Gradient method to optimize the weights of the LogReg model | [
"Executes",
"Conjugate",
"Gradient",
"method",
"to",
"optimize",
"the",
"weights",
"of",
"the",
"LogReg",
"model"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Linear/LogisticRegression.php#L156-L165 | train | Runs Conjugate Gradient | [
30522,
5123,
3853,
2448,
8663,
9103,
5867,
16307,
11638,
1006,
9140,
1002,
8168,
1010,
9140,
1002,
7889,
1010,
8503,
1002,
17978,
11263,
12273,
1007,
1024,
11675,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
23569,
27605,
6290,
1027,
1027,
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... |
matomo-org/matomo | libs/HTML/QuickForm2/Renderer/Default.php | HTML_QuickForm2_Renderer_Default.reset | public function reset()
{
$this->html = array(array());
$this->hiddenHtml = '';
$this->errors = array();
$this->hasRequired = false;
$this->groupId = array();
return $this;
} | php | public function reset()
{
$this->html = array(array());
$this->hiddenHtml = '';
$this->errors = array();
$this->hasRequired = false;
$this->groupId = array();
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"html",
"=",
"array",
"(",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"hiddenHtml",
"=",
"''",
";",
"$",
"this",
"->",
"errors",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->... | Resets the accumulated data
This method is called automatically by startForm() method, but should
be called manually before calling other rendering methods separately.
@return HTML_QuickForm2_Renderer_Default | [
"Resets",
"the",
"accumulated",
"data"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Default.php#L260-L269 | train | Reset the current object | [
30522,
2270,
3853,
25141,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
16129,
1027,
9140,
1006,
9140,
1006,
1007,
1007,
1025,
1002,
2023,
1011,
1028,
5023,
11039,
19968,
1027,
1005,
1005,
1025,
1002,
2023,
1011,
1028,
10697,
1027,
9140,
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... |
matomo-org/matomo | core/API/Proxy.php | Proxy.call | public function call($className, $methodName, $parametersRequest)
{
// Temporarily sets the Request array to this API call context
return Context::executeWithQueryParameters($parametersRequest, function () use ($className, $methodName, $parametersRequest) {
$returnedValue = null;
$this->registerClass($className);
// instanciate the object
$object = $className::getInstance();
// check method exists
$this->checkMethodExists($className, $methodName);
// get the list of parameters required by the method
$parameterNamesDefaultValues = $this->getParametersList($className, $methodName);
// load parameters in the right order, etc.
$finalParameters = $this->getRequestParametersArray($parameterNamesDefaultValues, $parametersRequest);
// allow plugins to manipulate the value
$pluginName = $this->getModuleNameFromClassName($className);
$returnedValue = null;
/**
* Triggered before an API request is dispatched.
*
* This event can be used to modify the arguments passed to one or more API methods.
*
* **Example**
*
* Piwik::addAction('API.Request.dispatch', function (&$parameters, $pluginName, $methodName) {
* if ($pluginName == 'Actions') {
* if ($methodName == 'getPageUrls') {
* // ... do something ...
* } else {
* // ... do something else ...
* }
* }
* });
*
* @param array &$finalParameters List of parameters that will be passed to the API method.
* @param string $pluginName The name of the plugin the API method belongs to.
* @param string $methodName The name of the API method that will be called.
*/
Piwik::postEvent('API.Request.dispatch', array(&$finalParameters, $pluginName, $methodName));
/**
* Triggered before an API request is dispatched.
*
* This event exists for convenience and is triggered directly after the {@hook API.Request.dispatch}
* event is triggered. It can be used to modify the arguments passed to a **single** API method.
*
* _Note: This is can be accomplished with the {@hook API.Request.dispatch} event as well, however
* event handlers for that event will have to do more work._
*
* **Example**
*
* Piwik::addAction('API.Actions.getPageUrls', function (&$parameters) {
* // force use of a single website. for some reason.
* $parameters['idSite'] = 1;
* });
*
* @param array &$finalParameters List of parameters that will be passed to the API method.
*/
Piwik::postEvent(sprintf('API.%s.%s', $pluginName, $methodName), array(&$finalParameters));
/**
* Triggered before an API request is dispatched.
*
* Use this event to intercept an API request and execute your own code instead. If you set
* `$returnedValue` in a handler for this event, the original API method will not be executed,
* and the result will be what you set in the event handler.
*
* @param mixed &$returnedValue Set this to set the result and preempt normal API invocation.
* @param array &$finalParameters List of parameters that will be passed to the API method.
* @param string $pluginName The name of the plugin the API method belongs to.
* @param string $methodName The name of the API method that will be called.
* @param array $parametersRequest The query parameters for this request.
*/
Piwik::postEvent('API.Request.intercept', [&$returnedValue, $finalParameters, $pluginName, $methodName, $parametersRequest]);
$apiParametersInCorrectOrder = array();
foreach ($parameterNamesDefaultValues as $name => $defaultValue) {
if (isset($finalParameters[$name]) || array_key_exists($name, $finalParameters)) {
$apiParametersInCorrectOrder[] = $finalParameters[$name];
}
}
// call the method if a hook hasn't already set an output variable
if ($returnedValue === null) {
$returnedValue = call_user_func_array(array($object, $methodName), $apiParametersInCorrectOrder);
}
$endHookParams = array(
&$returnedValue,
array('className' => $className,
'module' => $pluginName,
'action' => $methodName,
'parameters' => $finalParameters)
);
/**
* Triggered directly after an API request is dispatched.
*
* This event exists for convenience and is triggered immediately before the
* {@hook API.Request.dispatch.end} event. It can be used to modify the output of a **single**
* API method.
*
* _Note: This can be accomplished with the {@hook API.Request.dispatch.end} event as well,
* however event handlers for that event will have to do more work._
*
* **Example**
*
* // append (0 hits) to the end of row labels whose row has 0 hits
* Piwik::addAction('API.Actions.getPageUrls', function (&$returnValue, $info)) {
* $returnValue->filter('ColumnCallbackReplace', 'label', function ($label, $hits) {
* if ($hits === 0) {
* return $label . " (0 hits)";
* } else {
* return $label;
* }
* }, null, array('nb_hits'));
* }
*
* @param mixed &$returnedValue The API method's return value. Can be an object, such as a
* {@link Piwik\DataTable DataTable} instance.
* could be a {@link Piwik\DataTable DataTable}.
* @param array $extraInfo An array holding information regarding the API request. Will
* contain the following data:
*
* - **className**: The namespace-d class name of the API instance
* that's being called.
* - **module**: The name of the plugin the API request was
* dispatched to.
* - **action**: The name of the API method that was executed.
* - **parameters**: The array of parameters passed to the API
* method.
*/
Piwik::postEvent(sprintf('API.%s.%s.end', $pluginName, $methodName), $endHookParams);
/**
* Triggered directly after an API request is dispatched.
*
* This event can be used to modify the output of any API method.
*
* **Example**
*
* // append (0 hits) to the end of row labels whose row has 0 hits for any report that has the 'nb_hits' metric
* Piwik::addAction('API.Actions.getPageUrls.end', function (&$returnValue, $info)) {
* // don't process non-DataTable reports and reports that don't have the nb_hits column
* if (!($returnValue instanceof DataTableInterface)
* || in_array('nb_hits', $returnValue->getColumns())
* ) {
* return;
* }
*
* $returnValue->filter('ColumnCallbackReplace', 'label', function ($label, $hits) {
* if ($hits === 0) {
* return $label . " (0 hits)";
* } else {
* return $label;
* }
* }, null, array('nb_hits'));
* }
*
* @param mixed &$returnedValue The API method's return value. Can be an object, such as a
* {@link Piwik\DataTable DataTable} instance.
* @param array $extraInfo An array holding information regarding the API request. Will
* contain the following data:
*
* - **className**: The namespace-d class name of the API instance
* that's being called.
* - **module**: The name of the plugin the API request was
* dispatched to.
* - **action**: The name of the API method that was executed.
* - **parameters**: The array of parameters passed to the API
* method.
*/
Piwik::postEvent('API.Request.dispatch.end', $endHookParams);
return $returnedValue;
});
} | php | public function call($className, $methodName, $parametersRequest)
{
// Temporarily sets the Request array to this API call context
return Context::executeWithQueryParameters($parametersRequest, function () use ($className, $methodName, $parametersRequest) {
$returnedValue = null;
$this->registerClass($className);
// instanciate the object
$object = $className::getInstance();
// check method exists
$this->checkMethodExists($className, $methodName);
// get the list of parameters required by the method
$parameterNamesDefaultValues = $this->getParametersList($className, $methodName);
// load parameters in the right order, etc.
$finalParameters = $this->getRequestParametersArray($parameterNamesDefaultValues, $parametersRequest);
// allow plugins to manipulate the value
$pluginName = $this->getModuleNameFromClassName($className);
$returnedValue = null;
/**
* Triggered before an API request is dispatched.
*
* This event can be used to modify the arguments passed to one or more API methods.
*
* **Example**
*
* Piwik::addAction('API.Request.dispatch', function (&$parameters, $pluginName, $methodName) {
* if ($pluginName == 'Actions') {
* if ($methodName == 'getPageUrls') {
* // ... do something ...
* } else {
* // ... do something else ...
* }
* }
* });
*
* @param array &$finalParameters List of parameters that will be passed to the API method.
* @param string $pluginName The name of the plugin the API method belongs to.
* @param string $methodName The name of the API method that will be called.
*/
Piwik::postEvent('API.Request.dispatch', array(&$finalParameters, $pluginName, $methodName));
/**
* Triggered before an API request is dispatched.
*
* This event exists for convenience and is triggered directly after the {@hook API.Request.dispatch}
* event is triggered. It can be used to modify the arguments passed to a **single** API method.
*
* _Note: This is can be accomplished with the {@hook API.Request.dispatch} event as well, however
* event handlers for that event will have to do more work._
*
* **Example**
*
* Piwik::addAction('API.Actions.getPageUrls', function (&$parameters) {
* // force use of a single website. for some reason.
* $parameters['idSite'] = 1;
* });
*
* @param array &$finalParameters List of parameters that will be passed to the API method.
*/
Piwik::postEvent(sprintf('API.%s.%s', $pluginName, $methodName), array(&$finalParameters));
/**
* Triggered before an API request is dispatched.
*
* Use this event to intercept an API request and execute your own code instead. If you set
* `$returnedValue` in a handler for this event, the original API method will not be executed,
* and the result will be what you set in the event handler.
*
* @param mixed &$returnedValue Set this to set the result and preempt normal API invocation.
* @param array &$finalParameters List of parameters that will be passed to the API method.
* @param string $pluginName The name of the plugin the API method belongs to.
* @param string $methodName The name of the API method that will be called.
* @param array $parametersRequest The query parameters for this request.
*/
Piwik::postEvent('API.Request.intercept', [&$returnedValue, $finalParameters, $pluginName, $methodName, $parametersRequest]);
$apiParametersInCorrectOrder = array();
foreach ($parameterNamesDefaultValues as $name => $defaultValue) {
if (isset($finalParameters[$name]) || array_key_exists($name, $finalParameters)) {
$apiParametersInCorrectOrder[] = $finalParameters[$name];
}
}
// call the method if a hook hasn't already set an output variable
if ($returnedValue === null) {
$returnedValue = call_user_func_array(array($object, $methodName), $apiParametersInCorrectOrder);
}
$endHookParams = array(
&$returnedValue,
array('className' => $className,
'module' => $pluginName,
'action' => $methodName,
'parameters' => $finalParameters)
);
/**
* Triggered directly after an API request is dispatched.
*
* This event exists for convenience and is triggered immediately before the
* {@hook API.Request.dispatch.end} event. It can be used to modify the output of a **single**
* API method.
*
* _Note: This can be accomplished with the {@hook API.Request.dispatch.end} event as well,
* however event handlers for that event will have to do more work._
*
* **Example**
*
* // append (0 hits) to the end of row labels whose row has 0 hits
* Piwik::addAction('API.Actions.getPageUrls', function (&$returnValue, $info)) {
* $returnValue->filter('ColumnCallbackReplace', 'label', function ($label, $hits) {
* if ($hits === 0) {
* return $label . " (0 hits)";
* } else {
* return $label;
* }
* }, null, array('nb_hits'));
* }
*
* @param mixed &$returnedValue The API method's return value. Can be an object, such as a
* {@link Piwik\DataTable DataTable} instance.
* could be a {@link Piwik\DataTable DataTable}.
* @param array $extraInfo An array holding information regarding the API request. Will
* contain the following data:
*
* - **className**: The namespace-d class name of the API instance
* that's being called.
* - **module**: The name of the plugin the API request was
* dispatched to.
* - **action**: The name of the API method that was executed.
* - **parameters**: The array of parameters passed to the API
* method.
*/
Piwik::postEvent(sprintf('API.%s.%s.end', $pluginName, $methodName), $endHookParams);
/**
* Triggered directly after an API request is dispatched.
*
* This event can be used to modify the output of any API method.
*
* **Example**
*
* // append (0 hits) to the end of row labels whose row has 0 hits for any report that has the 'nb_hits' metric
* Piwik::addAction('API.Actions.getPageUrls.end', function (&$returnValue, $info)) {
* // don't process non-DataTable reports and reports that don't have the nb_hits column
* if (!($returnValue instanceof DataTableInterface)
* || in_array('nb_hits', $returnValue->getColumns())
* ) {
* return;
* }
*
* $returnValue->filter('ColumnCallbackReplace', 'label', function ($label, $hits) {
* if ($hits === 0) {
* return $label . " (0 hits)";
* } else {
* return $label;
* }
* }, null, array('nb_hits'));
* }
*
* @param mixed &$returnedValue The API method's return value. Can be an object, such as a
* {@link Piwik\DataTable DataTable} instance.
* @param array $extraInfo An array holding information regarding the API request. Will
* contain the following data:
*
* - **className**: The namespace-d class name of the API instance
* that's being called.
* - **module**: The name of the plugin the API request was
* dispatched to.
* - **action**: The name of the API method that was executed.
* - **parameters**: The array of parameters passed to the API
* method.
*/
Piwik::postEvent('API.Request.dispatch.end', $endHookParams);
return $returnedValue;
});
} | [
"public",
"function",
"call",
"(",
"$",
"className",
",",
"$",
"methodName",
",",
"$",
"parametersRequest",
")",
"{",
"// Temporarily sets the Request array to this API call context",
"return",
"Context",
"::",
"executeWithQueryParameters",
"(",
"$",
"parametersRequest",
... | Will execute $className->$methodName($parametersValues)
If any error is detected (wrong number of parameters, method not found, class not found, etc.)
it will throw an exception
It also logs the API calls, with the parameters values, the returned value, the performance, etc.
You can enable logging in config/global.ini.php (log_api_call)
@param string $className The class name (eg. API)
@param string $methodName The method name
@param array $parametersRequest The parameters pairs (name=>value)
@return mixed|null
@throws Exception|\Piwik\NoAccessException | [
"Will",
"execute",
"$className",
"-",
">",
"$methodName",
"(",
"$parametersValues",
")",
"If",
"any",
"error",
"is",
"detected",
"(",
"wrong",
"number",
"of",
"parameters",
"method",
"not",
"found",
"class",
"not",
"found",
"etc",
".",
")",
"it",
"will",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Proxy.php#L144-L329 | train | Calls the specified class method with the given parameters request | [
30522,
2270,
3853,
2655,
1006,
1002,
2465,
18442,
1010,
1002,
4118,
18442,
1010,
1002,
11709,
2890,
15500,
1007,
1063,
1013,
1013,
8184,
4520,
1996,
5227,
9140,
2000,
2023,
17928,
2655,
6123,
2709,
6123,
1024,
1024,
15389,
24415,
4226,
2854... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Traits/MemcachedTrait.php | MemcachedTrait.createConnection | public static function createConnection($servers, array $options = [])
{
if (\is_string($servers)) {
$servers = [$servers];
} elseif (!\is_array($servers)) {
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers)));
}
if (!static::isSupported()) {
throw new CacheException('Memcached >= 2.2.0 is required');
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
try {
$options += static::$defaultClientOptions;
$client = new \Memcached($options['persistent_id']);
$username = $options['username'];
$password = $options['password'];
// parse any DSN in $servers
foreach ($servers as $i => $dsn) {
if (\is_array($dsn)) {
continue;
}
if (0 !== strpos($dsn, 'memcached:')) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:"', $dsn));
}
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
if (!empty($m[2])) {
list($username, $password) = explode(':', $m[2], 2) + [1 => null];
}
return 'file:'.($m[1] ?? '');
}, $dsn);
if (false === $params = parse_url($params)) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
$query = $hosts = [];
if (isset($params['query'])) {
parse_str($params['query'], $query);
if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
foreach ($hosts as $host => $weight) {
if (false === $port = strrpos($host, ':')) {
$hosts[$host] = [$host, 11211, (int) $weight];
} else {
$hosts[$host] = [substr($host, 0, $port), (int) substr($host, 1 + $port), (int) $weight];
}
}
$hosts = array_values($hosts);
unset($query['host']);
}
if ($hosts && !isset($params['host']) && !isset($params['path'])) {
unset($servers[$i]);
$servers = array_merge($servers, $hosts);
continue;
}
}
if (!isset($params['host']) && !isset($params['path'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
$params['weight'] = $m[1];
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
}
$params += [
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'port' => isset($params['host']) ? 11211 : null,
'weight' => 0,
];
if ($query) {
$params += $query;
$options = $query + $options;
}
$servers[$i] = [$params['host'], $params['port'], $params['weight']];
if ($hosts) {
$servers = array_merge($servers, $hosts);
}
}
// set client's options
unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
$options = array_change_key_case($options, CASE_UPPER);
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
}
foreach ($options as $name => $value) {
if (\is_int($name)) {
continue;
}
if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) {
$value = \constant('Memcached::'.$name.'_'.strtoupper($value));
}
$opt = \constant('Memcached::OPT_'.$name);
unset($options[$name]);
$options[$opt] = $value;
}
$client->setOptions($options);
// set client's servers, taking care of persistent connections
if (!$client->isPristine()) {
$oldServers = [];
foreach ($client->getServerList() as $server) {
$oldServers[] = [$server['host'], $server['port']];
}
$newServers = [];
foreach ($servers as $server) {
if (1 < \count($server)) {
$server = array_values($server);
unset($server[2]);
$server[1] = (int) $server[1];
}
$newServers[] = $server;
}
if ($oldServers !== $newServers) {
$client->resetServerList();
$client->addServers($servers);
}
} else {
$client->addServers($servers);
}
if (null !== $username || null !== $password) {
if (!method_exists($client, 'setSaslAuthData')) {
trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.');
}
$client->setSaslAuthData($username, $password);
}
return $client;
} finally {
restore_error_handler();
}
} | php | public static function createConnection($servers, array $options = [])
{
if (\is_string($servers)) {
$servers = [$servers];
} elseif (!\is_array($servers)) {
throw new InvalidArgumentException(sprintf('MemcachedAdapter::createClient() expects array or string as first argument, %s given.', \gettype($servers)));
}
if (!static::isSupported()) {
throw new CacheException('Memcached >= 2.2.0 is required');
}
set_error_handler(function ($type, $msg, $file, $line) { throw new \ErrorException($msg, 0, $type, $file, $line); });
try {
$options += static::$defaultClientOptions;
$client = new \Memcached($options['persistent_id']);
$username = $options['username'];
$password = $options['password'];
// parse any DSN in $servers
foreach ($servers as $i => $dsn) {
if (\is_array($dsn)) {
continue;
}
if (0 !== strpos($dsn, 'memcached:')) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s does not start with "memcached:"', $dsn));
}
$params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) {
if (!empty($m[2])) {
list($username, $password) = explode(':', $m[2], 2) + [1 => null];
}
return 'file:'.($m[1] ?? '');
}, $dsn);
if (false === $params = parse_url($params)) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
$query = $hosts = [];
if (isset($params['query'])) {
parse_str($params['query'], $query);
if (isset($query['host'])) {
if (!\is_array($hosts = $query['host'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
foreach ($hosts as $host => $weight) {
if (false === $port = strrpos($host, ':')) {
$hosts[$host] = [$host, 11211, (int) $weight];
} else {
$hosts[$host] = [substr($host, 0, $port), (int) substr($host, 1 + $port), (int) $weight];
}
}
$hosts = array_values($hosts);
unset($query['host']);
}
if ($hosts && !isset($params['host']) && !isset($params['path'])) {
unset($servers[$i]);
$servers = array_merge($servers, $hosts);
continue;
}
}
if (!isset($params['host']) && !isset($params['path'])) {
throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: %s', $dsn));
}
if (isset($params['path']) && preg_match('#/(\d+)$#', $params['path'], $m)) {
$params['weight'] = $m[1];
$params['path'] = substr($params['path'], 0, -\strlen($m[0]));
}
$params += [
'host' => isset($params['host']) ? $params['host'] : $params['path'],
'port' => isset($params['host']) ? 11211 : null,
'weight' => 0,
];
if ($query) {
$params += $query;
$options = $query + $options;
}
$servers[$i] = [$params['host'], $params['port'], $params['weight']];
if ($hosts) {
$servers = array_merge($servers, $hosts);
}
}
// set client's options
unset($options['persistent_id'], $options['username'], $options['password'], $options['weight'], $options['lazy']);
$options = array_change_key_case($options, CASE_UPPER);
$client->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
$client->setOption(\Memcached::OPT_NO_BLOCK, true);
$client->setOption(\Memcached::OPT_TCP_NODELAY, true);
if (!\array_key_exists('LIBKETAMA_COMPATIBLE', $options) && !\array_key_exists(\Memcached::OPT_LIBKETAMA_COMPATIBLE, $options)) {
$client->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
}
foreach ($options as $name => $value) {
if (\is_int($name)) {
continue;
}
if ('HASH' === $name || 'SERIALIZER' === $name || 'DISTRIBUTION' === $name) {
$value = \constant('Memcached::'.$name.'_'.strtoupper($value));
}
$opt = \constant('Memcached::OPT_'.$name);
unset($options[$name]);
$options[$opt] = $value;
}
$client->setOptions($options);
// set client's servers, taking care of persistent connections
if (!$client->isPristine()) {
$oldServers = [];
foreach ($client->getServerList() as $server) {
$oldServers[] = [$server['host'], $server['port']];
}
$newServers = [];
foreach ($servers as $server) {
if (1 < \count($server)) {
$server = array_values($server);
unset($server[2]);
$server[1] = (int) $server[1];
}
$newServers[] = $server;
}
if ($oldServers !== $newServers) {
$client->resetServerList();
$client->addServers($servers);
}
} else {
$client->addServers($servers);
}
if (null !== $username || null !== $password) {
if (!method_exists($client, 'setSaslAuthData')) {
trigger_error('Missing SASL support: the memcached extension must be compiled with --enable-memcached-sasl.');
}
$client->setSaslAuthData($username, $password);
}
return $client;
} finally {
restore_error_handler();
}
} | [
"public",
"static",
"function",
"createConnection",
"(",
"$",
"servers",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"servers",
")",
")",
"{",
"$",
"servers",
"=",
"[",
"$",
"servers",
"]",
";",
"}... | Creates a Memcached instance.
By default, the binary protocol, no block, and libketama compatible options are enabled.
Examples for servers:
- 'memcached://user:pass@localhost?weight=33'
- [['localhost', 11211, 33]]
@param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs
@param array $options An array of options
@return \Memcached
@throws \ErrorException When invalid options or servers are provided | [
"Creates",
"a",
"Memcached",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/MemcachedTrait.php#L80-L222 | train | Creates a Memcached client using the memcached server and options | [
30522,
2270,
10763,
3853,
3443,
8663,
2638,
7542,
1006,
1002,
14903,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
5164,
1006,
1002,
14903,
1007,
1007,
1063,
1002,
14903,
1027,
1031,
1002,
14903,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/HttpCache/HttpCache.php | HttpCache.validate | protected function validate(Request $request, Response $entry, $catch = false)
{
$subRequest = clone $request;
// send no head requests because we want content
if ('HEAD' === $request->getMethod()) {
$subRequest->setMethod('GET');
}
// add our cached last-modified validator
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
// Add our cached etag validator to the environment.
// We keep the etags from the client to handle the case when the client
// has a different private valid entry which is not cached here.
$cachedEtags = $entry->getEtag() ? [$entry->getEtag()] : [];
$requestEtags = $request->getETags();
if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) {
$subRequest->headers->set('if_none_match', implode(', ', $etags));
}
$response = $this->forward($subRequest, $catch, $entry);
if (304 == $response->getStatusCode()) {
$this->record($request, 'valid');
// return the response and not the cache entry if the response is valid but not cached
$etag = $response->getEtag();
if ($etag && \in_array($etag, $requestEtags) && !\in_array($etag, $cachedEtags)) {
return $response;
}
$entry = clone $entry;
$entry->headers->remove('Date');
foreach (['Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified'] as $name) {
if ($response->headers->has($name)) {
$entry->headers->set($name, $response->headers->get($name));
}
}
$response = $entry;
} else {
$this->record($request, 'invalid');
}
if ($response->isCacheable()) {
$this->store($request, $response);
}
return $response;
} | php | protected function validate(Request $request, Response $entry, $catch = false)
{
$subRequest = clone $request;
// send no head requests because we want content
if ('HEAD' === $request->getMethod()) {
$subRequest->setMethod('GET');
}
// add our cached last-modified validator
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
// Add our cached etag validator to the environment.
// We keep the etags from the client to handle the case when the client
// has a different private valid entry which is not cached here.
$cachedEtags = $entry->getEtag() ? [$entry->getEtag()] : [];
$requestEtags = $request->getETags();
if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) {
$subRequest->headers->set('if_none_match', implode(', ', $etags));
}
$response = $this->forward($subRequest, $catch, $entry);
if (304 == $response->getStatusCode()) {
$this->record($request, 'valid');
// return the response and not the cache entry if the response is valid but not cached
$etag = $response->getEtag();
if ($etag && \in_array($etag, $requestEtags) && !\in_array($etag, $cachedEtags)) {
return $response;
}
$entry = clone $entry;
$entry->headers->remove('Date');
foreach (['Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified'] as $name) {
if ($response->headers->has($name)) {
$entry->headers->set($name, $response->headers->get($name));
}
}
$response = $entry;
} else {
$this->record($request, 'invalid');
}
if ($response->isCacheable()) {
$this->store($request, $response);
}
return $response;
} | [
"protected",
"function",
"validate",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"entry",
",",
"$",
"catch",
"=",
"false",
")",
"{",
"$",
"subRequest",
"=",
"clone",
"$",
"request",
";",
"// send no head requests because we want content",
"if",
"(",
... | Validates that a cache entry is fresh.
The original request is used as a template for a conditional
GET request with the backend.
@param Request $request A Request instance
@param Response $entry A Response instance to validate
@param bool $catch Whether to process exceptions
@return Response A Response instance | [
"Validates",
"that",
"a",
"cache",
"entry",
"is",
"fresh",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php#L375-L426 | train | Validate the response and return the response | [
30522,
5123,
3853,
9398,
3686,
1006,
5227,
1002,
5227,
1010,
3433,
1002,
4443,
1010,
1002,
4608,
1027,
6270,
1007,
1063,
1002,
4942,
2890,
15500,
1027,
17598,
1002,
5227,
1025,
1013,
1013,
4604,
2053,
2132,
11186,
2138,
2057,
2215,
4180,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Live/API.php | API.getFirstVisitForVisitorId | public function getFirstVisitForVisitorId($idSite, $visitorId)
{
Piwik::checkUserHasSomeViewAccess();
if (empty($visitorId)) {
return new DataTable();
}
$model = new Model();
$data = $model->queryLogVisits($idSite, false, false, false, 0, 1, $visitorId, false, 'ASC');
$dataTable = $this->makeVisitorTableFromArray($data);
$this->addFilterToCleanVisitors($dataTable, $idSite, false, true);
return $dataTable;
} | php | public function getFirstVisitForVisitorId($idSite, $visitorId)
{
Piwik::checkUserHasSomeViewAccess();
if (empty($visitorId)) {
return new DataTable();
}
$model = new Model();
$data = $model->queryLogVisits($idSite, false, false, false, 0, 1, $visitorId, false, 'ASC');
$dataTable = $this->makeVisitorTableFromArray($data);
$this->addFilterToCleanVisitors($dataTable, $idSite, false, true);
return $dataTable;
} | [
"public",
"function",
"getFirstVisitForVisitorId",
"(",
"$",
"idSite",
",",
"$",
"visitorId",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeViewAccess",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"visitorId",
")",
")",
"{",
"return",
"new",
"DataTable",
"(",
... | Returns the very first visit for the given visitorId
@internal
@param $idSite
@param $visitorId
@return DataTable | [
"Returns",
"the",
"very",
"first",
"visit",
"for",
"the",
"given",
"visitorId"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Live/API.php#L314-L328 | train | Get the first visit for a given visitorId | [
30522,
2270,
3853,
2131,
8873,
12096,
11365,
4183,
29278,
11365,
15660,
3593,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
10367,
3593,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
8584,
6305,
9623,
2015,
1006,
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/HTML/QuickForm2/Renderer/Proxy.php | HTML_QuickForm2_Renderer_Proxy.addPlugin | protected function addPlugin($index, HTML_QuickForm2_Renderer_Plugin $plugin)
{
$methods = array();
$reflection = new ReflectionObject($plugin);
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
$lower = strtolower($method->getName());
if ('HTML_QuickForm2_Renderer_Plugin' == $method->getDeclaringClass()->getName()) {
continue;
} elseif (isset($this->_rendererMethods[$lower])
|| isset($this->_pluginMethods[$lower])
) {
throw new HTML_QuickForm2_InvalidArgumentException(
'Duplicate method name: name ' . $method->getName() . ' in plugin ' .
get_class($plugin) . ' already taken by ' .
(isset($this->_rendererMethods[$lower])?
get_class($this->_renderer):
get_class($this->_plugins[$this->_pluginMethods[$lower]])
)
);
}
$methods[$lower] = $index;
}
$plugin->setRenderer($this->_renderer);
$this->_plugins[$index] = $plugin;
$this->_pluginMethods += $methods;
} | php | protected function addPlugin($index, HTML_QuickForm2_Renderer_Plugin $plugin)
{
$methods = array();
$reflection = new ReflectionObject($plugin);
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
$lower = strtolower($method->getName());
if ('HTML_QuickForm2_Renderer_Plugin' == $method->getDeclaringClass()->getName()) {
continue;
} elseif (isset($this->_rendererMethods[$lower])
|| isset($this->_pluginMethods[$lower])
) {
throw new HTML_QuickForm2_InvalidArgumentException(
'Duplicate method name: name ' . $method->getName() . ' in plugin ' .
get_class($plugin) . ' already taken by ' .
(isset($this->_rendererMethods[$lower])?
get_class($this->_renderer):
get_class($this->_plugins[$this->_pluginMethods[$lower]])
)
);
}
$methods[$lower] = $index;
}
$plugin->setRenderer($this->_renderer);
$this->_plugins[$index] = $plugin;
$this->_pluginMethods += $methods;
} | [
"protected",
"function",
"addPlugin",
"(",
"$",
"index",
",",
"HTML_QuickForm2_Renderer_Plugin",
"$",
"plugin",
")",
"{",
"$",
"methods",
"=",
"array",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"ReflectionObject",
"(",
"$",
"plugin",
")",
";",
"foreach",... | Adds a plugin for the current renderer instance
Plugin's methods are imported and can be later called as this object's own
@param HTML_QuickForm2_Renderer_Plugin a plugin instance
@throws HTML_QuickForm2_InvalidArgumentException if a plugin has already
imported name | [
"Adds",
"a",
"plugin",
"for",
"the",
"current",
"renderer",
"instance"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Proxy.php#L162-L187 | train | Adds a plugin to the list of available methods | [
30522,
5123,
3853,
5587,
24759,
15916,
2378,
1006,
1002,
5950,
1010,
16129,
1035,
4248,
14192,
2475,
1035,
17552,
2121,
1035,
13354,
2378,
1002,
13354,
2378,
1007,
1063,
1002,
4725,
1027,
9140,
1006,
1007,
1025,
1002,
9185,
1027,
2047,
9185... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/SettingsPiwik.php | SettingsPiwik.getKnownSegmentsToArchive | public static function getKnownSegmentsToArchive()
{
$cacheId = 'KnownSegmentsToArchive';
$cache = PiwikCache::getTransientCache();
if ($cache->contains($cacheId)) {
return $cache->fetch($cacheId);
}
$segments = Config::getInstance()->Segments;
$segmentsToProcess = isset($segments['Segments']) ? $segments['Segments'] : array();
/**
* Triggered during the cron archiving process to collect segments that
* should be pre-processed for all websites. The archiving process will be launched
* for each of these segments when archiving data.
*
* This event can be used to add segments to be pre-processed. If your plugin depends
* on data from a specific segment, this event could be used to provide enhanced
* performance.
*
* _Note: If you just want to add a segment that is managed by the user, use the
* SegmentEditor API._
*
* **Example**
*
* Piwik::addAction('Segments.getKnownSegmentsToArchiveAllSites', function (&$segments) {
* $segments[] = 'country=jp;city=Tokyo';
* });
*
* @param array &$segmentsToProcess List of segment definitions, eg,
*
* array(
* 'browserCode=ff;resolution=800x600',
* 'country=jp;city=Tokyo'
* )
*
* Add segments to this array in your event handler.
*/
Piwik::postEvent('Segments.getKnownSegmentsToArchiveAllSites', array(&$segmentsToProcess));
$segmentsToProcess = array_unique($segmentsToProcess);
$cache->save($cacheId, $segmentsToProcess);
return $segmentsToProcess;
} | php | public static function getKnownSegmentsToArchive()
{
$cacheId = 'KnownSegmentsToArchive';
$cache = PiwikCache::getTransientCache();
if ($cache->contains($cacheId)) {
return $cache->fetch($cacheId);
}
$segments = Config::getInstance()->Segments;
$segmentsToProcess = isset($segments['Segments']) ? $segments['Segments'] : array();
/**
* Triggered during the cron archiving process to collect segments that
* should be pre-processed for all websites. The archiving process will be launched
* for each of these segments when archiving data.
*
* This event can be used to add segments to be pre-processed. If your plugin depends
* on data from a specific segment, this event could be used to provide enhanced
* performance.
*
* _Note: If you just want to add a segment that is managed by the user, use the
* SegmentEditor API._
*
* **Example**
*
* Piwik::addAction('Segments.getKnownSegmentsToArchiveAllSites', function (&$segments) {
* $segments[] = 'country=jp;city=Tokyo';
* });
*
* @param array &$segmentsToProcess List of segment definitions, eg,
*
* array(
* 'browserCode=ff;resolution=800x600',
* 'country=jp;city=Tokyo'
* )
*
* Add segments to this array in your event handler.
*/
Piwik::postEvent('Segments.getKnownSegmentsToArchiveAllSites', array(&$segmentsToProcess));
$segmentsToProcess = array_unique($segmentsToProcess);
$cache->save($cacheId, $segmentsToProcess);
return $segmentsToProcess;
} | [
"public",
"static",
"function",
"getKnownSegmentsToArchive",
"(",
")",
"{",
"$",
"cacheId",
"=",
"'KnownSegmentsToArchive'",
";",
"$",
"cache",
"=",
"PiwikCache",
"::",
"getTransientCache",
"(",
")",
";",
"if",
"(",
"$",
"cache",
"->",
"contains",
"(",
"$",
... | Returns every stored segment to pre-process for each site during cron archiving.
@return array The list of stored segments that apply to all sites. | [
"Returns",
"every",
"stored",
"segment",
"to",
"pre",
"-",
"process",
"for",
"each",
"site",
"during",
"cron",
"archiving",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/SettingsPiwik.php#L63-L107 | train | Returns the list of all known segments to archive | [
30522,
2270,
10763,
3853,
2131,
2243,
19779,
12325,
21693,
11187,
3406,
2906,
5428,
3726,
1006,
1007,
1063,
1002,
17053,
3593,
1027,
1005,
2124,
3366,
21693,
11187,
3406,
2906,
5428,
3726,
1005,
1025,
1002,
17053,
1027,
14255,
9148,
2243,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Middleware/SetCacheHeaders.php | SetCacheHeaders.handle | public function handle($request, Closure $next, $options = [])
{
$response = $next($request);
if (! $request->isMethodCacheable() || ! $response->getContent()) {
return $response;
}
if (is_string($options)) {
$options = $this->parseOptions($options);
}
if (isset($options['etag']) && $options['etag'] === true) {
$options['etag'] = md5($response->getContent());
}
$response->setCache($options);
$response->isNotModified($request);
return $response;
} | php | public function handle($request, Closure $next, $options = [])
{
$response = $next($request);
if (! $request->isMethodCacheable() || ! $response->getContent()) {
return $response;
}
if (is_string($options)) {
$options = $this->parseOptions($options);
}
if (isset($options['etag']) && $options['etag'] === true) {
$options['etag'] = md5($response->getContent());
}
$response->setCache($options);
$response->isNotModified($request);
return $response;
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"next",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"request",
"->",
"isMethodCacheab... | Add cache related HTTP headers.
@param \Illuminate\Http\Request $request
@param \Closure $next
@param string|array $options
@return \Symfony\Component\HttpFoundation\Response
@throws \InvalidArgumentException | [
"Add",
"cache",
"related",
"HTTP",
"headers",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Middleware/SetCacheHeaders.php#L19-L39 | train | Handle the request and return the response | [
30522,
2270,
3853,
5047,
1006,
1002,
5227,
1010,
8503,
1002,
2279,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
3433,
1027,
1002,
2279,
1006,
1002,
5227,
1007,
1025,
2065,
1006,
999,
1002,
5227,
1011,
1028,
2003,
11368,
6806,
164... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DependencyInjection/ContainerBuilder.php | ContainerBuilder.shareService | private function shareService(Definition $definition, $service, $id, array &$inlineServices)
{
$inlineServices[null !== $id ? $id : spl_object_hash($definition)] = $service;
if (null !== $id && $definition->isShared()) {
$this->services[$id] = $service;
unset($this->loading[$id]);
}
} | php | private function shareService(Definition $definition, $service, $id, array &$inlineServices)
{
$inlineServices[null !== $id ? $id : spl_object_hash($definition)] = $service;
if (null !== $id && $definition->isShared()) {
$this->services[$id] = $service;
unset($this->loading[$id]);
}
} | [
"private",
"function",
"shareService",
"(",
"Definition",
"$",
"definition",
",",
"$",
"service",
",",
"$",
"id",
",",
"array",
"&",
"$",
"inlineServices",
")",
"{",
"$",
"inlineServices",
"[",
"null",
"!==",
"$",
"id",
"?",
"$",
"id",
":",
"spl_object_h... | Shares a given service in the container.
@param Definition $definition
@param object $service
@param string|null $id | [
"Shares",
"a",
"given",
"service",
"in",
"the",
"container",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L1644-L1652 | train | Share a service with the inline service list | [
30522,
2797,
3853,
6661,
2121,
7903,
2063,
1006,
6210,
1002,
6210,
1010,
1002,
2326,
1010,
1002,
8909,
1010,
9140,
1004,
1002,
23881,
8043,
7903,
2229,
1007,
1063,
1002,
23881,
8043,
7903,
2229,
1031,
19701,
999,
1027,
1027,
1002,
8909,
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/Routing/ResponseFactory.php | ResponseFactory.streamDownload | public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment')
{
$response = new StreamedResponse($callback, 200, $headers);
if (! is_null($name)) {
$response->headers->set('Content-Disposition', $response->headers->makeDisposition(
$disposition,
$name,
$this->fallbackName($name)
));
}
return $response;
} | php | public function streamDownload($callback, $name = null, array $headers = [], $disposition = 'attachment')
{
$response = new StreamedResponse($callback, 200, $headers);
if (! is_null($name)) {
$response->headers->set('Content-Disposition', $response->headers->makeDisposition(
$disposition,
$name,
$this->fallbackName($name)
));
}
return $response;
} | [
"public",
"function",
"streamDownload",
"(",
"$",
"callback",
",",
"$",
"name",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"disposition",
"=",
"'attachment'",
")",
"{",
"$",
"response",
"=",
"new",
"StreamedResponse",
"(",
"$",
... | Create a new streamed response instance as a file download.
@param \Closure $callback
@param string|null $name
@param array $headers
@param string|null $disposition
@return \Symfony\Component\HttpFoundation\StreamedResponse | [
"Create",
"a",
"new",
"streamed",
"response",
"instance",
"as",
"a",
"file",
"download",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/ResponseFactory.php#L135-L148 | train | Streamed download. | [
30522,
2270,
3853,
5460,
7698,
11066,
1006,
1002,
2655,
5963,
1010,
1002,
2171,
1027,
19701,
1010,
9140,
1002,
20346,
2015,
1027,
1031,
1033,
1010,
1002,
22137,
1027,
1005,
14449,
1005,
1007,
1063,
1002,
3433,
1027,
2047,
18498,
6072,
26029... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Broadcasting/Broadcasters/Broadcaster.php | Broadcaster.resolveImplicitBindingIfPossible | protected function resolveImplicitBindingIfPossible($key, $value, $callbackParameters)
{
foreach ($callbackParameters as $parameter) {
if (! $this->isImplicitlyBindable($key, $parameter)) {
continue;
}
$instance = $parameter->getClass()->newInstance();
if (! $model = $instance->resolveRouteBinding($value)) {
throw new AccessDeniedHttpException;
}
return $model;
}
return $value;
} | php | protected function resolveImplicitBindingIfPossible($key, $value, $callbackParameters)
{
foreach ($callbackParameters as $parameter) {
if (! $this->isImplicitlyBindable($key, $parameter)) {
continue;
}
$instance = $parameter->getClass()->newInstance();
if (! $model = $instance->resolveRouteBinding($value)) {
throw new AccessDeniedHttpException;
}
return $model;
}
return $value;
} | [
"protected",
"function",
"resolveImplicitBindingIfPossible",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"callbackParameters",
")",
"{",
"foreach",
"(",
"$",
"callbackParameters",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isImpl... | Resolve an implicit parameter binding if applicable.
@param string $key
@param mixed $value
@param array $callbackParameters
@return mixed
@throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException | [
"Resolve",
"an",
"implicit",
"parameter",
"binding",
"if",
"applicable",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php#L200-L217 | train | Resolve implicit binding if possible | [
30522,
5123,
3853,
10663,
5714,
24759,
28775,
2102,
8428,
4667,
10128,
6873,
18719,
3468,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
1002,
2655,
5963,
28689,
22828,
2015,
1007,
1063,
18921,
6776,
1006,
1002,
2655,
5963,
28689,
22828,
2015,
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... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.addCustomHeader | public function addCustomHeader($name, $value = null)
{
if (null === $value) {
// Value passed in as name:value
$this->CustomHeader[] = explode(':', $name, 2);
} else {
$this->CustomHeader[] = [$name, $value];
}
} | php | public function addCustomHeader($name, $value = null)
{
if (null === $value) {
// Value passed in as name:value
$this->CustomHeader[] = explode(':', $name, 2);
} else {
$this->CustomHeader[] = [$name, $value];
}
} | [
"public",
"function",
"addCustomHeader",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"// Value passed in as name:value",
"$",
"this",
"->",
"CustomHeader",
"[",
"]",
"=",
"explode",
"(",
"... | Add a custom header.
$name value can be overloaded to contain
both header name and value (name:value).
@param string $name Custom header name
@param string|null $value Header value | [
"Add",
"a",
"custom",
"header",
".",
"$name",
"value",
"can",
"be",
"overloaded",
"to",
"contain",
"both",
"header",
"name",
"and",
"value",
"(",
"name",
":",
"value",
")",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L3733-L3741 | train | Add custom header | [
30522,
2270,
3853,
5587,
7874,
20389,
4974,
2121,
1006,
1002,
2171,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
3643,
1007,
1063,
1013,
1013,
3643,
2979,
1999,
2004,
2171,
1024,
3643,
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... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php | ChoiceType.finishView | public function finishView(FormView $view, FormInterface $form, array $options)
{
if ($options['expanded']) {
// Radio buttons should have the same name as the parent
$childName = $view->vars['full_name'];
// Checkboxes should append "[]" to allow multiple selection
if ($options['multiple']) {
$childName .= '[]';
}
foreach ($view as $childView) {
$childView->vars['full_name'] = $childName;
}
}
} | php | public function finishView(FormView $view, FormInterface $form, array $options)
{
if ($options['expanded']) {
// Radio buttons should have the same name as the parent
$childName = $view->vars['full_name'];
// Checkboxes should append "[]" to allow multiple selection
if ($options['multiple']) {
$childName .= '[]';
}
foreach ($view as $childView) {
$childView->vars['full_name'] = $childName;
}
}
} | [
"public",
"function",
"finishView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'expanded'",
"]",
")",
"{",
"// Radio buttons should have the same name as the parent",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php#L230-L245 | train | Finishes the form view. | [
30522,
2270,
3853,
3926,
8584,
1006,
2433,
8584,
1002,
3193,
1010,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
1002,
7047,
1031,
1005,
4423,
1005,
1033,
1007,
1063,
1013,
1013,
2557,
11287,
2323,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getIdsNotMatchingTags | public function getIdsNotMatchingTags($tags = array())
{
$res = $this->_query("SELECT id FROM cache");
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
$result = array();
foreach ($rows as $row) {
$id = $row['id'];
$matching = false;
foreach ($tags as $tag) {
$res = $this->_query("SELECT COUNT(*) AS nbr FROM tag WHERE name='$tag' AND id='$id'");
if (!$res) {
return array();
}
$nbr = (int) @sqlite_fetch_single($res);
if ($nbr > 0) {
$matching = true;
}
}
if (!$matching) {
$result[] = $id;
}
}
return $result;
} | php | public function getIdsNotMatchingTags($tags = array())
{
$res = $this->_query("SELECT id FROM cache");
$rows = @sqlite_fetch_all($res, SQLITE_ASSOC);
$result = array();
foreach ($rows as $row) {
$id = $row['id'];
$matching = false;
foreach ($tags as $tag) {
$res = $this->_query("SELECT COUNT(*) AS nbr FROM tag WHERE name='$tag' AND id='$id'");
if (!$res) {
return array();
}
$nbr = (int) @sqlite_fetch_single($res);
if ($nbr > 0) {
$matching = true;
}
}
if (!$matching) {
$result[] = $id;
}
}
return $result;
} | [
"public",
"function",
"getIdsNotMatchingTags",
"(",
"$",
"tags",
"=",
"array",
"(",
")",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"_query",
"(",
"\"SELECT id FROM cache\"",
")",
";",
"$",
"rows",
"=",
"@",
"sqlite_fetch_all",
"(",
"$",
"res",
",",
... | Return an array of stored cache ids which don't match given tags
In case of multiple tags, a logical OR is made between tags
@param array $tags array of tags
@return array array of not matching cache ids (string) | [
"Return",
"an",
"array",
"of",
"stored",
"cache",
"ids",
"which",
"don",
"t",
"match",
"given",
"tags"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Sqlite.php#L302-L325 | train | Returns all the ids not matching the given tags | [
30522,
2270,
3853,
2131,
9821,
17048,
18900,
8450,
15900,
2015,
1006,
1002,
22073,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
24501,
1027,
1002,
2023,
1011,
1028,
1035,
23032,
1006,
1000,
7276,
8909,
2013,
17053,
1000,
1007,
1025,
1002,
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/DependencyInjection/Compiler/AutowirePass.php | AutowirePass.process | public function process(ContainerBuilder $container)
{
try {
parent::process($container);
} finally {
$this->types = null;
$this->ambiguousServiceTypes = null;
$this->decoratedClass = null;
$this->decoratedId = null;
$this->methodCalls = null;
$this->getPreviousValue = null;
$this->decoratedMethodIndex = null;
$this->decoratedMethodArgumentIndex = null;
}
} | php | public function process(ContainerBuilder $container)
{
try {
parent::process($container);
} finally {
$this->types = null;
$this->ambiguousServiceTypes = null;
$this->decoratedClass = null;
$this->decoratedId = null;
$this->methodCalls = null;
$this->getPreviousValue = null;
$this->decoratedMethodIndex = null;
$this->decoratedMethodArgumentIndex = null;
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"try",
"{",
"parent",
"::",
"process",
"(",
"$",
"container",
")",
";",
"}",
"finally",
"{",
"$",
"this",
"->",
"types",
"=",
"null",
";",
"$",
"this",
"->",
"ambiguo... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php#L49-L63 | train | Process the container builder | [
30522,
2270,
3853,
2832,
1006,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
3046,
1063,
6687,
1024,
1024,
2832,
1006,
1002,
11661,
1007,
1025,
1065,
2633,
1063,
1002,
2023,
1011,
1028,
4127,
1027,
19701,
1025,
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... |
matomo-org/matomo | plugins/Installation/ServerFilesGenerator.php | ServerFilesGenerator.createHtAccessFiles | public static function createHtAccessFiles()
{
$denyAll = self::getDenyAllHtaccessContent();
$allow = self::getAllowHtaccessContent();
$allowAny =
"# Allow any file in this directory\n" .
"<Files \"*\">\n" .
"\t" . $allow . "\n" .
"</Files>\n";
$allowStaticAssets =
"# Serve HTML files as text/html mime type - Note: requires mod_mime apache module!\n" .
"<IfModule mod_mime.c>\n" .
" AddHandler text/html .html\n" .
" AddHandler text/html .htm\n" .
"</IfModule>\n\n" .
"# Allow to serve static files which are safe\n" .
"<Files ~ \"\\.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2|json)$\">\n" .
$allow . "\n" .
"</Files>\n";
$noCachePreview = "
# do not cache preview container files
<Files ~ \"^container_.*_preview\.js$\">
<IfModule mod_headers.c>
Header set Cache-Control \"Cache-Control: private, no-cache, no-store\"
</IfModule>
</Files>";
$directoriesToProtect = array(
'/js' => $allowAny . $noCachePreview,
'/libs' => $denyAll . $allowStaticAssets,
'/vendor' => $denyAll . $allowStaticAssets,
'/plugins' => $denyAll . $allowStaticAssets,
'/misc/user' => $denyAll . $allowStaticAssets,
);
foreach ($directoriesToProtect as $directoryToProtect => $content) {
self::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
}
// deny access to these folders
$directoriesToProtect = array(
'/config' => $denyAll,
'/core' => $denyAll,
'/lang' => $denyAll,
'/tmp' => $denyAll,
);
foreach ($directoriesToProtect as $directoryToProtect => $content) {
self::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
}
} | php | public static function createHtAccessFiles()
{
$denyAll = self::getDenyAllHtaccessContent();
$allow = self::getAllowHtaccessContent();
$allowAny =
"# Allow any file in this directory\n" .
"<Files \"*\">\n" .
"\t" . $allow . "\n" .
"</Files>\n";
$allowStaticAssets =
"# Serve HTML files as text/html mime type - Note: requires mod_mime apache module!\n" .
"<IfModule mod_mime.c>\n" .
" AddHandler text/html .html\n" .
" AddHandler text/html .htm\n" .
"</IfModule>\n\n" .
"# Allow to serve static files which are safe\n" .
"<Files ~ \"\\.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2|json)$\">\n" .
$allow . "\n" .
"</Files>\n";
$noCachePreview = "
# do not cache preview container files
<Files ~ \"^container_.*_preview\.js$\">
<IfModule mod_headers.c>
Header set Cache-Control \"Cache-Control: private, no-cache, no-store\"
</IfModule>
</Files>";
$directoriesToProtect = array(
'/js' => $allowAny . $noCachePreview,
'/libs' => $denyAll . $allowStaticAssets,
'/vendor' => $denyAll . $allowStaticAssets,
'/plugins' => $denyAll . $allowStaticAssets,
'/misc/user' => $denyAll . $allowStaticAssets,
);
foreach ($directoriesToProtect as $directoryToProtect => $content) {
self::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
}
// deny access to these folders
$directoriesToProtect = array(
'/config' => $denyAll,
'/core' => $denyAll,
'/lang' => $denyAll,
'/tmp' => $denyAll,
);
foreach ($directoriesToProtect as $directoryToProtect => $content) {
self::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
}
} | [
"public",
"static",
"function",
"createHtAccessFiles",
"(",
")",
"{",
"$",
"denyAll",
"=",
"self",
"::",
"getDenyAllHtaccessContent",
"(",
")",
";",
"$",
"allow",
"=",
"self",
"::",
"getAllowHtaccessContent",
"(",
")",
";",
"$",
"allowAny",
"=",
"\"# Allow any... | Generate Apache .htaccess files to restrict access
.htaccess files are created on all webservers even Nginx, as sometimes Nginx knows how to handle .htaccess files | [
"Generate",
"Apache",
".",
"htaccess",
"files",
"to",
"restrict",
"access",
".",
"htaccess",
"files",
"are",
"created",
"on",
"all",
"webservers",
"even",
"Nginx",
"as",
"sometimes",
"Nginx",
"knows",
"how",
"to",
"handle",
".",
"htaccess",
"files"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/ServerFilesGenerator.php#L31-L83 | train | Create all apache files | [
30522,
2270,
10763,
3853,
3443,
22893,
9468,
7971,
8873,
4244,
1006,
1007,
1063,
1002,
9772,
8095,
1027,
2969,
1024,
1024,
2131,
4181,
21095,
2140,
22893,
9468,
7971,
8663,
6528,
2102,
1006,
1007,
1025,
1002,
3499,
1027,
2969,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.