repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
z-song/laravel-admin | src/Form/Field.php | Field.checked | public function checked($checked = [])
{
if ($checked instanceof Arrayable) {
$checked = $checked->toArray();
}
$this->checked = array_merge($this->checked, $checked);
return $this;
} | php | public function checked($checked = [])
{
if ($checked instanceof Arrayable) {
$checked = $checked->toArray();
}
$this->checked = array_merge($this->checked, $checked);
return $this;
} | [
"public",
"function",
"checked",
"(",
"$",
"checked",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"checked",
"instanceof",
"Arrayable",
")",
"{",
"$",
"checked",
"=",
"$",
"checked",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"this",
"->",
"checked",
"... | Set the field option checked.
@param array $checked
@return $this | [
"Set",
"the",
"field",
"option",
"checked",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field.php#L453-L462 | train | Add checked items to the list | [
30522,
2270,
3853,
7039,
1006,
1002,
7039,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
7039,
6013,
11253,
9140,
3085,
1007,
1063,
1002,
7039,
1027,
1002,
7039,
1011,
1028,
2000,
2906,
9447,
1006,
1007,
1025,
1065,
1002,
2023,
1011,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Http/HttpUtils.php | HttpUtils.generateUri | public function generateUri($request, $path)
{
if (0 === strpos($path, 'http') || !$path) {
return $path;
}
if ('/' === $path[0]) {
return $request->getUriForPath($path);
}
if (null === $this->urlGenerator) {
throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.');
}
$url = $this->urlGenerator->generate($path, $request->attributes->all(), UrlGeneratorInterface::ABSOLUTE_URL);
// unnecessary query string parameters must be removed from URL
// (ie. query parameters that are presents in $attributes)
// fortunately, they all are, so we have to remove entire query string
$position = strpos($url, '?');
if (false !== $position) {
$fragment = parse_url($url, PHP_URL_FRAGMENT);
$url = substr($url, 0, $position);
// fragment must be preserved
if ($fragment) {
$url .= "#$fragment";
}
}
return $url;
} | php | public function generateUri($request, $path)
{
if (0 === strpos($path, 'http') || !$path) {
return $path;
}
if ('/' === $path[0]) {
return $request->getUriForPath($path);
}
if (null === $this->urlGenerator) {
throw new \LogicException('You must provide a UrlGeneratorInterface instance to be able to use routes.');
}
$url = $this->urlGenerator->generate($path, $request->attributes->all(), UrlGeneratorInterface::ABSOLUTE_URL);
// unnecessary query string parameters must be removed from URL
// (ie. query parameters that are presents in $attributes)
// fortunately, they all are, so we have to remove entire query string
$position = strpos($url, '?');
if (false !== $position) {
$fragment = parse_url($url, PHP_URL_FRAGMENT);
$url = substr($url, 0, $position);
// fragment must be preserved
if ($fragment) {
$url .= "#$fragment";
}
}
return $url;
} | [
"public",
"function",
"generateUri",
"(",
"$",
"request",
",",
"$",
"path",
")",
"{",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"path",
",",
"'http'",
")",
"||",
"!",
"$",
"path",
")",
"{",
"return",
"$",
"path",
";",
"}",
"if",
"(",
"'/'",
"=... | Generates a URI, based on the given path or absolute URL.
@param Request $request A Request instance
@param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
@return string An absolute URL
@throws \LogicException | [
"Generates",
"a",
"URI",
"based",
"on",
"the",
"given",
"path",
"or",
"absolute",
"URL",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/HttpUtils.php#L154-L184 | train | Generate a URL based on the request and path | [
30522,
2270,
3853,
9699,
9496,
1006,
1002,
5227,
1010,
1002,
4130,
1007,
1063,
2065,
1006,
1014,
1027,
1027,
1027,
2358,
14536,
2891,
1006,
1002,
4130,
1010,
1005,
8299,
1005,
1007,
1064,
1064,
999,
1002,
4130,
1007,
1063,
2709,
1002,
413... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Sqlite.php | Zend_Cache_Backend_Sqlite.getTags | public function getTags()
{
$this->_checkAndBuildStructure();
$res = $this->_query("SELECT DISTINCT(name) AS name FROM tag");
$result = array();
while ($id = @sqlite_fetch_single($res)) {
$result[] = $id;
}
return $result;
} | php | public function getTags()
{
$this->_checkAndBuildStructure();
$res = $this->_query("SELECT DISTINCT(name) AS name FROM tag");
$result = array();
while ($id = @sqlite_fetch_single($res)) {
$result[] = $id;
}
return $result;
} | [
"public",
"function",
"getTags",
"(",
")",
"{",
"$",
"this",
"->",
"_checkAndBuildStructure",
"(",
")",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"_query",
"(",
"\"SELECT DISTINCT(name) AS name FROM tag\"",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
"... | Return an array of stored tags
@return array array of stored tags (string) | [
"Return",
"an",
"array",
"of",
"stored",
"tags"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Sqlite.php#L247-L256 | train | Returns all the tags in the tree | [
30522,
2270,
3853,
2131,
15900,
2015,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
4638,
5685,
8569,
4014,
5104,
18300,
5397,
1006,
1007,
1025,
1002,
24501,
1027,
1002,
2023,
1011,
1028,
1035,
23032,
1006,
1000,
7276,
5664,
1006,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/Card/GeneralCardClient.php | GeneralCardClient.deactivate | public function deactivate(string $cardId, string $code)
{
$params = [
'card_id' => $cardId,
'code' => $code,
];
return $this->httpPostJson('card/generalcard/unactivate', $params);
} | php | public function deactivate(string $cardId, string $code)
{
$params = [
'card_id' => $cardId,
'code' => $code,
];
return $this->httpPostJson('card/generalcard/unactivate', $params);
} | [
"public",
"function",
"deactivate",
"(",
"string",
"$",
"cardId",
",",
"string",
"$",
"code",
")",
"{",
"$",
"params",
"=",
"[",
"'card_id'",
"=>",
"$",
"cardId",
",",
"'code'",
"=>",
"$",
"code",
",",
"]",
";",
"return",
"$",
"this",
"->",
"httpPost... | 通用卡撤销激活.
@param string $cardId
@param string $code
@return mixed | [
"通用卡撤销激活",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Card/GeneralCardClient.php#L41-L49 | train | Deactivate a card | [
30522,
2270,
3853,
26709,
6593,
21466,
1006,
5164,
1002,
4003,
3593,
1010,
5164,
1002,
3642,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
4003,
1035,
8909,
1005,
1027,
1028,
1002,
4003,
3593,
1010,
1005,
3642,
1005,
1027,
1028,
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/Session/Middleware/StartSession.php | StartSession.collectGarbage | protected function collectGarbage(Session $session)
{
$config = $this->manager->getSessionConfig();
// Here we will see if this request hits the garbage collection lottery by hitting
// the odds needed to perform garbage collection on any given request. If we do
// hit it, we'll call this handler to let it delete all the expired sessions.
if ($this->configHitsLottery($config)) {
$session->getHandler()->gc($this->getSessionLifetimeInSeconds());
}
} | php | protected function collectGarbage(Session $session)
{
$config = $this->manager->getSessionConfig();
// Here we will see if this request hits the garbage collection lottery by hitting
// the odds needed to perform garbage collection on any given request. If we do
// hit it, we'll call this handler to let it delete all the expired sessions.
if ($this->configHitsLottery($config)) {
$session->getHandler()->gc($this->getSessionLifetimeInSeconds());
}
} | [
"protected",
"function",
"collectGarbage",
"(",
"Session",
"$",
"session",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"manager",
"->",
"getSessionConfig",
"(",
")",
";",
"// Here we will see if this request hits the garbage collection lottery by hitting",
"// the od... | Remove the garbage from the session if necessary.
@param \Illuminate\Contracts\Session\Session $session
@return void | [
"Remove",
"the",
"garbage",
"from",
"the",
"session",
"if",
"necessary",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Session/Middleware/StartSession.php#L104-L114 | train | Collect the expired sessions | [
30522,
5123,
3853,
8145,
6843,
16078,
2063,
1006,
5219,
1002,
5219,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
1002,
2023,
1011,
1028,
3208,
1011,
1028,
4152,
7971,
3258,
8663,
8873,
2290,
1006,
1007,
1025,
1013,
1013,
2182,
2057,
2097,
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... |
z-song/laravel-admin | src/Layout/Row.php | Row.build | public function build()
{
$this->startRow();
foreach ($this->columns as $column) {
$column->build();
}
$this->endRow();
} | php | public function build()
{
$this->startRow();
foreach ($this->columns as $column) {
$column->build();
}
$this->endRow();
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"startRow",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"$",
"column",
"->",
"build",
"(",
")",
";",
"}",
"$",
"this",
"->",
"endRow"... | Build row column. | [
"Build",
"row",
"column",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Layout/Row.php#L75-L84 | train | Build the table | [
30522,
2270,
3853,
3857,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2707,
10524,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
7753,
2004,
1002,
5930,
1007,
1063,
1002,
5930,
1011,
1028,
3857,
1006,
1007,
1025,
1065,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php | MonthTransformer.getReverseMatchingRegExp | public function getReverseMatchingRegExp(int $length): string
{
switch ($length) {
case 1:
$regExp = '\d{1,2}';
break;
case 3:
$regExp = implode('|', self::$shortMonths);
break;
case 4:
$regExp = implode('|', self::$months);
break;
case 5:
$regExp = '[JFMASOND]';
break;
default:
$regExp = '\d{'.$length.'}';
break;
}
return $regExp;
} | php | public function getReverseMatchingRegExp(int $length): string
{
switch ($length) {
case 1:
$regExp = '\d{1,2}';
break;
case 3:
$regExp = implode('|', self::$shortMonths);
break;
case 4:
$regExp = implode('|', self::$months);
break;
case 5:
$regExp = '[JFMASOND]';
break;
default:
$regExp = '\d{'.$length.'}';
break;
}
return $regExp;
} | [
"public",
"function",
"getReverseMatchingRegExp",
"(",
"int",
"$",
"length",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"length",
")",
"{",
"case",
"1",
":",
"$",
"regExp",
"=",
"'\\d{1,2}'",
";",
"break",
";",
"case",
"3",
":",
"$",
"regExp",
"=",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php#L91-L112 | train | Get Reverse Matching Reg Exp | [
30522,
2270,
3853,
2131,
2890,
16070,
18900,
8450,
2890,
3351,
2595,
2361,
1006,
20014,
1002,
3091,
1007,
1024,
5164,
1063,
6942,
1006,
1002,
3091,
1007,
1063,
2553,
1015,
1024,
1002,
19723,
10288,
2361,
1027,
1005,
1032,
1040,
1063,
1015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/GeoIPAutoUpdater.php | GeoIPAutoUpdater.unzipDownloadedFile | public static function unzipDownloadedFile($path, $unlink = false)
{
$parts = explode('.', basename($path));
$filenameStart = $parts[0];
$dbFilename = $filenameStart . '.dat';
$tempFilename = $filenameStart . '.dat.new';
$outputPath = GeoIp::getPathForGeoIpDatabase($tempFilename);
// extract file
if (substr($path, -7, 7) == '.tar.gz') {
// find the .dat file in the tar archive
$unzip = Unzip::factory('tar.gz', $path);
$content = $unzip->listContent();
if (empty($content)) {
throw new Exception(Piwik::translate('UserCountry_CannotListContent',
array("'$path'", $unzip->errorInfo())));
}
$datFile = null;
foreach ($content as $info) {
$archivedPath = $info['filename'];
if (basename($archivedPath) === $dbFilename) {
$datFile = $archivedPath;
}
}
if ($datFile === null) {
throw new Exception(Piwik::translate('UserCountry_CannotFindGeoIPDatabaseInArchive',
array($dbFilename, "'$path'")));
}
// extract JUST the .dat file
$unzipped = $unzip->extractInString($datFile);
if (empty($unzipped)) {
throw new Exception(Piwik::translate('UserCountry_CannotUnzipDatFile',
array("'$path'", $unzip->errorInfo())));
}
// write unzipped to file
$fd = fopen($outputPath, 'wb');
fwrite($fd, $unzipped);
fclose($fd);
} else if (substr($path, -3, 3) == '.gz') {
$unzip = Unzip::factory('gz', $path);
$success = $unzip->extract($outputPath);
if ($success !== true) {
throw new Exception(Piwik::translate('UserCountry_CannotUnzipDatFile',
array("'$path'", $unzip->errorInfo())));
}
} else {
$ext = end(explode(basename($path), '.', 2));
throw new Exception(Piwik::translate('UserCountry_UnsupportedArchiveType', "'$ext'"));
}
try {
// test that the new archive is a valid GeoIP database
$dbType = GeoIp::getGeoIPDatabaseTypeFromFilename($dbFilename);
if ($dbType === false) // sanity check
{
throw new Exception("Unexpected GeoIP archive file name '$path'.");
}
$customDbNames = array(
'loc' => array(),
'isp' => array(),
'org' => array()
);
$customDbNames[$dbType] = array($tempFilename);
$phpProvider = new Php($customDbNames);
$location = self::getTestLocationCatchPhpErrors($phpProvider);
if (empty($location)
|| self::$unzipPhpError !== null
) {
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
Log::info("GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
" GeoIP database: %s: %s on line %s of %s.", $errno, $errstr, $errline, $errfile);
}
throw new Exception(Piwik::translate('UserCountry_ThisUrlIsNotAValidGeoIPDB'));
}
// delete the existing GeoIP database (if any) and rename the downloaded file
$oldDbFile = GeoIp::getPathForGeoIpDatabase($dbFilename);
if (file_exists($oldDbFile)) {
unlink($oldDbFile);
}
$tempFile = GeoIp::getPathForGeoIpDatabase($tempFilename);
if (@rename($tempFile, $oldDbFile) !== true) {
//In case the $tempfile cannot be renamed, we copy the file.
copy($tempFile, $oldDbFile);
unlink($tempFile);
}
// delete original archive
if ($unlink) {
unlink($path);
}
} catch (Exception $ex) {
// remove downloaded files
if (file_exists($outputPath)) {
unlink($outputPath);
}
unlink($path);
throw $ex;
}
} | php | public static function unzipDownloadedFile($path, $unlink = false)
{
$parts = explode('.', basename($path));
$filenameStart = $parts[0];
$dbFilename = $filenameStart . '.dat';
$tempFilename = $filenameStart . '.dat.new';
$outputPath = GeoIp::getPathForGeoIpDatabase($tempFilename);
// extract file
if (substr($path, -7, 7) == '.tar.gz') {
// find the .dat file in the tar archive
$unzip = Unzip::factory('tar.gz', $path);
$content = $unzip->listContent();
if (empty($content)) {
throw new Exception(Piwik::translate('UserCountry_CannotListContent',
array("'$path'", $unzip->errorInfo())));
}
$datFile = null;
foreach ($content as $info) {
$archivedPath = $info['filename'];
if (basename($archivedPath) === $dbFilename) {
$datFile = $archivedPath;
}
}
if ($datFile === null) {
throw new Exception(Piwik::translate('UserCountry_CannotFindGeoIPDatabaseInArchive',
array($dbFilename, "'$path'")));
}
// extract JUST the .dat file
$unzipped = $unzip->extractInString($datFile);
if (empty($unzipped)) {
throw new Exception(Piwik::translate('UserCountry_CannotUnzipDatFile',
array("'$path'", $unzip->errorInfo())));
}
// write unzipped to file
$fd = fopen($outputPath, 'wb');
fwrite($fd, $unzipped);
fclose($fd);
} else if (substr($path, -3, 3) == '.gz') {
$unzip = Unzip::factory('gz', $path);
$success = $unzip->extract($outputPath);
if ($success !== true) {
throw new Exception(Piwik::translate('UserCountry_CannotUnzipDatFile',
array("'$path'", $unzip->errorInfo())));
}
} else {
$ext = end(explode(basename($path), '.', 2));
throw new Exception(Piwik::translate('UserCountry_UnsupportedArchiveType', "'$ext'"));
}
try {
// test that the new archive is a valid GeoIP database
$dbType = GeoIp::getGeoIPDatabaseTypeFromFilename($dbFilename);
if ($dbType === false) // sanity check
{
throw new Exception("Unexpected GeoIP archive file name '$path'.");
}
$customDbNames = array(
'loc' => array(),
'isp' => array(),
'org' => array()
);
$customDbNames[$dbType] = array($tempFilename);
$phpProvider = new Php($customDbNames);
$location = self::getTestLocationCatchPhpErrors($phpProvider);
if (empty($location)
|| self::$unzipPhpError !== null
) {
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
Log::info("GeoIPAutoUpdater: Encountered PHP error when testing newly downloaded" .
" GeoIP database: %s: %s on line %s of %s.", $errno, $errstr, $errline, $errfile);
}
throw new Exception(Piwik::translate('UserCountry_ThisUrlIsNotAValidGeoIPDB'));
}
// delete the existing GeoIP database (if any) and rename the downloaded file
$oldDbFile = GeoIp::getPathForGeoIpDatabase($dbFilename);
if (file_exists($oldDbFile)) {
unlink($oldDbFile);
}
$tempFile = GeoIp::getPathForGeoIpDatabase($tempFilename);
if (@rename($tempFile, $oldDbFile) !== true) {
//In case the $tempfile cannot be renamed, we copy the file.
copy($tempFile, $oldDbFile);
unlink($tempFile);
}
// delete original archive
if ($unlink) {
unlink($path);
}
} catch (Exception $ex) {
// remove downloaded files
if (file_exists($outputPath)) {
unlink($outputPath);
}
unlink($path);
throw $ex;
}
} | [
"public",
"static",
"function",
"unzipDownloadedFile",
"(",
"$",
"path",
",",
"$",
"unlink",
"=",
"false",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"basename",
"(",
"$",
"path",
")",
")",
";",
"$",
"filenameStart",
"=",
"$",
"parts",
... | Unzips a downloaded GeoIP database. Only unzips .gz & .tar.gz files.
@param string $path Path to zipped file.
@param bool $unlink Whether to unlink archive or not.
@throws Exception | [
"Unzips",
"a",
"downloaded",
"GeoIP",
"database",
".",
"Only",
"unzips",
".",
"gz",
"&",
".",
"tar",
".",
"gz",
"files",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/GeoIPAutoUpdater.php#L190-L305 | train | Unzips a file containing a GeoIP database. | [
30522,
2270,
10763,
3853,
4895,
5831,
17299,
12384,
17468,
8873,
2571,
1006,
1002,
4130,
1010,
1002,
4895,
13767,
1027,
6270,
1007,
1063,
1002,
3033,
1027,
15044,
1006,
1005,
1012,
1005,
1010,
2918,
18442,
1006,
1002,
4130,
1007,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Collection.php | Collection.map | public function map(callable $callback)
{
$result = parent::map($callback);
return $result->contains(function ($item) {
return ! $item instanceof Model;
}) ? $result->toBase() : $result;
} | php | public function map(callable $callback)
{
$result = parent::map($callback);
return $result->contains(function ($item) {
return ! $item instanceof Model;
}) ? $result->toBase() : $result;
} | [
"public",
"function",
"map",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"map",
"(",
"$",
"callback",
")",
";",
"return",
"$",
"result",
"->",
"contains",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"!",... | Run a map over each of the items.
@param callable $callback
@return \Illuminate\Support\Collection|static | [
"Run",
"a",
"map",
"over",
"each",
"of",
"the",
"items",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Collection.php#L252-L259 | train | Map the items of the collection to a single value. | [
30522,
2270,
3853,
4949,
1006,
2655,
3085,
1002,
2655,
5963,
1007,
1063,
1002,
2765,
1027,
6687,
1024,
1024,
4949,
1006,
1002,
2655,
5963,
1007,
1025,
2709,
1002,
2765,
1011,
1028,
3397,
1006,
3853,
1006,
1002,
8875,
1007,
1063,
2709,
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... |
symfony/symfony | src/Symfony/Component/HttpClient/CurlHttpClient.php | CurlHttpClient.readRequestBody | private static function readRequestBody(int $length, \Closure $body, string &$buffer, bool &$eof): string
{
if (!$eof && \strlen($buffer) < $length) {
if (!\is_string($data = $body($length))) {
throw new TransportException(sprintf('The return value of the "body" option callback must be a string, %s returned.', \gettype($data)));
}
$buffer .= $data;
$eof = '' === $data;
}
$data = substr($buffer, 0, $length);
$buffer = substr($buffer, $length);
return $data;
} | php | private static function readRequestBody(int $length, \Closure $body, string &$buffer, bool &$eof): string
{
if (!$eof && \strlen($buffer) < $length) {
if (!\is_string($data = $body($length))) {
throw new TransportException(sprintf('The return value of the "body" option callback must be a string, %s returned.', \gettype($data)));
}
$buffer .= $data;
$eof = '' === $data;
}
$data = substr($buffer, 0, $length);
$buffer = substr($buffer, $length);
return $data;
} | [
"private",
"static",
"function",
"readRequestBody",
"(",
"int",
"$",
"length",
",",
"\\",
"Closure",
"$",
"body",
",",
"string",
"&",
"$",
"buffer",
",",
"bool",
"&",
"$",
"eof",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"eof",
"&&",
"\\",
"str... | Wraps the request's body callback to allow it to return strings longer than curl requested. | [
"Wraps",
"the",
"request",
"s",
"body",
"callback",
"to",
"allow",
"it",
"to",
"return",
"strings",
"longer",
"than",
"curl",
"requested",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/CurlHttpClient.php#L354-L369 | train | Reads the request body | [
30522,
2797,
10763,
3853,
3191,
2890,
15500,
23684,
1006,
20014,
1002,
3091,
1010,
1032,
8503,
1002,
2303,
1010,
5164,
1004,
1002,
17698,
1010,
22017,
2140,
1004,
1002,
1041,
11253,
1007,
1024,
5164,
1063,
2065,
1006,
999,
1002,
1041,
11253... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Console/Migrations/BaseCommand.php | BaseCommand.getMigrationPaths | protected function getMigrationPaths()
{
// Here, we will check to see if a path option has been defined. If it has we will
// use the path relative to the root of the installation folder so our database
// migrations may be run for any customized path from within the application.
if ($this->input->hasOption('path') && $this->option('path')) {
return collect($this->option('path'))->map(function ($path) {
return ! $this->usingRealPath()
? $this->laravel->basePath().'/'.$path
: $path;
})->all();
}
return array_merge(
$this->migrator->paths(), [$this->getMigrationPath()]
);
} | php | protected function getMigrationPaths()
{
// Here, we will check to see if a path option has been defined. If it has we will
// use the path relative to the root of the installation folder so our database
// migrations may be run for any customized path from within the application.
if ($this->input->hasOption('path') && $this->option('path')) {
return collect($this->option('path'))->map(function ($path) {
return ! $this->usingRealPath()
? $this->laravel->basePath().'/'.$path
: $path;
})->all();
}
return array_merge(
$this->migrator->paths(), [$this->getMigrationPath()]
);
} | [
"protected",
"function",
"getMigrationPaths",
"(",
")",
"{",
"// Here, we will check to see if a path option has been defined. If it has we will",
"// use the path relative to the root of the installation folder so our database",
"// migrations may be run for any customized path from within the appl... | Get all of the migration paths.
@return array | [
"Get",
"all",
"of",
"the",
"migration",
"paths",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Console/Migrations/BaseCommand.php#L14-L30 | train | Get the migration paths | [
30522,
5123,
3853,
2131,
4328,
29397,
15069,
2015,
1006,
1007,
1063,
1013,
1013,
2182,
1010,
2057,
2097,
4638,
2000,
2156,
2065,
1037,
4130,
5724,
2038,
2042,
4225,
1012,
2065,
2009,
2038,
2057,
2097,
1013,
1013,
2224,
1996,
4130,
5816,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Form.php | Form.normToView | private function normToView($value)
{
// Scalar values should be converted to strings to
// facilitate differentiation between empty ("") and zero (0).
// Only do this for simple forms, as the resulting value in
// compound forms is passed to the data mapper and thus should
// not be converted to a string before.
if (!($transformers = $this->config->getViewTransformers()) && !$this->config->getCompound()) {
return null === $value || is_scalar($value) ? (string) $value : $value;
}
try {
foreach ($transformers as $transformer) {
$value = $transformer->transform($value);
}
} catch (TransformationFailedException $exception) {
throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters());
}
return $value;
} | php | private function normToView($value)
{
// Scalar values should be converted to strings to
// facilitate differentiation between empty ("") and zero (0).
// Only do this for simple forms, as the resulting value in
// compound forms is passed to the data mapper and thus should
// not be converted to a string before.
if (!($transformers = $this->config->getViewTransformers()) && !$this->config->getCompound()) {
return null === $value || is_scalar($value) ? (string) $value : $value;
}
try {
foreach ($transformers as $transformer) {
$value = $transformer->transform($value);
}
} catch (TransformationFailedException $exception) {
throw new TransformationFailedException('Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters());
}
return $value;
} | [
"private",
"function",
"normToView",
"(",
"$",
"value",
")",
"{",
"// Scalar values should be converted to strings to",
"// facilitate differentiation between empty (\"\") and zero (0).",
"// Only do this for simple forms, as the resulting value in",
"// compound forms is passed to the data m... | Transforms the value if a view transformer is set.
@param mixed $value The value to transform
@return mixed
@throws TransformationFailedException If the normalized value cannot be transformed to "view" format | [
"Transforms",
"the",
"value",
"if",
"a",
"view",
"transformer",
"is",
"set",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Form.php#L1098-L1118 | train | Transforms the value to the view format | [
30522,
2797,
3853,
13373,
26525,
2666,
2860,
1006,
1002,
3643,
1007,
1063,
1013,
1013,
26743,
2099,
5300,
2323,
2022,
4991,
2000,
7817,
2000,
1013,
1013,
10956,
20582,
2090,
4064,
1006,
1000,
1000,
1007,
1998,
5717,
1006,
1014,
1007,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/ArchiveProcessor.php | ArchiveProcessor.aggregatedDataTableMapsAsOne | protected function aggregatedDataTableMapsAsOne(Map $map, DataTable $aggregated)
{
foreach ($map->getDataTables() as $tableToAggregate) {
if ($tableToAggregate instanceof Map) {
$this->aggregatedDataTableMapsAsOne($tableToAggregate, $aggregated);
} else {
$aggregated->addDataTable($tableToAggregate);
}
}
} | php | protected function aggregatedDataTableMapsAsOne(Map $map, DataTable $aggregated)
{
foreach ($map->getDataTables() as $tableToAggregate) {
if ($tableToAggregate instanceof Map) {
$this->aggregatedDataTableMapsAsOne($tableToAggregate, $aggregated);
} else {
$aggregated->addDataTable($tableToAggregate);
}
}
} | [
"protected",
"function",
"aggregatedDataTableMapsAsOne",
"(",
"Map",
"$",
"map",
",",
"DataTable",
"$",
"aggregated",
")",
"{",
"foreach",
"(",
"$",
"map",
"->",
"getDataTables",
"(",
")",
"as",
"$",
"tableToAggregate",
")",
"{",
"if",
"(",
"$",
"tableToAggr... | Aggregates the DataTable\Map into the destination $aggregated
@param $map
@param $aggregated | [
"Aggregates",
"the",
"DataTable",
"\\",
"Map",
"into",
"the",
"destination",
"$aggregated"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor.php#L526-L535 | train | Aggregate all data tables of a map into a DataTable | [
30522,
5123,
3853,
9572,
25062,
29336,
3085,
2863,
4523,
3022,
5643,
1006,
4949,
1002,
4949,
1010,
2951,
10880,
1002,
9572,
2094,
1007,
1063,
18921,
6776,
1006,
1002,
4949,
1011,
1028,
2131,
2850,
29336,
3085,
2015,
1006,
1007,
2004,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Style/SymfonyStyle.php | SymfonyStyle.createProgressBar | public function createProgressBar($max = 0)
{
$progressBar = parent::createProgressBar($max);
if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
$progressBar->setEmptyBarCharacter('░'); // light shade character \u2591
$progressBar->setProgressCharacter('');
$progressBar->setBarCharacter('▓'); // dark shade character \u2593
}
return $progressBar;
} | php | public function createProgressBar($max = 0)
{
$progressBar = parent::createProgressBar($max);
if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
$progressBar->setEmptyBarCharacter('░'); // light shade character \u2591
$progressBar->setProgressCharacter('');
$progressBar->setBarCharacter('▓'); // dark shade character \u2593
}
return $progressBar;
} | [
"public",
"function",
"createProgressBar",
"(",
"$",
"max",
"=",
"0",
")",
"{",
"$",
"progressBar",
"=",
"parent",
"::",
"createProgressBar",
"(",
"$",
"max",
")",
";",
"if",
"(",
"'\\\\'",
"!==",
"\\",
"DIRECTORY_SEPARATOR",
"||",
"'Hyper'",
"===",
"geten... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Style/SymfonyStyle.php#L268-L279 | train | Create a progress bar | [
30522,
2270,
3853,
3443,
21572,
17603,
4757,
8237,
1006,
1002,
4098,
1027,
1014,
30524,
1005,
999,
1027,
1027,
1032,
14176,
1035,
19802,
25879,
2953,
1064,
1064,
1005,
23760,
1005,
1027,
1027,
1027,
2131,
2368,
2615,
1006,
1005,
2744,
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/VarDumper/Dumper/HtmlDumper.php | HtmlDumper.dump | public function dump(Data $data, $output = null, array $extraDisplayOptions = [])
{
$this->extraDisplayOptions = $extraDisplayOptions;
$result = parent::dump($data, $output);
$this->dumpId = 'sf-dump-'.mt_rand();
return $result;
} | php | public function dump(Data $data, $output = null, array $extraDisplayOptions = [])
{
$this->extraDisplayOptions = $extraDisplayOptions;
$result = parent::dump($data, $output);
$this->dumpId = 'sf-dump-'.mt_rand();
return $result;
} | [
"public",
"function",
"dump",
"(",
"Data",
"$",
"data",
",",
"$",
"output",
"=",
"null",
",",
"array",
"$",
"extraDisplayOptions",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"extraDisplayOptions",
"=",
"$",
"extraDisplayOptions",
";",
"$",
"result",
"="... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L142-L149 | train | Dump the data into a string | [
30522,
2270,
3853,
15653,
1006,
2951,
1002,
2951,
1010,
1002,
6434,
1027,
19701,
1010,
9140,
1002,
4469,
10521,
13068,
7361,
9285,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
4469,
10521,
13068,
7361,
9285,
1027,
1002,
4469,
10521... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getAvailableOptions | protected function getAvailableOptions($scope, $searchQuery = null)
{
if ($scope->options) {
return $this->getOptionsFromArray($scope, $searchQuery);
}
$available = [];
$nameColumn = $this->getScopeNameFrom($scope);
$options = $this->getOptionsFromModel($scope, $searchQuery);
foreach ($options as $option) {
$available[$option->getKey()] = $option->{$nameColumn};
}
return $available;
} | php | protected function getAvailableOptions($scope, $searchQuery = null)
{
if ($scope->options) {
return $this->getOptionsFromArray($scope, $searchQuery);
}
$available = [];
$nameColumn = $this->getScopeNameFrom($scope);
$options = $this->getOptionsFromModel($scope, $searchQuery);
foreach ($options as $option) {
$available[$option->getKey()] = $option->{$nameColumn};
}
return $available;
} | [
"protected",
"function",
"getAvailableOptions",
"(",
"$",
"scope",
",",
"$",
"searchQuery",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"scope",
"->",
"options",
")",
"{",
"return",
"$",
"this",
"->",
"getOptionsFromArray",
"(",
"$",
"scope",
",",
"$",
"searc... | Returns the available options a scope can use, either from the
model relation or from a supplied array. Optionally apply a search
constraint to the options.
@param string $scope
@param string $searchQuery
@return array | [
"Returns",
"the",
"available",
"options",
"a",
"scope",
"can",
"use",
"either",
"from",
"the",
"model",
"relation",
"or",
"from",
"a",
"supplied",
"array",
".",
"Optionally",
"apply",
"a",
"search",
"constraint",
"to",
"the",
"options",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L328-L342 | train | Get available options from model | [
30522,
5123,
3853,
2131,
12462,
11733,
3468,
7361,
9285,
1006,
1002,
9531,
1010,
1002,
3945,
4226,
2854,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
9531,
1011,
1028,
7047,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
30524,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Builder.php | Builder.isNestedUnder | protected function isNestedUnder($relation, $name)
{
return Str::contains($name, '.') && Str::startsWith($name, $relation.'.');
} | php | protected function isNestedUnder($relation, $name)
{
return Str::contains($name, '.') && Str::startsWith($name, $relation.'.');
} | [
"protected",
"function",
"isNestedUnder",
"(",
"$",
"relation",
",",
"$",
"name",
")",
"{",
"return",
"Str",
"::",
"contains",
"(",
"$",
"name",
",",
"'.'",
")",
"&&",
"Str",
"::",
"startsWith",
"(",
"$",
"name",
",",
"$",
"relation",
".",
"'.'",
")"... | Determine if the relationship is nested.
@param string $relation
@param string $name
@return bool | [
"Determine",
"if",
"the",
"relationship",
"is",
"nested",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Builder.php#L631-L634 | train | Checks if the name of the relation is nested under the relation name | [
30522,
5123,
3853,
3475,
17944,
20824,
1006,
1002,
7189,
1010,
1002,
2171,
1007,
1063,
2709,
2358,
2099,
1024,
1024,
3397,
1006,
1002,
2171,
1010,
1005,
1012,
1005,
1007,
1004,
1004,
2358,
2099,
1024,
1024,
4627,
24415,
1006,
1002,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.addMetadata | public function addMetadata($idSite, $period, $name, $value)
{
$row = & $this->get($idSite, $period);
$row[self::METADATA_CONTAINER_ROW_KEY][$name] = $value;
} | php | public function addMetadata($idSite, $period, $name, $value)
{
$row = & $this->get($idSite, $period);
$row[self::METADATA_CONTAINER_ROW_KEY][$name] = $value;
} | [
"public",
"function",
"addMetadata",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"row",
"=",
"&",
"$",
"this",
"->",
"get",
"(",
"$",
"idSite",
",",
"$",
"period",
")",
";",
"$",
"row",
"[",
"self... | Adds a new metadata to the data for specific site & period. If there is no
data for the given site ID & period, it is set to the default row.
Note: Site ID and period range string are two special types of metadata. Since
the data stored in this class is indexed by site & period, this metadata is not
stored in individual data rows.
@param int $idSite
@param string $period eg, '2012-01-01,2012-01-31'
@param string $name The metadata name.
@param mixed $value The metadata name. | [
"Adds",
"a",
"new",
"metadata",
"to",
"the",
"data",
"for",
"specific",
"site",
"&",
"period",
".",
"If",
"there",
"is",
"no",
"data",
"for",
"the",
"given",
"site",
"ID",
"&",
"period",
"it",
"is",
"set",
"to",
"the",
"default",
"row",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L168-L172 | train | Add metadata to the page | [
30522,
2270,
3853,
5587,
11368,
8447,
2696,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
1002,
5216,
1027,
1004,
1002,
2023,
1011,
1028,
2131,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Auth/AuthenticatesUsers.php | AuthenticatesUsers.sendLoginResponse | protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
return $this->authenticated($request, $this->guard()->user())
?: redirect()->intended($this->redirectPath());
} | php | protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
return $this->authenticated($request, $this->guard()->user())
?: redirect()->intended($this->redirectPath());
} | [
"protected",
"function",
"sendLoginResponse",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"regenerate",
"(",
")",
";",
"$",
"this",
"->",
"clearLoginAttempts",
"(",
"$",
"request",
")",
";",
"return",
"$",
"... | Send the response after the user was authenticated.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"Send",
"the",
"response",
"after",
"the",
"user",
"was",
"authenticated",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php#L102-L110 | train | Send the login response to the user | [
30522,
5123,
3853,
4604,
21197,
2378,
6072,
26029,
3366,
1006,
5227,
1002,
5227,
1007,
1063,
1002,
5227,
1011,
1028,
5219,
1006,
1007,
1011,
1028,
19723,
24454,
3686,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
3154,
21197,
3981,
4674,
27718,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Session/SaveHandler/DbTable.php | Zend_Session_SaveHandler_DbTable._checkRequiredColumns | protected function _checkRequiredColumns()
{
if ($this->_modifiedColumn === null) {
/**
* @see Zend_Session_SaveHandler_Exception
*/
// require_once 'Zend/Session/SaveHandler/Exception.php';
throw new Zend_Session_SaveHandler_Exception(
"Configuration must define '" . self::MODIFIED_COLUMN . "' which names the "
. "session table last modification time column.");
} else if ($this->_lifetimeColumn === null) {
/**
* @see Zend_Session_SaveHandler_Exception
*/
// require_once 'Zend/Session/SaveHandler/Exception.php';
throw new Zend_Session_SaveHandler_Exception(
"Configuration must define '" . self::LIFETIME_COLUMN . "' which names the "
. "session table lifetime column.");
} else if ($this->_dataColumn === null) {
/**
* @see Zend_Session_SaveHandler_Exception
*/
// require_once 'Zend/Session/SaveHandler/Exception.php';
throw new Zend_Session_SaveHandler_Exception(
"Configuration must define '" . self::DATA_COLUMN . "' which names the "
. "session table data column.");
}
} | php | protected function _checkRequiredColumns()
{
if ($this->_modifiedColumn === null) {
/**
* @see Zend_Session_SaveHandler_Exception
*/
// require_once 'Zend/Session/SaveHandler/Exception.php';
throw new Zend_Session_SaveHandler_Exception(
"Configuration must define '" . self::MODIFIED_COLUMN . "' which names the "
. "session table last modification time column.");
} else if ($this->_lifetimeColumn === null) {
/**
* @see Zend_Session_SaveHandler_Exception
*/
// require_once 'Zend/Session/SaveHandler/Exception.php';
throw new Zend_Session_SaveHandler_Exception(
"Configuration must define '" . self::LIFETIME_COLUMN . "' which names the "
. "session table lifetime column.");
} else if ($this->_dataColumn === null) {
/**
* @see Zend_Session_SaveHandler_Exception
*/
// require_once 'Zend/Session/SaveHandler/Exception.php';
throw new Zend_Session_SaveHandler_Exception(
"Configuration must define '" . self::DATA_COLUMN . "' which names the "
. "session table data column.");
}
} | [
"protected",
"function",
"_checkRequiredColumns",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_modifiedColumn",
"===",
"null",
")",
"{",
"/**\n * @see Zend_Session_SaveHandler_Exception\n */",
"// require_once 'Zend/Session/SaveHandler/Exception.php';",
... | Check for required session table columns
@return void
@throws Zend_Session_SaveHandler_Exception | [
"Check",
"for",
"required",
"session",
"table",
"columns"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session/SaveHandler/DbTable.php#L478-L508 | train | Check required columns | [
30522,
5123,
3853,
1035,
4638,
2890,
15549,
5596,
25778,
2819,
3619,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
6310,
25778,
2819,
2078,
1027,
1027,
1027,
19701,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2156,
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... |
octobercms/october | modules/backend/formwidgets/PermissionEditor.php | PermissionEditor.getSaveValueSecure | protected function getSaveValueSecure($value)
{
$newPermissions = is_array($value) ? array_map('intval', $value) : [];
if (!empty($newPermissions)) {
$existingPermissions = $this->model->permissions ?: [];
$allowedPermissions = array_map(function ($permissionObject) {
return $permissionObject->code;
}, array_flatten($this->getFilteredPermissions()));
foreach ($newPermissions as $permission => $code) {
if (in_array($permission, $allowedPermissions)) {
$existingPermissions[$permission] = $code;
}
}
$newPermissions = $existingPermissions;
}
return $newPermissions;
} | php | protected function getSaveValueSecure($value)
{
$newPermissions = is_array($value) ? array_map('intval', $value) : [];
if (!empty($newPermissions)) {
$existingPermissions = $this->model->permissions ?: [];
$allowedPermissions = array_map(function ($permissionObject) {
return $permissionObject->code;
}, array_flatten($this->getFilteredPermissions()));
foreach ($newPermissions as $permission => $code) {
if (in_array($permission, $allowedPermissions)) {
$existingPermissions[$permission] = $code;
}
}
$newPermissions = $existingPermissions;
}
return $newPermissions;
} | [
"protected",
"function",
"getSaveValueSecure",
"(",
"$",
"value",
")",
"{",
"$",
"newPermissions",
"=",
"is_array",
"(",
"$",
"value",
")",
"?",
"array_map",
"(",
"'intval'",
",",
"$",
"value",
")",
":",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"... | Returns a safely parsed set of permissions, ensuring the user cannot elevate
their own permissions or permissions of another user above their own.
@param string $value
@return array | [
"Returns",
"a",
"safely",
"parsed",
"set",
"of",
"permissions",
"ensuring",
"the",
"user",
"cannot",
"elevate",
"their",
"own",
"permissions",
"or",
"permissions",
"of",
"another",
"user",
"above",
"their",
"own",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/PermissionEditor.php#L94-L115 | train | Get the array of permission codes from the passed value | [
30522,
5123,
3853,
4152,
10696,
10175,
15808,
29150,
1006,
1002,
3643,
1007,
1063,
1002,
2047,
4842,
25481,
2015,
1027,
2003,
1035,
9140,
1006,
1002,
3643,
1007,
1029,
9140,
1035,
4949,
1006,
1005,
20014,
10175,
1005,
1010,
1002,
3643,
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... |
octobercms/october | modules/backend/models/ImportModel.php | ImportModel.getFormatEncodingOptions | public function getFormatEncodingOptions()
{
$options = [
'utf-8',
'us-ascii',
'iso-8859-1',
'iso-8859-2',
'iso-8859-3',
'iso-8859-4',
'iso-8859-5',
'iso-8859-6',
'iso-8859-7',
'iso-8859-8',
'iso-8859-0',
'iso-8859-10',
'iso-8859-11',
'iso-8859-13',
'iso-8859-14',
'iso-8859-15',
'Windows-1251',
'Windows-1252'
];
$translated = array_map(function ($option) {
return Lang::get('backend::lang.import_export.encodings.'.Str::slug($option, '_'));
}, $options);
return array_combine($options, $translated);
} | php | public function getFormatEncodingOptions()
{
$options = [
'utf-8',
'us-ascii',
'iso-8859-1',
'iso-8859-2',
'iso-8859-3',
'iso-8859-4',
'iso-8859-5',
'iso-8859-6',
'iso-8859-7',
'iso-8859-8',
'iso-8859-0',
'iso-8859-10',
'iso-8859-11',
'iso-8859-13',
'iso-8859-14',
'iso-8859-15',
'Windows-1251',
'Windows-1252'
];
$translated = array_map(function ($option) {
return Lang::get('backend::lang.import_export.encodings.'.Str::slug($option, '_'));
}, $options);
return array_combine($options, $translated);
} | [
"public",
"function",
"getFormatEncodingOptions",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"'utf-8'",
",",
"'us-ascii'",
",",
"'iso-8859-1'",
",",
"'iso-8859-2'",
",",
"'iso-8859-3'",
",",
"'iso-8859-4'",
",",
"'iso-8859-5'",
",",
"'iso-8859-6'",
",",
"'iso-8859-7... | Returns all available encodings values from the localization config
@return array | [
"Returns",
"all",
"available",
"encodings",
"values",
"from",
"the",
"localization",
"config"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/models/ImportModel.php#L213-L241 | train | Returns the available format encoding options | [
30522,
2270,
3853,
2131,
14192,
3686,
15305,
4667,
7361,
9285,
1006,
1007,
1063,
1002,
7047,
1027,
1031,
1005,
21183,
2546,
1011,
1022,
1005,
1010,
1005,
2149,
1011,
2004,
6895,
2072,
1005,
1010,
1005,
11163,
1011,
6070,
28154,
1011,
1015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | HasAttributes.isDirty | public function isDirty($attributes = null)
{
return $this->hasChanges(
$this->getDirty(), is_array($attributes) ? $attributes : func_get_args()
);
} | php | public function isDirty($attributes = null)
{
return $this->hasChanges(
$this->getDirty(), is_array($attributes) ? $attributes : func_get_args()
);
} | [
"public",
"function",
"isDirty",
"(",
"$",
"attributes",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"hasChanges",
"(",
"$",
"this",
"->",
"getDirty",
"(",
")",
",",
"is_array",
"(",
"$",
"attributes",
")",
"?",
"$",
"attributes",
":",
"func_ge... | Determine if the model or any of the given attribute(s) have been modified.
@param array|string|null $attributes
@return bool | [
"Determine",
"if",
"the",
"model",
"or",
"any",
"of",
"the",
"given",
"attribute",
"(",
"s",
")",
"have",
"been",
"modified",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L1058-L1063 | train | Returns true if the model has any changes in the database | [
30522,
2270,
3853,
2003,
4305,
5339,
2100,
1006,
1002,
12332,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2038,
22305,
2229,
1006,
1002,
2023,
1011,
1028,
2131,
4305,
5339,
2100,
1006,
1007,
1010,
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... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.addInternalLink | function addInternalLink($label, $x0, $y0, $x1, $y1)
{
$this->numObj++;
$info = array('type' => 'ilink', 'label' => $label, 'rect' => array($x0, $y0, $x1, $y1));
$this->o_annotation($this->numObj, 'new', $info);
} | php | function addInternalLink($label, $x0, $y0, $x1, $y1)
{
$this->numObj++;
$info = array('type' => 'ilink', 'label' => $label, 'rect' => array($x0, $y0, $x1, $y1));
$this->o_annotation($this->numObj, 'new', $info);
} | [
"function",
"addInternalLink",
"(",
"$",
"label",
",",
"$",
"x0",
",",
"$",
"y0",
",",
"$",
"x1",
",",
"$",
"y1",
")",
"{",
"$",
"this",
"->",
"numObj",
"++",
";",
"$",
"info",
"=",
"array",
"(",
"'type'",
"=>",
"'ilink'",
",",
"'label'",
"=>",
... | add a link in the document to an internal destination (ie. within the document)
@param $label
@param $x0
@param $y0
@param $x1
@param $y1 | [
"add",
"a",
"link",
"in",
"the",
"document",
"to",
"an",
"internal",
"destination",
"(",
"ie",
".",
"within",
"the",
"document",
")"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2237-L2242 | train | Add an internal link to the hierarchy | [
30522,
3853,
5587,
18447,
11795,
8095,
19839,
1006,
1002,
3830,
1010,
1002,
1060,
2692,
1010,
1002,
1061,
2692,
1010,
1002,
1060,
2487,
1010,
1002,
1061,
2487,
1007,
1063,
1002,
2023,
1011,
1028,
16371,
5302,
2497,
3501,
1009,
1009,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Cookie.php | Cookie.set | public function set($name, $value)
{
$name = self::escapeValue($name);
// Delete value if $value === null
if (is_null($value)) {
if ($this->keyStore === false) {
unset($this->value[$name]);
return;
}
unset($this->value[$this->keyStore][$name]);
return;
}
if ($this->keyStore === false) {
$this->value[$name] = $value;
return;
}
$this->value[$this->keyStore][$name] = $value;
} | php | public function set($name, $value)
{
$name = self::escapeValue($name);
// Delete value if $value === null
if (is_null($value)) {
if ($this->keyStore === false) {
unset($this->value[$name]);
return;
}
unset($this->value[$this->keyStore][$name]);
return;
}
if ($this->keyStore === false) {
$this->value[$name] = $value;
return;
}
$this->value[$this->keyStore][$name] = $value;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"escapeValue",
"(",
"$",
"name",
")",
";",
"// Delete value if $value === null",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"if",
... | Registers a new name => value association in the cookie.
Registering new values is optimal if the value is a numeric value.
If the value is a string, it will be saved as a base64 encoded string.
If the value is an array, it will be saved as a serialized and base64 encoded
string which is not very good in terms of bytes usage.
You should save arrays only when you are sure about their maximum data size.
A cookie has to stay small and its size shouldn't increase over time!
@param string $name Name of the value to save; the name will be used to retrieve this value
@param string|array|number $value Value to save. If null, entry will be deleted from cookie. | [
"Registers",
"a",
"new",
"name",
"=",
">",
"value",
"association",
"in",
"the",
"cookie",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Cookie.php#L326-L346 | train | Set a value in the value array | [
30522,
2270,
3853,
2275,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
1002,
2171,
1027,
2969,
1024,
1024,
4019,
10175,
5657,
1006,
1002,
2171,
1007,
1025,
1013,
1013,
3972,
12870,
3643,
2065,
1002,
3643,
1027,
1027,
1027,
19701,
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 | plugins/Live/VisitorDetails.php | VisitorDetails.fetchFirstVisit | private function fetchFirstVisit()
{
$response = Request::processRequest('Live.getFirstVisitForVisitorId', [
'idSite' => $this->getIdSite(),
'visitorId' => $this->getVisitorId(),
]);
return $response->getFirstRow();
} | php | private function fetchFirstVisit()
{
$response = Request::processRequest('Live.getFirstVisitForVisitorId', [
'idSite' => $this->getIdSite(),
'visitorId' => $this->getVisitorId(),
]);
return $response->getFirstRow();
} | [
"private",
"function",
"fetchFirstVisit",
"(",
")",
"{",
"$",
"response",
"=",
"Request",
"::",
"processRequest",
"(",
"'Live.getFirstVisitForVisitorId'",
",",
"[",
"'idSite'",
"=>",
"$",
"this",
"->",
"getIdSite",
"(",
")",
",",
"'visitorId'",
"=>",
"$",
"thi... | Fetch first visit from Live API
@return DataTable\Row | [
"Fetch",
"first",
"visit",
"from",
"Live",
"API"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Live/VisitorDetails.php#L217-L225 | train | Fetch First Visit | [
30522,
2797,
3853,
18584,
8873,
12096,
11365,
4183,
1006,
1007,
1063,
1002,
3433,
1027,
5227,
1024,
1024,
2832,
2890,
15500,
1006,
1005,
2444,
1012,
2131,
8873,
12096,
11365,
4183,
29278,
11365,
15660,
3593,
1005,
1010,
1031,
1005,
8909,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Updates/2.13.1.php | Updates_2_13_1.getMigrations | public function getMigrations(Updater $updater)
{
$optionTable = Common::prefixTable('option');
$removeEmptyDefaultReportsSql = "delete from `$optionTable` where option_name like '%defaultReport%' and option_value=''";
return array(
$this->migration->db->sql($removeEmptyDefaultReportsSql)
);
} | php | public function getMigrations(Updater $updater)
{
$optionTable = Common::prefixTable('option');
$removeEmptyDefaultReportsSql = "delete from `$optionTable` where option_name like '%defaultReport%' and option_value=''";
return array(
$this->migration->db->sql($removeEmptyDefaultReportsSql)
);
} | [
"public",
"function",
"getMigrations",
"(",
"Updater",
"$",
"updater",
")",
"{",
"$",
"optionTable",
"=",
"Common",
"::",
"prefixTable",
"(",
"'option'",
")",
";",
"$",
"removeEmptyDefaultReportsSql",
"=",
"\"delete from `$optionTable` where option_name like '%defaultRepo... | Here you can define one or multiple SQL statements that should be executed during the update.
@return Updater\Migration[] | [
"Here",
"you",
"can",
"define",
"one",
"or",
"multiple",
"SQL",
"statements",
"that",
"should",
"be",
"executed",
"during",
"the",
"update",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updates/2.13.1.php#L36-L44 | train | Get migrations for the given Updater | [
30522,
2270,
3853,
2131,
4328,
29397,
2015,
1006,
10651,
2099,
1002,
10651,
2099,
1007,
1063,
1002,
5724,
10880,
1027,
2691,
1024,
1024,
17576,
10880,
1006,
1005,
5724,
1005,
1007,
1025,
1002,
6366,
6633,
13876,
18124,
7011,
11314,
2890,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ReplacesAttributes.php | ReplacesAttributes.replaceRequiredUnless | protected function replaceRequiredUnless($message, $attribute, $rule, $parameters)
{
$other = $this->getDisplayableAttribute($parameters[0]);
$values = [];
foreach (array_slice($parameters, 1) as $value) {
$values[] = $this->getDisplayableValue($parameters[0], $value);
}
return str_replace([':other', ':values'], [$other, implode(', ', $values)], $message);
} | php | protected function replaceRequiredUnless($message, $attribute, $rule, $parameters)
{
$other = $this->getDisplayableAttribute($parameters[0]);
$values = [];
foreach (array_slice($parameters, 1) as $value) {
$values[] = $this->getDisplayableValue($parameters[0], $value);
}
return str_replace([':other', ':values'], [$other, implode(', ', $values)], $message);
} | [
"protected",
"function",
"replaceRequiredUnless",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"parameters",
")",
"{",
"$",
"other",
"=",
"$",
"this",
"->",
"getDisplayableAttribute",
"(",
"$",
"parameters",
"[",
"0",
"]",
")",
... | Replace all place-holders for the required_unless rule.
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@return string | [
"Replace",
"all",
"place",
"-",
"holders",
"for",
"the",
"required_unless",
"rule",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php#L350-L361 | train | Replace all place - holders for the required_unless rule. | [
30522,
5123,
3853,
5672,
2890,
15549,
5596,
4609,
3238,
1006,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
1007,
1063,
1002,
2060,
1027,
1002,
2023,
1011,
1028,
2131,
10521,
13068,
3085,
19321,
3089,
8569,
2618,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db/Schema.php | Schema.getSchemaClassName | private static function getSchemaClassName($schemaName)
{
// Upgrade from pre 2.0.4
if (strtolower($schemaName) == 'myisam'
|| empty($schemaName)) {
$schemaName = self::DEFAULT_SCHEMA;
}
$class = str_replace(' ', '\\', ucwords(str_replace('_', ' ', strtolower($schemaName))));
return '\Piwik\Db\Schema\\' . $class;
} | php | private static function getSchemaClassName($schemaName)
{
// Upgrade from pre 2.0.4
if (strtolower($schemaName) == 'myisam'
|| empty($schemaName)) {
$schemaName = self::DEFAULT_SCHEMA;
}
$class = str_replace(' ', '\\', ucwords(str_replace('_', ' ', strtolower($schemaName))));
return '\Piwik\Db\Schema\\' . $class;
} | [
"private",
"static",
"function",
"getSchemaClassName",
"(",
"$",
"schemaName",
")",
"{",
"// Upgrade from pre 2.0.4",
"if",
"(",
"strtolower",
"(",
"$",
"schemaName",
")",
"==",
"'myisam'",
"||",
"empty",
"(",
"$",
"schemaName",
")",
")",
"{",
"$",
"schemaName... | Get schema class name
@param string $schemaName
@return string | [
"Get",
"schema",
"class",
"name"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Schema.php#L38-L48 | train | Returns the class name of the schema | [
30522,
2797,
10763,
3853,
4152,
5403,
22911,
27102,
18442,
1006,
1002,
8040,
28433,
18442,
1007,
1063,
1013,
1013,
12200,
2013,
3653,
1016,
1012,
1014,
1012,
1018,
2065,
1006,
2358,
5339,
12898,
13777,
1006,
1002,
8040,
28433,
18442,
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/Intl/Data/Provider/CurrencyDataProvider.php | CurrencyDataProvider.getRoundingIncrement | public function getRoundingIncrement($currency)
{
try {
return $this->reader->readEntry($this->path, 'meta', ['Meta', $currency, static::INDEX_ROUNDING_INCREMENT]);
} catch (MissingResourceException $e) {
return $this->reader->readEntry($this->path, 'meta', ['Meta', 'DEFAULT', static::INDEX_ROUNDING_INCREMENT]);
}
} | php | public function getRoundingIncrement($currency)
{
try {
return $this->reader->readEntry($this->path, 'meta', ['Meta', $currency, static::INDEX_ROUNDING_INCREMENT]);
} catch (MissingResourceException $e) {
return $this->reader->readEntry($this->path, 'meta', ['Meta', 'DEFAULT', static::INDEX_ROUNDING_INCREMENT]);
}
} | [
"public",
"function",
"getRoundingIncrement",
"(",
"$",
"currency",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"reader",
"->",
"readEntry",
"(",
"$",
"this",
"->",
"path",
",",
"'meta'",
",",
"[",
"'Meta'",
",",
"$",
"currency",
",",
"static",
... | Data provider for {@link \Symfony\Component\Intl\Currency::getRoundingIncrement()}. | [
"Data",
"provider",
"for",
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Data/Provider/CurrencyDataProvider.php#L118-L125 | train | Get Rounding Increment | [
30522,
2270,
3853,
2131,
22494,
15683,
2378,
16748,
3672,
1006,
1002,
9598,
1007,
1063,
3046,
1063,
2709,
1002,
2023,
1011,
1028,
8068,
1011,
1028,
3191,
4765,
2854,
1006,
1002,
2023,
1011,
1028,
4130,
1010,
1005,
18804,
1005,
1010,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Nonce.php | Nonce.verifyNonce | public static function verifyNonce($id, $cnonce)
{
$ns = new SessionNamespace($id);
$nonce = $ns->nonce;
// validate token
if (empty($cnonce) || $cnonce !== $nonce) {
return false;
}
// validate referrer
$referrer = Url::getReferrer();
if (!empty($referrer) && !Url::isLocalUrl($referrer)) {
return false;
}
// validate origin
$origin = self::getOrigin();
if (!empty($origin) &&
($origin == 'null'
|| !in_array($origin, self::getAcceptableOrigins()))
) {
return false;
}
return true;
} | php | public static function verifyNonce($id, $cnonce)
{
$ns = new SessionNamespace($id);
$nonce = $ns->nonce;
// validate token
if (empty($cnonce) || $cnonce !== $nonce) {
return false;
}
// validate referrer
$referrer = Url::getReferrer();
if (!empty($referrer) && !Url::isLocalUrl($referrer)) {
return false;
}
// validate origin
$origin = self::getOrigin();
if (!empty($origin) &&
($origin == 'null'
|| !in_array($origin, self::getAcceptableOrigins()))
) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"verifyNonce",
"(",
"$",
"id",
",",
"$",
"cnonce",
")",
"{",
"$",
"ns",
"=",
"new",
"SessionNamespace",
"(",
"$",
"id",
")",
";",
"$",
"nonce",
"=",
"$",
"ns",
"->",
"nonce",
";",
"// validate token",
"if",
"(",
"empty... | Returns if a nonce is valid and comes from a valid request.
A nonce is valid if it matches the current nonce and if the current nonce
has not expired.
The request is valid if the referrer is a local URL (see {@link Url::isLocalUrl()})
and if the HTTP origin is valid (see {@link getAcceptableOrigins()}).
@param string $id The nonce's unique ID. See {@link getNonce()}.
@param string $cnonce Nonce sent from client.
@return bool `true` if valid; `false` otherwise. | [
"Returns",
"if",
"a",
"nonce",
"is",
"valid",
"and",
"comes",
"from",
"a",
"valid",
"request",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Nonce.php#L70-L96 | train | verifyNonce - Verify that the nonce is valid | [
30522,
2270,
10763,
3853,
20410,
8540,
3401,
1006,
1002,
8909,
1010,
1002,
27166,
2239,
3401,
1007,
1063,
1002,
24978,
1027,
2047,
5219,
18442,
23058,
1006,
1002,
8909,
1007,
1025,
1002,
2512,
3401,
1027,
1002,
24978,
1011,
1028,
2512,
3401... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Controller/RedirectController.php | RedirectController.urlRedirectAction | public function urlRedirectAction(Request $request, string $path, bool $permanent = false, string $scheme = null, int $httpPort = null, int $httpsPort = null, bool $keepRequestMethod = false): Response
{
if ('' == $path) {
throw new HttpException($permanent ? 410 : 404);
}
if ($keepRequestMethod) {
$statusCode = $permanent ? 308 : 307;
} else {
$statusCode = $permanent ? 301 : 302;
}
// redirect if the path is a full URL
if (parse_url($path, PHP_URL_SCHEME)) {
return new RedirectResponse($path, $statusCode);
}
if (null === $scheme) {
$scheme = $request->getScheme();
}
$qs = $request->getQueryString();
if ($qs) {
if (false === strpos($path, '?')) {
$qs = '?'.$qs;
} else {
$qs = '&'.$qs;
}
}
$port = '';
if ('http' === $scheme) {
if (null === $httpPort) {
if ('http' === $request->getScheme()) {
$httpPort = $request->getPort();
} else {
$httpPort = $this->httpPort;
}
}
if (null !== $httpPort && 80 != $httpPort) {
$port = ":$httpPort";
}
} elseif ('https' === $scheme) {
if (null === $httpsPort) {
if ('https' === $request->getScheme()) {
$httpsPort = $request->getPort();
} else {
$httpsPort = $this->httpsPort;
}
}
if (null !== $httpsPort && 443 != $httpsPort) {
$port = ":$httpsPort";
}
}
$url = $scheme.'://'.$request->getHost().$port.$request->getBaseUrl().$path.$qs;
return new RedirectResponse($url, $statusCode);
} | php | public function urlRedirectAction(Request $request, string $path, bool $permanent = false, string $scheme = null, int $httpPort = null, int $httpsPort = null, bool $keepRequestMethod = false): Response
{
if ('' == $path) {
throw new HttpException($permanent ? 410 : 404);
}
if ($keepRequestMethod) {
$statusCode = $permanent ? 308 : 307;
} else {
$statusCode = $permanent ? 301 : 302;
}
// redirect if the path is a full URL
if (parse_url($path, PHP_URL_SCHEME)) {
return new RedirectResponse($path, $statusCode);
}
if (null === $scheme) {
$scheme = $request->getScheme();
}
$qs = $request->getQueryString();
if ($qs) {
if (false === strpos($path, '?')) {
$qs = '?'.$qs;
} else {
$qs = '&'.$qs;
}
}
$port = '';
if ('http' === $scheme) {
if (null === $httpPort) {
if ('http' === $request->getScheme()) {
$httpPort = $request->getPort();
} else {
$httpPort = $this->httpPort;
}
}
if (null !== $httpPort && 80 != $httpPort) {
$port = ":$httpPort";
}
} elseif ('https' === $scheme) {
if (null === $httpsPort) {
if ('https' === $request->getScheme()) {
$httpsPort = $request->getPort();
} else {
$httpsPort = $this->httpsPort;
}
}
if (null !== $httpsPort && 443 != $httpsPort) {
$port = ":$httpsPort";
}
}
$url = $scheme.'://'.$request->getHost().$port.$request->getBaseUrl().$path.$qs;
return new RedirectResponse($url, $statusCode);
} | [
"public",
"function",
"urlRedirectAction",
"(",
"Request",
"$",
"request",
",",
"string",
"$",
"path",
",",
"bool",
"$",
"permanent",
"=",
"false",
",",
"string",
"$",
"scheme",
"=",
"null",
",",
"int",
"$",
"httpPort",
"=",
"null",
",",
"int",
"$",
"h... | Redirects to a URL.
The response status code is 302 if the permanent parameter is false (default),
and 301 if the redirection is permanent.
In case the path is empty, the status code will be 404 when permanent is false
and 410 otherwise.
@param Request $request The request instance
@param string $path The absolute path or URL to redirect to
@param bool $permanent Whether the redirect is permanent or not
@param string|null $scheme The URL scheme (null to keep the current one)
@param int|null $httpPort The HTTP port (null to keep the current one for the same scheme or the default configured port)
@param int|null $httpsPort The HTTPS port (null to keep the current one for the same scheme or the default configured port)
@param bool $keepRequestMethod Whether redirect action should keep HTTP request method
@throws HttpException In case the path is empty | [
"Redirects",
"to",
"a",
"URL",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php#L101-L161 | train | Redirect to a full URL | [
30522,
2270,
3853,
24471,
20974,
2098,
7442,
25572,
7542,
1006,
5227,
1002,
5227,
1010,
5164,
1002,
4130,
30524,
6442,
1027,
19701,
1010,
22017,
2140,
1002,
2562,
2890,
15500,
11368,
6806,
2094,
1027,
6270,
1007,
1024,
3433,
1063,
2065,
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... |
matomo-org/matomo | core/Period/Day.php | Day.getLocalizedShortString | public function getLocalizedShortString()
{
//"Mon 15 Aug"
$date = $this->getDateStart();
$out = $date->getLocalized(Date::DATE_FORMAT_DAY_MONTH);
return $out;
} | php | public function getLocalizedShortString()
{
//"Mon 15 Aug"
$date = $this->getDateStart();
$out = $date->getLocalized(Date::DATE_FORMAT_DAY_MONTH);
return $out;
} | [
"public",
"function",
"getLocalizedShortString",
"(",
")",
"{",
"//\"Mon 15 Aug\"",
"$",
"date",
"=",
"$",
"this",
"->",
"getDateStart",
"(",
")",
";",
"$",
"out",
"=",
"$",
"date",
"->",
"getLocalized",
"(",
"Date",
"::",
"DATE_FORMAT_DAY_MONTH",
")",
";",
... | Returns the day of the period as a localized short string
@return string | [
"Returns",
"the",
"day",
"of",
"the",
"period",
"as",
"a",
"localized",
"short",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Period/Day.php#L39-L45 | train | Get the date in the form of Mon 15 Aug | [
30522,
2270,
3853,
2131,
4135,
9289,
3550,
22231,
21217,
18886,
3070,
1006,
1007,
1063,
1013,
1013,
1000,
12256,
2321,
15476,
1000,
1002,
3058,
1027,
1002,
2023,
1011,
1028,
2131,
27122,
7559,
2102,
1006,
1007,
1025,
1002,
2041,
1027,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Profiler/Profile.php | Profile.getCollector | public function getCollector($name)
{
if (!isset($this->collectors[$name])) {
throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
}
return $this->collectors[$name];
} | php | public function getCollector($name)
{
if (!isset($this->collectors[$name])) {
throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
}
return $this->collectors[$name];
} | [
"public",
"function",
"getCollector",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"collectors",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Collector \"%s... | Gets a Collector by name.
@param string $name A collector name
@return DataCollectorInterface A DataCollectorInterface instance
@throws \InvalidArgumentException if the collector does not exist | [
"Gets",
"a",
"Collector",
"by",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Profiler/Profile.php#L239-L246 | train | Get a collector | [
30522,
2270,
3853,
2131,
26895,
22471,
2953,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
14256,
1031,
1002,
2171,
1033,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getUsersPlusRole | public function getUsersPlusRole($idSite, $limit = null, $offset = 0, $filter_search = null, $filter_access = null)
{
if (!$this->isUserHasAdminAccessTo($idSite)) {
// if the user is not an admin to $idSite, they can only see their own user
if ($offset > 1) {
Common::sendHeader('X-Matomo-Total-Results: 1');
return [];
}
$user = $this->model->getUser($this->access->getLogin());
$user['role'] = $this->access->getRoleForSite($idSite);
$user['capabilities'] = $this->access->getCapabilitiesForSite($idSite);
$users = [$user];
$totalResults = 1;
} else {
// if the current user is not the superuser, only select users that have access to a site this user
// has admin access to
$loginsToLimit = null;
if (!Piwik::hasUserSuperUserAccess()) {
$adminIdSites = Access::getInstance()->getSitesIdWithAdminAccess();
if (empty($adminIdSites)) { // sanity check
throw new \Exception("The current admin user does not have access to any sites.");
}
$loginsToLimit = $this->model->getUsersWithAccessToSites($adminIdSites);
}
list($users, $totalResults) = $this->model->getUsersWithRole($idSite, $limit, $offset, $filter_search, $filter_access, $loginsToLimit);
foreach ($users as &$user) {
$user['superuser_access'] = $user['superuser_access'] == 1;
if ($user['superuser_access']) {
$user['role'] = 'superuser';
$user['capabilities'] = [];
} else {
list($user['role'], $user['capabilities']) = $this->getRoleAndCapabilitiesFromAccess($user['access']);
$user['role'] = empty($user['role']) ? 'noaccess' : reset($user['role']);
}
unset($user['access']);
}
}
$users = $this->enrichUsers($users);
$users = $this->enrichUsersWithLastSeen($users);
foreach ($users as &$user) {
unset($user['password']);
}
Common::sendHeader('X-Matomo-Total-Results: ' . $totalResults);
return $users;
} | php | public function getUsersPlusRole($idSite, $limit = null, $offset = 0, $filter_search = null, $filter_access = null)
{
if (!$this->isUserHasAdminAccessTo($idSite)) {
// if the user is not an admin to $idSite, they can only see their own user
if ($offset > 1) {
Common::sendHeader('X-Matomo-Total-Results: 1');
return [];
}
$user = $this->model->getUser($this->access->getLogin());
$user['role'] = $this->access->getRoleForSite($idSite);
$user['capabilities'] = $this->access->getCapabilitiesForSite($idSite);
$users = [$user];
$totalResults = 1;
} else {
// if the current user is not the superuser, only select users that have access to a site this user
// has admin access to
$loginsToLimit = null;
if (!Piwik::hasUserSuperUserAccess()) {
$adminIdSites = Access::getInstance()->getSitesIdWithAdminAccess();
if (empty($adminIdSites)) { // sanity check
throw new \Exception("The current admin user does not have access to any sites.");
}
$loginsToLimit = $this->model->getUsersWithAccessToSites($adminIdSites);
}
list($users, $totalResults) = $this->model->getUsersWithRole($idSite, $limit, $offset, $filter_search, $filter_access, $loginsToLimit);
foreach ($users as &$user) {
$user['superuser_access'] = $user['superuser_access'] == 1;
if ($user['superuser_access']) {
$user['role'] = 'superuser';
$user['capabilities'] = [];
} else {
list($user['role'], $user['capabilities']) = $this->getRoleAndCapabilitiesFromAccess($user['access']);
$user['role'] = empty($user['role']) ? 'noaccess' : reset($user['role']);
}
unset($user['access']);
}
}
$users = $this->enrichUsers($users);
$users = $this->enrichUsersWithLastSeen($users);
foreach ($users as &$user) {
unset($user['password']);
}
Common::sendHeader('X-Matomo-Total-Results: ' . $totalResults);
return $users;
} | [
"public",
"function",
"getUsersPlusRole",
"(",
"$",
"idSite",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"filter_search",
"=",
"null",
",",
"$",
"filter_access",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
... | Returns all users with their role for $idSite.
@param int $idSite
@param int|null $limit
@param int|null $offset
@param string|null $filter_search text to search for in the user's login, email and alias (if any)
@param string|null $filter_access only select users with this access to $idSite. can be 'noaccess', 'some', 'view', 'admin', 'superuser'
Filtering by 'superuser' is only allowed for other superusers.
@return array | [
"Returns",
"all",
"users",
"with",
"their",
"role",
"for",
"$idSite",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/API.php#L298-L350 | train | Returns all users with a specific role and capabilities | [
30522,
2270,
3853,
2131,
20330,
13102,
7393,
13153,
2063,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
5787,
1027,
19701,
1010,
1002,
16396,
1027,
1014,
1010,
1002,
11307,
1035,
3945,
1027,
19701,
1010,
1002,
11307,
1035,
3229,
1027,
19701,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/Link.php | Link.parsedownElement | public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
{
$innerElement = $this->source->parsedownElement($title, $alt, $class, $id, $reset);
return [
'name' => 'a',
'attributes' => $this->attributes,
'handler' => is_string($innerElement) ? 'line' : 'element',
'text' => $innerElement
];
} | php | public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
{
$innerElement = $this->source->parsedownElement($title, $alt, $class, $id, $reset);
return [
'name' => 'a',
'attributes' => $this->attributes,
'handler' => is_string($innerElement) ? 'line' : 'element',
'text' => $innerElement
];
} | [
"public",
"function",
"parsedownElement",
"(",
"$",
"title",
"=",
"null",
",",
"$",
"alt",
"=",
"null",
",",
"$",
"class",
"=",
"null",
",",
"$",
"id",
"=",
"null",
",",
"$",
"reset",
"=",
"true",
")",
"{",
"$",
"innerElement",
"=",
"$",
"this",
... | Get an element (is array) that can be rendered by the Parsedown engine
@param string $title
@param string $alt
@param string $class
@param string $id
@param bool $reset
@return array | [
"Get",
"an",
"element",
"(",
"is",
"array",
")",
"that",
"can",
"be",
"rendered",
"by",
"the",
"Parsedown",
"engine"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/Link.php#L44-L54 | train | Devuelve el elemento de una base de datos | [
30522,
2270,
3853,
11968,
6924,
12384,
12260,
3672,
1006,
1002,
2516,
1027,
19701,
1010,
1002,
12456,
1027,
19701,
1010,
1002,
2465,
1027,
19701,
1010,
1002,
8909,
1027,
19701,
1010,
1002,
25141,
1027,
2995,
1007,
1063,
1002,
5110,
12260,
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... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.getList | public function getList(PageInterface $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false)
{
if (!$current) {
if ($level) {
throw new \RuntimeException('Internal error');
}
$current = $this->root();
}
$list = [];
if (!$current->root()) {
if ($rawRoutes) {
$route = $current->rawRoute();
} else {
$route = $current->route();
}
if ($showFullpath) {
$option = $current->route();
} else {
$extra = $showSlug ? '(' . $current->slug() . ') ' : '';
$option = str_repeat('—-', $level). '▸ ' . $extra . $current->title();
}
$list[$route] = $option;
}
if ($limitLevels === false || ($level+1 < $limitLevels)) {
foreach ($current->children() as $next) {
if ($showAll || $next->routable() || ($next->modular() && $showModular)) {
$list = array_merge($list, $this->getList($next, $level + 1, $rawRoutes, $showAll, $showFullpath, $showSlug, $showModular, $limitLevels));
}
}
}
return $list;
} | php | public function getList(PageInterface $current = null, $level = 0, $rawRoutes = false, $showAll = true, $showFullpath = false, $showSlug = false, $showModular = false, $limitLevels = false)
{
if (!$current) {
if ($level) {
throw new \RuntimeException('Internal error');
}
$current = $this->root();
}
$list = [];
if (!$current->root()) {
if ($rawRoutes) {
$route = $current->rawRoute();
} else {
$route = $current->route();
}
if ($showFullpath) {
$option = $current->route();
} else {
$extra = $showSlug ? '(' . $current->slug() . ') ' : '';
$option = str_repeat('—-', $level). '▸ ' . $extra . $current->title();
}
$list[$route] = $option;
}
if ($limitLevels === false || ($level+1 < $limitLevels)) {
foreach ($current->children() as $next) {
if ($showAll || $next->routable() || ($next->modular() && $showModular)) {
$list = array_merge($list, $this->getList($next, $level + 1, $rawRoutes, $showAll, $showFullpath, $showSlug, $showModular, $limitLevels));
}
}
}
return $list;
} | [
"public",
"function",
"getList",
"(",
"PageInterface",
"$",
"current",
"=",
"null",
",",
"$",
"level",
"=",
"0",
",",
"$",
"rawRoutes",
"=",
"false",
",",
"$",
"showAll",
"=",
"true",
",",
"$",
"showFullpath",
"=",
"false",
",",
"$",
"showSlug",
"=",
... | Get list of route/title of all pages.
@param PageInterface $current
@param int $level
@param bool $rawRoutes
@param bool $showAll
@param bool $showFullpath
@param bool $showSlug
@param bool $showModular
@param bool $limitLevels
@return array | [
"Get",
"list",
"of",
"route",
"/",
"title",
"of",
"all",
"pages",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L686-L728 | train | Get List of all routes | [
30522,
2270,
3853,
2131,
9863,
1006,
3931,
18447,
2121,
12172,
1002,
2783,
1027,
19701,
1010,
1002,
2504,
1027,
1014,
1010,
1002,
6315,
22494,
4570,
1027,
6270,
1010,
1002,
2265,
8095,
1027,
2995,
1010,
1002,
2265,
3993,
14277,
8988,
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/ReplacesAttributes.php | ReplacesAttributes.replaceDateEquals | protected function replaceDateEquals($message, $attribute, $rule, $parameters)
{
return $this->replaceBefore($message, $attribute, $rule, $parameters);
} | php | protected function replaceDateEquals($message, $attribute, $rule, $parameters)
{
return $this->replaceBefore($message, $attribute, $rule, $parameters);
} | [
"protected",
"function",
"replaceDateEquals",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"replaceBefore",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",... | Replace all place-holders for the date_equals rule.
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@return string | [
"Replace",
"all",
"place",
"-",
"holders",
"for",
"the",
"date_equals",
"rule",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php#L446-L449 | train | Replace all place - holders for date_equals | [
30522,
5123,
3853,
2999,
3686,
2063,
26426,
2015,
1006,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5672,
4783,
29278,
2063,
1006,
1002,
4471,
1010,
1002,
17961,
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... |
octobercms/october | modules/backend/widgets/Form.php | Form.makeFormField | protected function makeFormField($name, $config = [])
{
$label = $config['label'] ?? null;
list($fieldName, $fieldContext) = $this->getFieldName($name);
$field = new FormField($fieldName, $label);
if ($fieldContext) {
$field->context = $fieldContext;
}
$field->arrayName = $this->arrayName;
$field->idPrefix = $this->getId();
/*
* Simple field type
*/
if (is_string($config)) {
if ($this->isFormWidget($config) !== false) {
$field->displayAs('widget', ['widget' => $config]);
}
else {
$field->displayAs($config);
}
}
/*
* Defined field type
*/
else {
$fieldType = $config['type'] ?? null;
if (!is_string($fieldType) && $fieldType !== null) {
throw new ApplicationException(Lang::get(
'backend::lang.field.invalid_type',
['type' => gettype($fieldType)]
));
}
/*
* Widget with configuration
*/
if ($this->isFormWidget($fieldType) !== false) {
$config['widget'] = $fieldType;
$fieldType = 'widget';
}
$field->displayAs($fieldType, $config);
}
/*
* Set field value
*/
$field->value = $this->getFieldValue($field);
/*
* Apply the field name to the validation engine
*/
$attrName = implode('.', HtmlHelper::nameToArray($field->fieldName));
if ($this->model && method_exists($this->model, 'setValidationAttributeName')) {
$this->model->setValidationAttributeName($attrName, $field->label);
}
/*
* Check model if field is required
*/
if ($field->required === null && $this->model && method_exists($this->model, 'isAttributeRequired')) {
// Check nested fields
if ($this->isNested) {
// Get the current attribute level
$nameArray = HtmlHelper::nameToArray($this->arrayName);
unset($nameArray[0]);
// Convert any numeric indexes to wildcards
foreach ($nameArray as $i => $value) {
if (preg_match('/^[0-9]*$/', $value)) {
$nameArray[$i] = '*';
}
}
// Recombine names for full attribute name in rules array
$attrName = implode('.', $nameArray) . ".{$attrName}";
}
$field->required = $this->model->isAttributeRequired($attrName);
}
/*
* Get field options from model
*/
$optionModelTypes = ['dropdown', 'radio', 'checkboxlist', 'balloon-selector'];
if (in_array($field->type, $optionModelTypes, false)) {
/*
* Defer the execution of option data collection
*/
$field->options(function () use ($field, $config) {
$fieldOptions = $config['options'] ?? null;
$fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
return $fieldOptions;
});
}
return $field;
} | php | protected function makeFormField($name, $config = [])
{
$label = $config['label'] ?? null;
list($fieldName, $fieldContext) = $this->getFieldName($name);
$field = new FormField($fieldName, $label);
if ($fieldContext) {
$field->context = $fieldContext;
}
$field->arrayName = $this->arrayName;
$field->idPrefix = $this->getId();
/*
* Simple field type
*/
if (is_string($config)) {
if ($this->isFormWidget($config) !== false) {
$field->displayAs('widget', ['widget' => $config]);
}
else {
$field->displayAs($config);
}
}
/*
* Defined field type
*/
else {
$fieldType = $config['type'] ?? null;
if (!is_string($fieldType) && $fieldType !== null) {
throw new ApplicationException(Lang::get(
'backend::lang.field.invalid_type',
['type' => gettype($fieldType)]
));
}
/*
* Widget with configuration
*/
if ($this->isFormWidget($fieldType) !== false) {
$config['widget'] = $fieldType;
$fieldType = 'widget';
}
$field->displayAs($fieldType, $config);
}
/*
* Set field value
*/
$field->value = $this->getFieldValue($field);
/*
* Apply the field name to the validation engine
*/
$attrName = implode('.', HtmlHelper::nameToArray($field->fieldName));
if ($this->model && method_exists($this->model, 'setValidationAttributeName')) {
$this->model->setValidationAttributeName($attrName, $field->label);
}
/*
* Check model if field is required
*/
if ($field->required === null && $this->model && method_exists($this->model, 'isAttributeRequired')) {
// Check nested fields
if ($this->isNested) {
// Get the current attribute level
$nameArray = HtmlHelper::nameToArray($this->arrayName);
unset($nameArray[0]);
// Convert any numeric indexes to wildcards
foreach ($nameArray as $i => $value) {
if (preg_match('/^[0-9]*$/', $value)) {
$nameArray[$i] = '*';
}
}
// Recombine names for full attribute name in rules array
$attrName = implode('.', $nameArray) . ".{$attrName}";
}
$field->required = $this->model->isAttributeRequired($attrName);
}
/*
* Get field options from model
*/
$optionModelTypes = ['dropdown', 'radio', 'checkboxlist', 'balloon-selector'];
if (in_array($field->type, $optionModelTypes, false)) {
/*
* Defer the execution of option data collection
*/
$field->options(function () use ($field, $config) {
$fieldOptions = $config['options'] ?? null;
$fieldOptions = $this->getOptionsFromModel($field, $fieldOptions);
return $fieldOptions;
});
}
return $field;
} | [
"protected",
"function",
"makeFormField",
"(",
"$",
"name",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"label",
"=",
"$",
"config",
"[",
"'label'",
"]",
"??",
"null",
";",
"list",
"(",
"$",
"fieldName",
",",
"$",
"fieldContext",
")",
"=",
"$... | Creates a form field object from name and configuration.
@param string $name
@param array $config
@return FormField | [
"Creates",
"a",
"form",
"field",
"object",
"from",
"name",
"and",
"configuration",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L781-L884 | train | Creates a form field object | [
30522,
5123,
3853,
2191,
14192,
3790,
1006,
1002,
2171,
1010,
1002,
9530,
8873,
2290,
1027,
1031,
1033,
1007,
1063,
1002,
3830,
1027,
30524,
1027,
2047,
2433,
3790,
1006,
1002,
2492,
18442,
1010,
1002,
3830,
1007,
1025,
2065,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/FileIntegrity.php | FileIntegrity.getFilesFoundButNotExpected | protected static function getFilesFoundButNotExpected()
{
$files = \Piwik\Manifest::$files;
$pluginsInManifest = self::getPluginsFoundInManifest();
$filesFoundButNotExpected = array();
foreach (self::getPathsToInvestigate() as $file) {
if (is_dir($file)) {
continue;
}
$file = substr($file, strlen(PIWIK_DOCUMENT_ROOT)); // remove piwik path to match format in manifest.inc.php
$file = ltrim($file, "\\/");
if (self::isFileFromPluginNotInManifest($file, $pluginsInManifest)) {
continue;
}
if (self::isFileNotInManifestButExpectedAnyway($file)) {
continue;
}
if (self::isFileFromDirectoryThatShouldBeDeleted($file)) {
// we already report the directory as "Directory to delete" so no need to repeat the instruction for each file
continue;
}
if (!isset($files[$file])) {
$filesFoundButNotExpected[] = $file;
}
}
return $filesFoundButNotExpected;
} | php | protected static function getFilesFoundButNotExpected()
{
$files = \Piwik\Manifest::$files;
$pluginsInManifest = self::getPluginsFoundInManifest();
$filesFoundButNotExpected = array();
foreach (self::getPathsToInvestigate() as $file) {
if (is_dir($file)) {
continue;
}
$file = substr($file, strlen(PIWIK_DOCUMENT_ROOT)); // remove piwik path to match format in manifest.inc.php
$file = ltrim($file, "\\/");
if (self::isFileFromPluginNotInManifest($file, $pluginsInManifest)) {
continue;
}
if (self::isFileNotInManifestButExpectedAnyway($file)) {
continue;
}
if (self::isFileFromDirectoryThatShouldBeDeleted($file)) {
// we already report the directory as "Directory to delete" so no need to repeat the instruction for each file
continue;
}
if (!isset($files[$file])) {
$filesFoundButNotExpected[] = $file;
}
}
return $filesFoundButNotExpected;
} | [
"protected",
"static",
"function",
"getFilesFoundButNotExpected",
"(",
")",
"{",
"$",
"files",
"=",
"\\",
"Piwik",
"\\",
"Manifest",
"::",
"$",
"files",
";",
"$",
"pluginsInManifest",
"=",
"self",
"::",
"getPluginsFoundInManifest",
"(",
")",
";",
"$",
"filesFo... | Look for files which are in the filesystem, but should not be
@return array | [
"Look",
"for",
"files",
"which",
"are",
"in",
"the",
"filesystem",
"but",
"should",
"not",
"be"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FileIntegrity.php#L201-L232 | train | Returns the list of files that should be investigated but not expected | [
30522,
5123,
10763,
3853,
2131,
8873,
4244,
14876,
8630,
8569,
2102,
22074,
2595,
5051,
10985,
1006,
1007,
1063,
1002,
6764,
1027,
1032,
14255,
9148,
2243,
1032,
19676,
1024,
1024,
1002,
6764,
1025,
1002,
13354,
7076,
2378,
20799,
14081,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/ChildDefinition.php | ChildDefinition.getArgument | public function getArgument($index)
{
if (\array_key_exists('index_'.$index, $this->arguments)) {
return $this->arguments['index_'.$index];
}
return parent::getArgument($index);
} | php | public function getArgument($index)
{
if (\array_key_exists('index_'.$index, $this->arguments)) {
return $this->arguments['index_'.$index];
}
return parent::getArgument($index);
} | [
"public",
"function",
"getArgument",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"\\",
"array_key_exists",
"(",
"'index_'",
".",
"$",
"index",
",",
"$",
"this",
"->",
"arguments",
")",
")",
"{",
"return",
"$",
"this",
"->",
"arguments",
"[",
"'index_'",
".... | Gets an argument to pass to the service constructor/factory method.
If replaceArgument() has been used to replace an argument, this method
will return the replacement value.
@param int|string $index
@return mixed The argument value
@throws OutOfBoundsException When the argument does not exist | [
"Gets",
"an",
"argument",
"to",
"pass",
"to",
"the",
"service",
"constructor",
"/",
"factory",
"method",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/ChildDefinition.php#L72-L79 | train | Get an argument from the arguments array | [
30522,
2270,
3853,
2131,
2906,
22850,
4765,
1006,
1002,
5950,
1007,
1063,
2065,
1006,
1032,
9140,
1035,
3145,
1035,
6526,
1006,
1005,
5950,
1035,
1005,
1012,
1002,
5950,
1010,
1002,
2023,
1011,
1028,
9918,
1007,
1007,
1063,
2709,
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... |
matomo-org/matomo | libs/Zend/Validate/Identical.php | Zend_Validate_Identical.setToken | public function setToken($token)
{
$this->_tokenString = (string) $token;
$this->_token = $token;
return $this;
} | php | public function setToken($token)
{
$this->_tokenString = (string) $token;
$this->_token = $token;
return $this;
} | [
"public",
"function",
"setToken",
"(",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"_tokenString",
"=",
"(",
"string",
")",
"$",
"token",
";",
"$",
"this",
"->",
"_token",
"=",
"$",
"token",
";",
"return",
"$",
"this",
";",
"}"
] | Set token against which to compare
@param mixed $token
@return Zend_Validate_Identical | [
"Set",
"token",
"against",
"which",
"to",
"compare"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Identical.php#L103-L108 | train | Set the token to use for this page | [
30522,
2270,
3853,
2275,
18715,
2368,
1006,
1002,
19204,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
19204,
3367,
4892,
1027,
1006,
5164,
1007,
1002,
19204,
1025,
1002,
2023,
1011,
1028,
1035,
19204,
1027,
1002,
19204,
1025,
2709,
1002,
2023,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Columns/Dimension.php | Dimension.getSqlSegment | public function getSqlSegment()
{
if (!empty($this->sqlSegment)) {
return $this->sqlSegment;
}
if ($this->dbTableName && $this->columnName) {
return $this->dbTableName . '.' . $this->columnName;
}
} | php | public function getSqlSegment()
{
if (!empty($this->sqlSegment)) {
return $this->sqlSegment;
}
if ($this->dbTableName && $this->columnName) {
return $this->dbTableName . '.' . $this->columnName;
}
} | [
"public",
"function",
"getSqlSegment",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"sqlSegment",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sqlSegment",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"dbTableName",
"&&",
"$",
"this",
... | Returns a sql segment expression for this dimension.
@return string
@api since Piwik 3.2.0 | [
"Returns",
"a",
"sql",
"segment",
"expression",
"for",
"this",
"dimension",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L677-L686 | train | Get SQL Segment | [
30522,
2270,
3853,
4152,
4160,
4877,
13910,
3672,
1006,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
2023,
1011,
1028,
29296,
3366,
21693,
4765,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
29296,
3366,
21693,
4765,
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... |
laravel/framework | src/Illuminate/Foundation/Console/KeyGenerateCommand.php | KeyGenerateCommand.handle | public function handle()
{
$key = $this->generateRandomKey();
if ($this->option('show')) {
return $this->line('<comment>'.$key.'</comment>');
}
// Next, we will replace the application key in the environment file so it is
// automatically setup for this developer. This key gets generated using a
// secure random byte generator and is later base64 encoded for storage.
if (! $this->setKeyInEnvironmentFile($key)) {
return;
}
$this->laravel['config']['app.key'] = $key;
$this->info('Application key set successfully.');
} | php | public function handle()
{
$key = $this->generateRandomKey();
if ($this->option('show')) {
return $this->line('<comment>'.$key.'</comment>');
}
// Next, we will replace the application key in the environment file so it is
// automatically setup for this developer. This key gets generated using a
// secure random byte generator and is later base64 encoded for storage.
if (! $this->setKeyInEnvironmentFile($key)) {
return;
}
$this->laravel['config']['app.key'] = $key;
$this->info('Application key set successfully.');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"generateRandomKey",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'show'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"line",
"(",
"'<comment>'",
".... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php#L34-L52 | train | Handle the application key setup | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
3145,
1027,
1002,
2023,
1011,
1028,
9699,
13033,
5358,
14839,
1006,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
2265,
1005,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Rule/MimeType.php | HTML_QuickForm2_Rule_MimeType.validateOwner | protected function validateOwner()
{
$value = $this->owner->getValue();
if (!isset($value['error']) || UPLOAD_ERR_NO_FILE == $value['error']) {
return true;
}
$mime = $this->getConfig();
return is_array($mime)? in_array($value['type'], $mime):
$value['type'] == $mime;
} | php | protected function validateOwner()
{
$value = $this->owner->getValue();
if (!isset($value['error']) || UPLOAD_ERR_NO_FILE == $value['error']) {
return true;
}
$mime = $this->getConfig();
return is_array($mime)? in_array($value['type'], $mime):
$value['type'] == $mime;
} | [
"protected",
"function",
"validateOwner",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"owner",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
"[",
"'error'",
"]",
")",
"||",
"UPLOAD_ERR_NO_FILE",
"==",
"$",
"val... | Validates the owner element
@return bool whether uploaded file's MIME type is correct | [
"Validates",
"the",
"owner",
"element"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule/MimeType.php#L75-L84 | train | Validate owner value | [
30522,
5123,
3853,
9398,
3686,
12384,
2121,
1006,
1007,
1063,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
3954,
1011,
1028,
2131,
10175,
5657,
1006,
1007,
1025,
2065,
1006,
999,
26354,
3388,
1006,
1002,
3643,
1031,
1005,
7561,
1005,
1033,
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/LanguagesManager/TranslationWriter/Writer.php | Writer.setLanguage | public function setLanguage($language)
{
if (!preg_match('/^([a-z]{2,3}(-[a-z]{2,3})?)$/i', $language)) {
throw new Exception(Piwik::translate('General_ExceptionLanguageFileNotFound', array($language)));
}
$this->language = strtolower($language);
} | php | public function setLanguage($language)
{
if (!preg_match('/^([a-z]{2,3}(-[a-z]{2,3})?)$/i', $language)) {
throw new Exception(Piwik::translate('General_ExceptionLanguageFileNotFound', array($language)));
}
$this->language = strtolower($language);
} | [
"public",
"function",
"setLanguage",
"(",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^([a-z]{2,3}(-[a-z]{2,3})?)$/i'",
",",
"$",
"language",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Piwik",
"::",
"translate",
"(",
"'General_Excep... | @param string $language ISO 639-1 alpha-2 language code
@throws \Exception | [
"@param",
"string",
"$language",
"ISO",
"639",
"-",
"1",
"alpha",
"-",
"2",
"language",
"code"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/TranslationWriter/Writer.php#L107-L114 | train | Sets the language of the language file. | [
30522,
2270,
3853,
2275,
25023,
6692,
3351,
1006,
1002,
2653,
1007,
1063,
2065,
1006,
999,
3653,
2290,
1035,
2674,
1006,
1005,
1013,
1034,
1006,
1031,
1037,
1011,
1062,
1033,
1063,
1016,
1010,
1017,
1065,
1006,
1011,
1031,
1037,
1011,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpClient/Response/CurlResponse.php | CurlResponse.getInfo | public function getInfo(string $type = null)
{
if (!$info = $this->finalInfo) {
self::perform($this->multi);
$info = array_merge($this->info, curl_getinfo($this->handle));
$info['url'] = $this->info['url'] ?? $info['url'];
$info['redirect_url'] = $this->info['redirect_url'] ?? null;
// workaround curl not subtracting the time offset for pushed responses
if (isset($this->info['url']) && $info['start_time'] / 1000 < $info['total_time']) {
$info['total_time'] -= $info['starttransfer_time'] ?: $info['total_time'];
$info['starttransfer_time'] = 0.0;
}
if (!\in_array(curl_getinfo($this->handle, CURLINFO_PRIVATE), ['headers', 'content'], true)) {
$this->finalInfo = $info;
}
}
return null !== $type ? $info[$type] ?? null : $info;
} | php | public function getInfo(string $type = null)
{
if (!$info = $this->finalInfo) {
self::perform($this->multi);
$info = array_merge($this->info, curl_getinfo($this->handle));
$info['url'] = $this->info['url'] ?? $info['url'];
$info['redirect_url'] = $this->info['redirect_url'] ?? null;
// workaround curl not subtracting the time offset for pushed responses
if (isset($this->info['url']) && $info['start_time'] / 1000 < $info['total_time']) {
$info['total_time'] -= $info['starttransfer_time'] ?: $info['total_time'];
$info['starttransfer_time'] = 0.0;
}
if (!\in_array(curl_getinfo($this->handle, CURLINFO_PRIVATE), ['headers', 'content'], true)) {
$this->finalInfo = $info;
}
}
return null !== $type ? $info[$type] ?? null : $info;
} | [
"public",
"function",
"getInfo",
"(",
"string",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"info",
"=",
"$",
"this",
"->",
"finalInfo",
")",
"{",
"self",
"::",
"perform",
"(",
"$",
"this",
"->",
"multi",
")",
";",
"$",
"info",
"=",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/Response/CurlResponse.php#L142-L162 | train | Get info from curl handle | [
30522,
2270,
3853,
2131,
2378,
14876,
1006,
5164,
1002,
2828,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1002,
18558,
1027,
1002,
2023,
1011,
1028,
2345,
2378,
14876,
1007,
1063,
2969,
1024,
1024,
4685,
1006,
1002,
2023,
1011,
1028,
4800,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MorphTo.php | MorphTo.replayMacros | protected function replayMacros(Builder $query)
{
foreach ($this->macroBuffer as $macro) {
$query->{$macro['method']}(...$macro['parameters']);
}
return $query;
} | php | protected function replayMacros(Builder $query)
{
foreach ($this->macroBuffer as $macro) {
$query->{$macro['method']}(...$macro['parameters']);
}
return $query;
} | [
"protected",
"function",
"replayMacros",
"(",
"Builder",
"$",
"query",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"macroBuffer",
"as",
"$",
"macro",
")",
"{",
"$",
"query",
"->",
"{",
"$",
"macro",
"[",
"'method'",
"]",
"}",
"(",
"...",
"$",
"macro... | Replay stored macro calls on the actual related instance.
@param \Illuminate\Database\Eloquent\Builder $query
@return \Illuminate\Database\Eloquent\Builder | [
"Replay",
"stored",
"macro",
"calls",
"on",
"the",
"actual",
"related",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/MorphTo.php#L262-L269 | train | Replay macro buffer | [
30522,
5123,
3853,
15712,
22911,
7352,
1006,
12508,
1002,
23032,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
26632,
8569,
12494,
2004,
1002,
26632,
1007,
1063,
1002,
23032,
1011,
1028,
1063,
1002,
26632,
1031,
1005,
4118,
1005,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Broadcasting/BroadcastController.php | BroadcastController.authenticate | public function authenticate(Request $request)
{
if ($request->hasSession()) {
$request->session()->reflash();
}
return Broadcast::auth($request);
} | php | public function authenticate(Request $request)
{
if ($request->hasSession()) {
$request->session()->reflash();
}
return Broadcast::auth($request);
} | [
"public",
"function",
"authenticate",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"hasSession",
"(",
")",
")",
"{",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"reflash",
"(",
")",
";",
"}",
"return",
"Broadcast",
... | Authenticate the request for channel access.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"Authenticate",
"the",
"request",
"for",
"channel",
"access",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Broadcasting/BroadcastController.php#L17-L24 | train | Authenticates the user | [
30522,
2270,
3853,
14469,
3686,
1006,
5227,
1002,
5227,
1007,
1063,
2065,
1006,
1002,
5227,
1011,
1028,
2038,
8583,
10992,
1006,
1007,
1007,
1063,
1002,
5227,
1011,
1028,
5219,
1006,
1007,
1011,
1028,
25416,
27067,
1006,
1007,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/Skin.php | Skin.getPath | public function getPath($path = null, $isPublic = false)
{
$path = RouterHelper::normalizeUrl($path);
$assetFile = $this->skinPath . $path;
if (File::isFile($assetFile)) {
return $isPublic
? $this->publicSkinPath . $path
: $this->skinPath . $path;
}
return $isPublic
? $this->defaultPublicSkinPath . $path
: $this->defaultSkinPath . $path;
} | php | public function getPath($path = null, $isPublic = false)
{
$path = RouterHelper::normalizeUrl($path);
$assetFile = $this->skinPath . $path;
if (File::isFile($assetFile)) {
return $isPublic
? $this->publicSkinPath . $path
: $this->skinPath . $path;
}
return $isPublic
? $this->defaultPublicSkinPath . $path
: $this->defaultSkinPath . $path;
} | [
"public",
"function",
"getPath",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"isPublic",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"RouterHelper",
"::",
"normalizeUrl",
"(",
"$",
"path",
")",
";",
"$",
"assetFile",
"=",
"$",
"this",
"->",
"skinPath",
".... | Looks up a path to a skin-based file, if it doesn't exist, the default path is used.
@param string $path
@param boolean $isPublic
@return string | [
"Looks",
"up",
"a",
"path",
"to",
"a",
"skin",
"-",
"based",
"file",
"if",
"it",
"doesn",
"t",
"exist",
"the",
"default",
"path",
"is",
"used",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Skin.php#L73-L87 | train | Get path to skin | [
30522,
2270,
3853,
2131,
15069,
1006,
1002,
4130,
1027,
19701,
1010,
1002,
2003,
14289,
16558,
2594,
1027,
6270,
1007,
1063,
1002,
4130,
1027,
2799,
25032,
2884,
4842,
1024,
1024,
3671,
4697,
3126,
2140,
1006,
1002,
4130,
1007,
1025,
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... |
getgrav/grav | system/src/Grav/Common/Page/Medium/Medium.php | Medium.classes | public function classes()
{
$classes = func_get_args();
if (!empty($classes)) {
$this->attributes['class'] = implode(',', $classes);
}
return $this;
} | php | public function classes()
{
$classes = func_get_args();
if (!empty($classes)) {
$this->attributes['class'] = implode(',', $classes);
}
return $this;
} | [
"public",
"function",
"classes",
"(",
")",
"{",
"$",
"classes",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"implode",
"(",
"','",
",",... | Add a class to the element from Markdown or Twig
Example:  or 
@return $this | [
"Add",
"a",
"class",
"to",
"the",
"element",
"from",
"Markdown",
"or",
"Twig",
"Example",
":",
"!",
"[",
"Example",
"]",
"(",
"myimg",
".",
"png?classes",
"=",
"float",
"-",
"left",
")",
"or",
"!",
"[",
"Example",
"]",
"(",
"myimg",
".",
"png?classes... | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/Medium.php#L582-L590 | train | Set the classes to be displayed in the form field | [
30522,
2270,
3853,
4280,
1006,
1007,
1063,
1002,
4280,
1027,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
1025,
2065,
1006,
999,
4064,
1006,
1002,
4280,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
12332,
1031,
1005,
2465,
1005,
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/widgets/Lists.php | Lists.onSort | public function onSort()
{
if ($column = post('sortColumn')) {
/*
* Toggle the sort direction and set the sorting column
*/
$sortOptions = ['column' => $this->getSortColumn(), 'direction' => $this->sortDirection];
if ($column != $sortOptions['column'] || $sortOptions['direction'] == 'asc') {
$this->sortDirection = $sortOptions['direction'] = 'desc';
}
else {
$this->sortDirection = $sortOptions['direction'] = 'asc';
}
$this->sortColumn = $sortOptions['column'] = $column;
$this->putSession('sort', $sortOptions);
/*
* Persist the page number
*/
$this->currentPageNumber = post('page');
return $this->onRefresh();
}
} | php | public function onSort()
{
if ($column = post('sortColumn')) {
/*
* Toggle the sort direction and set the sorting column
*/
$sortOptions = ['column' => $this->getSortColumn(), 'direction' => $this->sortDirection];
if ($column != $sortOptions['column'] || $sortOptions['direction'] == 'asc') {
$this->sortDirection = $sortOptions['direction'] = 'desc';
}
else {
$this->sortDirection = $sortOptions['direction'] = 'asc';
}
$this->sortColumn = $sortOptions['column'] = $column;
$this->putSession('sort', $sortOptions);
/*
* Persist the page number
*/
$this->currentPageNumber = post('page');
return $this->onRefresh();
}
} | [
"public",
"function",
"onSort",
"(",
")",
"{",
"if",
"(",
"$",
"column",
"=",
"post",
"(",
"'sortColumn'",
")",
")",
"{",
"/*\n * Toggle the sort direction and set the sorting column\n */",
"$",
"sortOptions",
"=",
"[",
"'column'",
"=>",
"$",
... | Event handler for sorting the list. | [
"Event",
"handler",
"for",
"sorting",
"the",
"list",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1461-L1488 | train | On Sort event | [
30522,
2270,
3853,
2006,
21748,
2102,
1006,
1007,
1063,
2065,
1006,
1002,
5930,
1027,
2695,
1006,
1005,
4066,
25778,
2819,
2078,
1005,
1007,
1007,
1063,
1013,
1008,
1008,
2000,
24679,
1996,
4066,
3257,
1998,
2275,
1996,
22210,
5930,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/IntervalTrait.php | IntervalTrait.validateCronSequence | private function validateCronSequence($minute = null, $hour = null, $day = null, $month = null, $weekday = null)
{
return [
'minute' => $this->validateCronRange($minute, 0, 59),
'hour' => $this->validateCronRange($hour, 0, 23),
'day' => $this->validateCronRange($day, 1, 31),
'month' => $this->validateCronRange($month, 1, 12),
'weekday' => $this->validateCronRange($weekday, 0, 6),
];
} | php | private function validateCronSequence($minute = null, $hour = null, $day = null, $month = null, $weekday = null)
{
return [
'minute' => $this->validateCronRange($minute, 0, 59),
'hour' => $this->validateCronRange($hour, 0, 23),
'day' => $this->validateCronRange($day, 1, 31),
'month' => $this->validateCronRange($month, 1, 12),
'weekday' => $this->validateCronRange($weekday, 0, 6),
];
} | [
"private",
"function",
"validateCronSequence",
"(",
"$",
"minute",
"=",
"null",
",",
"$",
"hour",
"=",
"null",
",",
"$",
"day",
"=",
"null",
",",
"$",
"month",
"=",
"null",
",",
"$",
"weekday",
"=",
"null",
")",
"{",
"return",
"[",
"'minute'",
"=>",
... | Validate sequence of cron expression.
@param int|string $minute
@param int|string $hour
@param int|string $day
@param int|string $month
@param int|string $weekday
@return array | [
"Validate",
"sequence",
"of",
"cron",
"expression",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/IntervalTrait.php#L363-L372 | train | Validate Cron Sequence | [
30522,
2797,
3853,
9398,
3686,
26775,
5644,
2063,
4226,
5897,
1006,
1002,
3371,
1027,
19701,
1010,
1002,
3178,
1027,
19701,
1010,
1002,
2154,
1027,
19701,
1010,
1002,
3204,
1027,
19701,
1010,
1002,
16904,
1027,
19701,
1007,
1063,
2709,
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/Loader/XmlFileLoader.php | XmlFileLoader.processAnonymousServices | private function processAnonymousServices(\DOMDocument $xml, $file, $defaults)
{
$definitions = [];
$count = 0;
$suffix = '~'.ContainerBuilder::hash($file);
$xpath = new \DOMXPath($xml);
$xpath->registerNamespace('container', self::NS);
// anonymous services as arguments/properties
if (false !== $nodes = $xpath->query('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]|//container:bind[not(@id)]|//container:factory[not(@service)]|//container:configurator[not(@service)]')) {
foreach ($nodes as $node) {
if ($services = $this->getChildren($node, 'service')) {
// give it a unique name
$id = sprintf('.%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $services[0]->getAttribute('class')).$suffix);
$node->setAttribute('id', $id);
$node->setAttribute('service', $id);
$definitions[$id] = [$services[0], $file];
$services[0]->setAttribute('id', $id);
// anonymous services are always private
// we could not use the constant false here, because of XML parsing
$services[0]->setAttribute('public', 'false');
}
}
}
// anonymous services "in the wild"
if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) {
foreach ($nodes as $node) {
throw new InvalidArgumentException(sprintf('Top-level services must have "id" attribute, none found in %s at line %d.', $file, $node->getLineNo()));
}
}
// resolve definitions
uksort($definitions, 'strnatcmp');
foreach (array_reverse($definitions) as $id => list($domElement, $file)) {
if (null !== $definition = $this->parseDefinition($domElement, $file, [])) {
$this->setDefinition($id, $definition);
}
}
} | php | private function processAnonymousServices(\DOMDocument $xml, $file, $defaults)
{
$definitions = [];
$count = 0;
$suffix = '~'.ContainerBuilder::hash($file);
$xpath = new \DOMXPath($xml);
$xpath->registerNamespace('container', self::NS);
// anonymous services as arguments/properties
if (false !== $nodes = $xpath->query('//container:argument[@type="service"][not(@id)]|//container:property[@type="service"][not(@id)]|//container:bind[not(@id)]|//container:factory[not(@service)]|//container:configurator[not(@service)]')) {
foreach ($nodes as $node) {
if ($services = $this->getChildren($node, 'service')) {
// give it a unique name
$id = sprintf('.%d_%s', ++$count, preg_replace('/^.*\\\\/', '', $services[0]->getAttribute('class')).$suffix);
$node->setAttribute('id', $id);
$node->setAttribute('service', $id);
$definitions[$id] = [$services[0], $file];
$services[0]->setAttribute('id', $id);
// anonymous services are always private
// we could not use the constant false here, because of XML parsing
$services[0]->setAttribute('public', 'false');
}
}
}
// anonymous services "in the wild"
if (false !== $nodes = $xpath->query('//container:services/container:service[not(@id)]')) {
foreach ($nodes as $node) {
throw new InvalidArgumentException(sprintf('Top-level services must have "id" attribute, none found in %s at line %d.', $file, $node->getLineNo()));
}
}
// resolve definitions
uksort($definitions, 'strnatcmp');
foreach (array_reverse($definitions) as $id => list($domElement, $file)) {
if (null !== $definition = $this->parseDefinition($domElement, $file, [])) {
$this->setDefinition($id, $definition);
}
}
} | [
"private",
"function",
"processAnonymousServices",
"(",
"\\",
"DOMDocument",
"$",
"xml",
",",
"$",
"file",
",",
"$",
"defaults",
")",
"{",
"$",
"definitions",
"=",
"[",
"]",
";",
"$",
"count",
"=",
"0",
";",
"$",
"suffix",
"=",
"'~'",
".",
"ContainerBu... | Processes anonymous services.
@param \DOMDocument $xml
@param string $file
@param array $defaults | [
"Processes",
"anonymous",
"services",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php#L428-L470 | train | Process anonymous services | [
30522,
2797,
3853,
2832,
6761,
4890,
27711,
8043,
7903,
2229,
1006,
1032,
14383,
3527,
24894,
4765,
1002,
20950,
1010,
1002,
5371,
1010,
1002,
12398,
2015,
1007,
1063,
1002,
15182,
1027,
1031,
1033,
1025,
1002,
4175,
1027,
1014,
1025,
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/Db/Adapter/Db2.php | Zend_Db_Adapter_Db2.lastSequenceId | public function lastSequenceId($sequenceName)
{
$this->_connect();
if (!$this->_isI5) {
$quotedSequenceName = $this->quoteIdentifier($sequenceName, true);
$sql = 'SELECT PREVVAL FOR ' . $quotedSequenceName . ' AS VAL FROM SYSIBM.SYSDUMMY1';
} else {
$quotedSequenceName = $sequenceName;
$sql = 'SELECT PREVVAL FOR ' . $this->quoteIdentifier($sequenceName, true) . ' AS VAL FROM QSYS2.QSQPTABL';
}
$value = $this->fetchOne($sql);
return (string) $value;
} | php | public function lastSequenceId($sequenceName)
{
$this->_connect();
if (!$this->_isI5) {
$quotedSequenceName = $this->quoteIdentifier($sequenceName, true);
$sql = 'SELECT PREVVAL FOR ' . $quotedSequenceName . ' AS VAL FROM SYSIBM.SYSDUMMY1';
} else {
$quotedSequenceName = $sequenceName;
$sql = 'SELECT PREVVAL FOR ' . $this->quoteIdentifier($sequenceName, true) . ' AS VAL FROM QSYS2.QSQPTABL';
}
$value = $this->fetchOne($sql);
return (string) $value;
} | [
"public",
"function",
"lastSequenceId",
"(",
"$",
"sequenceName",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_isI5",
")",
"{",
"$",
"quotedSequenceName",
"=",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"... | Return the most recent value from the specified sequence in the database.
This is supported only on RDBMS brands that support sequences
(e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null.
@param string $sequenceName
@return string | [
"Return",
"the",
"most",
"recent",
"value",
"from",
"the",
"specified",
"sequence",
"in",
"the",
"database",
".",
"This",
"is",
"supported",
"only",
"on",
"RDBMS",
"brands",
"that",
"support",
"sequences",
"(",
"e",
".",
"g",
".",
"Oracle",
"PostgreSQL",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Db2.php#L500-L514 | train | Get last sequence id | [
30522,
2270,
3853,
16180,
2063,
4226,
5897,
3593,
1006,
1002,
5537,
18442,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
2003,
2072,
2629,
1007,
1063,
1002,
9339,
3366,
42... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Dompdf.php | Dompdf.processHtml | private function processHtml()
{
$this->tree->build_tree();
$this->css->load_css_file(Stylesheet::getDefaultStylesheet(), Stylesheet::ORIG_UA);
$acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
$acceptedmedia[] = $this->options->getDefaultMediaType();
// <base href="" />
$base_nodes = $this->dom->getElementsByTagName("base");
if ($base_nodes->length && ($href = $base_nodes->item(0)->getAttribute("href"))) {
list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($href);
}
// Set the base path of the Stylesheet to that of the file being processed
$this->css->set_protocol($this->protocol);
$this->css->set_host($this->baseHost);
$this->css->set_base_path($this->basePath);
// Get all the stylesheets so that they are processed in document order
$xpath = new DOMXPath($this->dom);
$stylesheets = $xpath->query("//*[name() = 'link' or name() = 'style']");
/** @var \DOMElement $tag */
foreach ($stylesheets as $tag) {
switch (strtolower($tag->nodeName)) {
// load <link rel="STYLESHEET" ... /> tags
case "link":
if (mb_strtolower(stripos($tag->getAttribute("rel"), "stylesheet") !== false) || // may be "appendix stylesheet"
mb_strtolower($tag->getAttribute("type")) === "text/css"
) {
//Check if the css file is for an accepted media type
//media not given then always valid
$formedialist = preg_split("/[\s\n,]/", $tag->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
if (count($formedialist) > 0) {
$accept = false;
foreach ($formedialist as $type) {
if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
$accept = true;
break;
}
}
if (!$accept) {
//found at least one mediatype, but none of the accepted ones
//Skip this css file.
break;
}
}
$url = $tag->getAttribute("href");
$url = Helpers::build_url($this->protocol, $this->baseHost, $this->basePath, $url);
$this->css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
}
break;
// load <style> tags
case "style":
// Accept all <style> tags by default (note this is contrary to W3C
// HTML 4.0 spec:
// http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
// which states that the default media type is 'screen'
if ($tag->hasAttributes() &&
($media = $tag->getAttribute("media")) &&
!in_array($media, $acceptedmedia)
) {
break;
}
$css = "";
if ($tag->hasChildNodes()) {
$child = $tag->firstChild;
while ($child) {
$css .= $child->nodeValue; // Handle <style><!-- blah --></style>
$child = $child->nextSibling;
}
} else {
$css = $tag->nodeValue;
}
$this->css->load_css($css, Stylesheet::ORIG_AUTHOR);
break;
}
}
} | php | private function processHtml()
{
$this->tree->build_tree();
$this->css->load_css_file(Stylesheet::getDefaultStylesheet(), Stylesheet::ORIG_UA);
$acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
$acceptedmedia[] = $this->options->getDefaultMediaType();
// <base href="" />
$base_nodes = $this->dom->getElementsByTagName("base");
if ($base_nodes->length && ($href = $base_nodes->item(0)->getAttribute("href"))) {
list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($href);
}
// Set the base path of the Stylesheet to that of the file being processed
$this->css->set_protocol($this->protocol);
$this->css->set_host($this->baseHost);
$this->css->set_base_path($this->basePath);
// Get all the stylesheets so that they are processed in document order
$xpath = new DOMXPath($this->dom);
$stylesheets = $xpath->query("//*[name() = 'link' or name() = 'style']");
/** @var \DOMElement $tag */
foreach ($stylesheets as $tag) {
switch (strtolower($tag->nodeName)) {
// load <link rel="STYLESHEET" ... /> tags
case "link":
if (mb_strtolower(stripos($tag->getAttribute("rel"), "stylesheet") !== false) || // may be "appendix stylesheet"
mb_strtolower($tag->getAttribute("type")) === "text/css"
) {
//Check if the css file is for an accepted media type
//media not given then always valid
$formedialist = preg_split("/[\s\n,]/", $tag->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
if (count($formedialist) > 0) {
$accept = false;
foreach ($formedialist as $type) {
if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
$accept = true;
break;
}
}
if (!$accept) {
//found at least one mediatype, but none of the accepted ones
//Skip this css file.
break;
}
}
$url = $tag->getAttribute("href");
$url = Helpers::build_url($this->protocol, $this->baseHost, $this->basePath, $url);
$this->css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
}
break;
// load <style> tags
case "style":
// Accept all <style> tags by default (note this is contrary to W3C
// HTML 4.0 spec:
// http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
// which states that the default media type is 'screen'
if ($tag->hasAttributes() &&
($media = $tag->getAttribute("media")) &&
!in_array($media, $acceptedmedia)
) {
break;
}
$css = "";
if ($tag->hasChildNodes()) {
$child = $tag->firstChild;
while ($child) {
$css .= $child->nodeValue; // Handle <style><!-- blah --></style>
$child = $child->nextSibling;
}
} else {
$css = $tag->nodeValue;
}
$this->css->load_css($css, Stylesheet::ORIG_AUTHOR);
break;
}
}
} | [
"private",
"function",
"processHtml",
"(",
")",
"{",
"$",
"this",
"->",
"tree",
"->",
"build_tree",
"(",
")",
";",
"$",
"this",
"->",
"css",
"->",
"load_css_file",
"(",
"Stylesheet",
"::",
"getDefaultStylesheet",
"(",
")",
",",
"Stylesheet",
"::",
"ORIG_UA... | Builds the {@link FrameTree}, loads any CSS and applies the styles to
the {@link FrameTree} | [
"Builds",
"the",
"{"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L568-L654 | train | Process the HTML | [
30522,
2797,
3853,
2832,
11039,
19968,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
3392,
1011,
1028,
3857,
1035,
3392,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
20116,
2015,
1011,
1028,
7170,
1035,
20116,
2015,
1035,
5371,
1006,
6782,
21030,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/EventCacheCommand.php | EventCacheCommand.handle | public function handle()
{
$this->call('event:clear');
file_put_contents(
$this->laravel->getCachedEventsPath(),
'<?php return '.var_export($this->getEvents(), true).';'
);
$this->info('Events cached successfully!');
} | php | public function handle()
{
$this->call('event:clear');
file_put_contents(
$this->laravel->getCachedEventsPath(),
'<?php return '.var_export($this->getEvents(), true).';'
);
$this->info('Events cached successfully!');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'event:clear'",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"laravel",
"->",
"getCachedEventsPath",
"(",
")",
",",
"'<?php return '",
".",
"var_export",
"(",
"$",
"t... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/EventCacheCommand.php#L29-L39 | train | Handle the cached events | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2655,
1006,
1005,
2724,
1024,
3154,
1005,
1007,
1025,
5371,
1035,
2404,
1035,
8417,
1006,
1002,
2023,
1011,
1028,
13679,
15985,
1011,
1028,
2131,
3540,
7690,
18697,
7666,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Csrf/CsrfTokenManager.php | CsrfTokenManager.isTokenValid | public function isTokenValid(CsrfToken $token)
{
$namespacedId = $this->getNamespace().$token->getId();
if (!$this->storage->hasToken($namespacedId)) {
return false;
}
return hash_equals($this->storage->getToken($namespacedId), $token->getValue());
} | php | public function isTokenValid(CsrfToken $token)
{
$namespacedId = $this->getNamespace().$token->getId();
if (!$this->storage->hasToken($namespacedId)) {
return false;
}
return hash_equals($this->storage->getToken($namespacedId), $token->getValue());
} | [
"public",
"function",
"isTokenValid",
"(",
"CsrfToken",
"$",
"token",
")",
"{",
"$",
"namespacedId",
"=",
"$",
"this",
"->",
"getNamespace",
"(",
")",
".",
"$",
"token",
"->",
"getId",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"storage",
"->"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php#L107-L115 | train | Check if a token is valid | [
30522,
2270,
3853,
21541,
11045,
2078,
10175,
3593,
1006,
20116,
12881,
18715,
2368,
1002,
19204,
1007,
1063,
1002,
3415,
15327,
4305,
2094,
1027,
1002,
2023,
1011,
1028,
2131,
18442,
23058,
1006,
1007,
1012,
1002,
19204,
1011,
1028,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
domnikl/DesignPatternsPHP | Behavioral/ChainOfResponsibilities/Responsible/HttpInMemoryCacheHandler.php | HttpInMemoryCacheHandler.processing | protected function processing(RequestInterface $request)
{
$key = sprintf(
'%s?%s',
$request->getUri()->getPath(),
$request->getUri()->getQuery()
);
if ($request->getMethod() == 'GET' && isset($this->data[$key])) {
return $this->data[$key];
}
return null;
} | php | protected function processing(RequestInterface $request)
{
$key = sprintf(
'%s?%s',
$request->getUri()->getPath(),
$request->getUri()->getQuery()
);
if ($request->getMethod() == 'GET' && isset($this->data[$key])) {
return $this->data[$key];
}
return null;
} | [
"protected",
"function",
"processing",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"key",
"=",
"sprintf",
"(",
"'%s?%s'",
",",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
",",
"$",
"request",
"->",
"getUri",
"(",
")... | @param RequestInterface $request
@return string|null | [
"@param",
"RequestInterface",
"$request"
] | 5f5649b57ea94471e20b54eb439c6368dea07886 | https://github.com/domnikl/DesignPatternsPHP/blob/5f5649b57ea94471e20b54eb439c6368dea07886/Behavioral/ChainOfResponsibilities/Responsible/HttpInMemoryCacheHandler.php#L31-L44 | train | processing - processing - processing | [
30522,
5123,
3853,
6364,
1006,
5227,
18447,
2121,
12172,
1002,
5227,
1007,
1063,
1002,
3145,
1027,
9043,
2546,
1006,
1005,
1003,
1055,
1029,
1003,
1055,
1005,
1010,
1002,
5227,
1011,
1028,
2131,
9496,
1006,
1007,
1011,
1028,
2131,
15069,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/ProgressBar.php | ProgressBar.getFormatDefinition | public static function getFormatDefinition(string $name): ?string
{
if (!self::$formats) {
self::$formats = self::initFormats();
}
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
} | php | public static function getFormatDefinition(string $name): ?string
{
if (!self::$formats) {
self::$formats = self::initFormats();
}
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
} | [
"public",
"static",
"function",
"getFormatDefinition",
"(",
"string",
"$",
"name",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"formats",
")",
"{",
"self",
"::",
"$",
"formats",
"=",
"self",
"::",
"initFormats",
"(",
")",
";",
"}... | Gets the format for a given name.
@param string $name The format name
@return string|null A format string | [
"Gets",
"the",
"format",
"for",
"a",
"given",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/ProgressBar.php#L132-L139 | train | Get format definition by name | [
30522,
2270,
10763,
3853,
2131,
14192,
4017,
3207,
16294,
22753,
1006,
5164,
1002,
2171,
1007,
1024,
1029,
5164,
1063,
2065,
1006,
30524,
1007,
1063,
2969,
1024,
1024,
1002,
11630,
1027,
2969,
1024,
1024,
1999,
4183,
14192,
11149,
1006,
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... |
z-song/laravel-admin | src/Form/Field/File.php | File.prepare | public function prepare($file)
{
if (request()->has(static::FILE_DELETE_FLAG)) {
return $this->destroy();
}
$this->name = $this->getStoreName($file);
return $this->uploadAndDeleteOriginal($file);
} | php | public function prepare($file)
{
if (request()->has(static::FILE_DELETE_FLAG)) {
return $this->destroy();
}
$this->name = $this->getStoreName($file);
return $this->uploadAndDeleteOriginal($file);
} | [
"public",
"function",
"prepare",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"has",
"(",
"static",
"::",
"FILE_DELETE_FLAG",
")",
")",
"{",
"return",
"$",
"this",
"->",
"destroy",
"(",
")",
";",
"}",
"$",
"this",
"->",
"name",... | Prepare for saving.
@param UploadedFile|array $file
@return mixed|string | [
"Prepare",
"for",
"saving",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/File.php#L103-L112 | train | Prepare the store and upload the file | [
30522,
2270,
3853,
7374,
1006,
1002,
5371,
1007,
1063,
2065,
1006,
5227,
1006,
1007,
1011,
1028,
2038,
1006,
10763,
1024,
1024,
5371,
1035,
3972,
12870,
1035,
5210,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
6033,
1006,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/QuestionHelper.php | QuestionHelper.doAsk | private function doAsk(OutputInterface $output, Question $question)
{
$this->writePrompt($output, $question);
$inputStream = $this->inputStream ?: STDIN;
$autocomplete = $question->getAutocompleterCallback();
if (null === $autocomplete || !$this->hasSttyAvailable()) {
$ret = false;
if ($question->isHidden()) {
try {
$ret = trim($this->getHiddenResponse($output, $inputStream));
} catch (RuntimeException $e) {
if (!$question->isHiddenFallback()) {
throw $e;
}
}
}
if (false === $ret) {
$ret = fgets($inputStream, 4096);
if (false === $ret) {
throw new RuntimeException('Aborted.');
}
$ret = trim($ret);
}
} else {
$ret = trim($this->autocomplete($output, $question, $inputStream, $autocomplete));
}
if ($output instanceof ConsoleSectionOutput) {
$output->addContent($ret);
}
$ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
if ($normalizer = $question->getNormalizer()) {
return $normalizer($ret);
}
return $ret;
} | php | private function doAsk(OutputInterface $output, Question $question)
{
$this->writePrompt($output, $question);
$inputStream = $this->inputStream ?: STDIN;
$autocomplete = $question->getAutocompleterCallback();
if (null === $autocomplete || !$this->hasSttyAvailable()) {
$ret = false;
if ($question->isHidden()) {
try {
$ret = trim($this->getHiddenResponse($output, $inputStream));
} catch (RuntimeException $e) {
if (!$question->isHiddenFallback()) {
throw $e;
}
}
}
if (false === $ret) {
$ret = fgets($inputStream, 4096);
if (false === $ret) {
throw new RuntimeException('Aborted.');
}
$ret = trim($ret);
}
} else {
$ret = trim($this->autocomplete($output, $question, $inputStream, $autocomplete));
}
if ($output instanceof ConsoleSectionOutput) {
$output->addContent($ret);
}
$ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
if ($normalizer = $question->getNormalizer()) {
return $normalizer($ret);
}
return $ret;
} | [
"private",
"function",
"doAsk",
"(",
"OutputInterface",
"$",
"output",
",",
"Question",
"$",
"question",
")",
"{",
"$",
"this",
"->",
"writePrompt",
"(",
"$",
"output",
",",
"$",
"question",
")",
";",
"$",
"inputStream",
"=",
"$",
"this",
"->",
"inputStr... | Asks the question to the user.
@return bool|mixed|string|null
@throws RuntimeException In case the fallback is deactivated and the response cannot be hidden | [
"Asks",
"the",
"question",
"to",
"the",
"user",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/QuestionHelper.php#L113-L154 | train | Asks the user for input. | [
30522,
2797,
3853,
2079,
19895,
1006,
6434,
18447,
2121,
12172,
1002,
6434,
1010,
3160,
1002,
3160,
1007,
1063,
1002,
2023,
1011,
1028,
4339,
21572,
27718,
1006,
1002,
6434,
1010,
1002,
3160,
1007,
1025,
1002,
20407,
25379,
1027,
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... |
z-song/laravel-admin | src/Form/Footer.php | Footer.disableReset | public function disableReset(bool $disable = true)
{
if ($disable) {
array_delete($this->buttons, 'reset');
} elseif (!in_array('reset', $this->buttons)) {
array_push($this->buttons, 'reset');
}
return $this;
} | php | public function disableReset(bool $disable = true)
{
if ($disable) {
array_delete($this->buttons, 'reset');
} elseif (!in_array('reset', $this->buttons)) {
array_push($this->buttons, 'reset');
}
return $this;
} | [
"public",
"function",
"disableReset",
"(",
"bool",
"$",
"disable",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"disable",
")",
"{",
"array_delete",
"(",
"$",
"this",
"->",
"buttons",
",",
"'reset'",
")",
";",
"}",
"elseif",
"(",
"!",
"in_array",
"(",
"'re... | Disable reset button.
@return $this | [
"Disable",
"reset",
"button",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Footer.php#L53-L62 | train | Disable reset button | [
30522,
2270,
3853,
4487,
19150,
6072,
3388,
1006,
22017,
2140,
1002,
4487,
19150,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
4487,
19150,
1007,
1063,
9140,
1035,
3972,
12870,
1006,
1002,
2023,
1011,
1028,
11287,
1010,
1005,
25141,
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... |
laravel/framework | src/Illuminate/Support/Collection.php | Collection.operatorForWhere | protected function operatorForWhere($key, $operator = null, $value = null)
{
if (func_num_args() === 1) {
$value = true;
$operator = '=';
}
if (func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
return function ($item) use ($key, $operator, $value) {
$retrieved = data_get($item, $key);
$strings = array_filter([$retrieved, $value], function ($value) {
return is_string($value) || (is_object($value) && method_exists($value, '__toString'));
});
if (count($strings) < 2 && count(array_filter([$retrieved, $value], 'is_object')) == 1) {
return in_array($operator, ['!=', '<>', '!==']);
}
switch ($operator) {
default:
case '=':
case '==': return $retrieved == $value;
case '!=':
case '<>': return $retrieved != $value;
case '<': return $retrieved < $value;
case '>': return $retrieved > $value;
case '<=': return $retrieved <= $value;
case '>=': return $retrieved >= $value;
case '===': return $retrieved === $value;
case '!==': return $retrieved !== $value;
}
};
} | php | protected function operatorForWhere($key, $operator = null, $value = null)
{
if (func_num_args() === 1) {
$value = true;
$operator = '=';
}
if (func_num_args() === 2) {
$value = $operator;
$operator = '=';
}
return function ($item) use ($key, $operator, $value) {
$retrieved = data_get($item, $key);
$strings = array_filter([$retrieved, $value], function ($value) {
return is_string($value) || (is_object($value) && method_exists($value, '__toString'));
});
if (count($strings) < 2 && count(array_filter([$retrieved, $value], 'is_object')) == 1) {
return in_array($operator, ['!=', '<>', '!==']);
}
switch ($operator) {
default:
case '=':
case '==': return $retrieved == $value;
case '!=':
case '<>': return $retrieved != $value;
case '<': return $retrieved < $value;
case '>': return $retrieved > $value;
case '<=': return $retrieved <= $value;
case '>=': return $retrieved >= $value;
case '===': return $retrieved === $value;
case '!==': return $retrieved !== $value;
}
};
} | [
"protected",
"function",
"operatorForWhere",
"(",
"$",
"key",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"$",
"value",
"=",
"true",
";",
"$",
"operator",
... | Get an operator checker callback.
@param string $key
@param string $operator
@param mixed $value
@return \Closure | [
"Get",
"an",
"operator",
"checker",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Collection.php#L656-L695 | train | Returns a closure that will check if the value of the key matches the value of the operator | [
30522,
5123,
3853,
6872,
29278,
2860,
5886,
2063,
1006,
1002,
3145,
1010,
1002,
6872,
1027,
19701,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
4569,
2278,
1035,
16371,
2213,
1035,
12098,
5620,
1006,
1007,
1027,
1027,
1027,
1015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CoreHome/Controller.php | Controller.redirectToPaypal | public function redirectToPaypal()
{
$parameters = Request::getRequestArrayFromString($request = null);
foreach ($parameters as $name => $param) {
if ($name == 'idSite'
|| $name == 'module'
|| $name == 'action'
) {
unset($parameters[$name]);
}
}
$paypalParameters = [
"cmd" => "_s-xclick"
];
if (empty($parameters["onetime"]) || $parameters["onetime"] != "true") {
$paypalParameters["hosted_button_id"] = "DVKLY73RS7JTE";
$paypalParameters["currency_code"] = "USD";
$paypalParameters["on0"] = "Piwik Supporter";
if (!empty($parameters["os0"])) {
$paypalParameters["os0"] = $parameters["os0"];
}
} else {
$paypalParameters["hosted_button_id"] = "RPL23NJURMTFA";
}
$url = "https://www.paypal.com/cgi-bin/webscr?" . Url::getQueryStringFromParameters($paypalParameters);
Url::redirectToUrl($url);
exit;
} | php | public function redirectToPaypal()
{
$parameters = Request::getRequestArrayFromString($request = null);
foreach ($parameters as $name => $param) {
if ($name == 'idSite'
|| $name == 'module'
|| $name == 'action'
) {
unset($parameters[$name]);
}
}
$paypalParameters = [
"cmd" => "_s-xclick"
];
if (empty($parameters["onetime"]) || $parameters["onetime"] != "true") {
$paypalParameters["hosted_button_id"] = "DVKLY73RS7JTE";
$paypalParameters["currency_code"] = "USD";
$paypalParameters["on0"] = "Piwik Supporter";
if (!empty($parameters["os0"])) {
$paypalParameters["os0"] = $parameters["os0"];
}
} else {
$paypalParameters["hosted_button_id"] = "RPL23NJURMTFA";
}
$url = "https://www.paypal.com/cgi-bin/webscr?" . Url::getQueryStringFromParameters($paypalParameters);
Url::redirectToUrl($url);
exit;
} | [
"public",
"function",
"redirectToPaypal",
"(",
")",
"{",
"$",
"parameters",
"=",
"Request",
"::",
"getRequestArrayFromString",
"(",
"$",
"request",
"=",
"null",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"name",
"=>",
"$",
"param",
")",
"{",
... | Redirects the user to a paypal so they can donate to Piwik. | [
"Redirects",
"the",
"user",
"to",
"a",
"paypal",
"so",
"they",
"can",
"donate",
"to",
"Piwik",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreHome/Controller.php#L269-L298 | train | Redirects to PayPal | [
30522,
2270,
3853,
2417,
7442,
6593,
14399,
4710,
12952,
1006,
1007,
1063,
1002,
11709,
1027,
5227,
1024,
1024,
2131,
2890,
15500,
2906,
9447,
19699,
22225,
18886,
3070,
1006,
1002,
5227,
1027,
19701,
1007,
1025,
18921,
6776,
1006,
1002,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.urlExtension | public function urlExtension()
{
if ($this->home()) {
return '';
}
// if not set in the page get the value from system config
if (null === $this->url_extension) {
$this->url_extension = Grav::instance()['config']->get('system.pages.append_url_extension', '');
}
return $this->url_extension;
} | php | public function urlExtension()
{
if ($this->home()) {
return '';
}
// if not set in the page get the value from system config
if (null === $this->url_extension) {
$this->url_extension = Grav::instance()['config']->get('system.pages.append_url_extension', '');
}
return $this->url_extension;
} | [
"public",
"function",
"urlExtension",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"home",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"// if not set in the page get the value from system config",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"url_extension",... | Returns the page extension, got from the page `url_extension` config and falls back to the
system config `system.pages.append_url_extension`.
@return string The extension of this page. For example `.html` | [
"Returns",
"the",
"page",
"extension",
"got",
"from",
"the",
"page",
"url_extension",
"config",
"and",
"falls",
"back",
"to",
"the",
"system",
"config",
"system",
".",
"pages",
".",
"append_url_extension",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L1446-L1458 | train | Get the value of the append_url_extension property | [
30522,
2270,
3853,
24471,
2571,
18413,
6132,
3258,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2188,
1006,
1007,
1007,
1063,
2709,
1005,
1005,
1025,
1065,
1013,
1013,
2065,
2025,
2275,
1999,
1996,
3931,
2131,
1996,
3643,
2013,
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/Redis/RedisManager.php | RedisManager.resolve | public function resolve($name = null)
{
$name = $name ?: 'default';
$options = $this->config['options'] ?? [];
if (isset($this->config[$name])) {
return $this->connector()->connect($this->config[$name], $options);
}
if (isset($this->config['clusters'][$name])) {
return $this->resolveCluster($name);
}
throw new InvalidArgumentException("Redis connection [{$name}] not configured.");
} | php | public function resolve($name = null)
{
$name = $name ?: 'default';
$options = $this->config['options'] ?? [];
if (isset($this->config[$name])) {
return $this->connector()->connect($this->config[$name], $options);
}
if (isset($this->config['clusters'][$name])) {
return $this->resolveCluster($name);
}
throw new InvalidArgumentException("Redis connection [{$name}] not configured.");
} | [
"public",
"function",
"resolve",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"$",
"name",
"?",
":",
"'default'",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"config",
"[",
"'options'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"isset",... | Resolve the given connection by name.
@param string|null $name
@return \Illuminate\Redis\Connections\Connection
@throws \InvalidArgumentException | [
"Resolve",
"the",
"given",
"connection",
"by",
"name",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/RedisManager.php#L91-L106 | train | Resolve the redis connection | [
30522,
2270,
3853,
10663,
1006,
1002,
2171,
1027,
19701,
1007,
1063,
1002,
2171,
1027,
1002,
2171,
1029,
1024,
1005,
12398,
1005,
1025,
1002,
7047,
1027,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1031,
1005,
7047,
1005,
1033,
1029,
1029,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Route.php | Route.getController | public function getController()
{
if (! $this->controller) {
$class = $this->parseControllerCallback()[0];
$this->controller = $this->container->make(ltrim($class, '\\'));
}
return $this->controller;
} | php | public function getController()
{
if (! $this->controller) {
$class = $this->parseControllerCallback()[0];
$this->controller = $this->container->make(ltrim($class, '\\'));
}
return $this->controller;
} | [
"public",
"function",
"getController",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"controller",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"parseControllerCallback",
"(",
")",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"controller",
"=",
"$",... | Get the controller instance for the route.
@return mixed | [
"Get",
"the",
"controller",
"instance",
"for",
"the",
"route",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Route.php#L228-L237 | train | Get the controller | [
30522,
2270,
3853,
2131,
8663,
13181,
10820,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
11486,
1007,
1063,
1002,
2465,
1027,
1002,
2023,
1011,
1028,
11968,
3366,
8663,
13181,
10820,
9289,
20850,
8684,
1006,
1007,
1031,
1014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FilterScope.php | FilterScope.evalConfig | protected function evalConfig($config)
{
if (isset($config['options'])) {
$this->options = $config['options'];
}
if (isset($config['context'])) {
$this->context = $config['context'];
}
if (isset($config['default'])) {
$this->defaults = $config['default'];
}
if (isset($config['conditions'])) {
$this->conditions = $config['conditions'];
}
if (isset($config['scope'])) {
$this->scope = $config['scope'];
}
if (isset($config['cssClass'])) {
$this->cssClass = $config['cssClass'];
}
if (isset($config['nameFrom'])) {
$this->nameFrom = $config['nameFrom'];
}
if (isset($config['descriptionFrom'])) {
$this->descriptionFrom = $config['descriptionFrom'];
}
if (array_key_exists('disabled', $config)) {
$this->disabled = $config['disabled'];
}
return $config;
} | php | protected function evalConfig($config)
{
if (isset($config['options'])) {
$this->options = $config['options'];
}
if (isset($config['context'])) {
$this->context = $config['context'];
}
if (isset($config['default'])) {
$this->defaults = $config['default'];
}
if (isset($config['conditions'])) {
$this->conditions = $config['conditions'];
}
if (isset($config['scope'])) {
$this->scope = $config['scope'];
}
if (isset($config['cssClass'])) {
$this->cssClass = $config['cssClass'];
}
if (isset($config['nameFrom'])) {
$this->nameFrom = $config['nameFrom'];
}
if (isset($config['descriptionFrom'])) {
$this->descriptionFrom = $config['descriptionFrom'];
}
if (array_key_exists('disabled', $config)) {
$this->disabled = $config['disabled'];
}
return $config;
} | [
"protected",
"function",
"evalConfig",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"config",
"[",
"'options'",
"]",
";",
"}",
"if",
"(",
"isset"... | Process options and apply them to this object.
@param array $config
@return array | [
"Process",
"options",
"and",
"apply",
"them",
"to",
"this",
"object",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FilterScope.php#L114-L144 | train | Evaluate the config array | [
30522,
5123,
3853,
9345,
22499,
2078,
8873,
2290,
1006,
1002,
9530,
8873,
2290,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
9530,
8873,
2290,
1031,
1005,
7047,
1005,
1033,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
7047,
1027,
1002,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Settings/Storage/Backend/PluginSettingsTable.php | PluginSettingsTable.removeAllUserSettingsForUser | public static function removeAllUserSettingsForUser($userLogin)
{
if (empty($userLogin)) {
throw new Exception('No userLogin specified. Cannot remove all settings for this user');
}
try {
$table = Common::prefixTable('plugin_setting');
Db::get()->query(sprintf('DELETE FROM %s WHERE user_login = ?', $table), array($userLogin));
} catch (Exception $e) {
if ($e->getCode() != 42) {
// ignore table not found error, which might occur when updating from an older version of Piwik
throw $e;
}
}
} | php | public static function removeAllUserSettingsForUser($userLogin)
{
if (empty($userLogin)) {
throw new Exception('No userLogin specified. Cannot remove all settings for this user');
}
try {
$table = Common::prefixTable('plugin_setting');
Db::get()->query(sprintf('DELETE FROM %s WHERE user_login = ?', $table), array($userLogin));
} catch (Exception $e) {
if ($e->getCode() != 42) {
// ignore table not found error, which might occur when updating from an older version of Piwik
throw $e;
}
}
} | [
"public",
"static",
"function",
"removeAllUserSettingsForUser",
"(",
"$",
"userLogin",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"userLogin",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No userLogin specified. Cannot remove all settings for this user'",
")",
";",... | Unsets all settings for a user. The settings will be removed from the database. Used when
a user is deleted.
@internal
@param string $userLogin
@throws \Exception If the `$userLogin` is empty. Otherwise we would delete most plugin settings | [
"Unsets",
"all",
"settings",
"for",
"a",
"user",
".",
"The",
"settings",
"will",
"be",
"removed",
"from",
"the",
"database",
".",
"Used",
"when",
"a",
"user",
"is",
"deleted",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Settings/Storage/Backend/PluginSettingsTable.php#L172-L187 | train | Remove all settings for a user | [
30522,
2270,
10763,
3853,
6366,
8095,
20330,
21678,
8613,
29278,
20330,
1006,
1002,
5310,
21197,
2378,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
5310,
21197,
2378,
1007,
1007,
1063,
5466,
2047,
6453,
1006,
1005,
2053,
5310,
21197,
2378,
967... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/Connections/PhpRedisConnection.php | PhpRedisConnection.applyPrefix | private function applyPrefix($key)
{
$prefix = (string) $this->client->getOption(Redis::OPT_PREFIX);
return $prefix.$key;
} | php | private function applyPrefix($key)
{
$prefix = (string) $this->client->getOption(Redis::OPT_PREFIX);
return $prefix.$key;
} | [
"private",
"function",
"applyPrefix",
"(",
"$",
"key",
")",
"{",
"$",
"prefix",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"client",
"->",
"getOption",
"(",
"Redis",
"::",
"OPT_PREFIX",
")",
";",
"return",
"$",
"prefix",
".",
"$",
"key",
";",
"}"
] | Apply prefix to the given key if necessary.
@param string $key
@return string | [
"Apply",
"prefix",
"to",
"the",
"given",
"key",
"if",
"necessary",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Connections/PhpRedisConnection.php#L418-L423 | train | Apply prefix to the key | [
30522,
2797,
3853,
6611,
28139,
8873,
2595,
1006,
1002,
3145,
30524,
1002,
3145,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Config/Writer/Json.php | Zend_Config_Writer_Json.render | public function render()
{
$data = $this->_config->toArray();
$sectionName = $this->_config->getSectionName();
$extends = $this->_config->getExtends();
if (is_string($sectionName)) {
$data = array($sectionName => $data);
}
foreach ($extends as $section => $parentSection) {
$data[$section][Zend_Config_Json::EXTENDS_NAME] = $parentSection;
}
// Ensure that each "extends" section actually exists
foreach ($data as $section => $sectionData) {
if (is_array($sectionData) && isset($sectionData[Zend_Config_Json::EXTENDS_NAME])) {
$sectionExtends = $sectionData[Zend_Config_Json::EXTENDS_NAME];
if (!isset($data[$sectionExtends])) {
// Remove "extends" declaration if section does not exist
unset($data[$section][Zend_Config_Json::EXTENDS_NAME]);
}
}
}
$out = Zend_Json::encode($data);
if ($this->prettyPrint()) {
$out = Zend_Json::prettyPrint($out);
}
return $out;
} | php | public function render()
{
$data = $this->_config->toArray();
$sectionName = $this->_config->getSectionName();
$extends = $this->_config->getExtends();
if (is_string($sectionName)) {
$data = array($sectionName => $data);
}
foreach ($extends as $section => $parentSection) {
$data[$section][Zend_Config_Json::EXTENDS_NAME] = $parentSection;
}
// Ensure that each "extends" section actually exists
foreach ($data as $section => $sectionData) {
if (is_array($sectionData) && isset($sectionData[Zend_Config_Json::EXTENDS_NAME])) {
$sectionExtends = $sectionData[Zend_Config_Json::EXTENDS_NAME];
if (!isset($data[$sectionExtends])) {
// Remove "extends" declaration if section does not exist
unset($data[$section][Zend_Config_Json::EXTENDS_NAME]);
}
}
}
$out = Zend_Json::encode($data);
if ($this->prettyPrint()) {
$out = Zend_Json::prettyPrint($out);
}
return $out;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_config",
"->",
"toArray",
"(",
")",
";",
"$",
"sectionName",
"=",
"$",
"this",
"->",
"_config",
"->",
"getSectionName",
"(",
")",
";",
"$",
"extends",
"=",
"$",
"... | Render a Zend_Config into a JSON config string.
@since 1.10
@return string | [
"Render",
"a",
"Zend_Config",
"into",
"a",
"JSON",
"config",
"string",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer/Json.php#L75-L105 | train | Render the current configuration | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
2951,
1027,
1002,
2023,
1011,
1028,
1035,
9530,
8873,
2290,
1011,
1028,
2000,
2906,
9447,
1006,
1007,
1025,
1002,
2930,
18442,
1027,
1002,
2023,
1011,
1028,
1035,
9530,
8873,
2290,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Lock/Store/StoreFactory.php | StoreFactory.createStore | public static function createStore($connection)
{
if (
$connection instanceof \Redis ||
$connection instanceof \RedisArray ||
$connection instanceof \RedisCluster ||
$connection instanceof \Predis\Client ||
$connection instanceof RedisProxy ||
$connection instanceof RedisClusterProxy
) {
return new RedisStore($connection);
}
if ($connection instanceof \Memcached) {
return new MemcachedStore($connection);
}
if ($connection instanceof \Zookeeper) {
return new ZookeeperStore($connection);
}
if (!\is_string($connection)) {
throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', \get_class($connection)));
}
switch (true) {
case 'flock' === $connection:
return new FlockStore();
case 0 === strpos($connection, 'flock://'):
return new FlockStore(substr($connection, 8));
case 'semaphore' === $connection:
return new SemaphoreStore();
case \class_exists(AbstractAdapter::class) && preg_match('#^[a-z]++://#', $connection):
return static::createStore(AbstractAdapter::createConnection($connection));
default:
throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection));
}
} | php | public static function createStore($connection)
{
if (
$connection instanceof \Redis ||
$connection instanceof \RedisArray ||
$connection instanceof \RedisCluster ||
$connection instanceof \Predis\Client ||
$connection instanceof RedisProxy ||
$connection instanceof RedisClusterProxy
) {
return new RedisStore($connection);
}
if ($connection instanceof \Memcached) {
return new MemcachedStore($connection);
}
if ($connection instanceof \Zookeeper) {
return new ZookeeperStore($connection);
}
if (!\is_string($connection)) {
throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', \get_class($connection)));
}
switch (true) {
case 'flock' === $connection:
return new FlockStore();
case 0 === strpos($connection, 'flock://'):
return new FlockStore(substr($connection, 8));
case 'semaphore' === $connection:
return new SemaphoreStore();
case \class_exists(AbstractAdapter::class) && preg_match('#^[a-z]++://#', $connection):
return static::createStore(AbstractAdapter::createConnection($connection));
default:
throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection));
}
} | [
"public",
"static",
"function",
"createStore",
"(",
"$",
"connection",
")",
"{",
"if",
"(",
"$",
"connection",
"instanceof",
"\\",
"Redis",
"||",
"$",
"connection",
"instanceof",
"\\",
"RedisArray",
"||",
"$",
"connection",
"instanceof",
"\\",
"RedisCluster",
... | @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|\Memcached|\Zookeeper|string $connection Connection or DSN or Store short name
@return StoreInterface | [
"@param",
"\\",
"Redis|",
"\\",
"RedisArray|",
"\\",
"RedisCluster|",
"\\",
"Predis",
"\\",
"Client|",
"\\",
"Memcached|",
"\\",
"Zookeeper|string",
"$connection",
"Connection",
"or",
"DSN",
"or",
"Store",
"short",
"name"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Store/StoreFactory.php#L32-L66 | train | Create a store from a connection | [
30522,
2270,
10763,
3853,
9005,
19277,
1006,
1002,
4434,
1007,
1063,
2065,
1006,
1002,
4434,
6013,
11253,
1032,
2417,
2483,
1064,
1064,
1002,
4434,
6013,
11253,
1032,
2417,
14268,
11335,
2100,
1064,
1064,
1002,
4434,
6013,
11253,
1032,
2417... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Css/Style.php | Style.set_color | function set_color($color)
{
$col = $this->munge_color($color);
if (is_null($col) || !isset($col["hex"])) {
$color = "inherit";
} else {
$color = $col["hex"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["color"] = null;
$this->_props["color"] = $color;
} | php | function set_color($color)
{
$col = $this->munge_color($color);
if (is_null($col) || !isset($col["hex"])) {
$color = "inherit";
} else {
$color = $col["hex"];
}
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["color"] = null;
$this->_props["color"] = $color;
} | [
"function",
"set_color",
"(",
"$",
"color",
")",
"{",
"$",
"col",
"=",
"$",
"this",
"->",
"munge_color",
"(",
"$",
"color",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"col",
")",
"||",
"!",
"isset",
"(",
"$",
"col",
"[",
"\"hex\"",
"]",
")",
")"... | Sets color
The color parameter can be any valid CSS color value
@link http://www.w3.org/TR/CSS21/colors.html#propdef-color
@param string $color | [
"Sets",
"color"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1804-L1817 | train | set the color of the node | [
30522,
3853,
2275,
1035,
3609,
1006,
1002,
3609,
1007,
1063,
1002,
8902,
1027,
1002,
2023,
1011,
1028,
14163,
15465,
1035,
3609,
1006,
1002,
3609,
1007,
1025,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
8902,
1007,
1064,
1064,
999,
26354,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Access.php | Access.doAsSuperUser | public static function doAsSuperUser($function)
{
$isSuperUser = self::getInstance()->hasSuperUserAccess();
$access = self::getInstance();
$login = $access->getLogin();
$shouldResetLogin = empty($login); // make sure to reset login if a login was set by "makeSureLoginNameIsSet()"
$access->setSuperUserAccess(true);
try {
$result = $function();
} catch (Exception $ex) {
$access->setSuperUserAccess($isSuperUser);
if ($shouldResetLogin) {
$access->login = null;
}
throw $ex;
}
if ($shouldResetLogin) {
$access->login = null;
}
$access->setSuperUserAccess($isSuperUser);
return $result;
} | php | public static function doAsSuperUser($function)
{
$isSuperUser = self::getInstance()->hasSuperUserAccess();
$access = self::getInstance();
$login = $access->getLogin();
$shouldResetLogin = empty($login); // make sure to reset login if a login was set by "makeSureLoginNameIsSet()"
$access->setSuperUserAccess(true);
try {
$result = $function();
} catch (Exception $ex) {
$access->setSuperUserAccess($isSuperUser);
if ($shouldResetLogin) {
$access->login = null;
}
throw $ex;
}
if ($shouldResetLogin) {
$access->login = null;
}
$access->setSuperUserAccess($isSuperUser);
return $result;
} | [
"public",
"static",
"function",
"doAsSuperUser",
"(",
"$",
"function",
")",
"{",
"$",
"isSuperUser",
"=",
"self",
"::",
"getInstance",
"(",
")",
"->",
"hasSuperUserAccess",
"(",
")",
";",
"$",
"access",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$... | Executes a callback with superuser privileges, making sure those privileges are rescinded
before this method exits. Privileges will be rescinded even if an exception is thrown.
@param callback $function The callback to execute. Should accept no arguments.
@return mixed The result of `$function`.
@throws Exception rethrows any exceptions thrown by `$function`.
@api | [
"Executes",
"a",
"callback",
"with",
"superuser",
"privileges",
"making",
"sure",
"those",
"privileges",
"are",
"rescinded",
"before",
"this",
"method",
"exits",
".",
"Privileges",
"will",
"be",
"rescinded",
"even",
"if",
"an",
"exception",
"is",
"thrown",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Access.php#L618-L644 | train | This method is used to do a function as a super user | [
30522,
2270,
10763,
3853,
2079,
12054,
6279,
21608,
2121,
1006,
1002,
3853,
1007,
1063,
1002,
26354,
6279,
21608,
2121,
1027,
2969,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2038,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Manager.php | Manager.getAllPluginsNames | public static function getAllPluginsNames()
{
$pluginList = StaticContainer::get('Piwik\Application\Kernel\PluginList');
$pluginsToLoad = array_merge(
self::getInstance()->readPluginsDirectory(),
$pluginList->getCorePluginsDisabledByDefault()
);
$pluginsToLoad = array_values(array_unique($pluginsToLoad));
return $pluginsToLoad;
} | php | public static function getAllPluginsNames()
{
$pluginList = StaticContainer::get('Piwik\Application\Kernel\PluginList');
$pluginsToLoad = array_merge(
self::getInstance()->readPluginsDirectory(),
$pluginList->getCorePluginsDisabledByDefault()
);
$pluginsToLoad = array_values(array_unique($pluginsToLoad));
return $pluginsToLoad;
} | [
"public",
"static",
"function",
"getAllPluginsNames",
"(",
")",
"{",
"$",
"pluginList",
"=",
"StaticContainer",
"::",
"get",
"(",
"'Piwik\\Application\\Kernel\\PluginList'",
")",
";",
"$",
"pluginsToLoad",
"=",
"array_merge",
"(",
"self",
"::",
"getInstance",
"(",
... | Returns the name of all plugins found in this Piwik instance
(including those not enabled and themes)
@return array | [
"Returns",
"the",
"name",
"of",
"all",
"plugins",
"found",
"in",
"this",
"Piwik",
"instance",
"(",
"including",
"those",
"not",
"enabled",
"and",
"themes",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Manager.php#L1115-L1125 | train | Get all plugins names that are available in the system. | [
30522,
2270,
10763,
3853,
2131,
8095,
24759,
15916,
7076,
18442,
2015,
1006,
1007,
1063,
1002,
13354,
2378,
9863,
1027,
10763,
8663,
18249,
2121,
1024,
1024,
2131,
1006,
1005,
14255,
9148,
2243,
1032,
4646,
1032,
16293,
1032,
13354,
2378,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/LanguagesManager/Commands/Update.php | Update.getAllPlugins | public static function getAllPlugins()
{
static $pluginsWithTranslations;
if (!empty($pluginsWithTranslations)) {
return $pluginsWithTranslations;
}
$pluginsWithTranslations = array();
foreach (Manager::getPluginsDirectories() as $pluginsDir) {
$pluginsWithTranslations = array_merge($pluginsWithTranslations, glob(sprintf('%s*/lang/en.json', $pluginsDir)));
}
$pluginsWithTranslations = array_map(function ($elem) {
$replace = Manager::getPluginsDirectories();
$replace[] = '/lang/en.json';
return str_replace($replace, '', $elem);
}, $pluginsWithTranslations);
return $pluginsWithTranslations;
} | php | public static function getAllPlugins()
{
static $pluginsWithTranslations;
if (!empty($pluginsWithTranslations)) {
return $pluginsWithTranslations;
}
$pluginsWithTranslations = array();
foreach (Manager::getPluginsDirectories() as $pluginsDir) {
$pluginsWithTranslations = array_merge($pluginsWithTranslations, glob(sprintf('%s*/lang/en.json', $pluginsDir)));
}
$pluginsWithTranslations = array_map(function ($elem) {
$replace = Manager::getPluginsDirectories();
$replace[] = '/lang/en.json';
return str_replace($replace, '', $elem);
}, $pluginsWithTranslations);
return $pluginsWithTranslations;
} | [
"public",
"static",
"function",
"getAllPlugins",
"(",
")",
"{",
"static",
"$",
"pluginsWithTranslations",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pluginsWithTranslations",
")",
")",
"{",
"return",
"$",
"pluginsWithTranslations",
";",
"}",
"$",
"pluginsWithTrans... | Returns all plugins having their own translations that are bundled in core
@return array | [
"Returns",
"all",
"plugins",
"having",
"their",
"own",
"translations",
"that",
"are",
"bundled",
"in",
"core"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/Commands/Update.php#L153-L172 | train | Get all plugins with translations | [
30522,
2270,
10763,
3853,
2131,
8095,
24759,
15916,
7076,
1006,
1007,
1063,
10763,
1002,
13354,
7076,
24415,
6494,
3619,
13490,
2015,
1025,
2065,
1006,
999,
4064,
1006,
1002,
13354,
7076,
24415,
6494,
3619,
13490,
2015,
1007,
1007,
1063,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement/Pdo.php | Zend_Db_Statement_Pdo._execute | public function _execute(array $params = null)
{
try {
if ($params !== null) {
return $this->_stmt->execute($params);
} else {
return $this->_stmt->execute();
}
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
}
} | php | public function _execute(array $params = null)
{
try {
if ($params !== null) {
return $this->_stmt->execute($params);
} else {
return $this->_stmt->execute();
}
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
}
} | [
"public",
"function",
"_execute",
"(",
"array",
"$",
"params",
"=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"params",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_stmt",
"->",
"execute",
"(",
"$",
"params",
")",
";",
"}",
"else",
... | Executes a prepared statement.
@param array $params OPTIONAL Values to bind to parameter placeholders.
@return bool
@throws Zend_Db_Statement_Exception | [
"Executes",
"a",
"prepared",
"statement",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Pdo.php#L224-L236 | train | Execute the statement | [
30522,
2270,
3853,
1035,
15389,
1006,
9140,
1002,
11498,
5244,
1027,
19701,
1007,
1063,
3046,
1063,
2065,
1006,
1002,
11498,
5244,
999,
1027,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1011,
1028,
15389,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/Identical.php | Zend_Validate_Identical.isValid | public function isValid($value, $context = null)
{
$this->_setValue((string) $value);
if (($context !== null) && isset($context) && array_key_exists($this->getToken(), $context)) {
$token = $context[$this->getToken()];
} else {
$token = $this->getToken();
}
if ($token === null) {
$this->_error(self::MISSING_TOKEN);
return false;
}
$strict = $this->getStrict();
if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) {
$this->_error(self::NOT_SAME);
return false;
}
return true;
} | php | public function isValid($value, $context = null)
{
$this->_setValue((string) $value);
if (($context !== null) && isset($context) && array_key_exists($this->getToken(), $context)) {
$token = $context[$this->getToken()];
} else {
$token = $this->getToken();
}
if ($token === null) {
$this->_error(self::MISSING_TOKEN);
return false;
}
$strict = $this->getStrict();
if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) {
$this->_error(self::NOT_SAME);
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_setValue",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"if",
"(",
"(",
"$",
"context",
"!==",
"null",
")",
"&&",
"isset",
"(... | Defined by Zend_Validate_Interface
Returns true if and only if a token has been set and the provided value
matches that token.
@param mixed $value
@param array $context
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Identical.php#L141-L163 | train | Valida o valor de la lista | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
3643,
1010,
1002,
6123,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
2275,
10175,
5657,
1006,
1006,
5164,
1007,
1002,
3643,
1007,
1025,
2065,
1006,
1006,
1002,
6123,
999,
1027,
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/Validate/EmailAddress.php | Zend_Validate_EmailAddress._validateMXRecords | private function _validateMXRecords()
{
$mxHosts = array();
$result = getmxrr($this->_hostname, $mxHosts);
if (!$result) {
$this->_error(self::INVALID_MX_RECORD);
} else if ($this->_options['deep'] && function_exists('checkdnsrr')) {
$validAddress = false;
$reserved = true;
foreach ($mxHosts as $hostname) {
$res = $this->_isReserved($hostname);
if (!$res) {
$reserved = false;
}
if (!$res
&& (checkdnsrr($hostname, "A")
|| checkdnsrr($hostname, "AAAA")
|| checkdnsrr($hostname, "A6"))) {
$validAddress = true;
break;
}
}
if (!$validAddress) {
$result = false;
if ($reserved) {
$this->_error(self::INVALID_SEGMENT);
} else {
$this->_error(self::INVALID_MX_RECORD);
}
}
}
return $result;
} | php | private function _validateMXRecords()
{
$mxHosts = array();
$result = getmxrr($this->_hostname, $mxHosts);
if (!$result) {
$this->_error(self::INVALID_MX_RECORD);
} else if ($this->_options['deep'] && function_exists('checkdnsrr')) {
$validAddress = false;
$reserved = true;
foreach ($mxHosts as $hostname) {
$res = $this->_isReserved($hostname);
if (!$res) {
$reserved = false;
}
if (!$res
&& (checkdnsrr($hostname, "A")
|| checkdnsrr($hostname, "AAAA")
|| checkdnsrr($hostname, "A6"))) {
$validAddress = true;
break;
}
}
if (!$validAddress) {
$result = false;
if ($reserved) {
$this->_error(self::INVALID_SEGMENT);
} else {
$this->_error(self::INVALID_MX_RECORD);
}
}
}
return $result;
} | [
"private",
"function",
"_validateMXRecords",
"(",
")",
"{",
"$",
"mxHosts",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"getmxrr",
"(",
"$",
"this",
"->",
"_hostname",
",",
"$",
"mxHosts",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"$"... | Internal method to validate the servers MX records
@return boolean | [
"Internal",
"method",
"to",
"validate",
"the",
"servers",
"MX",
"records"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/EmailAddress.php#L442-L477 | train | Check if the MX records are valid | [
30522,
2797,
3853,
1035,
9398,
3686,
22984,
2890,
27108,
5104,
1006,
1007,
1063,
1002,
25630,
15006,
3215,
1027,
9140,
1006,
1007,
1025,
1002,
2765,
1027,
2131,
22984,
12171,
1006,
1002,
2023,
1011,
1028,
1035,
3677,
18442,
1010,
1002,
2563... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Annotations/AnnotationList.php | AnnotationList.remove | public function remove($idSite, $idNote)
{
$this->checkIdSiteIsLoaded($idSite);
$this->checkNoteExists($idSite, $idNote);
unset($this->annotations[$idSite][$idNote]);
} | php | public function remove($idSite, $idNote)
{
$this->checkIdSiteIsLoaded($idSite);
$this->checkNoteExists($idSite, $idNote);
unset($this->annotations[$idSite][$idNote]);
} | [
"public",
"function",
"remove",
"(",
"$",
"idSite",
",",
"$",
"idNote",
")",
"{",
"$",
"this",
"->",
"checkIdSiteIsLoaded",
"(",
"$",
"idSite",
")",
";",
"$",
"this",
"->",
"checkNoteExists",
"(",
"$",
"idSite",
",",
"$",
"idNote",
")",
";",
"unset",
... | Removes a note from a site's collection of annotations.
Note: This method does not perist the change in the DB. The save method must
be called for that.
@param int $idSite The ID of the site whose annotation will be updated.
@param int $idNote The ID of the note.
@throws Exception if $idSite is not an ID that was supplied upon construction.
@throws Exception if $idNote does not refer to valid note for the site. | [
"Removes",
"a",
"note",
"from",
"a",
"site",
"s",
"collection",
"of",
"annotations",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L158-L164 | train | Remove an annotation from the list of annotations | [
30522,
2270,
3853,
6366,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
8909,
22074,
1007,
1063,
1002,
2023,
1011,
1028,
4638,
9821,
4221,
2483,
17468,
1006,
1002,
8909,
28032,
2063,
1007,
1025,
1002,
2023,
1011,
1028,
4638,
22074,
10288,
5130,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ImageMedium.php | ImageMedium.filter | public function filter($filter = 'image.filters.default')
{
$filters = (array) $this->get($filter, []);
foreach ($filters as $params) {
$params = (array) $params;
$method = array_shift($params);
$this->__call($method, $params);
}
} | php | public function filter($filter = 'image.filters.default')
{
$filters = (array) $this->get($filter, []);
foreach ($filters as $params) {
$params = (array) $params;
$method = array_shift($params);
$this->__call($method, $params);
}
} | [
"public",
"function",
"filter",
"(",
"$",
"filter",
"=",
"'image.filters.default'",
")",
"{",
"$",
"filters",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"get",
"(",
"$",
"filter",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
... | Filter image by using user defined filter parameters.
@param string $filter Filter to be used. | [
"Filter",
"image",
"by",
"using",
"user",
"defined",
"filter",
"parameters",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ImageMedium.php#L630-L638 | train | Filter image by name | [
30522,
2270,
3853,
11307,
1006,
1002,
11307,
1027,
1005,
3746,
1012,
17736,
1012,
12398,
1005,
1007,
1063,
1002,
17736,
1027,
1006,
9140,
1007,
1002,
2023,
1011,
1028,
2131,
1006,
1002,
11307,
1010,
1031,
1033,
1007,
1025,
18921,
6776,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/RedisTaggedCache.php | RedisTaggedCache.forever | public function forever($key, $value)
{
$this->pushForeverKeys($this->tags->getNamespace(), $key);
return parent::forever($key, $value);
} | php | public function forever($key, $value)
{
$this->pushForeverKeys($this->tags->getNamespace(), $key);
return parent::forever($key, $value);
} | [
"public",
"function",
"forever",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"pushForeverKeys",
"(",
"$",
"this",
"->",
"tags",
"->",
"getNamespace",
"(",
")",
",",
"$",
"key",
")",
";",
"return",
"parent",
"::",
"forever",
"(",
... | Store an item in the cache indefinitely.
@param string $key
@param mixed $value
@return bool | [
"Store",
"an",
"item",
"in",
"the",
"cache",
"indefinitely",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/RedisTaggedCache.php#L74-L79 | train | Forever - push the key and value to the stack | [
30522,
2270,
3853,
5091,
1006,
1002,
3145,
1010,
1002,
3643,
1007,
1063,
1002,
2023,
1011,
1028,
5245,
29278,
22507,
14839,
2015,
1006,
1002,
2023,
1011,
1028,
22073,
1011,
1028,
2131,
18442,
23058,
1006,
1007,
1010,
1002,
3145,
1007,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreUpdater/Updater.php | Updater.updatePiwik | public function updatePiwik($https = true)
{
if (!$this->isNewVersionAvailable()) {
throw new Exception($this->translator->translate('CoreUpdater_ExceptionAlreadyLatestVersion', Version::VERSION));
}
SettingsServer::setMaxExecutionTime(0);
$newVersion = $this->getLatestVersion();
$url = $this->getArchiveUrl($newVersion, $https);
$messages = array();
try {
$archiveFile = $this->downloadArchive($newVersion, $url);
$messages[] = $this->translator->translate('CoreUpdater_DownloadingUpdateFromX', $url);
$extractedArchiveDirectory = $this->decompressArchive($archiveFile);
$messages[] = $this->translator->translate('CoreUpdater_UnpackingTheUpdate');
$this->verifyDecompressedArchive($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_VerifyingUnpackedFiles');
if (Marketplace::isMarketplaceEnabled()) {
// we need to load the marketplace already here, otherwise it will use the new, updated file in Piwik 3
// we also need to make sure to create a new instance here as otherwise we would change the "global"
// environment, but we only want to change piwik version temporarily for this task here
$environment = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Environment');
$environment->setPiwikVersion($newVersion);
/** @var \Piwik\Plugins\Marketplace\Api\Client $marketplaceClient */
$marketplaceClient = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Api\Client', array(
'environment' => $environment
));
require_once PIWIK_DOCUMENT_ROOT . '/plugins/CorePluginsAdmin/PluginInstaller.php';
require_once PIWIK_DOCUMENT_ROOT . '/plugins/Marketplace/Api/Exception.php';
}
$this->installNewFiles($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_InstallingTheLatestVersion');
} catch (ArchiveDownloadException $e) {
throw $e;
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
try {
if (Marketplace::isMarketplaceEnabled() && !empty($marketplaceClient)) {
$messages[] = $this->translator->translate('CoreUpdater_CheckingForPluginUpdates');
$pluginManager = PluginManager::getInstance();
$pluginManager->loadAllPluginsAndGetTheirInfo();
$loadedPlugins = $pluginManager->getLoadedPlugins();
$marketplaceClient->clearAllCacheEntries();
$pluginsWithUpdate = $marketplaceClient->checkUpdates($loadedPlugins);
foreach ($pluginsWithUpdate as $pluginWithUpdate) {
$pluginName = $pluginWithUpdate['name'];
$messages[] = $this->translator->translate('CoreUpdater_UpdatingPluginXToVersionY',
array($pluginName, $pluginWithUpdate['version']));
$pluginInstaller = new PluginInstaller($marketplaceClient);
$pluginInstaller->installOrUpdatePluginFromMarketplace($pluginName);
}
}
} catch (MarketplaceApi\Exception $e) {
// there is a problem with the connection to the server, ignore for now
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
try {
$disabledPluginNames = $this->disableIncompatiblePlugins($newVersion);
if (!empty($disabledPluginNames)) {
$messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames));
}
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
return $messages;
} | php | public function updatePiwik($https = true)
{
if (!$this->isNewVersionAvailable()) {
throw new Exception($this->translator->translate('CoreUpdater_ExceptionAlreadyLatestVersion', Version::VERSION));
}
SettingsServer::setMaxExecutionTime(0);
$newVersion = $this->getLatestVersion();
$url = $this->getArchiveUrl($newVersion, $https);
$messages = array();
try {
$archiveFile = $this->downloadArchive($newVersion, $url);
$messages[] = $this->translator->translate('CoreUpdater_DownloadingUpdateFromX', $url);
$extractedArchiveDirectory = $this->decompressArchive($archiveFile);
$messages[] = $this->translator->translate('CoreUpdater_UnpackingTheUpdate');
$this->verifyDecompressedArchive($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_VerifyingUnpackedFiles');
if (Marketplace::isMarketplaceEnabled()) {
// we need to load the marketplace already here, otherwise it will use the new, updated file in Piwik 3
// we also need to make sure to create a new instance here as otherwise we would change the "global"
// environment, but we only want to change piwik version temporarily for this task here
$environment = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Environment');
$environment->setPiwikVersion($newVersion);
/** @var \Piwik\Plugins\Marketplace\Api\Client $marketplaceClient */
$marketplaceClient = StaticContainer::getContainer()->make('Piwik\Plugins\Marketplace\Api\Client', array(
'environment' => $environment
));
require_once PIWIK_DOCUMENT_ROOT . '/plugins/CorePluginsAdmin/PluginInstaller.php';
require_once PIWIK_DOCUMENT_ROOT . '/plugins/Marketplace/Api/Exception.php';
}
$this->installNewFiles($extractedArchiveDirectory);
$messages[] = $this->translator->translate('CoreUpdater_InstallingTheLatestVersion');
} catch (ArchiveDownloadException $e) {
throw $e;
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
try {
if (Marketplace::isMarketplaceEnabled() && !empty($marketplaceClient)) {
$messages[] = $this->translator->translate('CoreUpdater_CheckingForPluginUpdates');
$pluginManager = PluginManager::getInstance();
$pluginManager->loadAllPluginsAndGetTheirInfo();
$loadedPlugins = $pluginManager->getLoadedPlugins();
$marketplaceClient->clearAllCacheEntries();
$pluginsWithUpdate = $marketplaceClient->checkUpdates($loadedPlugins);
foreach ($pluginsWithUpdate as $pluginWithUpdate) {
$pluginName = $pluginWithUpdate['name'];
$messages[] = $this->translator->translate('CoreUpdater_UpdatingPluginXToVersionY',
array($pluginName, $pluginWithUpdate['version']));
$pluginInstaller = new PluginInstaller($marketplaceClient);
$pluginInstaller->installOrUpdatePluginFromMarketplace($pluginName);
}
}
} catch (MarketplaceApi\Exception $e) {
// there is a problem with the connection to the server, ignore for now
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
try {
$disabledPluginNames = $this->disableIncompatiblePlugins($newVersion);
if (!empty($disabledPluginNames)) {
$messages[] = $this->translator->translate('CoreUpdater_DisablingIncompatiblePlugins', implode(', ', $disabledPluginNames));
}
} catch (Exception $e) {
throw new UpdaterException($e, $messages);
}
return $messages;
} | [
"public",
"function",
"updatePiwik",
"(",
"$",
"https",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isNewVersionAvailable",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"this",
"->",
"translator",
"->",
"translate",
"(",
"'... | Update Piwik codebase by downloading and installing the latest version.
@param bool $https Whether to use HTTPS if supported of not. If false, will use HTTP.
@return string[] Return an array of messages for the user.
@throws ArchiveDownloadException
@throws UpdaterException
@throws Exception | [
"Update",
"Piwik",
"codebase",
"by",
"downloading",
"and",
"installing",
"the",
"latest",
"version",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreUpdater/Updater.php#L95-L176 | train | Update the Piwik version | [
30522,
2270,
3853,
10651,
8197,
9148,
2243,
1006,
1002,
16770,
1027,
2995,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
3475,
7974,
27774,
12462,
11733,
3468,
1006,
1007,
1007,
1063,
5466,
2047,
6453,
1006,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Archive/DataCollection.php | DataCollection.getIndexedArray | public function getIndexedArray($resultIndices)
{
$indexKeys = array_keys($resultIndices);
$result = $this->createOrderedIndex($indexKeys);
foreach ($this->data as $idSite => $rowsByPeriod) {
foreach ($rowsByPeriod as $period => $row) {
// FIXME: This hack works around a strange bug that occurs when getting
// archive IDs through ArchiveProcessing instances. When a table
// does not already exist, for some reason the archive ID for
// today (or from two days ago) will be added to the Archive
// instances list. The Archive instance will then select data
// for periods outside of the requested set.
// working around the bug here, but ideally, we need to figure
// out why incorrect idarchives are being selected.
if (empty($this->periods[$period])) {
continue;
}
$this->putRowInIndex($result, $indexKeys, $row, $idSite, $period);
}
}
return $result;
} | php | public function getIndexedArray($resultIndices)
{
$indexKeys = array_keys($resultIndices);
$result = $this->createOrderedIndex($indexKeys);
foreach ($this->data as $idSite => $rowsByPeriod) {
foreach ($rowsByPeriod as $period => $row) {
// FIXME: This hack works around a strange bug that occurs when getting
// archive IDs through ArchiveProcessing instances. When a table
// does not already exist, for some reason the archive ID for
// today (or from two days ago) will be added to the Archive
// instances list. The Archive instance will then select data
// for periods outside of the requested set.
// working around the bug here, but ideally, we need to figure
// out why incorrect idarchives are being selected.
if (empty($this->periods[$period])) {
continue;
}
$this->putRowInIndex($result, $indexKeys, $row, $idSite, $period);
}
}
return $result;
} | [
"public",
"function",
"getIndexedArray",
"(",
"$",
"resultIndices",
")",
"{",
"$",
"indexKeys",
"=",
"array_keys",
"(",
"$",
"resultIndices",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"createOrderedIndex",
"(",
"$",
"indexKeys",
")",
";",
"foreach",
... | Returns archive data as an array indexed by metadata.
@param array $resultIndices An array mapping metadata names to pretty labels
for them. Each archive data row will be indexed
by the metadata specified here.
Eg, array('site' => 'idSite', 'period' => 'Date')
@return array | [
"Returns",
"archive",
"data",
"as",
"an",
"array",
"indexed",
"by",
"metadata",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataCollection.php#L184-L208 | train | Get an ordered array of archive IDs indexed by the given indices | [
30522,
2270,
3853,
2131,
22254,
10288,
11960,
11335,
2100,
1006,
1002,
2765,
22254,
23522,
1007,
1063,
1002,
5950,
14839,
2015,
1027,
9140,
1035,
6309,
1006,
1002,
2765,
22254,
23522,
1007,
1025,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/LogTablesProvider.php | LogTablesProvider.getLogTable | public function getLogTable($tableNameWithoutPrefix)
{
foreach ($this->getAllLogTables() as $table) {
if ($table->getName() === $tableNameWithoutPrefix) {
return $table;
}
}
} | php | public function getLogTable($tableNameWithoutPrefix)
{
foreach ($this->getAllLogTables() as $table) {
if ($table->getName() === $tableNameWithoutPrefix) {
return $table;
}
}
} | [
"public",
"function",
"getLogTable",
"(",
"$",
"tableNameWithoutPrefix",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAllLogTables",
"(",
")",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"->",
"getName",
"(",
")",
"===",
"$",
"tableNameWit... | Get an instance of a specific log table if such a log table exists.
@param string $tableNameWithoutPrefix eg "log_visit"
@return LogTable|null | [
"Get",
"an",
"instance",
"of",
"a",
"specific",
"log",
"table",
"if",
"such",
"a",
"log",
"table",
"exists",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/LogTablesProvider.php#L38-L45 | train | Get the log table for a given name without prefix | [
30522,
2270,
3853,
2131,
21197,
10880,
1006,
1002,
2795,
18442,
24415,
5833,
28139,
8873,
2595,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
8095,
21197,
10880,
2015,
1006,
1007,
2004,
1002,
2795,
1007,
1063,
2065,
1006,
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... |
matomo-org/matomo | plugins/PrivacyManager/PrivacyManager.php | PrivacyManager.installationFormInit | public function installationFormInit(FormDefaultSettings $form)
{
$form->addElement('checkbox', 'do_not_track', null,
array(
'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_DoNotTrack_EnabledMoreInfo') . '</div> ' . Piwik::translate('PrivacyManager_DoNotTrack_Enable')
));
$form->addElement('checkbox', 'anonymise_ip', null,
array(
'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_AnonymizeIpExtendedHelp', array('213.34.51.91', '213.34.0.0')) . '</div> ' . Piwik::translate('PrivacyManager_AnonymizeIpInlineHelp')
));
// default values
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
'do_not_track' => $this->dntChecker->isActive(),
'anonymise_ip' => IPAnonymizer::isActive(),
)));
} | php | public function installationFormInit(FormDefaultSettings $form)
{
$form->addElement('checkbox', 'do_not_track', null,
array(
'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_DoNotTrack_EnabledMoreInfo') . '</div> ' . Piwik::translate('PrivacyManager_DoNotTrack_Enable')
));
$form->addElement('checkbox', 'anonymise_ip', null,
array(
'content' => '<div class="form-help">' . Piwik::translate('PrivacyManager_AnonymizeIpExtendedHelp', array('213.34.51.91', '213.34.0.0')) . '</div> ' . Piwik::translate('PrivacyManager_AnonymizeIpInlineHelp')
));
// default values
$form->addDataSource(new HTML_QuickForm2_DataSource_Array(array(
'do_not_track' => $this->dntChecker->isActive(),
'anonymise_ip' => IPAnonymizer::isActive(),
)));
} | [
"public",
"function",
"installationFormInit",
"(",
"FormDefaultSettings",
"$",
"form",
")",
"{",
"$",
"form",
"->",
"addElement",
"(",
"'checkbox'",
",",
"'do_not_track'",
",",
"null",
",",
"array",
"(",
"'content'",
"=>",
"'<div class=\"form-help\">'",
".",
"Piwi... | Customize the Installation "default settings" form.
@param FormDefaultSettings $form | [
"Customize",
"the",
"Installation",
"default",
"settings",
"form",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L237-L253 | train | This method is called when the installation form is being initialized. | [
30522,
2270,
3853,
8272,
14192,
5498,
2102,
1006,
2433,
3207,
7011,
11314,
21678,
8613,
1002,
2433,
1007,
1063,
1002,
2433,
1011,
1028,
5587,
12260,
3672,
1006,
1005,
4638,
8758,
1005,
1010,
1005,
2079,
1035,
2025,
1035,
2650,
1005,
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... |
symfony/symfony | src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php | FilesystemTagAwareAdapter.doDelete | protected function doDelete(array $ids, array $tagData = []): bool
{
$ok = $this->doDeleteCache($ids);
// Remove tags
$files = [];
$fs = $this->getFilesystem();
foreach ($tagData as $tagId => $idMap) {
$tagFolder = $this->getTagFolder($tagId);
foreach ($idMap as $id) {
$files[] = $this->getFile($id, false, $tagFolder);
}
}
$fs->remove($files);
return $ok;
} | php | protected function doDelete(array $ids, array $tagData = []): bool
{
$ok = $this->doDeleteCache($ids);
// Remove tags
$files = [];
$fs = $this->getFilesystem();
foreach ($tagData as $tagId => $idMap) {
$tagFolder = $this->getTagFolder($tagId);
foreach ($idMap as $id) {
$files[] = $this->getFile($id, false, $tagFolder);
}
}
$fs->remove($files);
return $ok;
} | [
"protected",
"function",
"doDelete",
"(",
"array",
"$",
"ids",
",",
"array",
"$",
"tagData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"ok",
"=",
"$",
"this",
"->",
"doDeleteCache",
"(",
"$",
"ids",
")",
";",
"// Remove tags",
"$",
"files",
"=",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php#L94-L110 | train | Delete cache and all tags | [
30522,
5123,
3853,
26489,
12260,
2618,
1006,
9140,
1002,
8909,
2015,
1010,
9140,
1002,
6415,
2850,
2696,
1027,
1031,
1033,
1007,
1024,
22017,
2140,
1063,
1002,
7929,
1027,
1002,
2023,
1011,
1028,
26489,
12260,
26557,
15395,
1006,
1002,
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... |
symfony/symfony | src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php | DoctrineOrmTypeGuesser.guessType | public function guessType($class, $property)
{
if (!$ret = $this->getMetadata($class)) {
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
}
list($metadata, $name) = $ret;
if ($metadata->hasAssociation($property)) {
$multiple = $metadata->isCollectionValuedAssociation($property);
$mapping = $metadata->getAssociationMapping($property);
return new TypeGuess('Symfony\Bridge\Doctrine\Form\Type\EntityType', ['em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple], Guess::HIGH_CONFIDENCE);
}
switch ($metadata->getTypeOfField($property)) {
case Type::TARRAY:
case Type::SIMPLE_ARRAY:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', [], Guess::MEDIUM_CONFIDENCE);
case Type::BOOLEAN:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', [], Guess::HIGH_CONFIDENCE);
case Type::DATETIME:
case Type::DATETIMETZ:
case 'vardatetime':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', [], Guess::HIGH_CONFIDENCE);
case 'datetime_immutable':
case 'datetimetz_immutable':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
case 'dateinterval':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', [], Guess::HIGH_CONFIDENCE);
case Type::DATE:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', [], Guess::HIGH_CONFIDENCE);
case 'date_immutable':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
case Type::TIME:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', [], Guess::HIGH_CONFIDENCE);
case 'time_immutable':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
case Type::DECIMAL:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', ['input' => 'string'], Guess::MEDIUM_CONFIDENCE);
case Type::FLOAT:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', [], Guess::MEDIUM_CONFIDENCE);
case Type::INTEGER:
case Type::BIGINT:
case Type::SMALLINT:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', [], Guess::MEDIUM_CONFIDENCE);
case Type::STRING:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::MEDIUM_CONFIDENCE);
case Type::TEXT:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextareaType', [], Guess::MEDIUM_CONFIDENCE);
default:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
}
} | php | public function guessType($class, $property)
{
if (!$ret = $this->getMetadata($class)) {
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
}
list($metadata, $name) = $ret;
if ($metadata->hasAssociation($property)) {
$multiple = $metadata->isCollectionValuedAssociation($property);
$mapping = $metadata->getAssociationMapping($property);
return new TypeGuess('Symfony\Bridge\Doctrine\Form\Type\EntityType', ['em' => $name, 'class' => $mapping['targetEntity'], 'multiple' => $multiple], Guess::HIGH_CONFIDENCE);
}
switch ($metadata->getTypeOfField($property)) {
case Type::TARRAY:
case Type::SIMPLE_ARRAY:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CollectionType', [], Guess::MEDIUM_CONFIDENCE);
case Type::BOOLEAN:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\CheckboxType', [], Guess::HIGH_CONFIDENCE);
case Type::DATETIME:
case Type::DATETIMETZ:
case 'vardatetime':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', [], Guess::HIGH_CONFIDENCE);
case 'datetime_immutable':
case 'datetimetz_immutable':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
case 'dateinterval':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', [], Guess::HIGH_CONFIDENCE);
case Type::DATE:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', [], Guess::HIGH_CONFIDENCE);
case 'date_immutable':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
case Type::TIME:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', [], Guess::HIGH_CONFIDENCE);
case 'time_immutable':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TimeType', ['input' => 'datetime_immutable'], Guess::HIGH_CONFIDENCE);
case Type::DECIMAL:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', ['input' => 'string'], Guess::MEDIUM_CONFIDENCE);
case Type::FLOAT:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\NumberType', [], Guess::MEDIUM_CONFIDENCE);
case Type::INTEGER:
case Type::BIGINT:
case Type::SMALLINT:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\IntegerType', [], Guess::MEDIUM_CONFIDENCE);
case Type::STRING:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::MEDIUM_CONFIDENCE);
case Type::TEXT:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextareaType', [], Guess::MEDIUM_CONFIDENCE);
default:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
}
} | [
"public",
"function",
"guessType",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"$",
"ret",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"class",
")",
")",
"{",
"return",
"new",
"TypeGuess",
"(",
"'Symfony\\Component\\Form\\Exte... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php#L39-L92 | train | Guesses the type of a property | [
30522,
2270,
3853,
3984,
13874,
1006,
1002,
2465,
1010,
1002,
3200,
1007,
1063,
2065,
1006,
999,
1002,
2128,
2102,
1027,
1002,
2023,
1011,
1028,
2131,
11368,
8447,
2696,
1006,
1002,
2465,
1007,
1007,
1063,
2709,
2047,
2828,
22967,
2015,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Writable/Maildir.php | Zend_Mail_Storage_Writable_Maildir.initMaildir | public static function initMaildir($dir)
{
if (file_exists($dir)) {
if (!is_dir($dir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('maildir must be a directory if already exists');
}
} else {
if (!mkdir($dir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
$dir = dirname($dir);
if (!file_exists($dir)) {
throw new Zend_Mail_Storage_Exception("parent $dir not found");
} else if (!is_dir($dir)) {
throw new Zend_Mail_Storage_Exception("parent $dir not a directory");
} else {
throw new Zend_Mail_Storage_Exception('cannot create maildir');
}
}
}
foreach (array('cur', 'tmp', 'new') as $subdir) {
if (!@mkdir($dir . DIRECTORY_SEPARATOR . $subdir)) {
// ignore if dir exists (i.e. was already valid maildir or two processes try to create one)
if (!file_exists($dir . DIRECTORY_SEPARATOR . $subdir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('could not create subdir ' . $subdir);
}
}
}
} | php | public static function initMaildir($dir)
{
if (file_exists($dir)) {
if (!is_dir($dir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('maildir must be a directory if already exists');
}
} else {
if (!mkdir($dir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
$dir = dirname($dir);
if (!file_exists($dir)) {
throw new Zend_Mail_Storage_Exception("parent $dir not found");
} else if (!is_dir($dir)) {
throw new Zend_Mail_Storage_Exception("parent $dir not a directory");
} else {
throw new Zend_Mail_Storage_Exception('cannot create maildir');
}
}
}
foreach (array('cur', 'tmp', 'new') as $subdir) {
if (!@mkdir($dir . DIRECTORY_SEPARATOR . $subdir)) {
// ignore if dir exists (i.e. was already valid maildir or two processes try to create one)
if (!file_exists($dir . DIRECTORY_SEPARATOR . $subdir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('could not create subdir ' . $subdir);
}
}
}
} | [
"public",
"static",
"function",
"initMaildir",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"/**\n * @see Zend_Mail_Storage_Exception\n ... | create a new maildir
If the given dir is already a valid maildir this will not fail.
@param string $dir directory for the new maildir (may already exist)
@return null
@throws Zend_Mail_Storage_Exception | [
"create",
"a",
"new",
"maildir"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L62-L101 | train | Create the maildir | [
30522,
2270,
10763,
3853,
1999,
4183,
21397,
4305,
2099,
1006,
1002,
16101,
1007,
1063,
2065,
1006,
5371,
1035,
6526,
1006,
1002,
16101,
1007,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16101,
1006,
1002,
16101,
1007,
1007,
1063,
1013,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FormRegistry.php | FormRegistry.getTypeGuesser | public function getTypeGuesser()
{
if (false === $this->guesser) {
$guessers = [];
foreach ($this->extensions as $extension) {
$guesser = $extension->getTypeGuesser();
if ($guesser) {
$guessers[] = $guesser;
}
}
$this->guesser = !empty($guessers) ? new FormTypeGuesserChain($guessers) : null;
}
return $this->guesser;
} | php | public function getTypeGuesser()
{
if (false === $this->guesser) {
$guessers = [];
foreach ($this->extensions as $extension) {
$guesser = $extension->getTypeGuesser();
if ($guesser) {
$guessers[] = $guesser;
}
}
$this->guesser = !empty($guessers) ? new FormTypeGuesserChain($guessers) : null;
}
return $this->guesser;
} | [
"public",
"function",
"getTypeGuesser",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"guesser",
")",
"{",
"$",
"guessers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"extensions",
"as",
"$",
"extension",
")",
"{",
"$",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormRegistry.php#L161-L178 | train | Returns the type guesser chain | [
30522,
2270,
3853,
2131,
13874,
22967,
8043,
1006,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
3984,
2121,
1007,
1063,
1002,
3984,
2545,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
14305,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getFieldNameFromData | protected function getFieldNameFromData($fieldName, $data, $default = null)
{
/*
* Array field name, eg: field[key][key2][key3]
*/
$keyParts = HtmlHelper::nameToArray($fieldName);
$lastField = end($keyParts);
$result = $data;
/*
* Loop the field key parts and build a value.
* To support relations only the last field should return the
* relation value, all others will look up the relation object as normal.
*/
foreach ($keyParts as $key) {
if ($result instanceof Model && $result->hasRelation($key)) {
if ($key == $lastField) {
$result = $result->getRelationValue($key) ?: $default;
}
else {
$result = $result->{$key};
}
}
elseif (is_array($result)) {
if (!array_key_exists($key, $result)) {
return $default;
}
$result = $result[$key];
}
else {
if (!isset($result->{$key})) {
return $default;
}
$result = $result->{$key};
}
}
return $result;
} | php | protected function getFieldNameFromData($fieldName, $data, $default = null)
{
/*
* Array field name, eg: field[key][key2][key3]
*/
$keyParts = HtmlHelper::nameToArray($fieldName);
$lastField = end($keyParts);
$result = $data;
/*
* Loop the field key parts and build a value.
* To support relations only the last field should return the
* relation value, all others will look up the relation object as normal.
*/
foreach ($keyParts as $key) {
if ($result instanceof Model && $result->hasRelation($key)) {
if ($key == $lastField) {
$result = $result->getRelationValue($key) ?: $default;
}
else {
$result = $result->{$key};
}
}
elseif (is_array($result)) {
if (!array_key_exists($key, $result)) {
return $default;
}
$result = $result[$key];
}
else {
if (!isset($result->{$key})) {
return $default;
}
$result = $result->{$key};
}
}
return $result;
} | [
"protected",
"function",
"getFieldNameFromData",
"(",
"$",
"fieldName",
",",
"$",
"data",
",",
"$",
"default",
"=",
"null",
")",
"{",
"/*\n * Array field name, eg: field[key][key2][key3]\n */",
"$",
"keyParts",
"=",
"HtmlHelper",
"::",
"nameToArray",
"("... | Internal method to extract the value of a field name from a data set.
@param string $fieldName
@param mixed $data
@param mixed $default
@return mixed | [
"Internal",
"method",
"to",
"extract",
"the",
"value",
"of",
"a",
"field",
"name",
"from",
"a",
"data",
"set",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L676-L716 | train | Get the field name from the data | [
30522,
5123,
3853,
2131,
3790,
18442,
19699,
5358,
2850,
2696,
1006,
1002,
2492,
18442,
1010,
1002,
2951,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
1013,
1008,
1008,
9140,
2492,
2171,
1010,
1041,
2290,
1024,
2492,
1031,
3145,
1033,
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/Form/Extension/Core/Type/DateType.php | DateType.finishView | public function finishView(FormView $view, FormInterface $form, array $options)
{
$view->vars['widget'] = $options['widget'];
// Change the input to a HTML5 date input if
// * the widget is set to "single_text"
// * the format matches the one expected by HTML5
// * the html5 is set to true
if ($options['html5'] && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) {
$view->vars['type'] = 'date';
}
if ($form->getConfig()->hasAttribute('formatter')) {
$pattern = $form->getConfig()->getAttribute('formatter')->getPattern();
// remove special characters unless the format was explicitly specified
if (!\is_string($options['format'])) {
// remove quoted strings first
$pattern = preg_replace('/\'[^\']+\'/', '', $pattern);
// remove remaining special chars
$pattern = preg_replace('/[^yMd]+/', '', $pattern);
}
// set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy)
// lookup various formats at http://userguide.icu-project.org/formatparse/datetime
if (preg_match('/^([yMd]+)[^yMd]*([yMd]+)[^yMd]*([yMd]+)$/', $pattern)) {
$pattern = preg_replace(['/y+/', '/M+/', '/d+/'], ['{{ year }}', '{{ month }}', '{{ day }}'], $pattern);
} else {
// default fallback
$pattern = '{{ year }}{{ month }}{{ day }}';
}
$view->vars['date_pattern'] = $pattern;
}
} | php | public function finishView(FormView $view, FormInterface $form, array $options)
{
$view->vars['widget'] = $options['widget'];
// Change the input to a HTML5 date input if
// * the widget is set to "single_text"
// * the format matches the one expected by HTML5
// * the html5 is set to true
if ($options['html5'] && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) {
$view->vars['type'] = 'date';
}
if ($form->getConfig()->hasAttribute('formatter')) {
$pattern = $form->getConfig()->getAttribute('formatter')->getPattern();
// remove special characters unless the format was explicitly specified
if (!\is_string($options['format'])) {
// remove quoted strings first
$pattern = preg_replace('/\'[^\']+\'/', '', $pattern);
// remove remaining special chars
$pattern = preg_replace('/[^yMd]+/', '', $pattern);
}
// set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy)
// lookup various formats at http://userguide.icu-project.org/formatparse/datetime
if (preg_match('/^([yMd]+)[^yMd]*([yMd]+)[^yMd]*([yMd]+)$/', $pattern)) {
$pattern = preg_replace(['/y+/', '/M+/', '/d+/'], ['{{ year }}', '{{ month }}', '{{ day }}'], $pattern);
} else {
// default fallback
$pattern = '{{ year }}{{ month }}{{ day }}';
}
$view->vars['date_pattern'] = $pattern;
}
} | [
"public",
"function",
"finishView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"'widget'",
"]",
"=",
"$",
"options",
"[",
"'widget'",
"]",
";",
"// Change the i... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/DateType.php#L173-L208 | train | Finishes the view | [
30522,
2270,
3853,
3926,
8584,
1006,
2433,
8584,
1002,
3193,
1010,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
9140,
1002,
7047,
1007,
1063,
1002,
3193,
1011,
1028,
13075,
2015,
1031,
1005,
15536,
24291,
1005,
1033,
1027,
1002,
7047,
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... |
laravel/framework | src/Illuminate/Routing/Route.php | Route.uses | public function uses($action)
{
$action = is_string($action) ? $this->addGroupNamespaceToStringUses($action) : $action;
return $this->setAction(array_merge($this->action, $this->parseAction([
'uses' => $action,
'controller' => $action,
])));
} | php | public function uses($action)
{
$action = is_string($action) ? $this->addGroupNamespaceToStringUses($action) : $action;
return $this->setAction(array_merge($this->action, $this->parseAction([
'uses' => $action,
'controller' => $action,
])));
} | [
"public",
"function",
"uses",
"(",
"$",
"action",
")",
"{",
"$",
"action",
"=",
"is_string",
"(",
"$",
"action",
")",
"?",
"$",
"this",
"->",
"addGroupNamespaceToStringUses",
"(",
"$",
"action",
")",
":",
"$",
"action",
";",
"return",
"$",
"this",
"->"... | Set the handler for the route.
@param \Closure|string $action
@return $this | [
"Set",
"the",
"handler",
"for",
"the",
"route",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Route.php#L709-L717 | train | Add a controller to the uses array | [
30522,
2270,
3853,
3594,
1006,
1002,
2895,
1007,
1063,
1002,
2895,
1027,
2003,
1035,
5164,
1006,
1002,
2895,
1007,
1029,
1002,
2023,
1011,
1028,
5587,
17058,
18442,
23058,
13122,
18886,
3070,
25581,
1006,
1002,
2895,
1007,
1024,
1002,
2895,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.ancestor | public function ancestor($lookup = null)
{
/** @var Pages $pages */
$pages = Grav::instance()['pages'];
return $pages->ancestor($this->route, $lookup);
} | php | public function ancestor($lookup = null)
{
/** @var Pages $pages */
$pages = Grav::instance()['pages'];
return $pages->ancestor($this->route, $lookup);
} | [
"public",
"function",
"ancestor",
"(",
"$",
"lookup",
"=",
"null",
")",
"{",
"/** @var Pages $pages */",
"$",
"pages",
"=",
"Grav",
"::",
"instance",
"(",
")",
"[",
"'pages'",
"]",
";",
"return",
"$",
"pages",
"->",
"ancestor",
"(",
"$",
"this",
"->",
... | Helper method to return an ancestor page.
@param bool $lookup Name of the parent folder
@return PageInterface page you were looking for if it exists | [
"Helper",
"method",
"to",
"return",
"an",
"ancestor",
"page",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L2576-L2582 | train | Get the ancestor page of this route | [
30522,
2270,
3853,
13032,
1006,
1002,
2298,
6279,
1027,
19701,
1007,
1063,
1013,
1008,
30524,
1024,
6013,
1006,
1007,
1031,
1005,
5530,
1005,
1033,
1025,
2709,
1002,
5530,
1011,
1028,
13032,
1006,
1002,
2023,
1011,
1028,
2799,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/ProgressBar.php | ProgressBar.getPlaceholderFormatterDefinition | public static function getPlaceholderFormatterDefinition(string $name): ?callable
{
if (!self::$formatters) {
self::$formatters = self::initPlaceholderFormatters();
}
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
} | php | public static function getPlaceholderFormatterDefinition(string $name): ?callable
{
if (!self::$formatters) {
self::$formatters = self::initPlaceholderFormatters();
}
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
} | [
"public",
"static",
"function",
"getPlaceholderFormatterDefinition",
"(",
"string",
"$",
"name",
")",
":",
"?",
"callable",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"formatters",
")",
"{",
"self",
"::",
"$",
"formatters",
"=",
"self",
"::",
"initPlaceholderFo... | Gets the placeholder formatter for a given name.
@param string $name The placeholder name (including the delimiter char like %)
@return callable|null A PHP callable | [
"Gets",
"the",
"placeholder",
"formatter",
"for",
"a",
"given",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/ProgressBar.php#L99-L106 | train | Returns the placeholder formatter definition for the given name. | [
30522,
2270,
10763,
3853,
2131,
24759,
10732,
14528,
14192,
20097,
3207,
16294,
22753,
1006,
5164,
1002,
2171,
1007,
1024,
1029,
2655,
3085,
1063,
2065,
1006,
999,
2969,
1024,
1024,
1002,
4289,
7747,
1007,
1063,
2969,
1024,
1024,
1002,
4289... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php | SqlServerGrammar.compileDropIfExists | public function compileDropIfExists(Blueprint $blueprint, Fluent $command)
{
return sprintf('if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = %s) drop table %s',
"'".str_replace("'", "''", $this->getTablePrefix().$blueprint->getTable())."'",
$this->wrapTable($blueprint)
);
} | php | public function compileDropIfExists(Blueprint $blueprint, Fluent $command)
{
return sprintf('if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = %s) drop table %s',
"'".str_replace("'", "''", $this->getTablePrefix().$blueprint->getTable())."'",
$this->wrapTable($blueprint)
);
} | [
"public",
"function",
"compileDropIfExists",
"(",
"Blueprint",
"$",
"blueprint",
",",
"Fluent",
"$",
"command",
")",
"{",
"return",
"sprintf",
"(",
"'if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = %s) drop table %s'",
",",
"\"'\"",
".",
"str_replace",
... | Compile a drop table (if exists) command.
@param \Illuminate\Database\Schema\Blueprint $blueprint
@param \Illuminate\Support\Fluent $command
@return string | [
"Compile",
"a",
"drop",
"table",
"(",
"if",
"exists",
")",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php#L166-L172 | train | Compile drop table if exists | [
30522,
2270,
3853,
9227,
18981,
29323,
9048,
12837,
1006,
2630,
16550,
1002,
2630,
16550,
1010,
19376,
1002,
3094,
1007,
1063,
2709,
9043,
2546,
1006,
1005,
2065,
6526,
1006,
7276,
1008,
2013,
2592,
1035,
8040,
28433,
1012,
7251,
2073,
2795... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Validator.php | Validator.getRule | protected function getRule($attribute, $rules)
{
if (! array_key_exists($attribute, $this->rules)) {
return;
}
$rules = (array) $rules;
foreach ($this->rules[$attribute] as $rule) {
[$rule, $parameters] = ValidationRuleParser::parse($rule);
if (in_array($rule, $rules)) {
return [$rule, $parameters];
}
}
} | php | protected function getRule($attribute, $rules)
{
if (! array_key_exists($attribute, $this->rules)) {
return;
}
$rules = (array) $rules;
foreach ($this->rules[$attribute] as $rule) {
[$rule, $parameters] = ValidationRuleParser::parse($rule);
if (in_array($rule, $rules)) {
return [$rule, $parameters];
}
}
} | [
"protected",
"function",
"getRule",
"(",
"$",
"attribute",
",",
"$",
"rules",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"attribute",
",",
"$",
"this",
"->",
"rules",
")",
")",
"{",
"return",
";",
"}",
"$",
"rules",
"=",
"(",
"array",
... | Get a rule and its parameters for a given attribute.
@param string $attribute
@param string|array $rules
@return array|null | [
"Get",
"a",
"rule",
"and",
"its",
"parameters",
"for",
"a",
"given",
"attribute",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Validator.php#L738-L753 | train | Get the rule for the attribute | [
30522,
5123,
3853,
2131,
6820,
2571,
1006,
1002,
17961,
1010,
1002,
3513,
1007,
1063,
2065,
1006,
999,
9140,
1035,
3145,
1035,
6526,
1006,
1002,
17961,
1010,
1002,
2023,
1011,
1028,
3513,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
3513,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Db/Pdo/Mysql.php | Mysql.query | public function query($query, $parameters = array())
{
if (is_null($this->connection)) {
return false;
}
try {
if (self::$profiling) {
$timer = $this->initProfiler();
}
if (!is_array($parameters)) {
$parameters = array($parameters);
}
$sth = $this->connection->prepare($query);
$sth->execute($parameters);
if (self::$profiling && isset($timer)) {
$this->recordQueryProfile($query, $timer);
}
return $sth;
} catch (PDOException $e) {
$message = $e->getMessage() . " In query: $query Parameters: " . var_export($parameters, true);
throw new DbException("Error query: " . $message, (int) $e->getCode());
}
} | php | public function query($query, $parameters = array())
{
if (is_null($this->connection)) {
return false;
}
try {
if (self::$profiling) {
$timer = $this->initProfiler();
}
if (!is_array($parameters)) {
$parameters = array($parameters);
}
$sth = $this->connection->prepare($query);
$sth->execute($parameters);
if (self::$profiling && isset($timer)) {
$this->recordQueryProfile($query, $timer);
}
return $sth;
} catch (PDOException $e) {
$message = $e->getMessage() . " In query: $query Parameters: " . var_export($parameters, true);
throw new DbException("Error query: " . $message, (int) $e->getCode());
}
} | [
"public",
"function",
"query",
"(",
"$",
"query",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"self",
"::... | Executes a query, using optional bound parameters.
@param string $query Query
@param array|string $parameters Parameters to bind array('idsite'=> 1)
@return PDOStatement|bool PDOStatement or false if failed
@throws DbException if an exception occurred | [
"Executes",
"a",
"query",
"using",
"optional",
"bound",
"parameters",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Db/Pdo/Mysql.php#L216-L241 | train | Returns a PDOStatement and executes it. | [
30522,
2270,
3853,
23032,
1006,
1002,
23032,
1010,
1002,
11709,
1027,
9140,
1006,
1007,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
4434,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
3046,
1063,
2065,
1006,
2969,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Constraints/LanguageValidator.php | LanguageValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Language) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Language');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
if (!class_exists(Languages::class)) {
throw new LogicException('The "symfony/intl" component is required to use the Language constraint.');
}
$value = (string) $value;
if (!Languages::exists($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Language::NO_SUCH_LANGUAGE_ERROR)
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Language) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Language');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
if (!class_exists(Languages::class)) {
throw new LogicException('The "symfony/intl" component is required to use the Language constraint.');
}
$value = (string) $value;
if (!Languages::exists($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Language::NO_SUCH_LANGUAGE_ERROR)
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Language",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/LanguageValidator.php#L31-L57 | train | Checks if the value is a valid Language value | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
2653,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
1035,
3415,
15327,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.