repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
symfony/symfony | src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php | ProfilerController.searchAction | public function searchAction(Request $request)
{
$this->denyAccessIfProfilerDisabled();
$ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
$method = $request->query->get('method');
$statusCode = $request->query->get('status_code');
$url = $request->query->get('url');
$start = $request->query->get('start', null);
$end = $request->query->get('end', null);
$limit = $request->query->get('limit');
$token = $request->query->get('token');
if ($request->hasSession()) {
$session = $request->getSession();
$session->set('_profiler_search_ip', $ip);
$session->set('_profiler_search_method', $method);
$session->set('_profiler_search_status_code', $statusCode);
$session->set('_profiler_search_url', $url);
$session->set('_profiler_search_start', $start);
$session->set('_profiler_search_end', $end);
$session->set('_profiler_search_limit', $limit);
$session->set('_profiler_search_token', $token);
}
if (!empty($token)) {
return new RedirectResponse($this->generator->generate('_profiler', ['token' => $token]), 302, ['Content-Type' => 'text/html']);
}
$tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode);
return new RedirectResponse($this->generator->generate('_profiler_search_results', [
'token' => $tokens ? $tokens[0]['token'] : 'empty',
'ip' => $ip,
'method' => $method,
'status_code' => $statusCode,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
]), 302, ['Content-Type' => 'text/html']);
} | php | public function searchAction(Request $request)
{
$this->denyAccessIfProfilerDisabled();
$ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
$method = $request->query->get('method');
$statusCode = $request->query->get('status_code');
$url = $request->query->get('url');
$start = $request->query->get('start', null);
$end = $request->query->get('end', null);
$limit = $request->query->get('limit');
$token = $request->query->get('token');
if ($request->hasSession()) {
$session = $request->getSession();
$session->set('_profiler_search_ip', $ip);
$session->set('_profiler_search_method', $method);
$session->set('_profiler_search_status_code', $statusCode);
$session->set('_profiler_search_url', $url);
$session->set('_profiler_search_start', $start);
$session->set('_profiler_search_end', $end);
$session->set('_profiler_search_limit', $limit);
$session->set('_profiler_search_token', $token);
}
if (!empty($token)) {
return new RedirectResponse($this->generator->generate('_profiler', ['token' => $token]), 302, ['Content-Type' => 'text/html']);
}
$tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode);
return new RedirectResponse($this->generator->generate('_profiler_search_results', [
'token' => $tokens ? $tokens[0]['token'] : 'empty',
'ip' => $ip,
'method' => $method,
'status_code' => $statusCode,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
]), 302, ['Content-Type' => 'text/html']);
} | [
"public",
"function",
"searchAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"denyAccessIfProfilerDisabled",
"(",
")",
";",
"$",
"ip",
"=",
"preg_replace",
"(",
"'/[^:\\d\\.]/'",
",",
"''",
",",
"$",
"request",
"->",
"query",
"->",
"g... | Narrows the search bar.
@return Response A Response instance
@throws NotFoundHttpException | [
"Narrows",
"the",
"search",
"bar",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php#L261-L303 | train | Search for tokens | [
30522,
2270,
3853,
3945,
18908,
3258,
1006,
5227,
1002,
5227,
1007,
1063,
1002,
2023,
1011,
1028,
9772,
6305,
9623,
5332,
22540,
3217,
8873,
3917,
10521,
3085,
2094,
1006,
1007,
1025,
1002,
12997,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
slimphp/Slim | Slim/CallableResolver.php | CallableResolver.resolveCallable | protected function resolveCallable($class, $method = '__invoke')
{
if ($this->container->has($class)) {
return [$this->container->get($class), $method];
}
if (!class_exists($class)) {
throw new RuntimeException(sprintf('Callable %s does not exist', $class));
}
return [new $class($this->container), $method];
} | php | protected function resolveCallable($class, $method = '__invoke')
{
if ($this->container->has($class)) {
return [$this->container->get($class), $method];
}
if (!class_exists($class)) {
throw new RuntimeException(sprintf('Callable %s does not exist', $class));
}
return [new $class($this->container), $method];
} | [
"protected",
"function",
"resolveCallable",
"(",
"$",
"class",
",",
"$",
"method",
"=",
"'__invoke'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"class",
")",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"container",
"... | Check if string is something in the DIC
that's callable or is a class name which has an __invoke() method.
@param string $class
@param string $method
@return callable
@throws RuntimeException if the callable does not exist | [
"Check",
"if",
"string",
"is",
"something",
"in",
"the",
"DIC",
"that",
"s",
"callable",
"or",
"is",
"a",
"class",
"name",
"which",
"has",
"an",
"__invoke",
"()",
"method",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/CallableResolver.php#L83-L94 | train | Resolves callable. | [
30522,
5123,
3853,
10663,
9289,
20470,
2571,
1006,
1002,
2465,
1010,
1002,
4118,
1027,
1005,
1035,
1035,
1999,
6767,
3489,
1005,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11661,
1011,
1028,
2038,
1006,
1002,
2465,
1007,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Report.php | Report.getProcessedMetricsForTable | public static function getProcessedMetricsForTable(DataTable $dataTable, Report $report = null)
{
/** @var ProcessedMetric[] $metrics */
$metrics = self::getMetricsForTable($dataTable, $report, 'Piwik\\Plugin\\ProcessedMetric');
// sort metrics w/ dependent metrics calculated before the metrics that depend on them
$result = [];
self::processedMetricDfs($metrics, function ($metricName) use (&$result, $metrics) {
$result[$metricName] = $metrics[$metricName];
});
return $result;
} | php | public static function getProcessedMetricsForTable(DataTable $dataTable, Report $report = null)
{
/** @var ProcessedMetric[] $metrics */
$metrics = self::getMetricsForTable($dataTable, $report, 'Piwik\\Plugin\\ProcessedMetric');
// sort metrics w/ dependent metrics calculated before the metrics that depend on them
$result = [];
self::processedMetricDfs($metrics, function ($metricName) use (&$result, $metrics) {
$result[$metricName] = $metrics[$metricName];
});
return $result;
} | [
"public",
"static",
"function",
"getProcessedMetricsForTable",
"(",
"DataTable",
"$",
"dataTable",
",",
"Report",
"$",
"report",
"=",
"null",
")",
"{",
"/** @var ProcessedMetric[] $metrics */",
"$",
"metrics",
"=",
"self",
"::",
"getMetricsForTable",
"(",
"$",
"data... | Returns the ProcessedMetrics that should be computed and formatted for a DataTable of a
certain report. The ProcessedMetrics returned are those specified by the Report metadata
as well as the DataTable metadata.
@param DataTable $dataTable
@param Report|null $report
@return ProcessedMetric[]
@api | [
"Returns",
"the",
"ProcessedMetrics",
"that",
"should",
"be",
"computed",
"and",
"formatted",
"for",
"a",
"DataTable",
"of",
"a",
"certain",
"report",
".",
"The",
"ProcessedMetrics",
"returned",
"are",
"those",
"specified",
"by",
"the",
"Report",
"metadata",
"as... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Report.php#L1005-L1016 | train | Returns all processed metrics for a DataTable and a report. | [
30522,
2270,
10763,
3853,
2131,
21572,
9623,
6924,
12589,
22747,
11589,
3085,
1006,
2951,
10880,
1002,
2951,
10880,
1010,
3189,
1002,
3189,
1027,
19701,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
13995,
12589,
1031,
1033,
1002,
12046,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail.php | Zend_Mail.getBodyHtml | public function getBodyHtml($htmlOnly = false)
{
if ($htmlOnly && $this->_bodyHtml) {
$body = $this->_bodyHtml;
return $body->getContent();
}
return $this->_bodyHtml;
} | php | public function getBodyHtml($htmlOnly = false)
{
if ($htmlOnly && $this->_bodyHtml) {
$body = $this->_bodyHtml;
return $body->getContent();
}
return $this->_bodyHtml;
} | [
"public",
"function",
"getBodyHtml",
"(",
"$",
"htmlOnly",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"htmlOnly",
"&&",
"$",
"this",
"->",
"_bodyHtml",
")",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"_bodyHtml",
";",
"return",
"$",
"body",
"->",
"getCon... | Return Zend_Mime_Part representing body HTML
@param bool $htmlOnly Whether to return the body HTML only, or the MIME part; defaults to false, the MIME part
@return false|Zend_Mime_Part|string | [
"Return",
"Zend_Mime_Part",
"representing",
"body",
"HTML"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L425-L433 | train | Get Body Html | [
30522,
2270,
3853,
2131,
23684,
11039,
19968,
1006,
1002,
16129,
2239,
2135,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
16129,
2239,
2135,
1004,
1004,
1002,
2023,
1011,
1028,
1035,
2303,
11039,
19968,
1007,
1063,
1002,
2303,
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... |
overtrue/wechat | src/Factory.php | Factory.make | public static function make($name, array $config)
{
$namespace = Kernel\Support\Str::studly($name);
$application = "\\EasyWeChat\\{$namespace}\\Application";
return new $application($config);
} | php | public static function make($name, array $config)
{
$namespace = Kernel\Support\Str::studly($name);
$application = "\\EasyWeChat\\{$namespace}\\Application";
return new $application($config);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"$",
"namespace",
"=",
"Kernel",
"\\",
"Support",
"\\",
"Str",
"::",
"studly",
"(",
"$",
"name",
")",
";",
"$",
"application",
"=",
"\"\\\\EasyWeChat\\\\{$na... | @param string $name
@param array $config
@return \EasyWeChat\Kernel\ServiceContainer | [
"@param",
"string",
"$name",
"@param",
"array",
"$config"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Factory.php#L33-L39 | train | Create a new instance of the current class | [
30522,
2270,
10763,
3853,
2191,
1006,
1002,
2171,
1010,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
3415,
15327,
1027,
16293,
1032,
2490,
1032,
2358,
2099,
1024,
1024,
16054,
2135,
1006,
1002,
2171,
1007,
1025,
1002,
4646,
1027,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Referrers/API.php | API.removeSubtableIds | private function removeSubtableIds($table)
{
if ($table instanceof DataTable\Map) {
foreach ($table->getDataTables() as $childTable) {
$this->removeSubtableIds($childTable);
}
} else {
foreach ($table->getRows() as $row) {
$row->removeSubtable();
}
}
return $table;
} | php | private function removeSubtableIds($table)
{
if ($table instanceof DataTable\Map) {
foreach ($table->getDataTables() as $childTable) {
$this->removeSubtableIds($childTable);
}
} else {
foreach ($table->getRows() as $row) {
$row->removeSubtable();
}
}
return $table;
} | [
"private",
"function",
"removeSubtableIds",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"instanceof",
"DataTable",
"\\",
"Map",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"getDataTables",
"(",
")",
"as",
"$",
"childTable",
")",
"{",
"$",
"... | Utility function that removes the subtable IDs for the subtables of the
getReferrerType report. This avoids infinite recursion in said report (ie,
the grandchildren of the report will be the original report, and it will
recurse when trying to get a flat report).
@param DataTable $table
@return DataTable Returns $table for convenience. | [
"Utility",
"function",
"that",
"removes",
"the",
"subtable",
"IDs",
"for",
"the",
"subtables",
"of",
"the",
"getReferrerType",
"report",
".",
"This",
"avoids",
"infinite",
"recursion",
"in",
"said",
"report",
"(",
"ie",
"the",
"grandchildren",
"of",
"the",
"re... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L594-L607 | train | Remove all subtable ids of a DataTable | [
30522,
2797,
3853,
20362,
12083,
10880,
9821,
1006,
1002,
2795,
1007,
1063,
2065,
1006,
1002,
2795,
6013,
11253,
2951,
10880,
1032,
4949,
1007,
1063,
18921,
6776,
1006,
1002,
2795,
1011,
1028,
2131,
2850,
29336,
3085,
2015,
1006,
1007,
2004... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SubmitButton.php | SubmitButton.submit | public function submit($submittedData, $clearMissing = true)
{
if ($this->getConfig()->getDisabled()) {
$this->clicked = false;
return $this;
}
parent::submit($submittedData, $clearMissing);
$this->clicked = null !== $submittedData;
return $this;
} | php | public function submit($submittedData, $clearMissing = true)
{
if ($this->getConfig()->getDisabled()) {
$this->clicked = false;
return $this;
}
parent::submit($submittedData, $clearMissing);
$this->clicked = null !== $submittedData;
return $this;
} | [
"public",
"function",
"submit",
"(",
"$",
"submittedData",
",",
"$",
"clearMissing",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getDisabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"clicked",
"=",
"false",
";",... | Submits data to the button.
@param string|null $submittedData The data
@param bool $clearMissing Not used
@return $this
@throws Exception\AlreadySubmittedException if the form has already been submitted | [
"Submits",
"data",
"to",
"the",
"button",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/SubmitButton.php#L44-L57 | train | Submits the form to the user | [
30522,
2270,
3853,
12040,
1006,
1002,
7864,
2850,
2696,
1010,
1002,
3154,
15630,
7741,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2131,
8663,
8873,
2290,
1006,
1007,
1011,
1028,
2131,
10521,
3085,
2094,
1006,
1007,
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... |
overtrue/wechat | src/Payment/Refund/Client.php | Client.byTransactionId | public function byTransactionId(string $transactionId, string $refundNumber, int $totalFee, int $refundFee, array $optional = [])
{
return $this->refund($refundNumber, $totalFee, $refundFee, array_merge($optional, ['transaction_id' => $transactionId]));
} | php | public function byTransactionId(string $transactionId, string $refundNumber, int $totalFee, int $refundFee, array $optional = [])
{
return $this->refund($refundNumber, $totalFee, $refundFee, array_merge($optional, ['transaction_id' => $transactionId]));
} | [
"public",
"function",
"byTransactionId",
"(",
"string",
"$",
"transactionId",
",",
"string",
"$",
"refundNumber",
",",
"int",
"$",
"totalFee",
",",
"int",
"$",
"refundFee",
",",
"array",
"$",
"optional",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"-... | Refund by transaction id.
@param string $transactionId
@param string $refundNumber
@param int $totalFee
@param int $refundFee
@param array $optional
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Refund",
"by",
"transaction",
"id",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Refund/Client.php#L49-L52 | train | Refund by Transaction ID | [
30522,
2270,
3853,
2011,
6494,
3619,
18908,
3258,
3593,
1006,
5164,
1002,
12598,
3593,
1010,
5164,
1002,
25416,
8630,
19172,
5677,
1010,
20014,
1002,
2561,
7959,
2063,
1010,
20014,
1002,
25416,
8630,
7959,
2063,
1010,
9140,
1002,
11887,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/formwidgets/CodeEditor.php | CodeEditor.applyEditorPreferences | protected function applyEditorPreferences()
{
// Load the editor system settings
$preferences = BackendPreference::instance();
$this->fontSize = $preferences->editor_font_size;
$this->wordWrap = $preferences->editor_word_wrap;
$this->codeFolding = $preferences->editor_code_folding;
$this->autoClosing = $preferences->editor_auto_closing;
$this->tabSize = $preferences->editor_tab_size;
$this->theme = $preferences->editor_theme;
$this->showInvisibles = $preferences->editor_show_invisibles;
$this->highlightActiveLine = $preferences->editor_highlight_active_line;
$this->useSoftTabs = !$preferences->editor_use_hard_tabs;
$this->showGutter = $preferences->editor_show_gutter;
$this->autocompletion = $preferences->editor_autocompletion;
$this->enableSnippets = $preferences->editor_enable_snippets;
$this->displayIndentGuides = $preferences->editor_display_indent_guides;
$this->showPrintMargin = $preferences->editor_show_print_margin;
} | php | protected function applyEditorPreferences()
{
// Load the editor system settings
$preferences = BackendPreference::instance();
$this->fontSize = $preferences->editor_font_size;
$this->wordWrap = $preferences->editor_word_wrap;
$this->codeFolding = $preferences->editor_code_folding;
$this->autoClosing = $preferences->editor_auto_closing;
$this->tabSize = $preferences->editor_tab_size;
$this->theme = $preferences->editor_theme;
$this->showInvisibles = $preferences->editor_show_invisibles;
$this->highlightActiveLine = $preferences->editor_highlight_active_line;
$this->useSoftTabs = !$preferences->editor_use_hard_tabs;
$this->showGutter = $preferences->editor_show_gutter;
$this->autocompletion = $preferences->editor_autocompletion;
$this->enableSnippets = $preferences->editor_enable_snippets;
$this->displayIndentGuides = $preferences->editor_display_indent_guides;
$this->showPrintMargin = $preferences->editor_show_print_margin;
} | [
"protected",
"function",
"applyEditorPreferences",
"(",
")",
"{",
"// Load the editor system settings",
"$",
"preferences",
"=",
"BackendPreference",
"::",
"instance",
"(",
")",
";",
"$",
"this",
"->",
"fontSize",
"=",
"$",
"preferences",
"->",
"editor_font_size",
"... | Looks at the user preferences and overrides any set values.
@return void | [
"Looks",
"at",
"the",
"user",
"preferences",
"and",
"overrides",
"any",
"set",
"values",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/CodeEditor.php#L198-L217 | train | Load the editor preferences | [
30522,
5123,
3853,
6611,
2098,
15660,
28139,
25523,
2015,
1006,
1007,
1063,
1013,
1013,
7170,
1996,
3559,
2291,
10906,
1002,
18394,
1027,
2067,
10497,
28139,
25523,
1024,
1024,
6013,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
15489,
5332,
43... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/AcceptHeader.php | AcceptHeader.fromString | public static function fromString($headerValue)
{
$index = 0;
$parts = HeaderUtils::split((string) $headerValue, ',;=');
return new self(array_map(function ($subParts) use (&$index) {
$part = array_shift($subParts);
$attributes = HeaderUtils::combine($subParts);
$item = new AcceptHeaderItem($part[0], $attributes);
$item->setIndex($index++);
return $item;
}, $parts));
} | php | public static function fromString($headerValue)
{
$index = 0;
$parts = HeaderUtils::split((string) $headerValue, ',;=');
return new self(array_map(function ($subParts) use (&$index) {
$part = array_shift($subParts);
$attributes = HeaderUtils::combine($subParts);
$item = new AcceptHeaderItem($part[0], $attributes);
$item->setIndex($index++);
return $item;
}, $parts));
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"headerValue",
")",
"{",
"$",
"index",
"=",
"0",
";",
"$",
"parts",
"=",
"HeaderUtils",
"::",
"split",
"(",
"(",
"string",
")",
"$",
"headerValue",
",",
"',;='",
")",
";",
"return",
"new",
"self",... | Builds an AcceptHeader instance from a string.
@param string $headerValue
@return self | [
"Builds",
"an",
"AcceptHeader",
"instance",
"from",
"a",
"string",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/AcceptHeader.php#L51-L66 | train | Create AcceptHeaderList from header value | [
30522,
2270,
10763,
3853,
2013,
3367,
4892,
1006,
1002,
20346,
10175,
5657,
1007,
1063,
1002,
5950,
1027,
1014,
1025,
1002,
3033,
1027,
20346,
21823,
4877,
1024,
1024,
3975,
1006,
1006,
5164,
1007,
1002,
20346,
10175,
5657,
1010,
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... |
matomo-org/matomo | libs/Zend/Db/Adapter/Db2.php | Zend_Db_Adapter_Db2.listTables | public function listTables($schema = null)
{
$this->_connect();
if ($schema === null && $this->_config['schema'] != null) {
$schema = $this->_config['schema'];
}
$tables = array();
if (!$this->_isI5) {
if ($schema) {
$stmt = db2_tables($this->_connection, null, $schema);
} else {
$stmt = db2_tables($this->_connection);
}
while ($row = db2_fetch_assoc($stmt)) {
$tables[] = $row['TABLE_NAME'];
}
} else {
$tables = $this->_i5listTables($schema);
}
return $tables;
} | php | public function listTables($schema = null)
{
$this->_connect();
if ($schema === null && $this->_config['schema'] != null) {
$schema = $this->_config['schema'];
}
$tables = array();
if (!$this->_isI5) {
if ($schema) {
$stmt = db2_tables($this->_connection, null, $schema);
} else {
$stmt = db2_tables($this->_connection);
}
while ($row = db2_fetch_assoc($stmt)) {
$tables[] = $row['TABLE_NAME'];
}
} else {
$tables = $this->_i5listTables($schema);
}
return $tables;
} | [
"public",
"function",
"listTables",
"(",
"$",
"schema",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"if",
"(",
"$",
"schema",
"===",
"null",
"&&",
"$",
"this",
"->",
"_config",
"[",
"'schema'",
"]",
"!=",
"null",
")",
"{",
... | Returns a list of the tables in the database.
@param string $schema OPTIONAL
@return array | [
"Returns",
"a",
"list",
"of",
"the",
"tables",
"in",
"the",
"database",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Db2.php#L320-L344 | train | Returns an array of tables in the database | [
30522,
2270,
3853,
2862,
10880,
2015,
1006,
1002,
8040,
28433,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
2065,
1006,
1002,
8040,
28433,
1027,
1027,
1027,
19701,
1004,
1004,
1002,
2023,
1011,
1028,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Console/Gpm/UninstallCommand.php | UninstallCommand.uninstallPackage | private function uninstallPackage($slug, $package, $is_dependency = false)
{
if (!$slug) {
return false;
}
//check if there are packages that have this as a dependency. Abort and show list
$dependent_packages = $this->gpm->getPackagesThatDependOnPackage($slug);
if (count($dependent_packages) > ($is_dependency ? 1 : 0)) {
$this->output->writeln('');
$this->output->writeln('');
$this->output->writeln('<red>Uninstallation failed.</red>');
$this->output->writeln('');
if (\count($dependent_packages) > ($is_dependency ? 2 : 1)) {
$this->output->writeln('The installed packages <cyan>' . implode('</cyan>, <cyan>', $dependent_packages) . '</cyan> depends on this package. Please remove those first.');
} else {
$this->output->writeln('The installed package <cyan>' . implode('</cyan>, <cyan>', $dependent_packages) . '</cyan> depends on this package. Please remove it first.');
}
$this->output->writeln('');
return false;
}
if (isset($package->dependencies)) {
$dependencies = $package->dependencies;
if ($is_dependency) {
foreach ($dependencies as $key => $dependency) {
if (\in_array($dependency['name'], $this->dependencies, true)) {
unset($dependencies[$key]);
}
}
} else {
if (\count($dependencies) > 0) {
$this->output->writeln(' `- Dependencies found...');
$this->output->writeln('');
}
}
$questionHelper = $this->getHelper('question');
foreach ($dependencies as $dependency) {
$this->dependencies[] = $dependency['name'];
if (\is_array($dependency)) {
$dependency = $dependency['name'];
}
if ($dependency === 'grav' || $dependency === 'php') {
continue;
}
$dependencyPackage = $this->gpm->findPackage($dependency);
$dependency_exists = $this->packageExists($dependency, $dependencyPackage);
if ($dependency_exists == Installer::EXISTS) {
$this->output->writeln("A dependency on <cyan>{$dependencyPackage->name}</cyan> [v{$dependencyPackage->version}] was found");
$question = new ConfirmationQuestion(" |- Uninstall <cyan>{$dependencyPackage->name}</cyan>? [y|N] ", false);
$answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question);
if ($answer) {
$uninstall = $this->uninstallPackage($dependency, $dependencyPackage, true);
if (!$uninstall) {
$this->output->writeln(" '- <red>Uninstallation failed or aborted.</red>");
} else {
$this->output->writeln(" '- <green>Success!</green> ");
}
$this->output->writeln('');
} else {
$this->output->writeln(" '- <yellow>You decided not to uninstall {$dependencyPackage->name}.</yellow>");
$this->output->writeln('');
}
}
}
}
$locator = Grav::instance()['locator'];
$path = $locator->findResource($package->package_type . '://' . $slug);
Installer::uninstall($path);
$errorCode = Installer::lastErrorCode();
if ($errorCode && $errorCode !== Installer::IS_LINK && $errorCode !== Installer::EXISTS) {
$this->output->writeln(" |- Uninstalling {$package->name} package... <red>error</red> ");
$this->output->writeln(" | '- <yellow>" . Installer::lastErrorMsg() . '</yellow>');
return false;
}
$message = Installer::getMessage();
if ($message) {
$this->output->writeln(" |- {$message}");
}
if (!$is_dependency && $this->dependencies) {
$this->output->writeln("Finishing up uninstalling <cyan>{$package->name}</cyan>");
}
$this->output->writeln(" |- Uninstalling {$package->name} package... <green>ok</green> ");
return true;
} | php | private function uninstallPackage($slug, $package, $is_dependency = false)
{
if (!$slug) {
return false;
}
//check if there are packages that have this as a dependency. Abort and show list
$dependent_packages = $this->gpm->getPackagesThatDependOnPackage($slug);
if (count($dependent_packages) > ($is_dependency ? 1 : 0)) {
$this->output->writeln('');
$this->output->writeln('');
$this->output->writeln('<red>Uninstallation failed.</red>');
$this->output->writeln('');
if (\count($dependent_packages) > ($is_dependency ? 2 : 1)) {
$this->output->writeln('The installed packages <cyan>' . implode('</cyan>, <cyan>', $dependent_packages) . '</cyan> depends on this package. Please remove those first.');
} else {
$this->output->writeln('The installed package <cyan>' . implode('</cyan>, <cyan>', $dependent_packages) . '</cyan> depends on this package. Please remove it first.');
}
$this->output->writeln('');
return false;
}
if (isset($package->dependencies)) {
$dependencies = $package->dependencies;
if ($is_dependency) {
foreach ($dependencies as $key => $dependency) {
if (\in_array($dependency['name'], $this->dependencies, true)) {
unset($dependencies[$key]);
}
}
} else {
if (\count($dependencies) > 0) {
$this->output->writeln(' `- Dependencies found...');
$this->output->writeln('');
}
}
$questionHelper = $this->getHelper('question');
foreach ($dependencies as $dependency) {
$this->dependencies[] = $dependency['name'];
if (\is_array($dependency)) {
$dependency = $dependency['name'];
}
if ($dependency === 'grav' || $dependency === 'php') {
continue;
}
$dependencyPackage = $this->gpm->findPackage($dependency);
$dependency_exists = $this->packageExists($dependency, $dependencyPackage);
if ($dependency_exists == Installer::EXISTS) {
$this->output->writeln("A dependency on <cyan>{$dependencyPackage->name}</cyan> [v{$dependencyPackage->version}] was found");
$question = new ConfirmationQuestion(" |- Uninstall <cyan>{$dependencyPackage->name}</cyan>? [y|N] ", false);
$answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question);
if ($answer) {
$uninstall = $this->uninstallPackage($dependency, $dependencyPackage, true);
if (!$uninstall) {
$this->output->writeln(" '- <red>Uninstallation failed or aborted.</red>");
} else {
$this->output->writeln(" '- <green>Success!</green> ");
}
$this->output->writeln('');
} else {
$this->output->writeln(" '- <yellow>You decided not to uninstall {$dependencyPackage->name}.</yellow>");
$this->output->writeln('');
}
}
}
}
$locator = Grav::instance()['locator'];
$path = $locator->findResource($package->package_type . '://' . $slug);
Installer::uninstall($path);
$errorCode = Installer::lastErrorCode();
if ($errorCode && $errorCode !== Installer::IS_LINK && $errorCode !== Installer::EXISTS) {
$this->output->writeln(" |- Uninstalling {$package->name} package... <red>error</red> ");
$this->output->writeln(" | '- <yellow>" . Installer::lastErrorMsg() . '</yellow>');
return false;
}
$message = Installer::getMessage();
if ($message) {
$this->output->writeln(" |- {$message}");
}
if (!$is_dependency && $this->dependencies) {
$this->output->writeln("Finishing up uninstalling <cyan>{$package->name}</cyan>");
}
$this->output->writeln(" |- Uninstalling {$package->name} package... <green>ok</green> ");
return true;
} | [
"private",
"function",
"uninstallPackage",
"(",
"$",
"slug",
",",
"$",
"package",
",",
"$",
"is_dependency",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"slug",
")",
"{",
"return",
"false",
";",
"}",
"//check if there are packages that have this as a dependency... | @param string $slug
@param Package $package
@return bool | [
"@param",
"string",
"$slug",
"@param",
"Package",
"$package"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/Gpm/UninstallCommand.php#L132-L240 | train | Uninstalls a package | [
30522,
2797,
3853,
4895,
7076,
9080,
14277,
8684,
4270,
1006,
1002,
23667,
1010,
1002,
7427,
1010,
1002,
2003,
1035,
24394,
1027,
6270,
1007,
1063,
2065,
1006,
999,
1002,
23667,
1007,
1063,
2709,
6270,
1025,
1065,
1013,
1013,
4638,
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/Database/Query/Builder.php | Builder.insertUsing | public function insertUsing(array $columns, $query)
{
[$sql, $bindings] = $this->createSub($query);
return $this->connection->insert(
$this->grammar->compileInsertUsing($this, $columns, $sql),
$this->cleanBindings($bindings)
);
} | php | public function insertUsing(array $columns, $query)
{
[$sql, $bindings] = $this->createSub($query);
return $this->connection->insert(
$this->grammar->compileInsertUsing($this, $columns, $sql),
$this->cleanBindings($bindings)
);
} | [
"public",
"function",
"insertUsing",
"(",
"array",
"$",
"columns",
",",
"$",
"query",
")",
"{",
"[",
"$",
"sql",
",",
"$",
"bindings",
"]",
"=",
"$",
"this",
"->",
"createSub",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
"->",
"connection",
... | Insert new records into the table using a subquery.
@param array $columns
@param \Closure|\Illuminate\Database\Query\Builder|string $query
@return bool | [
"Insert",
"new",
"records",
"into",
"the",
"table",
"using",
"a",
"subquery",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L2667-L2675 | train | Inserts a record into the database using a query. The parameters are passed to the insert method. | [
30522,
2270,
3853,
19274,
18161,
1006,
9140,
1002,
7753,
1010,
1002,
23032,
1007,
1063,
1031,
1002,
29296,
1010,
1002,
8031,
2015,
1033,
1027,
1002,
2023,
1011,
1028,
9005,
12083,
1006,
1002,
23032,
1007,
1025,
2709,
1002,
2023,
1011,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Table/Select.php | Zend_Db_Table_Select.isReadOnly | public function isReadOnly()
{
$readOnly = false;
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
$cols = $this->_info[Zend_Db_Table_Abstract::COLS];
if (!count($fields)) {
return $readOnly;
}
foreach ($fields as $columnEntry) {
$column = $columnEntry[1];
$alias = $columnEntry[2];
if ($alias !== null) {
$column = $alias;
}
switch (true) {
case ($column == self::SQL_WILDCARD):
break;
case ($column instanceof Zend_Db_Expr):
case (!in_array($column, $cols)):
$readOnly = true;
break 2;
}
}
return $readOnly;
} | php | public function isReadOnly()
{
$readOnly = false;
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
$cols = $this->_info[Zend_Db_Table_Abstract::COLS];
if (!count($fields)) {
return $readOnly;
}
foreach ($fields as $columnEntry) {
$column = $columnEntry[1];
$alias = $columnEntry[2];
if ($alias !== null) {
$column = $alias;
}
switch (true) {
case ($column == self::SQL_WILDCARD):
break;
case ($column instanceof Zend_Db_Expr):
case (!in_array($column, $cols)):
$readOnly = true;
break 2;
}
}
return $readOnly;
} | [
"public",
"function",
"isReadOnly",
"(",
")",
"{",
"$",
"readOnly",
"=",
"false",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"getPart",
"(",
"Zend_Db_Table_Select",
"::",
"COLUMNS",
")",
";",
"$",
"cols",
"=",
"$",
"this",
"->",
"_info",
"[",
"Zend_Db... | Tests query to determine if expressions or aliases columns exist.
@return boolean | [
"Tests",
"query",
"to",
"determine",
"if",
"expressions",
"or",
"aliases",
"columns",
"exist",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Select.php#L126-L156 | train | Return true if this table is read - only | [
30522,
2270,
3853,
2003,
16416,
5280,
2135,
1006,
1007,
1063,
1002,
3191,
2239,
2135,
1027,
6270,
1025,
1002,
4249,
1027,
1002,
2023,
1011,
1028,
2131,
19362,
2102,
1006,
16729,
2094,
1035,
16962,
1035,
2795,
1035,
7276,
1024,
1024,
7753,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.hasSttyAvailable | private function hasSttyAvailable(): bool
{
if (null !== self::$stty) {
return self::$stty;
}
exec('stty 2>&1', $output, $exitcode);
return self::$stty = 0 === $exitcode;
} | php | private function hasSttyAvailable(): bool
{
if (null !== self::$stty) {
return self::$stty;
}
exec('stty 2>&1', $output, $exitcode);
return self::$stty = 0 === $exitcode;
} | [
"private",
"function",
"hasSttyAvailable",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"null",
"!==",
"self",
"::",
"$",
"stty",
")",
"{",
"return",
"self",
"::",
"$",
"stty",
";",
"}",
"exec",
"(",
"'stty 2>&1'",
",",
"$",
"output",
",",
"$",
"exitcode",... | Returns whether Stty is available or not. | [
"Returns",
"whether",
"Stty",
"is",
"available",
"or",
"not",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/QuestionHelper.php#L442-L451 | train | Has Stty available? | [
30522,
2797,
3853,
2038,
3367,
21426,
3567,
11733,
3468,
1006,
1007,
1024,
22017,
2140,
1063,
2065,
1006,
19701,
999,
1027,
1027,
2969,
1024,
1024,
1002,
2358,
3723,
1007,
1063,
2709,
2969,
1024,
1024,
1002,
2358,
3723,
1025,
1065,
4654,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php | SqlServerGrammar.compileUpdate | public function compileUpdate(Builder $query, $values)
{
[$table, $alias] = $this->parseUpdateTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements.
$columns = collect($values)->map(function ($value, $key) {
return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
// If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries
// can get join statements to attach to other tables when they're needed.
$joins = '';
if (isset($query->joins)) {
$joins = ' '.$this->compileJoins($query, $query->joins);
}
// Of course, update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run.
$where = $this->compileWheres($query);
if (! empty($joins)) {
return trim("update {$alias} set {$columns} from {$table}{$joins} {$where}");
}
return trim("update {$table}{$joins} set $columns $where");
} | php | public function compileUpdate(Builder $query, $values)
{
[$table, $alias] = $this->parseUpdateTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements.
$columns = collect($values)->map(function ($value, $key) {
return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
// If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries
// can get join statements to attach to other tables when they're needed.
$joins = '';
if (isset($query->joins)) {
$joins = ' '.$this->compileJoins($query, $query->joins);
}
// Of course, update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run.
$where = $this->compileWheres($query);
if (! empty($joins)) {
return trim("update {$alias} set {$columns} from {$table}{$joins} {$where}");
}
return trim("update {$table}{$joins} set $columns $where");
} | [
"public",
"function",
"compileUpdate",
"(",
"Builder",
"$",
"query",
",",
"$",
"values",
")",
"{",
"[",
"$",
"table",
",",
"$",
"alias",
"]",
"=",
"$",
"this",
"->",
"parseUpdateTable",
"(",
"$",
"query",
"->",
"from",
")",
";",
"// Each one of the colum... | Compile an update statement into SQL.
@param \Illuminate\Database\Query\Builder $query
@param array $values
@return string | [
"Compile",
"an",
"update",
"statement",
"into",
"SQL",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php#L350-L380 | train | Compiles an update query into SQL | [
30522,
2270,
3853,
4012,
22090,
6279,
13701,
1006,
12508,
1002,
23032,
1010,
1002,
5300,
1007,
1063,
1031,
1002,
2795,
1010,
1002,
14593,
1033,
1027,
1002,
2023,
1011,
1028,
11968,
3366,
6279,
13701,
10880,
1006,
1002,
23032,
1011,
1028,
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 | core/Session.php | Session.isSessionHandler | public static function isSessionHandler($handler)
{
$config = Config::getInstance();
return !isset($config->General['session_save_handler'])
|| $config->General['session_save_handler'] === $handler;
} | php | public static function isSessionHandler($handler)
{
$config = Config::getInstance();
return !isset($config->General['session_save_handler'])
|| $config->General['session_save_handler'] === $handler;
} | [
"public",
"static",
"function",
"isSessionHandler",
"(",
"$",
"handler",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"getInstance",
"(",
")",
";",
"return",
"!",
"isset",
"(",
"$",
"config",
"->",
"General",
"[",
"'session_save_handler'",
"]",
")",
"||",... | Are we using file-based session store?
@return bool True if file-based; false otherwise | [
"Are",
"we",
"using",
"file",
"-",
"based",
"session",
"store?"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Session.php#L34-L39 | train | Check if session handler is set in config | [
30522,
2270,
10763,
3853,
26354,
7971,
3258,
11774,
3917,
1006,
1002,
28213,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1025,
2709,
999,
26354,
3388,
1006,
1002,
9530,
8873,
2290,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Session.php | Zend_Session.sessionExists | public static function sessionExists()
{
if (ini_get('session.use_cookies') == '1' && isset($_COOKIE[session_name()])) {
return true;
} elseif (!empty($_REQUEST[session_name()])) {
return true;
} elseif (self::$_unitTestEnabled) {
return true;
}
return false;
} | php | public static function sessionExists()
{
if (ini_get('session.use_cookies') == '1' && isset($_COOKIE[session_name()])) {
return true;
} elseif (!empty($_REQUEST[session_name()])) {
return true;
} elseif (self::$_unitTestEnabled) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"sessionExists",
"(",
")",
"{",
"if",
"(",
"ini_get",
"(",
"'session.use_cookies'",
")",
"==",
"'1'",
"&&",
"isset",
"(",
"$",
"_COOKIE",
"[",
"session_name",
"(",
")",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"el... | sessionExists() - whether or not a session exists for the current request
@return bool | [
"sessionExists",
"()",
"-",
"whether",
"or",
"not",
"a",
"session",
"exists",
"for",
"the",
"current",
"request"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session.php#L384-L395 | train | Returns true if session exists | [
30522,
2270,
10763,
3853,
5219,
10288,
5130,
1006,
1007,
1063,
2065,
1006,
1999,
2072,
1035,
2131,
1006,
1005,
5219,
1012,
2224,
1035,
16324,
1005,
1007,
1027,
1027,
1005,
1015,
1005,
1004,
1004,
26354,
3388,
1006,
1002,
1035,
17387,
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/Auth/DatabaseUserProvider.php | DatabaseUserProvider.updateRememberToken | public function updateRememberToken(UserContract $user, $token)
{
$this->conn->table($this->table)
->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
->update([$user->getRememberTokenName() => $token]);
} | php | public function updateRememberToken(UserContract $user, $token)
{
$this->conn->table($this->table)
->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
->update([$user->getRememberTokenName() => $token]);
} | [
"public",
"function",
"updateRememberToken",
"(",
"UserContract",
"$",
"user",
",",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"conn",
"->",
"table",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"where",
"(",
"$",
"user",
"->",
"getAuthIdentifierName",
"(... | Update the "remember me" token for the given user in storage.
@param \Illuminate\Contracts\Auth\Authenticatable $user
@param string $token
@return void | [
"Update",
"the",
"remember",
"me",
"token",
"for",
"the",
"given",
"user",
"in",
"storage",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/DatabaseUserProvider.php#L87-L92 | train | Update the remember me token for a user | [
30522,
2270,
3853,
10651,
28578,
6633,
21201,
7520,
1006,
5310,
8663,
6494,
6593,
1002,
5310,
1010,
1002,
19204,
1007,
1063,
1002,
2023,
1011,
1028,
9530,
2078,
1011,
1028,
2795,
1006,
1002,
2023,
1011,
1028,
2795,
1007,
1011,
1028,
2073,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Static.php | Zend_Cache_Backend_Static.setOption | public function setOption($name, $value)
{
if ($name == 'tag_cache') {
$this->setInnerCache($value);
} else {
parent::setOption($name, $value);
}
return $this;
} | php | public function setOption($name, $value)
{
if ($name == 'tag_cache') {
$this->setInnerCache($value);
} else {
parent::setOption($name, $value);
}
return $this;
} | [
"public",
"function",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"'tag_cache'",
")",
"{",
"$",
"this",
"->",
"setInnerCache",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"parent",
"::",
"setOption",
... | Interceptor child method to handle the case where an Inner
Cache object is being set since it's not supported by the
standard backend interface
@param string $name
@param mixed $value
@return Zend_Cache_Backend_Static | [
"Interceptor",
"child",
"method",
"to",
"handle",
"the",
"case",
"where",
"an",
"Inner",
"Cache",
"object",
"is",
"being",
"set",
"since",
"it",
"s",
"not",
"supported",
"by",
"the",
"standard",
"backend",
"interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Static.php#L83-L91 | train | Set the value of an option in the current context | [
30522,
2270,
3853,
2275,
7361,
3508,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
2171,
1027,
1027,
1005,
6415,
1035,
17053,
1005,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
23111,
2121,
3540,
5403,
1006,
1002,
3643,
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/Validation/Rules/DatabaseRule.php | DatabaseRule.where | public function where($column, $value = null)
{
if (is_array($value)) {
return $this->whereIn($column, $value);
}
if ($column instanceof Closure) {
return $this->using($column);
}
$this->wheres[] = compact('column', 'value');
return $this;
} | php | public function where($column, $value = null)
{
if (is_array($value)) {
return $this->whereIn($column, $value);
}
if ($column instanceof Closure) {
return $this->using($column);
}
$this->wheres[] = compact('column', 'value');
return $this;
} | [
"public",
"function",
"where",
"(",
"$",
"column",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"whereIn",
"(",
"$",
"column",
",",
"$",
"value",
")",
";",
"}",
... | Set a "where" constraint on the query.
@param string|\Closure $column
@param array|string|null $value
@return $this | [
"Set",
"a",
"where",
"constraint",
"on",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Rules/DatabaseRule.php#L57-L70 | train | Add where clause | [
30522,
2270,
3853,
2073,
1006,
1002,
5930,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
16726,
1006,
1002,
5930,
1010,
1002,
3643,
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... |
matomo-org/matomo | plugins/LanguagesManager/TranslationWriter/Filter/ByParameterCount.php | ByParameterCount._getParametersCountToReplace | protected function _getParametersCountToReplace($string)
{
$sprintfParameters = array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s', '%7$s', '%8$s', '%9$s');
$count = array();
foreach ($sprintfParameters as $parameter) {
$placeholderCount = substr_count($string, $parameter);
if ($placeholderCount > 0) {
$count[$parameter] = $placeholderCount;
}
}
return $count;
} | php | protected function _getParametersCountToReplace($string)
{
$sprintfParameters = array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s', '%7$s', '%8$s', '%9$s');
$count = array();
foreach ($sprintfParameters as $parameter) {
$placeholderCount = substr_count($string, $parameter);
if ($placeholderCount > 0) {
$count[$parameter] = $placeholderCount;
}
}
return $count;
} | [
"protected",
"function",
"_getParametersCountToReplace",
"(",
"$",
"string",
")",
"{",
"$",
"sprintfParameters",
"=",
"array",
"(",
"'%s'",
",",
"'%1$s'",
",",
"'%2$s'",
",",
"'%3$s'",
",",
"'%4$s'",
",",
"'%5$s'",
",",
"'%6$s'",
",",
"'%7$s'",
",",
"'%8$s'"... | Counts the placeholder parameters n given string
@param string $string
@return array | [
"Counts",
"the",
"placeholder",
"parameters",
"n",
"given",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/TranslationWriter/Filter/ByParameterCount.php#L71-L84 | train | Returns the number of parameters that should be replaced | [
30522,
5123,
3853,
1035,
2131,
28689,
22828,
9363,
16671,
19277,
24759,
10732,
1006,
1002,
5164,
1007,
1063,
1002,
9043,
22540,
5400,
22828,
2015,
1027,
9140,
1006,
1005,
1003,
1055,
1005,
1010,
1005,
1003,
1015,
1002,
1055,
1005,
1010,
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 | libs/Zend/Mail/Protocol/Imap.php | Zend_Mail_Protocol_Imap.listMailbox | public function listMailbox($reference = '', $mailbox = '*')
{
$result = array();
$list = $this->requestAndResponse('LIST', $this->escapeString($reference, $mailbox));
if (!$list || $list === true) {
return $result;
}
foreach ($list as $item) {
if (count($item) != 4 || $item[0] != 'LIST') {
continue;
}
$result[$item[3]] = array('delim' => $item[2], 'flags' => $item[1]);
}
return $result;
} | php | public function listMailbox($reference = '', $mailbox = '*')
{
$result = array();
$list = $this->requestAndResponse('LIST', $this->escapeString($reference, $mailbox));
if (!$list || $list === true) {
return $result;
}
foreach ($list as $item) {
if (count($item) != 4 || $item[0] != 'LIST') {
continue;
}
$result[$item[3]] = array('delim' => $item[2], 'flags' => $item[1]);
}
return $result;
} | [
"public",
"function",
"listMailbox",
"(",
"$",
"reference",
"=",
"''",
",",
"$",
"mailbox",
"=",
"'*'",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"list",
"=",
"$",
"this",
"->",
"requestAndResponse",
"(",
"'LIST'",
",",
"$",
"this",
... | get mailbox list
this method can't be named after the IMAP command 'LIST', as list is a reserved keyword
@param string $reference mailbox reference for list
@param string $mailbox mailbox name match with wildcards
@return array mailboxes that matched $mailbox as array(globalName => array('delim' => .., 'flags' => ..))
@throws Zend_Mail_Protocol_Exception | [
"get",
"mailbox",
"list"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L649-L665 | train | List all mailboxes | [
30522,
2270,
3853,
2862,
21397,
8758,
1006,
1002,
4431,
1027,
1005,
1005,
1010,
1002,
5653,
8758,
1027,
1005,
1008,
1005,
1007,
1063,
1002,
2765,
1027,
9140,
1006,
1007,
1025,
1002,
2862,
1027,
1002,
2023,
1011,
1028,
5227,
5685,
6072,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Folder/Maildir.php | Zend_Mail_Storage_Folder_Maildir.getFolders | public function getFolders($rootFolder = null)
{
if (!$rootFolder || $rootFolder == 'INBOX') {
return $this->_rootFolder;
}
// rootdir is same as INBOX in maildir
if (strpos($rootFolder, 'INBOX' . $this->_delim) === 0) {
$rootFolder = substr($rootFolder, 6);
}
$currentFolder = $this->_rootFolder;
$subname = trim($rootFolder, $this->_delim);
while ($currentFolder) {
@list($entry, $subname) = @explode($this->_delim, $subname, 2);
$currentFolder = $currentFolder->$entry;
if (!$subname) {
break;
}
}
if ($currentFolder->getGlobalName() != rtrim($rootFolder, $this->_delim)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("folder $rootFolder not found");
}
return $currentFolder;
} | php | public function getFolders($rootFolder = null)
{
if (!$rootFolder || $rootFolder == 'INBOX') {
return $this->_rootFolder;
}
// rootdir is same as INBOX in maildir
if (strpos($rootFolder, 'INBOX' . $this->_delim) === 0) {
$rootFolder = substr($rootFolder, 6);
}
$currentFolder = $this->_rootFolder;
$subname = trim($rootFolder, $this->_delim);
while ($currentFolder) {
@list($entry, $subname) = @explode($this->_delim, $subname, 2);
$currentFolder = $currentFolder->$entry;
if (!$subname) {
break;
}
}
if ($currentFolder->getGlobalName() != rtrim($rootFolder, $this->_delim)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("folder $rootFolder not found");
}
return $currentFolder;
} | [
"public",
"function",
"getFolders",
"(",
"$",
"rootFolder",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"rootFolder",
"||",
"$",
"rootFolder",
"==",
"'INBOX'",
")",
"{",
"return",
"$",
"this",
"->",
"_rootFolder",
";",
"}",
"// rootdir is same as INBOX in ma... | get root folder or given folder
@param string $rootFolder get folder structure for given folder, else root
@return Zend_Mail_Storage_Folder root or wanted folder
@throws Zend_Mail_Storage_Exception | [
"get",
"root",
"folder",
"or",
"given",
"folder"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Folder/Maildir.php#L187-L215 | train | get all folders in the folder | [
30522,
2270,
3853,
2131,
10371,
2545,
1006,
1002,
7117,
10371,
2121,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1002,
7117,
10371,
2121,
1064,
1064,
1002,
7117,
10371,
2121,
1027,
1027,
1005,
1999,
8758,
1005,
1007,
1063,
2709,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Visit/Factory.php | Factory.make | public static function make()
{
$visit = null;
/**
* Triggered before a new **visit tracking object** is created. Subscribers to this
* event can force the use of a custom visit tracking object that extends from
* {@link Piwik\Tracker\VisitInterface}.
*
* @param \Piwik\Tracker\VisitInterface &$visit Initialized to null, but can be set to
* a new visit object. If it isn't modified
* Piwik uses the default class.
*/
Piwik::postEvent('Tracker.makeNewVisitObject', array(&$visit));
if (!isset($visit)) {
$visit = new Visit();
} elseif (!($visit instanceof VisitInterface)) {
throw new Exception("The Visit object set in the plugin must implement VisitInterface");
}
return $visit;
} | php | public static function make()
{
$visit = null;
/**
* Triggered before a new **visit tracking object** is created. Subscribers to this
* event can force the use of a custom visit tracking object that extends from
* {@link Piwik\Tracker\VisitInterface}.
*
* @param \Piwik\Tracker\VisitInterface &$visit Initialized to null, but can be set to
* a new visit object. If it isn't modified
* Piwik uses the default class.
*/
Piwik::postEvent('Tracker.makeNewVisitObject', array(&$visit));
if (!isset($visit)) {
$visit = new Visit();
} elseif (!($visit instanceof VisitInterface)) {
throw new Exception("The Visit object set in the plugin must implement VisitInterface");
}
return $visit;
} | [
"public",
"static",
"function",
"make",
"(",
")",
"{",
"$",
"visit",
"=",
"null",
";",
"/**\n * Triggered before a new **visit tracking object** is created. Subscribers to this\n * event can force the use of a custom visit tracking object that extends from\n * {@link ... | Returns the Tracker_Visit object.
This method can be overwritten to use a different Tracker_Visit object
@throws Exception
@return \Piwik\Tracker\Visit | [
"Returns",
"the",
"Tracker_Visit",
"object",
".",
"This",
"method",
"can",
"be",
"overwritten",
"to",
"use",
"a",
"different",
"Tracker_Visit",
"object"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Visit/Factory.php#L25-L47 | train | Create a new visit tracking object | [
30522,
2270,
10763,
3853,
2191,
1006,
1007,
1063,
1002,
3942,
1027,
19701,
1025,
1013,
1008,
1008,
1008,
13330,
2077,
1037,
2047,
1008,
1008,
3942,
9651,
4874,
1008,
1008,
2003,
2580,
1012,
17073,
2000,
2023,
1008,
2724,
2064,
2486,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/API.php | API.getSitesWithAdminAccess | public function getSitesWithAdminAccess($fetchAliasUrls = false, $pattern = false, $limit = false)
{
$sitesId = $this->getSitesIdWithAdminAccess();
if ($pattern === false) {
$sites = $this->getSitesFromIds($sitesId, $limit);
} else {
$sites = $this->getModel()->getPatternMatchSites($sitesId, $pattern, $limit);
foreach ($sites as &$site) {
$this->enrichSite($site);
}
$sites = Site::setSitesFromArray($sites);
}
if ($fetchAliasUrls) {
foreach ($sites as &$site) {
$site['alias_urls'] = $this->getSiteUrlsFromId($site['idsite']);
}
}
return $sites;
} | php | public function getSitesWithAdminAccess($fetchAliasUrls = false, $pattern = false, $limit = false)
{
$sitesId = $this->getSitesIdWithAdminAccess();
if ($pattern === false) {
$sites = $this->getSitesFromIds($sitesId, $limit);
} else {
$sites = $this->getModel()->getPatternMatchSites($sitesId, $pattern, $limit);
foreach ($sites as &$site) {
$this->enrichSite($site);
}
$sites = Site::setSitesFromArray($sites);
}
if ($fetchAliasUrls) {
foreach ($sites as &$site) {
$site['alias_urls'] = $this->getSiteUrlsFromId($site['idsite']);
}
}
return $sites;
} | [
"public",
"function",
"getSitesWithAdminAccess",
"(",
"$",
"fetchAliasUrls",
"=",
"false",
",",
"$",
"pattern",
"=",
"false",
",",
"$",
"limit",
"=",
"false",
")",
"{",
"$",
"sitesId",
"=",
"$",
"this",
"->",
"getSitesIdWithAdminAccess",
"(",
")",
";",
"if... | Returns the list of websites with the 'admin' access for the current user.
For the superUser it returns all the websites in the database.
@param bool $fetchAliasUrls
@param false|string $pattern
@param false|int $limit
@return array for each site, an array of information (idsite, name, main_url, etc.) | [
"Returns",
"the",
"list",
"of",
"websites",
"with",
"the",
"admin",
"access",
"for",
"the",
"current",
"user",
".",
"For",
"the",
"superUser",
"it",
"returns",
"all",
"the",
"websites",
"in",
"the",
"database",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L345-L368 | train | Get all the sites with admin access | [
30522,
2270,
3853,
4152,
7616,
24415,
4215,
22311,
9468,
7971,
1006,
1002,
18584,
22786,
26210,
4877,
1027,
6270,
1010,
1002,
5418,
1027,
6270,
1010,
1002,
5787,
1027,
6270,
1007,
1063,
1002,
4573,
3593,
1027,
1002,
2023,
1011,
1028,
30524,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
barryvdh/laravel-debugbar | src/DataCollector/QueryCollector.php | QueryCollector.fileIsInExcludedPath | protected function fileIsInExcludedPath($file)
{
$excludedPaths = [
'/vendor/laravel/framework/src/Illuminate/Database',
'/vendor/laravel/framework/src/Illuminate/Events',
'/vendor/barryvdh/laravel-debugbar',
];
$normalizedPath = str_replace('\\', '/', $file);
foreach ($excludedPaths as $excludedPath) {
if (strpos($normalizedPath, $excludedPath) !== false) {
return true;
}
}
return false;
} | php | protected function fileIsInExcludedPath($file)
{
$excludedPaths = [
'/vendor/laravel/framework/src/Illuminate/Database',
'/vendor/laravel/framework/src/Illuminate/Events',
'/vendor/barryvdh/laravel-debugbar',
];
$normalizedPath = str_replace('\\', '/', $file);
foreach ($excludedPaths as $excludedPath) {
if (strpos($normalizedPath, $excludedPath) !== false) {
return true;
}
}
return false;
} | [
"protected",
"function",
"fileIsInExcludedPath",
"(",
"$",
"file",
")",
"{",
"$",
"excludedPaths",
"=",
"[",
"'/vendor/laravel/framework/src/Illuminate/Database'",
",",
"'/vendor/laravel/framework/src/Illuminate/Events'",
",",
"'/vendor/barryvdh/laravel-debugbar'",
",",
"]",
";... | Check if the given file is to be excluded from analysis
@param string $file
@return bool | [
"Check",
"if",
"the",
"given",
"file",
"is",
"to",
"be",
"excluded",
"from",
"analysis"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/QueryCollector.php#L273-L290 | train | Checks if a file is in the excluded path | [
30522,
5123,
3853,
5371,
17417,
2638,
2595,
20464,
13936,
15069,
1006,
1002,
5371,
1007,
1063,
1002,
12421,
15069,
2015,
1027,
1031,
1005,
1013,
21431,
1013,
13679,
15985,
1013,
7705,
1013,
5034,
2278,
1013,
5665,
12717,
12556,
1013,
7809,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineReceiver.php | DoctrineReceiver.getMessageCount | public function getMessageCount(): int
{
try {
return $this->connection->getMessageCount();
} catch (DBALException $exception) {
throw new TransportException($exception->getMessage(), 0, $exception);
}
} | php | public function getMessageCount(): int
{
try {
return $this->connection->getMessageCount();
} catch (DBALException $exception) {
throw new TransportException($exception->getMessage(), 0, $exception);
}
} | [
"public",
"function",
"getMessageCount",
"(",
")",
":",
"int",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"getMessageCount",
"(",
")",
";",
"}",
"catch",
"(",
"DBALException",
"$",
"exception",
")",
"{",
"throw",
"new",
"TransportExc... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineReceiver.php#L87-L94 | train | Get Message Count | [
30522,
2270,
3853,
2131,
7834,
3736,
3351,
3597,
16671,
1006,
1007,
1024,
20014,
1063,
3046,
1063,
2709,
1002,
2023,
1011,
1028,
4434,
1011,
1028,
2131,
7834,
3736,
3351,
3597,
16671,
1006,
1007,
1025,
1065,
4608,
1006,
16962,
9453,
2595,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Mbox.php | Zend_Mail_Storage_Mbox.getRawHeader | public function getRawHeader($id, $part = null, $topLines = 0)
{
if ($part !== null) {
// TODO: implement
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('not implemented');
}
$messagePos = $this->_getPos($id);
// TODO: toplines
return stream_get_contents($this->_fh, $messagePos['separator'] - $messagePos['start'], $messagePos['start']);
} | php | public function getRawHeader($id, $part = null, $topLines = 0)
{
if ($part !== null) {
// TODO: implement
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('not implemented');
}
$messagePos = $this->_getPos($id);
// TODO: toplines
return stream_get_contents($this->_fh, $messagePos['separator'] - $messagePos['start'], $messagePos['start']);
} | [
"public",
"function",
"getRawHeader",
"(",
"$",
"id",
",",
"$",
"part",
"=",
"null",
",",
"$",
"topLines",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"part",
"!==",
"null",
")",
"{",
"// TODO: implement",
"/**\n * @see Zend_Mail_Storage_Exception\n ... | /*
Get raw header of message or part
@param int $id number of message
@param null|array|string $part path to part or null for messsage header
@param int $topLines include this many lines with header (after an empty line)
@return string raw header
@throws Zend_Mail_Protocol_Exception
@throws Zend_Mail_Storage_Exception | [
"/",
"*",
"Get",
"raw",
"header",
"of",
"message",
"or",
"part"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Mbox.php#L176-L189 | train | Get raw header | [
30522,
2270,
3853,
2131,
2527,
2860,
4974,
2121,
1006,
1002,
8909,
1010,
1002,
2112,
1027,
19701,
1010,
1002,
2327,
12735,
1027,
1014,
1007,
1063,
2065,
1006,
1002,
2112,
999,
30524,
1025,
5466,
2047,
16729,
2094,
1035,
5653,
1035,
5527,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Console/Descriptor/Descriptor.php | Descriptor.getClassDescription | public static function getClassDescription(string $class, string &$resolvedClass = null): string
{
$resolvedClass = $class;
try {
$resource = new ClassExistenceResource($class, false);
// isFresh() will explode ONLY if a parent class/trait does not exist
$resource->isFresh(0);
$r = new \ReflectionClass($class);
$resolvedClass = $r->name;
if ($docComment = $r->getDocComment()) {
$docComment = preg_split('#\n\s*\*\s*[\n@]#', substr($docComment, 3, -2), 2)[0];
return trim(preg_replace('#\s*\n\s*\*\s*#', ' ', $docComment));
}
} catch (\ReflectionException $e) {
}
return '';
} | php | public static function getClassDescription(string $class, string &$resolvedClass = null): string
{
$resolvedClass = $class;
try {
$resource = new ClassExistenceResource($class, false);
// isFresh() will explode ONLY if a parent class/trait does not exist
$resource->isFresh(0);
$r = new \ReflectionClass($class);
$resolvedClass = $r->name;
if ($docComment = $r->getDocComment()) {
$docComment = preg_split('#\n\s*\*\s*[\n@]#', substr($docComment, 3, -2), 2)[0];
return trim(preg_replace('#\s*\n\s*\*\s*#', ' ', $docComment));
}
} catch (\ReflectionException $e) {
}
return '';
} | [
"public",
"static",
"function",
"getClassDescription",
"(",
"string",
"$",
"class",
",",
"string",
"&",
"$",
"resolvedClass",
"=",
"null",
")",
":",
"string",
"{",
"$",
"resolvedClass",
"=",
"$",
"class",
";",
"try",
"{",
"$",
"resource",
"=",
"new",
"Cl... | Gets class description from a docblock. | [
"Gets",
"class",
"description",
"from",
"a",
"docblock",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php#L300-L321 | train | Get the description of a class | [
30522,
2270,
10763,
3853,
2131,
26266,
6155,
23235,
3258,
1006,
5164,
1002,
2465,
1010,
5164,
1004,
1002,
10395,
26266,
1027,
19701,
1007,
1024,
5164,
1063,
1002,
30524,
7692,
1011,
1028,
2003,
19699,
9953,
1006,
1014,
1007,
1025,
1002,
105... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Model.php | Model.setSort | protected function setSort()
{
$this->sort = Input::get($this->sortName, []);
if (!is_array($this->sort)) {
return;
}
if (empty($this->sort['column']) || empty($this->sort['type'])) {
return;
}
if (Str::contains($this->sort['column'], '.')) {
$this->setRelationSort($this->sort['column']);
} else {
$this->resetOrderBy();
// get column. if contains "cast", set set column as cast
if (!empty($this->sort['cast'])) {
$column = "CAST({$this->sort['column']} AS {$this->sort['cast']}) {$this->sort['type']}";
$method = 'orderByRaw';
$arguments = [$column];
} else {
$column = $this->sort['column'];
$method = 'orderBy';
$arguments = [$column, $this->sort['type']];
}
$this->queries->push([
'method' => $method,
'arguments' => $arguments,
]);
}
} | php | protected function setSort()
{
$this->sort = Input::get($this->sortName, []);
if (!is_array($this->sort)) {
return;
}
if (empty($this->sort['column']) || empty($this->sort['type'])) {
return;
}
if (Str::contains($this->sort['column'], '.')) {
$this->setRelationSort($this->sort['column']);
} else {
$this->resetOrderBy();
// get column. if contains "cast", set set column as cast
if (!empty($this->sort['cast'])) {
$column = "CAST({$this->sort['column']} AS {$this->sort['cast']}) {$this->sort['type']}";
$method = 'orderByRaw';
$arguments = [$column];
} else {
$column = $this->sort['column'];
$method = 'orderBy';
$arguments = [$column, $this->sort['type']];
}
$this->queries->push([
'method' => $method,
'arguments' => $arguments,
]);
}
} | [
"protected",
"function",
"setSort",
"(",
")",
"{",
"$",
"this",
"->",
"sort",
"=",
"Input",
"::",
"get",
"(",
"$",
"this",
"->",
"sortName",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"sort",
")",
")",
"{",
"re... | Set the grid sort.
@return void | [
"Set",
"the",
"grid",
"sort",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Model.php#L511-L543 | train | Set sort by input | [
30522,
5123,
3853,
4520,
11589,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
4066,
1027,
7953,
1024,
1024,
2131,
1006,
1002,
2023,
1011,
1028,
4066,
18442,
1010,
1031,
1033,
1007,
1025,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php | EnumNodeDefinition.instantiateNode | protected function instantiateNode()
{
if (null === $this->values) {
throw new \RuntimeException('You must call ->values() on enum nodes.');
}
return new EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator);
} | php | protected function instantiateNode()
{
if (null === $this->values) {
throw new \RuntimeException('You must call ->values() on enum nodes.');
}
return new EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator);
} | [
"protected",
"function",
"instantiateNode",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"values",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You must call ->values() on enum nodes.'",
")",
";",
"}",
"return",
"new",
"EnumNode",
... | Instantiate a Node.
@return EnumNode The node
@throws \RuntimeException | [
"Instantiate",
"a",
"Node",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/Builder/EnumNodeDefinition.php#L48-L55 | train | Instantiates the node | [
30522,
5123,
3853,
7107,
13143,
3630,
3207,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
5300,
1007,
1063,
5466,
2047,
1032,
2448,
7292,
10288,
24422,
1006,
1005,
2017,
2442,
2655,
1011,
1028,
5300,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Context/ExecutionContext.php | ExecutionContext.setNode | public function setNode($value, $object, MetadataInterface $metadata = null, $propertyPath)
{
$this->value = $value;
$this->object = $object;
$this->metadata = $metadata;
$this->propertyPath = (string) $propertyPath;
} | php | public function setNode($value, $object, MetadataInterface $metadata = null, $propertyPath)
{
$this->value = $value;
$this->object = $object;
$this->metadata = $metadata;
$this->propertyPath = (string) $propertyPath;
} | [
"public",
"function",
"setNode",
"(",
"$",
"value",
",",
"$",
"object",
",",
"MetadataInterface",
"$",
"metadata",
"=",
"null",
",",
"$",
"propertyPath",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"object",
"=",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Context/ExecutionContext.php#L159-L165 | train | Set the node of the current page | [
30522,
2270,
3853,
2275,
3630,
3207,
1006,
1002,
3643,
1010,
1002,
4874,
1010,
27425,
18447,
2121,
12172,
1002,
27425,
1027,
19701,
1010,
1002,
3200,
15069,
1007,
1063,
1002,
2023,
1011,
1028,
3643,
1027,
1002,
3643,
1025,
1002,
2023,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Config/CompiledLanguages.php | CompiledLanguages.loadFile | protected function loadFile($name, $filename)
{
$file = CompiledYamlFile::instance($filename);
if (preg_match('|languages\.yaml$|', $filename)) {
$this->object->mergeRecursive((array) $file->content());
} else {
$this->object->mergeRecursive([$name => $file->content()]);
}
$file->free();
} | php | protected function loadFile($name, $filename)
{
$file = CompiledYamlFile::instance($filename);
if (preg_match('|languages\.yaml$|', $filename)) {
$this->object->mergeRecursive((array) $file->content());
} else {
$this->object->mergeRecursive([$name => $file->content()]);
}
$file->free();
} | [
"protected",
"function",
"loadFile",
"(",
"$",
"name",
",",
"$",
"filename",
")",
"{",
"$",
"file",
"=",
"CompiledYamlFile",
"::",
"instance",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"preg_match",
"(",
"'|languages\\.yaml$|'",
",",
"$",
"filename",
")",... | Load single configuration file and append it to the correct position.
@param string $name Name of the position.
@param string $filename File to be loaded. | [
"Load",
"single",
"configuration",
"file",
"and",
"append",
"it",
"to",
"the",
"correct",
"position",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Config/CompiledLanguages.php#L57-L66 | train | Load a language file into the object | [
30522,
5123,
3853,
7170,
8873,
2571,
1006,
1002,
2171,
1010,
1002,
5371,
18442,
1007,
1063,
1002,
5371,
1027,
9227,
14852,
10270,
9463,
1024,
1024,
6013,
1006,
1002,
5371,
18442,
1007,
1025,
2065,
1006,
3653,
2290,
1035,
2674,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Blueprint.php | Blueprint.mediumInteger | public function mediumInteger($column, $autoIncrement = false, $unsigned = false)
{
return $this->addColumn('mediumInteger', $column, compact('autoIncrement', 'unsigned'));
} | php | public function mediumInteger($column, $autoIncrement = false, $unsigned = false)
{
return $this->addColumn('mediumInteger', $column, compact('autoIncrement', 'unsigned'));
} | [
"public",
"function",
"mediumInteger",
"(",
"$",
"column",
",",
"$",
"autoIncrement",
"=",
"false",
",",
"$",
"unsigned",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"addColumn",
"(",
"'mediumInteger'",
",",
"$",
"column",
",",
"compact",
"(",
"... | Create a new medium integer (3-byte) column on the table.
@param string $column
@param bool $autoIncrement
@param bool $unsigned
@return \Illuminate\Database\Schema\ColumnDefinition | [
"Create",
"a",
"new",
"medium",
"integer",
"(",
"3",
"-",
"byte",
")",
"column",
"on",
"the",
"table",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Blueprint.php#L704-L707 | train | Add a medium integer column to the table | [
30522,
2270,
3853,
5396,
18447,
26320,
1006,
1002,
5930,
1010,
1002,
8285,
2378,
16748,
3672,
1027,
6270,
1010,
1002,
27121,
1027,
6270,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5587,
25778,
2819,
2078,
1006,
1005,
5396,
18447,
26320,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement.php | Zend_Db_Statement.setFetchMode | public function setFetchMode($mode)
{
switch ($mode) {
case Zend_Db::FETCH_NUM:
case Zend_Db::FETCH_ASSOC:
case Zend_Db::FETCH_BOTH:
case Zend_Db::FETCH_OBJ:
$this->_fetchMode = $mode;
break;
case Zend_Db::FETCH_BOUND:
default:
$this->closeCursor();
/**
* @see Zend_Db_Statement_Exception
*/
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception('invalid fetch mode');
break;
}
} | php | public function setFetchMode($mode)
{
switch ($mode) {
case Zend_Db::FETCH_NUM:
case Zend_Db::FETCH_ASSOC:
case Zend_Db::FETCH_BOTH:
case Zend_Db::FETCH_OBJ:
$this->_fetchMode = $mode;
break;
case Zend_Db::FETCH_BOUND:
default:
$this->closeCursor();
/**
* @see Zend_Db_Statement_Exception
*/
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception('invalid fetch mode');
break;
}
} | [
"public",
"function",
"setFetchMode",
"(",
"$",
"mode",
")",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"Zend_Db",
"::",
"FETCH_NUM",
":",
"case",
"Zend_Db",
"::",
"FETCH_ASSOC",
":",
"case",
"Zend_Db",
"::",
"FETCH_BOTH",
":",
"case",
"Zend_Db",
... | Set the default fetch mode for this statement.
@param int $mode The fetch mode.
@return bool
@throws Zend_Db_Statement_Exception | [
"Set",
"the",
"default",
"fetch",
"mode",
"for",
"this",
"statement",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement.php#L421-L440 | train | Set the fetch mode of the statement | [
30522,
2270,
3853,
2275,
7959,
10649,
5302,
3207,
1006,
1002,
5549,
1007,
1063,
6942,
1006,
1002,
5549,
1007,
1063,
2553,
16729,
2094,
1035,
16962,
1024,
1024,
18584,
1035,
16371,
2213,
1024,
2553,
16729,
2094,
1035,
16962,
1024,
1024,
1858... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Data/Validation.php | Validation.validateRequired | public static function validateRequired($value, $params)
{
if (is_scalar($value)) {
return (bool) $params !== true || $value !== '';
}
return (bool) $params !== true || !empty($value);
} | php | public static function validateRequired($value, $params)
{
if (is_scalar($value)) {
return (bool) $params !== true || $value !== '';
}
return (bool) $params !== true || !empty($value);
} | [
"public",
"static",
"function",
"validateRequired",
"(",
"$",
"value",
",",
"$",
"params",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"params",
"!==",
"true",
"||",
"$",
"value",
"!==",
"''",
... | HTML5 attributes (min, max and range are handled inside the types) | [
"HTML5",
"attributes",
"(",
"min",
"max",
"and",
"range",
"are",
"handled",
"inside",
"the",
"types",
")"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Validation.php#L707-L714 | train | Validate required value | [
30522,
2270,
10763,
3853,
9398,
24932,
2063,
15549,
5596,
1006,
1002,
3643,
1010,
1002,
11498,
5244,
1007,
1063,
2065,
1006,
2003,
1035,
26743,
2099,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
1006,
22017,
2140,
1007,
1002,
11498,
5244,
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... |
matomo-org/matomo | plugins/CoreUpdater/Commands/Update.php | Update.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->executeClearCaches();
$yes = $input->getOption('yes');
try {
$this->makeUpdate($input, $output, true);
if (!$yes) {
$yes = $this->askForUpdateConfirmation($input, $output);
}
if ($yes) {
$output->writeln("\n" . Piwik::translate('CoreUpdater_ConsoleStartingDbUpgrade'));
$this->makeUpdate($input, $output, false);
$this->writeSuccessMessage($output, array(Piwik::translate('CoreUpdater_PiwikHasBeenSuccessfullyUpgraded')));
} else {
$this->writeSuccessMessage($output, array(Piwik::translate('CoreUpdater_DbUpgradeNotExecuted')));
}
$this->writeAlertMessageWhenCommandExecutedWithUnexpectedUser($output);
} catch(NoUpdatesFoundException $e) {
// Do not fail if no updates were found
$this->writeSuccessMessage($output, array($e->getMessage()));
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->executeClearCaches();
$yes = $input->getOption('yes');
try {
$this->makeUpdate($input, $output, true);
if (!$yes) {
$yes = $this->askForUpdateConfirmation($input, $output);
}
if ($yes) {
$output->writeln("\n" . Piwik::translate('CoreUpdater_ConsoleStartingDbUpgrade'));
$this->makeUpdate($input, $output, false);
$this->writeSuccessMessage($output, array(Piwik::translate('CoreUpdater_PiwikHasBeenSuccessfullyUpgraded')));
} else {
$this->writeSuccessMessage($output, array(Piwik::translate('CoreUpdater_DbUpgradeNotExecuted')));
}
$this->writeAlertMessageWhenCommandExecutedWithUnexpectedUser($output);
} catch(NoUpdatesFoundException $e) {
// Do not fail if no updates were found
$this->writeSuccessMessage($output, array($e->getMessage()));
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"executeClearCaches",
"(",
")",
";",
"$",
"yes",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'yes'",
")",
";",
"t... | Execute command like: ./console core:update --yes | [
"Execute",
"command",
"like",
":",
".",
"/",
"console",
"core",
":",
"update",
"--",
"yes"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreUpdater/Commands/Update.php#L50-L80 | train | Executes the update command | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
2023,
1011,
1028,
15389,
14321,
2906,
3540,
8376,
1006,
1007,
1025,
1002,
2748,
1027,
1002,
7953,
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... |
overtrue/wechat | src/OfficialAccount/Card/Client.php | Client.getQrCode | public function getQrCode($ticket)
{
$baseUri = 'https://mp.weixin.qq.com/cgi-bin/showqrcode';
$params = [
'ticket' => $ticket,
];
$response = $this->requestRaw($baseUri, 'GET', $params);
return [
'status' => $response->getStatusCode(),
'reason' => $response->getReasonPhrase(),
'headers' => $response->getHeaders(),
'body' => strval($response->getBody()),
'url' => $baseUri.'?'.http_build_query($params),
];
} | php | public function getQrCode($ticket)
{
$baseUri = 'https://mp.weixin.qq.com/cgi-bin/showqrcode';
$params = [
'ticket' => $ticket,
];
$response = $this->requestRaw($baseUri, 'GET', $params);
return [
'status' => $response->getStatusCode(),
'reason' => $response->getReasonPhrase(),
'headers' => $response->getHeaders(),
'body' => strval($response->getBody()),
'url' => $baseUri.'?'.http_build_query($params),
];
} | [
"public",
"function",
"getQrCode",
"(",
"$",
"ticket",
")",
"{",
"$",
"baseUri",
"=",
"'https://mp.weixin.qq.com/cgi-bin/showqrcode'",
";",
"$",
"params",
"=",
"[",
"'ticket'",
"=>",
"$",
"ticket",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"r... | ticket 换取二维码图片.
@param string $ticket
@return array | [
"ticket",
"换取二维码图片",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Card/Client.php#L174-L190 | train | Get QrCode for ticket | [
30522,
2270,
3853,
2131,
4160,
29566,
3207,
1006,
1002,
7281,
1007,
1063,
1002,
2918,
9496,
1027,
1005,
16770,
1024,
1013,
1013,
6131,
1012,
11417,
20303,
1012,
1053,
4160,
1012,
4012,
1013,
1039,
5856,
1011,
8026,
1013,
2265,
4160,
29566,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/PlaceholderTokenParser.php | PlaceholderTokenParser.parse | public function parse(Twig_Token $token)
{
$stream = $this->parser->getStream();
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
$body = null;
$params = [];
if ($stream->test(Twig_Token::NAME_TYPE, 'default')) {
$stream->next();
$params = $this->loadParams($stream);
$body = $this->parser->subparse([$this, 'decidePlaceholderEnd'], true);
$stream->expect(Twig_Token::BLOCK_END_TYPE);
}
else {
$params = $this->loadParams($stream);
}
return new PlaceholderNode($name, $params, $body, $token->getLine(), $this->getTag());
} | php | public function parse(Twig_Token $token)
{
$stream = $this->parser->getStream();
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
$body = null;
$params = [];
if ($stream->test(Twig_Token::NAME_TYPE, 'default')) {
$stream->next();
$params = $this->loadParams($stream);
$body = $this->parser->subparse([$this, 'decidePlaceholderEnd'], true);
$stream->expect(Twig_Token::BLOCK_END_TYPE);
}
else {
$params = $this->loadParams($stream);
}
return new PlaceholderNode($name, $params, $body, $token->getLine(), $this->getTag());
} | [
"public",
"function",
"parse",
"(",
"Twig_Token",
"$",
"token",
")",
"{",
"$",
"stream",
"=",
"$",
"this",
"->",
"parser",
"->",
"getStream",
"(",
")",
";",
"$",
"name",
"=",
"$",
"stream",
"->",
"expect",
"(",
"Twig_Token",
"::",
"NAME_TYPE",
")",
"... | Parses a token and returns a node.
@param Twig_Token $token A Twig_Token instance
@return Twig_Node A Twig_Node instance | [
"Parses",
"a",
"token",
"and",
"returns",
"a",
"node",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/PlaceholderTokenParser.php#L30-L49 | train | Parses a placeholder token and returns a PlaceholderNode | [
30522,
2270,
3853,
11968,
3366,
1006,
1056,
16279,
1035,
19204,
1002,
19204,
1007,
1063,
1002,
5460,
1027,
1002,
2023,
1011,
1028,
11968,
8043,
1011,
1028,
4152,
25379,
1006,
1007,
1025,
1002,
2171,
1027,
1002,
5460,
1011,
1028,
5987,
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/Database/Eloquent/Collection.php | Collection.load | public function load($relations)
{
if ($this->isNotEmpty()) {
if (is_string($relations)) {
$relations = func_get_args();
}
$query = $this->first()->newQueryWithoutRelationships()->with($relations);
$this->items = $query->eagerLoadRelations($this->items);
}
return $this;
} | php | public function load($relations)
{
if ($this->isNotEmpty()) {
if (is_string($relations)) {
$relations = func_get_args();
}
$query = $this->first()->newQueryWithoutRelationships()->with($relations);
$this->items = $query->eagerLoadRelations($this->items);
}
return $this;
} | [
"public",
"function",
"load",
"(",
"$",
"relations",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNotEmpty",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"relations",
")",
")",
"{",
"$",
"relations",
"=",
"func_get_args",
"(",
")",
";",
"}",... | Load a set of relationships onto the collection.
@param array|string $relations
@return $this | [
"Load",
"a",
"set",
"of",
"relationships",
"onto",
"the",
"collection",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Collection.php#L51-L64 | train | Load relations from the collection | [
30522,
2270,
3853,
7170,
1006,
1002,
4262,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3475,
12184,
27718,
2100,
1006,
1007,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
4262,
1007,
1007,
1063,
1002,
4262,
1027,
30524,
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/Database/Eloquent/Concerns/HasAttributes.php | HasAttributes.syncOriginalAttributes | public function syncOriginalAttributes($attributes)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();
foreach ($attributes as $attribute) {
$this->original[$attribute] = $this->attributes[$attribute];
}
return $this;
} | php | public function syncOriginalAttributes($attributes)
{
$attributes = is_array($attributes) ? $attributes : func_get_args();
foreach ($attributes as $attribute) {
$this->original[$attribute] = $this->attributes[$attribute];
}
return $this;
} | [
"public",
"function",
"syncOriginalAttributes",
"(",
"$",
"attributes",
")",
"{",
"$",
"attributes",
"=",
"is_array",
"(",
"$",
"attributes",
")",
"?",
"$",
"attributes",
":",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"a... | Sync multiple original attribute with their current values.
@param array|string $attributes
@return $this | [
"Sync",
"multiple",
"original",
"attribute",
"with",
"their",
"current",
"values",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L1029-L1038 | train | Synchronize original attributes with the attributes of the current object | [
30522,
2270,
3853,
26351,
10050,
24965,
19321,
3089,
8569,
4570,
1006,
1002,
12332,
1007,
1063,
1002,
12332,
1027,
2003,
1035,
9140,
1006,
1002,
12332,
1007,
1029,
1002,
12332,
1024,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Layout/Row.php | Row.column | public function column($width, $content)
{
$width = $width < 1 ? round(12 * $width) : $width;
$column = new Column($content, $width);
$this->addColumn($column);
} | php | public function column($width, $content)
{
$width = $width < 1 ? round(12 * $width) : $width;
$column = new Column($content, $width);
$this->addColumn($column);
} | [
"public",
"function",
"column",
"(",
"$",
"width",
",",
"$",
"content",
")",
"{",
"$",
"width",
"=",
"$",
"width",
"<",
"1",
"?",
"round",
"(",
"12",
"*",
"$",
"width",
")",
":",
"$",
"width",
";",
"$",
"column",
"=",
"new",
"Column",
"(",
"$",... | Add a column.
@param int $width
@param $content | [
"Add",
"a",
"column",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Layout/Row.php#L39-L46 | train | Add a column to the header | [
30522,
2270,
3853,
5930,
1006,
1002,
9381,
1010,
1002,
4180,
1007,
1063,
1002,
9381,
1027,
1002,
9381,
1026,
1015,
1029,
2461,
1006,
2260,
1008,
1002,
9381,
1007,
1024,
1002,
9381,
1025,
1002,
5930,
1027,
2047,
5930,
1006,
1002,
4180,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php | DateTimeZoneNormalizer.denormalize | public function denormalize($data, $class, $format = null, array $context = [])
{
if ('' === $data || null === $data) {
throw new NotNormalizableValueException('The data is either an empty string or null, you should pass a string that can be parsed as a DateTimeZone.');
}
try {
return new \DateTimeZone($data);
} catch (\Exception $e) {
throw new NotNormalizableValueException($e->getMessage(), $e->getCode(), $e);
}
} | php | public function denormalize($data, $class, $format = null, array $context = [])
{
if ('' === $data || null === $data) {
throw new NotNormalizableValueException('The data is either an empty string or null, you should pass a string that can be parsed as a DateTimeZone.');
}
try {
return new \DateTimeZone($data);
} catch (\Exception $e) {
throw new NotNormalizableValueException($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"denormalize",
"(",
"$",
"data",
",",
"$",
"class",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"data",
"||",
"null",
"===",
"$",
"data",
")",
"{",
"... | {@inheritdoc}
@throws NotNormalizableValueException | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/DateTimeZoneNormalizer.php#L51-L62 | train | Denormalizes a string into a DateTimeZone | [
30522,
2270,
3853,
30524,
1007,
1063,
5466,
2047,
2025,
12131,
9067,
21335,
3468,
10175,
5657,
10288,
24422,
1006,
1005,
1996,
2951,
2003,
2593,
2019,
4064,
5164,
2030,
19701,
1010,
2017,
2323,
3413,
1037,
5164,
2008,
2064,
2022,
11968,
692... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php | ChoiceFormField.initialize | protected function initialize()
{
if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) {
throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName));
}
if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) {
throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type')));
}
$this->value = null;
$this->options = [];
$this->multiple = false;
if ('input' == $this->node->nodeName) {
$this->type = strtolower($this->node->getAttribute('type'));
$optionValue = $this->buildOptionValue($this->node);
$this->options[] = $optionValue;
if ($this->node->hasAttribute('checked')) {
$this->value = $optionValue['value'];
}
} else {
$this->type = 'select';
if ($this->node->hasAttribute('multiple')) {
$this->multiple = true;
$this->value = [];
$this->name = str_replace('[]', '', $this->name);
}
$found = false;
foreach ($this->xpath->query('descendant::option', $this->node) as $option) {
$optionValue = $this->buildOptionValue($option);
$this->options[] = $optionValue;
if ($option->hasAttribute('selected')) {
$found = true;
if ($this->multiple) {
$this->value[] = $optionValue['value'];
} else {
$this->value = $optionValue['value'];
}
}
}
// if no option is selected and if it is a simple select box, take the first option as the value
if (!$found && !$this->multiple && !empty($this->options)) {
$this->value = $this->options[0]['value'];
}
}
} | php | protected function initialize()
{
if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) {
throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName));
}
if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) {
throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type')));
}
$this->value = null;
$this->options = [];
$this->multiple = false;
if ('input' == $this->node->nodeName) {
$this->type = strtolower($this->node->getAttribute('type'));
$optionValue = $this->buildOptionValue($this->node);
$this->options[] = $optionValue;
if ($this->node->hasAttribute('checked')) {
$this->value = $optionValue['value'];
}
} else {
$this->type = 'select';
if ($this->node->hasAttribute('multiple')) {
$this->multiple = true;
$this->value = [];
$this->name = str_replace('[]', '', $this->name);
}
$found = false;
foreach ($this->xpath->query('descendant::option', $this->node) as $option) {
$optionValue = $this->buildOptionValue($option);
$this->options[] = $optionValue;
if ($option->hasAttribute('selected')) {
$found = true;
if ($this->multiple) {
$this->value[] = $optionValue['value'];
} else {
$this->value = $optionValue['value'];
}
}
}
// if no option is selected and if it is a simple select box, take the first option as the value
if (!$found && !$this->multiple && !empty($this->options)) {
$this->value = $this->options[0]['value'];
}
}
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"'input'",
"!==",
"$",
"this",
"->",
"node",
"->",
"nodeName",
"&&",
"'select'",
"!==",
"$",
"this",
"->",
"node",
"->",
"nodeName",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
... | Initializes the form field.
@throws \LogicException When node type is incorrect | [
"Initializes",
"the",
"form",
"field",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php#L203-L253 | train | Initializes the field from the given node | [
30522,
5123,
3853,
3988,
4697,
1006,
1007,
1063,
2065,
1006,
1005,
7953,
1005,
999,
1027,
1027,
1002,
2023,
1011,
1028,
13045,
1011,
1028,
13045,
18442,
1004,
1004,
1005,
7276,
1005,
999,
1027,
1027,
1002,
2023,
1011,
1028,
13045,
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/Filesystem/Filesystem.php | Filesystem.makePathRelative | public function makePathRelative($endPath, $startPath)
{
if (!$this->isAbsolutePath($startPath)) {
throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath));
}
if (!$this->isAbsolutePath($endPath)) {
throw new InvalidArgumentException(sprintf('The end path "%s" is not absolute.', $endPath));
}
// Normalize separators on Windows
if ('\\' === \DIRECTORY_SEPARATOR) {
$endPath = str_replace('\\', '/', $endPath);
$startPath = str_replace('\\', '/', $startPath);
}
$stripDriveLetter = function ($path) {
if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
return substr($path, 2);
}
return $path;
};
$endPath = $stripDriveLetter($endPath);
$startPath = $stripDriveLetter($startPath);
// Split the paths into arrays
$startPathArr = explode('/', trim($startPath, '/'));
$endPathArr = explode('/', trim($endPath, '/'));
$normalizePathArray = function ($pathSegments) {
$result = [];
foreach ($pathSegments as $segment) {
if ('..' === $segment) {
array_pop($result);
} elseif ('.' !== $segment) {
$result[] = $segment;
}
}
return $result;
};
$startPathArr = $normalizePathArray($startPathArr);
$endPathArr = $normalizePathArray($endPathArr);
// Find for which directory the common path stops
$index = 0;
while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
++$index;
}
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
$depth = 0;
} else {
$depth = \count($startPathArr) - $index;
}
// Repeated "../" for each level need to reach the common path
$traverser = str_repeat('../', $depth);
$endPathRemainder = implode('/', \array_slice($endPathArr, $index));
// Construct $endPath from traversing to the common path, then to the remaining $endPath
$relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
return '' === $relativePath ? './' : $relativePath;
} | php | public function makePathRelative($endPath, $startPath)
{
if (!$this->isAbsolutePath($startPath)) {
throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath));
}
if (!$this->isAbsolutePath($endPath)) {
throw new InvalidArgumentException(sprintf('The end path "%s" is not absolute.', $endPath));
}
// Normalize separators on Windows
if ('\\' === \DIRECTORY_SEPARATOR) {
$endPath = str_replace('\\', '/', $endPath);
$startPath = str_replace('\\', '/', $startPath);
}
$stripDriveLetter = function ($path) {
if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
return substr($path, 2);
}
return $path;
};
$endPath = $stripDriveLetter($endPath);
$startPath = $stripDriveLetter($startPath);
// Split the paths into arrays
$startPathArr = explode('/', trim($startPath, '/'));
$endPathArr = explode('/', trim($endPath, '/'));
$normalizePathArray = function ($pathSegments) {
$result = [];
foreach ($pathSegments as $segment) {
if ('..' === $segment) {
array_pop($result);
} elseif ('.' !== $segment) {
$result[] = $segment;
}
}
return $result;
};
$startPathArr = $normalizePathArray($startPathArr);
$endPathArr = $normalizePathArray($endPathArr);
// Find for which directory the common path stops
$index = 0;
while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
++$index;
}
// Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels)
if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
$depth = 0;
} else {
$depth = \count($startPathArr) - $index;
}
// Repeated "../" for each level need to reach the common path
$traverser = str_repeat('../', $depth);
$endPathRemainder = implode('/', \array_slice($endPathArr, $index));
// Construct $endPath from traversing to the common path, then to the remaining $endPath
$relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
return '' === $relativePath ? './' : $relativePath;
} | [
"public",
"function",
"makePathRelative",
"(",
"$",
"endPath",
",",
"$",
"startPath",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isAbsolutePath",
"(",
"$",
"startPath",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Th... | Given an existing path, convert it to a path relative to a given starting path.
@param string $endPath Absolute path of target
@param string $startPath Absolute path where traversal begins
@return string Path of target relative to starting path | [
"Given",
"an",
"existing",
"path",
"convert",
"it",
"to",
"a",
"path",
"relative",
"to",
"a",
"given",
"starting",
"path",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Filesystem/Filesystem.php#L447-L517 | train | Makes the path relative to the common path | [
30522,
2270,
3853,
2191,
15069,
16570,
8082,
1006,
1002,
2203,
15069,
1010,
1002,
2707,
15069,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
18061,
5910,
4747,
10421,
15069,
1006,
1002,
2707,
15069,
1007,
1007,
1063,
5466,
2047,
1952... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SEO/API.php | API.getRank | public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$metricProvider = new ProviderCache(new Aggregator());
$domain = Url::getHostFromUrl($url);
$metrics = $metricProvider->getMetrics($domain);
return $this->toDataTable($metrics);
} | php | public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$metricProvider = new ProviderCache(new Aggregator());
$domain = Url::getHostFromUrl($url);
$metrics = $metricProvider->getMetrics($domain);
return $this->toDataTable($metrics);
} | [
"public",
"function",
"getRank",
"(",
"$",
"url",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeViewAccess",
"(",
")",
";",
"$",
"metricProvider",
"=",
"new",
"ProviderCache",
"(",
"new",
"Aggregator",
"(",
")",
")",
";",
"$",
"domain",
"=",
"Url",
"::",
"ge... | Returns SEO statistics for a URL.
@param string $url URL to request SEO stats for
@return DataTable | [
"Returns",
"SEO",
"statistics",
"for",
"a",
"URL",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SEO/API.php#L38-L47 | train | Returns the rank of the domain. | [
30522,
2270,
3853,
2131,
26763,
1006,
1002,
24471,
2140,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
8584,
6305,
9623,
2015,
1006,
1007,
1025,
1002,
12046,
21572,
17258,
2121,
1027,
2047,
10802,
3540,
5403,
1006,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserId/Archiver.php | Archiver.aggregateUsers | protected function aggregateUsers()
{
$userIdFieldName = self::USER_ID_FIELD;
$visitorIdFieldName = self::VISITOR_ID_FIELD;
/** @var \Zend_Db_Statement $query */
$query = $this->getLogAggregator()->queryVisitsByDimension(
array(self::USER_ID_FIELD),
"log_visit.$userIdFieldName IS NOT NULL AND log_visit.$userIdFieldName != ''",
array("LOWER(HEX($visitorIdFieldName)) as $visitorIdFieldName")
);
if ($query === false) {
return;
}
$rowsCount = 0;
while ($row = $query->fetch()) {
$rowsCount++;
$this->arrays->sumMetricsVisits($row[$userIdFieldName], $row);
$this->rememberVisitorId($row);
}
} | php | protected function aggregateUsers()
{
$userIdFieldName = self::USER_ID_FIELD;
$visitorIdFieldName = self::VISITOR_ID_FIELD;
/** @var \Zend_Db_Statement $query */
$query = $this->getLogAggregator()->queryVisitsByDimension(
array(self::USER_ID_FIELD),
"log_visit.$userIdFieldName IS NOT NULL AND log_visit.$userIdFieldName != ''",
array("LOWER(HEX($visitorIdFieldName)) as $visitorIdFieldName")
);
if ($query === false) {
return;
}
$rowsCount = 0;
while ($row = $query->fetch()) {
$rowsCount++;
$this->arrays->sumMetricsVisits($row[$userIdFieldName], $row);
$this->rememberVisitorId($row);
}
} | [
"protected",
"function",
"aggregateUsers",
"(",
")",
"{",
"$",
"userIdFieldName",
"=",
"self",
"::",
"USER_ID_FIELD",
";",
"$",
"visitorIdFieldName",
"=",
"self",
"::",
"VISITOR_ID_FIELD",
";",
"/** @var \\Zend_Db_Statement $query */",
"$",
"query",
"=",
"$",
"this"... | Used to aggregate daily data per user ID | [
"Used",
"to",
"aggregate",
"daily",
"data",
"per",
"user",
"ID"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserId/Archiver.php#L75-L97 | train | Aggregate visits by dimension | [
30522,
5123,
3853,
9572,
20330,
2015,
1006,
1007,
1063,
1002,
5310,
3593,
3790,
18442,
1027,
2969,
1024,
1024,
5310,
1035,
8909,
1035,
2492,
1025,
1002,
10367,
3593,
3790,
18442,
1027,
2969,
1024,
1024,
10367,
1035,
8909,
1035,
2492,
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... |
overtrue/wechat | src/Payment/Transfer/Client.php | Client.queryBalanceOrder | public function queryBalanceOrder(string $partnerTradeNo)
{
$params = [
'appid' => $this->app['config']->app_id,
'mch_id' => $this->app['config']->mch_id,
'partner_trade_no' => $partnerTradeNo,
];
return $this->safeRequest('mmpaymkttransfers/gettransferinfo', $params);
} | php | public function queryBalanceOrder(string $partnerTradeNo)
{
$params = [
'appid' => $this->app['config']->app_id,
'mch_id' => $this->app['config']->mch_id,
'partner_trade_no' => $partnerTradeNo,
];
return $this->safeRequest('mmpaymkttransfers/gettransferinfo', $params);
} | [
"public",
"function",
"queryBalanceOrder",
"(",
"string",
"$",
"partnerTradeNo",
")",
"{",
"$",
"params",
"=",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"app_id",
",",
"'mch_id'",
"=>",
"$",
"this",
"->",
"app",
"[",
"... | Query MerchantPay to balance.
@param string $partnerTradeNo
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Query",
"MerchantPay",
"to",
"balance",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Transfer/Client.php#L35-L44 | train | Query Balance Order | [
30522,
2270,
3853,
23032,
26657,
8551,
2121,
1006,
5164,
1002,
4256,
6494,
4181,
2080,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
10439,
3593,
1005,
1027,
1028,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
9530,
8873,
2290,
1005,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Core/User/UserChecker.php | UserChecker.checkPostAuth | public function checkPostAuth(UserInterface $user)
{
if (!$user instanceof AdvancedUserInterface && !$user instanceof User) {
return;
}
if ($user instanceof AdvancedUserInterface && !$user instanceof User) {
@trigger_error(sprintf('Calling "%s()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.', __METHOD__), E_USER_DEPRECATED);
}
if (!$user->isCredentialsNonExpired()) {
$ex = new CredentialsExpiredException('User credentials have expired.');
$ex->setUser($user);
throw $ex;
}
} | php | public function checkPostAuth(UserInterface $user)
{
if (!$user instanceof AdvancedUserInterface && !$user instanceof User) {
return;
}
if ($user instanceof AdvancedUserInterface && !$user instanceof User) {
@trigger_error(sprintf('Calling "%s()" with an AdvancedUserInterface is deprecated since Symfony 4.1. Create a custom user checker if you wish to keep this functionality.', __METHOD__), E_USER_DEPRECATED);
}
if (!$user->isCredentialsNonExpired()) {
$ex = new CredentialsExpiredException('User credentials have expired.');
$ex->setUser($user);
throw $ex;
}
} | [
"public",
"function",
"checkPostAuth",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"$",
"user",
"instanceof",
"AdvancedUserInterface",
"&&",
"!",
"$",
"user",
"instanceof",
"User",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"user",
"i... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/User/UserChecker.php#L61-L76 | train | Check post auth | [
30522,
2270,
3853,
4638,
19894,
4887,
2705,
1006,
5310,
18447,
2121,
12172,
1002,
5310,
1007,
1063,
2065,
1006,
999,
1002,
5310,
6013,
11253,
3935,
20330,
18447,
30524,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
4214,
1000,
1003,
1055,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.init | public function init(\SplFileInfo $file, $extension = null)
{
$config = Grav::instance()['config'];
// some extension logic
if (empty($extension)) {
$this->extension('.' . $file->getExtension());
} else {
$this->extension($extension);
}
// extract page language from page extension
$language = trim(basename($this->extension(), 'md'), '.') ?: null;
$this->language($language);
$this->hide_home_route = $config->get('system.home.hide_in_urls', false);
$this->home_route = $this->adjustRouteCase($config->get('system.home.alias'));
$this->filePath($file->getPathname());
$this->modified($file->getMTime());
$this->id($this->modified() . md5($this->filePath()));
$this->routable(true);
$this->header();
$this->date();
$this->metadata();
$this->url();
$this->visible();
$this->modularTwig(strpos($this->slug(), '_') === 0);
$this->setPublishState();
$this->published();
$this->urlExtension();
return $this;
} | php | public function init(\SplFileInfo $file, $extension = null)
{
$config = Grav::instance()['config'];
// some extension logic
if (empty($extension)) {
$this->extension('.' . $file->getExtension());
} else {
$this->extension($extension);
}
// extract page language from page extension
$language = trim(basename($this->extension(), 'md'), '.') ?: null;
$this->language($language);
$this->hide_home_route = $config->get('system.home.hide_in_urls', false);
$this->home_route = $this->adjustRouteCase($config->get('system.home.alias'));
$this->filePath($file->getPathname());
$this->modified($file->getMTime());
$this->id($this->modified() . md5($this->filePath()));
$this->routable(true);
$this->header();
$this->date();
$this->metadata();
$this->url();
$this->visible();
$this->modularTwig(strpos($this->slug(), '_') === 0);
$this->setPublishState();
$this->published();
$this->urlExtension();
return $this;
} | [
"public",
"function",
"init",
"(",
"\\",
"SplFileInfo",
"$",
"file",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"Grav",
"::",
"instance",
"(",
")",
"[",
"'config'",
"]",
";",
"// some extension logic",
"if",
"(",
"empty",
"(",
"$... | Initializes the page instance variables based on a file
@param \SplFileInfo $file The file information for the .md file that the page represents
@param string $extension
@return $this | [
"Initializes",
"the",
"page",
"instance",
"variables",
"based",
"on",
"a",
"file"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L130-L163 | train | Initializes the page object | [
30522,
2270,
3853,
1999,
4183,
1006,
1032,
11867,
10270,
9463,
2378,
14876,
1002,
5371,
1010,
1002,
5331,
1027,
19701,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1031,
1005,
9530,
8873,
2290,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/RouteCacheCommand.php | RouteCacheCommand.getFreshApplication | protected function getFreshApplication()
{
return tap(require $this->laravel->bootstrapPath().'/app.php', function ($app) {
$app->make(ConsoleKernelContract::class)->bootstrap();
});
} | php | protected function getFreshApplication()
{
return tap(require $this->laravel->bootstrapPath().'/app.php', function ($app) {
$app->make(ConsoleKernelContract::class)->bootstrap();
});
} | [
"protected",
"function",
"getFreshApplication",
"(",
")",
"{",
"return",
"tap",
"(",
"require",
"$",
"this",
"->",
"laravel",
"->",
"bootstrapPath",
"(",
")",
".",
"'/app.php'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"make",
"(",
... | Get a fresh application instance.
@return \Illuminate\Contracts\Foundation\Application | [
"Get",
"a",
"fresh",
"application",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/RouteCacheCommand.php#L90-L95 | train | Get fresh application. | [
30522,
5123,
3853,
2131,
19699,
9953,
29098,
19341,
3508,
1006,
1007,
1063,
2709,
11112,
1006,
5478,
1002,
2023,
1011,
1028,
13679,
15985,
1011,
1028,
6879,
6494,
13944,
2705,
1006,
1007,
1012,
1005,
1013,
10439,
1012,
25718,
1005,
1010,
38... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php | PropertyNormalizer.getAttributeValue | protected function getAttributeValue($object, $attribute, $format = null, array $context = [])
{
try {
$reflectionProperty = $this->getReflectionProperty($object, $attribute);
} catch (\ReflectionException $reflectionException) {
return;
}
// Override visibility
if (!$reflectionProperty->isPublic()) {
$reflectionProperty->setAccessible(true);
}
return $reflectionProperty->getValue($object);
} | php | protected function getAttributeValue($object, $attribute, $format = null, array $context = [])
{
try {
$reflectionProperty = $this->getReflectionProperty($object, $attribute);
} catch (\ReflectionException $reflectionException) {
return;
}
// Override visibility
if (!$reflectionProperty->isPublic()) {
$reflectionProperty->setAccessible(true);
}
return $reflectionProperty->getValue($object);
} | [
"protected",
"function",
"getAttributeValue",
"(",
"$",
"object",
",",
"$",
"attribute",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"reflectionProperty",
"=",
"$",
"this",
"->",
"getReflection... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php#L121-L135 | train | Get the value of an attribute from an object | [
30522,
5123,
3853,
2131,
19321,
3089,
8569,
2618,
10175,
5657,
1006,
1002,
4874,
1010,
1002,
17961,
1010,
1002,
4289,
1027,
19701,
1010,
30524,
24422,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
2058,
15637,
16476,
2065,
1006,
999,
1002,
9185... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/FlexCollection.php | FlexCollection.getCachedMethods | public static function getCachedMethods(): array
{
return [
'getTypePrefix' => true,
'getType' => true,
'getFlexDirectory' => true,
'getCacheKey' => true,
'getCacheChecksum' => true,
'getTimestamp' => true,
'hasProperty' => true,
'getProperty' => true,
'hasNestedProperty' => true,
'getNestedProperty' => true,
'orderBy' => true,
'render' => false,
'isAuthorized' => 'session',
'search' => true,
'sort' => true,
];
} | php | public static function getCachedMethods(): array
{
return [
'getTypePrefix' => true,
'getType' => true,
'getFlexDirectory' => true,
'getCacheKey' => true,
'getCacheChecksum' => true,
'getTimestamp' => true,
'hasProperty' => true,
'getProperty' => true,
'hasNestedProperty' => true,
'getNestedProperty' => true,
'orderBy' => true,
'render' => false,
'isAuthorized' => 'session',
'search' => true,
'sort' => true,
];
} | [
"public",
"static",
"function",
"getCachedMethods",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'getTypePrefix'",
"=>",
"true",
",",
"'getType'",
"=>",
"true",
",",
"'getFlexDirectory'",
"=>",
"true",
",",
"'getCacheKey'",
"=>",
"true",
",",
"'getCacheChecksum'... | Get list of cached methods.
@return array Returns a list of methods with their caching information. | [
"Get",
"list",
"of",
"cached",
"methods",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/FlexCollection.php#L47-L67 | train | Get all cached methods | [
30522,
2270,
10763,
3853,
2131,
3540,
7690,
11368,
6806,
5104,
1006,
1007,
1024,
9140,
1063,
2709,
1031,
1005,
2131,
13874,
28139,
8873,
2595,
1005,
1027,
1028,
2995,
1010,
1005,
2131,
13874,
1005,
1027,
1028,
2995,
1010,
1005,
2131,
21031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Repeater.php | Repeater.processExistingItems | protected function processExistingItems()
{
$loadedIndexes = $loadedGroups = [];
$loadValue = $this->getLoadValue();
// Ensure that the minimum number of items are preinitialized
// ONLY DONE WHEN NOT IN GROUP MODE
if (!$this->useGroups && $this->minItems > 0) {
if (!is_array($loadValue)) {
$loadValue = [];
for ($i = 0; $i < $this->minItems; $i++) {
$loadValue[$i] = [];
}
} elseif (count($loadValue) < $this->minItems) {
for ($i = 0; $i < ($this->minItems - count($loadValue)); $i++) {
$loadValue[] = [];
}
}
}
if (is_array($loadValue)) {
foreach ($loadValue as $index => $loadedValue) {
$loadedIndexes[] = $index;
$loadedGroups[] = array_get($loadedValue, '_group');
}
}
$itemIndexes = post($this->indexInputName, $loadedIndexes);
$itemGroups = post($this->groupInputName, $loadedGroups);
if (!count($itemIndexes)) {
return;
}
$items = array_combine(
(array) $itemIndexes,
(array) ($this->useGroups ? $itemGroups : $itemIndexes)
);
foreach ($items as $itemIndex => $groupCode) {
$this->makeItemFormWidget($itemIndex, $groupCode);
$this->indexCount = max((int) $itemIndex, $this->indexCount);
}
} | php | protected function processExistingItems()
{
$loadedIndexes = $loadedGroups = [];
$loadValue = $this->getLoadValue();
// Ensure that the minimum number of items are preinitialized
// ONLY DONE WHEN NOT IN GROUP MODE
if (!$this->useGroups && $this->minItems > 0) {
if (!is_array($loadValue)) {
$loadValue = [];
for ($i = 0; $i < $this->minItems; $i++) {
$loadValue[$i] = [];
}
} elseif (count($loadValue) < $this->minItems) {
for ($i = 0; $i < ($this->minItems - count($loadValue)); $i++) {
$loadValue[] = [];
}
}
}
if (is_array($loadValue)) {
foreach ($loadValue as $index => $loadedValue) {
$loadedIndexes[] = $index;
$loadedGroups[] = array_get($loadedValue, '_group');
}
}
$itemIndexes = post($this->indexInputName, $loadedIndexes);
$itemGroups = post($this->groupInputName, $loadedGroups);
if (!count($itemIndexes)) {
return;
}
$items = array_combine(
(array) $itemIndexes,
(array) ($this->useGroups ? $itemGroups : $itemIndexes)
);
foreach ($items as $itemIndex => $groupCode) {
$this->makeItemFormWidget($itemIndex, $groupCode);
$this->indexCount = max((int) $itemIndex, $this->indexCount);
}
} | [
"protected",
"function",
"processExistingItems",
"(",
")",
"{",
"$",
"loadedIndexes",
"=",
"$",
"loadedGroups",
"=",
"[",
"]",
";",
"$",
"loadValue",
"=",
"$",
"this",
"->",
"getLoadValue",
"(",
")",
";",
"// Ensure that the minimum number of items are preinitialize... | Processes existing form data and applies it to the form widgets.
@return void | [
"Processes",
"existing",
"form",
"data",
"and",
"applies",
"it",
"to",
"the",
"form",
"widgets",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/Repeater.php#L208-L251 | train | Processes existing items | [
30522,
5123,
3853,
2832,
10288,
2923,
2075,
4221,
5244,
1006,
1007,
1063,
1002,
8209,
22254,
10288,
2229,
1027,
1002,
8209,
17058,
2015,
1027,
1031,
1033,
1025,
1002,
7170,
10175,
5657,
1027,
1002,
2023,
1011,
1028,
2131,
11066,
10175,
5657... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter/Like.php | Like.condition | public function condition($inputs)
{
$value = Arr::get($inputs, $this->column);
if (is_array($value)) {
$value = array_filter($value);
}
if (is_null($value) || empty($value)) {
return;
}
$this->value = $value;
$expr = str_replace('{value}', $this->value, $this->exprFormat);
return $this->buildCondition($this->column, $this->operator, $expr);
} | php | public function condition($inputs)
{
$value = Arr::get($inputs, $this->column);
if (is_array($value)) {
$value = array_filter($value);
}
if (is_null($value) || empty($value)) {
return;
}
$this->value = $value;
$expr = str_replace('{value}', $this->value, $this->exprFormat);
return $this->buildCondition($this->column, $this->operator, $expr);
} | [
"public",
"function",
"condition",
"(",
"$",
"inputs",
")",
"{",
"$",
"value",
"=",
"Arr",
"::",
"get",
"(",
"$",
"inputs",
",",
"$",
"this",
"->",
"column",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
... | Get condition of this filter.
@param array $inputs
@return array|mixed|void | [
"Get",
"condition",
"of",
"this",
"filter",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/Like.php#L26-L43 | train | Return the condition for the given input array. | [
30522,
2270,
3853,
4650,
1006,
1002,
20407,
1007,
1063,
1002,
3643,
1027,
12098,
2099,
1024,
1024,
2131,
1006,
1002,
20407,
1010,
1002,
2023,
1011,
1028,
5930,
1007,
1025,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
3643,
1007,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Finder/Finder.php | Finder.ignoreVCS | public function ignoreVCS($ignoreVCS)
{
if ($ignoreVCS) {
$this->ignore |= static::IGNORE_VCS_FILES;
} else {
$this->ignore &= ~static::IGNORE_VCS_FILES;
}
return $this;
} | php | public function ignoreVCS($ignoreVCS)
{
if ($ignoreVCS) {
$this->ignore |= static::IGNORE_VCS_FILES;
} else {
$this->ignore &= ~static::IGNORE_VCS_FILES;
}
return $this;
} | [
"public",
"function",
"ignoreVCS",
"(",
"$",
"ignoreVCS",
")",
"{",
"if",
"(",
"$",
"ignoreVCS",
")",
"{",
"$",
"this",
"->",
"ignore",
"|=",
"static",
"::",
"IGNORE_VCS_FILES",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ignore",
"&=",
"~",
"static",
... | Forces the finder to ignore version control directories.
This option is enabled by default.
@param bool $ignoreVCS Whether to exclude VCS files or not
@return $this
@see ExcludeDirectoryFilterIterator | [
"Forces",
"the",
"finder",
"to",
"ignore",
"version",
"control",
"directories",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Finder/Finder.php#L367-L376 | train | ignoreVCS - Set flag to ignore all VCS files | [
30522,
2270,
3853,
8568,
25465,
2015,
1006,
1002,
8568,
25465,
2015,
1007,
1063,
2065,
1006,
1002,
8568,
25465,
2015,
1007,
1063,
1002,
2023,
1011,
1028,
8568,
1064,
1027,
10763,
1024,
1024,
8568,
1035,
18315,
2015,
1035,
6764,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/UrlHelper.php | UrlHelper.getLossyUrl | public static function getLossyUrl($url)
{
static $countries;
if (!isset($countries)) {
/** @var RegionDataProvider $regionDataProvider */
$regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$countries = implode('|', array_keys($regionDataProvider->getCountryList(true)));
}
return preg_replace(
array(
'/^(w+[0-9]*|search)\./',
'/(^|\.)m\./',
'/(\.(com|org|net|co|it|edu))?\.(' . $countries . ')(\/|$)/',
'/(^|\.)(' . $countries . ')\./',
),
array(
'',
'$1',
'.{}$4',
'$1{}.',
),
$url);
} | php | public static function getLossyUrl($url)
{
static $countries;
if (!isset($countries)) {
/** @var RegionDataProvider $regionDataProvider */
$regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$countries = implode('|', array_keys($regionDataProvider->getCountryList(true)));
}
return preg_replace(
array(
'/^(w+[0-9]*|search)\./',
'/(^|\.)m\./',
'/(\.(com|org|net|co|it|edu))?\.(' . $countries . ')(\/|$)/',
'/(^|\.)(' . $countries . ')\./',
),
array(
'',
'$1',
'.{}$4',
'$1{}.',
),
$url);
} | [
"public",
"static",
"function",
"getLossyUrl",
"(",
"$",
"url",
")",
"{",
"static",
"$",
"countries",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"countries",
")",
")",
"{",
"/** @var RegionDataProvider $regionDataProvider */",
"$",
"regionDataProvider",
"=",
"Stati... | Reduce URL to more minimal form. 2 letter country codes are
replaced by '{}', while other parts are simply removed.
Examples:
www.example.com -> example.com
search.example.com -> example.com
m.example.com -> example.com
de.example.com -> {}.example.com
example.de -> example.{}
example.co.uk -> example.{}
@param string $url
@return string | [
"Reduce",
"URL",
"to",
"more",
"minimal",
"form",
".",
"2",
"letter",
"country",
"codes",
"are",
"replaced",
"by",
"{}",
"while",
"other",
"parts",
"are",
"simply",
"removed",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/UrlHelper.php#L108-L131 | train | Returns the locally displayed elastic search URL. | [
30522,
2270,
10763,
3853,
2131,
10483,
6508,
3126,
2140,
1006,
1002,
24471,
2140,
1007,
1063,
10763,
1002,
3032,
1025,
2065,
1006,
999,
26354,
3388,
1006,
1002,
3032,
1007,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
2555,
2850,
2696,
21572,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/View.php | View.singleReport | public static function singleReport($title, $reportHtml)
{
$view = new View('@CoreHome/_singleReport');
$view->title = $title;
$view->report = $reportHtml;
return $view->render();
} | php | public static function singleReport($title, $reportHtml)
{
$view = new View('@CoreHome/_singleReport');
$view->title = $title;
$view->report = $reportHtml;
return $view->render();
} | [
"public",
"static",
"function",
"singleReport",
"(",
"$",
"title",
",",
"$",
"reportHtml",
")",
"{",
"$",
"view",
"=",
"new",
"View",
"(",
"'@CoreHome/_singleReport'",
")",
";",
"$",
"view",
"->",
"title",
"=",
"$",
"title",
";",
"$",
"view",
"->",
"re... | Creates a View for and then renders the single report template.
Can be used for pages that display only one report to avoid having to create
a new template.
@param string $title The report title.
@param string $reportHtml The report body HTML.
@return string|void The report contents if `$fetch` is true. | [
"Creates",
"a",
"View",
"for",
"and",
"then",
"renders",
"the",
"single",
"report",
"template",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/View.php#L449-L455 | train | Single Report - Shows a single report | [
30522,
2270,
10763,
3853,
2309,
2890,
6442,
1006,
1002,
2516,
1010,
1002,
3189,
11039,
19968,
1007,
1063,
1002,
3193,
1027,
2047,
3193,
1006,
1005,
1030,
4563,
23393,
2063,
1013,
1035,
2309,
2890,
6442,
1005,
1007,
1025,
1002,
3193,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php | CamelCaseToSnakeCaseNameConverter.normalize | public function normalize($propertyName)
{
if (null === $this->attributes || \in_array($propertyName, $this->attributes)) {
return strtolower(preg_replace('/[A-Z]/', '_\\0', lcfirst($propertyName)));
}
return $propertyName;
} | php | public function normalize($propertyName)
{
if (null === $this->attributes || \in_array($propertyName, $this->attributes)) {
return strtolower(preg_replace('/[A-Z]/', '_\\0', lcfirst($propertyName)));
}
return $propertyName;
} | [
"public",
"function",
"normalize",
"(",
"$",
"propertyName",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"attributes",
"||",
"\\",
"in_array",
"(",
"$",
"propertyName",
",",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"return",
"strtolower... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php#L37-L44 | train | Normalize the property name to a standard language | [
30522,
2270,
3853,
3671,
4697,
1006,
1002,
3200,
18442,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
12332,
1064,
1064,
1032,
1999,
1035,
9140,
1006,
1002,
3200,
18442,
1010,
1002,
2023,
1011,
1028,
12332,
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/Facades/Facade.php | Facade.resolved | public static function resolved(Closure $callback)
{
static::$app->afterResolving(static::getFacadeAccessor(), function ($service) use ($callback) {
$callback($service);
});
} | php | public static function resolved(Closure $callback)
{
static::$app->afterResolving(static::getFacadeAccessor(), function ($service) use ($callback) {
$callback($service);
});
} | [
"public",
"static",
"function",
"resolved",
"(",
"Closure",
"$",
"callback",
")",
"{",
"static",
"::",
"$",
"app",
"->",
"afterResolving",
"(",
"static",
"::",
"getFacadeAccessor",
"(",
")",
",",
"function",
"(",
"$",
"service",
")",
"use",
"(",
"$",
"ca... | Run a Closure when the facade has been resolved.
@param \Closure $callback
@return void | [
"Run",
"a",
"Closure",
"when",
"the",
"facade",
"has",
"been",
"resolved",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Facades/Facade.php#L32-L37 | train | Resolves the service after resolving | [
30522,
2270,
10763,
3853,
10395,
1006,
8503,
1002,
2655,
5963,
1007,
1063,
10763,
1024,
1024,
1002,
10439,
1011,
1028,
2044,
6072,
4747,
6455,
1006,
10763,
1024,
1024,
2131,
7011,
21869,
6305,
9623,
21748,
1006,
1007,
1010,
3853,
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... |
php-ai/php-ml | src/DimensionReduction/KernelPCA.php | KernelPCA.centerMatrix | protected function centerMatrix(array $matrix, int $n): array
{
$N = array_fill(0, $n, array_fill(0, $n, 1.0 / $n));
$N = new Matrix($N, false);
$K = new Matrix($matrix, false);
// K.N (This term is repeated so we cache it once)
$K_N = $K->multiply($N);
// N.K
$N_K = $N->multiply($K);
// N.K.N
$N_K_N = $N->multiply($K_N);
return $K->subtract($N_K)
->subtract($K_N)
->add($N_K_N)
->toArray();
} | php | protected function centerMatrix(array $matrix, int $n): array
{
$N = array_fill(0, $n, array_fill(0, $n, 1.0 / $n));
$N = new Matrix($N, false);
$K = new Matrix($matrix, false);
// K.N (This term is repeated so we cache it once)
$K_N = $K->multiply($N);
// N.K
$N_K = $N->multiply($K);
// N.K.N
$N_K_N = $N->multiply($K_N);
return $K->subtract($N_K)
->subtract($K_N)
->add($N_K_N)
->toArray();
} | [
"protected",
"function",
"centerMatrix",
"(",
"array",
"$",
"matrix",
",",
"int",
"$",
"n",
")",
":",
"array",
"{",
"$",
"N",
"=",
"array_fill",
"(",
"0",
",",
"$",
"n",
",",
"array_fill",
"(",
"0",
",",
"$",
"n",
",",
"1.0",
"/",
"$",
"n",
")"... | Kernel matrix is centered in its original space by using the following
conversion:
K′ = K − N.K − K.N + N.K.N where N is n-by-n matrix filled with 1/n | [
"Kernel",
"matrix",
"is",
"centered",
"in",
"its",
"original",
"space",
"by",
"using",
"the",
"following",
"conversion",
":"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/DimensionReduction/KernelPCA.php#L146-L163 | train | Center the matrix by the given number of terms | [
30522,
5123,
3853,
2415,
18900,
17682,
1006,
9140,
1002,
8185,
1010,
20014,
1002,
1050,
1007,
1024,
9140,
1063,
1002,
1050,
1027,
9140,
1035,
6039,
1006,
1014,
1010,
1002,
1050,
1010,
9140,
1035,
6039,
1006,
1014,
1010,
1002,
1050,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php | SerializesAndRestoresModelIdentifiers.restoreModel | public function restoreModel($value)
{
return $this->getQueryForModelRestoration(
(new $value->class)->setConnection($value->connection), $value->id
)->useWritePdo()->firstOrFail()->load($value->relations ?? []);
} | php | public function restoreModel($value)
{
return $this->getQueryForModelRestoration(
(new $value->class)->setConnection($value->connection), $value->id
)->useWritePdo()->firstOrFail()->load($value->relations ?? []);
} | [
"public",
"function",
"restoreModel",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"getQueryForModelRestoration",
"(",
"(",
"new",
"$",
"value",
"->",
"class",
")",
"->",
"setConnection",
"(",
"$",
"value",
"->",
"connection",
")",
",",
"$",
... | Restore the model from the model identifier instance.
@param \Illuminate\Contracts\Database\ModelIdentifier $value
@return \Illuminate\Database\Eloquent\Model | [
"Restore",
"the",
"model",
"from",
"the",
"model",
"identifier",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php#L81-L86 | train | Restores a model from the database. | [
30522,
2270,
3853,
9239,
5302,
9247,
1006,
1002,
3643,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2131,
4226,
2854,
14192,
10244,
20974,
4355,
21223,
1006,
1006,
2047,
1002,
3643,
1011,
1028,
2465,
1007,
1011,
1028,
2275,
8663,
2638,
7542,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php | AnnotationClassLoader.load | public function load($class, $type = null)
{
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}
$class = new \ReflectionClass($class);
if ($class->isAbstract()) {
throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName()));
}
$globals = $this->getGlobals($class);
$collection = new RouteCollection();
$collection->addResource(new FileResource($class->getFileName()));
foreach ($class->getMethods() as $method) {
$this->defaultRouteIndex = 0;
foreach ($this->reader->getMethodAnnotations($method) as $annot) {
if ($annot instanceof $this->routeAnnotationClass) {
$this->addRoute($collection, $annot, $globals, $class, $method);
}
}
}
if (0 === $collection->count() && $class->hasMethod('__invoke')) {
$globals = $this->resetGlobals();
foreach ($this->reader->getClassAnnotations($class) as $annot) {
if ($annot instanceof $this->routeAnnotationClass) {
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
}
}
}
return $collection;
} | php | public function load($class, $type = null)
{
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}
$class = new \ReflectionClass($class);
if ($class->isAbstract()) {
throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class->getName()));
}
$globals = $this->getGlobals($class);
$collection = new RouteCollection();
$collection->addResource(new FileResource($class->getFileName()));
foreach ($class->getMethods() as $method) {
$this->defaultRouteIndex = 0;
foreach ($this->reader->getMethodAnnotations($method) as $annot) {
if ($annot instanceof $this->routeAnnotationClass) {
$this->addRoute($collection, $annot, $globals, $class, $method);
}
}
}
if (0 === $collection->count() && $class->hasMethod('__invoke')) {
$globals = $this->resetGlobals();
foreach ($this->reader->getClassAnnotations($class) as $annot) {
if ($annot instanceof $this->routeAnnotationClass) {
$this->addRoute($collection, $annot, $globals, $class, $class->getMethod('__invoke'));
}
}
}
return $collection;
} | [
"public",
"function",
"load",
"(",
"$",
"class",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Class \"%s\" does not exist... | Loads from annotations from a class.
@param string $class A class name
@param string|null $type The resource type
@return RouteCollection A RouteCollection instance
@throws \InvalidArgumentException When route can't be parsed | [
"Loads",
"from",
"annotations",
"from",
"a",
"class",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php#L97-L132 | train | Load all annotations from a class | [
30522,
2270,
3853,
7170,
1006,
1002,
2465,
1010,
1002,
2828,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2465,
1035,
6526,
1006,
1002,
2465,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422,
1006,
9043,
2546,
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/Config.php | Config.reload | protected function reload($pathLocal = null, $pathGlobal = null, $pathCommon = null)
{
$this->settings->reload($pathGlobal, $pathLocal, $pathCommon);
} | php | protected function reload($pathLocal = null, $pathGlobal = null, $pathCommon = null)
{
$this->settings->reload($pathGlobal, $pathLocal, $pathCommon);
} | [
"protected",
"function",
"reload",
"(",
"$",
"pathLocal",
"=",
"null",
",",
"$",
"pathGlobal",
"=",
"null",
",",
"$",
"pathCommon",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"settings",
"->",
"reload",
"(",
"$",
"pathGlobal",
",",
"$",
"pathLocal",
","... | Reloads config data from disk.
@throws \Exception if the global config file is not found and this is a tracker request, or
if the local config file is not found and this is NOT a tracker request. | [
"Reloads",
"config",
"data",
"from",
"disk",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Config.php#L315-L318 | train | Reloads the settings from the database | [
30522,
5123,
3853,
2128,
11066,
1006,
1002,
4130,
4135,
9289,
1027,
19701,
1010,
1002,
4130,
23296,
16429,
2389,
1027,
19701,
1010,
1002,
4130,
9006,
8202,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
10906,
1011,
1028,
2128,
11066,
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... |
laravel/framework | src/Illuminate/Mail/Mailer.php | Mailer.shouldSendMessage | protected function shouldSendMessage($message, $data = [])
{
if (! $this->events) {
return true;
}
return $this->events->until(
new Events\MessageSending($message, $data)
) !== false;
} | php | protected function shouldSendMessage($message, $data = [])
{
if (! $this->events) {
return true;
}
return $this->events->until(
new Events\MessageSending($message, $data)
) !== false;
} | [
"protected",
"function",
"shouldSendMessage",
"(",
"$",
"message",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"events",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"events",
"->",
"until",
"... | Determines if the message can be sent.
@param \Swift_Message $message
@param array $data
@return bool | [
"Determines",
"if",
"the",
"message",
"can",
"be",
"sent",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailer.php#L497-L506 | train | Check if we should send a message | [
30522,
5123,
3853,
2323,
5054,
22117,
7971,
4270,
1006,
1002,
4471,
1010,
1002,
2951,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2824,
1007,
1063,
2709,
2995,
1025,
1065,
2709,
1002,
2023,
1011,
1028,
2824,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php | ContainerDebugCommand.getContainerBuilder | protected function getContainerBuilder()
{
if ($this->containerBuilder) {
return $this->containerBuilder;
}
$kernel = $this->getApplication()->getKernel();
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
$container = $buildContainer();
} else {
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
$container->setParameter('container.build_hash', $hash = ContainerBuilder::hash(__METHOD__));
$container->setParameter('container.build_id', hash('crc32', $hash.time()));
}
$container->getCompilerPassConfig()->setRemovingPasses([]);
$container->compile();
return $this->containerBuilder = $container;
} | php | protected function getContainerBuilder()
{
if ($this->containerBuilder) {
return $this->containerBuilder;
}
$kernel = $this->getApplication()->getKernel();
if (!$kernel->isDebug() || !(new ConfigCache($kernel->getContainer()->getParameter('debug.container.dump'), true))->isFresh()) {
$buildContainer = \Closure::bind(function () { return $this->buildContainer(); }, $kernel, \get_class($kernel));
$container = $buildContainer();
} else {
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator()))->load($kernel->getContainer()->getParameter('debug.container.dump'));
$container->setParameter('container.build_hash', $hash = ContainerBuilder::hash(__METHOD__));
$container->setParameter('container.build_id', hash('crc32', $hash.time()));
}
$container->getCompilerPassConfig()->setRemovingPasses([]);
$container->compile();
return $this->containerBuilder = $container;
} | [
"protected",
"function",
"getContainerBuilder",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"containerBuilder",
")",
"{",
"return",
"$",
"this",
"->",
"containerBuilder",
";",
"}",
"$",
"kernel",
"=",
"$",
"this",
"->",
"getApplication",
"(",
")",
"->",
... | Loads the ContainerBuilder from the cache.
@return ContainerBuilder
@throws \LogicException | [
"Loads",
"the",
"ContainerBuilder",
"from",
"the",
"cache",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php#L215-L236 | train | Get the container builder | [
30522,
5123,
3853,
2131,
8663,
18249,
2121,
8569,
23891,
2099,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11661,
8569,
23891,
2099,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
11661,
8569,
23891,
2099,
1025,
1065,
1002,
16293,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Request.php | Request.getCharsets | public function getCharsets()
{
if (null !== $this->charsets) {
return $this->charsets;
}
return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all());
} | php | public function getCharsets()
{
if (null !== $this->charsets) {
return $this->charsets;
}
return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all());
} | [
"public",
"function",
"getCharsets",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"charsets",
")",
"{",
"return",
"$",
"this",
"->",
"charsets",
";",
"}",
"return",
"$",
"this",
"->",
"charsets",
"=",
"array_keys",
"(",
"AcceptHeader",
"... | Gets a list of charsets acceptable by the client browser.
@return array List of charsets in preferable order | [
"Gets",
"a",
"list",
"of",
"charsets",
"acceptable",
"by",
"the",
"client",
"browser",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Request.php#L1645-L1652 | train | Get all charset names from Accept - Charset header | [
30522,
2270,
3853,
2131,
7507,
22573,
3215,
1006,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
25869,
13462,
2015,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
25869,
13462,
2015,
1025,
1065,
2709,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Config/Repository.php | Repository.get | public function get($key, $default = null)
{
if (is_array($key)) {
return $this->getMany($key);
}
return Arr::get($this->items, $key, $default);
} | php | public function get($key, $default = null)
{
if (is_array($key)) {
return $this->getMany($key);
}
return Arr::get($this->items, $key, $default);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getMany",
"(",
"$",
"key",
")",
";",
"}",
"return",
"Arr",
"::",
"get... | Get the specified configuration value.
@param array|string $key
@param mixed $default
@return mixed | [
"Get",
"the",
"specified",
"configuration",
"value",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Config/Repository.php#L47-L54 | train | Get a value from the items array or array | [
30522,
2270,
3853,
2131,
1006,
1002,
3145,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
3145,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2131,
2386,
2100,
1006,
1002,
3145,
1007,
1025,
1065,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select._renderColumns | protected function _renderColumns($sql)
{
if (!count($this->_parts[self::COLUMNS])) {
return null;
}
$columns = array();
foreach ($this->_parts[self::COLUMNS] as $columnEntry) {
list($correlationName, $column, $alias) = $columnEntry;
if ($column instanceof Zend_Db_Expr) {
$columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
} else {
if ($column == self::SQL_WILDCARD) {
$column = new Zend_Db_Expr(self::SQL_WILDCARD);
$alias = null;
}
if (empty($correlationName)) {
$columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
} else {
$columns[] = $this->_adapter->quoteColumnAs(array($correlationName, $column), $alias, true);
}
}
}
return $sql .= ' ' . implode(', ', $columns);
} | php | protected function _renderColumns($sql)
{
if (!count($this->_parts[self::COLUMNS])) {
return null;
}
$columns = array();
foreach ($this->_parts[self::COLUMNS] as $columnEntry) {
list($correlationName, $column, $alias) = $columnEntry;
if ($column instanceof Zend_Db_Expr) {
$columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
} else {
if ($column == self::SQL_WILDCARD) {
$column = new Zend_Db_Expr(self::SQL_WILDCARD);
$alias = null;
}
if (empty($correlationName)) {
$columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
} else {
$columns[] = $this->_adapter->quoteColumnAs(array($correlationName, $column), $alias, true);
}
}
}
return $sql .= ' ' . implode(', ', $columns);
} | [
"protected",
"function",
"_renderColumns",
"(",
"$",
"sql",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"COLUMNS",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"columns",
"=",
"array",
"(",
")",
... | Render DISTINCT clause
@param string $sql SQL query
@return string|null | [
"Render",
"DISTINCT",
"clause"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1070-L1095 | train | Render columns in SQL statement | [
30522,
5123,
3853,
1035,
17552,
25778,
2819,
3619,
1006,
1002,
29296,
1007,
1063,
2065,
1006,
999,
4175,
1006,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
2969,
1024,
1024,
7753,
1033,
1007,
1007,
1063,
2709,
19701,
1025,
1065,
1002,
7753,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Data/Validation.php | Validation.typeTime | public static function typeTime($value, array $params, array $field)
{
if (!isset($params['format'])) {
$params['format'] = 'H:i';
}
return self::typeDatetime($value, $params, $field);
} | php | public static function typeTime($value, array $params, array $field)
{
if (!isset($params['format'])) {
$params['format'] = 'H:i';
}
return self::typeDatetime($value, $params, $field);
} | [
"public",
"static",
"function",
"typeTime",
"(",
"$",
"value",
",",
"array",
"$",
"params",
",",
"array",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'format'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'format'",
"]",... | HTML5 input: time
@param mixed $value Value to be validated.
@param array $params Validation parameters.
@param array $field Blueprint for the field.
@return bool True if validation succeeded. | [
"HTML5",
"input",
":",
"time"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Validation.php#L502-L509 | train | TypeDatetime or DateTime | [
30522,
2270,
10763,
3853,
2828,
7292,
1006,
1002,
3643,
1010,
9140,
1002,
11498,
5244,
1010,
9140,
1002,
2492,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
11498,
5244,
1031,
1005,
4289,
1005,
1033,
1007,
1007,
1063,
1002,
11498,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Generator/UrlGenerator.php | UrlGenerator.generate | public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
{
$route = null;
$locale = $parameters['_locale']
?? $this->context->getParameter('_locale')
?: $this->defaultLocale;
if (null !== $locale) {
do {
if (null !== ($route = $this->routes->get($name.'.'.$locale)) && $route->getDefault('_canonical_route') === $name) {
unset($parameters['_locale']);
break;
}
} while (false !== $locale = strstr($locale, '_', true));
}
if (null === $route = $route ?? $this->routes->get($name)) {
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
}
// the Route has a cache of its own and is not recompiled as long as it does not get modified
$compiledRoute = $route->compile();
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes());
} | php | public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
{
$route = null;
$locale = $parameters['_locale']
?? $this->context->getParameter('_locale')
?: $this->defaultLocale;
if (null !== $locale) {
do {
if (null !== ($route = $this->routes->get($name.'.'.$locale)) && $route->getDefault('_canonical_route') === $name) {
unset($parameters['_locale']);
break;
}
} while (false !== $locale = strstr($locale, '_', true));
}
if (null === $route = $route ?? $this->routes->get($name)) {
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
}
// the Route has a cache of its own and is not recompiled as long as it does not get modified
$compiledRoute = $route->compile();
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $name, $referenceType, $compiledRoute->getHostTokens(), $route->getSchemes());
} | [
"public",
"function",
"generate",
"(",
"$",
"name",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"referenceType",
"=",
"self",
"::",
"ABSOLUTE_PATH",
")",
"{",
"$",
"route",
"=",
"null",
";",
"$",
"locale",
"=",
"$",
"parameters",
"[",
"'_locale'",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Generator/UrlGenerator.php#L127-L151 | train | Generate a URL for the named route | [
30522,
2270,
3853,
9699,
1006,
1002,
2171,
1010,
1002,
11709,
1027,
1031,
1033,
1010,
1002,
4431,
13874,
1027,
2969,
1024,
1024,
7619,
1035,
4130,
1007,
1063,
1002,
2799,
1027,
19701,
1025,
1002,
2334,
2063,
1027,
1002,
11709,
1031,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/WinCache.php | Zend_Cache_Backend_WinCache.touch | public function touch($id, $extraLifetime)
{
$tmp = wincache_ucache_get($id);
if (is_array($tmp)) {
$data = $tmp[0];
$mtime = $tmp[1];
if (!isset($tmp[2])) {
return false;
}
$lifetime = $tmp[2];
$newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
if ($newLifetime <=0) {
return false;
}
return wincache_ucache_set($id, array($data, time(), $newLifetime), $newLifetime);
}
return false;
} | php | public function touch($id, $extraLifetime)
{
$tmp = wincache_ucache_get($id);
if (is_array($tmp)) {
$data = $tmp[0];
$mtime = $tmp[1];
if (!isset($tmp[2])) {
return false;
}
$lifetime = $tmp[2];
$newLifetime = $lifetime - (time() - $mtime) + $extraLifetime;
if ($newLifetime <=0) {
return false;
}
return wincache_ucache_set($id, array($data, time(), $newLifetime), $newLifetime);
}
return false;
} | [
"public",
"function",
"touch",
"(",
"$",
"id",
",",
"$",
"extraLifetime",
")",
"{",
"$",
"tmp",
"=",
"wincache_ucache_get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"tmp",
")",
")",
"{",
"$",
"data",
"=",
"$",
"tmp",
"[",
"0",
... | Give (if possible) an extra lifetime to the given cache id
@param string $id cache id
@param int $extraLifetime
@return boolean true if ok | [
"Give",
"(",
"if",
"possible",
")",
"an",
"extra",
"lifetime",
"to",
"the",
"given",
"cache",
"id"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/WinCache.php#L304-L321 | train | Touch a user cache entry | [
30522,
2270,
3853,
3543,
1006,
1002,
8909,
1010,
1002,
4469,
15509,
7292,
1007,
1063,
1002,
1056,
8737,
1027,
2663,
3540,
5403,
1035,
15384,
15395,
1035,
2131,
1006,
1002,
8909,
1007,
1025,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
1056,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/API.php | API.getSitesGroups | public function getSitesGroups()
{
Piwik::checkUserHasSuperUserAccess();
$groups = $this->getModel()->getSitesGroups();
$cleanedGroups = array_map('trim', $groups);
return $cleanedGroups;
} | php | public function getSitesGroups()
{
Piwik::checkUserHasSuperUserAccess();
$groups = $this->getModel()->getSitesGroups();
$cleanedGroups = array_map('trim', $groups);
return $cleanedGroups;
} | [
"public",
"function",
"getSitesGroups",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"$",
"groups",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getSitesGroups",
"(",
")",
";",
"$",
"cleanedGroups",
"=",
"array_map",
... | Returns the list of website groups, including the empty group
if no group were specified for some websites
@return array of group names strings | [
"Returns",
"the",
"list",
"of",
"website",
"groups",
"including",
"the",
"empty",
"group",
"if",
"no",
"group",
"were",
"specified",
"for",
"some",
"websites"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L216-L224 | train | Returns the list of all the site groups in the site. | [
30522,
2270,
3853,
4152,
7616,
17058,
2015,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1025,
1002,
2967,
1027,
1002,
2023,
1011,
1028,
2131,
5302,
9247,
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... |
laravel/framework | src/Illuminate/Queue/Worker.php | Worker.raiseExceptionOccurredJobEvent | protected function raiseExceptionOccurredJobEvent($connectionName, $job, $e)
{
$this->events->dispatch(new Events\JobExceptionOccurred(
$connectionName, $job, $e
));
} | php | protected function raiseExceptionOccurredJobEvent($connectionName, $job, $e)
{
$this->events->dispatch(new Events\JobExceptionOccurred(
$connectionName, $job, $e
));
} | [
"protected",
"function",
"raiseExceptionOccurredJobEvent",
"(",
"$",
"connectionName",
",",
"$",
"job",
",",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"events",
"->",
"dispatch",
"(",
"new",
"Events",
"\\",
"JobExceptionOccurred",
"(",
"$",
"connectionName",
",",... | Raise the exception occurred queue job event.
@param string $connectionName
@param \Illuminate\Contracts\Queue\Job $job
@param \Exception $e
@return void | [
"Raise",
"the",
"exception",
"occurred",
"queue",
"job",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Worker.php#L482-L487 | train | Throws an exception occurred event for the passed job and the exception object. | [
30522,
5123,
3853,
5333,
10288,
24422,
10085,
10841,
20529,
5558,
4783,
15338,
1006,
1002,
4434,
18442,
1010,
1002,
3105,
1010,
1002,
1041,
1007,
1063,
1002,
2023,
1011,
1028,
2824,
1011,
1028,
18365,
1006,
2047,
2824,
1032,
3105,
10288,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ProxyHeaders.php | ProxyHeaders.getProtocolInformation | public static function getProtocolInformation()
{
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
return 'SERVER_PORT=443';
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
return 'X-Forwarded-Proto';
}
if (isset($_SERVER['HTTP_X_FORWARDED_SCHEME']) && strtolower($_SERVER['HTTP_X_FORWARDED_SCHEME']) == 'https') {
return 'X-Forwarded-Scheme';
}
if (isset($_SERVER['HTTP_X_URL_SCHEME']) && strtolower($_SERVER['HTTP_X_URL_SCHEME']) == 'https') {
return 'X-Url-Scheme';
}
return null;
} | php | public static function getProtocolInformation()
{
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
return 'SERVER_PORT=443';
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') {
return 'X-Forwarded-Proto';
}
if (isset($_SERVER['HTTP_X_FORWARDED_SCHEME']) && strtolower($_SERVER['HTTP_X_FORWARDED_SCHEME']) == 'https') {
return 'X-Forwarded-Scheme';
}
if (isset($_SERVER['HTTP_X_URL_SCHEME']) && strtolower($_SERVER['HTTP_X_URL_SCHEME']) == 'https') {
return 'X-Url-Scheme';
}
return null;
} | [
"public",
"static",
"function",
"getProtocolInformation",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'SERVER_PORT'",
"]",
"==",
"443",
")",
"{",
"return",
"'SERVER_PORT=443'",
";",
"}... | Get protocol information, with the exception of HTTPS
@return string protocol information | [
"Get",
"protocol",
"information",
"with",
"the",
"exception",
"of",
"HTTPS"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ProxyHeaders.php#L22-L41 | train | Get protocol information | [
30522,
2270,
10763,
3853,
2131,
21572,
3406,
25778,
2378,
14192,
3370,
1006,
1007,
1063,
2065,
1006,
26354,
30524,
2065,
1006,
26354,
3388,
1006,
1002,
1035,
8241,
1031,
1005,
8299,
1035,
1060,
1035,
2830,
2098,
1035,
15053,
1005,
1033,
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 | libs/Zend/Cache/Backend/File.php | Zend_Cache_Backend_File._filePutContents | protected function _filePutContents($file, $string)
{
$result = false;
$f = @fopen($file, 'ab+');
if ($f) {
if ($this->_options['file_locking']) @flock($f, LOCK_EX);
fseek($f, 0);
ftruncate($f, 0);
$tmp = @fwrite($f, $string);
if (!($tmp === FALSE)) {
$result = true;
}
@fclose($f);
}
@chmod($file, $this->_options['cache_file_umask']);
return $result;
} | php | protected function _filePutContents($file, $string)
{
$result = false;
$f = @fopen($file, 'ab+');
if ($f) {
if ($this->_options['file_locking']) @flock($f, LOCK_EX);
fseek($f, 0);
ftruncate($f, 0);
$tmp = @fwrite($f, $string);
if (!($tmp === FALSE)) {
$result = true;
}
@fclose($f);
}
@chmod($file, $this->_options['cache_file_umask']);
return $result;
} | [
"protected",
"function",
"_filePutContents",
"(",
"$",
"file",
",",
"$",
"string",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"f",
"=",
"@",
"fopen",
"(",
"$",
"file",
",",
"'ab+'",
")",
";",
"if",
"(",
"$",
"f",
")",
"{",
"if",
"(",
"$",... | Put the given string into the given file
@param string $file File complete path
@param string $string String to put in file
@return boolean true if no problem | [
"Put",
"the",
"given",
"string",
"into",
"the",
"given",
"file"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/File.php#L977-L993 | train | Write a string to a file | [
30522,
5123,
3853,
1035,
5371,
18780,
8663,
6528,
3215,
1006,
1002,
5371,
1010,
1002,
5164,
1007,
1063,
1002,
2765,
1027,
6270,
1025,
1002,
1042,
1027,
1030,
1042,
26915,
1006,
1002,
5371,
1010,
1005,
11113,
1009,
1005,
1007,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/MediaLibrary.php | MediaLibrary.listFolderContents | public function listFolderContents($folder = '/', $sortBy = 'title', $filter = null, $ignoreFolders = false)
{
$folder = self::validatePath($folder);
$fullFolderPath = $this->getMediaPath($folder);
/*
* Try to load the contents from cache
*/
$cached = Cache::get($this->cacheKey, false);
$cached = $cached ? @unserialize(@base64_decode($cached)) : [];
if (!is_array($cached)) {
$cached = [];
}
if (array_key_exists($fullFolderPath, $cached)) {
$folderContents = $cached[$fullFolderPath];
}
else {
$folderContents = $this->scanFolderContents($fullFolderPath);
$cached[$fullFolderPath] = $folderContents;
Cache::put(
$this->cacheKey,
base64_encode(serialize($cached)),
Config::get('cms.storage.media.ttl', 10)
);
}
/*
* Sort the result and combine the file and folder lists
*/
if ($sortBy !== false) {
$this->sortItemList($folderContents['files'], $sortBy);
$this->sortItemList($folderContents['folders'], $sortBy);
}
$this->filterItemList($folderContents['files'], $filter);
if (!$ignoreFolders) {
$folderContents = array_merge($folderContents['folders'], $folderContents['files']);
}
else {
$folderContents = $folderContents['files'];
}
return $folderContents;
} | php | public function listFolderContents($folder = '/', $sortBy = 'title', $filter = null, $ignoreFolders = false)
{
$folder = self::validatePath($folder);
$fullFolderPath = $this->getMediaPath($folder);
/*
* Try to load the contents from cache
*/
$cached = Cache::get($this->cacheKey, false);
$cached = $cached ? @unserialize(@base64_decode($cached)) : [];
if (!is_array($cached)) {
$cached = [];
}
if (array_key_exists($fullFolderPath, $cached)) {
$folderContents = $cached[$fullFolderPath];
}
else {
$folderContents = $this->scanFolderContents($fullFolderPath);
$cached[$fullFolderPath] = $folderContents;
Cache::put(
$this->cacheKey,
base64_encode(serialize($cached)),
Config::get('cms.storage.media.ttl', 10)
);
}
/*
* Sort the result and combine the file and folder lists
*/
if ($sortBy !== false) {
$this->sortItemList($folderContents['files'], $sortBy);
$this->sortItemList($folderContents['folders'], $sortBy);
}
$this->filterItemList($folderContents['files'], $filter);
if (!$ignoreFolders) {
$folderContents = array_merge($folderContents['folders'], $folderContents['files']);
}
else {
$folderContents = $folderContents['files'];
}
return $folderContents;
} | [
"public",
"function",
"listFolderContents",
"(",
"$",
"folder",
"=",
"'/'",
",",
"$",
"sortBy",
"=",
"'title'",
",",
"$",
"filter",
"=",
"null",
",",
"$",
"ignoreFolders",
"=",
"false",
")",
"{",
"$",
"folder",
"=",
"self",
"::",
"validatePath",
"(",
"... | Returns a list of folders and files in a Library folder.
@param string $folder Specifies the folder path relative the the Library root.
@param mixed $sortBy Determines the sorting preference.
Supported values are 'title', 'size', 'lastModified' (see SORT_BY_XXX class constants), FALSE (to disable sorting), or an associative array with a 'by' key and a 'direction' key: ['by' => SORT_BY_XXX, 'direction' => SORT_DIRECTION_XXX].
@param string $filter Determines the document type filtering preference.
Supported values are 'image', 'video', 'audio', 'document' (see FILE_TYPE_XXX constants of MediaLibraryItem class).
@param boolean $ignoreFolders Determines whether folders should be suppressed in the result list.
@return array Returns an array of MediaLibraryItem objects. | [
"Returns",
"a",
"list",
"of",
"folders",
"and",
"files",
"in",
"a",
"Library",
"folder",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L114-L163 | train | Returns the contents of a folder | [
30522,
2270,
3853,
2862,
10371,
2121,
8663,
6528,
3215,
1006,
1002,
19622,
1027,
1005,
1013,
1005,
1010,
1002,
4066,
3762,
1027,
1005,
2516,
1005,
1010,
1002,
11307,
1027,
19701,
1010,
1002,
8568,
10371,
2545,
1027,
6270,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php | YamlDumper.dumpValue | private function dumpValue($value)
{
if ($value instanceof ServiceClosureArgument) {
$value = $value->getValues()[0];
}
if ($value instanceof ArgumentInterface) {
$tag = $value;
if ($value instanceof TaggedIteratorArgument || ($value instanceof ServiceLocatorArgument && $tag = $value->getTaggedIteratorArgument())) {
if (null === $tag->getIndexAttribute()) {
$content = $tag->getTag();
} else {
$content = [
'tag' => $tag->getTag(),
'index_by' => $tag->getIndexAttribute(),
];
if (null !== $tag->getDefaultIndexMethod()) {
$content['default_index_method'] = $tag->getDefaultIndexMethod();
}
}
return new TaggedValue($value instanceof TaggedIteratorArgument ? 'tagged' : 'tagged_locator', $content);
}
if ($value instanceof IteratorArgument) {
$tag = 'iterator';
} elseif ($value instanceof ServiceLocatorArgument) {
$tag = 'service_locator';
} else {
throw new RuntimeException(sprintf('Unspecified Yaml tag for type "%s".', \get_class($value)));
}
return new TaggedValue($tag, $this->dumpValue($value->getValues()));
}
if (\is_array($value)) {
$code = [];
foreach ($value as $k => $v) {
$code[$k] = $this->dumpValue($v);
}
return $code;
} elseif ($value instanceof Reference) {
return $this->getServiceCall((string) $value, $value);
} elseif ($value instanceof Parameter) {
return $this->getParameterCall((string) $value);
} elseif ($value instanceof Expression) {
return $this->getExpressionCall((string) $value);
} elseif ($value instanceof Definition) {
return new TaggedValue('service', (new Parser())->parse("_:\n".$this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']);
} elseif (\is_object($value) || \is_resource($value)) {
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
}
return $value;
} | php | private function dumpValue($value)
{
if ($value instanceof ServiceClosureArgument) {
$value = $value->getValues()[0];
}
if ($value instanceof ArgumentInterface) {
$tag = $value;
if ($value instanceof TaggedIteratorArgument || ($value instanceof ServiceLocatorArgument && $tag = $value->getTaggedIteratorArgument())) {
if (null === $tag->getIndexAttribute()) {
$content = $tag->getTag();
} else {
$content = [
'tag' => $tag->getTag(),
'index_by' => $tag->getIndexAttribute(),
];
if (null !== $tag->getDefaultIndexMethod()) {
$content['default_index_method'] = $tag->getDefaultIndexMethod();
}
}
return new TaggedValue($value instanceof TaggedIteratorArgument ? 'tagged' : 'tagged_locator', $content);
}
if ($value instanceof IteratorArgument) {
$tag = 'iterator';
} elseif ($value instanceof ServiceLocatorArgument) {
$tag = 'service_locator';
} else {
throw new RuntimeException(sprintf('Unspecified Yaml tag for type "%s".', \get_class($value)));
}
return new TaggedValue($tag, $this->dumpValue($value->getValues()));
}
if (\is_array($value)) {
$code = [];
foreach ($value as $k => $v) {
$code[$k] = $this->dumpValue($v);
}
return $code;
} elseif ($value instanceof Reference) {
return $this->getServiceCall((string) $value, $value);
} elseif ($value instanceof Parameter) {
return $this->getParameterCall((string) $value);
} elseif ($value instanceof Expression) {
return $this->getExpressionCall((string) $value);
} elseif ($value instanceof Definition) {
return new TaggedValue('service', (new Parser())->parse("_:\n".$this->addService('_', $value), Yaml::PARSE_CUSTOM_TAGS)['_']['_']);
} elseif (\is_object($value) || \is_resource($value)) {
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
}
return $value;
} | [
"private",
"function",
"dumpValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"ServiceClosureArgument",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"getValues",
"(",
")",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"$",
"value"... | Dumps the value to YAML format.
@param mixed $value
@return mixed
@throws RuntimeException When trying to dump object or resource | [
"Dumps",
"the",
"value",
"to",
"YAML",
"format",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php#L229-L285 | train | Dump value to a string | [
30522,
2797,
3853,
15653,
10175,
5657,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
3643,
6013,
11253,
2326,
20464,
2891,
5397,
2906,
22850,
4765,
1007,
1063,
1002,
3643,
1027,
1002,
3643,
1011,
1028,
2131,
10175,
15808,
1006,
1007,
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... |
walkor/Workerman | Protocols/Http.php | Http.getRequestSize | protected static function getRequestSize($header, $method)
{
if($method === 'GET' || $method === 'OPTIONS' || $method === 'HEAD') {
return strlen($header) + 4;
}
$match = array();
if (preg_match("/\r\nContent-Length: ?(\d+)/i", $header, $match)) {
$content_length = isset($match[1]) ? $match[1] : 0;
return $content_length + strlen($header) + 4;
}
return $method === 'DELETE' ? strlen($header) + 4 : 0;
} | php | protected static function getRequestSize($header, $method)
{
if($method === 'GET' || $method === 'OPTIONS' || $method === 'HEAD') {
return strlen($header) + 4;
}
$match = array();
if (preg_match("/\r\nContent-Length: ?(\d+)/i", $header, $match)) {
$content_length = isset($match[1]) ? $match[1] : 0;
return $content_length + strlen($header) + 4;
}
return $method === 'DELETE' ? strlen($header) + 4 : 0;
} | [
"protected",
"static",
"function",
"getRequestSize",
"(",
"$",
"header",
",",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"'GET'",
"||",
"$",
"method",
"===",
"'OPTIONS'",
"||",
"$",
"method",
"===",
"'HEAD'",
")",
"{",
"return",
"strlen",
... | Get whole size of the request
includes the request headers and request body.
@param string $header The request headers
@param string $method The request method
@return integer | [
"Get",
"whole",
"size",
"of",
"the",
"request",
"includes",
"the",
"request",
"headers",
"and",
"request",
"body",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Http.php#L66-L77 | train | Returns the size of the request | [
30522,
5123,
10763,
3853,
2131,
2890,
15500,
5332,
4371,
1006,
1002,
20346,
1010,
1002,
4118,
1007,
1063,
2065,
1006,
1002,
4118,
1027,
1027,
1027,
1005,
2131,
1005,
1064,
1064,
1002,
4118,
1027,
1027,
1027,
1005,
7047,
1005,
1064,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php | DbalLogger.startQuery | public function startQuery($sql, array $params = null, array $types = null)
{
if (null !== $this->stopwatch) {
$this->stopwatch->start('doctrine', 'doctrine');
}
if (null !== $this->logger) {
$this->log($sql, null === $params ? [] : $this->normalizeParams($params));
}
} | php | public function startQuery($sql, array $params = null, array $types = null)
{
if (null !== $this->stopwatch) {
$this->stopwatch->start('doctrine', 'doctrine');
}
if (null !== $this->logger) {
$this->log($sql, null === $params ? [] : $this->normalizeParams($params));
}
} | [
"public",
"function",
"startQuery",
"(",
"$",
"sql",
",",
"array",
"$",
"params",
"=",
"null",
",",
"array",
"$",
"types",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"stopwatch",
")",
"{",
"$",
"this",
"->",
"stopwatch",
"-... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php#L38-L47 | train | Starts the query | [
30522,
2270,
3853,
2707,
30524,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
2644,
18866,
1007,
1063,
1002,
2023,
1011,
1028,
2644,
18866,
1011,
1028,
2707,
1006,
1005,
8998,
1005,
1010,
1005,
8998,
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... |
apache/thrift | lib/php/lib/Transport/TTransport.php | TTransport.readAll | public function readAll($len)
{
// return $this->read($len);
$data = '';
$got = 0;
while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
$data .= $this->read($len - $got);
}
return $data;
} | php | public function readAll($len)
{
// return $this->read($len);
$data = '';
$got = 0;
while (($got = TStringFuncFactory::create()->strlen($data)) < $len) {
$data .= $this->read($len - $got);
}
return $data;
} | [
"public",
"function",
"readAll",
"(",
"$",
"len",
")",
"{",
"// return $this->read($len);",
"$",
"data",
"=",
"''",
";",
"$",
"got",
"=",
"0",
";",
"while",
"(",
"(",
"$",
"got",
"=",
"TStringFuncFactory",
"::",
"create",
"(",
")",
"->",
"strlen",
"(",... | Guarantees that the full amount of data is read.
@return string The data, of exact length
@throws TTransportException if cannot read data | [
"Guarantees",
"that",
"the",
"full",
"amount",
"of",
"data",
"is",
"read",
"."
] | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Transport/TTransport.php#L69-L80 | train | Read all the bytes from the stream. | [
30522,
2270,
3853,
3191,
8095,
1006,
1002,
18798,
1007,
1063,
1013,
1013,
2709,
1002,
2023,
1011,
1028,
3191,
1006,
1002,
18798,
1007,
1025,
1002,
2951,
1027,
1005,
1005,
1025,
1002,
2288,
1027,
1014,
1025,
2096,
1006,
1006,
1002,
2288,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataAccess/RawLogDao.php | RawLogDao.deleteUnusedLogActions | public function deleteUnusedLogActions()
{
if (!Db::isLockPrivilegeGranted()) {
throw new \Exception("RawLogDao.deleteUnusedLogActions() requires table locking permission in order to complete without error.");
}
// get current max ID in log tables w/ idaction references.
$maxIds = $this->getMaxIdsInLogTables();
$this->createTempTableForStoringUsedActions();
// do large insert (inserting everything before maxIds) w/o locking tables...
$this->insertActionsToKeep($maxIds, $deleteOlderThanMax = true);
// ... then do small insert w/ locked tables to minimize the amount of time tables are locked.
$this->lockLogTables();
$this->insertActionsToKeep($maxIds, $deleteOlderThanMax = false);
// delete before unlocking tables so there's no chance a new log row that references an
// unused action will be inserted.
$this->deleteUnusedActions();
Db::unlockAllTables();
$this->dropTempTableForStoringUsedActions();
} | php | public function deleteUnusedLogActions()
{
if (!Db::isLockPrivilegeGranted()) {
throw new \Exception("RawLogDao.deleteUnusedLogActions() requires table locking permission in order to complete without error.");
}
// get current max ID in log tables w/ idaction references.
$maxIds = $this->getMaxIdsInLogTables();
$this->createTempTableForStoringUsedActions();
// do large insert (inserting everything before maxIds) w/o locking tables...
$this->insertActionsToKeep($maxIds, $deleteOlderThanMax = true);
// ... then do small insert w/ locked tables to minimize the amount of time tables are locked.
$this->lockLogTables();
$this->insertActionsToKeep($maxIds, $deleteOlderThanMax = false);
// delete before unlocking tables so there's no chance a new log row that references an
// unused action will be inserted.
$this->deleteUnusedActions();
Db::unlockAllTables();
$this->dropTempTableForStoringUsedActions();
} | [
"public",
"function",
"deleteUnusedLogActions",
"(",
")",
"{",
"if",
"(",
"!",
"Db",
"::",
"isLockPrivilegeGranted",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"RawLogDao.deleteUnusedLogActions() requires table locking permission in order to complete with... | Deletes all unused entries from the log_action table. This method uses a temporary table to store used
actions, and then deletes rows from log_action that are not in this temporary table.
Table locking is required to avoid concurrency issues.
@throws \Exception If table locking permission is not granted to the current MySQL user. | [
"Deletes",
"all",
"unused",
"entries",
"from",
"the",
"log_action",
"table",
".",
"This",
"method",
"uses",
"a",
"temporary",
"table",
"to",
"store",
"used",
"actions",
"and",
"then",
"deletes",
"rows",
"from",
"log_action",
"that",
"are",
"not",
"in",
"this... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/RawLogDao.php#L162-L187 | train | Delete unused log actions | [
30522,
2270,
3853,
3972,
12870,
4609,
13901,
21197,
18908,
8496,
1006,
1007,
1063,
2065,
1006,
999,
16962,
1024,
1024,
2003,
7878,
18098,
12848,
9463,
3351,
18980,
2098,
1006,
1007,
1007,
1063,
5466,
2047,
1032,
6453,
1006,
1000,
6315,
2119... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/controllers/Updates.php | Updates.onExecuteStep | public function onExecuteStep()
{
/*
* Address timeout limits
*/
@set_time_limit(3600);
$manager = UpdateManager::instance();
$stepCode = post('code');
switch ($stepCode) {
case 'downloadCore':
$manager->downloadCore(post('hash'));
break;
case 'extractCore':
$manager->extractCore();
break;
case 'setBuild':
$manager->setBuild(post('build'), post('hash'));
break;
case 'downloadPlugin':
$manager->downloadPlugin(post('name'), post('hash'), post('install'));
break;
case 'downloadTheme':
$manager->downloadTheme(post('name'), post('hash'));
break;
case 'extractPlugin':
$manager->extractPlugin(post('name'), post('hash'));
break;
case 'extractTheme':
$manager->extractTheme(post('name'), post('hash'));
break;
case 'completeUpdate':
$manager->update();
Flash::success(Lang::get('system::lang.updates.update_success'));
return Redirect::refresh();
case 'completeInstall':
$manager->update();
Flash::success(Lang::get('system::lang.install.install_success'));
return Redirect::refresh();
}
} | php | public function onExecuteStep()
{
/*
* Address timeout limits
*/
@set_time_limit(3600);
$manager = UpdateManager::instance();
$stepCode = post('code');
switch ($stepCode) {
case 'downloadCore':
$manager->downloadCore(post('hash'));
break;
case 'extractCore':
$manager->extractCore();
break;
case 'setBuild':
$manager->setBuild(post('build'), post('hash'));
break;
case 'downloadPlugin':
$manager->downloadPlugin(post('name'), post('hash'), post('install'));
break;
case 'downloadTheme':
$manager->downloadTheme(post('name'), post('hash'));
break;
case 'extractPlugin':
$manager->extractPlugin(post('name'), post('hash'));
break;
case 'extractTheme':
$manager->extractTheme(post('name'), post('hash'));
break;
case 'completeUpdate':
$manager->update();
Flash::success(Lang::get('system::lang.updates.update_success'));
return Redirect::refresh();
case 'completeInstall':
$manager->update();
Flash::success(Lang::get('system::lang.install.install_success'));
return Redirect::refresh();
}
} | [
"public",
"function",
"onExecuteStep",
"(",
")",
"{",
"/*\n * Address timeout limits\n */",
"@",
"set_time_limit",
"(",
"3600",
")",
";",
"$",
"manager",
"=",
"UpdateManager",
"::",
"instance",
"(",
")",
";",
"$",
"stepCode",
"=",
"post",
"(",
"'... | Runs a specific update step. | [
"Runs",
"a",
"specific",
"update",
"step",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/controllers/Updates.php#L258-L307 | train | Runs the step | [
30522,
2270,
3853,
2028,
2595,
8586,
10421,
13473,
2361,
1006,
1007,
1063,
1013,
1008,
1008,
4769,
2051,
5833,
6537,
1008,
1013,
1030,
2275,
1035,
2051,
1035,
5787,
1006,
9475,
2692,
1007,
1025,
1002,
3208,
1027,
10651,
24805,
4590,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php | PdoSessionHandler.doRead | protected function doRead($sessionId)
{
if (self::LOCK_ADVISORY === $this->lockMode) {
$this->unlockStatements[] = $this->doAdvisoryLock($sessionId);
}
$selectSql = $this->getSelectSql();
$selectStmt = $this->pdo->prepare($selectSql);
$selectStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
$insertStmt = null;
do {
$selectStmt->execute();
$sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM);
if ($sessionRows) {
if ($sessionRows[0][1] + $sessionRows[0][2] < time()) {
$this->sessionExpired = true;
return '';
}
return \is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0];
}
if (null !== $insertStmt) {
$this->rollback();
throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.');
}
if (!filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
// In strict mode, session fixation is not possible: new sessions always start with a unique
// random id, so that concurrency is not possible and this code path can be skipped.
// Exclusive-reading of non-existent rows does not block, so we need to do an insert to block
// until other connections to the session are committed.
try {
$insertStmt = $this->getInsertStatement($sessionId, '', 0);
$insertStmt->execute();
} catch (\PDOException $e) {
// Catch duplicate key error because other connection created the session already.
// It would only not be the case when the other connection destroyed the session.
if (0 === strpos($e->getCode(), '23')) {
// Retrieve finished session data written by concurrent connection by restarting the loop.
// We have to start a new transaction as a failed query will mark the current transaction as
// aborted in PostgreSQL and disallow further queries within it.
$this->rollback();
$this->beginTransaction();
continue;
}
throw $e;
}
}
return '';
} while (true);
} | php | protected function doRead($sessionId)
{
if (self::LOCK_ADVISORY === $this->lockMode) {
$this->unlockStatements[] = $this->doAdvisoryLock($sessionId);
}
$selectSql = $this->getSelectSql();
$selectStmt = $this->pdo->prepare($selectSql);
$selectStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
$insertStmt = null;
do {
$selectStmt->execute();
$sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM);
if ($sessionRows) {
if ($sessionRows[0][1] + $sessionRows[0][2] < time()) {
$this->sessionExpired = true;
return '';
}
return \is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0];
}
if (null !== $insertStmt) {
$this->rollback();
throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.');
}
if (!filter_var(ini_get('session.use_strict_mode'), FILTER_VALIDATE_BOOLEAN) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
// In strict mode, session fixation is not possible: new sessions always start with a unique
// random id, so that concurrency is not possible and this code path can be skipped.
// Exclusive-reading of non-existent rows does not block, so we need to do an insert to block
// until other connections to the session are committed.
try {
$insertStmt = $this->getInsertStatement($sessionId, '', 0);
$insertStmt->execute();
} catch (\PDOException $e) {
// Catch duplicate key error because other connection created the session already.
// It would only not be the case when the other connection destroyed the session.
if (0 === strpos($e->getCode(), '23')) {
// Retrieve finished session data written by concurrent connection by restarting the loop.
// We have to start a new transaction as a failed query will mark the current transaction as
// aborted in PostgreSQL and disallow further queries within it.
$this->rollback();
$this->beginTransaction();
continue;
}
throw $e;
}
}
return '';
} while (true);
} | [
"protected",
"function",
"doRead",
"(",
"$",
"sessionId",
")",
"{",
"if",
"(",
"self",
"::",
"LOCK_ADVISORY",
"===",
"$",
"this",
"->",
"lockMode",
")",
"{",
"$",
"this",
"->",
"unlockStatements",
"[",
"]",
"=",
"$",
"this",
"->",
"doAdvisoryLock",
"(",
... | Reads the session data in respect to the different locking strategies.
We need to make sure we do not return session data that is already considered garbage according
to the session.gc_maxlifetime setting because gc() is called after read() and only sometimes.
@param string $sessionId Session ID
@return string The session data | [
"Reads",
"the",
"session",
"data",
"in",
"respect",
"to",
"the",
"different",
"locking",
"strategies",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L610-L666 | train | Reads session data | [
30522,
5123,
3853,
2079,
16416,
2094,
1006,
1002,
5219,
3593,
1007,
30524,
1024,
5843,
1035,
7319,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
5843,
5302,
3207,
1007,
1063,
1002,
2023,
1011,
1028,
19829,
9153,
18532,
11187,
1031,
1033,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/ViewDataTable.php | ViewDataTable.throwWhenSettingNonOverridableParameter | public function throwWhenSettingNonOverridableParameter($overrideParams)
{
$nonOverridableParams = $this->getNonOverridableParams($overrideParams);
if(count($nonOverridableParams) > 0) {
throw new \Exception(sprintf(
"Setting parameters %s is not allowed. Please report this bug to the Matomo team.",
implode(" and ", $nonOverridableParams)
));
}
} | php | public function throwWhenSettingNonOverridableParameter($overrideParams)
{
$nonOverridableParams = $this->getNonOverridableParams($overrideParams);
if(count($nonOverridableParams) > 0) {
throw new \Exception(sprintf(
"Setting parameters %s is not allowed. Please report this bug to the Matomo team.",
implode(" and ", $nonOverridableParams)
));
}
} | [
"public",
"function",
"throwWhenSettingNonOverridableParameter",
"(",
"$",
"overrideParams",
")",
"{",
"$",
"nonOverridableParams",
"=",
"$",
"this",
"->",
"getNonOverridableParams",
"(",
"$",
"overrideParams",
")",
";",
"if",
"(",
"count",
"(",
"$",
"nonOverridable... | Display a meaningful error message when any invalid parameter is being set.
@param $overrideParams
@throws | [
"Display",
"a",
"meaningful",
"error",
"message",
"when",
"any",
"invalid",
"parameter",
"is",
"being",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ViewDataTable.php#L558-L567 | train | Throws an exception if setting parameters is not allowed | [
30522,
2270,
3853,
5466,
2860,
10222,
21678,
2075,
8540,
7840,
14615,
3085,
28689,
22828,
1006,
1002,
2058,
15637,
28689,
5244,
1007,
1063,
1002,
2512,
7840,
14615,
3085,
28689,
5244,
1027,
1002,
2023,
1011,
1028,
2131,
8540,
7840,
14615,
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... |
slimphp/Slim | Slim/Http/Response.php | Response.filterStatus | protected function filterStatus($status)
{
if (!is_integer($status) ||
$status<StatusCode::HTTP_CONTINUE ||
$status>StatusCode::HTTP_NETWORK_CONNECTION_TIMEOUT_ERROR
) {
throw new InvalidArgumentException('Invalid HTTP status code');
}
return $status;
} | php | protected function filterStatus($status)
{
if (!is_integer($status) ||
$status<StatusCode::HTTP_CONTINUE ||
$status>StatusCode::HTTP_NETWORK_CONNECTION_TIMEOUT_ERROR
) {
throw new InvalidArgumentException('Invalid HTTP status code');
}
return $status;
} | [
"protected",
"function",
"filterStatus",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"status",
")",
"||",
"$",
"status",
"<",
"StatusCode",
"::",
"HTTP_CONTINUE",
"||",
"$",
"status",
">",
"StatusCode",
"::",
"HTTP_NETWORK_CONNECTIO... | Filter HTTP status code.
@param int $status HTTP status code.
@return int
@throws InvalidArgumentException If an invalid HTTP status code is provided. | [
"Filter",
"HTTP",
"status",
"code",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Response.php#L221-L231 | train | Filter HTTP status code | [
30522,
5123,
3853,
17736,
29336,
2271,
1006,
1002,
3570,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16109,
1006,
1002,
3570,
1007,
1064,
1064,
30524,
1007,
1025,
1065,
2709,
1002,
3570,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/Store.php | Store.doPurge | private function doPurge($url)
{
$key = $this->getCacheKey(Request::create($url));
if (isset($this->locks[$key])) {
flock($this->locks[$key], LOCK_UN);
fclose($this->locks[$key]);
unset($this->locks[$key]);
}
if (file_exists($path = $this->getPath($key))) {
unlink($path);
return true;
}
return false;
} | php | private function doPurge($url)
{
$key = $this->getCacheKey(Request::create($url));
if (isset($this->locks[$key])) {
flock($this->locks[$key], LOCK_UN);
fclose($this->locks[$key]);
unset($this->locks[$key]);
}
if (file_exists($path = $this->getPath($key))) {
unlink($path);
return true;
}
return false;
} | [
"private",
"function",
"doPurge",
"(",
"$",
"url",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getCacheKey",
"(",
"Request",
"::",
"create",
"(",
"$",
"url",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"locks",
"[",
"$",
"key",
... | Purges data for the given URL.
@param string $url A URL
@return bool true if the URL exists and has been purged, false otherwise | [
"Purges",
"data",
"for",
"the",
"given",
"URL",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/Store.php#L327-L343 | train | Purge the cache for a given URL | [
30522,
2797,
3853,
2079,
5311,
3351,
1006,
1002,
24471,
2140,
1007,
1063,
1002,
3145,
1027,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
14839,
1006,
5227,
1024,
1024,
3443,
1006,
1002,
24471,
2140,
1007,
1007,
1025,
2065,
1006,
26354,
3388,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
php-ai/php-ml | src/Helper/Optimizer/ConjugateGradient.php | MP.muls | public static function muls(array $m1, float $m2): array
{
$res = [];
foreach ($m1 as $val) {
$res[] = $val * $m2;
}
return $res;
} | php | public static function muls(array $m1, float $m2): array
{
$res = [];
foreach ($m1 as $val) {
$res[] = $val * $m2;
}
return $res;
} | [
"public",
"static",
"function",
"muls",
"(",
"array",
"$",
"m1",
",",
"float",
"$",
"m2",
")",
":",
"array",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"m1",
"as",
"$",
"val",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"val",
... | Element-wise <b>multiplication</b> of a vector with a scalar | [
"Element",
"-",
"wise",
"<b",
">",
"multiplication<",
"/",
"b",
">",
"of",
"a",
"vector",
"with",
"a",
"scalar"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/Optimizer/ConjugateGradient.php#L261-L269 | train | Multiply two values | [
30522,
2270,
10763,
3853,
14163,
4877,
1006,
9140,
1002,
23290,
1010,
14257,
1002,
25525,
1007,
1024,
9140,
1063,
1002,
24501,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
23290,
2004,
1002,
11748,
1007,
1063,
1002,
24501,
1031,
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... |
laravel/framework | src/Illuminate/View/Concerns/ManagesEvents.php | ManagesEvents.composers | public function composers(array $composers)
{
$registered = [];
foreach ($composers as $callback => $views) {
$registered = array_merge($registered, $this->composer($views, $callback));
}
return $registered;
} | php | public function composers(array $composers)
{
$registered = [];
foreach ($composers as $callback => $views) {
$registered = array_merge($registered, $this->composer($views, $callback));
}
return $registered;
} | [
"public",
"function",
"composers",
"(",
"array",
"$",
"composers",
")",
"{",
"$",
"registered",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"composers",
"as",
"$",
"callback",
"=>",
"$",
"views",
")",
"{",
"$",
"registered",
"=",
"array_merge",
"(",
"$",
... | Register multiple view composers via an array.
@param array $composers
@return array | [
"Register",
"multiple",
"view",
"composers",
"via",
"an",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Concerns/ManagesEvents.php#L35-L44 | train | Get all the composers | [
30522,
2270,
3853,
9929,
1006,
9140,
1002,
9929,
1007,
1063,
1002,
5068,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
9929,
2004,
1002,
2655,
5963,
1027,
1028,
1002,
5328,
1007,
1063,
1002,
5068,
1027,
9140,
1035,
13590,
1006,
1002,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Css/AttributeTranslator.php | AttributeTranslator._set_table_border | static protected function _set_table_border(\DOMElement $node, $value)
{
$cell_list = self::get_cell_list($node);
foreach ($cell_list as $cell) {
$style = rtrim($cell->getAttribute(self::$_style_attr));
$style .= "; border-width: " . ($value > 0 ? 1 : 0) . "pt; border-style: inset;";
$style = ltrim($style, ";");
$cell->setAttribute(self::$_style_attr, $style);
}
$style = rtrim($node->getAttribute(self::$_style_attr), ";");
$style .= "; border-width: $value" . "px; ";
return ltrim($style, "; ");
} | php | static protected function _set_table_border(\DOMElement $node, $value)
{
$cell_list = self::get_cell_list($node);
foreach ($cell_list as $cell) {
$style = rtrim($cell->getAttribute(self::$_style_attr));
$style .= "; border-width: " . ($value > 0 ? 1 : 0) . "pt; border-style: inset;";
$style = ltrim($style, ";");
$cell->setAttribute(self::$_style_attr, $style);
}
$style = rtrim($node->getAttribute(self::$_style_attr), ";");
$style .= "; border-width: $value" . "px; ";
return ltrim($style, "; ");
} | [
"static",
"protected",
"function",
"_set_table_border",
"(",
"\\",
"DOMElement",
"$",
"node",
",",
"$",
"value",
")",
"{",
"$",
"cell_list",
"=",
"self",
"::",
"get_cell_list",
"(",
"$",
"node",
")",
";",
"foreach",
"(",
"$",
"cell_list",
"as",
"$",
"cel... | @param \DOMElement $node
@param string $value
@return string | [
"@param",
"\\",
"DOMElement",
"$node",
"@param",
"string",
"$value"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/AttributeTranslator.php#L378-L393 | train | Set border width for table | [
30522,
10763,
5123,
3853,
1035,
2275,
1035,
2795,
1035,
3675,
1006,
1032,
8514,
16930,
4765,
1002,
13045,
1010,
1002,
3643,
1007,
1063,
1002,
3526,
1035,
2862,
1027,
2969,
1024,
1024,
2131,
1035,
3526,
1035,
2862,
1006,
1002,
13045,
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/Archive.php | Archive.getPluginForReport | public static function getPluginForReport($report)
{
// Core metrics are always processed in Core, for the requested date/period/segment
if (in_array($report, Metrics::getVisitsMetricNames())) {
$report = 'VisitsSummary_CoreMetrics';
} // Goal_* metrics are processed by the Goals plugin (HACK)
elseif (strpos($report, 'Goal_') === 0) {
$report = 'Goals_Metrics';
} elseif (strrpos($report, '_returning') === strlen($report) - strlen('_returning')) { // HACK
$report = 'VisitFrequency_Metrics';
}
$plugin = substr($report, 0, strpos($report, '_'));
if (empty($plugin)
|| !\Piwik\Plugin\Manager::getInstance()->isPluginActivated($plugin)
) {
throw new \Exception("Error: The report '$report' was requested but it is not available at this stage."
. " (Plugin '$plugin' is not activated.)");
}
return $plugin;
} | php | public static function getPluginForReport($report)
{
// Core metrics are always processed in Core, for the requested date/period/segment
if (in_array($report, Metrics::getVisitsMetricNames())) {
$report = 'VisitsSummary_CoreMetrics';
} // Goal_* metrics are processed by the Goals plugin (HACK)
elseif (strpos($report, 'Goal_') === 0) {
$report = 'Goals_Metrics';
} elseif (strrpos($report, '_returning') === strlen($report) - strlen('_returning')) { // HACK
$report = 'VisitFrequency_Metrics';
}
$plugin = substr($report, 0, strpos($report, '_'));
if (empty($plugin)
|| !\Piwik\Plugin\Manager::getInstance()->isPluginActivated($plugin)
) {
throw new \Exception("Error: The report '$report' was requested but it is not available at this stage."
. " (Plugin '$plugin' is not activated.)");
}
return $plugin;
} | [
"public",
"static",
"function",
"getPluginForReport",
"(",
"$",
"report",
")",
"{",
"// Core metrics are always processed in Core, for the requested date/period/segment",
"if",
"(",
"in_array",
"(",
"$",
"report",
",",
"Metrics",
"::",
"getVisitsMetricNames",
"(",
")",
")... | Returns the name of the plugin that archives a given report.
@param string $report Archive data name, eg, `'nb_visits'`, `'DevicesDetection_...'`, etc.
@return string Plugin name.
@throws \Exception If a plugin cannot be found or if the plugin for the report isn't
activated. | [
"Returns",
"the",
"name",
"of",
"the",
"plugin",
"that",
"archives",
"a",
"given",
"report",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive.php#L817-L837 | train | Returns the plugin name for the requested report | [
30522,
2270,
10763,
3853,
2131,
24759,
15916,
2378,
29278,
2890,
6442,
1006,
1002,
3189,
1007,
1063,
1013,
1013,
4563,
12046,
2015,
2024,
2467,
13995,
1999,
4563,
1010,
2005,
1996,
7303,
3058,
1013,
2558,
1013,
6903,
2065,
1006,
1999,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/GPM/GPM.php | GPM.calculateMergedDependenciesOfPackages | public function calculateMergedDependenciesOfPackages($packages)
{
$dependencies = [];
foreach ($packages as $package) {
$dependencies = $this->calculateMergedDependenciesOfPackage($package, $dependencies);
}
return $dependencies;
} | php | public function calculateMergedDependenciesOfPackages($packages)
{
$dependencies = [];
foreach ($packages as $package) {
$dependencies = $this->calculateMergedDependenciesOfPackage($package, $dependencies);
}
return $dependencies;
} | [
"public",
"function",
"calculateMergedDependenciesOfPackages",
"(",
"$",
"packages",
")",
"{",
"$",
"dependencies",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"package",
")",
"{",
"$",
"dependencies",
"=",
"$",
"this",
"->",
"calculateMe... | Calculates and merges the dependencies of the passed packages
@param array $packages
@return mixed
@throws \Exception | [
"Calculates",
"and",
"merges",
"the",
"dependencies",
"of",
"the",
"passed",
"packages"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/GPM.php#L1057-L1066 | train | Calculates the merged dependencies of all packages. | [
30522,
2270,
3853,
18422,
5017,
5999,
3207,
11837,
4181,
9243,
11253,
23947,
13923,
1006,
1002,
14555,
1007,
1063,
1002,
12530,
15266,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
14555,
2004,
1002,
7427,
1007,
1063,
1002,
12530,
15266,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.mailSend | protected function mailSend($header, $body)
{
$toArr = [];
foreach ($this->to as $toaddr) {
$toArr[] = $this->addrFormat($toaddr);
}
$to = implode(', ', $toArr);
$params = null;
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
if (!empty($this->Sender) and static::validateAddress($this->Sender)) {
//A space after `-f` is optional, but there is a long history of its presence
//causing problems, so we don't use one
//Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
//Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html
//Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html
//Example problem: https://www.drupal.org/node/1057954
// CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
if (self::isShellSafe($this->Sender)) {
$params = sprintf('-f%s', $this->Sender);
}
}
if (!empty($this->Sender) and static::validateAddress($this->Sender)) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
}
$result = false;
if ($this->SingleTo and count($toArr) > 1) {
foreach ($toArr as $toAddr) {
$result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
$this->doCallback($result, [$toAddr], $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
}
} else {
$result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
$this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if (!$result) {
throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL);
}
return true;
} | php | protected function mailSend($header, $body)
{
$toArr = [];
foreach ($this->to as $toaddr) {
$toArr[] = $this->addrFormat($toaddr);
}
$to = implode(', ', $toArr);
$params = null;
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
if (!empty($this->Sender) and static::validateAddress($this->Sender)) {
//A space after `-f` is optional, but there is a long history of its presence
//causing problems, so we don't use one
//Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
//Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html
//Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html
//Example problem: https://www.drupal.org/node/1057954
// CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
if (self::isShellSafe($this->Sender)) {
$params = sprintf('-f%s', $this->Sender);
}
}
if (!empty($this->Sender) and static::validateAddress($this->Sender)) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
}
$result = false;
if ($this->SingleTo and count($toArr) > 1) {
foreach ($toArr as $toAddr) {
$result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
$this->doCallback($result, [$toAddr], $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
}
} else {
$result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
$this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From, []);
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if (!$result) {
throw new Exception($this->lang('instantiate'), self::STOP_CRITICAL);
}
return true;
} | [
"protected",
"function",
"mailSend",
"(",
"$",
"header",
",",
"$",
"body",
")",
"{",
"$",
"toArr",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"to",
"as",
"$",
"toaddr",
")",
"{",
"$",
"toArr",
"[",
"]",
"=",
"$",
"this",
"->",
"addr... | Send mail using the PHP mail() function.
@see http://www.php.net/manual/en/book.mail.php
@param string $header The message headers
@param string $body The message body
@throws Exception
@return bool | [
"Send",
"mail",
"using",
"the",
"PHP",
"mail",
"()",
"function",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L1703-L1747 | train | Sends the message to all addresses in the to array | [
30522,
5123,
3853,
5653,
5054,
2094,
1006,
1002,
20346,
1010,
1002,
2303,
1007,
1063,
1002,
2000,
2906,
2099,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2000,
2004,
1002,
21344,
13626,
1007,
1063,
1002,
2000,
2906,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | BelongsToMany.addWhereConstraints | protected function addWhereConstraints()
{
$this->query->where(
$this->getQualifiedForeignPivotKeyName(), '=', $this->parent->{$this->parentKey}
);
return $this;
} | php | protected function addWhereConstraints()
{
$this->query->where(
$this->getQualifiedForeignPivotKeyName(), '=', $this->parent->{$this->parentKey}
);
return $this;
} | [
"protected",
"function",
"addWhereConstraints",
"(",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"where",
"(",
"$",
"this",
"->",
"getQualifiedForeignPivotKeyName",
"(",
")",
",",
"'='",
",",
"$",
"this",
"->",
"parent",
"->",
"{",
"$",
"this",
"->",
"pa... | Set the where clause for the relation query.
@return $this | [
"Set",
"the",
"where",
"clause",
"for",
"the",
"relation",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L220-L227 | train | Add where constraints for the related objects | [
30522,
5123,
3853,
5587,
2860,
5886,
8586,
5644,
23654,
3215,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
23032,
1011,
1028,
2073,
1006,
1002,
2023,
30524,
7416,
16206,
8197,
22994,
14839,
18442,
1006,
1007,
1010,
1005,
1027,
1005,
1010,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OpenPlatform/Application.php | Application.getReplaceServices | protected function getReplaceServices(AccessToken $accessToken = null): array
{
$services = [
'access_token' => $accessToken ?: function ($app) {
return new AccessToken($app, $this);
},
'server' => function ($app) {
return new Guard($app);
},
];
foreach (['cache', 'http_client', 'log', 'logger', 'request'] as $reuse) {
if (isset($this[$reuse])) {
$services[$reuse] = $this[$reuse];
}
}
return $services;
} | php | protected function getReplaceServices(AccessToken $accessToken = null): array
{
$services = [
'access_token' => $accessToken ?: function ($app) {
return new AccessToken($app, $this);
},
'server' => function ($app) {
return new Guard($app);
},
];
foreach (['cache', 'http_client', 'log', 'logger', 'request'] as $reuse) {
if (isset($this[$reuse])) {
$services[$reuse] = $this[$reuse];
}
}
return $services;
} | [
"protected",
"function",
"getReplaceServices",
"(",
"AccessToken",
"$",
"accessToken",
"=",
"null",
")",
":",
"array",
"{",
"$",
"services",
"=",
"[",
"'access_token'",
"=>",
"$",
"accessToken",
"?",
":",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"n... | @param \EasyWeChat\OpenPlatform\Authorizer\Auth\AccessToken|null $accessToken
@return array | [
"@param",
"\\",
"EasyWeChat",
"\\",
"OpenPlatform",
"\\",
"Authorizer",
"\\",
"Auth",
"\\",
"AccessToken|null",
"$accessToken"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenPlatform/Application.php#L187-L206 | train | Get Replace Services | [
30522,
5123,
3853,
2131,
2890,
24759,
10732,
8043,
7903,
2229,
1006,
3229,
18715,
2368,
1002,
3229,
18715,
2368,
1027,
19701,
1007,
1024,
9140,
1063,
1002,
2578,
1027,
1031,
1005,
3229,
1035,
19204,
1005,
1027,
1028,
1002,
3229,
18715,
2368... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/CombineAssets.php | CombineAssets.resetAliases | public function resetAliases($extension = null)
{
if ($extension === null) {
$this->aliases = [];
}
else {
$this->aliases[$extension] = [];
}
return $this;
} | php | public function resetAliases($extension = null)
{
if ($extension === null) {
$this->aliases = [];
}
else {
$this->aliases[$extension] = [];
}
return $this;
} | [
"public",
"function",
"resetAliases",
"(",
"$",
"extension",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"extension",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"aliases",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"aliases",
"[",
"$",
... | Clears any registered aliases.
@param string $extension Extension name. Eg: css
@return self | [
"Clears",
"any",
"registered",
"aliases",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L721-L731 | train | Reset aliases. | [
30522,
2270,
3853,
25141,
22786,
8583,
1006,
1002,
5331,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
5331,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
14593,
2229,
1027,
1031,
1033,
1025,
1065,
2842,
1063,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/CodeParser.php | CodeParser.handleCorruptCache | protected function handleCorruptCache($data)
{
$path = array_get($data, 'filePath', $this->getCacheFilePath());
if (is_file($path)) {
if (($className = $this->extractClassFromFile($path)) && class_exists($className)) {
$data['className'] = $className;
return $data;
}
@unlink($path);
}
unset(self::$cache[$this->filePath]);
return $this->parse();
} | php | protected function handleCorruptCache($data)
{
$path = array_get($data, 'filePath', $this->getCacheFilePath());
if (is_file($path)) {
if (($className = $this->extractClassFromFile($path)) && class_exists($className)) {
$data['className'] = $className;
return $data;
}
@unlink($path);
}
unset(self::$cache[$this->filePath]);
return $this->parse();
} | [
"protected",
"function",
"handleCorruptCache",
"(",
"$",
"data",
")",
"{",
"$",
"path",
"=",
"array_get",
"(",
"$",
"data",
",",
"'filePath'",
",",
"$",
"this",
"->",
"getCacheFilePath",
"(",
")",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
... | In some rare cases the cache file will not contain the class
name we expect. When this happens, destroy the corrupt file,
flush the request cache, and repeat the cycle.
@return void | [
"In",
"some",
"rare",
"cases",
"the",
"cache",
"file",
"will",
"not",
"contain",
"the",
"class",
"name",
"we",
"expect",
".",
"When",
"this",
"happens",
"destroy",
"the",
"corrupt",
"file",
"flush",
"the",
"request",
"cache",
"and",
"repeat",
"the",
"cycle... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/CodeParser.php#L190-L206 | train | Handle corrupt cache | [
30522,
5123,
3853,
5047,
27108,
21531,
13535,
15395,
1006,
1002,
2951,
1007,
1063,
1002,
4130,
1027,
9140,
1035,
2131,
1006,
1002,
2951,
1010,
1005,
5371,
15069,
1005,
1010,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
8873,
2571,
15069,
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 | plugins/GeoIp2/GeoIP2AutoUpdater.php | GeoIP2AutoUpdater.downloadFile | protected function downloadFile($dbType, $url)
{
$url = trim($url);
$ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);
// NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity
$zippedFilename = LocationProviderGeoIp2::$dbNames[$dbType][0] . '.' . $ext;
$zippedOutputPath = LocationProviderGeoIp2::getPathForGeoIpDatabase($zippedFilename);
$url = self::removeDateFromUrl($url);
// download zipped file to misc dir
try {
$success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath': " . $ex->getMessage());
}
if ($success !== true) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath'! (Unknown error)");
}
Log::info("GeoIP2AutoUpdater: successfully downloaded '%s'", $url);
try {
self::unzipDownloadedFile($zippedOutputPath, $dbType, $unlink = true);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after "
. "downloading " . "'$url': " . $ex->getMessage());
}
Log::info("GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'", $url);
} | php | protected function downloadFile($dbType, $url)
{
$url = trim($url);
$ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);
// NOTE: using the first item in $dbNames[$dbType] makes sure GeoLiteCity will be renamed to GeoIPCity
$zippedFilename = LocationProviderGeoIp2::$dbNames[$dbType][0] . '.' . $ext;
$zippedOutputPath = LocationProviderGeoIp2::getPathForGeoIpDatabase($zippedFilename);
$url = self::removeDateFromUrl($url);
// download zipped file to misc dir
try {
$success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath': " . $ex->getMessage());
}
if ($success !== true) {
throw new Exception("GeoIP2AutoUpdater: failed to download '$url' to "
. "'$zippedOutputPath'! (Unknown error)");
}
Log::info("GeoIP2AutoUpdater: successfully downloaded '%s'", $url);
try {
self::unzipDownloadedFile($zippedOutputPath, $dbType, $unlink = true);
} catch (Exception $ex) {
throw new Exception("GeoIP2AutoUpdater: failed to unzip '$zippedOutputPath' after "
. "downloading " . "'$url': " . $ex->getMessage());
}
Log::info("GeoIP2AutoUpdater: successfully updated GeoIP 2 database '%s'", $url);
} | [
"protected",
"function",
"downloadFile",
"(",
"$",
"dbType",
",",
"$",
"url",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"$",
"ext",
"=",
"GeoIP2AutoUpdater",
"::",
"getGeoIPUrlExtension",
"(",
"$",
"url",
")",
";",
"// NOTE: using the... | Downloads a GeoIP 2 database archive, extracts the .mmdb file and overwrites the existing
old database.
If something happens that causes the download to fail, no exception is thrown, but
an error is logged.
@param string $dbType
@param string $url URL to the database to download. The type of database is determined
from this URL.
@throws Exception | [
"Downloads",
"a",
"GeoIP",
"2",
"database",
"archive",
"extracts",
"the",
".",
"mmdb",
"file",
"and",
"overwrites",
"the",
"existing",
"old",
"database",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/GeoIP2AutoUpdater.php#L123-L159 | train | Download a zipped file to misc dir | [
30522,
5123,
3853,
8816,
8873,
2571,
1006,
1002,
16962,
13874,
1010,
1002,
24471,
2140,
1007,
1063,
1002,
24471,
2140,
1027,
12241,
1006,
1002,
24471,
2140,
1007,
1025,
1002,
4654,
2102,
1027,
20248,
11514,
2475,
4887,
24826,
17299,
24932,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.add_info | public function add_info($label, $value)
{
$canvas = $this->getCanvas();
if (!is_null($canvas)) {
$canvas->add_info($label, $value);
}
} | php | public function add_info($label, $value)
{
$canvas = $this->getCanvas();
if (!is_null($canvas)) {
$canvas->add_info($label, $value);
}
} | [
"public",
"function",
"add_info",
"(",
"$",
"label",
",",
"$",
"value",
")",
"{",
"$",
"canvas",
"=",
"$",
"this",
"->",
"getCanvas",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"canvas",
")",
")",
"{",
"$",
"canvas",
"->",
"add_info",
"(... | Add meta information to the PDF after rendering | [
"Add",
"meta",
"information",
"to",
"the",
"PDF",
"after",
"rendering"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L877-L883 | train | Add info to the page | [
30522,
2270,
3853,
5587,
1035,
18558,
1006,
1002,
3830,
1010,
1002,
3643,
1007,
1063,
1002,
10683,
1027,
1002,
2023,
1011,
1028,
2131,
9336,
12044,
1006,
1007,
1025,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
10683,
1007,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.