repo stringclasses 21 values | path stringlengths 10 105 | func_name stringlengths 6 64 | original_string stringlengths 105 15.6k | language stringclasses 1 value | code stringlengths 105 15.6k | code_tokens listlengths 29 2.15k | docstring stringlengths 11 2.85k | docstring_tokens listlengths 1 290 | sha stringclasses 21 values | url stringlengths 100 194 | partition stringclasses 1 value | summary stringlengths 8 319 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
laravel/framework | src/Illuminate/Redis/Limiters/ConcurrencyLimiter.php | ConcurrencyLimiter.acquire | protected function acquire($id)
{
$slots = array_map(function ($i) {
return $this->name.$i;
}, range(1, $this->maxLocks));
return $this->redis->eval(...array_merge(
[$this->lockScript(), count($slots)],
array_merge($slots, [$this->name, $this->releaseAfter, $id])
));
} | php | protected function acquire($id)
{
$slots = array_map(function ($i) {
return $this->name.$i;
}, range(1, $this->maxLocks));
return $this->redis->eval(...array_merge(
[$this->lockScript(), count($slots)],
array_merge($slots, [$this->name, $this->releaseAfter, $id])
));
} | [
"protected",
"function",
"acquire",
"(",
"$",
"id",
")",
"{",
"$",
"slots",
"=",
"array_map",
"(",
"function",
"(",
"$",
"i",
")",
"{",
"return",
"$",
"this",
"->",
"name",
".",
"$",
"i",
";",
"}",
",",
"range",
"(",
"1",
",",
"$",
"this",
"->"... | Attempt to acquire the lock.
@param string $id A unique identifier for this lock
@return mixed | [
"Attempt",
"to",
"acquire",
"the",
"lock",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Limiters/ConcurrencyLimiter.php#L102-L112 | train | Acquire a lock | [
30522,
5123,
3853,
9878,
1006,
1002,
8909,
1007,
1063,
1002,
19832,
1027,
9140,
1035,
4949,
1006,
3853,
1006,
1002,
1045,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2171,
1012,
1002,
1045,
1025,
1065,
1010,
2846,
1006,
1015,
1010,
1002,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | HttpCache.restoreResponseBody | private function restoreResponseBody(Request $request, Response $response)
{
if ($response->headers->has('X-Body-Eval')) {
ob_start();
if ($response->headers->has('X-Body-File')) {
include $response->headers->get('X-Body-File');
} else {
eval('; ?>'.$response->getContent().'<?php ;');
}
$response->setContent(ob_get_clean());
$response->headers->remove('X-Body-Eval');
if (!$response->headers->has('Transfer-Encoding')) {
$response->headers->set('Content-Length', \strlen($response->getContent()));
}
} elseif ($response->headers->has('X-Body-File')) {
// Response does not include possibly dynamic content (ESI, SSI), so we need
// not handle the content for HEAD requests
if (!$request->isMethod('HEAD')) {
$response->setContent(file_get_contents($response->headers->get('X-Body-File')));
}
} else {
return;
}
$response->headers->remove('X-Body-File');
} | php | private function restoreResponseBody(Request $request, Response $response)
{
if ($response->headers->has('X-Body-Eval')) {
ob_start();
if ($response->headers->has('X-Body-File')) {
include $response->headers->get('X-Body-File');
} else {
eval('; ?>'.$response->getContent().'<?php ;');
}
$response->setContent(ob_get_clean());
$response->headers->remove('X-Body-Eval');
if (!$response->headers->has('Transfer-Encoding')) {
$response->headers->set('Content-Length', \strlen($response->getContent()));
}
} elseif ($response->headers->has('X-Body-File')) {
// Response does not include possibly dynamic content (ESI, SSI), so we need
// not handle the content for HEAD requests
if (!$request->isMethod('HEAD')) {
$response->setContent(file_get_contents($response->headers->get('X-Body-File')));
}
} else {
return;
}
$response->headers->remove('X-Body-File');
} | [
"private",
"function",
"restoreResponseBody",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"headers",
"->",
"has",
"(",
"'X-Body-Eval'",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"if",
"(",... | Restores the Response body. | [
"Restores",
"the",
"Response",
"body",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php#L606-L633 | train | Restore the body of the response | [
30522,
2797,
3853,
9239,
6072,
26029,
3366,
23684,
1006,
5227,
1002,
5227,
1010,
3433,
1002,
3433,
1007,
1063,
2065,
1006,
1002,
3433,
1011,
1028,
20346,
2015,
1011,
1028,
2038,
1006,
1005,
1060,
1011,
2303,
1011,
9345,
2140,
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 | plugins/Insights/API.php | API.canGenerateInsights | public function canGenerateInsights($date, $period)
{
Piwik::checkUserHasSomeViewAccess();
try {
$lastDate = $this->model->getLastDate($date, $period, 1);
} catch (\Exception $e) {
return false;
}
if (empty($lastDate)) {
return false;
}
return true;
} | php | public function canGenerateInsights($date, $period)
{
Piwik::checkUserHasSomeViewAccess();
try {
$lastDate = $this->model->getLastDate($date, $period, 1);
} catch (\Exception $e) {
return false;
}
if (empty($lastDate)) {
return false;
}
return true;
} | [
"public",
"function",
"canGenerateInsights",
"(",
"$",
"date",
",",
"$",
"period",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeViewAccess",
"(",
")",
";",
"try",
"{",
"$",
"lastDate",
"=",
"$",
"this",
"->",
"model",
"->",
"getLastDate",
"(",
"$",
"date",
... | Detects whether insights can be generated for this date/period combination or not.
@param string $date eg 'today', '2012-12-12'
@param string $period eg 'day' or 'week'
@return bool | [
"Detects",
"whether",
"insights",
"can",
"be",
"generated",
"for",
"this",
"date",
"/",
"period",
"combination",
"or",
"not",
".",
"@param",
"string",
"$date",
"eg",
"today",
"2012",
"-",
"12",
"-",
"12",
"@param",
"string",
"$period",
"eg",
"day",
"or",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Insights/API.php#L79-L94 | train | Can generateInsights - This method is used to check if the user has access to the model | [
30522,
2270,
3853,
2064,
6914,
22139,
7076,
18743,
2015,
1006,
1002,
3058,
1010,
1002,
2558,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
8584,
6305,
9623,
2015,
1006,
1007,
1025,
3046,
1063,
1002,
2197,
13701,
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... |
laravel/framework | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.validateUnique | public function validateUnique($attribute, $value, $parameters)
{
$this->requireParameterCount(1, $parameters, 'unique');
[$connection, $table] = $this->parseTable($parameters[0]);
// The second parameter position holds the name of the column that needs to
// be verified as unique. If this parameter isn't specified we will just
// assume that this column to be verified shares the attribute's name.
$column = $this->getQueryColumn($parameters, $attribute);
[$idColumn, $id] = [null, null];
if (isset($parameters[2])) {
[$idColumn, $id] = $this->getUniqueIds($parameters);
if (! is_null($id)) {
$id = stripslashes($id);
}
}
// The presence verifier is responsible for counting rows within this store
// mechanism which might be a relational database or any other permanent
// data store like Redis, etc. We will use it to determine uniqueness.
$verifier = $this->getPresenceVerifierFor($connection);
$extra = $this->getUniqueExtra($parameters);
if ($this->currentRule instanceof Unique) {
$extra = array_merge($extra, $this->currentRule->queryCallbacks());
}
return $verifier->getCount(
$table, $column, $value, $id, $idColumn, $extra
) == 0;
} | php | public function validateUnique($attribute, $value, $parameters)
{
$this->requireParameterCount(1, $parameters, 'unique');
[$connection, $table] = $this->parseTable($parameters[0]);
// The second parameter position holds the name of the column that needs to
// be verified as unique. If this parameter isn't specified we will just
// assume that this column to be verified shares the attribute's name.
$column = $this->getQueryColumn($parameters, $attribute);
[$idColumn, $id] = [null, null];
if (isset($parameters[2])) {
[$idColumn, $id] = $this->getUniqueIds($parameters);
if (! is_null($id)) {
$id = stripslashes($id);
}
}
// The presence verifier is responsible for counting rows within this store
// mechanism which might be a relational database or any other permanent
// data store like Redis, etc. We will use it to determine uniqueness.
$verifier = $this->getPresenceVerifierFor($connection);
$extra = $this->getUniqueExtra($parameters);
if ($this->currentRule instanceof Unique) {
$extra = array_merge($extra, $this->currentRule->queryCallbacks());
}
return $verifier->getCount(
$table, $column, $value, $id, $idColumn, $extra
) == 0;
} | [
"public",
"function",
"validateUnique",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"requireParameterCount",
"(",
"1",
",",
"$",
"parameters",
",",
"'unique'",
")",
";",
"[",
"$",
"connection",
",",
"$",... | Validate the uniqueness of an attribute value on a given database table.
If a database column is not specified, the attribute will be used.
@param string $attribute
@param mixed $value
@param array $parameters
@return bool | [
"Validate",
"the",
"uniqueness",
"of",
"an",
"attribute",
"value",
"on",
"a",
"given",
"database",
"table",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L699-L734 | train | Validate that the attribute is unique | [
30522,
2270,
3853,
9398,
3686,
19496,
4226,
1006,
1002,
17961,
1010,
1002,
3643,
1010,
1002,
11709,
1007,
1063,
1002,
2023,
1011,
1028,
5478,
28689,
22828,
3597,
16671,
1006,
1015,
1010,
1002,
11709,
1010,
1005,
4310,
1005,
1007,
1025,
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... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Compiler/ResolveHotPathPass.php | ResolveHotPathPass.processValue | protected function processValue($value, $isRoot = false)
{
if ($value instanceof ArgumentInterface) {
return $value;
}
if ($value instanceof Definition && $isRoot && (isset($this->resolvedIds[$this->currentId]) || !$value->hasTag($this->tagName) || $value->isDeprecated())) {
return $value->isDeprecated() ? $value->clearTag($this->tagName) : $value;
}
if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->has($id = (string) $value)) {
$definition = $this->container->findDefinition($id);
if (!$definition->hasTag($this->tagName) && !$definition->isDeprecated()) {
$this->resolvedIds[$id] = true;
$definition->addTag($this->tagName);
parent::processValue($definition, false);
}
return $value;
}
return parent::processValue($value, $isRoot);
} | php | protected function processValue($value, $isRoot = false)
{
if ($value instanceof ArgumentInterface) {
return $value;
}
if ($value instanceof Definition && $isRoot && (isset($this->resolvedIds[$this->currentId]) || !$value->hasTag($this->tagName) || $value->isDeprecated())) {
return $value->isDeprecated() ? $value->clearTag($this->tagName) : $value;
}
if ($value instanceof Reference && ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE !== $value->getInvalidBehavior() && $this->container->has($id = (string) $value)) {
$definition = $this->container->findDefinition($id);
if (!$definition->hasTag($this->tagName) && !$definition->isDeprecated()) {
$this->resolvedIds[$id] = true;
$definition->addTag($this->tagName);
parent::processValue($definition, false);
}
return $value;
}
return parent::processValue($value, $isRoot);
} | [
"protected",
"function",
"processValue",
"(",
"$",
"value",
",",
"$",
"isRoot",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"ArgumentInterface",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"Defini... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/ResolveHotPathPass.php#L50-L70 | train | Process value. | [
30522,
5123,
3853,
2832,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
2003,
3217,
4140,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
3643,
6013,
11253,
6685,
18447,
2121,
12172,
1007,
1063,
2709,
1002,
3643,
1025,
1065,
2065,
1006,
1002,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Common.php | Common.sanitizeString | private static function sanitizeString($value)
{
// $_GET and $_REQUEST already urldecode()'d
// decode
// note: before php 5.2.7, htmlspecialchars() double encodes &#x hex items
$value = html_entity_decode($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
$value = self::sanitizeNullBytes($value);
// escape
$tmp = @htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
// note: php 5.2.5 and above, htmlspecialchars is destructive if input is not UTF-8
if ($value != '' && $tmp == '') {
// convert and escape
$value = utf8_encode($value);
$tmp = htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
return $tmp;
}
return $tmp;
} | php | private static function sanitizeString($value)
{
// $_GET and $_REQUEST already urldecode()'d
// decode
// note: before php 5.2.7, htmlspecialchars() double encodes &#x hex items
$value = html_entity_decode($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
$value = self::sanitizeNullBytes($value);
// escape
$tmp = @htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
// note: php 5.2.5 and above, htmlspecialchars is destructive if input is not UTF-8
if ($value != '' && $tmp == '') {
// convert and escape
$value = utf8_encode($value);
$tmp = htmlspecialchars($value, self::HTML_ENCODING_QUOTE_STYLE, 'UTF-8');
return $tmp;
}
return $tmp;
} | [
"private",
"static",
"function",
"sanitizeString",
"(",
"$",
"value",
")",
"{",
"// $_GET and $_REQUEST already urldecode()'d",
"// decode",
"// note: before php 5.2.7, htmlspecialchars() double encodes &#x hex items",
"$",
"value",
"=",
"html_entity_decode",
"(",
"$",
"value",
... | Sanitize a single input value
@param $value
@return string | [
"Sanitize",
"a",
"single",
"input",
"value"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Common.php#L366-L386 | train | Sanitize a string | [
30522,
2797,
10763,
3853,
2624,
25090,
11254,
18886,
3070,
1006,
1002,
3643,
1007,
1063,
1013,
1013,
1002,
1035,
2131,
1998,
1002,
1035,
5227,
2525,
24471,
17920,
16044,
1006,
1007,
1005,
30524,
1007,
3313,
4372,
23237,
1004,
1001,
1060,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Factory.php | Factory.of | public function of($class, $name = 'default')
{
return new FactoryBuilder(
$class, $name, $this->definitions, $this->states,
$this->afterMaking, $this->afterCreating, $this->faker
);
} | php | public function of($class, $name = 'default')
{
return new FactoryBuilder(
$class, $name, $this->definitions, $this->states,
$this->afterMaking, $this->afterCreating, $this->faker
);
} | [
"public",
"function",
"of",
"(",
"$",
"class",
",",
"$",
"name",
"=",
"'default'",
")",
"{",
"return",
"new",
"FactoryBuilder",
"(",
"$",
"class",
",",
"$",
"name",
",",
"$",
"this",
"->",
"definitions",
",",
"$",
"this",
"->",
"states",
",",
"$",
... | Create a builder for the given model.
@param string $class
@param string $name
@return \Illuminate\Database\Eloquent\FactoryBuilder | [
"Create",
"a",
"builder",
"for",
"the",
"given",
"model",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Factory.php#L255-L261 | train | Create a new factory builder for the given class and name | [
30522,
2270,
3853,
1997,
1006,
1002,
2465,
1010,
1002,
2171,
1027,
1005,
12398,
1005,
1007,
1063,
2709,
2047,
4713,
8569,
23891,
2099,
1006,
1002,
2465,
1010,
1002,
2171,
1010,
1002,
2023,
1011,
1028,
15182,
1010,
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 | libs/Zend/Validate/File/FilesSize.php | Zend_Validate_File_FilesSize.isValid | public function isValid($value, $file = null)
{
// require_once 'Zend/Loader.php';
if (is_string($value)) {
$value = array($value);
}
$min = $this->getMin(true);
$max = $this->getMax(true);
$size = $this->_getSize();
foreach ($value as $files) {
// Is file readable ?
if (!Zend_Loader::isReadable($files)) {
$this->_throw($file, self::NOT_READABLE);
continue;
}
if (!isset($this->_files[$files])) {
$this->_files[$files] = $files;
} else {
// file already counted... do not count twice
continue;
}
// limited to 2GB files
$size += @filesize($files);
$this->_size = $size;
if (($max !== null) && ($max < $size)) {
if ($this->useByteString()) {
$this->_max = $this->_toByteString($max);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_BIG);
$this->_max = $max;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_BIG);
}
}
}
// Check that aggregate files are >= minimum size
if (($min !== null) && ($size < $min)) {
if ($this->useByteString()) {
$this->_min = $this->_toByteString($min);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_SMALL);
$this->_min = $min;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_SMALL);
}
}
if (count($this->_messages) > 0) {
return false;
}
return true;
} | php | public function isValid($value, $file = null)
{
// require_once 'Zend/Loader.php';
if (is_string($value)) {
$value = array($value);
}
$min = $this->getMin(true);
$max = $this->getMax(true);
$size = $this->_getSize();
foreach ($value as $files) {
// Is file readable ?
if (!Zend_Loader::isReadable($files)) {
$this->_throw($file, self::NOT_READABLE);
continue;
}
if (!isset($this->_files[$files])) {
$this->_files[$files] = $files;
} else {
// file already counted... do not count twice
continue;
}
// limited to 2GB files
$size += @filesize($files);
$this->_size = $size;
if (($max !== null) && ($max < $size)) {
if ($this->useByteString()) {
$this->_max = $this->_toByteString($max);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_BIG);
$this->_max = $max;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_BIG);
}
}
}
// Check that aggregate files are >= minimum size
if (($min !== null) && ($size < $min)) {
if ($this->useByteString()) {
$this->_min = $this->_toByteString($min);
$this->_size = $this->_toByteString($size);
$this->_throw($file, self::TOO_SMALL);
$this->_min = $min;
$this->_size = $size;
} else {
$this->_throw($file, self::TOO_SMALL);
}
}
if (count($this->_messages) > 0) {
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
",",
"$",
"file",
"=",
"null",
")",
"{",
"// require_once 'Zend/Loader.php';",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array",
"(",
"$",
"value",
")",
";",
"}",
... | Defined by Zend_Validate_Interface
Returns true if and only if the disk usage of all files is at least min and
not bigger than max (when max is not null).
@param string|array $value Real file to check for size
@param array $file File data from Zend_File_Transfer
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/File/FilesSize.php#L105-L163 | train | Check if the aggregate file is valid | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
3643,
1010,
1002,
5371,
1027,
19701,
1007,
1063,
1013,
1013,
5478,
1035,
2320,
1005,
16729,
2094,
1013,
7170,
2121,
1012,
25718,
1005,
1025,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.prepareVars | protected function prepareVars()
{
$this->defineFormFields();
$this->applyFiltersFromModel();
$this->vars['sessionKey'] = $this->getSessionKey();
$this->vars['outsideTabs'] = $this->allTabs->outside;
$this->vars['primaryTabs'] = $this->allTabs->primary;
$this->vars['secondaryTabs'] = $this->allTabs->secondary;
} | php | protected function prepareVars()
{
$this->defineFormFields();
$this->applyFiltersFromModel();
$this->vars['sessionKey'] = $this->getSessionKey();
$this->vars['outsideTabs'] = $this->allTabs->outside;
$this->vars['primaryTabs'] = $this->allTabs->primary;
$this->vars['secondaryTabs'] = $this->allTabs->secondary;
} | [
"protected",
"function",
"prepareVars",
"(",
")",
"{",
"$",
"this",
"->",
"defineFormFields",
"(",
")",
";",
"$",
"this",
"->",
"applyFiltersFromModel",
"(",
")",
";",
"$",
"this",
"->",
"vars",
"[",
"'sessionKey'",
"]",
"=",
"$",
"this",
"->",
"getSessi... | Prepares the form data
@return void | [
"Prepares",
"the",
"form",
"data"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L305-L313 | train | Prepares the form fields and filters | [
30522,
5123,
3853,
7374,
10755,
2015,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
9375,
14192,
15155,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
6611,
8873,
21928,
22747,
21716,
5302,
9247,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
13075,
2015... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.isSelected | public function isSelected($value = true)
{
if ($this->value === null) {
return false;
}
return (string) $value === (string) $this->value;
} | php | public function isSelected($value = true)
{
if ($this->value === null) {
return false;
}
return (string) $value === (string) $this->value;
} | [
"public",
"function",
"isSelected",
"(",
"$",
"value",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"string",
")",
"$",
"value",
"===",
"(",
"string",
")",
"$",
... | Determine if the provided value matches this field's value.
@param string $value
@return bool | [
"Determine",
"if",
"the",
"provided",
"value",
"matches",
"this",
"field",
"s",
"value",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L367-L374 | train | Returns true if the value of the field is the same as the currently selected value. | [
30522,
2270,
3853,
26354,
12260,
10985,
1006,
1002,
3643,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3643,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
6270,
1025,
1065,
2709,
1006,
5164,
1007,
1002,
3643,
1027,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/API.php | API.getAvailableCapabilities | public function getAvailableCapabilities()
{
Piwik::checkUserHasSomeAdminAccess();
$response = array();
foreach ($this->capabilityProvider->getAllCapabilities() as $capability) {
$response[] = array(
'id' => $capability->getId(),
'name' => $capability->getName(),
'description' => $capability->getDescription(),
'helpUrl' => $capability->getHelpUrl(),
'includedInRoles' => $capability->getIncludedInRoles(),
'category' => $capability->getCategory(),
);
}
return $response;
} | php | public function getAvailableCapabilities()
{
Piwik::checkUserHasSomeAdminAccess();
$response = array();
foreach ($this->capabilityProvider->getAllCapabilities() as $capability) {
$response[] = array(
'id' => $capability->getId(),
'name' => $capability->getName(),
'description' => $capability->getDescription(),
'helpUrl' => $capability->getHelpUrl(),
'includedInRoles' => $capability->getIncludedInRoles(),
'category' => $capability->getCategory(),
);
}
return $response;
} | [
"public",
"function",
"getAvailableCapabilities",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeAdminAccess",
"(",
")",
";",
"$",
"response",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"capabilityProvider",
"->",
"getAllCapabilities",
"(",
... | Get the list of all available capabilities.
@return array[] Returns an array containing information about each capability | [
"Get",
"the",
"list",
"of",
"all",
"available",
"capabilities",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/API.php#L160-L178 | train | Returns all available capabilities | [
30522,
2270,
3853,
2131,
12462,
11733,
3468,
17695,
28518,
15909,
3111,
1006,
1007,
30524,
8095,
17695,
28518,
15909,
3111,
1006,
1007,
2004,
1002,
10673,
1007,
1063,
1002,
3433,
1031,
1033,
1027,
9140,
1006,
1005,
8909,
1005,
1027,
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... |
matomo-org/matomo | libs/Zend/Db/Statement/Sqlsrv.php | Zend_Db_Statement_Sqlsrv._bindParam | protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
//Db server doesn't support bind by name
return true;
} | php | protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
//Db server doesn't support bind by name
return true;
} | [
"protected",
"function",
"_bindParam",
"(",
"$",
"parameter",
",",
"&",
"$",
"variable",
",",
"$",
"type",
"=",
"null",
",",
"$",
"length",
"=",
"null",
",",
"$",
"options",
"=",
"null",
")",
"{",
"//Db server doesn't support bind by name",
"return",
"true",... | Binds a parameter to the specified variable name.
@param mixed $parameter Name the parameter, either integer or string.
@param mixed $variable Reference to PHP variable containing the value.
@param mixed $type OPTIONAL Datatype of SQL parameter.
@param mixed $length OPTIONAL Length of SQL parameter.
@param mixed $options OPTIONAL Other options.
@return bool
@throws Zend_Db_Statement_Exception | [
"Binds",
"a",
"parameter",
"to",
"the",
"specified",
"variable",
"name",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Sqlsrv.php#L87-L91 | train | Bind param to variable | [
30522,
5123,
3853,
1035,
14187,
28689,
2213,
1006,
1002,
16381,
1010,
1004,
1002,
8023,
1010,
1002,
2828,
1027,
19701,
1010,
1002,
3091,
1027,
19701,
1010,
1002,
7047,
1027,
19701,
1007,
1063,
1013,
1013,
16962,
8241,
2987,
1005,
1056,
2490... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Site.php | Site.setSites | public static function setSites($sites)
{
self::triggerSetSitesEvent($sites);
foreach ($sites as $idsite => $site) {
self::setSiteFromArray($idsite, $site);
}
} | php | public static function setSites($sites)
{
self::triggerSetSitesEvent($sites);
foreach ($sites as $idsite => $site) {
self::setSiteFromArray($idsite, $site);
}
} | [
"public",
"static",
"function",
"setSites",
"(",
"$",
"sites",
")",
"{",
"self",
"::",
"triggerSetSitesEvent",
"(",
"$",
"sites",
")",
";",
"foreach",
"(",
"$",
"sites",
"as",
"$",
"idsite",
"=>",
"$",
"site",
")",
"{",
"self",
"::",
"setSiteFromArray",
... | Sets the cached site data with an array that associates site IDs with
individual site data.
@param array $sites The array of sites data. Indexed by site ID. eg,
array('1' => array('name' => 'Site 1', ...),
'2' => array('name' => 'Site 2', ...))` | [
"Sets",
"the",
"cached",
"site",
"data",
"with",
"an",
"array",
"that",
"associates",
"site",
"IDs",
"with",
"individual",
"site",
"data",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Site.php#L109-L116 | train | setSites - Set the list of sites | [
30522,
2270,
10763,
3853,
4520,
7616,
1006,
1002,
4573,
1007,
1063,
2969,
1024,
1024,
27099,
8454,
7616,
18697,
3372,
1006,
1002,
4573,
1007,
1025,
18921,
6776,
1006,
1002,
4573,
2004,
1002,
8909,
28032,
2063,
1027,
1028,
1002,
2609,
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... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.DKIM_Sign | public function DKIM_Sign($signHeader)
{
if (!defined('PKCS7_TEXT')) {
if ($this->exceptions) {
throw new Exception($this->lang('extension_missing') . 'openssl');
}
return '';
}
$privKeyStr = !empty($this->DKIM_private_string) ?
$this->DKIM_private_string :
file_get_contents($this->DKIM_private);
if ('' != $this->DKIM_passphrase) {
$privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
} else {
$privKey = openssl_pkey_get_private($privKeyStr);
}
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
openssl_pkey_free($privKey);
return base64_encode($signature);
}
openssl_pkey_free($privKey);
return '';
} | php | public function DKIM_Sign($signHeader)
{
if (!defined('PKCS7_TEXT')) {
if ($this->exceptions) {
throw new Exception($this->lang('extension_missing') . 'openssl');
}
return '';
}
$privKeyStr = !empty($this->DKIM_private_string) ?
$this->DKIM_private_string :
file_get_contents($this->DKIM_private);
if ('' != $this->DKIM_passphrase) {
$privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
} else {
$privKey = openssl_pkey_get_private($privKeyStr);
}
if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
openssl_pkey_free($privKey);
return base64_encode($signature);
}
openssl_pkey_free($privKey);
return '';
} | [
"public",
"function",
"DKIM_Sign",
"(",
"$",
"signHeader",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'PKCS7_TEXT'",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exceptions",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"this",
"->",
"lang",
"("... | Generate a DKIM signature.
@param string $signHeader
@throws Exception
@return string The DKIM signature value | [
"Generate",
"a",
"DKIM",
"signature",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L4220-L4245 | train | DKIM_Sign - Signs a signature header | [
30522,
2270,
3853,
1040,
21138,
1035,
3696,
1006,
1002,
3696,
4974,
2121,
1007,
1063,
2065,
1006,
999,
4225,
1006,
1005,
1052,
2243,
6169,
2581,
1035,
3793,
1005,
1007,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11790,
1007,
1063,
54... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Command/CacheClearCommand.php | CacheClearCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$fs = $this->filesystem;
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$realCacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');
// the old cache dir name must not be longer than the real one to avoid exceeding
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
$fs->remove($oldCacheDir);
if (!is_writable($realCacheDir)) {
throw new RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
}
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$this->cacheClearer->clear($realCacheDir);
// The current event dispatcher is stale, let's not use it anymore
$this->getApplication()->setDispatcher(new EventDispatcher());
$containerFile = (new \ReflectionObject($kernel->getContainer()))->getFileName();
$containerDir = basename(\dirname($containerFile));
// the warmup cache dir name must have the same length as the real one
// to avoid the many problems in serialized resources files
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
if ($output->isVerbose() && $fs->exists($warmupDir)) {
$io->comment('Clearing outdated warmup directory...');
}
$fs->remove($warmupDir);
if ($_SERVER['REQUEST_TIME'] <= filemtime($containerFile) && filemtime($containerFile) <= time()) {
if ($output->isVerbose()) {
$io->comment('Cache is fresh.');
}
if (!$input->getOption('no-warmup') && !$input->getOption('no-optional-warmers')) {
if ($output->isVerbose()) {
$io->comment('Warming up optional cache...');
}
$warmer = $kernel->getContainer()->get('cache_warmer');
// non optional warmers already ran during container compilation
$warmer->enableOnlyOptionalWarmers();
$warmer->warmUp($realCacheDir);
}
} else {
$fs->mkdir($warmupDir);
if (!$input->getOption('no-warmup')) {
if ($output->isVerbose()) {
$io->comment('Warming up cache...');
}
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
}
if (!$fs->exists($warmupDir.'/'.$containerDir)) {
$fs->rename($realCacheDir.'/'.$containerDir, $warmupDir.'/'.$containerDir);
touch($warmupDir.'/'.$containerDir.'.legacy');
}
if ('/' === \DIRECTORY_SEPARATOR && $mounts = @file('/proc/mounts')) {
foreach ($mounts as $mount) {
$mount = \array_slice(explode(' ', $mount), 1, -3);
if (!\in_array(array_pop($mount), ['vboxsf', 'nfs'])) {
continue;
}
$mount = implode(' ', $mount).'/';
if (0 === strpos($realCacheDir, $mount)) {
$io->note('For better performances, you should move the cache and log directories to a non-shared folder of the VM.');
$oldCacheDir = false;
break;
}
}
}
if ($oldCacheDir) {
$fs->rename($realCacheDir, $oldCacheDir);
} else {
$fs->remove($realCacheDir);
}
$fs->rename($warmupDir, $realCacheDir);
if ($output->isVerbose()) {
$io->comment('Removing old cache directory...');
}
try {
$fs->remove($oldCacheDir);
} catch (IOException $e) {
if ($output->isVerbose()) {
$io->warning($e->getMessage());
}
}
}
if ($output->isVerbose()) {
$io->comment('Finished');
}
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$fs = $this->filesystem;
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$realCacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');
// the old cache dir name must not be longer than the real one to avoid exceeding
// the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
$oldCacheDir = substr($realCacheDir, 0, -1).('~' === substr($realCacheDir, -1) ? '+' : '~');
$fs->remove($oldCacheDir);
if (!is_writable($realCacheDir)) {
throw new RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
}
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$this->cacheClearer->clear($realCacheDir);
// The current event dispatcher is stale, let's not use it anymore
$this->getApplication()->setDispatcher(new EventDispatcher());
$containerFile = (new \ReflectionObject($kernel->getContainer()))->getFileName();
$containerDir = basename(\dirname($containerFile));
// the warmup cache dir name must have the same length as the real one
// to avoid the many problems in serialized resources files
$warmupDir = substr($realCacheDir, 0, -1).('_' === substr($realCacheDir, -1) ? '-' : '_');
if ($output->isVerbose() && $fs->exists($warmupDir)) {
$io->comment('Clearing outdated warmup directory...');
}
$fs->remove($warmupDir);
if ($_SERVER['REQUEST_TIME'] <= filemtime($containerFile) && filemtime($containerFile) <= time()) {
if ($output->isVerbose()) {
$io->comment('Cache is fresh.');
}
if (!$input->getOption('no-warmup') && !$input->getOption('no-optional-warmers')) {
if ($output->isVerbose()) {
$io->comment('Warming up optional cache...');
}
$warmer = $kernel->getContainer()->get('cache_warmer');
// non optional warmers already ran during container compilation
$warmer->enableOnlyOptionalWarmers();
$warmer->warmUp($realCacheDir);
}
} else {
$fs->mkdir($warmupDir);
if (!$input->getOption('no-warmup')) {
if ($output->isVerbose()) {
$io->comment('Warming up cache...');
}
$this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
}
if (!$fs->exists($warmupDir.'/'.$containerDir)) {
$fs->rename($realCacheDir.'/'.$containerDir, $warmupDir.'/'.$containerDir);
touch($warmupDir.'/'.$containerDir.'.legacy');
}
if ('/' === \DIRECTORY_SEPARATOR && $mounts = @file('/proc/mounts')) {
foreach ($mounts as $mount) {
$mount = \array_slice(explode(' ', $mount), 1, -3);
if (!\in_array(array_pop($mount), ['vboxsf', 'nfs'])) {
continue;
}
$mount = implode(' ', $mount).'/';
if (0 === strpos($realCacheDir, $mount)) {
$io->note('For better performances, you should move the cache and log directories to a non-shared folder of the VM.');
$oldCacheDir = false;
break;
}
}
}
if ($oldCacheDir) {
$fs->rename($realCacheDir, $oldCacheDir);
} else {
$fs->remove($realCacheDir);
}
$fs->rename($warmupDir, $realCacheDir);
if ($output->isVerbose()) {
$io->comment('Removing old cache directory...');
}
try {
$fs->remove($oldCacheDir);
} catch (IOException $e) {
if ($output->isVerbose()) {
$io->warning($e->getMessage());
}
}
}
if ($output->isVerbose()) {
$io->comment('Finished');
}
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"fs",
"=",
"$",
"this",
"->",
"filesystem",
";",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php#L75-L178 | train | Execute the command | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
1042,
2015,
1027,
1002,
2023,
1011,
1028,
6764,
27268,
6633,
1025,
1002,
22834,
1027,
2047,
25353,
2213,
148... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/UserId/Archiver.php | Archiver.aggregateMultipleReports | public function aggregateMultipleReports()
{
$dataTableRecords = array(self::USERID_ARCHIVE_RECORD);
$columnsAggregationOperation = null;
$this->getProcessor()->aggregateDataTableRecords(
$dataTableRecords,
$this->maximumRowsInDataTableLevelZero,
$this->maximumRowsInDataTableLevelZero,
$columnToSort = 'nb_visits',
$columnsAggregationOperation,
$columnsToRenameAfterAggregation = null,
$countRowsRecursive = array());
} | php | public function aggregateMultipleReports()
{
$dataTableRecords = array(self::USERID_ARCHIVE_RECORD);
$columnsAggregationOperation = null;
$this->getProcessor()->aggregateDataTableRecords(
$dataTableRecords,
$this->maximumRowsInDataTableLevelZero,
$this->maximumRowsInDataTableLevelZero,
$columnToSort = 'nb_visits',
$columnsAggregationOperation,
$columnsToRenameAfterAggregation = null,
$countRowsRecursive = array());
} | [
"public",
"function",
"aggregateMultipleReports",
"(",
")",
"{",
"$",
"dataTableRecords",
"=",
"array",
"(",
"self",
"::",
"USERID_ARCHIVE_RECORD",
")",
";",
"$",
"columnsAggregationOperation",
"=",
"null",
";",
"$",
"this",
"->",
"getProcessor",
"(",
")",
"->",... | Period archiving: simply sums up daily archives | [
"Period",
"archiving",
":",
"simply",
"sums",
"up",
"daily",
"archives"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserId/Archiver.php#L58-L70 | train | Aggregate multiple reports | [
30522,
2270,
3853,
9572,
12274,
7096,
11514,
3917,
13699,
11589,
2015,
1006,
1007,
1063,
1002,
2951,
10880,
2890,
27108,
5104,
1027,
9140,
1006,
2969,
1024,
1024,
5310,
3593,
1035,
8756,
1035,
2501,
1007,
1025,
1002,
7753,
8490,
17603,
1254... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Config/IniFileChain.php | IniFileChain.compareElements | public static function compareElements($elem1, $elem2)
{
if (is_array($elem1)) {
if (is_array($elem2)) {
return strcmp(serialize($elem1), serialize($elem2));
}
return 1;
}
if (is_array($elem2)) {
return -1;
}
if ((string)$elem1 === (string)$elem2) {
return 0;
}
return ((string)$elem1 > (string)$elem2) ? 1 : -1;
} | php | public static function compareElements($elem1, $elem2)
{
if (is_array($elem1)) {
if (is_array($elem2)) {
return strcmp(serialize($elem1), serialize($elem2));
}
return 1;
}
if (is_array($elem2)) {
return -1;
}
if ((string)$elem1 === (string)$elem2) {
return 0;
}
return ((string)$elem1 > (string)$elem2) ? 1 : -1;
} | [
"public",
"static",
"function",
"compareElements",
"(",
"$",
"elem1",
",",
"$",
"elem2",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"elem1",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"elem2",
")",
")",
"{",
"return",
"strcmp",
"(",
"serialize",... | Comparison function
@param mixed $elem1
@param mixed $elem2
@return int; | [
"Comparison",
"function"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config/IniFileChain.php#L314-L333 | train | Compare two elements | [
30522,
2270,
10763,
3853,
12826,
12260,
8163,
1006,
1002,
3449,
6633,
2487,
1010,
1002,
3449,
6633,
2475,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
3449,
6633,
2487,
1007,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Filter.php | Filter.filterActiveOptions | protected function filterActiveOptions(array $activeKeys, array &$availableOptions)
{
$active = [];
foreach ($availableOptions as $id => $option) {
if (!in_array($id, $activeKeys)) {
continue;
}
$active[$id] = $option;
unset($availableOptions[$id]);
}
return $active;
} | php | protected function filterActiveOptions(array $activeKeys, array &$availableOptions)
{
$active = [];
foreach ($availableOptions as $id => $option) {
if (!in_array($id, $activeKeys)) {
continue;
}
$active[$id] = $option;
unset($availableOptions[$id]);
}
return $active;
} | [
"protected",
"function",
"filterActiveOptions",
"(",
"array",
"$",
"activeKeys",
",",
"array",
"&",
"$",
"availableOptions",
")",
"{",
"$",
"active",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"availableOptions",
"as",
"$",
"id",
"=>",
"$",
"option",
")",
... | Removes any already selected options from the available options, returns
a newly built array.
@param array $activeKeys
@param array $availableOptions
@return array | [
"Removes",
"any",
"already",
"selected",
"options",
"from",
"the",
"available",
"options",
"returns",
"a",
"newly",
"built",
"array",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L351-L364 | train | Filter active options | [
30522,
5123,
3853,
11307,
19620,
7361,
9285,
1006,
9140,
1002,
3161,
14839,
2015,
1010,
9140,
1004,
1002,
2800,
7361,
9285,
1007,
1063,
1002,
3161,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2800,
7361,
9285,
2004,
1002,
8909,
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/DependencyInjection/Definition.php | Definition.addMethodCall | public function addMethodCall($method, array $arguments = []/*, bool $returnsClone = false*/)
{
if (empty($method)) {
throw new InvalidArgumentException('Method name cannot be empty.');
}
$this->calls[] = 2 < \func_num_args() && \func_get_arg(2) ? [$method, $arguments, true] : [$method, $arguments];
return $this;
} | php | public function addMethodCall($method, array $arguments = []/*, bool $returnsClone = false*/)
{
if (empty($method)) {
throw new InvalidArgumentException('Method name cannot be empty.');
}
$this->calls[] = 2 < \func_num_args() && \func_get_arg(2) ? [$method, $arguments, true] : [$method, $arguments];
return $this;
} | [
"public",
"function",
"addMethodCall",
"(",
"$",
"method",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
"/*, bool $returnsClone = false*/",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'... | Adds a method to call after service initialization.
@param string $method The method name to call
@param array $arguments An array of arguments to pass to the method call
@param bool $returnsClone Whether the call returns the service instance or not
@return $this
@throws InvalidArgumentException on empty $method param | [
"Adds",
"a",
"method",
"to",
"call",
"after",
"service",
"initialization",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Definition.php#L352-L360 | train | Adds a method to the stack | [
30522,
2270,
3853,
5587,
11368,
6806,
16409,
8095,
1006,
1002,
4118,
1010,
9140,
1002,
9918,
1027,
1031,
1033,
1013,
1008,
1010,
22017,
2140,
1002,
5651,
20464,
5643,
1027,
6270,
1008,
1013,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
4118,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/RedirectMiddleware.php | RedirectMiddleware.redirectUri | private function redirectUri(
RequestInterface $request,
ResponseInterface $response,
array $protocols
) {
$location = Psr7\UriResolver::resolve(
$request->getUri(),
new Psr7\Uri($response->getHeaderLine('Location'))
);
// Ensure that the redirect URI is allowed based on the protocols.
if (!in_array($location->getScheme(), $protocols)) {
throw new BadResponseException(
sprintf(
'Redirect URI, %s, does not use one of the allowed redirect protocols: %s',
$location,
implode(', ', $protocols)
),
$request,
$response
);
}
return $location;
} | php | private function redirectUri(
RequestInterface $request,
ResponseInterface $response,
array $protocols
) {
$location = Psr7\UriResolver::resolve(
$request->getUri(),
new Psr7\Uri($response->getHeaderLine('Location'))
);
// Ensure that the redirect URI is allowed based on the protocols.
if (!in_array($location->getScheme(), $protocols)) {
throw new BadResponseException(
sprintf(
'Redirect URI, %s, does not use one of the allowed redirect protocols: %s',
$location,
implode(', ', $protocols)
),
$request,
$response
);
}
return $location;
} | [
"private",
"function",
"redirectUri",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"array",
"$",
"protocols",
")",
"{",
"$",
"location",
"=",
"Psr7",
"\\",
"UriResolver",
"::",
"resolve",
"(",
"$",
"request",
"->",
... | Set the appropriate URL on the request based on the location header
@param RequestInterface $request
@param ResponseInterface $response
@param array $protocols
@return UriInterface | [
"Set",
"the",
"appropriate",
"URL",
"on",
"the",
"request",
"based",
"on",
"the",
"location",
"header"
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/RedirectMiddleware.php#L212-L236 | train | Resolve redirect URI | [
30522,
2797,
3853,
2417,
7442,
6593,
9496,
1006,
5227,
18447,
2121,
12172,
1002,
5227,
1010,
3433,
18447,
2121,
12172,
1002,
3433,
1010,
9140,
1002,
16744,
1007,
1063,
1002,
3295,
1027,
8827,
2099,
2581,
1032,
24471,
7442,
19454,
6299,
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/Messenger/Transport/AmqpExt/AmqpTransport.php | AmqpTransport.ack | public function ack(Envelope $envelope): void
{
($this->receiver ?? $this->getReceiver())->ack($envelope);
} | php | public function ack(Envelope $envelope): void
{
($this->receiver ?? $this->getReceiver())->ack($envelope);
} | [
"public",
"function",
"ack",
"(",
"Envelope",
"$",
"envelope",
")",
":",
"void",
"{",
"(",
"$",
"this",
"->",
"receiver",
"??",
"$",
"this",
"->",
"getReceiver",
"(",
")",
")",
"->",
"ack",
"(",
"$",
"envelope",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpTransport.php#L50-L53 | train | Acknowledge an incoming message | [
30522,
2270,
3853,
9353,
2243,
1006,
11255,
1002,
11255,
1007,
1024,
11675,
1063,
1006,
1002,
2023,
1011,
1028,
8393,
1029,
1029,
1002,
2023,
1011,
1028,
2131,
2890,
3401,
16402,
1006,
1007,
1007,
1011,
1028,
9353,
2243,
1006,
1002,
11255,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Widgets/Form.php | Form.formatAttribute | public function formatAttribute($attributes = [])
{
$attributes = $attributes ?: $this->attributes;
if ($this->hasFile()) {
$attributes['enctype'] = 'multipart/form-data';
}
$html = [];
foreach ($attributes as $key => $val) {
$html[] = "$key=\"$val\"";
}
return implode(' ', $html) ?: '';
} | php | public function formatAttribute($attributes = [])
{
$attributes = $attributes ?: $this->attributes;
if ($this->hasFile()) {
$attributes['enctype'] = 'multipart/form-data';
}
$html = [];
foreach ($attributes as $key => $val) {
$html[] = "$key=\"$val\"";
}
return implode(' ', $html) ?: '';
} | [
"public",
"function",
"formatAttribute",
"(",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"=",
"$",
"attributes",
"?",
":",
"$",
"this",
"->",
"attributes",
";",
"if",
"(",
"$",
"this",
"->",
"hasFile",
"(",
")",
")",
"{",
"$",
"... | Format form attributes form array to html.
@param array $attributes
@return string | [
"Format",
"form",
"attributes",
"form",
"array",
"to",
"html",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Widgets/Form.php#L285-L299 | train | Formats the attributes for the form | [
30522,
2270,
3853,
4289,
19321,
3089,
8569,
2618,
1006,
1002,
12332,
1027,
1031,
1033,
1007,
1063,
1002,
12332,
1027,
1002,
12332,
1029,
1024,
1002,
2023,
1011,
1028,
12332,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
2038,
8873,
2571,
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... |
symfony/symfony | src/Symfony/Component/Lock/Factory.php | Factory.createLock | public function createLock($resource, $ttl = 300.0, $autoRelease = true)
{
$lock = new Lock(new Key($resource), $this->store, $ttl, $autoRelease);
$lock->setLogger($this->logger);
return $lock;
} | php | public function createLock($resource, $ttl = 300.0, $autoRelease = true)
{
$lock = new Lock(new Key($resource), $this->store, $ttl, $autoRelease);
$lock->setLogger($this->logger);
return $lock;
} | [
"public",
"function",
"createLock",
"(",
"$",
"resource",
",",
"$",
"ttl",
"=",
"300.0",
",",
"$",
"autoRelease",
"=",
"true",
")",
"{",
"$",
"lock",
"=",
"new",
"Lock",
"(",
"new",
"Key",
"(",
"$",
"resource",
")",
",",
"$",
"this",
"->",
"store",... | Creates a lock for the given resource.
@param string $resource The resource to lock
@param float|null $ttl Maximum expected lock duration in seconds
@param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
@return Lock | [
"Creates",
"a",
"lock",
"for",
"the",
"given",
"resource",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Factory.php#L45-L51 | train | Create a Lock object for the given resource | [
30522,
2270,
3853,
3443,
7878,
1006,
1002,
7692,
1010,
1002,
23746,
2140,
1027,
3998,
1012,
1014,
1010,
1002,
8285,
16570,
19500,
1027,
2995,
1007,
1063,
1002,
5843,
1027,
2047,
5843,
1006,
2047,
3145,
1006,
1002,
7692,
1007,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Frontend/Output.php | Zend_Cache_Frontend_Output.start | public function start($id, $doNotTestCacheValidity = false, $echoData = true)
{
$data = $this->load($id, $doNotTestCacheValidity);
if ($data !== false) {
if ( $echoData ) {
echo($data);
return true;
} else {
return $data;
}
}
ob_start();
ob_implicit_flush(false);
$this->_idStack[] = $id;
return false;
} | php | public function start($id, $doNotTestCacheValidity = false, $echoData = true)
{
$data = $this->load($id, $doNotTestCacheValidity);
if ($data !== false) {
if ( $echoData ) {
echo($data);
return true;
} else {
return $data;
}
}
ob_start();
ob_implicit_flush(false);
$this->_idStack[] = $id;
return false;
} | [
"public",
"function",
"start",
"(",
"$",
"id",
",",
"$",
"doNotTestCacheValidity",
"=",
"false",
",",
"$",
"echoData",
"=",
"true",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"load",
"(",
"$",
"id",
",",
"$",
"doNotTestCacheValidity",
")",
";",
"... | Start the cache
@param string $id Cache id
@param boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested
@param boolean $echoData If set to true, datas are sent to the browser if the cache is hit (simpy returned else)
@return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas) | [
"Start",
"the",
"cache"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Output.php#L61-L76 | train | Start the language | [
30522,
2270,
3853,
2707,
1006,
1002,
8909,
1010,
1002,
2123,
28495,
3367,
3540,
16179,
11475,
25469,
1027,
6270,
1010,
1002,
9052,
2850,
2696,
1027,
2995,
1007,
1063,
1002,
2951,
1027,
1002,
2023,
1011,
1028,
7170,
1006,
1002,
8909,
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... |
octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalVarDump | protected function evalVarDump($variable)
{
$dumper = new HtmlDumper;
$cloner = new VarCloner;
$output = '<div style="display:none">';
$output .= $dumper->dump($cloner->cloneVar($variable), true);
$output .= '</div>';
return $output;
} | php | protected function evalVarDump($variable)
{
$dumper = new HtmlDumper;
$cloner = new VarCloner;
$output = '<div style="display:none">';
$output .= $dumper->dump($cloner->cloneVar($variable), true);
$output .= '</div>';
return $output;
} | [
"protected",
"function",
"evalVarDump",
"(",
"$",
"variable",
")",
"{",
"$",
"dumper",
"=",
"new",
"HtmlDumper",
";",
"$",
"cloner",
"=",
"new",
"VarCloner",
";",
"$",
"output",
"=",
"'<div style=\"display:none\">'",
";",
"$",
"output",
".=",
"$",
"dumper",
... | Dumps a variable using HTML Dumper, wrapped in a hidden DIV element.
@param mixed $variable
@return string | [
"Dumps",
"a",
"variable",
"using",
"HTML",
"Dumper",
"wrapped",
"in",
"a",
"hidden",
"DIV",
"element",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L240-L250 | train | Dump a variable | [
30522,
5123,
3853,
9345,
22144,
4103,
24237,
1006,
1002,
8023,
1007,
1063,
1002,
15653,
2121,
1027,
2047,
16129,
8566,
8737,
2121,
1025,
1002,
17598,
2099,
1027,
2047,
13075,
20464,
5643,
2099,
1025,
1002,
6434,
1027,
1005,
1026,
4487,
2615... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/Handler/CurlMultiHandler.php | CurlMultiHandler.cancel | private function cancel($id)
{
// Cannot cancel if it has been processed.
if (!isset($this->handles[$id])) {
return false;
}
$handle = $this->handles[$id]['easy']->handle;
unset($this->delays[$id], $this->handles[$id]);
curl_multi_remove_handle($this->_mh, $handle);
curl_close($handle);
return true;
} | php | private function cancel($id)
{
// Cannot cancel if it has been processed.
if (!isset($this->handles[$id])) {
return false;
}
$handle = $this->handles[$id]['easy']->handle;
unset($this->delays[$id], $this->handles[$id]);
curl_multi_remove_handle($this->_mh, $handle);
curl_close($handle);
return true;
} | [
"private",
"function",
"cancel",
"(",
"$",
"id",
")",
"{",
"// Cannot cancel if it has been processed.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"handles",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"handle",
"=",
"$... | Cancels a handle from sending and removes references to it.
@param int $id Handle ID to cancel and remove.
@return bool True on success, false on failure. | [
"Cancels",
"a",
"handle",
"from",
"sending",
"and",
"removes",
"references",
"to",
"it",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Handler/CurlMultiHandler.php#L154-L167 | train | Cancels a delay | [
30522,
2797,
3853,
17542,
1006,
1002,
8909,
1007,
1063,
1013,
1013,
3685,
17542,
2065,
2009,
2038,
2042,
13995,
1012,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
16024,
1031,
1002,
8909,
1033,
1007,
1007,
1063,
2709,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | Connection/AsyncTcpConnection.php | AsyncTcpConnection.reconnect | public function reconnect($after = 0)
{
$this->_status = self::STATUS_INITIAL;
static::$connections[$this->_id] = $this;
if ($this->_reconnectTimer) {
Timer::del($this->_reconnectTimer);
}
if ($after > 0) {
$this->_reconnectTimer = Timer::add($after, array($this, 'connect'), null, false);
return;
}
$this->connect();
} | php | public function reconnect($after = 0)
{
$this->_status = self::STATUS_INITIAL;
static::$connections[$this->_id] = $this;
if ($this->_reconnectTimer) {
Timer::del($this->_reconnectTimer);
}
if ($after > 0) {
$this->_reconnectTimer = Timer::add($after, array($this, 'connect'), null, false);
return;
}
$this->connect();
} | [
"public",
"function",
"reconnect",
"(",
"$",
"after",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"_status",
"=",
"self",
"::",
"STATUS_INITIAL",
";",
"static",
"::",
"$",
"connections",
"[",
"$",
"this",
"->",
"_id",
"]",
"=",
"$",
"this",
";",
"if",
"... | Reconnect.
@param int $after
@return void | [
"Reconnect",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/AsyncTcpConnection.php#L216-L228 | train | Reconnects to the current session | [
30522,
2270,
3853,
28667,
18256,
6593,
1006,
1002,
2044,
1027,
1014,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
3570,
1027,
2969,
1024,
1024,
3570,
1035,
3988,
1025,
10763,
1024,
1024,
1002,
7264,
1031,
1002,
2023,
1011,
1028,
1035,
8909,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/QueueServiceProvider.php | QueueServiceProvider.registerManager | protected function registerManager()
{
$this->app->singleton('queue', function ($app) {
// Once we have an instance of the queue manager, we will register the various
// resolvers for the queue connectors. These connectors are responsible for
// creating the classes that accept queue configs and instantiate queues.
return tap(new QueueManager($app), function ($manager) {
$this->registerConnectors($manager);
});
});
} | php | protected function registerManager()
{
$this->app->singleton('queue', function ($app) {
// Once we have an instance of the queue manager, we will register the various
// resolvers for the queue connectors. These connectors are responsible for
// creating the classes that accept queue configs and instantiate queues.
return tap(new QueueManager($app), function ($manager) {
$this->registerConnectors($manager);
});
});
} | [
"protected",
"function",
"registerManager",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'queue'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"// Once we have an instance of the queue manager, we will register the various",
"// resolvers for the queu... | Register the queue manager.
@return void | [
"Register",
"the",
"queue",
"manager",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/QueueServiceProvider.php#L41-L51 | train | Register the queue manager. | [
30522,
5123,
3853,
30524,
1997,
1996,
24240,
3208,
1010,
2057,
2097,
4236,
1996,
2536,
1013,
1013,
10663,
2869,
2005,
1996,
24240,
19400,
2015,
1012,
2122,
19400,
2015,
2024,
3625,
2005,
1013,
1013,
4526,
1996,
4280,
2008,
5138,
24240,
9530... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ChoiceList/Loader/IntlCallbackChoiceLoader.php | IntlCallbackChoiceLoader.loadValuesForChoices | public function loadValuesForChoices(array $choices, $value = null)
{
// Optimize
$choices = array_filter($choices);
if (empty($choices)) {
return [];
}
// If no callable is set, choices are the same as values
if (null === $value) {
return $choices;
}
return $this->loadChoiceList($value)->getValuesForChoices($choices);
} | php | public function loadValuesForChoices(array $choices, $value = null)
{
// Optimize
$choices = array_filter($choices);
if (empty($choices)) {
return [];
}
// If no callable is set, choices are the same as values
if (null === $value) {
return $choices;
}
return $this->loadChoiceList($value)->getValuesForChoices($choices);
} | [
"public",
"function",
"loadValuesForChoices",
"(",
"array",
"$",
"choices",
",",
"$",
"value",
"=",
"null",
")",
"{",
"// Optimize",
"$",
"choices",
"=",
"array_filter",
"(",
"$",
"choices",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"choices",
")",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/ChoiceList/Loader/IntlCallbackChoiceLoader.php#L39-L53 | train | Load values for choices | [
30522,
2270,
3853,
7170,
10175,
15808,
29278,
9905,
23522,
1006,
9140,
1002,
9804,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
1013,
1013,
23569,
27605,
4371,
1002,
9804,
1027,
9140,
1035,
11307,
1006,
1002,
9804,
1007,
1025,
2065,
1006,
406... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Cookie/Middleware/EncryptCookies.php | EncryptCookies.duplicate | protected function duplicate(Cookie $cookie, $value)
{
return new Cookie(
$cookie->getName(), $value, $cookie->getExpiresTime(),
$cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(),
$cookie->isHttpOnly(), $cookie->isRaw(), $cookie->getSameSite()
);
} | php | protected function duplicate(Cookie $cookie, $value)
{
return new Cookie(
$cookie->getName(), $value, $cookie->getExpiresTime(),
$cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(),
$cookie->isHttpOnly(), $cookie->isRaw(), $cookie->getSameSite()
);
} | [
"protected",
"function",
"duplicate",
"(",
"Cookie",
"$",
"cookie",
",",
"$",
"value",
")",
"{",
"return",
"new",
"Cookie",
"(",
"$",
"cookie",
"->",
"getName",
"(",
")",
",",
"$",
"value",
",",
"$",
"cookie",
"->",
"getExpiresTime",
"(",
")",
",",
"... | Duplicate a cookie with a new value.
@param \Symfony\Component\HttpFoundation\Cookie $cookie
@param mixed $value
@return \Symfony\Component\HttpFoundation\Cookie | [
"Duplicate",
"a",
"cookie",
"with",
"a",
"new",
"value",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cookie/Middleware/EncryptCookies.php#L153-L160 | train | Duplicate a cookie | [
30522,
5123,
3853,
24473,
1006,
17387,
1002,
17387,
1010,
1002,
3643,
1007,
1063,
2709,
2047,
17387,
1006,
1002,
17387,
1011,
1028,
2131,
18442,
1006,
1007,
1010,
1002,
3643,
1010,
1002,
17387,
1011,
1028,
2131,
30524,
17387,
1011,
1028,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Mailable.php | Mailable.setAddress | protected function setAddress($address, $name = null, $property = 'to')
{
foreach ($this->addressesToArray($address, $name) as $recipient) {
$recipient = $this->normalizeRecipient($recipient);
$this->{$property}[] = [
'name' => $recipient->name ?? null,
'address' => $recipient->email,
];
}
return $this;
} | php | protected function setAddress($address, $name = null, $property = 'to')
{
foreach ($this->addressesToArray($address, $name) as $recipient) {
$recipient = $this->normalizeRecipient($recipient);
$this->{$property}[] = [
'name' => $recipient->name ?? null,
'address' => $recipient->email,
];
}
return $this;
} | [
"protected",
"function",
"setAddress",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
",",
"$",
"property",
"=",
"'to'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"addressesToArray",
"(",
"$",
"address",
",",
"$",
"name",
")",
"as",
"$",
"rec... | Set the recipients of the message.
All recipients are stored internally as [['name' => ?, 'address' => ?]]
@param object|array|string $address
@param string|null $name
@param string $property
@return $this | [
"Set",
"the",
"recipients",
"of",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailable.php#L577-L589 | train | Set To Address | [
30522,
5123,
3853,
2275,
4215,
16200,
4757,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
19701,
1010,
1002,
3200,
1027,
1005,
2000,
1005,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
11596,
3406,
2906,
30524,
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... |
octobercms/october | modules/system/behaviors/SettingsModel.php | SettingsModel.beforeModelSave | public function beforeModelSave()
{
$this->model->item = $this->recordCode;
if ($this->fieldValues) {
$this->model->value = $this->fieldValues;
}
} | php | public function beforeModelSave()
{
$this->model->item = $this->recordCode;
if ($this->fieldValues) {
$this->model->value = $this->fieldValues;
}
} | [
"public",
"function",
"beforeModelSave",
"(",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"item",
"=",
"$",
"this",
"->",
"recordCode",
";",
"if",
"(",
"$",
"this",
"->",
"fieldValues",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"value",
"=",
"$",
... | Before the model is saved, ensure the record code is set
and the jsonable field values | [
"Before",
"the",
"model",
"is",
"saved",
"ensure",
"the",
"record",
"code",
"is",
"set",
"and",
"the",
"jsonable",
"field",
"values"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/behaviors/SettingsModel.php#L192-L198 | train | Before Model Save | [
30522,
2270,
3853,
2077,
5302,
9247,
3736,
3726,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2944,
1011,
1028,
8875,
1027,
1002,
2023,
1011,
1028,
2501,
16044,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
2492,
10175,
15808,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.dump | public function dump($variables = null, $caption = null)
{
$this->commentMap = [];
$this->zebra = 1;
$info = [];
if (!is_array($variables)) {
if ($variables instanceof Paginator) {
$variables = $this->paginatorToArray($variables);
}
elseif (is_object($variables)) {
$variables = $this->objectToArray($variables);
}
else {
$variables = [$variables];
}
}
$output = [];
$output[] = '<table>';
if ($caption) {
$output[] = $this->makeTableHeader($caption);
}
foreach ($variables as $key => $item) {
$output[] = $this->makeTableRow($key, $item);
}
$output[] = '</table>';
$html = implode(PHP_EOL, $output);
return '<pre style="' . $this->getContainerCss() . '">' . $html . '</pre>';
} | php | public function dump($variables = null, $caption = null)
{
$this->commentMap = [];
$this->zebra = 1;
$info = [];
if (!is_array($variables)) {
if ($variables instanceof Paginator) {
$variables = $this->paginatorToArray($variables);
}
elseif (is_object($variables)) {
$variables = $this->objectToArray($variables);
}
else {
$variables = [$variables];
}
}
$output = [];
$output[] = '<table>';
if ($caption) {
$output[] = $this->makeTableHeader($caption);
}
foreach ($variables as $key => $item) {
$output[] = $this->makeTableRow($key, $item);
}
$output[] = '</table>';
$html = implode(PHP_EOL, $output);
return '<pre style="' . $this->getContainerCss() . '">' . $html . '</pre>';
} | [
"public",
"function",
"dump",
"(",
"$",
"variables",
"=",
"null",
",",
"$",
"caption",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"commentMap",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"zebra",
"=",
"1",
";",
"$",
"info",
"=",
"[",
"]",
";",
"if",... | Dump information about a variable
@param mixed $variables Variable to dump
@param mixed $caption Caption [and subcaption] of the dump
@return void | [
"Dump",
"information",
"about",
"a",
"variable"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L142-L175 | train | Dump the variables | [
30522,
2270,
3853,
15653,
1006,
1002,
10857,
1027,
19701,
1010,
1002,
14408,
3258,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
7615,
2863,
2361,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
29145,
1027,
1015,
1025,
1002,
18558,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend.php | Zend_Cache_Backend._loggerSanity | protected function _loggerSanity()
{
if (!isset($this->_directives['logging']) || !$this->_directives['logging']) {
return;
}
if (isset($this->_directives['logger'])) {
if ($this->_directives['logger'] instanceof Zend_Log) {
return;
}
Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
}
// Create a default logger to the standard output stream
// require_once 'Zend/Log.php';
// require_once 'Zend/Log/Writer/Stream.php';
// require_once 'Zend/Log/Filter/Priority.php';
$logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
$logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<='));
$this->_directives['logger'] = $logger;
} | php | protected function _loggerSanity()
{
if (!isset($this->_directives['logging']) || !$this->_directives['logging']) {
return;
}
if (isset($this->_directives['logger'])) {
if ($this->_directives['logger'] instanceof Zend_Log) {
return;
}
Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
}
// Create a default logger to the standard output stream
// require_once 'Zend/Log.php';
// require_once 'Zend/Log/Writer/Stream.php';
// require_once 'Zend/Log/Filter/Priority.php';
$logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
$logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::WARN, '<='));
$this->_directives['logger'] = $logger;
} | [
"protected",
"function",
"_loggerSanity",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_directives",
"[",
"'logging'",
"]",
")",
"||",
"!",
"$",
"this",
"->",
"_directives",
"[",
"'logging'",
"]",
")",
"{",
"return",
";",
"}",
"if... | Make sure if we enable logging that the Zend_Log class
is available.
Create a default log object if none is set.
@throws Zend_Cache_Exception
@return void | [
"Make",
"sure",
"if",
"we",
"enable",
"logging",
"that",
"the",
"Zend_Log",
"class",
"is",
"available",
".",
"Create",
"a",
"default",
"log",
"object",
"if",
"none",
"is",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend.php#L224-L244 | train | Sanity check for logging | [
30522,
5123,
3853,
1035,
8833,
15776,
7088,
3723,
1006,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
1035,
16449,
2015,
1031,
1005,
15899,
1005,
1033,
1007,
1064,
1064,
999,
1002,
2023,
1011,
1028,
1035,
16449,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php | FailedMessagesRetryCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
$io->comment('Quit this command with CONTROL-C.');
if (!$output->isVeryVerbose()) {
$io->comment('Re-run the command with a -vv option to see logs about consumed messages.');
}
$receiver = $this->getReceiver();
$this->printPendingMessagesMessage($receiver, $io);
$io->writeln(sprintf('To retry all the messages, run <comment>messenger:consume %s</comment>', $this->getReceiverName()));
$shouldForce = $input->getOption('force');
$ids = $input->getArgument('id');
if (0 === \count($ids)) {
if (!$input->isInteractive()) {
throw new RuntimeException('Message id must be passed when in non-interactive mode.');
}
$this->runInteractive($io, $shouldForce);
return;
}
$this->retrySpecificIds($ids, $io, $shouldForce);
$io->success('All done!');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
$io->comment('Quit this command with CONTROL-C.');
if (!$output->isVeryVerbose()) {
$io->comment('Re-run the command with a -vv option to see logs about consumed messages.');
}
$receiver = $this->getReceiver();
$this->printPendingMessagesMessage($receiver, $io);
$io->writeln(sprintf('To retry all the messages, run <comment>messenger:consume %s</comment>', $this->getReceiverName()));
$shouldForce = $input->getOption('force');
$ids = $input->getArgument('id');
if (0 === \count($ids)) {
if (!$input->isInteractive()) {
throw new RuntimeException('Message id must be passed when in non-interactive mode.');
}
$this->runInteractive($io, $shouldForce);
return;
}
$this->retrySpecificIds($ids, $io, $shouldForce);
$io->success('All done!');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
"instanceof",
"ConsoleOutputInterface",
"?",
"$",
"output",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php#L93-L120 | train | Execute the command | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
22834,
1027,
2047,
25353,
2213,
14876,
4890,
21756,
2571,
1006,
1002,
7953,
1010,
1002,
6434,
6013,
11253,
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/UsersManager/UserAccessFilter.php | UserAccessFilter.filterLogins | public function filterLogins($logins)
{
if ($this->access->hasSuperUserAccess()) {
return $logins;
}
if (!$this->access->isUserHasSomeAdminAccess()) {
// keep only own user if it is in the list
foreach ($logins as $login) {
if ($this->isOwnLogin($login)) {
return array($login);
}
}
return array();
}
foreach ($logins as $index => $login) {
if (!$this->isNonSuperUserAllowedToSeeThisLogin($login)) {
unset($logins[$index]);
}
}
return array_values($logins);
} | php | public function filterLogins($logins)
{
if ($this->access->hasSuperUserAccess()) {
return $logins;
}
if (!$this->access->isUserHasSomeAdminAccess()) {
// keep only own user if it is in the list
foreach ($logins as $login) {
if ($this->isOwnLogin($login)) {
return array($login);
}
}
return array();
}
foreach ($logins as $index => $login) {
if (!$this->isNonSuperUserAllowedToSeeThisLogin($login)) {
unset($logins[$index]);
}
}
return array_values($logins);
} | [
"public",
"function",
"filterLogins",
"(",
"$",
"logins",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"access",
"->",
"hasSuperUserAccess",
"(",
")",
")",
"{",
"return",
"$",
"logins",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"access",
"->",
"isUserH... | Removes all logins from the list of logins where the current user has no permission to see them.
@param string[] $logins An array of logins / usernames. Eg array('username1', 'username2')
@return array | [
"Removes",
"all",
"logins",
"from",
"the",
"list",
"of",
"logins",
"where",
"the",
"current",
"user",
"has",
"no",
"permission",
"to",
"see",
"them",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/UserAccessFilter.php#L130-L154 | train | Filter logins to only super users if they are not in the list | [
30522,
2270,
3853,
11307,
21197,
7076,
1006,
1002,
8833,
7076,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3229,
1011,
1028,
2038,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1007,
1063,
2709,
1002,
8833,
7076,
1025,
1065,
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/Plugin/ViewDataTable.php | ViewDataTable.isRequestingSingleDataTable | public function isRequestingSingleDataTable()
{
$requestArray = $this->request->getRequestArray() + $_GET + $_POST;
$date = Common::getRequestVar('date', null, 'string', $requestArray);
$period = Common::getRequestVar('period', null, 'string', $requestArray);
$idSite = Common::getRequestVar('idSite', null, 'string', $requestArray);
if (Period::isMultiplePeriod($date, $period)
|| strpos($idSite, ',') !== false
|| $idSite == 'all'
) {
return false;
}
return true;
} | php | public function isRequestingSingleDataTable()
{
$requestArray = $this->request->getRequestArray() + $_GET + $_POST;
$date = Common::getRequestVar('date', null, 'string', $requestArray);
$period = Common::getRequestVar('period', null, 'string', $requestArray);
$idSite = Common::getRequestVar('idSite', null, 'string', $requestArray);
if (Period::isMultiplePeriod($date, $period)
|| strpos($idSite, ',') !== false
|| $idSite == 'all'
) {
return false;
}
return true;
} | [
"public",
"function",
"isRequestingSingleDataTable",
"(",
")",
"{",
"$",
"requestArray",
"=",
"$",
"this",
"->",
"request",
"->",
"getRequestArray",
"(",
")",
"+",
"$",
"_GET",
"+",
"$",
"_POST",
";",
"$",
"date",
"=",
"Common",
"::",
"getRequestVar",
"(",... | Returns `true` if this instance will request a single DataTable, `false` if requesting
more than one.
@return bool | [
"Returns",
"true",
"if",
"this",
"instance",
"will",
"request",
"a",
"single",
"DataTable",
"false",
"if",
"requesting",
"more",
"than",
"one",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ViewDataTable.php#L502-L517 | train | return true if the request is requesting a single datatable | [
30522,
2270,
3853,
2003,
2890,
15500,
8613,
2075,
3709,
6790,
10880,
1006,
1007,
1063,
1002,
5227,
2906,
9447,
1027,
1002,
2023,
1011,
1028,
5227,
1011,
1028,
2131,
2890,
15500,
2906,
9447,
1006,
1007,
1009,
1002,
1035,
2131,
1009,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/PrivacyManager/IPAnonymizer.php | IPAnonymizer.setVisitorIpAddress | public function setVisitorIpAddress(&$ip)
{
$ipObject = IP::fromBinaryIP($ip);
if (!$this->isActive()) {
Common::printDebug("Visitor IP was _not_ anonymized: ". $ipObject->toString());
return;
}
$privacyConfig = new Config();
$newIpObject = self::applyIPMask($ipObject, $privacyConfig->ipAddressMaskLength);
$ip = $newIpObject->toBinary();
Common::printDebug("Visitor IP (was: ". $ipObject->toString() .") has been anonymized: ". $newIpObject->toString());
} | php | public function setVisitorIpAddress(&$ip)
{
$ipObject = IP::fromBinaryIP($ip);
if (!$this->isActive()) {
Common::printDebug("Visitor IP was _not_ anonymized: ". $ipObject->toString());
return;
}
$privacyConfig = new Config();
$newIpObject = self::applyIPMask($ipObject, $privacyConfig->ipAddressMaskLength);
$ip = $newIpObject->toBinary();
Common::printDebug("Visitor IP (was: ". $ipObject->toString() .") has been anonymized: ". $newIpObject->toString());
} | [
"public",
"function",
"setVisitorIpAddress",
"(",
"&",
"$",
"ip",
")",
"{",
"$",
"ipObject",
"=",
"IP",
"::",
"fromBinaryIP",
"(",
"$",
"ip",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isActive",
"(",
")",
")",
"{",
"Common",
"::",
"printDebug",
... | Hook on Tracker.Visit.setVisitorIp to anomymize visitor IP addresses
@param string $ip IP address in binary format (network format) | [
"Hook",
"on",
"Tracker",
".",
"Visit",
".",
"setVisitorIp",
"to",
"anomymize",
"visitor",
"IP",
"addresses"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/IPAnonymizer.php#L37-L52 | train | Set visitor IP address | [
30522,
2270,
3853,
2275,
11365,
15660,
11514,
4215,
16200,
4757,
1006,
1004,
1002,
12997,
1007,
1063,
1002,
12997,
16429,
20614,
1027,
12997,
1024,
1024,
2013,
21114,
2854,
11514,
1006,
1002,
12997,
1007,
1025,
2065,
1006,
999,
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... |
guzzle/guzzle | build/Burgomaster.php | Burgomaster.createAutoloader | public function createAutoloader($files = array(), $filename = 'autoloader.php')
{
$sourceDir = realpath($this->stageDir);
$iter = new \RecursiveDirectoryIterator($sourceDir);
$iter = new \RecursiveIteratorIterator($iter);
$this->startSection('autoloader');
$this->debug('Creating classmap autoloader');
$this->debug("Collecting valid PHP files from {$this->stageDir}");
$classMap = array();
foreach ($iter as $file) {
if ($file->getExtension() == 'php') {
$location = str_replace($this->stageDir . '/', '', (string) $file);
$className = str_replace('/', '\\', $location);
$className = substr($className, 0, -4);
// Remove "src\" or "lib\"
if (strpos($className, 'src\\') === 0
|| strpos($className, 'lib\\') === 0
) {
$className = substr($className, 4);
}
$classMap[$className] = "__DIR__ . '/$location'";
$this->debug("Found $className");
}
}
$destFile = $this->stageDir . '/' . $filename;
$this->debug("Writing autoloader to {$destFile}");
if (!($h = fopen($destFile, 'w'))) {
throw new \RuntimeException('Unable to open file for writing');
}
$this->debug('Writing classmap files');
fwrite($h, "<?php\n\n");
fwrite($h, "\$mapping = array(\n");
foreach ($classMap as $c => $f) {
fwrite($h, " '$c' => $f,\n");
}
fwrite($h, ");\n\n");
fwrite($h, <<<EOT
spl_autoload_register(function (\$class) use (\$mapping) {
if (isset(\$mapping[\$class])) {
require \$mapping[\$class];
}
}, true);
EOT
);
fwrite($h, "\n");
$this->debug('Writing automatically included files');
foreach ($files as $file) {
fwrite($h, "require __DIR__ . '/$file';\n");
}
fclose($h);
$this->endSection();
} | php | public function createAutoloader($files = array(), $filename = 'autoloader.php')
{
$sourceDir = realpath($this->stageDir);
$iter = new \RecursiveDirectoryIterator($sourceDir);
$iter = new \RecursiveIteratorIterator($iter);
$this->startSection('autoloader');
$this->debug('Creating classmap autoloader');
$this->debug("Collecting valid PHP files from {$this->stageDir}");
$classMap = array();
foreach ($iter as $file) {
if ($file->getExtension() == 'php') {
$location = str_replace($this->stageDir . '/', '', (string) $file);
$className = str_replace('/', '\\', $location);
$className = substr($className, 0, -4);
// Remove "src\" or "lib\"
if (strpos($className, 'src\\') === 0
|| strpos($className, 'lib\\') === 0
) {
$className = substr($className, 4);
}
$classMap[$className] = "__DIR__ . '/$location'";
$this->debug("Found $className");
}
}
$destFile = $this->stageDir . '/' . $filename;
$this->debug("Writing autoloader to {$destFile}");
if (!($h = fopen($destFile, 'w'))) {
throw new \RuntimeException('Unable to open file for writing');
}
$this->debug('Writing classmap files');
fwrite($h, "<?php\n\n");
fwrite($h, "\$mapping = array(\n");
foreach ($classMap as $c => $f) {
fwrite($h, " '$c' => $f,\n");
}
fwrite($h, ");\n\n");
fwrite($h, <<<EOT
spl_autoload_register(function (\$class) use (\$mapping) {
if (isset(\$mapping[\$class])) {
require \$mapping[\$class];
}
}, true);
EOT
);
fwrite($h, "\n");
$this->debug('Writing automatically included files');
foreach ($files as $file) {
fwrite($h, "require __DIR__ . '/$file';\n");
}
fclose($h);
$this->endSection();
} | [
"public",
"function",
"createAutoloader",
"(",
"$",
"files",
"=",
"array",
"(",
")",
",",
"$",
"filename",
"=",
"'autoloader.php'",
")",
"{",
"$",
"sourceDir",
"=",
"realpath",
"(",
"$",
"this",
"->",
"stageDir",
")",
";",
"$",
"iter",
"=",
"new",
"\\"... | Creates a class-map autoloader to the staging directory in a file
named autoloader.php
@param array $files Files to explicitly require in the autoloader. This
is similar to Composer's "files" "autoload" section.
@param string $filename Name of the autoloader file.
@throws \RuntimeException if the file cannot be written | [
"Creates",
"a",
"class",
"-",
"map",
"autoloader",
"to",
"the",
"staging",
"directory",
"in",
"a",
"file",
"named",
"autoloader",
".",
"php"
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/build/Burgomaster.php#L230-L293 | train | Creates the classmap autoloader | [
30522,
2270,
3853,
3443,
4887,
3406,
11066,
2121,
1006,
1002,
6764,
1027,
9140,
1006,
1007,
1010,
1002,
5371,
18442,
1027,
1005,
8285,
11066,
2121,
1012,
25718,
1005,
1007,
1063,
1002,
23184,
4313,
1027,
2613,
15069,
1006,
1002,
2023,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Mailer.php | Mailer.render | public function render($view, array $data = [])
{
// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
[$view, $plain, $raw] = $this->parseView($view);
$data['message'] = $this->createMessage();
return $this->renderView($view ?: $plain, $data);
} | php | public function render($view, array $data = [])
{
// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
[$view, $plain, $raw] = $this->parseView($view);
$data['message'] = $this->createMessage();
return $this->renderView($view ?: $plain, $data);
} | [
"public",
"function",
"render",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"// First we need to parse the view, which could either be a string or an array",
"// containing both an HTML and plain text versions of the view which should",
"// be used when se... | Render the given message as a view.
@param string|array $view
@param array $data
@return string | [
"Render",
"the",
"given",
"message",
"as",
"a",
"view",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailer.php#L206-L216 | train | Render the view | [
30522,
2270,
3853,
17552,
1006,
1002,
3193,
1010,
9140,
1002,
2951,
1027,
1031,
1033,
1007,
1063,
1013,
1013,
2034,
2057,
2342,
2000,
11968,
3366,
1996,
3193,
1010,
2029,
2071,
2593,
2022,
1037,
5164,
2030,
2019,
9140,
1013,
1013,
4820,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php | MorphOneOrMany.addConstraints | public function addConstraints()
{
if (static::$constraints) {
parent::addConstraints();
$this->query->where($this->morphType, $this->morphClass);
}
} | php | public function addConstraints()
{
if (static::$constraints) {
parent::addConstraints();
$this->query->where($this->morphType, $this->morphClass);
}
} | [
"public",
"function",
"addConstraints",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"constraints",
")",
"{",
"parent",
"::",
"addConstraints",
"(",
")",
";",
"$",
"this",
"->",
"query",
"->",
"where",
"(",
"$",
"this",
"->",
"morphType",
",",
"$",
... | Set the base constraints on the relation query.
@return void | [
"Set",
"the",
"base",
"constraints",
"on",
"the",
"relation",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php#L48-L55 | train | Add constraints to the query | [
30522,
2270,
3853,
5587,
8663,
20528,
18447,
2015,
1006,
1007,
1063,
2065,
1006,
10763,
1024,
1024,
1002,
14679,
1007,
1063,
6687,
1024,
1024,
5587,
8663,
20528,
18447,
2015,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
23032,
1011,
1028,
2073... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Descriptor/JsonDescriptor.php | JsonDescriptor.writeData | private function writeData(array $data, array $options)
{
$this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
} | php | private function writeData(array $data, array $options)
{
$this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
} | [
"private",
"function",
"writeData",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"write",
"(",
"json_encode",
"(",
"$",
"data",
",",
"isset",
"(",
"$",
"options",
"[",
"'json_encoding'",
"]",
")",
"?",
"$",
"o... | Writes data as json.
@return array|string | [
"Writes",
"data",
"as",
"json",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Descriptor/JsonDescriptor.php#L98-L101 | train | Write data to the log file | [
30522,
2797,
3853,
4339,
2850,
2696,
1006,
9140,
1002,
2951,
1010,
9140,
1002,
7047,
1007,
1063,
1002,
2023,
1011,
1028,
4339,
1006,
1046,
3385,
1035,
4372,
16044,
1006,
1002,
2951,
1010,
26354,
3388,
1006,
1002,
7047,
1031,
1005,
1046,
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... |
matomo-org/matomo | libs/Zend/Db/Adapter/Db2.php | Zend_Db_Adapter_Db2.setFetchMode | public function setFetchMode($mode)
{
switch ($mode) {
case Zend_Db::FETCH_NUM: // seq array
case Zend_Db::FETCH_ASSOC: // assoc array
case Zend_Db::FETCH_BOTH: // seq+assoc array
case Zend_Db::FETCH_OBJ: // object
$this->_fetchMode = $mode;
break;
case Zend_Db::FETCH_BOUND: // bound to PHP variable
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception('FETCH_BOUND is not supported yet');
break;
default:
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception("Invalid fetch mode '$mode' specified");
break;
}
} | php | public function setFetchMode($mode)
{
switch ($mode) {
case Zend_Db::FETCH_NUM: // seq array
case Zend_Db::FETCH_ASSOC: // assoc array
case Zend_Db::FETCH_BOTH: // seq+assoc array
case Zend_Db::FETCH_OBJ: // object
$this->_fetchMode = $mode;
break;
case Zend_Db::FETCH_BOUND: // bound to PHP variable
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception('FETCH_BOUND is not supported yet');
break;
default:
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception("Invalid fetch mode '$mode' specified");
break;
}
} | [
"public",
"function",
"setFetchMode",
"(",
"$",
"mode",
")",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"Zend_Db",
"::",
"FETCH_NUM",
":",
"// seq array",
"case",
"Zend_Db",
"::",
"FETCH_ASSOC",
":",
"// assoc array",
"case",
"Zend_Db",
"::",
"FETCH_... | Set the fetch mode.
@param integer $mode
@return void
@throws Zend_Db_Adapter_Db2_Exception | [
"Set",
"the",
"fetch",
"mode",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Db2.php#L629-L653 | train | Set the fetch mode | [
30522,
2270,
3853,
2275,
7959,
10649,
5302,
3207,
1006,
1002,
5549,
1007,
1063,
6942,
1006,
1002,
5549,
1007,
1063,
2553,
16729,
2094,
1035,
16962,
1024,
1024,
18584,
1035,
16371,
2213,
1024,
1013,
1013,
7367,
4160,
9140,
2553,
16729,
2094,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Translator.php | Translator.trans | public function trans($id, array $parameters = [], $domain = null, $locale = null)
{
if (null === $domain) {
$domain = 'messages';
}
$id = (string) $id;
$catalogue = $this->getCatalogue($locale);
$locale = $catalogue->getLocale();
while (!$catalogue->defines($id, $domain)) {
if ($cat = $catalogue->getFallbackCatalogue()) {
$catalogue = $cat;
$locale = $catalogue->getLocale();
} else {
break;
}
}
if ($this->hasIntlFormatter && $catalogue->defines($id, $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
return $this->formatter->formatIntl($catalogue->get($id, $domain), $locale, $parameters);
}
return $this->formatter->format($catalogue->get($id, $domain), $locale, $parameters);
} | php | public function trans($id, array $parameters = [], $domain = null, $locale = null)
{
if (null === $domain) {
$domain = 'messages';
}
$id = (string) $id;
$catalogue = $this->getCatalogue($locale);
$locale = $catalogue->getLocale();
while (!$catalogue->defines($id, $domain)) {
if ($cat = $catalogue->getFallbackCatalogue()) {
$catalogue = $cat;
$locale = $catalogue->getLocale();
} else {
break;
}
}
if ($this->hasIntlFormatter && $catalogue->defines($id, $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
return $this->formatter->formatIntl($catalogue->get($id, $domain), $locale, $parameters);
}
return $this->formatter->format($catalogue->get($id, $domain), $locale, $parameters);
} | [
"public",
"function",
"trans",
"(",
"$",
"id",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"domain",
")",
"{",
"$",
"domain",
"=",
"'... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Translator.php#L197-L220 | train | Returns the translated message | [
30522,
2270,
3853,
9099,
1006,
1002,
8909,
1010,
9140,
1002,
11709,
1027,
1031,
1033,
1010,
1002,
5884,
1027,
19701,
1010,
1002,
2334,
2063,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
5884,
1007,
1063,
1002,
5884,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/EventDispatcher.php | EventDispatcher.postEvent | public function postEvent($eventName, $params, $pending = false, $plugins = null)
{
if ($pending) {
$this->pendingEvents[] = array($eventName, $params);
}
$manager = $this->pluginManager;
if (empty($plugins)) {
$plugins = $manager->getPluginsLoadedAndActivated();
}
$callbacks = array();
// collect all callbacks to execute
foreach ($plugins as $pluginName) {
if (!is_string($pluginName)) {
$pluginName = $pluginName->getPluginName();
}
if (!isset($this->pluginHooks[$pluginName])) {
$plugin = $manager->getLoadedPlugin($pluginName);
$this->pluginHooks[$pluginName] = $plugin->getListHooksRegistered();
}
$hooks = $this->pluginHooks[$pluginName];
if (isset($hooks[$eventName])) {
list($pluginFunction, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($hooks[$eventName]);
if (is_string($pluginFunction)) {
$plugin = $manager->getLoadedPlugin($pluginName);
$callbacks[$callbackGroup][] = array($plugin, $pluginFunction) ;
} else {
$callbacks[$callbackGroup][] = $pluginFunction;
}
}
}
if (isset($this->extraObservers[$eventName])) {
foreach ($this->extraObservers[$eventName] as $callbackInfo) {
list($callback, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($callbackInfo);
$callbacks[$callbackGroup][] = $callback;
}
}
// sort callbacks by their importance
ksort($callbacks);
// execute callbacks in order
foreach ($callbacks as $callbackGroup) {
foreach ($callbackGroup as $callback) {
call_user_func_array($callback, $params);
}
}
} | php | public function postEvent($eventName, $params, $pending = false, $plugins = null)
{
if ($pending) {
$this->pendingEvents[] = array($eventName, $params);
}
$manager = $this->pluginManager;
if (empty($plugins)) {
$plugins = $manager->getPluginsLoadedAndActivated();
}
$callbacks = array();
// collect all callbacks to execute
foreach ($plugins as $pluginName) {
if (!is_string($pluginName)) {
$pluginName = $pluginName->getPluginName();
}
if (!isset($this->pluginHooks[$pluginName])) {
$plugin = $manager->getLoadedPlugin($pluginName);
$this->pluginHooks[$pluginName] = $plugin->getListHooksRegistered();
}
$hooks = $this->pluginHooks[$pluginName];
if (isset($hooks[$eventName])) {
list($pluginFunction, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($hooks[$eventName]);
if (is_string($pluginFunction)) {
$plugin = $manager->getLoadedPlugin($pluginName);
$callbacks[$callbackGroup][] = array($plugin, $pluginFunction) ;
} else {
$callbacks[$callbackGroup][] = $pluginFunction;
}
}
}
if (isset($this->extraObservers[$eventName])) {
foreach ($this->extraObservers[$eventName] as $callbackInfo) {
list($callback, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($callbackInfo);
$callbacks[$callbackGroup][] = $callback;
}
}
// sort callbacks by their importance
ksort($callbacks);
// execute callbacks in order
foreach ($callbacks as $callbackGroup) {
foreach ($callbackGroup as $callback) {
call_user_func_array($callback, $params);
}
}
} | [
"public",
"function",
"postEvent",
"(",
"$",
"eventName",
",",
"$",
"params",
",",
"$",
"pending",
"=",
"false",
",",
"$",
"plugins",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"pending",
")",
"{",
"$",
"this",
"->",
"pendingEvents",
"[",
"]",
"=",
"ar... | Triggers an event, executing all callbacks associated with it.
@param string $eventName The name of the event, ie, API.getReportMetadata.
@param array $params The parameters to pass to each callback when executing.
@param bool $pending Whether this event should be posted again for plugins
loaded after the event is fired.
@param array|null $plugins The plugins to post events to. If null, the event
is posted to all plugins. The elements of this array
can be either the Plugin objects themselves
or their string names. | [
"Triggers",
"an",
"event",
"executing",
"all",
"callbacks",
"associated",
"with",
"it",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/EventDispatcher.php#L88-L144 | train | Post event callback | [
30522,
2270,
3853,
2695,
18697,
3372,
1006,
1002,
2724,
18442,
1010,
1002,
11498,
5244,
1010,
1002,
14223,
1027,
6270,
1010,
1002,
13354,
7076,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
14223,
1007,
1063,
1002,
2023,
1011,
1028,
14223,
186... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.calculateVersionNumberFromDependencyVersion | public function calculateVersionNumberFromDependencyVersion($version)
{
if ($version === '*') {
return null;
}
if ($version === '') {
return null;
}
if ($this->versionFormatIsNextSignificantRelease($version)) {
return trim(substr($version, 1));
}
if ($this->versionFormatIsEqualOrHigher($version)) {
return trim(substr($version, 2));
}
return $version;
} | php | public function calculateVersionNumberFromDependencyVersion($version)
{
if ($version === '*') {
return null;
}
if ($version === '') {
return null;
}
if ($this->versionFormatIsNextSignificantRelease($version)) {
return trim(substr($version, 1));
}
if ($this->versionFormatIsEqualOrHigher($version)) {
return trim(substr($version, 2));
}
return $version;
} | [
"public",
"function",
"calculateVersionNumberFromDependencyVersion",
"(",
"$",
"version",
")",
"{",
"if",
"(",
"$",
"version",
"===",
"'*'",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"version",
"===",
"''",
")",
"{",
"return",
"null",
";",
"}... | Returns the actual version from a dependency version string.
Examples:
$versionInformation == '~2.0' => returns '2.0'
$versionInformation == '>=2.0.2' => returns '2.0.2'
$versionInformation == '2.0.2' => returns '2.0.2'
$versionInformation == '*' => returns null
$versionInformation == '' => returns null
@param string $version
@return null|string | [
"Returns",
"the",
"actual",
"version",
"from",
"a",
"dependency",
"version",
"string",
".",
"Examples",
":",
"$versionInformation",
"==",
"~2",
".",
"0",
"=",
">",
"returns",
"2",
".",
"0",
"$versionInformation",
"==",
">",
"=",
"2",
".",
"0",
".",
"2",
... | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/GPM.php#L1081-L1096 | train | Calculates the version number from the dependency version | [
30522,
2270,
3853,
18422,
27774,
19172,
5677,
19699,
5358,
3207,
11837,
4181,
5666,
27774,
1006,
1002,
2544,
1007,
1063,
2065,
1006,
1002,
2544,
1027,
1027,
1027,
1005,
1008,
1005,
1007,
1063,
2709,
19701,
1025,
1065,
2065,
1006,
1002,
2544... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Adapter/Pdo/Ibm/Db2.php | Zend_Db_Adapter_Pdo_Ibm_Db2.describeTable | public function describeTable($tableName, $schemaName = null)
{
$sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
c.typename, c.default, c.nulls, c.length, c.scale,
c.identity, tc.type AS tabconsttype, k.colseq
FROM syscat.columns c
LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
ON (k.tabschema = tc.tabschema
AND k.tabname = tc.tabname
AND tc.type = 'P'))
ON (c.tabschema = k.tabschema
AND c.tabname = k.tabname
AND c.colname = k.colname)
WHERE "
. $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
if ($schemaName) {
$sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
}
$sql .= " ORDER BY c.colno";
$desc = array();
$stmt = $this->_adapter->query($sql);
/**
* To avoid case issues, fetch using FETCH_NUM
*/
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
/**
* The ordering of columns is defined by the query so we can map
* to variables to improve readability
*/
$tabschema = 0;
$tabname = 1;
$colname = 2;
$colno = 3;
$typename = 4;
$default = 5;
$nulls = 6;
$length = 7;
$scale = 8;
$identityCol = 9;
$tabconstype = 10;
$colseq = 11;
foreach ($result as $key => $row) {
list ($primary, $primaryPosition, $identity) = array(false, null, false);
if ($row[$tabconstype] == 'P') {
$primary = true;
$primaryPosition = $row[$colseq];
}
/**
* In IBM DB2, an column can be IDENTITY
* even if it is not part of the PRIMARY KEY.
*/
if ($row[$identityCol] == 'Y') {
$identity = true;
}
$desc[$this->_adapter->foldCase($row[$colname])] = array(
'SCHEMA_NAME' => $this->_adapter->foldCase($row[$tabschema]),
'TABLE_NAME' => $this->_adapter->foldCase($row[$tabname]),
'COLUMN_NAME' => $this->_adapter->foldCase($row[$colname]),
'COLUMN_POSITION' => $row[$colno]+1,
'DATA_TYPE' => $row[$typename],
'DEFAULT' => $row[$default],
'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
'LENGTH' => $row[$length],
'SCALE' => $row[$scale],
'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
'UNSIGNED' => false,
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
}
return $desc;
} | php | public function describeTable($tableName, $schemaName = null)
{
$sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
c.typename, c.default, c.nulls, c.length, c.scale,
c.identity, tc.type AS tabconsttype, k.colseq
FROM syscat.columns c
LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
ON (k.tabschema = tc.tabschema
AND k.tabname = tc.tabname
AND tc.type = 'P'))
ON (c.tabschema = k.tabschema
AND c.tabname = k.tabname
AND c.colname = k.colname)
WHERE "
. $this->_adapter->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName);
if ($schemaName) {
$sql .= $this->_adapter->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName);
}
$sql .= " ORDER BY c.colno";
$desc = array();
$stmt = $this->_adapter->query($sql);
/**
* To avoid case issues, fetch using FETCH_NUM
*/
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
/**
* The ordering of columns is defined by the query so we can map
* to variables to improve readability
*/
$tabschema = 0;
$tabname = 1;
$colname = 2;
$colno = 3;
$typename = 4;
$default = 5;
$nulls = 6;
$length = 7;
$scale = 8;
$identityCol = 9;
$tabconstype = 10;
$colseq = 11;
foreach ($result as $key => $row) {
list ($primary, $primaryPosition, $identity) = array(false, null, false);
if ($row[$tabconstype] == 'P') {
$primary = true;
$primaryPosition = $row[$colseq];
}
/**
* In IBM DB2, an column can be IDENTITY
* even if it is not part of the PRIMARY KEY.
*/
if ($row[$identityCol] == 'Y') {
$identity = true;
}
$desc[$this->_adapter->foldCase($row[$colname])] = array(
'SCHEMA_NAME' => $this->_adapter->foldCase($row[$tabschema]),
'TABLE_NAME' => $this->_adapter->foldCase($row[$tabname]),
'COLUMN_NAME' => $this->_adapter->foldCase($row[$colname]),
'COLUMN_POSITION' => $row[$colno]+1,
'DATA_TYPE' => $row[$typename],
'DEFAULT' => $row[$default],
'NULLABLE' => (bool) ($row[$nulls] == 'Y'),
'LENGTH' => $row[$length],
'SCALE' => $row[$scale],
'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0),
'UNSIGNED' => false,
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
}
return $desc;
} | [
"public",
"function",
"describeTable",
"(",
"$",
"tableName",
",",
"$",
"schemaName",
"=",
"null",
")",
"{",
"$",
"sql",
"=",
"\"SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,\n c.typename, c.default, c.nulls, c.length, c.scale,\n c.identity... | DB2 catalog lookup for describe table
@param string $tableName
@param string $schemaName OPTIONAL
@return array | [
"DB2",
"catalog",
"lookup",
"for",
"describe",
"table"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm/Db2.php#L77-L155 | train | Describes a table | [
30522,
2270,
3853,
6235,
10880,
1006,
1002,
2795,
18442,
1010,
1002,
8040,
28433,
18442,
1027,
19701,
1007,
1063,
1002,
29296,
1027,
1000,
7276,
5664,
1039,
1012,
21628,
22842,
2863,
1010,
1039,
1012,
21628,
18442,
1010,
1039,
1012,
8902,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | BelongsToMany.firstOrFail | public function firstOrFail($columns = ['*'])
{
if (! is_null($model = $this->first($columns))) {
return $model;
}
throw (new ModelNotFoundException)->setModel(get_class($this->related));
} | php | public function firstOrFail($columns = ['*'])
{
if (! is_null($model = $this->first($columns))) {
return $model;
}
throw (new ModelNotFoundException)->setModel(get_class($this->related));
} | [
"public",
"function",
"firstOrFail",
"(",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"model",
"=",
"$",
"this",
"->",
"first",
"(",
"$",
"columns",
")",
")",
")",
"{",
"return",
"$",
"model",
";",
"}",
... | Execute the query and get the first result or throw an exception.
@param array $columns
@return \Illuminate\Database\Eloquent\Model|static
@throws \Illuminate\Database\Eloquent\ModelNotFoundException | [
"Execute",
"the",
"query",
"and",
"get",
"the",
"first",
"result",
"or",
"throw",
"an",
"exception",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L571-L578 | train | Get the first model or throw an exception if there is no model found | [
30522,
2270,
3853,
2034,
16347,
12502,
1006,
1002,
7753,
1027,
1031,
1005,
1008,
1005,
1033,
1007,
1063,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
2944,
1027,
1002,
2023,
1011,
1028,
2034,
1006,
1002,
7753,
1007,
1007,
1007,
1063,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/controllers/Users.php | Users.update | public function update($recordId, $context = null)
{
// Users cannot edit themselves, only use My Settings
if ($context != 'myaccount' && $recordId == $this->user->id) {
return Backend::redirect('backend/users/myaccount');
}
return $this->asExtension('FormController')->update($recordId, $context);
} | php | public function update($recordId, $context = null)
{
// Users cannot edit themselves, only use My Settings
if ($context != 'myaccount' && $recordId == $this->user->id) {
return Backend::redirect('backend/users/myaccount');
}
return $this->asExtension('FormController')->update($recordId, $context);
} | [
"public",
"function",
"update",
"(",
"$",
"recordId",
",",
"$",
"context",
"=",
"null",
")",
"{",
"// Users cannot edit themselves, only use My Settings",
"if",
"(",
"$",
"context",
"!=",
"'myaccount'",
"&&",
"$",
"recordId",
"==",
"$",
"this",
"->",
"user",
"... | Update controller | [
"Update",
"controller"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/controllers/Users.php#L111-L119 | train | Update the record | [
30522,
2270,
3853,
10651,
1006,
1002,
2501,
3593,
1010,
1002,
6123,
1027,
19701,
1007,
1063,
1013,
1013,
5198,
3685,
10086,
3209,
1010,
2069,
2224,
2026,
10906,
2065,
1006,
1002,
6123,
999,
1027,
1005,
2026,
6305,
3597,
16671,
1005,
1004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ViewDataTable/Request.php | Request.getDefault | protected function getDefault($nameVar)
{
if (isset($this->requestConfig->$nameVar)) {
return $this->requestConfig->$nameVar;
}
return false;
} | php | protected function getDefault($nameVar)
{
if (isset($this->requestConfig->$nameVar)) {
return $this->requestConfig->$nameVar;
}
return false;
} | [
"protected",
"function",
"getDefault",
"(",
"$",
"nameVar",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"requestConfig",
"->",
"$",
"nameVar",
")",
")",
"{",
"return",
"$",
"this",
"->",
"requestConfig",
"->",
"$",
"nameVar",
";",
"}",
"retur... | Returns the default value for a given parameter.
For example, these default values can be set using the disable* methods.
@param string $nameVar
@return mixed | [
"Returns",
"the",
"default",
"value",
"for",
"a",
"given",
"parameter",
".",
"For",
"example",
"these",
"default",
"values",
"can",
"be",
"set",
"using",
"the",
"disable",
"*",
"methods",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Request.php#L139-L146 | train | Get default value of parameter | [
30522,
5123,
3853,
2131,
3207,
7011,
11314,
1006,
1002,
2171,
10755,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
5227,
8663,
8873,
2290,
1011,
1028,
1002,
2171,
10755,
1007,
1007,
1063,
2709,
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 | libs/HTML/QuickForm2/Factory.php | HTML_QuickForm2_Factory.registerRule | public static function registerRule($type, $className, $includeFile = null,
$config = null)
{
self::$registeredRules[strtolower($type)] = array($className, $includeFile, $config);
} | php | public static function registerRule($type, $className, $includeFile = null,
$config = null)
{
self::$registeredRules[strtolower($type)] = array($className, $includeFile, $config);
} | [
"public",
"static",
"function",
"registerRule",
"(",
"$",
"type",
",",
"$",
"className",
",",
"$",
"includeFile",
"=",
"null",
",",
"$",
"config",
"=",
"null",
")",
"{",
"self",
"::",
"$",
"registeredRules",
"[",
"strtolower",
"(",
"$",
"type",
")",
"]... | Registers a new rule type
@param string Rule type name (treated case-insensitively)
@param string Class name
@param string File containing the class, leave empty if class already loaded
@param mixed Configuration data for rules of the given type | [
"Registers",
"a",
"new",
"rule",
"type"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Factory.php#L184-L188 | train | Register a new rule type | [
30522,
2270,
10763,
3853,
4236,
6820,
2571,
1006,
1002,
2828,
1010,
1002,
2465,
18442,
1010,
1002,
2421,
8873,
2571,
1027,
19701,
1010,
1002,
9530,
8873,
2290,
1027,
19701,
1007,
1063,
2969,
1024,
1024,
1002,
5068,
6820,
4244,
1031,
2358,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ScheduledReports/API.php | API.addReport | public function addReport($idSite, $description, $period, $hour, $reportType, $reportFormat, $reports, $parameters, $idSegment = false, $evolutionPeriodFor = 'prev',
$evolutionPeriodN = null)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasViewAccess($idSite);
$currentUser = Piwik::getCurrentUserLogin();
self::ensureLanguageSetForUser($currentUser);
self::validateCommonReportAttributes($period, $hour, $description, $idSegment, $reportType, $reportFormat, $evolutionPeriodFor, $evolutionPeriodN);
// report parameters validations
$parameters = self::validateReportParameters($reportType, $parameters);
// validation of requested reports
$reports = self::validateRequestedReports($idSite, $reportType, $reports);
$idReport = $this->getModel()->createReport(array(
'idsite' => $idSite,
'login' => $currentUser,
'description' => $description,
'idsegment' => $idSegment,
'period' => $period,
'hour' => $hour,
'type' => $reportType,
'format' => $reportFormat,
'parameters' => $parameters,
'reports' => $reports,
'ts_created' => Date::now()->getDatetime(),
'deleted' => 0,
'evolution_graph_within_period' => $evolutionPeriodFor == 'each',
'evolution_graph_period_n' => $evolutionPeriodN ?: ImageGraph::getDefaultGraphEvolutionLastPeriods(),
));
return $idReport;
} | php | public function addReport($idSite, $description, $period, $hour, $reportType, $reportFormat, $reports, $parameters, $idSegment = false, $evolutionPeriodFor = 'prev',
$evolutionPeriodN = null)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasViewAccess($idSite);
$currentUser = Piwik::getCurrentUserLogin();
self::ensureLanguageSetForUser($currentUser);
self::validateCommonReportAttributes($period, $hour, $description, $idSegment, $reportType, $reportFormat, $evolutionPeriodFor, $evolutionPeriodN);
// report parameters validations
$parameters = self::validateReportParameters($reportType, $parameters);
// validation of requested reports
$reports = self::validateRequestedReports($idSite, $reportType, $reports);
$idReport = $this->getModel()->createReport(array(
'idsite' => $idSite,
'login' => $currentUser,
'description' => $description,
'idsegment' => $idSegment,
'period' => $period,
'hour' => $hour,
'type' => $reportType,
'format' => $reportFormat,
'parameters' => $parameters,
'reports' => $reports,
'ts_created' => Date::now()->getDatetime(),
'deleted' => 0,
'evolution_graph_within_period' => $evolutionPeriodFor == 'each',
'evolution_graph_period_n' => $evolutionPeriodN ?: ImageGraph::getDefaultGraphEvolutionLastPeriods(),
));
return $idReport;
} | [
"public",
"function",
"addReport",
"(",
"$",
"idSite",
",",
"$",
"description",
",",
"$",
"period",
",",
"$",
"hour",
",",
"$",
"reportType",
",",
"$",
"reportFormat",
",",
"$",
"reports",
",",
"$",
"parameters",
",",
"$",
"idSegment",
"=",
"false",
",... | Creates a new report and schedules it.
@param int $idSite
@param string $description Report description
@param string $period Schedule frequency: day, week or month
@param int $hour Hour (0-23) when the report should be sent
@param string $reportType 'email' or any other format provided via the ScheduledReports.getReportTypes hook
@param string $reportFormat 'pdf', 'html' or any other format provided via the ScheduledReports.getReportFormats hook
@param array $reports array of reports
@param array $parameters array of parameters
@param bool|int $idSegment Segment Identifier
@param string $evolutionPeriodFor If set to 'each', the evolution graphs cover each day within the period. If set to 'prev',
evolution graphs cover the previous N periods.
@param int|null $evolutionPeriodN The previous N periods to query in evolution graphs if $evolutionPeriodFor is 'each'.
@return int idReport generated | [
"Creates",
"a",
"new",
"report",
"and",
"schedules",
"it",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ScheduledReports/API.php#L98-L133 | train | Add a report to the imagegraph | [
30522,
2270,
3853,
5587,
2890,
6442,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
6412,
1010,
1002,
2558,
1010,
1002,
3178,
1010,
1002,
3189,
13874,
1010,
1002,
3189,
14192,
4017,
1010,
1002,
4311,
1010,
1002,
11709,
1010,
1002,
8909,
3366,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Common.php | Common.unsanitizeInputValues | public static function unsanitizeInputValues($value)
{
if (is_array($value)) {
$result = array();
foreach ($value as $key => $arrayValue) {
$result[$key] = self::unsanitizeInputValues($arrayValue);
}
return $result;
} else {
return self::unsanitizeInputValue($value);
}
} | php | public static function unsanitizeInputValues($value)
{
if (is_array($value)) {
$result = array();
foreach ($value as $key => $arrayValue) {
$result[$key] = self::unsanitizeInputValues($arrayValue);
}
return $result;
} else {
return self::unsanitizeInputValue($value);
}
} | [
"public",
"static",
"function",
"unsanitizeInputValues",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"a... | Unsanitizes one or more values and returns the result.
This method should be used when you need to unescape data that was obtained from
the user.
Some data in Piwik is stored sanitized (such as site name). In this case you may
have to use this method to unsanitize it in order to, for example, output it in JSON.
@param string|array $value The data to unsanitize. If an array is passed, the
array is sanitized recursively. Key values are not unsanitized.
@return string|array The unsanitized data.
@api | [
"Unsanitizes",
"one",
"or",
"more",
"values",
"and",
"returns",
"the",
"result",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Common.php#L414-L425 | train | Unsanitize input values | [
30522,
2270,
10763,
3853,
4895,
8791,
25090,
4371,
2378,
18780,
10175,
15808,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
3643,
1007,
1007,
1063,
1002,
2765,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Imap.php | Zend_Mail_Storage_Imap.getFolders | public function getFolders($rootFolder = null)
{
$folders = $this->_protocol->listMailbox((string)$rootFolder);
if (!$folders) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('folder not found');
}
ksort($folders, SORT_STRING);
$root = new Zend_Mail_Storage_Folder('/', '/', false);
$stack = array(null);
$folderStack = array(null);
$parentFolder = $root;
$parent = '';
foreach ($folders as $globalName => $data) {
do {
if (!$parent || strpos($globalName, $parent) === 0) {
$pos = strrpos($globalName, $data['delim']);
if ($pos === false) {
$localName = $globalName;
} else {
$localName = substr($globalName, $pos + 1);
}
$selectable = !$data['flags'] || !in_array('\\Noselect', $data['flags']);
array_push($stack, $parent);
$parent = $globalName . $data['delim'];
$folder = new Zend_Mail_Storage_Folder($localName, $globalName, $selectable);
$parentFolder->$localName = $folder;
array_push($folderStack, $parentFolder);
$parentFolder = $folder;
break;
} else if ($stack) {
$parent = array_pop($stack);
$parentFolder = array_pop($folderStack);
}
} while ($stack);
if (!$stack) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('error while constructing folder tree');
}
}
return $root;
} | php | public function getFolders($rootFolder = null)
{
$folders = $this->_protocol->listMailbox((string)$rootFolder);
if (!$folders) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('folder not found');
}
ksort($folders, SORT_STRING);
$root = new Zend_Mail_Storage_Folder('/', '/', false);
$stack = array(null);
$folderStack = array(null);
$parentFolder = $root;
$parent = '';
foreach ($folders as $globalName => $data) {
do {
if (!$parent || strpos($globalName, $parent) === 0) {
$pos = strrpos($globalName, $data['delim']);
if ($pos === false) {
$localName = $globalName;
} else {
$localName = substr($globalName, $pos + 1);
}
$selectable = !$data['flags'] || !in_array('\\Noselect', $data['flags']);
array_push($stack, $parent);
$parent = $globalName . $data['delim'];
$folder = new Zend_Mail_Storage_Folder($localName, $globalName, $selectable);
$parentFolder->$localName = $folder;
array_push($folderStack, $parentFolder);
$parentFolder = $folder;
break;
} else if ($stack) {
$parent = array_pop($stack);
$parentFolder = array_pop($folderStack);
}
} while ($stack);
if (!$stack) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('error while constructing folder tree');
}
}
return $root;
} | [
"public",
"function",
"getFolders",
"(",
"$",
"rootFolder",
"=",
"null",
")",
"{",
"$",
"folders",
"=",
"$",
"this",
"->",
"_protocol",
"->",
"listMailbox",
"(",
"(",
"string",
")",
"$",
"rootFolder",
")",
";",
"if",
"(",
"!",
"$",
"folders",
")",
"{... | get root folder or given folder
@param string $rootFolder get folder structure for given folder, else root
@return Zend_Mail_Storage_Folder root or wanted folder
@throws Zend_Mail_Storage_Exception
@throws Zend_Mail_Protocol_Exception | [
"get",
"root",
"folder",
"or",
"given",
"folder"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Imap.php#L395-L446 | train | Get all folders in the root folder | [
30522,
2270,
3853,
2131,
10371,
2545,
1006,
1002,
7117,
10371,
2121,
1027,
19701,
1007,
1063,
1002,
19622,
2015,
1027,
1002,
2023,
1011,
1028,
1035,
8778,
1011,
1028,
2862,
21397,
8758,
1006,
1006,
5164,
1007,
1002,
7117,
10371,
2121,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/ValidatorBuilder.php | ValidatorBuilder.getValidator | public function getValidator()
{
$metadataFactory = $this->metadataFactory;
if (!$metadataFactory) {
$loaders = $this->getLoaders();
$loader = null;
if (\count($loaders) > 1) {
$loader = new LoaderChain($loaders);
} elseif (1 === \count($loaders)) {
$loader = $loaders[0];
}
$metadataFactory = new LazyLoadingMetadataFactory($loader, $this->metadataCache);
}
$validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory();
$translator = $this->translator;
if (null === $translator) {
$translator = new class() implements TranslatorInterface, LocaleAwareInterface {
use TranslatorTrait;
};
// Force the locale to be 'en' when no translator is provided rather than relying on the Intl default locale
// This avoids depending on Intl or the stub implementation being available. It also ensures that Symfony
// validation messages are pluralized properly even when the default locale gets changed because they are in
// English.
$translator->setLocale('en');
}
$contextFactory = new ExecutionContextFactory($translator, $this->translationDomain);
return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers);
} | php | public function getValidator()
{
$metadataFactory = $this->metadataFactory;
if (!$metadataFactory) {
$loaders = $this->getLoaders();
$loader = null;
if (\count($loaders) > 1) {
$loader = new LoaderChain($loaders);
} elseif (1 === \count($loaders)) {
$loader = $loaders[0];
}
$metadataFactory = new LazyLoadingMetadataFactory($loader, $this->metadataCache);
}
$validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory();
$translator = $this->translator;
if (null === $translator) {
$translator = new class() implements TranslatorInterface, LocaleAwareInterface {
use TranslatorTrait;
};
// Force the locale to be 'en' when no translator is provided rather than relying on the Intl default locale
// This avoids depending on Intl or the stub implementation being available. It also ensures that Symfony
// validation messages are pluralized properly even when the default locale gets changed because they are in
// English.
$translator->setLocale('en');
}
$contextFactory = new ExecutionContextFactory($translator, $this->translationDomain);
return new RecursiveValidator($contextFactory, $metadataFactory, $validatorFactory, $this->initializers);
} | [
"public",
"function",
"getValidator",
"(",
")",
"{",
"$",
"metadataFactory",
"=",
"$",
"this",
"->",
"metadataFactory",
";",
"if",
"(",
"!",
"$",
"metadataFactory",
")",
"{",
"$",
"loaders",
"=",
"$",
"this",
"->",
"getLoaders",
"(",
")",
";",
"$",
"lo... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/ValidatorBuilder.php#L319-L353 | train | Returns a validator for the current locale | [
30522,
2270,
3853,
2131,
10175,
8524,
4263,
1006,
1007,
1063,
1002,
27425,
21450,
1027,
1002,
2023,
1011,
1028,
27425,
21450,
1025,
2065,
1006,
999,
1002,
27425,
21450,
1007,
1063,
1002,
7170,
2545,
1027,
1002,
2023,
1011,
1028,
2131,
11066... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Installer.php | Installer.isValidDestination | public static function isValidDestination($destination, $exclude = [])
{
self::$error = 0;
self::$target = $destination;
if (is_link($destination)) {
self::$error = self::IS_LINK;
} elseif (file_exists($destination)) {
self::$error = self::EXISTS;
} elseif (!file_exists($destination)) {
self::$error = self::NOT_FOUND;
} elseif (!is_dir($destination)) {
self::$error = self::NOT_DIRECTORY;
}
if (\count($exclude) && \in_array(self::$error, $exclude, true)) {
return true;
}
return !self::$error;
} | php | public static function isValidDestination($destination, $exclude = [])
{
self::$error = 0;
self::$target = $destination;
if (is_link($destination)) {
self::$error = self::IS_LINK;
} elseif (file_exists($destination)) {
self::$error = self::EXISTS;
} elseif (!file_exists($destination)) {
self::$error = self::NOT_FOUND;
} elseif (!is_dir($destination)) {
self::$error = self::NOT_DIRECTORY;
}
if (\count($exclude) && \in_array(self::$error, $exclude, true)) {
return true;
}
return !self::$error;
} | [
"public",
"static",
"function",
"isValidDestination",
"(",
"$",
"destination",
",",
"$",
"exclude",
"=",
"[",
"]",
")",
"{",
"self",
"::",
"$",
"error",
"=",
"0",
";",
"self",
"::",
"$",
"target",
"=",
"$",
"destination",
";",
"if",
"(",
"is_link",
"... | Runs a set of checks on the destination and sets the Error if any
@param string $destination The directory to run validations at
@param array $exclude An array of constants to exclude from the validation
@return bool True if validation passed. False otherwise | [
"Runs",
"a",
"set",
"of",
"checks",
"on",
"the",
"destination",
"and",
"sets",
"the",
"Error",
"if",
"any"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/Installer.php#L379-L399 | train | Check if the destination is valid | [
30522,
2270,
10763,
3853,
2003,
10175,
3593,
6155,
13770,
3508,
1006,
1002,
7688,
1010,
1002,
23329,
1027,
1031,
1033,
1007,
1063,
2969,
1024,
1024,
1002,
7561,
1027,
1014,
1025,
2969,
1024,
1024,
1002,
4539,
1027,
1002,
7688,
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... |
getgrav/grav | system/src/Grav/Common/Composer.php | Composer.getComposerLocation | public static function getComposerLocation()
{
if (!\function_exists('shell_exec') || stripos(PHP_OS, 'win') === 0) {
return self::DEFAULT_PATH;
}
// check for global composer install
$path = trim(shell_exec('command -v composer'));
// fall back to grav bundled composer
if (!$path || !preg_match('/(composer|composer\.phar)$/', $path)) {
$path = self::DEFAULT_PATH;
}
return $path;
} | php | public static function getComposerLocation()
{
if (!\function_exists('shell_exec') || stripos(PHP_OS, 'win') === 0) {
return self::DEFAULT_PATH;
}
// check for global composer install
$path = trim(shell_exec('command -v composer'));
// fall back to grav bundled composer
if (!$path || !preg_match('/(composer|composer\.phar)$/', $path)) {
$path = self::DEFAULT_PATH;
}
return $path;
} | [
"public",
"static",
"function",
"getComposerLocation",
"(",
")",
"{",
"if",
"(",
"!",
"\\",
"function_exists",
"(",
"'shell_exec'",
")",
"||",
"stripos",
"(",
"PHP_OS",
",",
"'win'",
")",
"===",
"0",
")",
"{",
"return",
"self",
"::",
"DEFAULT_PATH",
";",
... | Returns the location of composer.
@return string | [
"Returns",
"the",
"location",
"of",
"composer",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Composer.php#L22-L37 | train | Returns the path to the composer. json file | [
30522,
2270,
10763,
3853,
2131,
9006,
20688,
12190,
23909,
1006,
1007,
1063,
2065,
1006,
999,
1032,
3853,
1035,
6526,
1006,
1005,
5806,
1035,
4654,
8586,
1005,
1007,
1064,
1064,
6167,
2891,
1006,
25718,
1035,
9808,
1010,
1005,
2663,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Container.php | HTML_QuickForm2_Container.getElementsByName | public function getElementsByName($name)
{
$found = array();
foreach ($this->getRecursiveIterator() as $element) {
if ($element->getName() == $name) {
$found[] = $element;
}
}
return $found;
} | php | public function getElementsByName($name)
{
$found = array();
foreach ($this->getRecursiveIterator() as $element) {
if ($element->getName() == $name) {
$found[] = $element;
}
}
return $found;
} | [
"public",
"function",
"getElementsByName",
"(",
"$",
"name",
")",
"{",
"$",
"found",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRecursiveIterator",
"(",
")",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"g... | Returns an array of elements which name corresponds to element
@param string Elements name to find
@return array | [
"Returns",
"an",
"array",
"of",
"elements",
"which",
"name",
"corresponds",
"to",
"element"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Container.php#L279-L288 | train | Get all elements with the given name | [
30522,
2270,
3853,
2131,
12260,
8163,
3762,
18442,
1006,
1002,
2171,
1007,
1063,
1002,
2179,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
2890,
10841,
2869,
3512,
21646,
8844,
1006,
1007,
2004,
1002,
5783,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getRowFromIdSubDataTable | public function getRowFromIdSubDataTable($idSubTable)
{
$idSubTable = (int)$idSubTable;
foreach ($this->rows as $row) {
if ($row->getIdSubDataTable() === $idSubTable) {
return $row;
}
}
return false;
} | php | public function getRowFromIdSubDataTable($idSubTable)
{
$idSubTable = (int)$idSubTable;
foreach ($this->rows as $row) {
if ($row->getIdSubDataTable() === $idSubTable) {
return $row;
}
}
return false;
} | [
"public",
"function",
"getRowFromIdSubDataTable",
"(",
"$",
"idSubTable",
")",
"{",
"$",
"idSubTable",
"=",
"(",
"int",
")",
"$",
"idSubTable",
";",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"->",
"... | Returns the row that has a subtable with ID matching `$idSubtable`.
@param int $idSubTable The subtable ID.
@return Row|false The row or false if not found | [
"Returns",
"the",
"row",
"that",
"has",
"a",
"subtable",
"with",
"ID",
"matching",
"$idSubtable",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L769-L778 | train | Get Row from Id SubDataTable | [
30522,
2270,
3853,
2131,
10524,
19699,
20936,
5104,
12083,
2850,
29336,
3085,
1006,
1002,
8909,
6342,
19279,
3085,
1007,
1063,
1002,
8909,
6342,
19279,
3085,
1027,
1006,
20014,
1007,
1002,
8909,
6342,
19279,
3085,
1025,
18921,
6776,
1006,
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/PropertyAccess/PropertyAccessor.php | PropertyAccessor.writeCollection | private function writeCollection($zval, $property, $collection, $addMethod, $removeMethod)
{
// At this point the add and remove methods have been found
$previousValue = $this->readProperty($zval, $property);
$previousValue = $previousValue[self::VALUE];
if ($previousValue instanceof \Traversable) {
$previousValue = iterator_to_array($previousValue);
}
if ($previousValue && \is_array($previousValue)) {
if (\is_object($collection)) {
$collection = iterator_to_array($collection);
}
foreach ($previousValue as $key => $item) {
if (!\in_array($item, $collection, true)) {
unset($previousValue[$key]);
$zval[self::VALUE]->{$removeMethod}($item);
}
}
} else {
$previousValue = false;
}
foreach ($collection as $item) {
if (!$previousValue || !\in_array($item, $previousValue, true)) {
$zval[self::VALUE]->{$addMethod}($item);
}
}
} | php | private function writeCollection($zval, $property, $collection, $addMethod, $removeMethod)
{
// At this point the add and remove methods have been found
$previousValue = $this->readProperty($zval, $property);
$previousValue = $previousValue[self::VALUE];
if ($previousValue instanceof \Traversable) {
$previousValue = iterator_to_array($previousValue);
}
if ($previousValue && \is_array($previousValue)) {
if (\is_object($collection)) {
$collection = iterator_to_array($collection);
}
foreach ($previousValue as $key => $item) {
if (!\in_array($item, $collection, true)) {
unset($previousValue[$key]);
$zval[self::VALUE]->{$removeMethod}($item);
}
}
} else {
$previousValue = false;
}
foreach ($collection as $item) {
if (!$previousValue || !\in_array($item, $previousValue, true)) {
$zval[self::VALUE]->{$addMethod}($item);
}
}
} | [
"private",
"function",
"writeCollection",
"(",
"$",
"zval",
",",
"$",
"property",
",",
"$",
"collection",
",",
"$",
"addMethod",
",",
"$",
"removeMethod",
")",
"{",
"// At this point the add and remove methods have been found",
"$",
"previousValue",
"=",
"$",
"this"... | Adjusts a collection-valued property by calling add*() and remove*() methods.
@param array $zval The array containing the object to write to
@param string $property The property to write
@param iterable $collection The collection to write
@param string $addMethod The add*() method
@param string $removeMethod The remove*() method | [
"Adjusts",
"a",
"collection",
"-",
"valued",
"property",
"by",
"calling",
"add",
"*",
"()",
"and",
"remove",
"*",
"()",
"methods",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L581-L609 | train | Write collection to the array | [
30522,
2797,
3853,
4339,
26895,
18491,
1006,
1002,
1062,
10175,
1010,
1002,
3200,
1010,
1002,
3074,
1010,
1002,
5587,
11368,
6806,
2094,
1010,
1002,
6366,
11368,
6806,
2094,
1007,
1063,
1013,
1013,
2012,
2023,
2391,
1996,
5587,
1998,
6366,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DataArray.php | DataArray.enrichWithConversions | protected function enrichWithConversions(&$data)
{
foreach ($data as &$values) {
if (!isset($values[Metrics::INDEX_GOALS])) {
continue;
}
// When per goal metrics are processed, general 'visits converted' is not meaningful because
// it could differ from the sum of each goal conversions
unset($values[Metrics::INDEX_NB_VISITS_CONVERTED]);
$revenue = $conversions = 0;
foreach ($values[Metrics::INDEX_GOALS] as $idgoal => $goalValues) {
// Do not sum Cart revenue since it is a lost revenue
if ($idgoal >= GoalManager::IDGOAL_ORDER) {
$revenue += $goalValues[Metrics::INDEX_GOAL_REVENUE];
$conversions += $goalValues[Metrics::INDEX_GOAL_NB_CONVERSIONS];
}
}
$values[Metrics::INDEX_NB_CONVERSIONS] = $conversions;
// 25.00 recorded as 25
if (round($revenue) == $revenue) {
$revenue = round($revenue);
}
$values[Metrics::INDEX_REVENUE] = $revenue;
// if there are no "visit" column, we force one to prevent future complications
// eg. This helps the setDefaultColumnsToDisplay() call
if (!isset($values[Metrics::INDEX_NB_VISITS])) {
$values[Metrics::INDEX_NB_VISITS] = 0;
}
}
} | php | protected function enrichWithConversions(&$data)
{
foreach ($data as &$values) {
if (!isset($values[Metrics::INDEX_GOALS])) {
continue;
}
// When per goal metrics are processed, general 'visits converted' is not meaningful because
// it could differ from the sum of each goal conversions
unset($values[Metrics::INDEX_NB_VISITS_CONVERTED]);
$revenue = $conversions = 0;
foreach ($values[Metrics::INDEX_GOALS] as $idgoal => $goalValues) {
// Do not sum Cart revenue since it is a lost revenue
if ($idgoal >= GoalManager::IDGOAL_ORDER) {
$revenue += $goalValues[Metrics::INDEX_GOAL_REVENUE];
$conversions += $goalValues[Metrics::INDEX_GOAL_NB_CONVERSIONS];
}
}
$values[Metrics::INDEX_NB_CONVERSIONS] = $conversions;
// 25.00 recorded as 25
if (round($revenue) == $revenue) {
$revenue = round($revenue);
}
$values[Metrics::INDEX_REVENUE] = $revenue;
// if there are no "visit" column, we force one to prevent future complications
// eg. This helps the setDefaultColumnsToDisplay() call
if (!isset($values[Metrics::INDEX_NB_VISITS])) {
$values[Metrics::INDEX_NB_VISITS] = 0;
}
}
} | [
"protected",
"function",
"enrichWithConversions",
"(",
"&",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"&",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"values",
"[",
"Metrics",
"::",
"INDEX_GOALS",
"]",
")",
")",
"{",
... | Given an array of stats, it will process the sum of goal conversions
and sum of revenue and add it in the stats array in two new fields.
@param array $data Passed by reference, two new columns
will be added: total conversions, and total revenue, for all goals for this label/row | [
"Given",
"an",
"array",
"of",
"stats",
"it",
"will",
"process",
"the",
"sum",
"of",
"goal",
"conversions",
"and",
"sum",
"of",
"revenue",
"and",
"add",
"it",
"in",
"the",
"stats",
"array",
"in",
"two",
"new",
"fields",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataArray.php#L378-L409 | train | Enriches the revenue and conversions of all goal metrics | [
30522,
5123,
3853,
4372,
13149,
24415,
8663,
27774,
2015,
1006,
1004,
1002,
2951,
1007,
1063,
18921,
6776,
1006,
1002,
2951,
2004,
1004,
1002,
5300,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
5300,
1031,
12046,
2015,
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... |
domnikl/DesignPatternsPHP | Behavioral/ChainOfResponsibilities/Handler.php | Handler.handle | final public function handle(RequestInterface $request)
{
$processed = $this->processing($request);
if ($processed === null) {
// the request has not been processed by this handler => see the next
if ($this->successor !== null) {
$processed = $this->successor->handle($request);
}
}
return $processed;
} | php | final public function handle(RequestInterface $request)
{
$processed = $this->processing($request);
if ($processed === null) {
// the request has not been processed by this handler => see the next
if ($this->successor !== null) {
$processed = $this->successor->handle($request);
}
}
return $processed;
} | [
"final",
"public",
"function",
"handle",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"processed",
"=",
"$",
"this",
"->",
"processing",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"processed",
"===",
"null",
")",
"{",
"// the request has not... | This approach by using a template method pattern ensures you that
each subclass will not forget to call the successor
@param RequestInterface $request
@return string|null | [
"This",
"approach",
"by",
"using",
"a",
"template",
"method",
"pattern",
"ensures",
"you",
"that",
"each",
"subclass",
"will",
"not",
"forget",
"to",
"call",
"the",
"successor"
] | 5f5649b57ea94471e20b54eb439c6368dea07886 | https://github.com/domnikl/DesignPatternsPHP/blob/5f5649b57ea94471e20b54eb439c6368dea07886/Behavioral/ChainOfResponsibilities/Handler.php#L28-L40 | train | Handle the request | [
30522,
2345,
2270,
3853,
5047,
1006,
5227,
18447,
2121,
12172,
1002,
5227,
1007,
1063,
1002,
13995,
1027,
1002,
2023,
1011,
1028,
6364,
1006,
1002,
5227,
1007,
1025,
2065,
1006,
1002,
13995,
1027,
1027,
1027,
19701,
1007,
1063,
1013,
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... |
overtrue/wechat | src/OfficialAccount/User/UserClient.php | UserClient.select | public function select(array $openids, string $lang = 'zh_CN')
{
return $this->httpPostJson('cgi-bin/user/info/batchget', [
'user_list' => array_map(function ($openid) use ($lang) {
return [
'openid' => $openid,
'lang' => $lang,
];
}, $openids),
]);
} | php | public function select(array $openids, string $lang = 'zh_CN')
{
return $this->httpPostJson('cgi-bin/user/info/batchget', [
'user_list' => array_map(function ($openid) use ($lang) {
return [
'openid' => $openid,
'lang' => $lang,
];
}, $openids),
]);
} | [
"public",
"function",
"select",
"(",
"array",
"$",
"openids",
",",
"string",
"$",
"lang",
"=",
"'zh_CN'",
")",
"{",
"return",
"$",
"this",
"->",
"httpPostJson",
"(",
"'cgi-bin/user/info/batchget'",
",",
"[",
"'user_list'",
"=>",
"array_map",
"(",
"function",
... | Batch get users.
@param array $openids
@param string $lang
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Batch",
"get",
"users",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/User/UserClient.php#L53-L63 | train | Select users from a list of openids | [
30522,
2270,
3853,
7276,
1006,
9140,
1002,
2330,
9821,
1010,
5164,
1002,
11374,
1027,
1005,
1062,
2232,
1035,
27166,
1005,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
8299,
19894,
22578,
2239,
1006,
1005,
1039,
5856,
1011,
8026,
1013,
5310,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/IpUtils.php | IpUtils.checkIp | public static function checkIp($requestIp, $ips)
{
if (!\is_array($ips)) {
$ips = [$ips];
}
$method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4';
foreach ($ips as $ip) {
if (self::$method($requestIp, $ip)) {
return true;
}
}
return false;
} | php | public static function checkIp($requestIp, $ips)
{
if (!\is_array($ips)) {
$ips = [$ips];
}
$method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4';
foreach ($ips as $ip) {
if (self::$method($requestIp, $ip)) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"checkIp",
"(",
"$",
"requestIp",
",",
"$",
"ips",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"ips",
")",
")",
"{",
"$",
"ips",
"=",
"[",
"$",
"ips",
"]",
";",
"}",
"$",
"method",
"=",
"substr_count",
... | Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets.
@param string $requestIp IP to check
@param string|array $ips List of IPs or subnets (can be a string if only a single one)
@return bool Whether the IP is valid | [
"Checks",
"if",
"an",
"IPv4",
"or",
"IPv6",
"address",
"is",
"contained",
"in",
"the",
"list",
"of",
"given",
"IPs",
"or",
"subnets",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/IpUtils.php#L38-L53 | train | Check if ip is in list of IPs | [
30522,
2270,
10763,
3853,
30524,
1035,
9140,
1006,
1002,
12997,
2015,
1007,
1007,
1063,
1002,
12997,
2015,
1027,
1031,
1002,
12997,
2015,
1033,
1025,
1065,
1002,
4118,
1027,
4942,
3367,
2099,
1035,
4175,
1006,
1002,
5227,
11514,
1010,
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... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.onSetFilter | public function onSetFilter()
{
$filter = Input::get('filter');
$path = Input::get('path');
$this->setFilter($filter);
$this->setCurrentFolder($path);
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list'),
'#'.$this->getId('folder-path') => $this->makePartial('folder-path'),
'#'.$this->getId('filters') => $this->makePartial('filters')
];
} | php | public function onSetFilter()
{
$filter = Input::get('filter');
$path = Input::get('path');
$this->setFilter($filter);
$this->setCurrentFolder($path);
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list'),
'#'.$this->getId('folder-path') => $this->makePartial('folder-path'),
'#'.$this->getId('filters') => $this->makePartial('filters')
];
} | [
"public",
"function",
"onSetFilter",
"(",
")",
"{",
"$",
"filter",
"=",
"Input",
"::",
"get",
"(",
"'filter'",
")",
";",
"$",
"path",
"=",
"Input",
"::",
"get",
"(",
"'path'",
")",
";",
"$",
"this",
"->",
"setFilter",
"(",
"$",
"filter",
")",
";",
... | Set filter preference AJAX handler
@return array | [
"Set",
"filter",
"preference",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L240-L255 | train | onSetFilter callback - will prepare vars and return array | [
30522,
2270,
3853,
14447,
8873,
21928,
1006,
1007,
1063,
1002,
11307,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
11307,
1005,
1007,
1025,
1002,
4130,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
4130,
1005,
1007,
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... |
laravel/framework | src/Illuminate/Notifications/Messages/MailMessage.php | MailMessage.cc | public function cc($address, $name = null)
{
if ($this->arrayOfAddresses($address)) {
$this->cc += $this->parseAddresses($address);
} else {
$this->cc[] = [$address, $name];
}
return $this;
} | php | public function cc($address, $name = null)
{
if ($this->arrayOfAddresses($address)) {
$this->cc += $this->parseAddresses($address);
} else {
$this->cc[] = [$address, $name];
}
return $this;
} | [
"public",
"function",
"cc",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"arrayOfAddresses",
"(",
"$",
"address",
")",
")",
"{",
"$",
"this",
"->",
"cc",
"+=",
"$",
"this",
"->",
"parseAddresses",
"(",... | Set the cc address for the mail message.
@param array|string $address
@param string|null $name
@return $this | [
"Set",
"the",
"cc",
"address",
"for",
"the",
"mail",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Notifications/Messages/MailMessage.php#L169-L178 | train | Add cc address | [
30522,
2270,
3853,
10507,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
9140,
11253,
4215,
16200,
11393,
2015,
1006,
1002,
4769,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
10507,
1009,
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/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php | ReplaceAliasByActualDefinitionPass.process | public function process(ContainerBuilder $container)
{
// First collect all alias targets that need to be replaced
$seenAliasTargets = [];
$replacements = [];
foreach ($container->getAliases() as $definitionId => $target) {
$targetId = (string) $target;
// Special case: leave this target alone
if ('service_container' === $targetId) {
continue;
}
// Check if target needs to be replaces
if (isset($replacements[$targetId])) {
$container->setAlias($definitionId, $replacements[$targetId])->setPublic($target->isPublic())->setPrivate($target->isPrivate());
}
// No need to process the same target twice
if (isset($seenAliasTargets[$targetId])) {
continue;
}
// Process new target
$seenAliasTargets[$targetId] = true;
try {
$definition = $container->getDefinition($targetId);
} catch (ServiceNotFoundException $e) {
if ('' !== $e->getId() && '@' === $e->getId()[0]) {
throw new ServiceNotFoundException($e->getId(), $e->getSourceId(), null, [substr($e->getId(), 1)]);
}
throw $e;
}
if ($definition->isPublic()) {
continue;
}
// Remove private definition and schedule for replacement
$definition->setPublic(!$target->isPrivate());
$definition->setPrivate($target->isPrivate());
$container->setDefinition($definitionId, $definition);
$container->removeDefinition($targetId);
$replacements[$targetId] = $definitionId;
}
$this->replacements = $replacements;
parent::process($container);
$this->replacements = [];
} | php | public function process(ContainerBuilder $container)
{
// First collect all alias targets that need to be replaced
$seenAliasTargets = [];
$replacements = [];
foreach ($container->getAliases() as $definitionId => $target) {
$targetId = (string) $target;
// Special case: leave this target alone
if ('service_container' === $targetId) {
continue;
}
// Check if target needs to be replaces
if (isset($replacements[$targetId])) {
$container->setAlias($definitionId, $replacements[$targetId])->setPublic($target->isPublic())->setPrivate($target->isPrivate());
}
// No need to process the same target twice
if (isset($seenAliasTargets[$targetId])) {
continue;
}
// Process new target
$seenAliasTargets[$targetId] = true;
try {
$definition = $container->getDefinition($targetId);
} catch (ServiceNotFoundException $e) {
if ('' !== $e->getId() && '@' === $e->getId()[0]) {
throw new ServiceNotFoundException($e->getId(), $e->getSourceId(), null, [substr($e->getId(), 1)]);
}
throw $e;
}
if ($definition->isPublic()) {
continue;
}
// Remove private definition and schedule for replacement
$definition->setPublic(!$target->isPrivate());
$definition->setPrivate($target->isPrivate());
$container->setDefinition($definitionId, $definition);
$container->removeDefinition($targetId);
$replacements[$targetId] = $definitionId;
}
$this->replacements = $replacements;
parent::process($container);
$this->replacements = [];
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"// First collect all alias targets that need to be replaced",
"$",
"seenAliasTargets",
"=",
"[",
"]",
";",
"$",
"replacements",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"container... | Process the Container to replace aliases with service definitions.
@throws InvalidArgumentException if the service definition does not exist | [
"Process",
"the",
"Container",
"to",
"replace",
"aliases",
"with",
"service",
"definitions",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/ReplaceAliasByActualDefinitionPass.php#L34-L78 | train | Processes the container builder | [
30522,
2270,
3853,
2832,
1006,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
1013,
1013,
2034,
8145,
2035,
14593,
7889,
2008,
2342,
2000,
2022,
2999,
1002,
2464,
22786,
14117,
18150,
2015,
1027,
1031,
1033,
1025,
1002,
23936,
1027,
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... |
matomo-org/matomo | core/DataTable.php | DataTable.applyQueuedFilters | public function applyQueuedFilters()
{
foreach ($this->queuedFilters as $filter) {
$this->filter($filter['className'], $filter['parameters']);
}
$this->clearQueuedFilters();
} | php | public function applyQueuedFilters()
{
foreach ($this->queuedFilters as $filter) {
$this->filter($filter['className'], $filter['parameters']);
}
$this->clearQueuedFilters();
} | [
"public",
"function",
"applyQueuedFilters",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"queuedFilters",
"as",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"filter",
"(",
"$",
"filter",
"[",
"'className'",
"]",
",",
"$",
"filter",
"[",
"'parameters'... | Applies all filters that were previously queued to the table. See {@link queueFilter()}
for more information. | [
"Applies",
"all",
"filters",
"that",
"were",
"previously",
"queued",
"to",
"the",
"table",
".",
"See",
"{"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L601-L607 | train | Applies all queued filters. | [
30522,
2270,
3853,
6611,
4226,
5657,
20952,
4014,
7747,
1006,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
24240,
20952,
4014,
7747,
2004,
1002,
11307,
1007,
1063,
1002,
2023,
1011,
1028,
11307,
1006,
1002,
11307,
1031,
1005,
2465... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ParameterBag/EnvPlaceholderParameterBag.php | EnvPlaceholderParameterBag.mergeEnvPlaceholders | public function mergeEnvPlaceholders(self $bag)
{
if ($newPlaceholders = $bag->getEnvPlaceholders()) {
$this->envPlaceholders += $newPlaceholders;
foreach ($newPlaceholders as $env => $placeholders) {
$this->envPlaceholders[$env] += $placeholders;
}
}
if ($newUnusedPlaceholders = $bag->getUnusedEnvPlaceholders()) {
$this->unusedEnvPlaceholders += $newUnusedPlaceholders;
foreach ($newUnusedPlaceholders as $env => $placeholders) {
$this->unusedEnvPlaceholders[$env] += $placeholders;
}
}
} | php | public function mergeEnvPlaceholders(self $bag)
{
if ($newPlaceholders = $bag->getEnvPlaceholders()) {
$this->envPlaceholders += $newPlaceholders;
foreach ($newPlaceholders as $env => $placeholders) {
$this->envPlaceholders[$env] += $placeholders;
}
}
if ($newUnusedPlaceholders = $bag->getUnusedEnvPlaceholders()) {
$this->unusedEnvPlaceholders += $newUnusedPlaceholders;
foreach ($newUnusedPlaceholders as $env => $placeholders) {
$this->unusedEnvPlaceholders[$env] += $placeholders;
}
}
} | [
"public",
"function",
"mergeEnvPlaceholders",
"(",
"self",
"$",
"bag",
")",
"{",
"if",
"(",
"$",
"newPlaceholders",
"=",
"$",
"bag",
"->",
"getEnvPlaceholders",
"(",
")",
")",
"{",
"$",
"this",
"->",
"envPlaceholders",
"+=",
"$",
"newPlaceholders",
";",
"f... | Merges the env placeholders of another EnvPlaceholderParameterBag. | [
"Merges",
"the",
"env",
"placeholders",
"of",
"another",
"EnvPlaceholderParameterBag",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php#L101-L118 | train | Merge env placeholders with unused env placeholders | [
30522,
2270,
3853,
13590,
2368,
2615,
24759,
10732,
17794,
1006,
2969,
1002,
4524,
1007,
1063,
2065,
1006,
1002,
2047,
24759,
10732,
17794,
1027,
1002,
4524,
1011,
1028,
2131,
2368,
2615,
24759,
10732,
17794,
1006,
1007,
1007,
1063,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Controller.php | HTML_QuickForm2_Controller.getSessionContainer | public function getSessionContainer()
{
if (empty($this->sessionContainer)) {
$this->sessionContainer = new HTML_QuickForm2_Controller_SessionContainer($this);
}
return $this->sessionContainer;
} | php | public function getSessionContainer()
{
if (empty($this->sessionContainer)) {
$this->sessionContainer = new HTML_QuickForm2_Controller_SessionContainer($this);
}
return $this->sessionContainer;
} | [
"public",
"function",
"getSessionContainer",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sessionContainer",
")",
")",
"{",
"$",
"this",
"->",
"sessionContainer",
"=",
"new",
"HTML_QuickForm2_Controller_SessionContainer",
"(",
"$",
"this",
")",
... | Returns the session container with the controller data
@return HTML_QuickForm2_Controller_SessionContainer | [
"Returns",
"the",
"session",
"container",
"with",
"the",
"controller",
"data"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Controller.php#L211-L217 | train | Returns the session container | [
30522,
2270,
3853,
4152,
7971,
3258,
8663,
18249,
2121,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
5219,
8663,
18249,
2121,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
5219,
8663,
18249,
2121,
1027,
2047,
16129,
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... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php | SessionBagProxy.initialize | public function initialize(array &$array)
{
++$this->usageIndex;
$this->data[$this->bag->getStorageKey()] = &$array;
$this->bag->initialize($array);
} | php | public function initialize(array &$array)
{
++$this->usageIndex;
$this->data[$this->bag->getStorageKey()] = &$array;
$this->bag->initialize($array);
} | [
"public",
"function",
"initialize",
"(",
"array",
"&",
"$",
"array",
")",
"{",
"++",
"$",
"this",
"->",
"usageIndex",
";",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"bag",
"->",
"getStorageKey",
"(",
")",
"]",
"=",
"&",
"$",
"array",
";",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/SessionBagProxy.php#L66-L72 | train | Initializes the current bag with the passed array. | [
30522,
2270,
3853,
3988,
4697,
1006,
9140,
1004,
1002,
9140,
1007,
1063,
1009,
1009,
1002,
2023,
1011,
1028,
8192,
22254,
10288,
1025,
1002,
2023,
1011,
1028,
2951,
1031,
1002,
2023,
1011,
1028,
4524,
1011,
1028,
4152,
4263,
4270,
14839,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DomCrawler/Crawler.php | Crawler.children | public function children(/* string $selector = null */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "string $selector = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
$selector = 0 < \func_num_args() ? func_get_arg(0) : null;
if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
if (null !== $selector) {
$converter = $this->createCssSelectorConverter();
$xpath = $converter->toXPath($selector, 'child::');
return $this->filterRelativeXPath($xpath);
}
$node = $this->getNode(0)->firstChild;
return $this->createSubCrawler($node ? $this->sibling($node) : []);
} | php | public function children(/* string $selector = null */)
{
if (\func_num_args() < 1 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "string $selector = null" argument in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
$selector = 0 < \func_num_args() ? func_get_arg(0) : null;
if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
if (null !== $selector) {
$converter = $this->createCssSelectorConverter();
$xpath = $converter->toXPath($selector, 'child::');
return $this->filterRelativeXPath($xpath);
}
$node = $this->getNode(0)->firstChild;
return $this->createSubCrawler($node ? $this->sibling($node) : []);
} | [
"public",
"function",
"children",
"(",
"/* string $selector = null */",
")",
"{",
"if",
"(",
"\\",
"func_num_args",
"(",
")",
"<",
"1",
"&&",
"__CLASS__",
"!==",
"\\",
"get_class",
"(",
"$",
"this",
")",
"&&",
"__CLASS__",
"!==",
"(",
"new",
"\\",
"Reflect... | Returns the children nodes of the current selection.
@param string|null $selector An optional CSS selector to filter children
@return self
@throws \InvalidArgumentException When current node is empty
@throws \RuntimeException If the CssSelector Component is not available and $selector is provided | [
"Returns",
"the",
"children",
"nodes",
"of",
"the",
"current",
"selection",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/Crawler.php#L502-L523 | train | Returns the children of the current node list | [
30522,
2270,
3853,
2336,
1006,
1013,
1008,
5164,
1002,
27000,
1027,
19701,
1008,
1013,
1007,
1063,
2065,
1006,
1032,
4569,
2278,
1035,
16371,
2213,
1035,
12098,
5620,
1006,
1007,
1026,
1015,
1004,
1004,
1035,
1035,
2465,
1035,
1035,
999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getActiveThemeCode | public static function getActiveThemeCode()
{
$activeTheme = Config::get('cms.activeTheme');
if (App::hasDatabase()) {
try {
try {
$dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function () {
return Parameter::applyKey(self::ACTIVE_KEY)->value('value');
});
}
catch (Exception $ex) {
// Cache failed
$dbResult = Parameter::applyKey(self::ACTIVE_KEY)->value('value');
}
}
catch (Exception $ex) {
// Database failed
$dbResult = null;
}
if ($dbResult !== null && static::exists($dbResult)) {
$activeTheme = $dbResult;
}
}
/**
* @event cms.theme.getActiveTheme
* Overrides the active theme code.
*
* If a value is returned from this halting event, it will be used as the active
* theme code. Example usage:
*
* Event::listen('cms.theme.getActiveTheme', function() { return 'mytheme'; });
*
*/
$apiResult = Event::fire('cms.theme.getActiveTheme', [], true);
if ($apiResult !== null) {
$activeTheme = $apiResult;
}
if (!strlen($activeTheme)) {
throw new SystemException(Lang::get('cms::lang.theme.active.not_set'));
}
return $activeTheme;
} | php | public static function getActiveThemeCode()
{
$activeTheme = Config::get('cms.activeTheme');
if (App::hasDatabase()) {
try {
try {
$dbResult = Cache::remember(self::ACTIVE_KEY, 1440, function () {
return Parameter::applyKey(self::ACTIVE_KEY)->value('value');
});
}
catch (Exception $ex) {
// Cache failed
$dbResult = Parameter::applyKey(self::ACTIVE_KEY)->value('value');
}
}
catch (Exception $ex) {
// Database failed
$dbResult = null;
}
if ($dbResult !== null && static::exists($dbResult)) {
$activeTheme = $dbResult;
}
}
/**
* @event cms.theme.getActiveTheme
* Overrides the active theme code.
*
* If a value is returned from this halting event, it will be used as the active
* theme code. Example usage:
*
* Event::listen('cms.theme.getActiveTheme', function() { return 'mytheme'; });
*
*/
$apiResult = Event::fire('cms.theme.getActiveTheme', [], true);
if ($apiResult !== null) {
$activeTheme = $apiResult;
}
if (!strlen($activeTheme)) {
throw new SystemException(Lang::get('cms::lang.theme.active.not_set'));
}
return $activeTheme;
} | [
"public",
"static",
"function",
"getActiveThemeCode",
"(",
")",
"{",
"$",
"activeTheme",
"=",
"Config",
"::",
"get",
"(",
"'cms.activeTheme'",
")",
";",
"if",
"(",
"App",
"::",
"hasDatabase",
"(",
")",
")",
"{",
"try",
"{",
"try",
"{",
"$",
"dbResult",
... | Returns the active theme code.
By default the active theme is loaded from the cms.activeTheme parameter,
but this behavior can be overridden by the cms.theme.getActiveTheme event listener.
@return string
If the theme doesn't exist, returns null. | [
"Returns",
"the",
"active",
"theme",
"code",
".",
"By",
"default",
"the",
"active",
"theme",
"is",
"loaded",
"from",
"the",
"cms",
".",
"activeTheme",
"parameter",
"but",
"this",
"behavior",
"can",
"be",
"overridden",
"by",
"the",
"cms",
".",
"theme",
".",... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Theme.php#L148-L194 | train | Returns the active theme code. | [
30522,
2270,
10763,
3853,
2131,
19620,
10760,
4168,
16044,
1006,
1007,
1063,
1002,
3161,
10760,
4168,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
1006,
1005,
4642,
2015,
1012,
3161,
10760,
4168,
1005,
1007,
1025,
2065,
1006,
10439,
1024,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/Middleware/Authenticate.php | Authenticate.authenticate | protected function authenticate($request, array $guards)
{
if (empty($guards)) {
$guards = [null];
}
foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) {
return $this->auth->shouldUse($guard);
}
}
throw new AuthenticationException(
'Unauthenticated.', $guards, $this->redirectTo($request)
);
} | php | protected function authenticate($request, array $guards)
{
if (empty($guards)) {
$guards = [null];
}
foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) {
return $this->auth->shouldUse($guard);
}
}
throw new AuthenticationException(
'Unauthenticated.', $guards, $this->redirectTo($request)
);
} | [
"protected",
"function",
"authenticate",
"(",
"$",
"request",
",",
"array",
"$",
"guards",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"guards",
")",
")",
"{",
"$",
"guards",
"=",
"[",
"null",
"]",
";",
"}",
"foreach",
"(",
"$",
"guards",
"as",
"$",
... | Determine if the user is logged in to any of the given guards.
@param \Illuminate\Http\Request $request
@param array $guards
@return void
@throws \Illuminate\Auth\AuthenticationException | [
"Determine",
"if",
"the",
"user",
"is",
"logged",
"in",
"to",
"any",
"of",
"the",
"given",
"guards",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Middleware/Authenticate.php#L55-L70 | train | Checks if the user is authenticated. | [
30522,
5123,
3853,
14469,
3686,
1006,
1002,
5227,
1010,
9140,
1002,
4932,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
4932,
1007,
1007,
1063,
1002,
4932,
1027,
1031,
19701,
1033,
1025,
1065,
18921,
6776,
1006,
1002,
4932,
2004,
1002,
3457,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/HttpKernel.php | HttpKernel.terminate | public function terminate(Request $request, Response $response)
{
$this->dispatcher->dispatch(new TerminateEvent($this, $request, $response), KernelEvents::TERMINATE);
} | php | public function terminate(Request $request, Response $response)
{
$this->dispatcher->dispatch(new TerminateEvent($this, $request, $response), KernelEvents::TERMINATE);
} | [
"public",
"function",
"terminate",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"TerminateEvent",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"response",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpKernel.php#L86-L89 | train | Terminate the current request and response | [
30522,
2270,
3853,
20320,
1006,
5227,
1002,
5227,
1010,
3433,
1002,
3433,
1007,
1063,
1002,
2023,
1011,
1028,
18365,
2121,
1011,
1028,
18365,
1006,
2047,
20320,
18697,
3372,
1006,
1002,
2023,
1010,
1002,
5227,
1010,
1002,
3433,
1007,
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... |
matomo-org/matomo | libs/Zend/Db/Statement/Oracle.php | Zend_Db_Statement_Oracle.fetch | public function fetch($style = null, $cursor = null, $offset = null)
{
if (!$this->_stmt) {
return false;
}
if ($style === null) {
$style = $this->_fetchMode;
}
$lob_as_string = $this->getLobAsString() ? OCI_RETURN_LOBS : 0;
switch ($style) {
case Zend_Db::FETCH_NUM:
$row = oci_fetch_array($this->_stmt, OCI_NUM | OCI_RETURN_NULLS | $lob_as_string);
break;
case Zend_Db::FETCH_ASSOC:
$row = oci_fetch_array($this->_stmt, OCI_ASSOC | OCI_RETURN_NULLS | $lob_as_string);
break;
case Zend_Db::FETCH_BOTH:
$row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
break;
case Zend_Db::FETCH_OBJ:
$row = oci_fetch_object($this->_stmt);
break;
case Zend_Db::FETCH_BOUND:
$row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
if ($row !== false) {
return $this->_fetchBound($row);
}
break;
default:
/**
* @see Zend_Db_Adapter_Oracle_Exception
*/
// require_once 'Zend/Db/Statement/Oracle/Exception.php';
throw new Zend_Db_Statement_Oracle_Exception(
array(
'code' => 'HYC00',
'message' => "Invalid fetch mode '$style' specified"
)
);
break;
}
if (! $row && $error = oci_error($this->_stmt)) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
*/
// require_once 'Zend/Db/Statement/Oracle/Exception.php';
throw new Zend_Db_Statement_Oracle_Exception($error);
}
if (is_array($row) && array_key_exists('zend_db_rownum', $row)) {
unset($row['zend_db_rownum']);
}
return $row;
} | php | public function fetch($style = null, $cursor = null, $offset = null)
{
if (!$this->_stmt) {
return false;
}
if ($style === null) {
$style = $this->_fetchMode;
}
$lob_as_string = $this->getLobAsString() ? OCI_RETURN_LOBS : 0;
switch ($style) {
case Zend_Db::FETCH_NUM:
$row = oci_fetch_array($this->_stmt, OCI_NUM | OCI_RETURN_NULLS | $lob_as_string);
break;
case Zend_Db::FETCH_ASSOC:
$row = oci_fetch_array($this->_stmt, OCI_ASSOC | OCI_RETURN_NULLS | $lob_as_string);
break;
case Zend_Db::FETCH_BOTH:
$row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
break;
case Zend_Db::FETCH_OBJ:
$row = oci_fetch_object($this->_stmt);
break;
case Zend_Db::FETCH_BOUND:
$row = oci_fetch_array($this->_stmt, OCI_BOTH | OCI_RETURN_NULLS | $lob_as_string);
if ($row !== false) {
return $this->_fetchBound($row);
}
break;
default:
/**
* @see Zend_Db_Adapter_Oracle_Exception
*/
// require_once 'Zend/Db/Statement/Oracle/Exception.php';
throw new Zend_Db_Statement_Oracle_Exception(
array(
'code' => 'HYC00',
'message' => "Invalid fetch mode '$style' specified"
)
);
break;
}
if (! $row && $error = oci_error($this->_stmt)) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
*/
// require_once 'Zend/Db/Statement/Oracle/Exception.php';
throw new Zend_Db_Statement_Oracle_Exception($error);
}
if (is_array($row) && array_key_exists('zend_db_rownum', $row)) {
unset($row['zend_db_rownum']);
}
return $row;
} | [
"public",
"function",
"fetch",
"(",
"$",
"style",
"=",
"null",
",",
"$",
"cursor",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_stmt",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"style... | Fetches a row from the result set.
@param int $style OPTIONAL Fetch mode for this fetch operation.
@param int $cursor OPTIONAL Absolute, relative, or other.
@param int $offset OPTIONAL Number for absolute or relative cursors.
@return mixed Array, object, or scalar depending on fetch mode.
@throws Zend_Db_Statement_Exception | [
"Fetches",
"a",
"row",
"from",
"the",
"result",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Oracle.php#L291-L349 | train | Fetch a result from the statement | [
30522,
2270,
3853,
18584,
1006,
1002,
2806,
1027,
19701,
1010,
1002,
12731,
30524,
2806,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
2806,
1027,
1002,
2023,
1011,
1028,
1035,
18584,
5302,
3207,
1025,
1065,
1002,
8840,
2497,
1035,
2004,
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... |
octobercms/october | modules/backend/behaviors/ListController.php | ListController.listRender | public function listRender($definition = null)
{
if (!count($this->listWidgets)) {
throw new ApplicationException(Lang::get('backend::lang.list.behavior_not_ready'));
}
if (!$definition || !isset($this->listDefinitions[$definition])) {
$definition = $this->primaryDefinition;
}
$listConfig = $this->controller->listGetConfig($definition);
$vars = [
'toolbar' => null,
'filter' => null,
'list' => null,
];
if (isset($this->toolbarWidgets[$definition])) {
$vars['toolbar'] = $this->toolbarWidgets[$definition];
}
if (isset($this->filterWidgets[$definition])) {
$vars['filter'] = $this->filterWidgets[$definition];
}
$vars['list'] = $this->listWidgets[$definition];
return $this->listMakePartial('container', $vars);
} | php | public function listRender($definition = null)
{
if (!count($this->listWidgets)) {
throw new ApplicationException(Lang::get('backend::lang.list.behavior_not_ready'));
}
if (!$definition || !isset($this->listDefinitions[$definition])) {
$definition = $this->primaryDefinition;
}
$listConfig = $this->controller->listGetConfig($definition);
$vars = [
'toolbar' => null,
'filter' => null,
'list' => null,
];
if (isset($this->toolbarWidgets[$definition])) {
$vars['toolbar'] = $this->toolbarWidgets[$definition];
}
if (isset($this->filterWidgets[$definition])) {
$vars['filter'] = $this->filterWidgets[$definition];
}
$vars['list'] = $this->listWidgets[$definition];
return $this->listMakePartial('container', $vars);
} | [
"public",
"function",
"listRender",
"(",
"$",
"definition",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"listWidgets",
")",
")",
"{",
"throw",
"new",
"ApplicationException",
"(",
"Lang",
"::",
"get",
"(",
"'backend::lang.list.be... | Renders the widget collection.
@param string $definition Optional list definition.
@return string Rendered HTML for the list. | [
"Renders",
"the",
"widget",
"collection",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/ListController.php#L352-L381 | train | Render list widget | [
30522,
2270,
3853,
2862,
7389,
4063,
1006,
1002,
6210,
1027,
19701,
1007,
1063,
2065,
1006,
999,
4175,
1006,
1002,
2023,
1011,
1028,
2862,
9148,
28682,
1007,
1007,
1063,
5466,
2047,
4646,
10288,
24422,
1006,
11374,
1024,
1024,
2131,
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... |
z-song/laravel-admin | src/Grid.php | Grid.render | public function render()
{
$this->handleExportRequest(true);
try {
$this->build();
} catch (\Exception $e) {
return Handler::renderException($e);
}
return view($this->view, $this->variables())->render();
} | php | public function render()
{
$this->handleExportRequest(true);
try {
$this->build();
} catch (\Exception $e) {
return Handler::renderException($e);
}
return view($this->view, $this->variables())->render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"handleExportRequest",
"(",
"true",
")",
";",
"try",
"{",
"$",
"this",
"->",
"build",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"Handler",
":... | Get the string contents of the grid view.
@return string | [
"Get",
"the",
"string",
"contents",
"of",
"the",
"grid",
"view",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L1007-L1018 | train | Render the page | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
5047,
10288,
6442,
2890,
15500,
1006,
2995,
1007,
1025,
3046,
1063,
1002,
2023,
1011,
1028,
3857,
1006,
1007,
1025,
1065,
4608,
1006,
1032,
6453,
1002,
1041,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Console/AdminCommand.php | AdminCommand.listAdminCommands | protected function listAdminCommands()
{
$commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) {
if (Str::startsWith($key, 'admin:')) {
return [$key => $command];
}
return [];
})->toArray();
$width = $this->getColumnWidth($commands);
/** @var Command $command */
foreach ($commands as $command) {
$this->line(sprintf(" %-{$width}s %s", $command->getName(), $command->getDescription()));
}
} | php | protected function listAdminCommands()
{
$commands = collect(Artisan::all())->mapWithKeys(function ($command, $key) {
if (Str::startsWith($key, 'admin:')) {
return [$key => $command];
}
return [];
})->toArray();
$width = $this->getColumnWidth($commands);
/** @var Command $command */
foreach ($commands as $command) {
$this->line(sprintf(" %-{$width}s %s", $command->getName(), $command->getDescription()));
}
} | [
"protected",
"function",
"listAdminCommands",
"(",
")",
"{",
"$",
"commands",
"=",
"collect",
"(",
"Artisan",
"::",
"all",
"(",
")",
")",
"->",
"mapWithKeys",
"(",
"function",
"(",
"$",
"command",
",",
"$",
"key",
")",
"{",
"if",
"(",
"Str",
"::",
"s... | List all admin commands.
@return void | [
"List",
"all",
"admin",
"commands",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/AdminCommand.php#L57-L73 | train | List admin commands | [
30522,
5123,
3853,
2862,
4215,
10020,
9006,
2386,
5104,
1006,
1007,
1063,
1002,
10954,
1027,
8145,
1006,
2396,
29196,
1024,
1024,
2035,
1006,
1007,
1007,
1011,
1028,
4949,
24415,
14839,
2015,
1006,
3853,
1006,
1002,
3094,
1010,
1002,
3145,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/ControllerMetadata/ArgumentMetadata.php | ArgumentMetadata.getDefaultValue | public function getDefaultValue()
{
if (!$this->hasDefaultValue) {
throw new \LogicException(sprintf('Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this exception.', $this->name, __CLASS__));
}
return $this->defaultValue;
} | php | public function getDefaultValue()
{
if (!$this->hasDefaultValue) {
throw new \LogicException(sprintf('Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this exception.', $this->name, __CLASS__));
}
return $this->defaultValue;
} | [
"public",
"function",
"getDefaultValue",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasDefaultValue",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this excep... | Returns the default value of the argument.
@throws \LogicException if no default value is present; {@see self::hasDefaultValue()}
@return mixed | [
"Returns",
"the",
"default",
"value",
"of",
"the",
"argument",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/ControllerMetadata/ArgumentMetadata.php#L99-L106 | train | Get the default value of the argument | [
30522,
2270,
3853,
2131,
3207,
7011,
11314,
10175,
5657,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2038,
3207,
7011,
11314,
10175,
5657,
1007,
1063,
5466,
2047,
1032,
7961,
10288,
24422,
1006,
9043,
2546,
1006,
1005,
6685,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Authentication/DefaultAuthenticationFailureHandler.php | DefaultAuthenticationFailureHandler.onAuthenticationFailure | public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
if ($failureUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['failure_path_parameter'])) {
$this->options['failure_path'] = $failureUrl;
}
if (null === $this->options['failure_path']) {
$this->options['failure_path'] = $this->options['login_path'];
}
if ($this->options['failure_forward']) {
if (null !== $this->logger) {
$this->logger->debug('Authentication failure, forward triggered.', ['failure_path' => $this->options['failure_path']]);
}
$subRequest = $this->httpUtils->createRequest($request, $this->options['failure_path']);
$subRequest->attributes->set(Security::AUTHENTICATION_ERROR, $exception);
return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
if (null !== $this->logger) {
$this->logger->debug('Authentication failure, redirect triggered.', ['failure_path' => $this->options['failure_path']]);
}
$request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
return $this->httpUtils->createRedirectResponse($request, $this->options['failure_path']);
} | php | public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
if ($failureUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['failure_path_parameter'])) {
$this->options['failure_path'] = $failureUrl;
}
if (null === $this->options['failure_path']) {
$this->options['failure_path'] = $this->options['login_path'];
}
if ($this->options['failure_forward']) {
if (null !== $this->logger) {
$this->logger->debug('Authentication failure, forward triggered.', ['failure_path' => $this->options['failure_path']]);
}
$subRequest = $this->httpUtils->createRequest($request, $this->options['failure_path']);
$subRequest->attributes->set(Security::AUTHENTICATION_ERROR, $exception);
return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
if (null !== $this->logger) {
$this->logger->debug('Authentication failure, redirect triggered.', ['failure_path' => $this->options['failure_path']]);
}
$request->getSession()->set(Security::AUTHENTICATION_ERROR, $exception);
return $this->httpUtils->createRedirectResponse($request, $this->options['failure_path']);
} | [
"public",
"function",
"onAuthenticationFailure",
"(",
"Request",
"$",
"request",
",",
"AuthenticationException",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"failureUrl",
"=",
"ParameterBagUtils",
"::",
"getRequestParameterValue",
"(",
"$",
"request",
",",
"$",
"t... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationFailureHandler.php#L71-L99 | train | On authentication failure | [
30522,
2270,
3853,
2006,
4887,
10760,
16778,
10719,
7011,
4014,
5397,
1006,
5227,
1002,
5227,
1010,
27280,
10288,
24422,
1002,
6453,
1007,
1063,
2065,
1006,
1002,
4945,
3126,
2140,
1027,
16381,
16078,
21823,
4877,
1024,
1024,
2131,
2890,
15... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.php | Assets.config | public function config(array $config)
{
foreach ($config as $key => $value) {
if ($this->hasProperty($key)) {
$this->setProperty($key, $value);
} elseif (Utils::startsWith($key, 'css_') || Utils::startsWith($key, 'js_')) {
$this->pipeline_options[$key] = $value;
}
}
// Add timestamp if it's enabled
if ($this->enable_asset_timestamp) {
$this->timestamp = Grav::instance()['cache']->getKey();
}
return $this;
} | php | public function config(array $config)
{
foreach ($config as $key => $value) {
if ($this->hasProperty($key)) {
$this->setProperty($key, $value);
} elseif (Utils::startsWith($key, 'css_') || Utils::startsWith($key, 'js_')) {
$this->pipeline_options[$key] = $value;
}
}
// Add timestamp if it's enabled
if ($this->enable_asset_timestamp) {
$this->timestamp = Grav::instance()['cache']->getKey();
}
return $this;
} | [
"public",
"function",
"config",
"(",
"array",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasProperty",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
... | Set up configuration options.
All the class properties except 'js' and 'css' are accepted here.
Also, an extra option 'autoload' may be passed containing an array of
assets and/or collections that will be automatically added on startup.
@param array $config Configurable options.
@return $this | [
"Set",
"up",
"configuration",
"options",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Assets.php#L98-L114 | train | Set the config for the asset | [
30522,
2270,
3853,
9530,
8873,
2290,
1006,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
18921,
6776,
1006,
1002,
9530,
8873,
2290,
2004,
1002,
3145,
1027,
1028,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2038,
21572,
4842,
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... |
octobercms/october | modules/system/traits/ViewMaker.php | ViewMaker.makeLayout | public function makeLayout($name = null, $params = [], $throwException = true)
{
$layout = $name ?? $this->layout;
if ($layout == '') {
return '';
}
$layoutPath = $this->getViewPath($layout . '.htm', $this->layoutPath);
if (!File::exists($layoutPath)) {
if ($throwException) {
throw new SystemException(Lang::get('cms::lang.layout.not_found_name', ['name' => $layoutPath]));
}
return false;
}
return $this->makeFileContents($layoutPath, $params);
} | php | public function makeLayout($name = null, $params = [], $throwException = true)
{
$layout = $name ?? $this->layout;
if ($layout == '') {
return '';
}
$layoutPath = $this->getViewPath($layout . '.htm', $this->layoutPath);
if (!File::exists($layoutPath)) {
if ($throwException) {
throw new SystemException(Lang::get('cms::lang.layout.not_found_name', ['name' => $layoutPath]));
}
return false;
}
return $this->makeFileContents($layoutPath, $params);
} | [
"public",
"function",
"makeLayout",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"throwException",
"=",
"true",
")",
"{",
"$",
"layout",
"=",
"$",
"name",
"??",
"$",
"this",
"->",
"layout",
";",
"if",
"(",
"$",
"lay... | Render a layout.
@param string $name Specifies the layout name.
If this parameter is omitted, the $layout property will be used.
@param array $params Parameter variables to pass to the view.
@param bool $throwException Throw an exception if the layout is not found
@return mixed The layout contents, or false. | [
"Render",
"a",
"layout",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/ViewMaker.php#L139-L157 | train | Returns the layout file contents | [
30522,
2270,
3853,
2191,
8485,
5833,
1006,
1002,
2171,
1027,
19701,
1010,
1002,
11498,
5244,
1027,
1031,
1033,
1010,
1002,
5466,
10288,
24422,
1027,
2995,
1007,
1063,
1002,
9621,
1027,
1002,
2171,
1029,
1029,
1002,
2023,
1011,
1028,
9621,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/HandlerStack.php | HandlerStack.remove | public function remove($remove)
{
$this->cached = null;
$idx = is_callable($remove) ? 0 : 1;
$this->stack = array_values(array_filter(
$this->stack,
function ($tuple) use ($idx, $remove) {
return $tuple[$idx] !== $remove;
}
));
} | php | public function remove($remove)
{
$this->cached = null;
$idx = is_callable($remove) ? 0 : 1;
$this->stack = array_values(array_filter(
$this->stack,
function ($tuple) use ($idx, $remove) {
return $tuple[$idx] !== $remove;
}
));
} | [
"public",
"function",
"remove",
"(",
"$",
"remove",
")",
"{",
"$",
"this",
"->",
"cached",
"=",
"null",
";",
"$",
"idx",
"=",
"is_callable",
"(",
"$",
"remove",
")",
"?",
"0",
":",
"1",
";",
"$",
"this",
"->",
"stack",
"=",
"array_values",
"(",
"... | Remove a middleware by instance or name from the stack.
@param callable|string $remove Middleware to remove by instance or name. | [
"Remove",
"a",
"middleware",
"by",
"instance",
"or",
"name",
"from",
"the",
"stack",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/HandlerStack.php#L174-L184 | train | Remove a class or method from the stack | [
30522,
2270,
3853,
6366,
1006,
1002,
6366,
1007,
1063,
1002,
2023,
1011,
1028,
17053,
2094,
1027,
19701,
1025,
1002,
8909,
2595,
1027,
2003,
1035,
2655,
3085,
1006,
1002,
6366,
1007,
1029,
1014,
1024,
1015,
1025,
1002,
2023,
1011,
1028,
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... |
getgrav/grav | system/src/Grav/Common/Scheduler/Scheduler.php | Scheduler.getVerboseOutput | public function getVerboseOutput($type = 'text')
{
switch ($type) {
case 'text':
return implode("\n", $this->output_schedule);
case 'html':
return implode('<br>', $this->output_schedule);
case 'array':
return $this->output_schedule;
default:
throw new \InvalidArgumentException('Invalid output type');
}
} | php | public function getVerboseOutput($type = 'text')
{
switch ($type) {
case 'text':
return implode("\n", $this->output_schedule);
case 'html':
return implode('<br>', $this->output_schedule);
case 'array':
return $this->output_schedule;
default:
throw new \InvalidArgumentException('Invalid output type');
}
} | [
"public",
"function",
"getVerboseOutput",
"(",
"$",
"type",
"=",
"'text'",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'text'",
":",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"output_schedule",
")",
";",
"case",
"'html'",
... | Get the scheduler verbose output.
@param string $type Allowed: text, html, array
@return mixed The return depends on the requested $type | [
"Get",
"the",
"scheduler",
"verbose",
"output",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L204-L216 | train | Returns the output of the page | [
30522,
2270,
3853,
2131,
6299,
15853,
8780,
4904,
18780,
1006,
1002,
2828,
1027,
1005,
3793,
1005,
1007,
1063,
6942,
1006,
1002,
2828,
1007,
1063,
2553,
1005,
3793,
1005,
1024,
2709,
17727,
4135,
3207,
1006,
1000,
1032,
1050,
1000,
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... |
apache/thrift | lib/php/lib/Server/TForkingServer.php | TForkingServer.handleChild | private function handleChild(TTransport $transport)
{
try {
$inputTransport = $this->inputTransportFactory_->getTransport($transport);
$outputTransport = $this->outputTransportFactory_->getTransport($transport);
$inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport);
$outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport);
while ($this->processor_->process($inputProtocol, $outputProtocol)) {
}
@$transport->close();
} catch (TTransportException $e) {
}
exit(0);
} | php | private function handleChild(TTransport $transport)
{
try {
$inputTransport = $this->inputTransportFactory_->getTransport($transport);
$outputTransport = $this->outputTransportFactory_->getTransport($transport);
$inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport);
$outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport);
while ($this->processor_->process($inputProtocol, $outputProtocol)) {
}
@$transport->close();
} catch (TTransportException $e) {
}
exit(0);
} | [
"private",
"function",
"handleChild",
"(",
"TTransport",
"$",
"transport",
")",
"{",
"try",
"{",
"$",
"inputTransport",
"=",
"$",
"this",
"->",
"inputTransportFactory_",
"->",
"getTransport",
"(",
"$",
"transport",
")",
";",
"$",
"outputTransport",
"=",
"$",
... | Code run by the child.
@param TTransport $transport
@return void | [
"Code",
"run",
"by",
"the",
"child",
"."
] | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Server/TForkingServer.php#L81-L95 | train | Handle child transport | [
30522,
2797,
3853,
5047,
19339,
1006,
23746,
5521,
20205,
1002,
3665,
1007,
1063,
3046,
1063,
1002,
7953,
6494,
3619,
6442,
1027,
1002,
2023,
1011,
1028,
7953,
6494,
3619,
6442,
21450,
1035,
1011,
1028,
2131,
6494,
3619,
6442,
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/Console/Scheduling/CommandBuilder.php | CommandBuilder.ensureCorrectUser | protected function ensureCorrectUser(Event $event, $command)
{
return $event->user && ! windows_os() ? 'sudo -u '.$event->user.' -- sh -c \''.$command.'\'' : $command;
} | php | protected function ensureCorrectUser(Event $event, $command)
{
return $event->user && ! windows_os() ? 'sudo -u '.$event->user.' -- sh -c \''.$command.'\'' : $command;
} | [
"protected",
"function",
"ensureCorrectUser",
"(",
"Event",
"$",
"event",
",",
"$",
"command",
")",
"{",
"return",
"$",
"event",
"->",
"user",
"&&",
"!",
"windows_os",
"(",
")",
"?",
"'sudo -u '",
".",
"$",
"event",
"->",
"user",
".",
"' -- sh -c \\''",
... | Finalize the event's command syntax with the correct user.
@param \Illuminate\Console\Scheduling\Event $event
@param string $command
@return string | [
"Finalize",
"the",
"event",
"s",
"command",
"syntax",
"with",
"the",
"correct",
"user",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/CommandBuilder.php#L67-L70 | train | Ensure correct user | [
30522,
5123,
3853,
5676,
27108,
2890,
22675,
2121,
1006,
2724,
1002,
2724,
1010,
1002,
3094,
1007,
1063,
2709,
1002,
2724,
1011,
1028,
5310,
1004,
1004,
999,
3645,
1035,
9808,
1006,
30524,
1011,
1039,
1032,
1005,
1005,
1012,
1002,
3094,
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 | libs/Zend/Mail/Transport/Abstract.php | Zend_Mail_Transport_Abstract._prepareHeaders | protected function _prepareHeaders($headers)
{
if (!$this->_mail) {
/**
* @see Zend_Mail_Transport_Exception
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('Missing Zend_Mail object in _mail property');
}
$this->header = '';
foreach ($headers as $header => $content) {
if (isset($content['append'])) {
unset($content['append']);
$value = implode(',' . $this->EOL . ' ', $content);
$this->header .= $header . ': ' . $value . $this->EOL;
} else {
array_walk($content, array(get_class($this), '_formatHeader'), $header);
$this->header .= implode($this->EOL, $content) . $this->EOL;
}
}
// Sanity check on headers -- should not be > 998 characters
$sane = true;
foreach (explode($this->EOL, $this->header) as $line) {
if (strlen(trim($line)) > 998) {
$sane = false;
break;
}
}
if (!$sane) {
/**
* @see Zend_Mail_Transport_Exception
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Exception('At least one mail header line is too long');
}
} | php | protected function _prepareHeaders($headers)
{
if (!$this->_mail) {
/**
* @see Zend_Mail_Transport_Exception
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('Missing Zend_Mail object in _mail property');
}
$this->header = '';
foreach ($headers as $header => $content) {
if (isset($content['append'])) {
unset($content['append']);
$value = implode(',' . $this->EOL . ' ', $content);
$this->header .= $header . ': ' . $value . $this->EOL;
} else {
array_walk($content, array(get_class($this), '_formatHeader'), $header);
$this->header .= implode($this->EOL, $content) . $this->EOL;
}
}
// Sanity check on headers -- should not be > 998 characters
$sane = true;
foreach (explode($this->EOL, $this->header) as $line) {
if (strlen(trim($line)) > 998) {
$sane = false;
break;
}
}
if (!$sane) {
/**
* @see Zend_Mail_Transport_Exception
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Exception('At least one mail header line is too long');
}
} | [
"protected",
"function",
"_prepareHeaders",
"(",
"$",
"headers",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_mail",
")",
"{",
"/**\n * @see Zend_Mail_Transport_Exception\n */",
"// require_once 'Zend/Mail/Transport/Exception.php';",
"throw",
"new",
... | Prepare header string for use in transport
Prepares and generates {@link $header} based on the headers provided.
@param mixed $headers
@access protected
@return void
@throws Zend_Mail_Transport_Exception if any header lines exceed 998
characters | [
"Prepare",
"header",
"string",
"for",
"use",
"in",
"transport"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Transport/Abstract.php#L181-L219 | train | Prepare headers of the message | [
30522,
5123,
3853,
1035,
7374,
4974,
2545,
1006,
1002,
20346,
2015,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
5653,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2156,
16729,
2094,
1035,
5653,
1035,
3665,
1035,
6453,
1008,
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... |
octobercms/october | modules/backend/classes/ControllerBehavior.php | ControllerBehavior.hideAction | protected function hideAction($methodName)
{
if (!is_array($methodName)) {
$methodName = [$methodName];
}
$this->controller->hiddenActions = array_merge($this->controller->hiddenActions, $methodName);
} | php | protected function hideAction($methodName)
{
if (!is_array($methodName)) {
$methodName = [$methodName];
}
$this->controller->hiddenActions = array_merge($this->controller->hiddenActions, $methodName);
} | [
"protected",
"function",
"hideAction",
"(",
"$",
"methodName",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"methodName",
")",
")",
"{",
"$",
"methodName",
"=",
"[",
"$",
"methodName",
"]",
";",
"}",
"$",
"this",
"->",
"controller",
"->",
"hiddenAct... | Protects a public method from being available as an controller action.
These methods could be defined in a controller to override a behavior default action.
Such methods should be defined as public, to allow the behavior object to access it.
By default public methods of a controller are considered as actions.
To prevent this occurrence, methods should be hidden by using this method.
@param mixed $methodName Specifies a method name. | [
"Protects",
"a",
"public",
"method",
"from",
"being",
"available",
"as",
"an",
"controller",
"action",
".",
"These",
"methods",
"could",
"be",
"defined",
"in",
"a",
"controller",
"to",
"override",
"a",
"behavior",
"default",
"action",
".",
"Such",
"methods",
... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/ControllerBehavior.php#L125-L132 | train | Hide action from hidden actions array | [
30522,
5123,
3853,
5342,
18908,
3258,
1006,
1002,
4118,
18442,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
4118,
18442,
1007,
1007,
1063,
1002,
4118,
18442,
1027,
1031,
1002,
4118,
18442,
1033,
1025,
1065,
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... |
barryvdh/laravel-debugbar | src/LaravelDebugbar.php | LaravelDebugbar.modifyResponse | public function modifyResponse(Request $request, Response $response)
{
$app = $this->app;
if (!$this->isEnabled() || $this->isDebugbarRequest()) {
return $response;
}
// Show the Http Response Exception in the Debugbar, when available
if (isset($response->exception)) {
$this->addThrowable($response->exception);
}
if ($this->shouldCollect('config', false)) {
try {
$configCollector = new ConfigCollector();
$configCollector->setData($app['config']->all());
$this->addCollector($configCollector);
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
}
if ($this->app->bound(SessionManager::class)){
/** @var \Illuminate\Session\SessionManager $sessionManager */
$sessionManager = $app->make(SessionManager::class);
$httpDriver = new SymfonyHttpDriver($sessionManager, $response);
$this->setHttpDriver($httpDriver);
if ($this->shouldCollect('session') && ! $this->hasCollector('session')) {
try {
$this->addCollector(new SessionCollector($sessionManager));
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
}
} else {
$sessionManager = null;
}
if ($this->shouldCollect('symfony_request', true) && !$this->hasCollector('request')) {
try {
$this->addCollector(new RequestCollector($request, $response, $sessionManager, $this->getCurrentRequestId()));
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
}
if ($app['config']->get('debugbar.clockwork') && ! $this->hasCollector('clockwork')) {
try {
$this->addCollector(new ClockworkCollector($request, $response, $sessionManager));
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
$this->addClockworkHeaders($response);
}
if ($response->isRedirection()) {
try {
$this->stackData();
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
} elseif (
$this->isJsonRequest($request) &&
$app['config']->get('debugbar.capture_ajax', true)
) {
try {
$this->sendDataInHeaders(true);
if ($app['config']->get('debugbar.add_ajax_timing', false)) {
$this->addServerTimingHeaders($response);
}
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
} elseif (
($response->headers->has('Content-Type') &&
strpos($response->headers->get('Content-Type'), 'html') === false)
|| $request->getRequestFormat() !== 'html'
|| $response->getContent() === false
|| $this->isJsonRequest($request)
) {
try {
// Just collect + store data, don't inject it.
$this->collect();
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
} elseif ($app['config']->get('debugbar.inject', true)) {
try {
$this->injectDebugbar($response);
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
}
return $response;
} | php | public function modifyResponse(Request $request, Response $response)
{
$app = $this->app;
if (!$this->isEnabled() || $this->isDebugbarRequest()) {
return $response;
}
// Show the Http Response Exception in the Debugbar, when available
if (isset($response->exception)) {
$this->addThrowable($response->exception);
}
if ($this->shouldCollect('config', false)) {
try {
$configCollector = new ConfigCollector();
$configCollector->setData($app['config']->all());
$this->addCollector($configCollector);
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
}
if ($this->app->bound(SessionManager::class)){
/** @var \Illuminate\Session\SessionManager $sessionManager */
$sessionManager = $app->make(SessionManager::class);
$httpDriver = new SymfonyHttpDriver($sessionManager, $response);
$this->setHttpDriver($httpDriver);
if ($this->shouldCollect('session') && ! $this->hasCollector('session')) {
try {
$this->addCollector(new SessionCollector($sessionManager));
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
}
} else {
$sessionManager = null;
}
if ($this->shouldCollect('symfony_request', true) && !$this->hasCollector('request')) {
try {
$this->addCollector(new RequestCollector($request, $response, $sessionManager, $this->getCurrentRequestId()));
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
}
if ($app['config']->get('debugbar.clockwork') && ! $this->hasCollector('clockwork')) {
try {
$this->addCollector(new ClockworkCollector($request, $response, $sessionManager));
} catch (\Exception $e) {
$this->addThrowable(
new Exception(
'Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(),
$e->getCode(),
$e
)
);
}
$this->addClockworkHeaders($response);
}
if ($response->isRedirection()) {
try {
$this->stackData();
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
} elseif (
$this->isJsonRequest($request) &&
$app['config']->get('debugbar.capture_ajax', true)
) {
try {
$this->sendDataInHeaders(true);
if ($app['config']->get('debugbar.add_ajax_timing', false)) {
$this->addServerTimingHeaders($response);
}
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
} elseif (
($response->headers->has('Content-Type') &&
strpos($response->headers->get('Content-Type'), 'html') === false)
|| $request->getRequestFormat() !== 'html'
|| $response->getContent() === false
|| $this->isJsonRequest($request)
) {
try {
// Just collect + store data, don't inject it.
$this->collect();
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
} elseif ($app['config']->get('debugbar.inject', true)) {
try {
$this->injectDebugbar($response);
} catch (\Exception $e) {
$app['log']->error('Debugbar exception: ' . $e->getMessage());
}
}
return $response;
} | [
"public",
"function",
"modifyResponse",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
"(",
")",
"||",
"$",
"this",
"->",
"... | Modify the response and inject the debugbar (or data in headers)
@param \Symfony\Component\HttpFoundation\Request $request
@param \Symfony\Component\HttpFoundation\Response $response
@return \Symfony\Component\HttpFoundation\Response | [
"Modify",
"the",
"response",
"and",
"inject",
"the",
"debugbar",
"(",
"or",
"data",
"in",
"headers",
")"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/LaravelDebugbar.php#L618-L745 | train | Modify the response | [
30522,
2270,
3853,
19933,
6072,
26029,
3366,
1006,
5227,
1002,
5227,
1010,
3433,
1002,
3433,
1007,
1063,
1002,
10439,
1027,
1002,
2023,
1011,
1028,
10439,
1025,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2003,
8189,
23242,
1006,
1007,
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... |
matomo-org/matomo | libs/HTML/QuickForm2/Controller/SessionContainer.php | HTML_QuickForm2_Controller_SessionContainer.getOpaque | public function getOpaque($name)
{
return (array_key_exists('opaque', $this->data)
&& array_key_exists($name, $this->data['opaque']))
? $this->data['opaque'][$name]: null;
} | php | public function getOpaque($name)
{
return (array_key_exists('opaque', $this->data)
&& array_key_exists($name, $this->data['opaque']))
? $this->data['opaque'][$name]: null;
} | [
"public",
"function",
"getOpaque",
"(",
"$",
"name",
")",
"{",
"return",
"(",
"array_key_exists",
"(",
"'opaque'",
",",
"$",
"this",
"->",
"data",
")",
"&&",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"data",
"[",
"'opaque'",
"]",
")... | Returns a user-supplied parameter
@param string Parameter name
@return mixed | [
"Returns",
"a",
"user",
"-",
"supplied",
"parameter"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Controller/SessionContainer.php#L189-L194 | train | Get a value from the opaque array | [
30522,
2270,
3853,
2131,
29477,
4226,
1006,
1002,
2171,
1007,
1063,
2709,
1006,
9140,
1035,
3145,
1035,
6526,
1006,
1005,
28670,
1005,
1010,
1002,
2023,
1011,
1028,
2951,
1007,
1004,
1004,
9140,
1035,
3145,
1035,
6526,
1006,
1002,
2171,
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/Auth/AuthManager.php | AuthManager.createSessionDriver | public function createSessionDriver($name, $config)
{
$provider = $this->createUserProvider($config['provider'] ?? null);
$guard = new SessionGuard($name, $provider, $this->app['session.store']);
// When using the remember me functionality of the authentication services we
// will need to be set the encryption instance of the guard, which allows
// secure, encrypted cookie values to get generated for those cookies.
if (method_exists($guard, 'setCookieJar')) {
$guard->setCookieJar($this->app['cookie']);
}
if (method_exists($guard, 'setDispatcher')) {
$guard->setDispatcher($this->app['events']);
}
if (method_exists($guard, 'setRequest')) {
$guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
}
return $guard;
} | php | public function createSessionDriver($name, $config)
{
$provider = $this->createUserProvider($config['provider'] ?? null);
$guard = new SessionGuard($name, $provider, $this->app['session.store']);
// When using the remember me functionality of the authentication services we
// will need to be set the encryption instance of the guard, which allows
// secure, encrypted cookie values to get generated for those cookies.
if (method_exists($guard, 'setCookieJar')) {
$guard->setCookieJar($this->app['cookie']);
}
if (method_exists($guard, 'setDispatcher')) {
$guard->setDispatcher($this->app['events']);
}
if (method_exists($guard, 'setRequest')) {
$guard->setRequest($this->app->refresh('request', $guard, 'setRequest'));
}
return $guard;
} | [
"public",
"function",
"createSessionDriver",
"(",
"$",
"name",
",",
"$",
"config",
")",
"{",
"$",
"provider",
"=",
"$",
"this",
"->",
"createUserProvider",
"(",
"$",
"config",
"[",
"'provider'",
"]",
"??",
"null",
")",
";",
"$",
"guard",
"=",
"new",
"S... | Create a session based authentication guard.
@param string $name
@param array $config
@return \Illuminate\Auth\SessionGuard | [
"Create",
"a",
"session",
"based",
"authentication",
"guard",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/AuthManager.php#L121-L143 | train | Create a session guard | [
30522,
2270,
3853,
9005,
7971,
3258,
23663,
2099,
1006,
1002,
2171,
1010,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
10802,
1027,
1002,
2023,
1011,
1028,
3443,
20330,
21572,
17258,
2121,
1006,
1002,
9530,
8873,
2290,
1031,
1005,
10802,
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... |
slimphp/Slim | Slim/Http/UploadedFile.php | UploadedFile.getStream | public function getStream()
{
if ($this->moved) {
throw new RuntimeException(sprintf('Uploaded file %s has already been moved', $this->name));
}
if ($this->stream === null) {
$this->stream = new Stream(fopen($this->file, 'r'));
}
return $this->stream;
} | php | public function getStream()
{
if ($this->moved) {
throw new RuntimeException(sprintf('Uploaded file %s has already been moved', $this->name));
}
if ($this->stream === null) {
$this->stream = new Stream(fopen($this->file, 'r'));
}
return $this->stream;
} | [
"public",
"function",
"getStream",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"moved",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Uploaded file %s has already been moved'",
",",
"$",
"this",
"->",
"name",
")",
")",
";",
"}",
"if... | Retrieve a stream representing the uploaded file.
This method MUST return a StreamInterface instance, representing the
uploaded file. The purpose of this method is to allow utilizing native PHP
stream functionality to manipulate the file upload, such as
stream_copy_to_stream() (though the result will need to be decorated in a
native PHP stream wrapper to work with such functions).
If the moveTo() method has been called previously, this method MUST raise
an exception.
@return StreamInterface
@throws RuntimeException in cases when no stream is available or can be created. | [
"Retrieve",
"a",
"stream",
"representing",
"the",
"uploaded",
"file",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/UploadedFile.php#L183-L193 | train | Get the stream | [
30522,
2270,
3853,
4152,
25379,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2333,
1007,
1063,
5466,
2047,
2448,
7292,
10288,
24422,
1006,
9043,
2546,
1006,
1005,
21345,
5371,
1003,
1055,
2038,
2525,
2042,
2333,
1005,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/API.php | API.getSitesIdWithVisits | public function getSitesIdWithVisits($timestamp = false)
{
Piwik::checkUserHasSuperUserAccess();
if (empty($timestamp)) $timestamp = time();
$time = Date::factory((int)$timestamp)->getDatetime();
$now = Date::now()->addHour(1)->getDatetime();
$result = $this->getModel()->getSitesWithVisits($time, $now);
$idSites = array();
foreach ($result as $idSite) {
$idSites[] = $idSite['idsite'];
}
return $idSites;
} | php | public function getSitesIdWithVisits($timestamp = false)
{
Piwik::checkUserHasSuperUserAccess();
if (empty($timestamp)) $timestamp = time();
$time = Date::factory((int)$timestamp)->getDatetime();
$now = Date::now()->addHour(1)->getDatetime();
$result = $this->getModel()->getSitesWithVisits($time, $now);
$idSites = array();
foreach ($result as $idSite) {
$idSites[] = $idSite['idsite'];
}
return $idSites;
} | [
"public",
"function",
"getSitesIdWithVisits",
"(",
"$",
"timestamp",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"timestamp",
")",
")",
"$",
"timestamp",
"=",
"time",
"(",
")",
";",
"... | Returns the list of the website IDs that received some visits since the specified timestamp.
Requires Super User access.
@param bool|int $timestamp
@return array The list of website IDs
@deprecated since 2.15 This method will be removed in Matomo 3.0, there is no replacement. | [
"Returns",
"the",
"list",
"of",
"the",
"website",
"IDs",
"that",
"received",
"some",
"visits",
"since",
"the",
"specified",
"timestamp",
".",
"Requires",
"Super",
"User",
"access",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L317-L334 | train | Returns the list of all the websites that have visits for the given timestamp | [
30522,
2270,
3853,
4152,
7616,
3593,
24415,
11365,
12762,
1006,
1002,
2335,
15464,
2361,
1027,
6270,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1025,
2065,
1006,
4064,
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... |
symfony/symfony | src/Symfony/Component/Console/Terminal.php | Terminal.getWidth | public function getWidth()
{
$width = getenv('COLUMNS');
if (false !== $width) {
return (int) trim($width);
}
if (null === self::$width) {
self::initDimensions();
}
return self::$width ?: 80;
} | php | public function getWidth()
{
$width = getenv('COLUMNS');
if (false !== $width) {
return (int) trim($width);
}
if (null === self::$width) {
self::initDimensions();
}
return self::$width ?: 80;
} | [
"public",
"function",
"getWidth",
"(",
")",
"{",
"$",
"width",
"=",
"getenv",
"(",
"'COLUMNS'",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"width",
")",
"{",
"return",
"(",
"int",
")",
"trim",
"(",
"$",
"width",
")",
";",
"}",
"if",
"(",
"null",
... | Gets the terminal width.
@return int | [
"Gets",
"the",
"terminal",
"width",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Terminal.php#L24-L36 | train | Get the width of the terminal. | [
30522,
2270,
3853,
2131,
9148,
11927,
2232,
1006,
1007,
1063,
1002,
9381,
1027,
2131,
2368,
2615,
1006,
1005,
7753,
1005,
1007,
1025,
2065,
1006,
6270,
999,
1027,
1027,
1002,
9381,
1007,
1063,
2709,
1006,
20014,
1007,
12241,
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... |
octobercms/october | modules/backend/formwidgets/FileUpload.php | FileUpload.onRemoveAttachment | public function onRemoveAttachment()
{
$fileModel = $this->getRelationModel();
if (($fileId = post('file_id')) && ($file = $fileModel::find($fileId))) {
$this->getRelationObject()->remove($file, $this->sessionKey);
}
} | php | public function onRemoveAttachment()
{
$fileModel = $this->getRelationModel();
if (($fileId = post('file_id')) && ($file = $fileModel::find($fileId))) {
$this->getRelationObject()->remove($file, $this->sessionKey);
}
} | [
"public",
"function",
"onRemoveAttachment",
"(",
")",
"{",
"$",
"fileModel",
"=",
"$",
"this",
"->",
"getRelationModel",
"(",
")",
";",
"if",
"(",
"(",
"$",
"fileId",
"=",
"post",
"(",
"'file_id'",
")",
")",
"&&",
"(",
"$",
"file",
"=",
"$",
"fileMod... | Removes a file attachment. | [
"Removes",
"a",
"file",
"attachment",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/FileUpload.php#L277-L283 | train | On remove attachment | [
30522,
2270,
3853,
2006,
28578,
21818,
19321,
6776,
3672,
1006,
1007,
1063,
1002,
5371,
5302,
9247,
1027,
1002,
2023,
1011,
1028,
2131,
16570,
3370,
5302,
9247,
1006,
1007,
1025,
2065,
1006,
1006,
1002,
5371,
3593,
1027,
2695,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php | FileinfoMimeTypeGuesser.guess | public function guess($path)
{
if (!is_file($path)) {
throw new FileNotFoundException($path);
}
if (!is_readable($path)) {
throw new AccessDeniedException($path);
}
if (!self::isSupported()) {
return;
}
if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) {
return;
}
return $finfo->file($path);
} | php | public function guess($path)
{
if (!is_file($path)) {
throw new FileNotFoundException($path);
}
if (!is_readable($path)) {
throw new AccessDeniedException($path);
}
if (!self::isSupported()) {
return;
}
if (!$finfo = new \finfo(FILEINFO_MIME_TYPE, $this->magicFile)) {
return;
}
return $finfo->file($path);
} | [
"public",
"function",
"guess",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"$",
"path",
")",
";",
"}",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"path",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php#L54-L73 | train | Guesses the file type from the given path | [
30522,
2270,
3853,
3984,
1006,
1002,
4130,
1007,
1063,
2065,
1006,
999,
2003,
1035,
5371,
1006,
1002,
4130,
1007,
1007,
1063,
5466,
2047,
5371,
17048,
14876,
8630,
10288,
24422,
1006,
1002,
4130,
1007,
1025,
1065,
2065,
1006,
999,
2003,
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/Cache/CacheItem.php | CacheItem.expiresAt | public function expiresAt($expiration)
{
if (null === $expiration) {
$this->expiry = $this->defaultLifetime > 0 ? microtime(true) + $this->defaultLifetime : null;
} elseif ($expiration instanceof \DateTimeInterface) {
$this->expiry = (float) $expiration->format('U.u');
} else {
throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given', \is_object($expiration) ? \get_class($expiration) : \gettype($expiration)));
}
return $this;
} | php | public function expiresAt($expiration)
{
if (null === $expiration) {
$this->expiry = $this->defaultLifetime > 0 ? microtime(true) + $this->defaultLifetime : null;
} elseif ($expiration instanceof \DateTimeInterface) {
$this->expiry = (float) $expiration->format('U.u');
} else {
throw new InvalidArgumentException(sprintf('Expiration date must implement DateTimeInterface or be null, "%s" given', \is_object($expiration) ? \get_class($expiration) : \gettype($expiration)));
}
return $this;
} | [
"public",
"function",
"expiresAt",
"(",
"$",
"expiration",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"expiration",
")",
"{",
"$",
"this",
"->",
"expiry",
"=",
"$",
"this",
"->",
"defaultLifetime",
">",
"0",
"?",
"microtime",
"(",
"true",
")",
"+",
"$"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/CacheItem.php#L74-L85 | train | Set expiration date | [
30522,
2270,
3853,
4654,
20781,
16846,
1006,
1002,
4654,
16781,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
4654,
16781,
1007,
1063,
1002,
2023,
1011,
1028,
4654,
8197,
2854,
1027,
30524,
7292,
18447,
2121,
12172,
1007,
1063,
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/backend/classes/FormField.php | FormField.displayAs | public function displayAs($type, $config = [])
{
$this->type = strtolower($type) ?: $this->type;
$this->config = $this->evalConfig($config);
return $this;
} | php | public function displayAs($type, $config = [])
{
$this->type = strtolower($type) ?: $this->type;
$this->config = $this->evalConfig($config);
return $this;
} | [
"public",
"function",
"displayAs",
"(",
"$",
"type",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
"?",
":",
"$",
"this",
"->",
"type",
";",
"$",
"this",
"->",
"config",
"=",
"... | Specifies a field control rendering mode. Supported modes are:
- text - creates a text field. Default for varchar column types.
- textarea - creates a textarea control. Default for text column types.
- dropdown - creates a drop-down list. Default for reference-based columns.
- radio - creates a set of radio buttons.
- checkbox - creates a single checkbox.
- checkboxlist - creates a checkbox list.
- switch - creates a switch field.
@param string $type Specifies a render mode as described above
@param array $config A list of render mode specific config. | [
"Specifies",
"a",
"field",
"control",
"rendering",
"mode",
".",
"Supported",
"modes",
"are",
":",
"-",
"text",
"-",
"creates",
"a",
"text",
"field",
".",
"Default",
"for",
"varchar",
"column",
"types",
".",
"-",
"textarea",
"-",
"creates",
"a",
"textarea",... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L255-L261 | train | Display as type and config | [
30522,
2270,
3853,
4653,
3022,
1006,
1002,
2828,
1010,
1002,
9530,
8873,
2290,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
2828,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
2828,
1007,
1029,
1024,
1002,
2023,
1011,
1028,
2828,
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/MiniProgram/AppCode/Client.php | Client.getStream | protected function getStream(string $endpoint, array $params)
{
$response = $this->requestRaw($endpoint, 'POST', ['json' => $params]);
if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
return StreamResponse::buildFromPsrResponse($response);
}
return $this->castResponseToType($response, $this->app['config']->get('response_type'));
} | php | protected function getStream(string $endpoint, array $params)
{
$response = $this->requestRaw($endpoint, 'POST', ['json' => $params]);
if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
return StreamResponse::buildFromPsrResponse($response);
}
return $this->castResponseToType($response, $this->app['config']->get('response_type'));
} | [
"protected",
"function",
"getStream",
"(",
"string",
"$",
"endpoint",
",",
"array",
"$",
"params",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"requestRaw",
"(",
"$",
"endpoint",
",",
"'POST'",
",",
"[",
"'json'",
"=>",
"$",
"params",
"]",
")",
... | Get stream.
@param string $endpoint
@param array $params
@return \EasyWeChat\Kernel\Http\StreamResponse | [
"Get",
"stream",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/MiniProgram/AppCode/Client.php#L79-L88 | train | Get stream from the server | [
30522,
5123,
3853,
4152,
25379,
1006,
5164,
1002,
2203,
8400,
1010,
9140,
1002,
11498,
5244,
1007,
1063,
1002,
3433,
1027,
1002,
2023,
1011,
1028,
5227,
2527,
2860,
1006,
1002,
2203,
8400,
1010,
1005,
2695,
1005,
1010,
1031,
1005,
1046,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.