repo stringclasses 21 values | path stringlengths 10 105 | func_name stringlengths 6 64 | original_string stringlengths 105 15.6k | language stringclasses 1 value | code stringlengths 105 15.6k | code_tokens listlengths 29 2.15k | docstring stringlengths 11 2.85k | docstring_tokens listlengths 1 290 | sha stringclasses 21 values | url stringlengths 100 194 | partition stringclasses 1 value | summary stringlengths 8 319 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
symfony/symfony | src/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReader.php | BundleEntryReader.readEntry | public function readEntry($path, $locale, array $indices, $fallback = true)
{
$entry = null;
$isMultiValued = false;
$readSucceeded = false;
$exception = null;
$currentLocale = $locale;
$testedLocales = [];
while (null !== $currentLocale) {
// Resolve any aliases to their target locales
if (isset($this->localeAliases[$currentLocale])) {
$currentLocale = $this->localeAliases[$currentLocale];
}
try {
$data = $this->reader->read($path, $currentLocale);
$currentEntry = RecursiveArrayAccess::get($data, $indices);
$readSucceeded = true;
$isCurrentTraversable = $currentEntry instanceof \Traversable;
$isCurrentMultiValued = $isCurrentTraversable || \is_array($currentEntry);
// Return immediately if fallback is disabled or we are dealing
// with a scalar non-null entry
if (!$fallback || (!$isCurrentMultiValued && null !== $currentEntry)) {
return $currentEntry;
}
// =========================================================
// Fallback is enabled, entry is either multi-valued or NULL
// =========================================================
// If entry is multi-valued, convert to array
if ($isCurrentTraversable) {
$currentEntry = iterator_to_array($currentEntry);
}
// If previously read entry was multi-valued too, merge them
if ($isCurrentMultiValued && $isMultiValued) {
$currentEntry = array_merge($currentEntry, $entry);
}
// Keep the previous entry if the current entry is NULL
if (null !== $currentEntry) {
$entry = $currentEntry;
}
// If this or the previous entry was multi-valued, we are dealing
// with a merged, multi-valued entry now
$isMultiValued = $isMultiValued || $isCurrentMultiValued;
} catch (ResourceBundleNotFoundException $e) {
// Continue if there is a fallback locale for the current
// locale
$exception = $e;
} catch (OutOfBoundsException $e) {
// Remember exception and rethrow if we cannot find anything in
// the fallback locales either
$exception = $e;
}
// Remember which locales we tried
$testedLocales[] = $currentLocale;
// Check whether fallback is allowed
if (!$fallback) {
break;
}
// Then determine fallback locale
$currentLocale = Locale::getFallback($currentLocale);
}
// Multi-valued entry was merged
if ($isMultiValued) {
return $entry;
}
// Entry is still NULL, but no read error occurred
if ($readSucceeded) {
return $entry;
}
// Entry is still NULL, read error occurred. Throw an exception
// containing the detailed path and locale
$errorMessage = sprintf(
'Couldn\'t read the indices [%s] for the locale "%s" in "%s".',
implode('][', $indices),
$locale,
$path
);
// Append fallback locales, if any
if (\count($testedLocales) > 1) {
// Remove original locale
array_shift($testedLocales);
$errorMessage .= sprintf(
' The indices also couldn\'t be found for the fallback locale(s) "%s".',
implode('", "', $testedLocales)
);
}
throw new MissingResourceException($errorMessage, 0, $exception);
} | php | public function readEntry($path, $locale, array $indices, $fallback = true)
{
$entry = null;
$isMultiValued = false;
$readSucceeded = false;
$exception = null;
$currentLocale = $locale;
$testedLocales = [];
while (null !== $currentLocale) {
// Resolve any aliases to their target locales
if (isset($this->localeAliases[$currentLocale])) {
$currentLocale = $this->localeAliases[$currentLocale];
}
try {
$data = $this->reader->read($path, $currentLocale);
$currentEntry = RecursiveArrayAccess::get($data, $indices);
$readSucceeded = true;
$isCurrentTraversable = $currentEntry instanceof \Traversable;
$isCurrentMultiValued = $isCurrentTraversable || \is_array($currentEntry);
// Return immediately if fallback is disabled or we are dealing
// with a scalar non-null entry
if (!$fallback || (!$isCurrentMultiValued && null !== $currentEntry)) {
return $currentEntry;
}
// =========================================================
// Fallback is enabled, entry is either multi-valued or NULL
// =========================================================
// If entry is multi-valued, convert to array
if ($isCurrentTraversable) {
$currentEntry = iterator_to_array($currentEntry);
}
// If previously read entry was multi-valued too, merge them
if ($isCurrentMultiValued && $isMultiValued) {
$currentEntry = array_merge($currentEntry, $entry);
}
// Keep the previous entry if the current entry is NULL
if (null !== $currentEntry) {
$entry = $currentEntry;
}
// If this or the previous entry was multi-valued, we are dealing
// with a merged, multi-valued entry now
$isMultiValued = $isMultiValued || $isCurrentMultiValued;
} catch (ResourceBundleNotFoundException $e) {
// Continue if there is a fallback locale for the current
// locale
$exception = $e;
} catch (OutOfBoundsException $e) {
// Remember exception and rethrow if we cannot find anything in
// the fallback locales either
$exception = $e;
}
// Remember which locales we tried
$testedLocales[] = $currentLocale;
// Check whether fallback is allowed
if (!$fallback) {
break;
}
// Then determine fallback locale
$currentLocale = Locale::getFallback($currentLocale);
}
// Multi-valued entry was merged
if ($isMultiValued) {
return $entry;
}
// Entry is still NULL, but no read error occurred
if ($readSucceeded) {
return $entry;
}
// Entry is still NULL, read error occurred. Throw an exception
// containing the detailed path and locale
$errorMessage = sprintf(
'Couldn\'t read the indices [%s] for the locale "%s" in "%s".',
implode('][', $indices),
$locale,
$path
);
// Append fallback locales, if any
if (\count($testedLocales) > 1) {
// Remove original locale
array_shift($testedLocales);
$errorMessage .= sprintf(
' The indices also couldn\'t be found for the fallback locale(s) "%s".',
implode('", "', $testedLocales)
);
}
throw new MissingResourceException($errorMessage, 0, $exception);
} | [
"public",
"function",
"readEntry",
"(",
"$",
"path",
",",
"$",
"locale",
",",
"array",
"$",
"indices",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"$",
"entry",
"=",
"null",
";",
"$",
"isMultiValued",
"=",
"false",
";",
"$",
"readSucceeded",
"=",
"f... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReader.php#L72-L176 | train | Reads the entry from the reader for the given locale and indices | [
30522,
2270,
3853,
3191,
4765,
2854,
1006,
1002,
4130,
1010,
1002,
2334,
2063,
1010,
9140,
1002,
29299,
1010,
1002,
2991,
5963,
1027,
2995,
1007,
1063,
1002,
4443,
1027,
19701,
1025,
1002,
2003,
12274,
7096,
11444,
7630,
2098,
1027,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php | MemcachedSessionHandler.updateTimestamp | public function updateTimestamp($sessionId, $data)
{
$this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl);
return true;
} | php | public function updateTimestamp($sessionId, $data)
{
$this->memcached->touch($this->prefix.$sessionId, time() + $this->ttl);
return true;
} | [
"public",
"function",
"updateTimestamp",
"(",
"$",
"sessionId",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"memcached",
"->",
"touch",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"sessionId",
",",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"ttl",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php#L79-L84 | train | Update the timestamp of a session | [
30522,
2270,
3853,
10651,
7292,
9153,
8737,
1006,
1002,
5219,
3593,
1010,
1002,
2951,
1007,
1063,
1002,
2023,
1011,
1028,
2033,
12458,
15395,
2094,
1011,
1028,
3543,
1006,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
5219,
3593,
1010,
2051,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Console/ExtendCommand.php | ExtendCommand.handle | public function handle(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
$this->extensionDir = config('admin.extension_dir');
InputExtensionDir:
if (empty($this->extensionDir)) {
$this->extensionDir = $this->ask('Please input a directory to store your extension:');
}
if (!file_exists($this->extensionDir)) {
$this->makeDir();
}
$this->package = $this->argument('extension');
InputExtensionName:
if (!$this->validateExtensionName($this->package)) {
$this->package = $this->ask("[$this->package] is not a valid package name, please input a name like (<vendor>/<name>)");
goto InputExtensionName;
}
$this->makeDirs();
$this->makeFiles();
$this->info("The extension scaffolding generated successfully. \r\n");
$this->showTree();
} | php | public function handle(Filesystem $filesystem)
{
$this->filesystem = $filesystem;
$this->extensionDir = config('admin.extension_dir');
InputExtensionDir:
if (empty($this->extensionDir)) {
$this->extensionDir = $this->ask('Please input a directory to store your extension:');
}
if (!file_exists($this->extensionDir)) {
$this->makeDir();
}
$this->package = $this->argument('extension');
InputExtensionName:
if (!$this->validateExtensionName($this->package)) {
$this->package = $this->ask("[$this->package] is not a valid package name, please input a name like (<vendor>/<name>)");
goto InputExtensionName;
}
$this->makeDirs();
$this->makeFiles();
$this->info("The extension scaffolding generated successfully. \r\n");
$this->showTree();
} | [
"public",
"function",
"handle",
"(",
"Filesystem",
"$",
"filesystem",
")",
"{",
"$",
"this",
"->",
"filesystem",
"=",
"$",
"filesystem",
";",
"$",
"this",
"->",
"extensionDir",
"=",
"config",
"(",
"'admin.extension_dir'",
")",
";",
"InputExtensionDir",
":",
... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/ExtendCommand.php#L72-L100 | train | Handle the extension scaffolding | [
30522,
2270,
3853,
5047,
1006,
6764,
27268,
6633,
1002,
6764,
27268,
6633,
1007,
1063,
1002,
2023,
1011,
1028,
6764,
27268,
6633,
1027,
1002,
6764,
27268,
6633,
1025,
1002,
2023,
1011,
1028,
5331,
4305,
2099,
1027,
9530,
8873,
2290,
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... |
barryvdh/laravel-debugbar | src/DataCollector/QueryCollector.php | QueryCollector.performQueryAnalysis | protected function performQueryAnalysis($query)
{
$hints = [];
if (preg_match('/^\\s*SELECT\\s*`?[a-zA-Z0-9]*`?\\.?\\*/i', $query)) {
$hints[] = 'Use <code>SELECT *</code> only if you need all columns from table';
}
if (preg_match('/ORDER BY RAND()/i', $query)) {
$hints[] = '<code>ORDER BY RAND()</code> is slow, try to avoid if you can.
You can <a href="http://stackoverflow.com/questions/2663710/how-does-mysqls-order-by-rand-work" target="_blank">read this</a>
or <a href="http://stackoverflow.com/questions/1244555/how-can-i-optimize-mysqls-order-by-rand-function" target="_blank">this</a>';
}
if (strpos($query, '!=') !== false) {
$hints[] = 'The <code>!=</code> operator is not standard. Use the <code><></code> operator to test for inequality instead.';
}
if (stripos($query, 'WHERE') === false && preg_match('/^(SELECT) /i', $query)) {
$hints[] = 'The <code>SELECT</code> statement has no <code>WHERE</code> clause and could examine many more rows than intended';
}
if (preg_match('/LIMIT\\s/i', $query) && stripos($query, 'ORDER BY') === false) {
$hints[] = '<code>LIMIT</code> without <code>ORDER BY</code> causes non-deterministic results, depending on the query execution plan';
}
if (preg_match('/LIKE\\s[\'"](%.*?)[\'"]/i', $query, $matches)) {
$hints[] = 'An argument has a leading wildcard character: <code>' . $matches[1]. '</code>.
The predicate with this argument is not sargable and cannot use an index if one exists.';
}
return $hints;
} | php | protected function performQueryAnalysis($query)
{
$hints = [];
if (preg_match('/^\\s*SELECT\\s*`?[a-zA-Z0-9]*`?\\.?\\*/i', $query)) {
$hints[] = 'Use <code>SELECT *</code> only if you need all columns from table';
}
if (preg_match('/ORDER BY RAND()/i', $query)) {
$hints[] = '<code>ORDER BY RAND()</code> is slow, try to avoid if you can.
You can <a href="http://stackoverflow.com/questions/2663710/how-does-mysqls-order-by-rand-work" target="_blank">read this</a>
or <a href="http://stackoverflow.com/questions/1244555/how-can-i-optimize-mysqls-order-by-rand-function" target="_blank">this</a>';
}
if (strpos($query, '!=') !== false) {
$hints[] = 'The <code>!=</code> operator is not standard. Use the <code><></code> operator to test for inequality instead.';
}
if (stripos($query, 'WHERE') === false && preg_match('/^(SELECT) /i', $query)) {
$hints[] = 'The <code>SELECT</code> statement has no <code>WHERE</code> clause and could examine many more rows than intended';
}
if (preg_match('/LIMIT\\s/i', $query) && stripos($query, 'ORDER BY') === false) {
$hints[] = '<code>LIMIT</code> without <code>ORDER BY</code> causes non-deterministic results, depending on the query execution plan';
}
if (preg_match('/LIKE\\s[\'"](%.*?)[\'"]/i', $query, $matches)) {
$hints[] = 'An argument has a leading wildcard character: <code>' . $matches[1]. '</code>.
The predicate with this argument is not sargable and cannot use an index if one exists.';
}
return $hints;
} | [
"protected",
"function",
"performQueryAnalysis",
"(",
"$",
"query",
")",
"{",
"$",
"hints",
"=",
"[",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'/^\\\\s*SELECT\\\\s*`?[a-zA-Z0-9]*`?\\\\.?\\\\*/i'",
",",
"$",
"query",
")",
")",
"{",
"$",
"hints",
"[",
"]",
"="... | Explainer::performQueryAnalysis()
Perform simple regex analysis on the code
@package xplain (https://github.com/rap2hpoutre/mysql-xplain-xplain)
@author e-doceo
@copyright 2014
@version $Id$
@access public
@param string $query
@return string | [
"Explainer",
"::",
"performQueryAnalysis",
"()"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/QueryCollector.php#L161-L186 | train | Perform the analysis of the query | [
30522,
5123,
3853,
4685,
4226,
20444,
12032,
20960,
1006,
1002,
23032,
1007,
1063,
1002,
20385,
1027,
1031,
1033,
1025,
2065,
1006,
3653,
2290,
1035,
2674,
1006,
1005,
1013,
1034,
1032,
1032,
1055,
1008,
7276,
1032,
1032,
1055,
1008,
1036,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Tools.php | Tools.disableView | public function disableView(bool $disable = true)
{
if ($disable) {
array_delete($this->tools, 'view');
} elseif (!in_array('view', $this->tools)) {
array_push($this->tools, 'view');
}
return $this;
} | php | public function disableView(bool $disable = true)
{
if ($disable) {
array_delete($this->tools, 'view');
} elseif (!in_array('view', $this->tools)) {
array_push($this->tools, 'view');
}
return $this;
} | [
"public",
"function",
"disableView",
"(",
"bool",
"$",
"disable",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"disable",
")",
"{",
"array_delete",
"(",
"$",
"this",
"->",
"tools",
",",
"'view'",
")",
";",
"}",
"elseif",
"(",
"!",
"in_array",
"(",
"'view'"... | Disable `edit` tool.
@return $this | [
"Disable",
"edit",
"tool",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Tools.php#L115-L124 | train | Disable view tools | [
30522,
2270,
3853,
4487,
19150,
8584,
1006,
22017,
2140,
1002,
4487,
19150,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
4487,
19150,
1007,
1063,
9140,
1035,
3972,
12870,
1006,
1002,
2023,
1011,
1028,
5906,
1010,
1005,
3193,
1005,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Show/Field.php | Field.image | public function image($server = '', $width = 200, $height = 200)
{
return $this->unescape()->as(function ($images) use ($server, $width, $height) {
return collect($images)->map(function ($path) use ($server, $width, $height) {
if (empty($path)) {
return '';
}
if (url()->isValidUrl($path)) {
$src = $path;
} elseif ($server) {
$src = $server.$path;
} else {
$disk = config('admin.upload.disk');
if (config("filesystems.disks.{$disk}")) {
$src = Storage::disk($disk)->url($path);
} else {
return '';
}
}
return "<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img' />";
})->implode(' ');
});
} | php | public function image($server = '', $width = 200, $height = 200)
{
return $this->unescape()->as(function ($images) use ($server, $width, $height) {
return collect($images)->map(function ($path) use ($server, $width, $height) {
if (empty($path)) {
return '';
}
if (url()->isValidUrl($path)) {
$src = $path;
} elseif ($server) {
$src = $server.$path;
} else {
$disk = config('admin.upload.disk');
if (config("filesystems.disks.{$disk}")) {
$src = Storage::disk($disk)->url($path);
} else {
return '';
}
}
return "<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img' />";
})->implode(' ');
});
} | [
"public",
"function",
"image",
"(",
"$",
"server",
"=",
"''",
",",
"$",
"width",
"=",
"200",
",",
"$",
"height",
"=",
"200",
")",
"{",
"return",
"$",
"this",
"->",
"unescape",
"(",
")",
"->",
"as",
"(",
"function",
"(",
"$",
"images",
")",
"use",... | Show field as a image.
@param string $server
@param int $width
@param int $height
@return $this | [
"Show",
"field",
"as",
"a",
"image",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show/Field.php#L211-L236 | train | Return an array of images | [
30522,
2270,
3853,
3746,
1006,
1002,
8241,
1027,
1005,
1005,
1010,
1002,
9381,
1027,
3263,
1010,
1002,
4578,
1027,
3263,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
16655,
15782,
5051,
1006,
1007,
1011,
1028,
2004,
1006,
3853,
1006,
1002,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.verifyNonce | public static function verifyNonce($nonce, $action)
{
//Safety check for multiple nonces
if (is_array($nonce)) {
$nonce = array_shift($nonce);
}
//Nonce generated 0-12 hours ago
if ($nonce === self::getNonce($action)) {
return true;
}
//Nonce generated 12-24 hours ago
$previousTick = true;
return $nonce === self::getNonce($action, $previousTick);
} | php | public static function verifyNonce($nonce, $action)
{
//Safety check for multiple nonces
if (is_array($nonce)) {
$nonce = array_shift($nonce);
}
//Nonce generated 0-12 hours ago
if ($nonce === self::getNonce($action)) {
return true;
}
//Nonce generated 12-24 hours ago
$previousTick = true;
return $nonce === self::getNonce($action, $previousTick);
} | [
"public",
"static",
"function",
"verifyNonce",
"(",
"$",
"nonce",
",",
"$",
"action",
")",
"{",
"//Safety check for multiple nonces",
"if",
"(",
"is_array",
"(",
"$",
"nonce",
")",
")",
"{",
"$",
"nonce",
"=",
"array_shift",
"(",
"$",
"nonce",
")",
";",
... | Verify the passed nonce for the give action
@param string|string[] $nonce the nonce to verify
@param string $action the action to verify the nonce to
@return boolean verified or not | [
"Verify",
"the",
"passed",
"nonce",
"for",
"the",
"give",
"action"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L1123-L1139 | train | Verify if a nonce is valid for an action | [
30522,
2270,
10763,
3853,
20410,
8540,
3401,
1006,
1002,
2512,
3401,
1010,
1002,
2895,
1007,
1063,
1013,
1013,
3808,
4638,
2005,
3674,
2512,
9623,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2512,
3401,
1007,
1007,
1063,
1002,
2512,
3401,
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/Queue/SyncQueue.php | SyncQueue.raiseBeforeJobEvent | protected function raiseBeforeJobEvent(Job $job)
{
if ($this->container->bound('events')) {
$this->container['events']->dispatch(new Events\JobProcessing($this->connectionName, $job));
}
} | php | protected function raiseBeforeJobEvent(Job $job)
{
if ($this->container->bound('events')) {
$this->container['events']->dispatch(new Events\JobProcessing($this->connectionName, $job));
}
} | [
"protected",
"function",
"raiseBeforeJobEvent",
"(",
"Job",
"$",
"job",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"bound",
"(",
"'events'",
")",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'events'",
"]",
"->",
"dispatch",
"(",
"ne... | Raise the before queue job event.
@param \Illuminate\Contracts\Queue\Job $job
@return void | [
"Raise",
"the",
"before",
"queue",
"job",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/SyncQueue.php#L72-L77 | train | Raise before job event | [
30522,
5123,
3853,
5333,
4783,
29278,
20518,
20891,
15338,
1006,
3105,
1002,
3105,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11661,
1011,
1028,
5391,
1006,
1005,
2824,
1005,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
11661,
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... |
symfony/symfony | src/Symfony/Component/Config/Resource/DirectoryResource.php | DirectoryResource.isFresh | public function isFresh($timestamp)
{
if (!is_dir($this->resource)) {
return false;
}
if ($timestamp < filemtime($this->resource)) {
return false;
}
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
// if regex filtering is enabled only check matching files
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
continue;
}
// always monitor directories for changes, except the .. entries
// (otherwise deleted files wouldn't get detected)
if ($file->isDir() && '/..' === substr($file, -3)) {
continue;
}
// for broken links
try {
$fileMTime = $file->getMTime();
} catch (\RuntimeException $e) {
continue;
}
// early return if a file's mtime exceeds the passed timestamp
if ($timestamp < $fileMTime) {
return false;
}
}
return true;
} | php | public function isFresh($timestamp)
{
if (!is_dir($this->resource)) {
return false;
}
if ($timestamp < filemtime($this->resource)) {
return false;
}
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
// if regex filtering is enabled only check matching files
if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
continue;
}
// always monitor directories for changes, except the .. entries
// (otherwise deleted files wouldn't get detected)
if ($file->isDir() && '/..' === substr($file, -3)) {
continue;
}
// for broken links
try {
$fileMTime = $file->getMTime();
} catch (\RuntimeException $e) {
continue;
}
// early return if a file's mtime exceeds the passed timestamp
if ($timestamp < $fileMTime) {
return false;
}
}
return true;
} | [
"public",
"function",
"isFresh",
"(",
"$",
"timestamp",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"timestamp",
"<",
"filemtime",
"(",
"$",
"this",
"->",
"reso... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Resource/DirectoryResource.php#L71-L107 | train | Returns true if the directory is fresh enough | [
30522,
2270,
3853,
2003,
19699,
9953,
1006,
1002,
2335,
15464,
2361,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16101,
1006,
1002,
2023,
1011,
1028,
7692,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
2065,
1006,
1002,
2335,
15464,
2361,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.bindParam | public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
if (!is_int($parameter) && !is_string($parameter)) {
/**
* @see Zend_Db_Statement_Exception
*/
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception('Invalid bind-variable position');
}
$position = null;
if (($intval = (int) $parameter) > 0 && $this->_adapter->supportsParameters('positional')) {
if ($intval >= 1 || $intval <= count($this->_sqlParam)) {
$position = $intval;
}
} else if ($this->_adapter->supportsParameters('named')) {
if ($parameter[0] != ':') {
$parameter = ':' . $parameter;
}
if (in_array($parameter, $this->_sqlParam) !== false) {
$position = $parameter;
}
}
if ($position === null) {
/**
* @see Zend_Db_Statement_Exception
*/
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$parameter'");
}
// Finally we are assured that $position is valid
$this->_bindParam[$position] =& $variable;
return $this->_bindParam($position, $variable, $type, $length, $options);
} | php | public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
if (!is_int($parameter) && !is_string($parameter)) {
/**
* @see Zend_Db_Statement_Exception
*/
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception('Invalid bind-variable position');
}
$position = null;
if (($intval = (int) $parameter) > 0 && $this->_adapter->supportsParameters('positional')) {
if ($intval >= 1 || $intval <= count($this->_sqlParam)) {
$position = $intval;
}
} else if ($this->_adapter->supportsParameters('named')) {
if ($parameter[0] != ':') {
$parameter = ':' . $parameter;
}
if (in_array($parameter, $this->_sqlParam) !== false) {
$position = $parameter;
}
}
if ($position === null) {
/**
* @see Zend_Db_Statement_Exception
*/
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception("Invalid bind-variable position '$parameter'");
}
// Finally we are assured that $position is valid
$this->_bindParam[$position] =& $variable;
return $this->_bindParam($position, $variable, $type, $length, $options);
} | [
"public",
"function",
"bindParam",
"(",
"$",
"parameter",
",",
"&",
"$",
"variable",
",",
"$",
"type",
"=",
"null",
",",
"$",
"length",
"=",
"null",
",",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"parameter",
")",
... | Binds a parameter to the specified variable name.
@param mixed $parameter Name the parameter, either integer or string.
@param mixed $variable Reference to PHP variable containing the value.
@param mixed $type OPTIONAL Datatype of SQL parameter.
@param mixed $length OPTIONAL Length of SQL parameter.
@param mixed $options OPTIONAL Other options.
@return bool | [
"Binds",
"a",
"parameter",
"to",
"the",
"specified",
"variable",
"name",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement.php#L238-L273 | train | Bind a parameter to a variable | [
30522,
2270,
3853,
14187,
28689,
2213,
1006,
1002,
16381,
1010,
1004,
1002,
8023,
1010,
1002,
2828,
1027,
19701,
1010,
1002,
3091,
1027,
19701,
1010,
1002,
7047,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2003,
1035,
20014,
1006,
1002,
16381... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/traits/AssetMaker.php | AssetMaker.removeDuplicates | protected function removeDuplicates()
{
foreach ($this->assets as $type => &$collection) {
$pathCache = [];
foreach ($collection as $key => $asset) {
if (!$path = array_get($asset, 'path')) {
continue;
}
if (isset($pathCache[$path])) {
array_forget($collection, $key);
continue;
}
$pathCache[$path] = true;
}
}
} | php | protected function removeDuplicates()
{
foreach ($this->assets as $type => &$collection) {
$pathCache = [];
foreach ($collection as $key => $asset) {
if (!$path = array_get($asset, 'path')) {
continue;
}
if (isset($pathCache[$path])) {
array_forget($collection, $key);
continue;
}
$pathCache[$path] = true;
}
}
} | [
"protected",
"function",
"removeDuplicates",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"assets",
"as",
"$",
"type",
"=>",
"&",
"$",
"collection",
")",
"{",
"$",
"pathCache",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"k... | Removes duplicate assets from the entire collection.
@return void | [
"Removes",
"duplicate",
"assets",
"from",
"the",
"entire",
"collection",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/AssetMaker.php#L307-L327 | train | Remove duplicates from assets | [
30522,
5123,
3853,
3718,
6279,
19341,
4570,
1006,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
7045,
2004,
1002,
2828,
1027,
1028,
1004,
1002,
3074,
1007,
1063,
1002,
4130,
3540,
5403,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php | NativePasswordEncoder.encodePassword | public function encodePassword($raw, $salt)
{
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) {
throw new BadCredentialsException('Invalid password.');
}
// Ignore $salt, the auto-generated one is always the best
$encoded = password_hash($raw, $this->algo, $this->options);
if (72 < \strlen($raw) && 0 === strpos($encoded, '$2')) {
// BCrypt encodes only the first 72 chars
throw new BadCredentialsException('Invalid password.');
}
return $encoded;
} | php | public function encodePassword($raw, $salt)
{
if (\strlen($raw) > self::MAX_PASSWORD_LENGTH) {
throw new BadCredentialsException('Invalid password.');
}
// Ignore $salt, the auto-generated one is always the best
$encoded = password_hash($raw, $this->algo, $this->options);
if (72 < \strlen($raw) && 0 === strpos($encoded, '$2')) {
// BCrypt encodes only the first 72 chars
throw new BadCredentialsException('Invalid password.');
}
return $encoded;
} | [
"public",
"function",
"encodePassword",
"(",
"$",
"raw",
",",
"$",
"salt",
")",
"{",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"raw",
")",
">",
"self",
"::",
"MAX_PASSWORD_LENGTH",
")",
"{",
"throw",
"new",
"BadCredentialsException",
"(",
"'Invalid password.'",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Encoder/NativePasswordEncoder.php#L60-L76 | train | Encode a password using BCrypt | [
30522,
2270,
3853,
4372,
16044,
15194,
18351,
1006,
1002,
6315,
1010,
1002,
5474,
1007,
1063,
2065,
1006,
1032,
2358,
20927,
2078,
1006,
1002,
6315,
1007,
1028,
2969,
1024,
1024,
4098,
1035,
20786,
1035,
3091,
1007,
1063,
5466,
2047,
2919,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SessionInitializer.php | SessionInitializer.initSession | public function initSession(AuthInterface $auth)
{
$this->regenerateSessionId();
$authResult = $this->doAuthenticateSession($auth);
if (!$authResult->wasAuthenticationSuccessful()) {
Piwik::postEvent('Login.authenticate.failed', array($auth->getLogin()));
$this->processFailedSession();
} else {
Piwik::postEvent('Login.authenticate.successful', array($auth->getLogin()));
$this->processSuccessfulSession($authResult);
}
} | php | public function initSession(AuthInterface $auth)
{
$this->regenerateSessionId();
$authResult = $this->doAuthenticateSession($auth);
if (!$authResult->wasAuthenticationSuccessful()) {
Piwik::postEvent('Login.authenticate.failed', array($auth->getLogin()));
$this->processFailedSession();
} else {
Piwik::postEvent('Login.authenticate.successful', array($auth->getLogin()));
$this->processSuccessfulSession($authResult);
}
} | [
"public",
"function",
"initSession",
"(",
"AuthInterface",
"$",
"auth",
")",
"{",
"$",
"this",
"->",
"regenerateSessionId",
"(",
")",
";",
"$",
"authResult",
"=",
"$",
"this",
"->",
"doAuthenticateSession",
"(",
"$",
"auth",
")",
";",
"if",
"(",
"!",
"$"... | Authenticates the user and, if successful, initializes an authenticated session.
@param \Piwik\Auth $auth The Auth implementation to use.
@throws Exception If authentication fails or the user is not allowed to login for some reason. | [
"Authenticates",
"the",
"user",
"and",
"if",
"successful",
"initializes",
"an",
"authenticated",
"session",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Session/SessionInitializer.php#L28-L45 | train | Initializes the session and processes the authentication result | [
30522,
2270,
3853,
1999,
12762,
7971,
3258,
1006,
8740,
15222,
10111,
12881,
10732,
1002,
8740,
2705,
1007,
1063,
1002,
2023,
1011,
1028,
19723,
24454,
8520,
7971,
3258,
3593,
1006,
1007,
1025,
1002,
8740,
2705,
6072,
11314,
1027,
1002,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SearchEngine.php | SearchEngine.extractInformationFromUrl | public function extractInformationFromUrl($referrerUrl)
{
$referrerParsed = @parse_url($referrerUrl);
$referrerHost = '';
if (isset($referrerParsed['host'])) {
$referrerHost = $referrerParsed['host'];
}
if (empty($referrerHost)) {
return false;
}
// some search engines (eg. Bing Images) use the same domain
// as an existing search engine (eg. Bing), we must also use the url path
$referrerPath = '';
if (isset($referrerParsed['path'])) {
$referrerPath = $referrerParsed['path'];
}
$query = '';
if (isset($referrerParsed['query'])) {
$query = $referrerParsed['query'];
}
// Google Referrers URLs sometimes have the fragment which contains the keyword
if (!empty($referrerParsed['fragment'])) {
$query .= '&' . $referrerParsed['fragment'];
}
$referrerHost = $this->getEngineHostFromUrl($referrerHost, $referrerPath, $query);
if (empty($referrerHost)) {
return false;
}
$definitions = $this->getDefinitionByHost($referrerHost);
$searchEngineName = $definitions['name'];
$variableNames = $definitions['params'];
$keywordsHiddenFor = !empty($definitions['hiddenkeyword']) ? $definitions['hiddenkeyword'] : array();
$key = null;
if ($searchEngineName === 'Google Images') {
if (strpos($query, '&prev') !== false) {
$query = urldecode(trim(UrlHelper::getParameterFromQueryString($query, 'prev')));
$query = str_replace('&', '&', strstr($query, '?'));
}
$searchEngineName = 'Google Images';
} elseif ($searchEngineName === 'Google'
&& (strpos($query, '&as_') !== false || strpos($query, 'as_') === 0)
) {
$keys = array();
$key = UrlHelper::getParameterFromQueryString($query, 'as_q');
if (!empty($key)) {
array_push($keys, $key);
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_oq');
if (!empty($key)) {
array_push($keys, str_replace('+', ' OR ', $key));
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_epq');
if (!empty($key)) {
array_push($keys, "\"$key\"");
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_eq');
if (!empty($key)) {
array_push($keys, "-$key");
}
$key = trim(urldecode(implode(' ', $keys)));
}
if ($searchEngineName === 'Google') {
// top bar menu
$tbm = UrlHelper::getParameterFromQueryString($query, 'tbm');
switch ($tbm) {
case 'isch':
$searchEngineName = 'Google Images';
break;
case 'vid':
$searchEngineName = 'Google Video';
break;
case 'shop':
$searchEngineName = 'Google Shopping';
break;
}
}
if (empty($key)) {
foreach ($variableNames as $variableName) {
if ($variableName[0] == '/') {
// regular expression match
if (preg_match($variableName, $referrerUrl, $matches)) {
$key = trim(urldecode($matches[1]));
break;
}
} else {
// search for keywords now &vname=keyword
$key = UrlHelper::getParameterFromQueryString($query, $variableName);
$key = trim(urldecode($key));
// Special cases: empty keywords
if (empty($key)
&& (
// empty keyword parameter
strpos($query, sprintf('&%s=', $variableName)) !== false
|| strpos($query, sprintf('?%s=', $variableName)) !== false
)
) {
$key = false;
}
if (!empty($key)
|| $key === false
) {
break;
}
}
}
}
// if no keyword found, but empty keywords are allowed
if (!empty($keywordsHiddenFor) && ($key === null || $key === '')) {
$pathWithQueryAndFragment = $referrerPath;
if (!empty($query)) {
$pathWithQueryAndFragment .= '?'.$query;
}
if (!empty($referrerParsed['fragment'])) {
$pathWithQueryAndFragment .= '#'.$referrerParsed['fragment'];
}
foreach ($keywordsHiddenFor as $path) {
if (strlen($path) > 1 && substr($path, 0, 1) == '/' && substr($path, -1, 1) == '/') {
if (preg_match($path, $pathWithQueryAndFragment)) {
$key = false;
break;
}
} elseif ($path == $pathWithQueryAndFragment) {
$key = false;
break;
}
}
}
// $key === false is the special case "No keyword provided" which is a Search engine match
if ($key === null || $key === '') {
return false;
}
if (!empty($key)) {
if (!empty($definitions['charsets'])) {
$key = $this->convertCharset($key, $definitions['charsets']);
}
$key = Common::mb_strtolower($key);
}
return array(
'name' => $searchEngineName,
'keywords' => $key,
);
} | php | public function extractInformationFromUrl($referrerUrl)
{
$referrerParsed = @parse_url($referrerUrl);
$referrerHost = '';
if (isset($referrerParsed['host'])) {
$referrerHost = $referrerParsed['host'];
}
if (empty($referrerHost)) {
return false;
}
// some search engines (eg. Bing Images) use the same domain
// as an existing search engine (eg. Bing), we must also use the url path
$referrerPath = '';
if (isset($referrerParsed['path'])) {
$referrerPath = $referrerParsed['path'];
}
$query = '';
if (isset($referrerParsed['query'])) {
$query = $referrerParsed['query'];
}
// Google Referrers URLs sometimes have the fragment which contains the keyword
if (!empty($referrerParsed['fragment'])) {
$query .= '&' . $referrerParsed['fragment'];
}
$referrerHost = $this->getEngineHostFromUrl($referrerHost, $referrerPath, $query);
if (empty($referrerHost)) {
return false;
}
$definitions = $this->getDefinitionByHost($referrerHost);
$searchEngineName = $definitions['name'];
$variableNames = $definitions['params'];
$keywordsHiddenFor = !empty($definitions['hiddenkeyword']) ? $definitions['hiddenkeyword'] : array();
$key = null;
if ($searchEngineName === 'Google Images') {
if (strpos($query, '&prev') !== false) {
$query = urldecode(trim(UrlHelper::getParameterFromQueryString($query, 'prev')));
$query = str_replace('&', '&', strstr($query, '?'));
}
$searchEngineName = 'Google Images';
} elseif ($searchEngineName === 'Google'
&& (strpos($query, '&as_') !== false || strpos($query, 'as_') === 0)
) {
$keys = array();
$key = UrlHelper::getParameterFromQueryString($query, 'as_q');
if (!empty($key)) {
array_push($keys, $key);
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_oq');
if (!empty($key)) {
array_push($keys, str_replace('+', ' OR ', $key));
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_epq');
if (!empty($key)) {
array_push($keys, "\"$key\"");
}
$key = UrlHelper::getParameterFromQueryString($query, 'as_eq');
if (!empty($key)) {
array_push($keys, "-$key");
}
$key = trim(urldecode(implode(' ', $keys)));
}
if ($searchEngineName === 'Google') {
// top bar menu
$tbm = UrlHelper::getParameterFromQueryString($query, 'tbm');
switch ($tbm) {
case 'isch':
$searchEngineName = 'Google Images';
break;
case 'vid':
$searchEngineName = 'Google Video';
break;
case 'shop':
$searchEngineName = 'Google Shopping';
break;
}
}
if (empty($key)) {
foreach ($variableNames as $variableName) {
if ($variableName[0] == '/') {
// regular expression match
if (preg_match($variableName, $referrerUrl, $matches)) {
$key = trim(urldecode($matches[1]));
break;
}
} else {
// search for keywords now &vname=keyword
$key = UrlHelper::getParameterFromQueryString($query, $variableName);
$key = trim(urldecode($key));
// Special cases: empty keywords
if (empty($key)
&& (
// empty keyword parameter
strpos($query, sprintf('&%s=', $variableName)) !== false
|| strpos($query, sprintf('?%s=', $variableName)) !== false
)
) {
$key = false;
}
if (!empty($key)
|| $key === false
) {
break;
}
}
}
}
// if no keyword found, but empty keywords are allowed
if (!empty($keywordsHiddenFor) && ($key === null || $key === '')) {
$pathWithQueryAndFragment = $referrerPath;
if (!empty($query)) {
$pathWithQueryAndFragment .= '?'.$query;
}
if (!empty($referrerParsed['fragment'])) {
$pathWithQueryAndFragment .= '#'.$referrerParsed['fragment'];
}
foreach ($keywordsHiddenFor as $path) {
if (strlen($path) > 1 && substr($path, 0, 1) == '/' && substr($path, -1, 1) == '/') {
if (preg_match($path, $pathWithQueryAndFragment)) {
$key = false;
break;
}
} elseif ($path == $pathWithQueryAndFragment) {
$key = false;
break;
}
}
}
// $key === false is the special case "No keyword provided" which is a Search engine match
if ($key === null || $key === '') {
return false;
}
if (!empty($key)) {
if (!empty($definitions['charsets'])) {
$key = $this->convertCharset($key, $definitions['charsets']);
}
$key = Common::mb_strtolower($key);
}
return array(
'name' => $searchEngineName,
'keywords' => $key,
);
} | [
"public",
"function",
"extractInformationFromUrl",
"(",
"$",
"referrerUrl",
")",
"{",
"$",
"referrerParsed",
"=",
"@",
"parse_url",
"(",
"$",
"referrerUrl",
")",
";",
"$",
"referrerHost",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"referrerParsed",
"[",
... | Extracts a keyword from a raw not encoded URL.
Will only extract keyword if a known search engine has been detected.
Returns the keyword:
- in UTF8: automatically converted from other charsets when applicable
- strtolowered: "QUErY test!" will return "query test!"
- trimmed: extra spaces before and after are removed
The function returns false when a keyword couldn't be found.
eg. if the url is "http://www.google.com/partners.html" this will return false,
as the google keyword parameter couldn't be found.
@see unit tests in /tests/core/Common.test.php
@param string $referrerUrl URL referrer URL, eg. $_SERVER['HTTP_REFERER']
@return array|bool false if a keyword couldn't be extracted,
or array(
'name' => 'Google',
'keywords' => 'my searched keywords') | [
"Extracts",
"a",
"keyword",
"from",
"a",
"raw",
"not",
"encoded",
"URL",
".",
"Will",
"only",
"extract",
"keyword",
"if",
"a",
"known",
"search",
"engine",
"has",
"been",
"detected",
".",
"Returns",
"the",
"keyword",
":",
"-",
"in",
"UTF8",
":",
"automat... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/SearchEngine.php#L190-L347 | train | Extracts information from a referrers URL | [
30522,
2270,
3853,
14817,
2378,
14192,
3370,
19699,
5358,
3126,
2140,
1006,
1002,
6523,
14544,
3126,
2140,
1007,
1063,
1002,
6523,
14544,
19362,
6924,
1027,
1030,
11968,
3366,
1035,
24471,
2140,
1006,
1002,
6523,
14544,
3126,
2140,
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... |
dompdf/dompdf | src/Image/Cache.php | Cache.resolve_url | static function resolve_url($url, $protocol, $host, $base_path, Dompdf $dompdf)
{
self::$_dompdf = $dompdf;
$protocol = mb_strtolower($protocol);
$parsed_url = Helpers::explode_url($url);
$message = null;
$remote = ($protocol && $protocol !== "file://") || ($parsed_url['protocol'] != "");
$data_uri = strpos($parsed_url['protocol'], "data:") === 0;
$full_url = null;
$enable_remote = $dompdf->getOptions()->getIsRemoteEnabled();
try {
// Remote not allowed and is not DataURI
if (!$enable_remote && $remote && !$data_uri) {
throw new ImageException("Remote file access is disabled.", E_WARNING);
} // Remote allowed or DataURI
else {
if ($enable_remote && $remote || $data_uri) {
// Download remote files to a temporary directory
$full_url = Helpers::build_url($protocol, $host, $base_path, $url);
// From cache
if (isset(self::$_cache[$full_url])) {
$resolved_url = self::$_cache[$full_url];
} // From remote
else {
$tmp_dir = $dompdf->getOptions()->getTempDir();
$resolved_url = @tempnam($tmp_dir, "ca_dompdf_img_");
$image = "";
if ($data_uri) {
if ($parsed_data_uri = Helpers::parse_data_uri($url)) {
$image = $parsed_data_uri['data'];
}
} else {
list($image, $http_response_header) = Helpers::getFileContent($full_url, $dompdf->getHttpContext());
}
// Image not found or invalid
if (strlen($image) == 0) {
$msg = ($data_uri ? "Data-URI could not be parsed" : "Image not found");
throw new ImageException($msg, E_WARNING);
} // Image found, put in cache and process
else {
//e.g. fetch.php?media=url.jpg&cache=1
//- Image file name might be one of the dynamic parts of the url, don't strip off!
//- a remote url does not need to have a file extension at all
//- local cached file does not have a matching file extension
//Therefore get image type from the content
file_put_contents($resolved_url, $image);
}
}
} // Not remote, local image
else {
$resolved_url = Helpers::build_url($protocol, $host, $base_path, $url);
}
}
// Check if the local file is readable
if (!is_readable($resolved_url) || !filesize($resolved_url)) {
throw new ImageException("Image not readable or empty", E_WARNING);
} // Check is the file is an image
else {
list($width, $height, $type) = Helpers::dompdf_getimagesize($resolved_url, $dompdf->getHttpContext());
// Known image type
if ($width && $height && in_array($type, array("gif", "png", "jpeg", "bmp", "svg"))) {
//Don't put replacement image into cache - otherwise it will be deleted on cache cleanup.
//Only execute on successful caching of remote image.
if ($enable_remote && $remote || $data_uri) {
self::$_cache[$full_url] = $resolved_url;
}
} // Unknown image type
else {
throw new ImageException("Image type unknown", E_WARNING);
}
}
} catch (ImageException $e) {
$resolved_url = self::$broken_image;
$type = "png";
$message = self::$error_message;
Helpers::record_warnings($e->getCode(), $e->getMessage() . " \n $url", $e->getFile(), $e->getLine());
}
return array($resolved_url, $type, $message);
} | php | static function resolve_url($url, $protocol, $host, $base_path, Dompdf $dompdf)
{
self::$_dompdf = $dompdf;
$protocol = mb_strtolower($protocol);
$parsed_url = Helpers::explode_url($url);
$message = null;
$remote = ($protocol && $protocol !== "file://") || ($parsed_url['protocol'] != "");
$data_uri = strpos($parsed_url['protocol'], "data:") === 0;
$full_url = null;
$enable_remote = $dompdf->getOptions()->getIsRemoteEnabled();
try {
// Remote not allowed and is not DataURI
if (!$enable_remote && $remote && !$data_uri) {
throw new ImageException("Remote file access is disabled.", E_WARNING);
} // Remote allowed or DataURI
else {
if ($enable_remote && $remote || $data_uri) {
// Download remote files to a temporary directory
$full_url = Helpers::build_url($protocol, $host, $base_path, $url);
// From cache
if (isset(self::$_cache[$full_url])) {
$resolved_url = self::$_cache[$full_url];
} // From remote
else {
$tmp_dir = $dompdf->getOptions()->getTempDir();
$resolved_url = @tempnam($tmp_dir, "ca_dompdf_img_");
$image = "";
if ($data_uri) {
if ($parsed_data_uri = Helpers::parse_data_uri($url)) {
$image = $parsed_data_uri['data'];
}
} else {
list($image, $http_response_header) = Helpers::getFileContent($full_url, $dompdf->getHttpContext());
}
// Image not found or invalid
if (strlen($image) == 0) {
$msg = ($data_uri ? "Data-URI could not be parsed" : "Image not found");
throw new ImageException($msg, E_WARNING);
} // Image found, put in cache and process
else {
//e.g. fetch.php?media=url.jpg&cache=1
//- Image file name might be one of the dynamic parts of the url, don't strip off!
//- a remote url does not need to have a file extension at all
//- local cached file does not have a matching file extension
//Therefore get image type from the content
file_put_contents($resolved_url, $image);
}
}
} // Not remote, local image
else {
$resolved_url = Helpers::build_url($protocol, $host, $base_path, $url);
}
}
// Check if the local file is readable
if (!is_readable($resolved_url) || !filesize($resolved_url)) {
throw new ImageException("Image not readable or empty", E_WARNING);
} // Check is the file is an image
else {
list($width, $height, $type) = Helpers::dompdf_getimagesize($resolved_url, $dompdf->getHttpContext());
// Known image type
if ($width && $height && in_array($type, array("gif", "png", "jpeg", "bmp", "svg"))) {
//Don't put replacement image into cache - otherwise it will be deleted on cache cleanup.
//Only execute on successful caching of remote image.
if ($enable_remote && $remote || $data_uri) {
self::$_cache[$full_url] = $resolved_url;
}
} // Unknown image type
else {
throw new ImageException("Image type unknown", E_WARNING);
}
}
} catch (ImageException $e) {
$resolved_url = self::$broken_image;
$type = "png";
$message = self::$error_message;
Helpers::record_warnings($e->getCode(), $e->getMessage() . " \n $url", $e->getFile(), $e->getLine());
}
return array($resolved_url, $type, $message);
} | [
"static",
"function",
"resolve_url",
"(",
"$",
"url",
",",
"$",
"protocol",
",",
"$",
"host",
",",
"$",
"base_path",
",",
"Dompdf",
"$",
"dompdf",
")",
"{",
"self",
"::",
"$",
"_dompdf",
"=",
"$",
"dompdf",
";",
"$",
"protocol",
"=",
"mb_strtolower",
... | Resolve and fetch an image for use.
@param string $url The url of the image
@param string $protocol Default protocol if none specified in $url
@param string $host Default host if none specified in $url
@param string $base_path Default path if none specified in $url
@param Dompdf $dompdf The Dompdf instance
@throws ImageException
@return array An array with two elements: The local path to the image and the image extension | [
"Resolve",
"and",
"fetch",
"an",
"image",
"for",
"use",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Image/Cache.php#L60-L149 | train | Resolve the URL | [
30522,
10763,
3853,
10663,
1035,
24471,
2140,
1006,
1002,
24471,
2140,
1010,
1002,
8778,
1010,
1002,
3677,
1010,
1002,
2918,
1035,
4130,
1010,
14383,
17299,
2546,
1002,
14383,
17299,
2546,
1007,
1063,
2969,
1024,
1024,
1002,
1035,
14383,
17... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Frame.php | Frame.get_margin_height | public function get_margin_height()
{
$style = $this->_style;
return (float)$style->length_in_pt(array(
$style->height,
$style->margin_top,
$style->margin_bottom,
$style->border_top_width,
$style->border_bottom_width,
$style->padding_top,
$style->padding_bottom
), $this->_containing_block["h"]);
} | php | public function get_margin_height()
{
$style = $this->_style;
return (float)$style->length_in_pt(array(
$style->height,
$style->margin_top,
$style->margin_bottom,
$style->border_top_width,
$style->border_bottom_width,
$style->padding_top,
$style->padding_bottom
), $this->_containing_block["h"]);
} | [
"public",
"function",
"get_margin_height",
"(",
")",
"{",
"$",
"style",
"=",
"$",
"this",
"->",
"_style",
";",
"return",
"(",
"float",
")",
"$",
"style",
"->",
"length_in_pt",
"(",
"array",
"(",
"$",
"style",
"->",
"height",
",",
"$",
"style",
"->",
... | Return the height of the margin box of the frame, in pt. Meaningless
unless the height has been calculated properly.
@return float | [
"Return",
"the",
"height",
"of",
"the",
"margin",
"box",
"of",
"the",
"frame",
"in",
"pt",
".",
"Meaningless",
"unless",
"the",
"height",
"has",
"been",
"calculated",
"properly",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame.php#L474-L487 | train | Return the height of the margin box | [
30522,
2270,
3853,
2131,
1035,
7785,
1035,
4578,
1006,
1007,
1063,
1002,
2806,
1027,
1002,
2023,
1011,
1028,
1035,
2806,
1025,
2709,
1006,
14257,
1007,
1002,
2806,
1011,
1028,
3091,
1035,
1999,
1035,
13866,
1006,
9140,
1006,
1002,
2806,
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/Monolog/Processor/ClassNameProcessor.php | ClassNameProcessor.getLoggingClassName | private function getLoggingClassName()
{
$backtrace = $this->getBacktrace();
$name = Plugin::getPluginNameFromBacktrace($backtrace);
// if we can't determine the plugin, use the name of the calling class
if ($name == false) {
$name = $this->getClassNameThatIsLogging($backtrace);
}
return $name;
} | php | private function getLoggingClassName()
{
$backtrace = $this->getBacktrace();
$name = Plugin::getPluginNameFromBacktrace($backtrace);
// if we can't determine the plugin, use the name of the calling class
if ($name == false) {
$name = $this->getClassNameThatIsLogging($backtrace);
}
return $name;
} | [
"private",
"function",
"getLoggingClassName",
"(",
")",
"{",
"$",
"backtrace",
"=",
"$",
"this",
"->",
"getBacktrace",
"(",
")",
";",
"$",
"name",
"=",
"Plugin",
"::",
"getPluginNameFromBacktrace",
"(",
"$",
"backtrace",
")",
";",
"// if we can't determine the p... | Returns the name of the plugin/class that triggered the log.
@return string | [
"Returns",
"the",
"name",
"of",
"the",
"plugin",
"/",
"class",
"that",
"triggered",
"the",
"log",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Monolog/Processor/ClassNameProcessor.php#L38-L50 | train | Get the name of the class that is logging | [
30522,
2797,
3853,
2131,
21197,
4726,
26266,
18442,
1006,
1007,
1063,
1002,
2067,
6494,
3401,
1027,
1002,
2023,
1011,
1028,
2131,
5963,
6494,
3401,
1006,
1007,
1025,
1002,
2171,
1027,
13354,
2378,
1024,
1024,
2131,
24759,
15916,
23111,
1407... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Show/Field.php | Field.file | public function file($server = '', $download = true)
{
$field = $this;
return $this->unescape()->as(function ($path) use ($server, $download, $field) {
$name = basename($path);
$field->border = false;
$size = $url = '';
if (url()->isValidUrl($path)) {
$url = $path;
} elseif ($server) {
$url = $server.$path;
} else {
$storage = Storage::disk(config('admin.upload.disk'));
if ($storage->exists($path)) {
$url = $storage->url($path);
$size = ($storage->size($path) / 1000).'KB';
}
}
if (!$url) {
return '';
}
return <<<HTML
<ul class="mailbox-attachments clearfix">
<li style="margin-bottom: 0;">
<span class="mailbox-attachment-icon"><i class="fa {$field->getFileIcon($name)}"></i></span>
<div class="mailbox-attachment-info">
<div class="mailbox-attachment-name">
<i class="fa fa-paperclip"></i> {$name}
</div>
<span class="mailbox-attachment-size">
{$size}
<a href="{$url}" class="btn btn-default btn-xs pull-right" target="_blank"><i class="fa fa-cloud-download"></i></a>
</span>
</div>
</li>
</ul>
HTML;
});
} | php | public function file($server = '', $download = true)
{
$field = $this;
return $this->unescape()->as(function ($path) use ($server, $download, $field) {
$name = basename($path);
$field->border = false;
$size = $url = '';
if (url()->isValidUrl($path)) {
$url = $path;
} elseif ($server) {
$url = $server.$path;
} else {
$storage = Storage::disk(config('admin.upload.disk'));
if ($storage->exists($path)) {
$url = $storage->url($path);
$size = ($storage->size($path) / 1000).'KB';
}
}
if (!$url) {
return '';
}
return <<<HTML
<ul class="mailbox-attachments clearfix">
<li style="margin-bottom: 0;">
<span class="mailbox-attachment-icon"><i class="fa {$field->getFileIcon($name)}"></i></span>
<div class="mailbox-attachment-info">
<div class="mailbox-attachment-name">
<i class="fa fa-paperclip"></i> {$name}
</div>
<span class="mailbox-attachment-size">
{$size}
<a href="{$url}" class="btn btn-default btn-xs pull-right" target="_blank"><i class="fa fa-cloud-download"></i></a>
</span>
</div>
</li>
</ul>
HTML;
});
} | [
"public",
"function",
"file",
"(",
"$",
"server",
"=",
"''",
",",
"$",
"download",
"=",
"true",
")",
"{",
"$",
"field",
"=",
"$",
"this",
";",
"return",
"$",
"this",
"->",
"unescape",
"(",
")",
"->",
"as",
"(",
"function",
"(",
"$",
"path",
")",
... | Show field as a file.
@param string $server
@param bool $download
@return Field | [
"Show",
"field",
"as",
"a",
"file",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show/Field.php#L246-L290 | train | Returns the HTML for the file field | [
30522,
2270,
3853,
5371,
1006,
1002,
8241,
1027,
1005,
1005,
1010,
1002,
8816,
1027,
2995,
1007,
1063,
1002,
2492,
1027,
1002,
2023,
1025,
2709,
1002,
2023,
1011,
1028,
16655,
15782,
5051,
1006,
1007,
1011,
1028,
2004,
1006,
3853,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.havingBetween | public function havingBetween($column, array $values, $boolean = 'and', $not = false)
{
$type = 'between';
$this->havings[] = compact('type', 'column', 'values', 'boolean', 'not');
$this->addBinding($this->cleanBindings($values), 'having');
return $this;
} | php | public function havingBetween($column, array $values, $boolean = 'and', $not = false)
{
$type = 'between';
$this->havings[] = compact('type', 'column', 'values', 'boolean', 'not');
$this->addBinding($this->cleanBindings($values), 'having');
return $this;
} | [
"public",
"function",
"havingBetween",
"(",
"$",
"column",
",",
"array",
"$",
"values",
",",
"$",
"boolean",
"=",
"'and'",
",",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"type",
"=",
"'between'",
";",
"$",
"this",
"->",
"havings",
"[",
"]",
"=",
"co... | Add a "having between " clause to the query.
@param string $column
@param array $values
@param string $boolean
@param bool $not
@return \Illuminate\Database\Query\Builder|static | [
"Add",
"a",
"having",
"between",
"clause",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L1750-L1759 | train | Adds a having between clause to the query. | [
30522,
2270,
3853,
2383,
20915,
28394,
2078,
1006,
1002,
5930,
1010,
9140,
1002,
5300,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1010,
1002,
2025,
1027,
6270,
1007,
1063,
1002,
2828,
1027,
1005,
2090,
1005,
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... |
symfony/symfony | src/Symfony/Component/Routing/Route.php | Route.getRequirement | public function getRequirement($key)
{
return isset($this->requirements[$key]) ? $this->requirements[$key] : null;
} | php | public function getRequirement($key)
{
return isset($this->requirements[$key]) ? $this->requirements[$key] : null;
} | [
"public",
"function",
"getRequirement",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"requirements",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"requirements",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | Returns the requirement for the given key.
@param string $key The key
@return string|null The regex or null when not given | [
"Returns",
"the",
"requirement",
"for",
"the",
"given",
"key",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Route.php#L479-L482 | train | Get a requirement | [
30522,
2270,
3853,
2131,
2890,
15549,
28578,
4765,
1006,
1002,
3145,
1007,
1063,
2709,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
5918,
1031,
1002,
3145,
1033,
1007,
1029,
1002,
2023,
1011,
1028,
5918,
1031,
1002,
3145,
1033,
1024,
19701,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/FormatterHelper.php | FormatterHelper.truncate | public function truncate($message, $length, $suffix = '...')
{
$computedLength = $length - $this->strlen($suffix);
if ($computedLength > $this->strlen($message)) {
return $message;
}
if (false === $encoding = mb_detect_encoding($message, null, true)) {
return substr($message, 0, $length).$suffix;
}
return mb_substr($message, 0, $length, $encoding).$suffix;
} | php | public function truncate($message, $length, $suffix = '...')
{
$computedLength = $length - $this->strlen($suffix);
if ($computedLength > $this->strlen($message)) {
return $message;
}
if (false === $encoding = mb_detect_encoding($message, null, true)) {
return substr($message, 0, $length).$suffix;
}
return mb_substr($message, 0, $length, $encoding).$suffix;
} | [
"public",
"function",
"truncate",
"(",
"$",
"message",
",",
"$",
"length",
",",
"$",
"suffix",
"=",
"'...'",
")",
"{",
"$",
"computedLength",
"=",
"$",
"length",
"-",
"$",
"this",
"->",
"strlen",
"(",
"$",
"suffix",
")",
";",
"if",
"(",
"$",
"compu... | Truncates a message to the given length.
@param string $message
@param int $length
@param string $suffix
@return string | [
"Truncates",
"a",
"message",
"to",
"the",
"given",
"length",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/FormatterHelper.php#L84-L97 | train | Truncates a message to a specified length with a suffix | [
30522,
2270,
3853,
19817,
4609,
16280,
1006,
1002,
4471,
1010,
1002,
3091,
1010,
1002,
16809,
1027,
1005,
1012,
1012,
1012,
1005,
1007,
1063,
1002,
24806,
7770,
13512,
2232,
1027,
1002,
3091,
1011,
1002,
2023,
1011,
1028,
2358,
20927,
2078,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.search | public function search(array $params)
{
$response = $this->requestAndResponse('SEARCH', $params);
if (!$response) {
return $response;
}
foreach ($response as $ids) {
if ($ids[0] == 'SEARCH') {
array_shift($ids);
return $ids;
}
}
return array();
} | php | public function search(array $params)
{
$response = $this->requestAndResponse('SEARCH', $params);
if (!$response) {
return $response;
}
foreach ($response as $ids) {
if ($ids[0] == 'SEARCH') {
array_shift($ids);
return $ids;
}
}
return array();
} | [
"public",
"function",
"search",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"requestAndResponse",
"(",
"'SEARCH'",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"response",
")",
"{",
"return",
"$",
"response",
... | do a search request
This method is currently marked as internal as the API might change and is not
safe if you don't take precautions.
@internal
@return array message ids | [
"do",
"a",
"search",
"request"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L822-L836 | train | Search for a record | [
30522,
2270,
3853,
3945,
1006,
9140,
1002,
11498,
5244,
1007,
1063,
1002,
3433,
1027,
1002,
2023,
1011,
1028,
5227,
5685,
6072,
26029,
3366,
1006,
1005,
3945,
1005,
1010,
1002,
11498,
5244,
1007,
1025,
2065,
1006,
999,
1002,
3433,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/API/DataTableManipulator.php | DataTableManipulator.loadSubtable | protected function loadSubtable($dataTable, $row)
{
if (!($this->apiModule && $this->apiMethod && count($this->request))) {
return null;
}
$request = $this->request;
$idSubTable = $row->getIdSubDataTable();
if ($idSubTable === null) {
return null;
}
$request['idSubtable'] = $idSubTable;
if ($dataTable) {
$period = $dataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX);
if ($period instanceof Range) {
$request['date'] = $period->getDateStart() . ',' . $period->getDateEnd();
} else {
$request['date'] = $period->getDateStart()->toString();
}
}
$method = $this->getApiMethodForSubtable($request);
return $this->callApiAndReturnDataTable($this->apiModule, $method, $request);
} | php | protected function loadSubtable($dataTable, $row)
{
if (!($this->apiModule && $this->apiMethod && count($this->request))) {
return null;
}
$request = $this->request;
$idSubTable = $row->getIdSubDataTable();
if ($idSubTable === null) {
return null;
}
$request['idSubtable'] = $idSubTable;
if ($dataTable) {
$period = $dataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX);
if ($period instanceof Range) {
$request['date'] = $period->getDateStart() . ',' . $period->getDateEnd();
} else {
$request['date'] = $period->getDateStart()->toString();
}
}
$method = $this->getApiMethodForSubtable($request);
return $this->callApiAndReturnDataTable($this->apiModule, $method, $request);
} | [
"protected",
"function",
"loadSubtable",
"(",
"$",
"dataTable",
",",
"$",
"row",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"apiModule",
"&&",
"$",
"this",
"->",
"apiMethod",
"&&",
"count",
"(",
"$",
"this",
"->",
"request",
")",
")",
")",
"... | Load the subtable for a row.
Returns null if none is found.
@param DataTable $dataTable
@param Row $row
@return DataTable | [
"Load",
"the",
"subtable",
"for",
"a",
"row",
".",
"Returns",
"null",
"if",
"none",
"is",
"found",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/DataTableManipulator.php#L103-L128 | train | Load Subtable and return the result | [
30522,
5123,
3853,
15665,
12083,
10880,
1006,
1002,
2951,
10880,
1010,
1002,
5216,
1007,
1063,
2065,
1006,
999,
1006,
1002,
2023,
1011,
1028,
17928,
5302,
8566,
2571,
1004,
1004,
1002,
2023,
1011,
1028,
17928,
11368,
6806,
2094,
1004,
1004,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/Store.php | Store.restoreResponse | private function restoreResponse($headers, $body = null)
{
$status = $headers['X-Status'][0];
unset($headers['X-Status']);
if (null !== $body) {
$headers['X-Body-File'] = [$body];
}
return new Response($body, $status, $headers);
} | php | private function restoreResponse($headers, $body = null)
{
$status = $headers['X-Status'][0];
unset($headers['X-Status']);
if (null !== $body) {
$headers['X-Body-File'] = [$body];
}
return new Response($body, $status, $headers);
} | [
"private",
"function",
"restoreResponse",
"(",
"$",
"headers",
",",
"$",
"body",
"=",
"null",
")",
"{",
"$",
"status",
"=",
"$",
"headers",
"[",
"'X-Status'",
"]",
"[",
"0",
"]",
";",
"unset",
"(",
"$",
"headers",
"[",
"'X-Status'",
"]",
")",
";",
... | Restores a Response from the HTTP headers and body.
@param array $headers An array of HTTP headers for the Response
@param string $body The Response body
@return Response | [
"Restores",
"a",
"Response",
"from",
"the",
"HTTP",
"headers",
"and",
"body",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/Store.php#L478-L488 | train | Restore Response from headers and body | [
30522,
2797,
3853,
9239,
6072,
26029,
3366,
1006,
1002,
20346,
2015,
1010,
1002,
2303,
1027,
19701,
1007,
1063,
1002,
3570,
1027,
1002,
20346,
2015,
1031,
1005,
1060,
1011,
3570,
1005,
1033,
1031,
1014,
1033,
1025,
4895,
13462,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Dompdf.php | Dompdf.write_log | private function write_log()
{
$log_output_file = $this->getOptions()->getLogOutputFile();
if (!$log_output_file || !is_writable($log_output_file)) {
return;
}
$frames = Frame::$ID_COUNTER;
$memory = memory_get_peak_usage(true) / 1024;
$time = (microtime(true) - $this->startTime) * 1000;
$out = sprintf(
"<span style='color: #000' title='Frames'>%6d</span>" .
"<span style='color: #009' title='Memory'>%10.2f KB</span>" .
"<span style='color: #900' title='Time'>%10.2f ms</span>" .
"<span title='Quirksmode'> " .
($this->quirksmode ? "<span style='color: #d00'> ON</span>" : "<span style='color: #0d0'>OFF</span>") .
"</span><br />", $frames, $memory, $time);
$out .= ob_get_contents();
ob_clean();
file_put_contents($log_output_file, $out);
} | php | private function write_log()
{
$log_output_file = $this->getOptions()->getLogOutputFile();
if (!$log_output_file || !is_writable($log_output_file)) {
return;
}
$frames = Frame::$ID_COUNTER;
$memory = memory_get_peak_usage(true) / 1024;
$time = (microtime(true) - $this->startTime) * 1000;
$out = sprintf(
"<span style='color: #000' title='Frames'>%6d</span>" .
"<span style='color: #009' title='Memory'>%10.2f KB</span>" .
"<span style='color: #900' title='Time'>%10.2f ms</span>" .
"<span title='Quirksmode'> " .
($this->quirksmode ? "<span style='color: #d00'> ON</span>" : "<span style='color: #0d0'>OFF</span>") .
"</span><br />", $frames, $memory, $time);
$out .= ob_get_contents();
ob_clean();
file_put_contents($log_output_file, $out);
} | [
"private",
"function",
"write_log",
"(",
")",
"{",
"$",
"log_output_file",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
"->",
"getLogOutputFile",
"(",
")",
";",
"if",
"(",
"!",
"$",
"log_output_file",
"||",
"!",
"is_writable",
"(",
"$",
"log_output_file... | Writes the output buffer in the log file
@return void | [
"Writes",
"the",
"output",
"buffer",
"in",
"the",
"log",
"file"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L890-L913 | train | Write the log to the log file | [
30522,
2797,
3853,
4339,
1035,
8833,
1006,
1007,
1063,
1002,
8833,
1035,
6434,
1035,
5371,
1027,
1002,
2023,
1011,
1028,
2131,
7361,
9285,
1006,
1007,
1011,
1028,
2131,
21197,
5833,
18780,
8873,
2571,
1006,
1007,
1025,
2065,
1006,
999,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/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... |
laravel/framework | src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | PostgresGrammar.compileUpdateFrom | protected function compileUpdateFrom(Builder $query)
{
if (! isset($query->joins)) {
return '';
}
// When using Postgres, updates with joins list the joined tables in the from
// clause, which is different than other systems like MySQL. Here, we will
// compile out the tables that are joined and add them to a from clause.
$froms = collect($query->joins)->map(function ($join) {
return $this->wrapTable($join->table);
})->all();
if (count($froms) > 0) {
return ' from '.implode(', ', $froms);
}
} | php | protected function compileUpdateFrom(Builder $query)
{
if (! isset($query->joins)) {
return '';
}
// When using Postgres, updates with joins list the joined tables in the from
// clause, which is different than other systems like MySQL. Here, we will
// compile out the tables that are joined and add them to a from clause.
$froms = collect($query->joins)->map(function ($join) {
return $this->wrapTable($join->table);
})->all();
if (count($froms) > 0) {
return ' from '.implode(', ', $froms);
}
} | [
"protected",
"function",
"compileUpdateFrom",
"(",
"Builder",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"query",
"->",
"joins",
")",
")",
"{",
"return",
"''",
";",
"}",
"// When using Postgres, updates with joins list the joined tables in the from",... | Compile the "from" clause for an update with a join.
@param \Illuminate\Database\Query\Builder $query
@return string|null | [
"Compile",
"the",
"from",
"clause",
"for",
"an",
"update",
"with",
"a",
"join",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php#L285-L301 | train | Compiles the from clause for update queries | [
30522,
5123,
3853,
4012,
22090,
6279,
13701,
19699,
5358,
1006,
12508,
1002,
23032,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
23032,
1011,
1028,
9794,
1007,
1007,
1063,
2709,
1005,
1005,
1025,
1065,
1013,
1013,
2043,
2478,
2695,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/UriSigner.php | UriSigner.sign | public function sign($uri)
{
$url = parse_url($uri);
if (isset($url['query'])) {
parse_str($url['query'], $params);
} else {
$params = [];
}
$uri = $this->buildUrl($url, $params);
$params[$this->parameter] = $this->computeHash($uri);
return $this->buildUrl($url, $params);
} | php | public function sign($uri)
{
$url = parse_url($uri);
if (isset($url['query'])) {
parse_str($url['query'], $params);
} else {
$params = [];
}
$uri = $this->buildUrl($url, $params);
$params[$this->parameter] = $this->computeHash($uri);
return $this->buildUrl($url, $params);
} | [
"public",
"function",
"sign",
"(",
"$",
"uri",
")",
"{",
"$",
"url",
"=",
"parse_url",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"url",
"[",
"'query'",
"]",
")",
")",
"{",
"parse_str",
"(",
"$",
"url",
"[",
"'query'",
"]",
",",
... | Signs a URI.
The given URI is signed by adding the query string parameter
which value depends on the URI and the secret.
@param string $uri A URI to sign
@return string The signed URI | [
"Signs",
"a",
"URI",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/UriSigner.php#L44-L57 | train | Signs a URI and returns the signed URL. | [
30522,
2270,
3853,
3696,
1006,
1002,
24471,
2072,
1007,
1063,
1002,
24471,
2140,
1027,
11968,
3366,
1035,
24471,
2140,
1006,
1002,
24471,
2072,
1007,
1025,
2065,
1006,
26354,
3388,
1006,
1002,
24471,
2140,
1031,
1005,
23032,
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... |
overtrue/wechat | src/OfficialAccount/Broadcasting/Client.php | Client.previewImage | public function previewImage(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID)
{
return $this->previewMessage(new Image($mediaId), $reception, $method);
} | php | public function previewImage(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID)
{
return $this->previewMessage(new Image($mediaId), $reception, $method);
} | [
"public",
"function",
"previewImage",
"(",
"string",
"$",
"mediaId",
",",
"$",
"reception",
",",
"$",
"method",
"=",
"self",
"::",
"PREVIEW_BY_OPENID",
")",
"{",
"return",
"$",
"this",
"->",
"previewMessage",
"(",
"new",
"Image",
"(",
"$",
"mediaId",
")",
... | Preview a image message.
@param mixed $mediaId message
@param string $reception
@param string $method
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\RuntimeException
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Preview",
"a",
"image",
"message",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Broadcasting/Client.php#L282-L285 | train | Preview image message | [
30522,
2270,
3853,
19236,
9581,
3351,
1006,
5164,
1002,
2865,
3593,
1010,
1002,
7684,
1010,
1002,
4118,
1027,
2969,
1024,
1024,
19236,
1035,
2011,
1035,
2330,
3593,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
19236,
7834,
3736,
3351,
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/Settings/Plugin/SystemSetting.php | SystemSetting.isWritableByCurrentUser | public function isWritableByCurrentUser()
{
if ($this->hasConfigValue()) {
return false;
}
if (isset($this->hasWritePermission)) {
return $this->hasWritePermission;
}
// performance improvement, do not detect this in __construct otherwise likely rather "big" query to DB.
$this->hasWritePermission = Piwik::hasUserSuperUserAccess();
return $this->hasWritePermission;
} | php | public function isWritableByCurrentUser()
{
if ($this->hasConfigValue()) {
return false;
}
if (isset($this->hasWritePermission)) {
return $this->hasWritePermission;
}
// performance improvement, do not detect this in __construct otherwise likely rather "big" query to DB.
$this->hasWritePermission = Piwik::hasUserSuperUserAccess();
return $this->hasWritePermission;
} | [
"public",
"function",
"isWritableByCurrentUser",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasConfigValue",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"hasWritePermission",
")",
")",
"{",
"return",
... | Returns `true` if this setting is writable for the current user, `false` if otherwise. In case it returns
writable for the current user it will be visible in the Plugin settings UI.
@return bool | [
"Returns",
"true",
"if",
"this",
"setting",
"is",
"writable",
"for",
"the",
"current",
"user",
"false",
"if",
"otherwise",
".",
"In",
"case",
"it",
"returns",
"writable",
"for",
"the",
"current",
"user",
"it",
"will",
"be",
"visible",
"in",
"the",
"Plugin"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Settings/Plugin/SystemSetting.php#L50-L64 | train | Returns true if the user has write permission for this user. | [
30522,
2270,
3853,
2003,
13088,
6590,
3468,
3762,
10841,
14343,
3372,
20330,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2038,
8663,
8873,
2290,
10175,
5657,
1006,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
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... |
matomo-org/matomo | libs/Zend/Db/Table/Abstract.php | Zend_Db_Table_Abstract._fetch | protected function _fetch(Zend_Db_Table_Select $select)
{
$stmt = $this->_db->query($select);
$data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
return $data;
} | php | protected function _fetch(Zend_Db_Table_Select $select)
{
$stmt = $this->_db->query($select);
$data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
return $data;
} | [
"protected",
"function",
"_fetch",
"(",
"Zend_Db_Table_Select",
"$",
"select",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"_db",
"->",
"query",
"(",
"$",
"select",
")",
";",
"$",
"data",
"=",
"$",
"stmt",
"->",
"fetchAll",
"(",
"Zend_Db",
"::",
"... | Support method for fetching rows.
@param Zend_Db_Table_Select $select query options.
@return array An array containing the row results in FETCH_ASSOC mode. | [
"Support",
"method",
"for",
"fetching",
"rows",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Abstract.php#L1527-L1532 | train | Fetch all records from the database | [
30522,
5123,
3853,
1035,
18584,
1006,
16729,
2094,
1035,
16962,
1035,
2795,
1035,
7276,
1002,
7276,
1007,
1063,
1002,
2358,
20492,
1027,
1002,
2023,
1011,
1028,
1035,
16962,
1011,
1028,
23032,
1006,
1002,
7276,
1007,
1025,
1002,
2951,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/Router.php | Router.loadUrlMap | protected function loadUrlMap()
{
$key = $this->getCacheKey('page-url-map');
$cacheable = Config::get('cms.enableRoutesCache');
if ($cacheable) {
$cached = Cache::get($key, false);
}
else {
$cached = false;
}
if (!$cached || ($unserialized = @unserialize(@base64_decode($cached))) === false) {
/*
* The item doesn't exist in the cache, create the map
*/
$pages = $this->theme->listPages();
$map = [];
foreach ($pages as $page) {
if (!$page->url) {
continue;
}
$map[] = ['file' => $page->getFileName(), 'pattern' => $page->url];
}
$this->urlMap = $map;
if ($cacheable) {
Cache::put($key, base64_encode(serialize($map)), Config::get('cms.urlCacheTtl', 1));
}
return false;
}
$this->urlMap = $unserialized;
return true;
} | php | protected function loadUrlMap()
{
$key = $this->getCacheKey('page-url-map');
$cacheable = Config::get('cms.enableRoutesCache');
if ($cacheable) {
$cached = Cache::get($key, false);
}
else {
$cached = false;
}
if (!$cached || ($unserialized = @unserialize(@base64_decode($cached))) === false) {
/*
* The item doesn't exist in the cache, create the map
*/
$pages = $this->theme->listPages();
$map = [];
foreach ($pages as $page) {
if (!$page->url) {
continue;
}
$map[] = ['file' => $page->getFileName(), 'pattern' => $page->url];
}
$this->urlMap = $map;
if ($cacheable) {
Cache::put($key, base64_encode(serialize($map)), Config::get('cms.urlCacheTtl', 1));
}
return false;
}
$this->urlMap = $unserialized;
return true;
} | [
"protected",
"function",
"loadUrlMap",
"(",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getCacheKey",
"(",
"'page-url-map'",
")",
";",
"$",
"cacheable",
"=",
"Config",
"::",
"get",
"(",
"'cms.enableRoutesCache'",
")",
";",
"if",
"(",
"$",
"cacheable",
... | Loads the URL map - a list of page file names and corresponding URL patterns.
The URL map can is cached. The clearUrlMap() method resets the cache. By default
the map is updated every time when a page is saved in the back-end, or
when the interval defined with the cms.urlCacheTtl expires.
@return boolean Returns true if the URL map was loaded from the cache. Otherwise returns false. | [
"Loads",
"the",
"URL",
"map",
"-",
"a",
"list",
"of",
"page",
"file",
"names",
"and",
"corresponding",
"URL",
"patterns",
".",
"The",
"URL",
"map",
"can",
"is",
"cached",
".",
"The",
"clearUrlMap",
"()",
"method",
"resets",
"the",
"cache",
".",
"By",
"... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Router.php#L226-L262 | train | Load the url map | [
30522,
5123,
3853,
7170,
3126,
19145,
2361,
1006,
1007,
1063,
1002,
3145,
1027,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
14839,
1006,
1005,
3931,
1011,
24471,
2140,
1011,
4949,
1005,
1007,
1025,
1002,
17053,
3085,
1027,
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 | plugins/UserCountry/Columns/Country.php | Country.getHost | private function getHost($ipStr)
{
$ip = IP::fromStringIP($ipStr);
$host = $ip->getHostname();
$host = ($host === null ? $ipStr : $host);
return trim(strtolower($host));
} | php | private function getHost($ipStr)
{
$ip = IP::fromStringIP($ipStr);
$host = $ip->getHostname();
$host = ($host === null ? $ipStr : $host);
return trim(strtolower($host));
} | [
"private",
"function",
"getHost",
"(",
"$",
"ipStr",
")",
"{",
"$",
"ip",
"=",
"IP",
"::",
"fromStringIP",
"(",
"$",
"ipStr",
")",
";",
"$",
"host",
"=",
"$",
"ip",
"->",
"getHostname",
"(",
")",
";",
"$",
"host",
"=",
"(",
"$",
"host",
"===",
... | Returns the hostname given the IP address string
@param string $ipStr IP Address
@return string hostname (or human-readable IP address) | [
"Returns",
"the",
"hostname",
"given",
"the",
"IP",
"address",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/Columns/Country.php#L139-L147 | train | Get host name | [
30522,
2797,
3853,
2131,
15006,
2102,
1006,
1002,
12997,
3367,
2099,
1007,
1063,
1002,
12997,
1027,
12997,
1024,
1024,
2013,
3367,
4892,
11514,
1006,
1002,
12997,
3367,
2099,
1007,
1025,
1002,
3677,
1027,
1002,
12997,
1011,
1028,
2131,
1500... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/traits/FormModelWidget.php | FormModelWidget.resolveModelAttribute | public function resolveModelAttribute($attribute)
{
try {
return $this->formField->resolveModelAttribute($this->model, $attribute);
}
catch (Exception $ex) {
throw new ApplicationException(Lang::get('backend::lang.model.missing_relation', [
'class' => get_class($this->model),
'relation' => $attribute
]));
}
} | php | public function resolveModelAttribute($attribute)
{
try {
return $this->formField->resolveModelAttribute($this->model, $attribute);
}
catch (Exception $ex) {
throw new ApplicationException(Lang::get('backend::lang.model.missing_relation', [
'class' => get_class($this->model),
'relation' => $attribute
]));
}
} | [
"public",
"function",
"resolveModelAttribute",
"(",
"$",
"attribute",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"formField",
"->",
"resolveModelAttribute",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"attribute",
")",
";",
"}",
"catch",
"(",
"Excep... | Returns the final model and attribute name of
a nested HTML array attribute.
Eg: list($model, $attribute) = $this->resolveModelAttribute($this->valueFrom);
@param string $attribute.
@return array | [
"Returns",
"the",
"final",
"model",
"and",
"attribute",
"name",
"of",
"a",
"nested",
"HTML",
"array",
"attribute",
".",
"Eg",
":",
"list",
"(",
"$model",
"$attribute",
")",
"=",
"$this",
"-",
">",
"resolveModelAttribute",
"(",
"$this",
"-",
">",
"valueFrom... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/traits/FormModelWidget.php#L26-L37 | train | Resolve model attribute | [
30522,
2270,
3853,
10663,
5302,
9247,
19321,
3089,
8569,
2618,
1006,
1002,
17961,
1007,
1063,
3046,
1063,
2709,
1002,
2023,
1011,
1028,
2433,
3790,
1011,
1028,
10663,
5302,
9247,
19321,
3089,
8569,
2618,
1006,
1002,
2023,
1011,
1028,
2944,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/API/Request.php | Request.process | public function process()
{
// read the format requested for the output data
$outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $this->request));
$disablePostProcessing = $this->shouldDisablePostProcessing();
// create the response
$response = new ResponseBuilder($outputFormat, $this->request);
if ($disablePostProcessing) {
$response->disableDataTablePostProcessor();
}
$corsHandler = new CORSHandler();
$corsHandler->handle();
$tokenAuth = Common::getRequestVar('token_auth', '', 'string', $this->request);
$shouldReloadAuth = false;
try {
++self::$nestedApiInvocationCount;
// IP check is needed here as we cannot listen to API.Request.authenticate as it would then not return proper API format response.
// We can also not do it by listening to API.Request.dispatch as by then the user is already authenticated and we want to make sure
// to not expose any information in case the IP is not whitelisted.
$whitelist = new LoginWhitelist();
if ($whitelist->shouldCheckWhitelist() && $whitelist->shouldWhitelistApplyToAPI()) {
$ip = IP::getIpFromHeader();
$whitelist->checkIsWhitelisted($ip);
}
// read parameters
$moduleMethod = Common::getRequestVar('method', null, 'string', $this->request);
list($module, $method) = $this->extractModuleAndMethod($moduleMethod);
list($module, $method) = self::getRenamedModuleAndAction($module, $method);
PluginManager::getInstance()->checkIsPluginActivated($module);
$apiClassName = self::getClassNameAPI($module);
if ($shouldReloadAuth = self::shouldReloadAuthUsingTokenAuth($this->request)) {
$access = Access::getInstance();
$tokenAuthToRestore = $access->getTokenAuth();
$hadSuperUserAccess = $access->hasSuperUserAccess();
self::forceReloadAuthUsingTokenAuth($tokenAuth);
}
// call the method
$returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request);
// get the response with the request query parameters loaded, since DataTablePost processor will use the Report
// class instance, which may inspect the query parameters. (eg, it may look for the idCustomReport parameters
// which may only exist in $this->request, if the request was called programatically)
$toReturn = Context::executeWithQueryParameters($this->request, function () use ($response, $returnedValue, $module, $method) {
return $response->getResponse($returnedValue, $module, $method);
});
} catch (Exception $e) {
StaticContainer::get(LoggerInterface::class)->error('Uncaught exception in API: {exception}', [
'exception' => $e,
'ignoreInScreenWriter' => true,
]);
$toReturn = $response->getResponseException($e);
} finally {
--self::$nestedApiInvocationCount;
}
if ($shouldReloadAuth) {
$this->restoreAuthUsingTokenAuth($tokenAuthToRestore, $hadSuperUserAccess);
}
return $toReturn;
} | php | public function process()
{
// read the format requested for the output data
$outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $this->request));
$disablePostProcessing = $this->shouldDisablePostProcessing();
// create the response
$response = new ResponseBuilder($outputFormat, $this->request);
if ($disablePostProcessing) {
$response->disableDataTablePostProcessor();
}
$corsHandler = new CORSHandler();
$corsHandler->handle();
$tokenAuth = Common::getRequestVar('token_auth', '', 'string', $this->request);
$shouldReloadAuth = false;
try {
++self::$nestedApiInvocationCount;
// IP check is needed here as we cannot listen to API.Request.authenticate as it would then not return proper API format response.
// We can also not do it by listening to API.Request.dispatch as by then the user is already authenticated and we want to make sure
// to not expose any information in case the IP is not whitelisted.
$whitelist = new LoginWhitelist();
if ($whitelist->shouldCheckWhitelist() && $whitelist->shouldWhitelistApplyToAPI()) {
$ip = IP::getIpFromHeader();
$whitelist->checkIsWhitelisted($ip);
}
// read parameters
$moduleMethod = Common::getRequestVar('method', null, 'string', $this->request);
list($module, $method) = $this->extractModuleAndMethod($moduleMethod);
list($module, $method) = self::getRenamedModuleAndAction($module, $method);
PluginManager::getInstance()->checkIsPluginActivated($module);
$apiClassName = self::getClassNameAPI($module);
if ($shouldReloadAuth = self::shouldReloadAuthUsingTokenAuth($this->request)) {
$access = Access::getInstance();
$tokenAuthToRestore = $access->getTokenAuth();
$hadSuperUserAccess = $access->hasSuperUserAccess();
self::forceReloadAuthUsingTokenAuth($tokenAuth);
}
// call the method
$returnedValue = Proxy::getInstance()->call($apiClassName, $method, $this->request);
// get the response with the request query parameters loaded, since DataTablePost processor will use the Report
// class instance, which may inspect the query parameters. (eg, it may look for the idCustomReport parameters
// which may only exist in $this->request, if the request was called programatically)
$toReturn = Context::executeWithQueryParameters($this->request, function () use ($response, $returnedValue, $module, $method) {
return $response->getResponse($returnedValue, $module, $method);
});
} catch (Exception $e) {
StaticContainer::get(LoggerInterface::class)->error('Uncaught exception in API: {exception}', [
'exception' => $e,
'ignoreInScreenWriter' => true,
]);
$toReturn = $response->getResponseException($e);
} finally {
--self::$nestedApiInvocationCount;
}
if ($shouldReloadAuth) {
$this->restoreAuthUsingTokenAuth($tokenAuthToRestore, $hadSuperUserAccess);
}
return $toReturn;
} | [
"public",
"function",
"process",
"(",
")",
"{",
"// read the format requested for the output data",
"$",
"outputFormat",
"=",
"strtolower",
"(",
"Common",
"::",
"getRequestVar",
"(",
"'format'",
",",
"'xml'",
",",
"'string'",
",",
"$",
"this",
"->",
"request",
")"... | Dispatches the API request to the appropriate API method and returns the result
after post-processing.
Post-processing includes:
- flattening if **flat** is 0
- running generic filters unless **disable_generic_filters** is set to 1
- URL decoding label column values
- running queued filters unless **disable_queued_filters** is set to 1
- removing columns based on the values of the **hideColumns** and **showColumns** query parameters
- filtering rows if the **label** query parameter is set
- converting the result to the appropriate format (ie, XML, JSON, etc.)
If `'original'` is supplied for the output format, the result is returned as a PHP
object.
@throws PluginDeactivatedException if the module plugin is not activated.
@throws Exception if the requested API method cannot be called, if required parameters for the
API method are missing or if the API method throws an exception and the **format**
query parameter is **original**.
@return DataTable|Map|string The data resulting from the API call. | [
"Dispatches",
"the",
"API",
"request",
"to",
"the",
"appropriate",
"API",
"method",
"and",
"returns",
"the",
"result",
"after",
"post",
"-",
"processing",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Request.php#L216-L289 | train | Process the request and return the response | [
30522,
2270,
3853,
2832,
1006,
1007,
1063,
1013,
1013,
3191,
1996,
4289,
7303,
2005,
1996,
6434,
2951,
1002,
6434,
14192,
4017,
1027,
2358,
5339,
12898,
13777,
1006,
2691,
1024,
1024,
2131,
2890,
15500,
10755,
1006,
1005,
4289,
1005,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Finder/Gitignore.php | Gitignore.toRegex | public static function toRegex(string $gitignoreFileContent): string
{
$gitignoreFileContent = preg_replace('/^[^\\\\]*#.*/', '', $gitignoreFileContent);
$gitignoreLines = preg_split('/\r\n|\r|\n/', $gitignoreFileContent);
$gitignoreLines = array_map('trim', $gitignoreLines);
$gitignoreLines = array_filter($gitignoreLines);
$ignoreLinesPositive = array_filter($gitignoreLines, function (string $line) {
return !preg_match('/^!/', $line);
});
$ignoreLinesNegative = array_filter($gitignoreLines, function (string $line) {
return preg_match('/^!/', $line);
});
$ignoreLinesNegative = array_map(function (string $line) {
return preg_replace('/^!(.*)/', '${1}', $line);
}, $ignoreLinesNegative);
$ignoreLinesNegative = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesNegative);
$ignoreLinesPositive = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesPositive);
if (empty($ignoreLinesPositive)) {
return '/^$/';
}
if (empty($ignoreLinesNegative)) {
return sprintf('/%s/', implode('|', $ignoreLinesPositive));
}
return sprintf('/(?=^(?:(?!(%s)).)*$)(%s)/', implode('|', $ignoreLinesNegative), implode('|', $ignoreLinesPositive));
} | php | public static function toRegex(string $gitignoreFileContent): string
{
$gitignoreFileContent = preg_replace('/^[^\\\\]*#.*/', '', $gitignoreFileContent);
$gitignoreLines = preg_split('/\r\n|\r|\n/', $gitignoreFileContent);
$gitignoreLines = array_map('trim', $gitignoreLines);
$gitignoreLines = array_filter($gitignoreLines);
$ignoreLinesPositive = array_filter($gitignoreLines, function (string $line) {
return !preg_match('/^!/', $line);
});
$ignoreLinesNegative = array_filter($gitignoreLines, function (string $line) {
return preg_match('/^!/', $line);
});
$ignoreLinesNegative = array_map(function (string $line) {
return preg_replace('/^!(.*)/', '${1}', $line);
}, $ignoreLinesNegative);
$ignoreLinesNegative = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesNegative);
$ignoreLinesPositive = array_map([__CLASS__, 'getRegexFromGitignore'], $ignoreLinesPositive);
if (empty($ignoreLinesPositive)) {
return '/^$/';
}
if (empty($ignoreLinesNegative)) {
return sprintf('/%s/', implode('|', $ignoreLinesPositive));
}
return sprintf('/(?=^(?:(?!(%s)).)*$)(%s)/', implode('|', $ignoreLinesNegative), implode('|', $ignoreLinesPositive));
} | [
"public",
"static",
"function",
"toRegex",
"(",
"string",
"$",
"gitignoreFileContent",
")",
":",
"string",
"{",
"$",
"gitignoreFileContent",
"=",
"preg_replace",
"(",
"'/^[^\\\\\\\\]*#.*/'",
",",
"''",
",",
"$",
"gitignoreFileContent",
")",
";",
"$",
"gitignoreLin... | Returns a regexp which is the equivalent of the gitignore pattern.
@param string $gitignoreFileContent
@return string The regexp | [
"Returns",
"a",
"regexp",
"which",
"is",
"the",
"equivalent",
"of",
"the",
"gitignore",
"pattern",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Finder/Gitignore.php#L28-L58 | train | Converts gitignore lines to regular expression | [
30522,
2270,
10763,
3853,
9538,
3351,
2595,
1006,
5164,
1002,
21025,
30524,
1008,
1001,
1012,
1008,
1013,
1005,
1010,
1005,
1005,
1010,
1002,
21025,
3775,
26745,
2890,
8873,
2571,
8663,
6528,
2102,
1007,
1025,
1002,
21025,
3775,
26745,
1657... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Process/Process.php | Process.setTty | public function setTty($tty)
{
if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
throw new RuntimeException('TTY mode is not supported on Windows platform.');
}
if ($tty && !self::isTtySupported()) {
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
}
$this->tty = (bool) $tty;
return $this;
} | php | public function setTty($tty)
{
if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
throw new RuntimeException('TTY mode is not supported on Windows platform.');
}
if ($tty && !self::isTtySupported()) {
throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
}
$this->tty = (bool) $tty;
return $this;
} | [
"public",
"function",
"setTty",
"(",
"$",
"tty",
")",
"{",
"if",
"(",
"'\\\\'",
"===",
"\\",
"DIRECTORY_SEPARATOR",
"&&",
"$",
"tty",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'TTY mode is not supported on Windows platform.'",
")",
";",
"}",
"if",
"(... | Enables or disables the TTY mode.
@param bool $tty True to enabled and false to disable
@return self The current Process instance
@throws RuntimeException In case the TTY mode is not supported | [
"Enables",
"or",
"disables",
"the",
"TTY",
"mode",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L1055-L1068 | train | Set tty mode | [
30522,
2270,
3853,
2275,
15353,
1006,
1002,
23746,
2100,
1007,
1063,
2065,
1006,
1005,
1032,
1032,
1005,
1027,
1027,
1027,
1032,
14176,
1035,
19802,
25879,
2953,
1004,
1004,
1002,
23746,
2100,
1007,
1063,
5466,
2047,
2448,
7292,
10288,
2442... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Show/Tools.php | Tools.getResource | public function getResource()
{
if (is_null($this->resource)) {
$this->resource = $this->panel->getParent()->getResourcePath();
}
return $this->resource;
} | php | public function getResource()
{
if (is_null($this->resource)) {
$this->resource = $this->panel->getParent()->getResourcePath();
}
return $this->resource;
} | [
"public",
"function",
"getResource",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"$",
"this",
"->",
"resource",
"=",
"$",
"this",
"->",
"panel",
"->",
"getParent",
"(",
")",
"->",
"getResourcePath",
"(",
")... | Get resource path.
@return string | [
"Get",
"resource",
"path",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show/Tools.php#L91-L98 | train | Get resource path | [
30522,
2270,
3853,
2131,
6072,
8162,
3401,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
7692,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
7692,
1027,
1002,
2023,
1011,
1028,
5997,
1011,
1028,
2131,
19362,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php | ResponseCacheStrategy.add | public function add(Response $response)
{
++$this->embeddedResponses;
foreach (self::$overrideDirectives as $directive) {
if ($response->headers->hasCacheControlDirective($directive)) {
$this->flagDirectives[$directive] = true;
}
}
foreach (self::$inheritDirectives as $directive) {
if (false !== $this->flagDirectives[$directive]) {
$this->flagDirectives[$directive] = $response->headers->hasCacheControlDirective($directive);
}
}
$age = $response->getAge();
$this->age = max($this->age, $age);
if ($this->willMakeFinalResponseUncacheable($response)) {
$this->isNotCacheableResponseEmbedded = true;
return;
}
$this->storeRelativeAgeDirective('max-age', $response->headers->getCacheControlDirective('max-age'), $age);
$this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage') ?: $response->headers->getCacheControlDirective('max-age'), $age);
$expires = $response->getExpires();
$expires = null !== $expires ? $expires->format('U') - $response->getDate()->format('U') : null;
$this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0);
} | php | public function add(Response $response)
{
++$this->embeddedResponses;
foreach (self::$overrideDirectives as $directive) {
if ($response->headers->hasCacheControlDirective($directive)) {
$this->flagDirectives[$directive] = true;
}
}
foreach (self::$inheritDirectives as $directive) {
if (false !== $this->flagDirectives[$directive]) {
$this->flagDirectives[$directive] = $response->headers->hasCacheControlDirective($directive);
}
}
$age = $response->getAge();
$this->age = max($this->age, $age);
if ($this->willMakeFinalResponseUncacheable($response)) {
$this->isNotCacheableResponseEmbedded = true;
return;
}
$this->storeRelativeAgeDirective('max-age', $response->headers->getCacheControlDirective('max-age'), $age);
$this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage') ?: $response->headers->getCacheControlDirective('max-age'), $age);
$expires = $response->getExpires();
$expires = null !== $expires ? $expires->format('U') - $response->getDate()->format('U') : null;
$this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0);
} | [
"public",
"function",
"add",
"(",
"Response",
"$",
"response",
")",
"{",
"++",
"$",
"this",
"->",
"embeddedResponses",
";",
"foreach",
"(",
"self",
"::",
"$",
"overrideDirectives",
"as",
"$",
"directive",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"head... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php#L59-L90 | train | Add a response to the cache | [
30522,
2270,
3853,
5587,
1006,
3433,
1002,
3433,
1007,
1063,
1009,
1009,
1002,
2023,
1011,
1028,
11157,
6072,
26029,
8583,
1025,
18921,
6776,
1006,
2969,
1024,
1024,
1002,
2058,
15637,
4305,
2890,
15277,
2015,
2004,
1002,
16449,
1007,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Twig/TwigExtension.php | TwigExtension.xssFunc | public function xssFunc($data)
{
if (!\is_array($data)) {
return Security::detectXss($data);
}
$results = Security::detectXssFromArray($data);
$results_parts = array_map(function($value, $key) {
return $key.': \''.$value . '\'';
}, array_values($results), array_keys($results));
return implode(', ', $results_parts);
} | php | public function xssFunc($data)
{
if (!\is_array($data)) {
return Security::detectXss($data);
}
$results = Security::detectXssFromArray($data);
$results_parts = array_map(function($value, $key) {
return $key.': \''.$value . '\'';
}, array_values($results), array_keys($results));
return implode(', ', $results_parts);
} | [
"public",
"function",
"xssFunc",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"Security",
"::",
"detectXss",
"(",
"$",
"data",
")",
";",
"}",
"$",
"results",
"=",
"Security",
"::",
"detect... | Allow quick check of a string for XSS Vulnerabilities
@param string|array $data
@return bool|string|array | [
"Allow",
"quick",
"check",
"of",
"a",
"string",
"for",
"XSS",
"Vulnerabilities"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TwigExtension.php#L585-L597 | train | Return the XSS string | [
30522,
2270,
3853,
1060,
4757,
11263,
12273,
1006,
1002,
2951,
1007,
1063,
2065,
1006,
30524,
1063,
2709,
3036,
1024,
1024,
11487,
2595,
4757,
1006,
1002,
2951,
1007,
1025,
1065,
1002,
3463,
1027,
3036,
1024,
1024,
11487,
2595,
4757,
19699,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/PendingMail.php | PendingMail.send | public function send(MailableContract $mailable)
{
if ($mailable instanceof ShouldQueue) {
return $this->queue($mailable);
}
return $this->mailer->send($this->fill($mailable));
} | php | public function send(MailableContract $mailable)
{
if ($mailable instanceof ShouldQueue) {
return $this->queue($mailable);
}
return $this->mailer->send($this->fill($mailable));
} | [
"public",
"function",
"send",
"(",
"MailableContract",
"$",
"mailable",
")",
"{",
"if",
"(",
"$",
"mailable",
"instanceof",
"ShouldQueue",
")",
"{",
"return",
"$",
"this",
"->",
"queue",
"(",
"$",
"mailable",
")",
";",
"}",
"return",
"$",
"this",
"->",
... | Send a new mailable message instance.
@param \Illuminate\Contracts\Mail\Mailable $mailable
@return mixed | [
"Send",
"a",
"new",
"mailable",
"message",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/PendingMail.php#L121-L128 | train | Sends the given mailable to the mailer. | [
30522,
2270,
3853,
4604,
1006,
5653,
3085,
8663,
6494,
6593,
1002,
5653,
3085,
1007,
1063,
2065,
1006,
1002,
5653,
3085,
6013,
11253,
2323,
4226,
5657,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
24240,
1006,
1002,
5653,
3085,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php | NativeSessionStorage.regenerate | public function regenerate($destroy = false, $lifetime = null)
{
// Cannot regenerate the session ID for non-active sessions.
if (\PHP_SESSION_ACTIVE !== session_status()) {
return false;
}
if (headers_sent()) {
return false;
}
if (null !== $lifetime) {
ini_set('session.cookie_lifetime', $lifetime);
}
if ($destroy) {
$this->metadataBag->stampNew();
}
$isRegenerated = session_regenerate_id($destroy);
// The reference to $_SESSION in session bags is lost in PHP7 and we need to re-create it.
// @see https://bugs.php.net/bug.php?id=70013
$this->loadSession();
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}
return $isRegenerated;
} | php | public function regenerate($destroy = false, $lifetime = null)
{
// Cannot regenerate the session ID for non-active sessions.
if (\PHP_SESSION_ACTIVE !== session_status()) {
return false;
}
if (headers_sent()) {
return false;
}
if (null !== $lifetime) {
ini_set('session.cookie_lifetime', $lifetime);
}
if ($destroy) {
$this->metadataBag->stampNew();
}
$isRegenerated = session_regenerate_id($destroy);
// The reference to $_SESSION in session bags is lost in PHP7 and we need to re-create it.
// @see https://bugs.php.net/bug.php?id=70013
$this->loadSession();
if (null !== $this->emulateSameSite) {
$originalCookie = SessionUtils::popSessionCookie(session_name(), session_id());
if (null !== $originalCookie) {
header(sprintf('%s; SameSite=%s', $originalCookie, $this->emulateSameSite), false);
}
}
return $isRegenerated;
} | [
"public",
"function",
"regenerate",
"(",
"$",
"destroy",
"=",
"false",
",",
"$",
"lifetime",
"=",
"null",
")",
"{",
"// Cannot regenerate the session ID for non-active sessions.",
"if",
"(",
"\\",
"PHP_SESSION_ACTIVE",
"!==",
"session_status",
"(",
")",
")",
"{",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L200-L233 | train | Regenerate the session ID | [
30522,
2270,
3853,
19723,
24454,
3686,
1006,
1002,
6033,
1027,
6270,
1010,
1002,
6480,
1027,
19701,
1007,
1063,
1013,
1013,
3685,
19723,
24454,
3686,
1996,
5219,
8909,
2005,
2512,
1011,
3161,
6521,
1012,
2065,
30524,
19701,
999,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid.php | Grid.option | public function option($key, $value = null)
{
if (is_null($value)) {
return $this->options[$key];
}
$this->options[$key] = $value;
return $this;
} | php | public function option($key, $value = null)
{
if (is_null($value)) {
return $this->options[$key];
}
$this->options[$key] = $value;
return $this;
} | [
"public",
"function",
"option",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"this",
"->",
"optio... | Get or set option for grid.
@param string $key
@param mixed $value
@return $this|mixed | [
"Get",
"or",
"set",
"option",
"for",
"grid",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L267-L276 | train | Option for the current language | [
30522,
2270,
3853,
5724,
1006,
1002,
3145,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7047,
1031,
1002,
3145,
1033,
1025,
1065,
1002,
2023,
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/Translation/Dumper/IniFileDumper.php | IniFileDumper.formatCatalogue | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
{
$output = '';
foreach ($messages->all($domain) as $source => $target) {
$escapeTarget = str_replace('"', '\"', $target);
$output .= $source.'="'.$escapeTarget."\"\n";
}
return $output;
} | php | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
{
$output = '';
foreach ($messages->all($domain) as $source => $target) {
$escapeTarget = str_replace('"', '\"', $target);
$output .= $source.'="'.$escapeTarget."\"\n";
}
return $output;
} | [
"public",
"function",
"formatCatalogue",
"(",
"MessageCatalogue",
"$",
"messages",
",",
"$",
"domain",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"messages",
"->",
"all",
"(",
"$",
"domain... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Dumper/IniFileDumper.php#L26-L36 | train | Format the catalogue | [
30522,
2270,
3853,
4289,
11266,
23067,
9077,
1006,
4471,
11266,
23067,
9077,
1002,
7696,
1010,
1002,
5884,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
6434,
1027,
1005,
1005,
1025,
18921,
6776,
1006,
1002,
7696,
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... |
slimphp/Slim | Slim/App.php | App.handlePhpError | protected function handlePhpError(Throwable $e, ServerRequestInterface $request, ResponseInterface $response)
{
$handler = 'phpErrorHandler';
$params = [$request, $response, $e];
if ($this->container->has($handler)) {
$callable = $this->container->get($handler);
// Call the registered handler
return call_user_func_array($callable, $params);
}
// No handlers found, so just throw the exception
throw $e;
} | php | protected function handlePhpError(Throwable $e, ServerRequestInterface $request, ResponseInterface $response)
{
$handler = 'phpErrorHandler';
$params = [$request, $response, $e];
if ($this->container->has($handler)) {
$callable = $this->container->get($handler);
// Call the registered handler
return call_user_func_array($callable, $params);
}
// No handlers found, so just throw the exception
throw $e;
} | [
"protected",
"function",
"handlePhpError",
"(",
"Throwable",
"$",
"e",
",",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"handler",
"=",
"'phpErrorHandler'",
";",
"$",
"params",
"=",
"[",
"$",
"request",
"... | Call relevant handler from the Container if needed. If it doesn't exist,
then just re-throw.
@param Throwable $e
@param ServerRequestInterface $request
@param ResponseInterface $response
@return ResponseInterface
@throws Throwable | [
"Call",
"relevant",
"handler",
"from",
"the",
"Container",
"if",
"needed",
".",
"If",
"it",
"doesn",
"t",
"exist",
"then",
"just",
"re",
"-",
"throw",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/App.php#L720-L733 | train | Handle PHP errors | [
30522,
5123,
3853,
5047,
8458,
4842,
29165,
1006,
5466,
3085,
1002,
1041,
1010,
8241,
2890,
15500,
18447,
2121,
12172,
1002,
5227,
1010,
3433,
18447,
2121,
12172,
1002,
3433,
1007,
1063,
1002,
28213,
1027,
1005,
25718,
2121,
29165,
11774,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.sortArrayByKey | public static function sortArrayByKey($array, $array_key, $direction = SORT_DESC, $sort_flags = SORT_REGULAR)
{
$output = [];
if (!is_array($array) || !$array) {
return $output;
}
foreach ($array as $key => $row) {
$output[$key] = $row[$array_key];
}
array_multisort($output, $direction, $sort_flags, $array);
return $array;
} | php | public static function sortArrayByKey($array, $array_key, $direction = SORT_DESC, $sort_flags = SORT_REGULAR)
{
$output = [];
if (!is_array($array) || !$array) {
return $output;
}
foreach ($array as $key => $row) {
$output[$key] = $row[$array_key];
}
array_multisort($output, $direction, $sort_flags, $array);
return $array;
} | [
"public",
"static",
"function",
"sortArrayByKey",
"(",
"$",
"array",
",",
"$",
"array_key",
",",
"$",
"direction",
"=",
"SORT_DESC",
",",
"$",
"sort_flags",
"=",
"SORT_REGULAR",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"... | Sort an array by a key value in the array
@param mixed $array
@param string|int $array_key
@param int $direction
@param int $sort_flags
@return array | [
"Sort",
"an",
"array",
"by",
"a",
"key",
"value",
"in",
"the",
"array"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L1272-L1287 | train | Sort array by key | [
30522,
2270,
10763,
3853,
4066,
2906,
9447,
3762,
14839,
1006,
1002,
9140,
1010,
1002,
9140,
1035,
3145,
1010,
1002,
3257,
1027,
4066,
1035,
4078,
2278,
1010,
1002,
4066,
1035,
9245,
1027,
4066,
1035,
3180,
1007,
1063,
1002,
6434,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Profiler.php | Profiler.aggregateXhprofRuns | public static function aggregateXhprofRuns($runIds, $profilerNamespace, $saveToRunId)
{
$xhprofRuns = new XHProfRuns_Default();
$aggregatedData = array();
foreach ($runIds as $runId) {
$xhprofRunData = $xhprofRuns->get_run($runId, $profilerNamespace, $description);
foreach ($xhprofRunData as $key => $data) {
if (empty($aggregatedData[$key])) {
$aggregatedData[$key] = $data;
} else {
// don't aggregate main() metrics since only the super run has the correct metrics for the entire run
if ($key == "main()") {
continue;
}
$aggregatedData[$key]["ct"] += $data["ct"]; // call count
$aggregatedData[$key]["wt"] += $data["wt"]; // incl. wall time
$aggregatedData[$key]["cpu"] += $data["cpu"]; // cpu time
$aggregatedData[$key]["mu"] += $data["mu"]; // memory usage
$aggregatedData[$key]["pmu"] = max($aggregatedData[$key]["pmu"], $data["pmu"]); // peak mem usage
}
}
}
$xhprofRuns->save_run($aggregatedData, $profilerNamespace, $saveToRunId);
} | php | public static function aggregateXhprofRuns($runIds, $profilerNamespace, $saveToRunId)
{
$xhprofRuns = new XHProfRuns_Default();
$aggregatedData = array();
foreach ($runIds as $runId) {
$xhprofRunData = $xhprofRuns->get_run($runId, $profilerNamespace, $description);
foreach ($xhprofRunData as $key => $data) {
if (empty($aggregatedData[$key])) {
$aggregatedData[$key] = $data;
} else {
// don't aggregate main() metrics since only the super run has the correct metrics for the entire run
if ($key == "main()") {
continue;
}
$aggregatedData[$key]["ct"] += $data["ct"]; // call count
$aggregatedData[$key]["wt"] += $data["wt"]; // incl. wall time
$aggregatedData[$key]["cpu"] += $data["cpu"]; // cpu time
$aggregatedData[$key]["mu"] += $data["mu"]; // memory usage
$aggregatedData[$key]["pmu"] = max($aggregatedData[$key]["pmu"], $data["pmu"]); // peak mem usage
}
}
}
$xhprofRuns->save_run($aggregatedData, $profilerNamespace, $saveToRunId);
} | [
"public",
"static",
"function",
"aggregateXhprofRuns",
"(",
"$",
"runIds",
",",
"$",
"profilerNamespace",
",",
"$",
"saveToRunId",
")",
"{",
"$",
"xhprofRuns",
"=",
"new",
"XHProfRuns_Default",
"(",
")",
";",
"$",
"aggregatedData",
"=",
"array",
"(",
")",
";... | Aggregates xhprof runs w/o normalizing (xhprof_aggregate_runs will always average data which
does not fit Piwik's use case). | [
"Aggregates",
"xhprof",
"runs",
"w",
"/",
"o",
"normalizing",
"(",
"xhprof_aggregate_runs",
"will",
"always",
"average",
"data",
"which",
"does",
"not",
"fit",
"Piwik",
"s",
"use",
"case",
")",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Profiler.php#L311-L339 | train | Aggregate XHProf run metrics to the main run metrics | [
30522,
2270,
10763,
3853,
9572,
2595,
22269,
3217,
19699,
4609,
2015,
1006,
1002,
2448,
9821,
1010,
1002,
6337,
12789,
7834,
15327,
1010,
1002,
3828,
4263,
19496,
2094,
1007,
1063,
1002,
1060,
22269,
3217,
19699,
4609,
2015,
1027,
2047,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Payment/Sandbox/Client.php | Client.getKey | public function getKey(): string
{
if ($cache = $this->getCache()->get($this->getCacheKey())) {
return $cache;
}
$response = $this->request('sandboxnew/pay/getsignkey');
if ('SUCCESS' === $response['return_code']) {
$this->getCache()->set($this->getCacheKey(), $key = $response['sandbox_signkey'], 24 * 3600);
return $key;
}
throw new SandboxException($response['retmsg'] ?? $response['return_msg']);
} | php | public function getKey(): string
{
if ($cache = $this->getCache()->get($this->getCacheKey())) {
return $cache;
}
$response = $this->request('sandboxnew/pay/getsignkey');
if ('SUCCESS' === $response['return_code']) {
$this->getCache()->set($this->getCacheKey(), $key = $response['sandbox_signkey'], 24 * 3600);
return $key;
}
throw new SandboxException($response['retmsg'] ?? $response['return_msg']);
} | [
"public",
"function",
"getKey",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
")",
")",
"{",
"return",
"$",
"cache",
";",
"}",
... | @return string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
@throws \EasyWeChat\Payment\Kernel\Exceptions\SandboxException
@throws \Psr\SimpleCache\InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException | [
"@return",
"string"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Sandbox/Client.php#L35-L50 | train | Get the sign key | [
30522,
2270,
3853,
2131,
14839,
1006,
1007,
1024,
5164,
1063,
2065,
1006,
1002,
17053,
1027,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
1006,
1007,
1011,
1028,
2131,
1006,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
14839,
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... |
matomo-org/matomo | core/Development.php | Development.formatMethodCall | public static function formatMethodCall($classOrObject, $method)
{
if (is_object($classOrObject)) {
$classOrObject = get_class($classOrObject);
}
return $classOrObject . '::' . $method . '()';
} | php | public static function formatMethodCall($classOrObject, $method)
{
if (is_object($classOrObject)) {
$classOrObject = get_class($classOrObject);
}
return $classOrObject . '::' . $method . '()';
} | [
"public",
"static",
"function",
"formatMethodCall",
"(",
"$",
"classOrObject",
",",
"$",
"method",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"classOrObject",
")",
")",
"{",
"$",
"classOrObject",
"=",
"get_class",
"(",
"$",
"classOrObject",
")",
";",
"}",... | Formats a method call depending on the given class/object and method name. It does not perform any checks whether
does actually exists.
@param string|object $classOrObject
@param string $method
@return string Formatted method call. Example: "MyNamespace\MyClassname::methodName()" | [
"Formats",
"a",
"method",
"call",
"depending",
"on",
"the",
"given",
"class",
"/",
"object",
"and",
"method",
"name",
".",
"It",
"does",
"not",
"perform",
"any",
"checks",
"whether",
"does",
"actually",
"exists",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Development.php#L69-L76 | train | Format a method call to a class or object | [
30522,
2270,
10763,
3853,
4289,
11368,
6806,
16409,
8095,
1006,
1002,
2465,
14604,
2497,
20614,
1010,
1002,
4118,
1007,
1063,
2065,
1006,
2003,
1035,
4874,
1006,
1002,
2465,
14604,
2497,
20614,
1007,
1007,
1063,
1002,
2465,
14604,
2497,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.validateInput | protected function validateInput(InputInterface $input)
{
$options = ['tags', 'tag', 'parameters', 'parameter'];
$optionsCount = 0;
foreach ($options as $option) {
if ($input->getOption($option)) {
++$optionsCount;
}
}
$name = $input->getArgument('name');
if ((null !== $name) && ($optionsCount > 0)) {
throw new InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined with the service name argument.');
} elseif ((null === $name) && $optionsCount > 1) {
throw new InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined together.');
}
} | php | protected function validateInput(InputInterface $input)
{
$options = ['tags', 'tag', 'parameters', 'parameter'];
$optionsCount = 0;
foreach ($options as $option) {
if ($input->getOption($option)) {
++$optionsCount;
}
}
$name = $input->getArgument('name');
if ((null !== $name) && ($optionsCount > 0)) {
throw new InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined with the service name argument.');
} elseif ((null === $name) && $optionsCount > 1) {
throw new InvalidArgumentException('The options tags, tag, parameters & parameter can not be combined together.');
}
} | [
"protected",
"function",
"validateInput",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"$",
"options",
"=",
"[",
"'tags'",
",",
"'tag'",
",",
"'parameters'",
",",
"'parameter'",
"]",
";",
"$",
"optionsCount",
"=",
"0",
";",
"foreach",
"(",
"$",
"options"... | Validates input arguments and options.
@throws \InvalidArgumentException | [
"Validates",
"input",
"arguments",
"and",
"options",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php#L189-L206 | train | Validate input for the language | [
30522,
5123,
3853,
9398,
3686,
2378,
18780,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1007,
1063,
1002,
7047,
1027,
1031,
1005,
22073,
1005,
1010,
1005,
6415,
1005,
1010,
1005,
11709,
1005,
1010,
1005,
16381,
1005,
1033,
1025,
1002,
7047,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.newPage | function newPage($insert = 0, $id = 0, $pos = 'after')
{
// if there is a state saved, then go up the stack closing them
// then on the new page, re-open them with the right setings
if ($this->nStateStack) {
for ($i = $this->nStateStack; $i >= 1; $i--) {
$this->restoreState($i);
}
}
$this->numObj++;
if ($insert) {
// the id from the ezPdf class is the id of the contents of the page, not the page object itself
// query that object to find the parent
$rid = $this->objects[$id]['onPage'];
$opt = array('rid' => $rid, 'pos' => $pos);
$this->o_page($this->numObj, 'new', $opt);
} else {
$this->o_page($this->numObj, 'new');
}
// if there is a stack saved, then put that onto the page
if ($this->nStateStack) {
for ($i = 1; $i <= $this->nStateStack; $i++) {
$this->saveState($i);
}
}
// and if there has been a stroke or fill color set, then transfer them
if (isset($this->currentColor)) {
$this->setColor($this->currentColor, true);
}
if (isset($this->currentStrokeColor)) {
$this->setStrokeColor($this->currentStrokeColor, true);
}
// if there is a line style set, then put this in too
if (mb_strlen($this->currentLineStyle, '8bit')) {
$this->addContent("\n$this->currentLineStyle");
}
// the call to the o_page object set currentContents to the present page, so this can be returned as the page id
return $this->currentContents;
} | php | function newPage($insert = 0, $id = 0, $pos = 'after')
{
// if there is a state saved, then go up the stack closing them
// then on the new page, re-open them with the right setings
if ($this->nStateStack) {
for ($i = $this->nStateStack; $i >= 1; $i--) {
$this->restoreState($i);
}
}
$this->numObj++;
if ($insert) {
// the id from the ezPdf class is the id of the contents of the page, not the page object itself
// query that object to find the parent
$rid = $this->objects[$id]['onPage'];
$opt = array('rid' => $rid, 'pos' => $pos);
$this->o_page($this->numObj, 'new', $opt);
} else {
$this->o_page($this->numObj, 'new');
}
// if there is a stack saved, then put that onto the page
if ($this->nStateStack) {
for ($i = 1; $i <= $this->nStateStack; $i++) {
$this->saveState($i);
}
}
// and if there has been a stroke or fill color set, then transfer them
if (isset($this->currentColor)) {
$this->setColor($this->currentColor, true);
}
if (isset($this->currentStrokeColor)) {
$this->setStrokeColor($this->currentStrokeColor, true);
}
// if there is a line style set, then put this in too
if (mb_strlen($this->currentLineStyle, '8bit')) {
$this->addContent("\n$this->currentLineStyle");
}
// the call to the o_page object set currentContents to the present page, so this can be returned as the page id
return $this->currentContents;
} | [
"function",
"newPage",
"(",
"$",
"insert",
"=",
"0",
",",
"$",
"id",
"=",
"0",
",",
"$",
"pos",
"=",
"'after'",
")",
"{",
"// if there is a state saved, then go up the stack closing them",
"// then on the new page, re-open them with the right setings",
"if",
"(",
"$",
... | add a new page to the document
this also makes the new page the current active object
@param int $insert
@param int $id
@param string $pos
@return int | [
"add",
"a",
"new",
"page",
"to",
"the",
"document",
"this",
"also",
"makes",
"the",
"new",
"page",
"the",
"current",
"active",
"object"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3823-L3869 | train | newPage - new page - save the state stack and put the new page on the right setings | [
30522,
3853,
2047,
13704,
1006,
1002,
19274,
1027,
1014,
1010,
1002,
8909,
1027,
1014,
1010,
1002,
13433,
2015,
1027,
1005,
2044,
1005,
1007,
1063,
1013,
1013,
2065,
2045,
2003,
1037,
2110,
5552,
1010,
2059,
2175,
2039,
1996,
9991,
5494,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Container.php | HTML_QuickForm2_Container.getElementById | public function getElementById($id)
{
foreach ($this->getRecursiveIterator() as $element) {
if ($id == $element->getId()) {
return $element;
}
}
return null;
} | php | public function getElementById($id)
{
foreach ($this->getRecursiveIterator() as $element) {
if ($id == $element->getId()) {
return $element;
}
}
return null;
} | [
"public",
"function",
"getElementById",
"(",
"$",
"id",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRecursiveIterator",
"(",
")",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"id",
"==",
"$",
"element",
"->",
"getId",
"(",
")",
")",
"{",
"r... | Returns an element if its id is found
@param string Element id to find
@return HTML_QuickForm2_Node|null | [
"Returns",
"an",
"element",
"if",
"its",
"id",
"is",
"found"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Container.php#L263-L271 | train | Get an element by its id | [
30522,
2270,
3853,
2131,
12260,
3672,
3762,
3593,
1006,
1002,
8909,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
2890,
10841,
2869,
3512,
21646,
8844,
1006,
1007,
2004,
1002,
5783,
1007,
1063,
2065,
1006,
1002,
8909,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/Controller.php | Controller.verifyForceSecure | protected function verifyForceSecure()
{
if (Request::secure() || Request::ajax()) {
return true;
}
// @todo if year >= 2018 change default from false to null
$forceSecure = Config::get('cms.backendForceSecure', false);
if ($forceSecure === null) {
$forceSecure = !Config::get('app.debug', false);
}
return !$forceSecure;
} | php | protected function verifyForceSecure()
{
if (Request::secure() || Request::ajax()) {
return true;
}
// @todo if year >= 2018 change default from false to null
$forceSecure = Config::get('cms.backendForceSecure', false);
if ($forceSecure === null) {
$forceSecure = !Config::get('app.debug', false);
}
return !$forceSecure;
} | [
"protected",
"function",
"verifyForceSecure",
"(",
")",
"{",
"if",
"(",
"Request",
"::",
"secure",
"(",
")",
"||",
"Request",
"::",
"ajax",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"// @todo if year >= 2018 change default from false to null",
"$",
"forceS... | Checks if the back-end should force a secure protocol (HTTPS) enabled by config.
@return bool | [
"Checks",
"if",
"the",
"back",
"-",
"end",
"should",
"force",
"a",
"secure",
"protocol",
"(",
"HTTPS",
")",
"enabled",
"by",
"config",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L749-L762 | train | Verify force secure | [
30522,
5123,
3853,
20410,
14821,
3366,
23887,
1006,
1007,
1063,
2065,
1006,
5227,
1024,
1024,
5851,
1006,
1007,
1064,
1064,
5227,
1024,
1024,
18176,
1006,
1007,
1007,
1063,
2709,
2995,
1025,
1065,
1013,
1013,
1030,
28681,
2080,
2065,
2095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Container/Container.php | Container.resolveDependencies | protected function resolveDependencies(array $dependencies)
{
$results = [];
foreach ($dependencies as $dependency) {
// If this dependency has a override for this particular build we will use
// that instead as the value. Otherwise, we will continue with this run
// of resolutions and let reflection attempt to determine the result.
if ($this->hasParameterOverride($dependency)) {
$results[] = $this->getParameterOverride($dependency);
continue;
}
// If the class is null, it means the dependency is a string or some other
// primitive type which we can not resolve since it is not a class and
// we will just bomb out with an error since we have no-where to go.
$results[] = is_null($dependency->getClass())
? $this->resolvePrimitive($dependency)
: $this->resolveClass($dependency);
}
return $results;
} | php | protected function resolveDependencies(array $dependencies)
{
$results = [];
foreach ($dependencies as $dependency) {
// If this dependency has a override for this particular build we will use
// that instead as the value. Otherwise, we will continue with this run
// of resolutions and let reflection attempt to determine the result.
if ($this->hasParameterOverride($dependency)) {
$results[] = $this->getParameterOverride($dependency);
continue;
}
// If the class is null, it means the dependency is a string or some other
// primitive type which we can not resolve since it is not a class and
// we will just bomb out with an error since we have no-where to go.
$results[] = is_null($dependency->getClass())
? $this->resolvePrimitive($dependency)
: $this->resolveClass($dependency);
}
return $results;
} | [
"protected",
"function",
"resolveDependencies",
"(",
"array",
"$",
"dependencies",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"// If this dependency has a override for this particular build we ... | Resolve all of the dependencies from the ReflectionParameters.
@param array $dependencies
@return array
@throws \Illuminate\Contracts\Container\BindingResolutionException | [
"Resolve",
"all",
"of",
"the",
"dependencies",
"from",
"the",
"ReflectionParameters",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L834-L857 | train | Resolves the dependencies | [
30522,
5123,
3853,
10395,
13699,
10497,
15266,
1006,
9140,
1002,
12530,
15266,
1007,
1063,
1002,
3463,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
12530,
15266,
2004,
1002,
24394,
1007,
1063,
1013,
1013,
2065,
2023,
24394,
2038,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Column.php | Column.setRelation | public function setRelation($relation, $relationColumn = null)
{
$this->relation = $relation;
$this->relationColumn = $relationColumn;
return $this;
} | php | public function setRelation($relation, $relationColumn = null)
{
$this->relation = $relation;
$this->relationColumn = $relationColumn;
return $this;
} | [
"public",
"function",
"setRelation",
"(",
"$",
"relation",
",",
"$",
"relationColumn",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"relation",
"=",
"$",
"relation",
";",
"$",
"this",
"->",
"relationColumn",
"=",
"$",
"relationColumn",
";",
"return",
"$",
"... | Set relation.
@param string $relation
@param string $relationColumn
@return $this | [
"Set",
"relation",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Column.php#L269-L275 | train | Set relation column | [
30522,
2270,
3853,
2275,
16570,
3370,
1006,
1002,
7189,
1010,
1002,
7189,
25778,
2819,
2078,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
7189,
1027,
1002,
7189,
1025,
1002,
2023,
1011,
1028,
7189,
25778,
2819,
2078,
1027,
1002,
7189,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Templating/Loader/ChainLoader.php | ChainLoader.isFresh | public function isFresh(TemplateReferenceInterface $template, $time)
{
foreach ($this->loaders as $loader) {
return $loader->isFresh($template, $time);
}
return false;
} | php | public function isFresh(TemplateReferenceInterface $template, $time)
{
foreach ($this->loaders as $loader) {
return $loader->isFresh($template, $time);
}
return false;
} | [
"public",
"function",
"isFresh",
"(",
"TemplateReferenceInterface",
"$",
"template",
",",
"$",
"time",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loaders",
"as",
"$",
"loader",
")",
"{",
"return",
"$",
"loader",
"->",
"isFresh",
"(",
"$",
"template",
... | Returns true if the template is still fresh.
@param TemplateReferenceInterface $template A template
@param int $time The last modification time of the cached template (timestamp)
@return bool | [
"Returns",
"true",
"if",
"the",
"template",
"is",
"still",
"fresh",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Templating/Loader/ChainLoader.php#L68-L75 | train | Returns true if the template is fresh. | [
30522,
2270,
3853,
2003,
19699,
9953,
1006,
23561,
2890,
25523,
18447,
2121,
12172,
1002,
23561,
1010,
1002,
2051,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
7170,
2545,
2004,
1002,
7170,
2121,
1007,
1063,
2709,
1002,
7170,
2121... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Input/InputDefinition.php | InputDefinition.getArgument | public function getArgument($name)
{
if (!$this->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
$arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
return $arguments[$name];
} | php | public function getArgument($name)
{
if (!$this->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
}
$arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
return $arguments[$name];
} | [
"public",
"function",
"getArgument",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasArgument",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"%s\" argument does not exist.'",
",",
... | Returns an InputArgument by name or by position.
@param string|int $name The InputArgument name or position
@return InputArgument An InputArgument object
@throws InvalidArgumentException When argument given doesn't exist | [
"Returns",
"an",
"InputArgument",
"by",
"name",
"or",
"by",
"position",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Input/InputDefinition.php#L132-L141 | train | Get the value of an argument | [
30522,
2270,
3853,
2131,
2906,
22850,
4765,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2038,
2906,
22850,
4765,
1006,
1002,
2171,
1007,
1007,
1063,
5466,
2047,
19528,
2906,
22850,
15781,
2595,
24422,
1006,
9043,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Console/ForgetFailedCommand.php | ForgetFailedCommand.handle | public function handle()
{
if ($this->laravel['queue.failer']->forget($this->argument('id'))) {
$this->info('Failed job deleted successfully!');
} else {
$this->error('No failed job matches the given ID.');
}
} | php | public function handle()
{
if ($this->laravel['queue.failer']->forget($this->argument('id'))) {
$this->info('Failed job deleted successfully!');
} else {
$this->error('No failed job matches the given ID.');
}
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"laravel",
"[",
"'queue.failer'",
"]",
"->",
"forget",
"(",
"$",
"this",
"->",
"argument",
"(",
"'id'",
")",
")",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"'Failed job dele... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Console/ForgetFailedCommand.php#L28-L35 | train | Handle the failed job deletion | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
13679,
15985,
1031,
1005,
24240,
1012,
8246,
2121,
1005,
1033,
1011,
1028,
5293,
1006,
1002,
2023,
1011,
1028,
6685,
1006,
1005,
8909,
1005,
1007,
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... |
symfony/symfony | src/Symfony/Component/Console/Helper/QuestionHelper.php | QuestionHelper.autocomplete | private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete): string
{
$ret = '';
$i = 0;
$ofs = -1;
$matches = $autocomplete($ret);
$numMatches = \count($matches);
$sttyMode = shell_exec('stty -g');
// Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
shell_exec('stty -icanon -echo');
// Add highlighted text style
$output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
// Read a keypress
while (!feof($inputStream)) {
$c = fread($inputStream, 1);
// as opposed to fgets(), fread() returns an empty string when the stream content is empty, not false.
if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) {
shell_exec(sprintf('stty %s', $sttyMode));
throw new RuntimeException('Aborted.');
} elseif ("\177" === $c) { // Backspace Character
if (0 === $numMatches && 0 !== $i) {
--$i;
// Move cursor backwards
$output->write("\033[1D");
}
if (0 === $i) {
$ofs = -1;
$matches = $autocomplete($ret);
$numMatches = \count($matches);
} else {
$numMatches = 0;
}
// Pop the last character off the end of our string
$ret = substr($ret, 0, $i);
} elseif ("\033" === $c) {
// Did we read an escape sequence?
$c .= fread($inputStream, 2);
// A = Up Arrow. B = Down Arrow
if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
if ('A' === $c[2] && -1 === $ofs) {
$ofs = 0;
}
if (0 === $numMatches) {
continue;
}
$ofs += ('A' === $c[2]) ? -1 : 1;
$ofs = ($numMatches + $ofs) % $numMatches;
}
} elseif (\ord($c) < 32) {
if ("\t" === $c || "\n" === $c) {
if ($numMatches > 0 && -1 !== $ofs) {
$ret = (string) $matches[$ofs];
// Echo out remaining chars for current match
$output->write(substr($ret, $i));
$i = \strlen($ret);
$matches = array_filter(
$autocomplete($ret),
function ($match) use ($ret) {
return '' === $ret || 0 === strpos($match, $ret);
}
);
$numMatches = \count($matches);
$ofs = -1;
}
if ("\n" === $c) {
$output->write($c);
break;
}
}
continue;
} else {
if ("\x80" <= $c) {
$c .= fread($inputStream, ["\xC0" => 1, "\xD0" => 1, "\xE0" => 2, "\xF0" => 3][$c & "\xF0"]);
}
$output->write($c);
$ret .= $c;
++$i;
$numMatches = 0;
$ofs = 0;
foreach ($autocomplete($ret) as $value) {
// If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
if (0 === strpos($value, $ret)) {
$matches[$numMatches++] = $value;
}
}
}
// Erase characters from cursor to end of line
$output->write("\033[K");
if ($numMatches > 0 && -1 !== $ofs) {
// Save cursor position
$output->write("\0337");
// Write highlighted text
$output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
// Restore cursor position
$output->write("\0338");
}
}
// Reset stty so it behaves normally again
shell_exec(sprintf('stty %s', $sttyMode));
return $ret;
} | php | private function autocomplete(OutputInterface $output, Question $question, $inputStream, callable $autocomplete): string
{
$ret = '';
$i = 0;
$ofs = -1;
$matches = $autocomplete($ret);
$numMatches = \count($matches);
$sttyMode = shell_exec('stty -g');
// Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
shell_exec('stty -icanon -echo');
// Add highlighted text style
$output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
// Read a keypress
while (!feof($inputStream)) {
$c = fread($inputStream, 1);
// as opposed to fgets(), fread() returns an empty string when the stream content is empty, not false.
if (false === $c || ('' === $ret && '' === $c && null === $question->getDefault())) {
shell_exec(sprintf('stty %s', $sttyMode));
throw new RuntimeException('Aborted.');
} elseif ("\177" === $c) { // Backspace Character
if (0 === $numMatches && 0 !== $i) {
--$i;
// Move cursor backwards
$output->write("\033[1D");
}
if (0 === $i) {
$ofs = -1;
$matches = $autocomplete($ret);
$numMatches = \count($matches);
} else {
$numMatches = 0;
}
// Pop the last character off the end of our string
$ret = substr($ret, 0, $i);
} elseif ("\033" === $c) {
// Did we read an escape sequence?
$c .= fread($inputStream, 2);
// A = Up Arrow. B = Down Arrow
if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
if ('A' === $c[2] && -1 === $ofs) {
$ofs = 0;
}
if (0 === $numMatches) {
continue;
}
$ofs += ('A' === $c[2]) ? -1 : 1;
$ofs = ($numMatches + $ofs) % $numMatches;
}
} elseif (\ord($c) < 32) {
if ("\t" === $c || "\n" === $c) {
if ($numMatches > 0 && -1 !== $ofs) {
$ret = (string) $matches[$ofs];
// Echo out remaining chars for current match
$output->write(substr($ret, $i));
$i = \strlen($ret);
$matches = array_filter(
$autocomplete($ret),
function ($match) use ($ret) {
return '' === $ret || 0 === strpos($match, $ret);
}
);
$numMatches = \count($matches);
$ofs = -1;
}
if ("\n" === $c) {
$output->write($c);
break;
}
}
continue;
} else {
if ("\x80" <= $c) {
$c .= fread($inputStream, ["\xC0" => 1, "\xD0" => 1, "\xE0" => 2, "\xF0" => 3][$c & "\xF0"]);
}
$output->write($c);
$ret .= $c;
++$i;
$numMatches = 0;
$ofs = 0;
foreach ($autocomplete($ret) as $value) {
// If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
if (0 === strpos($value, $ret)) {
$matches[$numMatches++] = $value;
}
}
}
// Erase characters from cursor to end of line
$output->write("\033[K");
if ($numMatches > 0 && -1 !== $ofs) {
// Save cursor position
$output->write("\0337");
// Write highlighted text
$output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
// Restore cursor position
$output->write("\0338");
}
}
// Reset stty so it behaves normally again
shell_exec(sprintf('stty %s', $sttyMode));
return $ret;
} | [
"private",
"function",
"autocomplete",
"(",
"OutputInterface",
"$",
"output",
",",
"Question",
"$",
"question",
",",
"$",
"inputStream",
",",
"callable",
"$",
"autocomplete",
")",
":",
"string",
"{",
"$",
"ret",
"=",
"''",
";",
"$",
"i",
"=",
"0",
";",
... | Autocompletes a question.
@param resource $inputStream | [
"Autocompletes",
"a",
"question",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/QuestionHelper.php#L199-L320 | train | Autocomplete the question using the input stream and the question s default value. | [
30522,
2797,
3853,
8285,
9006,
10814,
2618,
1006,
6434,
18447,
2121,
12172,
1002,
6434,
1010,
3160,
1002,
3160,
1010,
1002,
20407,
25379,
1010,
2655,
3085,
1002,
8285,
9006,
10814,
2618,
1007,
1024,
5164,
1063,
1002,
2128,
2102,
1027,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Reader/TranslationReader.php | TranslationReader.read | public function read($directory, MessageCatalogue $catalogue)
{
if (!is_dir($directory)) {
return;
}
foreach ($this->loaders as $format => $loader) {
// load any existing translation files
$finder = new Finder();
$extension = $catalogue->getLocale().'.'.$format;
$files = $finder->files()->name('*.'.$extension)->in($directory);
foreach ($files as $file) {
$domain = substr($file->getFilename(), 0, -1 * \strlen($extension) - 1);
$catalogue->addCatalogue($loader->load($file->getPathname(), $catalogue->getLocale(), $domain));
}
}
} | php | public function read($directory, MessageCatalogue $catalogue)
{
if (!is_dir($directory)) {
return;
}
foreach ($this->loaders as $format => $loader) {
// load any existing translation files
$finder = new Finder();
$extension = $catalogue->getLocale().'.'.$format;
$files = $finder->files()->name('*.'.$extension)->in($directory);
foreach ($files as $file) {
$domain = substr($file->getFilename(), 0, -1 * \strlen($extension) - 1);
$catalogue->addCatalogue($loader->load($file->getPathname(), $catalogue->getLocale(), $domain));
}
}
} | [
"public",
"function",
"read",
"(",
"$",
"directory",
",",
"MessageCatalogue",
"$",
"catalogue",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"loaders",
"as",
"$",
"fo... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Reader/TranslationReader.php#L46-L62 | train | Reads translation files from a directory and adds them to the MessageCatalogue | [
30522,
2270,
3853,
3191,
1006,
1002,
14176,
1010,
4471,
11266,
23067,
9077,
1002,
10161,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16101,
1006,
1002,
14176,
1007,
1007,
1063,
2709,
1025,
1065,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
7170,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Footer.php | Footer.disableViewCheck | public function disableViewCheck(bool $disable = true)
{
if ($disable) {
array_delete($this->checkboxes, 'view');
} elseif (!in_array('view', $this->checkboxes)) {
array_push($this->checkboxes, 'view');
}
return $this;
} | php | public function disableViewCheck(bool $disable = true)
{
if ($disable) {
array_delete($this->checkboxes, 'view');
} elseif (!in_array('view', $this->checkboxes)) {
array_push($this->checkboxes, 'view');
}
return $this;
} | [
"public",
"function",
"disableViewCheck",
"(",
"bool",
"$",
"disable",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"disable",
")",
"{",
"array_delete",
"(",
"$",
"this",
"->",
"checkboxes",
",",
"'view'",
")",
";",
"}",
"elseif",
"(",
"!",
"in_array",
"(",
... | Disable View Checkbox.
@return $this | [
"Disable",
"View",
"Checkbox",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Footer.php#L85-L94 | train | Disable view check | [
30522,
2270,
3853,
4487,
19150,
8584,
5403,
3600,
1006,
22017,
2140,
1002,
4487,
19150,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
4487,
19150,
1007,
1063,
9140,
1035,
3972,
12870,
1006,
1002,
2023,
1011,
1028,
4638,
8758,
2229,
1010,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Request.php | Request.isTimestampValid | protected function isTimestampValid($time, $now = null)
{
if (empty($now)) {
$now = $this->getCurrentTimestamp();
}
return $time <= $now
&& $time > $now - 20 * 365 * 86400;
} | php | protected function isTimestampValid($time, $now = null)
{
if (empty($now)) {
$now = $this->getCurrentTimestamp();
}
return $time <= $now
&& $time > $now - 20 * 365 * 86400;
} | [
"protected",
"function",
"isTimestampValid",
"(",
"$",
"time",
",",
"$",
"now",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"now",
")",
")",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"getCurrentTimestamp",
"(",
")",
";",
"}",
"return",
"$",... | Returns true if the timestamp is valid ie. timestamp is sometime in the last 10 years and is not in the future.
@param $time int Timestamp to test
@param $now int Current timestamp
@return bool | [
"Returns",
"true",
"if",
"the",
"timestamp",
"is",
"valid",
"ie",
".",
"timestamp",
"is",
"sometime",
"in",
"the",
"last",
"10",
"years",
"and",
"is",
"not",
"in",
"the",
"future",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Request.php#L515-L523 | train | Check if a timestamp is valid | [
30522,
5123,
3853,
21541,
14428,
9153,
8737,
10175,
3593,
1006,
1002,
2051,
1010,
1002,
2085,
1027,
19701,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2085,
1007,
1007,
1063,
1002,
2085,
1027,
1002,
2023,
1011,
1028,
2131,
10841,
14343,
3372,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ReportRenderer/Pdf.php | Pdf.paintReportTableHeader | private function paintReportTableHeader()
{
$initPosX = 10;
// Get the longest column name
$longestColumnName = '';
foreach ($this->reportColumns as $columnName) {
if (strlen($columnName) > strlen($longestColumnName)) {
$longestColumnName = $columnName;
}
}
$columnsCount = count($this->reportColumns);
// Computes available column width
if ($this->orientation == self::PORTRAIT
&& $columnsCount <= 3
) {
$totalWidth = $this->reportWidthPortrait * 2 / 3;
} elseif ($this->orientation == self::LANDSCAPE) {
$totalWidth = $this->reportWidthLandscape;
} else {
$totalWidth = $this->reportWidthPortrait;
}
$this->totalWidth = $totalWidth;
$this->labelCellWidth = max(round(($this->totalWidth / $columnsCount)), $this->minWidthLabelCell);
$this->cellWidth = round(($this->totalWidth - $this->labelCellWidth) / ($columnsCount - 1));
$this->totalWidth = $this->labelCellWidth + ($columnsCount - 1) * $this->cellWidth;
$this->TCPDF->SetFillColor($this->tableHeaderBackgroundColor[0], $this->tableHeaderBackgroundColor[1], $this->tableHeaderBackgroundColor[2]);
$this->TCPDF->SetTextColor($this->tableHeaderTextColor[0], $this->tableHeaderTextColor[1], $this->tableHeaderTextColor[2]);
$this->TCPDF->SetLineWidth(.3);
$this->setBorderColor();
$this->TCPDF->SetFont($this->reportFont, $this->reportFontStyle);
$this->TCPDF->SetFillColor(255);
$this->TCPDF->SetTextColor($this->tableHeaderBackgroundColor[0], $this->tableHeaderBackgroundColor[1], $this->tableHeaderBackgroundColor[2]);
$this->TCPDF->SetDrawColor(255);
$posY = $this->TCPDF->GetY();
$this->TCPDF->MultiCell($this->cellWidth, $this->cellHeight, $longestColumnName, 1, 'C', true);
$maxCellHeight = $this->TCPDF->GetY() - $posY;
$this->TCPDF->SetFillColor($this->tableHeaderBackgroundColor[0], $this->tableHeaderBackgroundColor[1], $this->tableHeaderBackgroundColor[2]);
$this->TCPDF->SetTextColor($this->tableHeaderTextColor[0], $this->tableHeaderTextColor[1], $this->tableHeaderTextColor[2]);
$this->TCPDF->SetDrawColor($this->tableCellBorderColor[0], $this->tableCellBorderColor[1], $this->tableCellBorderColor[2]);
$this->TCPDF->SetXY($initPosX, $posY);
$countColumns = 0;
$posX = $initPosX;
foreach ($this->reportColumns as $columnName) {
$columnName = $this->formatText($columnName);
//Label column
if ($countColumns == 0) {
$this->TCPDF->MultiCell($this->labelCellWidth, $maxCellHeight, $columnName, $border = 0, $align = 'L', true);
$this->TCPDF->SetXY($posX + $this->labelCellWidth, $posY);
} else {
$this->TCPDF->MultiCell($this->cellWidth, $maxCellHeight, $columnName, $border = 0, $align = 'L', true);
$this->TCPDF->SetXY($posX + $this->cellWidth, $posY);
}
$countColumns++;
$posX = $this->TCPDF->GetX();
}
$this->TCPDF->Ln();
$this->TCPDF->SetXY($initPosX, $posY + $maxCellHeight);
} | php | private function paintReportTableHeader()
{
$initPosX = 10;
// Get the longest column name
$longestColumnName = '';
foreach ($this->reportColumns as $columnName) {
if (strlen($columnName) > strlen($longestColumnName)) {
$longestColumnName = $columnName;
}
}
$columnsCount = count($this->reportColumns);
// Computes available column width
if ($this->orientation == self::PORTRAIT
&& $columnsCount <= 3
) {
$totalWidth = $this->reportWidthPortrait * 2 / 3;
} elseif ($this->orientation == self::LANDSCAPE) {
$totalWidth = $this->reportWidthLandscape;
} else {
$totalWidth = $this->reportWidthPortrait;
}
$this->totalWidth = $totalWidth;
$this->labelCellWidth = max(round(($this->totalWidth / $columnsCount)), $this->minWidthLabelCell);
$this->cellWidth = round(($this->totalWidth - $this->labelCellWidth) / ($columnsCount - 1));
$this->totalWidth = $this->labelCellWidth + ($columnsCount - 1) * $this->cellWidth;
$this->TCPDF->SetFillColor($this->tableHeaderBackgroundColor[0], $this->tableHeaderBackgroundColor[1], $this->tableHeaderBackgroundColor[2]);
$this->TCPDF->SetTextColor($this->tableHeaderTextColor[0], $this->tableHeaderTextColor[1], $this->tableHeaderTextColor[2]);
$this->TCPDF->SetLineWidth(.3);
$this->setBorderColor();
$this->TCPDF->SetFont($this->reportFont, $this->reportFontStyle);
$this->TCPDF->SetFillColor(255);
$this->TCPDF->SetTextColor($this->tableHeaderBackgroundColor[0], $this->tableHeaderBackgroundColor[1], $this->tableHeaderBackgroundColor[2]);
$this->TCPDF->SetDrawColor(255);
$posY = $this->TCPDF->GetY();
$this->TCPDF->MultiCell($this->cellWidth, $this->cellHeight, $longestColumnName, 1, 'C', true);
$maxCellHeight = $this->TCPDF->GetY() - $posY;
$this->TCPDF->SetFillColor($this->tableHeaderBackgroundColor[0], $this->tableHeaderBackgroundColor[1], $this->tableHeaderBackgroundColor[2]);
$this->TCPDF->SetTextColor($this->tableHeaderTextColor[0], $this->tableHeaderTextColor[1], $this->tableHeaderTextColor[2]);
$this->TCPDF->SetDrawColor($this->tableCellBorderColor[0], $this->tableCellBorderColor[1], $this->tableCellBorderColor[2]);
$this->TCPDF->SetXY($initPosX, $posY);
$countColumns = 0;
$posX = $initPosX;
foreach ($this->reportColumns as $columnName) {
$columnName = $this->formatText($columnName);
//Label column
if ($countColumns == 0) {
$this->TCPDF->MultiCell($this->labelCellWidth, $maxCellHeight, $columnName, $border = 0, $align = 'L', true);
$this->TCPDF->SetXY($posX + $this->labelCellWidth, $posY);
} else {
$this->TCPDF->MultiCell($this->cellWidth, $maxCellHeight, $columnName, $border = 0, $align = 'L', true);
$this->TCPDF->SetXY($posX + $this->cellWidth, $posY);
}
$countColumns++;
$posX = $this->TCPDF->GetX();
}
$this->TCPDF->Ln();
$this->TCPDF->SetXY($initPosX, $posY + $maxCellHeight);
} | [
"private",
"function",
"paintReportTableHeader",
"(",
")",
"{",
"$",
"initPosX",
"=",
"10",
";",
"// Get the longest column name",
"$",
"longestColumnName",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"reportColumns",
"as",
"$",
"columnName",
")",
"{",
... | Draw the table header (first row) | [
"Draw",
"the",
"table",
"header",
"(",
"first",
"row",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ReportRenderer/Pdf.php#L462-L527 | train | Paints the table header | [
30522,
2797,
3853,
6773,
2890,
6442,
10880,
4974,
2121,
1006,
1007,
1063,
1002,
1999,
4183,
6873,
2015,
2595,
1027,
2184,
1025,
1013,
1013,
2131,
1996,
6493,
5930,
2171,
1002,
6493,
25778,
2819,
9516,
4168,
1027,
1005,
1005,
1025,
18921,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Period/Factory.php | Factory.makePeriodFromQueryParams | public static function makePeriodFromQueryParams($timezone, $period, $date)
{
if (empty($timezone)) {
$timezone = 'UTC';
}
if ($period == 'range') {
self::checkPeriodIsEnabled('range');
$oPeriod = new Range('range', $date, $timezone, Date::factory('today', $timezone));
} else {
if (!($date instanceof Date)) {
if ($date == 'now' || $date == 'today') {
$date = date('Y-m-d', Date::factory('now', $timezone)->getTimestamp());
} elseif ($date == 'yesterday' || $date == 'yesterdaySameTime') {
$date = date('Y-m-d', Date::factory('now', $timezone)->subDay(1)->getTimestamp());
}
$date = Date::factory($date);
}
$oPeriod = Factory::build($period, $date);
}
return $oPeriod;
} | php | public static function makePeriodFromQueryParams($timezone, $period, $date)
{
if (empty($timezone)) {
$timezone = 'UTC';
}
if ($period == 'range') {
self::checkPeriodIsEnabled('range');
$oPeriod = new Range('range', $date, $timezone, Date::factory('today', $timezone));
} else {
if (!($date instanceof Date)) {
if ($date == 'now' || $date == 'today') {
$date = date('Y-m-d', Date::factory('now', $timezone)->getTimestamp());
} elseif ($date == 'yesterday' || $date == 'yesterdaySameTime') {
$date = date('Y-m-d', Date::factory('now', $timezone)->subDay(1)->getTimestamp());
}
$date = Date::factory($date);
}
$oPeriod = Factory::build($period, $date);
}
return $oPeriod;
} | [
"public",
"static",
"function",
"makePeriodFromQueryParams",
"(",
"$",
"timezone",
",",
"$",
"period",
",",
"$",
"date",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"timezone",
")",
")",
"{",
"$",
"timezone",
"=",
"'UTC'",
";",
"}",
"if",
"(",
"$",
"peri... | Creates a Period instance using a period, date and timezone.
@param string $timezone The timezone of the date. Only used if `$date` is `'now'`, `'today'`,
`'yesterday'` or `'yesterdaySameTime'`.
@param string $period The period string: `"day"`, `"week"`, `"month"`, `"year"`, `"range"`.
@param string $date The date or date range string. Can be a special value including
`'now'`, `'today'`, `'yesterday'`, `'yesterdaySameTime'`.
@return \Piwik\Period | [
"Creates",
"a",
"Period",
"instance",
"using",
"a",
"period",
"date",
"and",
"timezone",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Period/Factory.php#L143-L164 | train | MakePeriodFromQueryParams - Builds Period object from query parameters | [
30522,
2270,
10763,
3853,
2191,
4842,
3695,
20952,
21716,
4226,
2854,
28689,
5244,
1006,
1002,
2051,
15975,
1010,
1002,
2558,
1010,
1002,
3058,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2051,
15975,
1007,
1007,
1063,
1002,
2051,
15975,
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... |
getgrav/grav | system/src/Grav/Common/GPM/Response.php | Response.getAuto | private static function getAuto()
{
if (!ini_get('open_basedir') && self::isFopenAvailable()) {
return self::getFopen(func_get_args());
}
if (self::isCurlAvailable()) {
return self::getCurl(func_get_args());
}
return null;
} | php | private static function getAuto()
{
if (!ini_get('open_basedir') && self::isFopenAvailable()) {
return self::getFopen(func_get_args());
}
if (self::isCurlAvailable()) {
return self::getCurl(func_get_args());
}
return null;
} | [
"private",
"static",
"function",
"getAuto",
"(",
")",
"{",
"if",
"(",
"!",
"ini_get",
"(",
"'open_basedir'",
")",
"&&",
"self",
"::",
"isFopenAvailable",
"(",
")",
")",
"{",
"return",
"self",
"::",
"getFopen",
"(",
"func_get_args",
"(",
")",
")",
";",
... | Automatically picks the preferred method
@return string The response of the request | [
"Automatically",
"picks",
"the",
"preferred",
"method"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/Response.php#L256-L267 | train | Get Auto - Open File | [
30522,
2797,
10763,
3853,
2131,
4887,
3406,
1006,
1007,
1063,
2065,
1006,
999,
1999,
2072,
1035,
2131,
1006,
1005,
2330,
1035,
2241,
4313,
1005,
1007,
1004,
1004,
2969,
1024,
1024,
2003,
14876,
11837,
12462,
11733,
3468,
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... |
matomo-org/matomo | libs/Zend/Db/Table/Row/Abstract.php | Zend_Db_Table_Row_Abstract._prepareReference | protected function _prepareReference(Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
{
$parentTableName = (get_class($parentTable) === 'Zend_Db_Table') ? $parentTable->getDefinitionConfigName() : get_class($parentTable);
$map = $dependentTable->getReference($parentTableName, $ruleKey);
if (!isset($map[Zend_Db_Table_Abstract::REF_COLUMNS])) {
$parentInfo = $parentTable->info();
$map[Zend_Db_Table_Abstract::REF_COLUMNS] = array_values((array) $parentInfo['primary']);
}
$map[Zend_Db_Table_Abstract::COLUMNS] = (array) $map[Zend_Db_Table_Abstract::COLUMNS];
$map[Zend_Db_Table_Abstract::REF_COLUMNS] = (array) $map[Zend_Db_Table_Abstract::REF_COLUMNS];
return $map;
} | php | protected function _prepareReference(Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
{
$parentTableName = (get_class($parentTable) === 'Zend_Db_Table') ? $parentTable->getDefinitionConfigName() : get_class($parentTable);
$map = $dependentTable->getReference($parentTableName, $ruleKey);
if (!isset($map[Zend_Db_Table_Abstract::REF_COLUMNS])) {
$parentInfo = $parentTable->info();
$map[Zend_Db_Table_Abstract::REF_COLUMNS] = array_values((array) $parentInfo['primary']);
}
$map[Zend_Db_Table_Abstract::COLUMNS] = (array) $map[Zend_Db_Table_Abstract::COLUMNS];
$map[Zend_Db_Table_Abstract::REF_COLUMNS] = (array) $map[Zend_Db_Table_Abstract::REF_COLUMNS];
return $map;
} | [
"protected",
"function",
"_prepareReference",
"(",
"Zend_Db_Table_Abstract",
"$",
"dependentTable",
",",
"Zend_Db_Table_Abstract",
"$",
"parentTable",
",",
"$",
"ruleKey",
")",
"{",
"$",
"parentTableName",
"=",
"(",
"get_class",
"(",
"$",
"parentTable",
")",
"===",
... | Prepares a table reference for lookup.
Ensures all reference keys are set and properly formatted.
@param Zend_Db_Table_Abstract $dependentTable
@param Zend_Db_Table_Abstract $parentTable
@param string $ruleKey
@return array | [
"Prepares",
"a",
"table",
"reference",
"for",
"lookup",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Row/Abstract.php#L842-L856 | train | Prepare reference map | [
30522,
5123,
3853,
1035,
7374,
2890,
25523,
1006,
16729,
2094,
1035,
16962,
1035,
2795,
1035,
10061,
1002,
7790,
10880,
1010,
16729,
2094,
1035,
16962,
1035,
2795,
1035,
10061,
1002,
6687,
10880,
1010,
1002,
3627,
14839,
1007,
1063,
1002,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Stopwatch/Section.php | Section.isEventStarted | public function isEventStarted($name)
{
return isset($this->events[$name]) && $this->events[$name]->isStarted();
} | php | public function isEventStarted($name)
{
return isset($this->events[$name]) && $this->events[$name]->isStarted();
} | [
"public",
"function",
"isEventStarted",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"name",
"]",
")",
"&&",
"$",
"this",
"->",
"events",
"[",
"$",
"name",
"]",
"->",
"isStarted",
"(",
")",
";",
"}"
] | Checks if the event was started.
@param string $name The event name
@return bool | [
"Checks",
"if",
"the",
"event",
"was",
"started",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Stopwatch/Section.php#L134-L137 | train | Checks if an event is started | [
30522,
2270,
3853,
2003,
18697,
7666,
7559,
3064,
1006,
1002,
2171,
1007,
1063,
2709,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2824,
1031,
1002,
2171,
1033,
1007,
1004,
1004,
1002,
2023,
1011,
1028,
2824,
1031,
1002,
2171,
1033,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Ecommerce/Columns/RevenueDiscount.php | RevenueDiscount.onEcommerceOrderConversion | public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
return $this->roundRevenueIfNeeded($request->getParam('ec_dt'));
} | php | public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
return $this->roundRevenueIfNeeded($request->getParam('ec_dt'));
} | [
"public",
"function",
"onEcommerceOrderConversion",
"(",
"Request",
"$",
"request",
",",
"Visitor",
"$",
"visitor",
",",
"$",
"action",
",",
"GoalManager",
"$",
"goalManager",
")",
"{",
"return",
"$",
"this",
"->",
"roundRevenueIfNeeded",
"(",
"$",
"request",
... | @param Request $request
@param Visitor $visitor
@param Action|null $action
@param GoalManager $goalManager
@return mixed|false | [
"@param",
"Request",
"$request",
"@param",
"Visitor",
"$visitor",
"@param",
"Action|null",
"$action",
"@param",
"GoalManager",
"$goalManager"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Ecommerce/Columns/RevenueDiscount.php#L32-L35 | train | This method is triggered when an ecommerce order conversion is triggered. | [
30522,
2270,
3853,
2028,
9006,
5017,
3401,
8551,
2121,
8663,
27774,
1006,
5227,
1002,
5227,
1010,
10367,
1002,
10367,
1010,
1002,
2895,
1010,
3125,
24805,
4590,
1002,
3125,
24805,
4590,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2461,
2890,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.copyFolder | public function copyFolder($originalPath, $newPath)
{
$disk = $this->getStorageDisk();
$copyDirectory = function ($srcPath, $destPath) use (&$copyDirectory, $disk) {
$srcPath = self::validatePath($srcPath);
$fullSrcPath = $this->getMediaPath($srcPath);
$destPath = self::validatePath($destPath);
$fullDestPath = $this->getMediaPath($destPath);
if (!$disk->makeDirectory($fullDestPath)) {
return false;
}
$folderContents = $this->scanFolderContents($fullSrcPath);
foreach ($folderContents['folders'] as $dirInfo) {
if (!$copyDirectory($dirInfo->path, $destPath.'/'.basename($dirInfo->path))) {
return false;
}
}
foreach ($folderContents['files'] as $fileInfo) {
$fullFileSrcPath = $this->getMediaPath($fileInfo->path);
if (!$disk->copy($fullFileSrcPath, $fullDestPath.'/'.basename($fileInfo->path))) {
return false;
}
}
return true;
};
return $copyDirectory($originalPath, $newPath);
} | php | public function copyFolder($originalPath, $newPath)
{
$disk = $this->getStorageDisk();
$copyDirectory = function ($srcPath, $destPath) use (&$copyDirectory, $disk) {
$srcPath = self::validatePath($srcPath);
$fullSrcPath = $this->getMediaPath($srcPath);
$destPath = self::validatePath($destPath);
$fullDestPath = $this->getMediaPath($destPath);
if (!$disk->makeDirectory($fullDestPath)) {
return false;
}
$folderContents = $this->scanFolderContents($fullSrcPath);
foreach ($folderContents['folders'] as $dirInfo) {
if (!$copyDirectory($dirInfo->path, $destPath.'/'.basename($dirInfo->path))) {
return false;
}
}
foreach ($folderContents['files'] as $fileInfo) {
$fullFileSrcPath = $this->getMediaPath($fileInfo->path);
if (!$disk->copy($fullFileSrcPath, $fullDestPath.'/'.basename($fileInfo->path))) {
return false;
}
}
return true;
};
return $copyDirectory($originalPath, $newPath);
} | [
"public",
"function",
"copyFolder",
"(",
"$",
"originalPath",
",",
"$",
"newPath",
")",
"{",
"$",
"disk",
"=",
"$",
"this",
"->",
"getStorageDisk",
"(",
")",
";",
"$",
"copyDirectory",
"=",
"function",
"(",
"$",
"srcPath",
",",
"$",
"destPath",
")",
"u... | Copies a folder.
@param string $originalPath Specifies the original path of the folder.
@param string $newPath Specifies the new path of the folder.
@return boolean | [
"Copies",
"a",
"folder",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L352-L387 | train | Copy folder to new path | [
30522,
2270,
3853,
6100,
10371,
2121,
1006,
1002,
2434,
15069,
1010,
1002,
2047,
15069,
1007,
1063,
1002,
9785,
1027,
1002,
2023,
1011,
1028,
4152,
4263,
18655,
20573,
1006,
1007,
1025,
1002,
6100,
4305,
2890,
16761,
2100,
1027,
3853,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Data/Data.php | Data.file | public function file(FileInterface $storage = null)
{
if ($storage) {
$this->storage = $storage;
}
return $this->storage;
} | php | public function file(FileInterface $storage = null)
{
if ($storage) {
$this->storage = $storage;
}
return $this->storage;
} | [
"public",
"function",
"file",
"(",
"FileInterface",
"$",
"storage",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"storage",
")",
"{",
"$",
"this",
"->",
"storage",
"=",
"$",
"storage",
";",
"}",
"return",
"$",
"this",
"->",
"storage",
";",
"}"
] | Set or get the data storage.
@param FileInterface $storage Optionally enter a new storage.
@return FileInterface | [
"Set",
"or",
"get",
"the",
"data",
"storage",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Data.php#L286-L293 | train | Get the file | [
30522,
2270,
3853,
5371,
1006,
5371,
18447,
2121,
12172,
1002,
5527,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
5527,
1007,
1063,
1002,
2023,
1011,
1028,
5527,
1027,
1002,
5527,
1025,
1065,
2709,
1002,
2023,
1011,
1028,
5527,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/traits/CollapsableWidget.php | CollapsableWidget.getCollapseStatus | protected function getCollapseStatus($group, $default = true)
{
$statuses = $this->getCollapseStatuses();
if (array_key_exists($group, $statuses)) {
return $statuses[$group];
}
return $default;
} | php | protected function getCollapseStatus($group, $default = true)
{
$statuses = $this->getCollapseStatuses();
if (array_key_exists($group, $statuses)) {
return $statuses[$group];
}
return $default;
} | [
"protected",
"function",
"getCollapseStatus",
"(",
"$",
"group",
",",
"$",
"default",
"=",
"true",
")",
"{",
"$",
"statuses",
"=",
"$",
"this",
"->",
"getCollapseStatuses",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"group",
",",
"$",
"statu... | Gets a collapsed state.
@param string $group
@param bool $default
@return bool|string | [
"Gets",
"a",
"collapsed",
"state",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/traits/CollapsableWidget.php#L79-L88 | train | Get Collapse Status | [
30522,
5123,
3853,
2131,
26895,
9331,
8583,
29336,
2271,
1006,
1002,
2177,
1010,
1002,
12398,
1027,
2995,
1007,
1063,
1002,
3570,
2229,
1027,
1002,
2023,
1011,
1028,
2131,
26895,
9331,
8583,
29336,
25581,
1006,
1007,
1025,
2065,
1006,
9140,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/BrowserKit/CookieJar.php | CookieJar.updateFromResponse | public function updateFromResponse(Response $response, $uri = null)
{
$this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri);
} | php | public function updateFromResponse(Response $response, $uri = null)
{
$this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri);
} | [
"public",
"function",
"updateFromResponse",
"(",
"Response",
"$",
"response",
",",
"$",
"uri",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"updateFromSetCookie",
"(",
"$",
"response",
"->",
"getHeader",
"(",
"'Set-Cookie'",
",",
"false",
")",
",",
"$",
"uri"... | Updates the cookie jar from a Response object.
@param Response $response A Response object
@param string $uri The base URL | [
"Updates",
"the",
"cookie",
"jar",
"from",
"a",
"Response",
"object",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/CookieJar.php#L146-L149 | train | Update the current page from a response. | [
30522,
2270,
3853,
10651,
19699,
5358,
6072,
26029,
3366,
1006,
3433,
1002,
3433,
1010,
1002,
24471,
2072,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
10651,
19699,
22225,
3388,
3597,
23212,
2063,
1006,
1002,
3433,
1011,
1028,
2131,
49... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getSocials | public function getSocials($idSite, $period, $date, $segment = false, $expanded = false, $flat = false)
{
Piwik::checkUserHasViewAccess($idSite);
$dataTable = Archive::createDataTableFromArchive(Archiver::SOCIAL_NETWORKS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $flat);
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', function ($name) {
return Social::getInstance()->getMainUrlFromName($name);
}));
$dataTable = $this->completeSocialTablesWithOldReports($dataTable, $idSite, $period, $date, $segment, $expanded, $flat);
$dataTable->filter('MetadataCallbackAddMetadata', array('url', 'logo', function ($url) { return Social::getInstance()->getLogoFromUrl($url); }));
return $dataTable;
} | php | public function getSocials($idSite, $period, $date, $segment = false, $expanded = false, $flat = false)
{
Piwik::checkUserHasViewAccess($idSite);
$dataTable = Archive::createDataTableFromArchive(Archiver::SOCIAL_NETWORKS_RECORD_NAME, $idSite, $period, $date, $segment, $expanded, $flat);
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'url', function ($name) {
return Social::getInstance()->getMainUrlFromName($name);
}));
$dataTable = $this->completeSocialTablesWithOldReports($dataTable, $idSite, $period, $date, $segment, $expanded, $flat);
$dataTable->filter('MetadataCallbackAddMetadata', array('url', 'logo', function ($url) { return Social::getInstance()->getLogoFromUrl($url); }));
return $dataTable;
} | [
"public",
"function",
"getSocials",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"expanded",
"=",
"false",
",",
"$",
"flat",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",... | Returns report comparing the number of visits (and other info) for social network referrers.
This is a view of the getWebsites report.
@param string $idSite
@param string $period
@param string $date
@param string|bool $segment
@param bool $expanded
@param bool $flat
@return DataTable | [
"Returns",
"report",
"comparing",
"the",
"number",
"of",
"visits",
"(",
"and",
"other",
"info",
")",
"for",
"social",
"network",
"referrers",
".",
"This",
"is",
"a",
"view",
"of",
"the",
"getWebsites",
"report",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L362-L377 | train | Get the list of social networks | [
30522,
2270,
3853,
4152,
10085,
26340,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1010,
1002,
4423,
1027,
6270,
1010,
1002,
4257,
1027,
6270,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/API/Request.php | Request.shouldLoadExpanded | public static function shouldLoadExpanded()
{
// if filter_column_recursive & filter_pattern_recursive are supplied, and flat isn't supplied
// we have to load all the child subtables.
return Common::getRequestVar('filter_column_recursive', false) !== false
&& Common::getRequestVar('filter_pattern_recursive', false) !== false
&& !self::shouldLoadFlatten();
} | php | public static function shouldLoadExpanded()
{
// if filter_column_recursive & filter_pattern_recursive are supplied, and flat isn't supplied
// we have to load all the child subtables.
return Common::getRequestVar('filter_column_recursive', false) !== false
&& Common::getRequestVar('filter_pattern_recursive', false) !== false
&& !self::shouldLoadFlatten();
} | [
"public",
"static",
"function",
"shouldLoadExpanded",
"(",
")",
"{",
"// if filter_column_recursive & filter_pattern_recursive are supplied, and flat isn't supplied",
"// we have to load all the child subtables.",
"return",
"Common",
"::",
"getRequestVar",
"(",
"'filter_column_recursive'... | Returns whether the DataTable result will have to be expanded for the
current request before rendering.
@return bool
@ignore | [
"Returns",
"whether",
"the",
"DataTable",
"result",
"will",
"have",
"to",
"be",
"expanded",
"for",
"the",
"current",
"request",
"before",
"rendering",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Request.php#L569-L576 | train | Returns true if the expanded tree of subtables should be loaded. | [
30522,
2270,
10763,
3853,
2323,
11066,
10288,
9739,
5732,
1006,
1007,
1063,
1013,
1013,
2065,
11307,
1035,
5930,
1035,
28667,
9236,
3512,
1004,
11307,
1035,
5418,
1035,
28667,
9236,
3512,
2024,
8127,
1010,
1998,
4257,
3475,
1005,
1056,
8127... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.depth | public function depth($levels)
{
foreach ((array) $levels as $level) {
$this->depths[] = new Comparator\NumberComparator($level);
}
return $this;
} | php | public function depth($levels)
{
foreach ((array) $levels as $level) {
$this->depths[] = new Comparator\NumberComparator($level);
}
return $this;
} | [
"public",
"function",
"depth",
"(",
"$",
"levels",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"levels",
"as",
"$",
"level",
")",
"{",
"$",
"this",
"->",
"depths",
"[",
"]",
"=",
"new",
"Comparator",
"\\",
"NumberComparator",
"(",
"$",
"level",... | Adds tests for the directory depth.
Usage:
$finder->depth('> 1') // the Finder will start matching at level 1.
$finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
$finder->depth(['>= 1', '< 3'])
@param string|int|string[]|int[] $levels The depth level expression or an array of depth levels
@return $this
@see DepthRangeFilterIterator
@see NumberComparator | [
"Adds",
"tests",
"for",
"the",
"directory",
"depth",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Finder/Finder.php#L122-L129 | train | Depth - based search | [
30522,
2270,
3853,
5995,
1006,
1002,
3798,
1007,
1063,
18921,
6776,
1006,
1006,
9140,
1007,
1002,
3798,
2004,
1002,
2504,
1007,
1063,
1002,
2023,
1011,
1028,
11143,
1031,
1033,
1027,
2047,
4012,
28689,
4263,
1032,
2193,
9006,
28689,
4263,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/thrift | lib/php/lib/Server/TSSLServerSocket.php | TSSLServerSocket.listen | public function listen()
{
$this->listener_ = @stream_socket_server(
$this->host_ . ':' . $this->port_,
$errno,
$errstr,
STREAM_SERVER_BIND | STREAM_SERVER_LISTEN,
$this->context_
);
} | php | public function listen()
{
$this->listener_ = @stream_socket_server(
$this->host_ . ':' . $this->port_,
$errno,
$errstr,
STREAM_SERVER_BIND | STREAM_SERVER_LISTEN,
$this->context_
);
} | [
"public",
"function",
"listen",
"(",
")",
"{",
"$",
"this",
"->",
"listener_",
"=",
"@",
"stream_socket_server",
"(",
"$",
"this",
"->",
"host_",
".",
"':'",
".",
"$",
"this",
"->",
"port_",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"STREAM_SERVER_BI... | Opens a new socket server handle
@return void | [
"Opens",
"a",
"new",
"socket",
"server",
"handle"
] | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Server/TSSLServerSocket.php#L69-L78 | train | Create a stream socket server | [
30522,
2270,
3853,
4952,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
19373,
1035,
1027,
1030,
5460,
1035,
22278,
1035,
8241,
1006,
1002,
2023,
1011,
1028,
3677,
1035,
1012,
1005,
1024,
1005,
1012,
1002,
2023,
1011,
1028,
3417,
1035,
1010,
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/PrivacyManager/LogDataPurger.php | LogDataPurger.getPurgeEstimate | public function getPurgeEstimate($deleteLogsOlderThan)
{
$result = array();
// deal w/ log tables that will be purged
$maxIdVisit = $this->getDeleteIdVisitOffset($deleteLogsOlderThan);
if (!empty($maxIdVisit)) {
foreach (self::getDeleteTableLogTables() as $table) {
// getting an estimate for log_action is not supported since it can take too long
if ($table != Common::prefixTable('log_action')) {
$rowCount = $this->getLogTableDeleteCount($table, $maxIdVisit);
if ($rowCount > 0) {
$result[$table] = $rowCount;
}
}
}
}
return $result;
} | php | public function getPurgeEstimate($deleteLogsOlderThan)
{
$result = array();
// deal w/ log tables that will be purged
$maxIdVisit = $this->getDeleteIdVisitOffset($deleteLogsOlderThan);
if (!empty($maxIdVisit)) {
foreach (self::getDeleteTableLogTables() as $table) {
// getting an estimate for log_action is not supported since it can take too long
if ($table != Common::prefixTable('log_action')) {
$rowCount = $this->getLogTableDeleteCount($table, $maxIdVisit);
if ($rowCount > 0) {
$result[$table] = $rowCount;
}
}
}
}
return $result;
} | [
"public",
"function",
"getPurgeEstimate",
"(",
"$",
"deleteLogsOlderThan",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// deal w/ log tables that will be purged",
"$",
"maxIdVisit",
"=",
"$",
"this",
"->",
"getDeleteIdVisitOffset",
"(",
"$",
"deleteLogsOl... | Returns an array describing what data would be purged if purging were invoked.
This function returns an array that maps table names with the number of rows
that will be deleted.
@param int $deleteLogsOlderThan The number of days after which log entires are considered old.
Visits and related data whose age is greater than this number
will be purged.
@return array
TODO: purge estimate uses max idvisit w/ time, but purge does not, so estimate may be less accurate.
to be more accurate, it should use the same strategy as purgeData(), but this could be very slow. | [
"Returns",
"an",
"array",
"describing",
"what",
"data",
"would",
"be",
"purged",
"if",
"purging",
"were",
"invoked",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/LogDataPurger.php#L117-L136 | train | Returns an estimate of the number of log tables that will be purged | [
30522,
2270,
3853,
2131,
5311,
18372,
16643,
8585,
1006,
1002,
3972,
12870,
21197,
19454,
4063,
21604,
1007,
1063,
1002,
2765,
1027,
9140,
1006,
1007,
1025,
1013,
1013,
3066,
1059,
1013,
8833,
7251,
2008,
2097,
2022,
24694,
2094,
1002,
2151... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SettingsServer.php | SettingsServer.isGdExtensionEnabled | public static function isGdExtensionEnabled()
{
static $gd = null;
if (is_null($gd)) {
$gd = false;
$extensions = @get_loaded_extensions();
if (is_array($extensions)) {
$gd = in_array('gd', $extensions) && function_exists('imageftbbox');
}
}
return $gd;
} | php | public static function isGdExtensionEnabled()
{
static $gd = null;
if (is_null($gd)) {
$gd = false;
$extensions = @get_loaded_extensions();
if (is_array($extensions)) {
$gd = in_array('gd', $extensions) && function_exists('imageftbbox');
}
}
return $gd;
} | [
"public",
"static",
"function",
"isGdExtensionEnabled",
"(",
")",
"{",
"static",
"$",
"gd",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"gd",
")",
")",
"{",
"$",
"gd",
"=",
"false",
";",
"$",
"extensions",
"=",
"@",
"get_loaded_extensions",
"(",
... | Returns `true` if the GD PHP extension is available, `false` if otherwise.
_Note: ImageGraph and the sparkline report visualization depend on the GD extension._
@return bool
@api | [
"Returns",
"true",
"if",
"the",
"GD",
"PHP",
"extension",
"is",
"available",
"false",
"if",
"otherwise",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/SettingsServer.php#L112-L125 | train | Return true if the GD extension is enabled | [
30522,
2270,
10763,
3853,
2003,
2290,
3207,
18413,
6132,
3258,
8189,
23242,
1006,
1007,
1063,
10763,
1002,
1043,
2094,
1027,
19701,
1025,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
1043,
2094,
1007,
1007,
1063,
1002,
1043,
2094,
1027,
6270,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/PluginManager.php | PluginManager.deletePlugin | public function deletePlugin($id)
{
/*
* Rollback plugin
*/
UpdateManager::instance()->rollbackPlugin($id);
/*
* Delete from file system
*/
if ($pluginPath = self::instance()->getPluginPath($id)) {
File::deleteDirectory($pluginPath);
}
} | php | public function deletePlugin($id)
{
/*
* Rollback plugin
*/
UpdateManager::instance()->rollbackPlugin($id);
/*
* Delete from file system
*/
if ($pluginPath = self::instance()->getPluginPath($id)) {
File::deleteDirectory($pluginPath);
}
} | [
"public",
"function",
"deletePlugin",
"(",
"$",
"id",
")",
"{",
"/*\n * Rollback plugin\n */",
"UpdateManager",
"::",
"instance",
"(",
")",
"->",
"rollbackPlugin",
"(",
"$",
"id",
")",
";",
"/*\n * Delete from file system\n */",
"if",
"("... | Completely roll back and delete a plugin from the system.
@param string $id Plugin code/namespace
@return void | [
"Completely",
"roll",
"back",
"and",
"delete",
"a",
"plugin",
"from",
"the",
"system",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/PluginManager.php#L763-L776 | train | Delete a plugin | [
30522,
2270,
3853,
3972,
12870,
24759,
15916,
2378,
1006,
1002,
8909,
1007,
1063,
1013,
1008,
1008,
4897,
5963,
13354,
2378,
1008,
1013,
10651,
24805,
4590,
1024,
1024,
6013,
1006,
1007,
1011,
1028,
4897,
5963,
24759,
15916,
2378,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Capsule/Manager.php | Manager.push | public static function push($job, $data = '', $queue = null, $connection = null)
{
return static::$instance->connection($connection)->push($job, $data, $queue);
} | php | public static function push($job, $data = '', $queue = null, $connection = null)
{
return static::$instance->connection($connection)->push($job, $data, $queue);
} | [
"public",
"static",
"function",
"push",
"(",
"$",
"job",
",",
"$",
"data",
"=",
"''",
",",
"$",
"queue",
"=",
"null",
",",
"$",
"connection",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"$",
"instance",
"->",
"connection",
"(",
"$",
"connection"... | Push a new job onto the queue.
@param string $job
@param mixed $data
@param string $queue
@param string $connection
@return mixed | [
"Push",
"a",
"new",
"job",
"onto",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Capsule/Manager.php#L97-L100 | train | Push a job to the queue | [
30522,
2270,
10763,
3853,
5245,
1006,
1002,
3105,
1010,
1002,
2951,
1027,
1005,
1005,
1010,
1002,
24240,
1027,
19701,
1010,
1002,
4434,
1027,
19701,
1007,
1063,
2709,
10763,
1024,
1024,
1002,
6013,
1011,
1028,
4434,
1006,
1002,
4434,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Oci.php | Zend_Db_Adapter_Pdo_Oci.describeTable | public function describeTable($tableName, $schemaName = null)
{
$version = $this->getServerVersion();
if (($version === null) || version_compare($version, '9.0.0', '>=')) {
$sql = "SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
FROM ALL_TAB_COLUMNS TC
LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
$bind[':TBNAME'] = $tableName;
if ($schemaName) {
$sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
$bind[':SCNAME'] = $schemaName;
}
$sql .= ' ORDER BY TC.COLUMN_ID';
} else {
$subSql="SELECT AC.OWNER, AC.TABLE_NAME, ACC.COLUMN_NAME, AC.CONSTRAINT_TYPE, ACC.POSITION
from ALL_CONSTRAINTS AC, ALL_CONS_COLUMNS ACC
WHERE ACC.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
AND ACC.TABLE_NAME = AC.TABLE_NAME
AND ACC.OWNER = AC.OWNER
AND AC.CONSTRAINT_TYPE = 'P'
AND UPPER(AC.TABLE_NAME) = UPPER(:TBNAME)";
$bind[':TBNAME'] = $tableName;
if ($schemaName) {
$subSql .= ' AND UPPER(ACC.OWNER) = UPPER(:SCNAME)';
$bind[':SCNAME'] = $schemaName;
}
$sql="SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
TC.DATA_SCALE, TC.DATA_PRECISION, CC.CONSTRAINT_TYPE, CC.POSITION
FROM ALL_TAB_COLUMNS TC, ($subSql) CC
WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)
AND TC.OWNER = CC.OWNER(+) AND TC.TABLE_NAME = CC.TABLE_NAME(+) AND TC.COLUMN_NAME = CC.COLUMN_NAME(+)";
if ($schemaName) {
$sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
}
$sql .= ' ORDER BY TC.COLUMN_ID';
}
$stmt = $this->query($sql, $bind);
/**
* Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
*/
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$table_name = 0;
$owner = 1;
$column_name = 2;
$data_type = 3;
$data_default = 4;
$nullable = 5;
$column_id = 6;
$data_length = 7;
$data_scale = 8;
$data_precision = 9;
$constraint_type = 10;
$position = 11;
$desc = array();
foreach ($result as $key => $row) {
list ($primary, $primaryPosition, $identity) = array(false, null, false);
if ($row[$constraint_type] == 'P') {
$primary = true;
$primaryPosition = $row[$position];
/**
* Oracle does not support auto-increment keys.
*/
$identity = false;
}
$desc[$this->foldCase($row[$column_name])] = array(
'SCHEMA_NAME' => $this->foldCase($row[$owner]),
'TABLE_NAME' => $this->foldCase($row[$table_name]),
'COLUMN_NAME' => $this->foldCase($row[$column_name]),
'COLUMN_POSITION' => $row[$column_id],
'DATA_TYPE' => $row[$data_type],
'DEFAULT' => $row[$data_default],
'NULLABLE' => (bool) ($row[$nullable] == 'Y'),
'LENGTH' => $row[$data_length],
'SCALE' => $row[$data_scale],
'PRECISION' => $row[$data_precision],
'UNSIGNED' => null, // @todo
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
}
return $desc;
} | php | public function describeTable($tableName, $schemaName = null)
{
$version = $this->getServerVersion();
if (($version === null) || version_compare($version, '9.0.0', '>=')) {
$sql = "SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
FROM ALL_TAB_COLUMNS TC
LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
$bind[':TBNAME'] = $tableName;
if ($schemaName) {
$sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
$bind[':SCNAME'] = $schemaName;
}
$sql .= ' ORDER BY TC.COLUMN_ID';
} else {
$subSql="SELECT AC.OWNER, AC.TABLE_NAME, ACC.COLUMN_NAME, AC.CONSTRAINT_TYPE, ACC.POSITION
from ALL_CONSTRAINTS AC, ALL_CONS_COLUMNS ACC
WHERE ACC.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
AND ACC.TABLE_NAME = AC.TABLE_NAME
AND ACC.OWNER = AC.OWNER
AND AC.CONSTRAINT_TYPE = 'P'
AND UPPER(AC.TABLE_NAME) = UPPER(:TBNAME)";
$bind[':TBNAME'] = $tableName;
if ($schemaName) {
$subSql .= ' AND UPPER(ACC.OWNER) = UPPER(:SCNAME)';
$bind[':SCNAME'] = $schemaName;
}
$sql="SELECT TC.TABLE_NAME, TC.OWNER, TC.COLUMN_NAME, TC.DATA_TYPE,
TC.DATA_DEFAULT, TC.NULLABLE, TC.COLUMN_ID, TC.DATA_LENGTH,
TC.DATA_SCALE, TC.DATA_PRECISION, CC.CONSTRAINT_TYPE, CC.POSITION
FROM ALL_TAB_COLUMNS TC, ($subSql) CC
WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)
AND TC.OWNER = CC.OWNER(+) AND TC.TABLE_NAME = CC.TABLE_NAME(+) AND TC.COLUMN_NAME = CC.COLUMN_NAME(+)";
if ($schemaName) {
$sql .= ' AND UPPER(TC.OWNER) = UPPER(:SCNAME)';
}
$sql .= ' ORDER BY TC.COLUMN_ID';
}
$stmt = $this->query($sql, $bind);
/**
* Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
*/
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$table_name = 0;
$owner = 1;
$column_name = 2;
$data_type = 3;
$data_default = 4;
$nullable = 5;
$column_id = 6;
$data_length = 7;
$data_scale = 8;
$data_precision = 9;
$constraint_type = 10;
$position = 11;
$desc = array();
foreach ($result as $key => $row) {
list ($primary, $primaryPosition, $identity) = array(false, null, false);
if ($row[$constraint_type] == 'P') {
$primary = true;
$primaryPosition = $row[$position];
/**
* Oracle does not support auto-increment keys.
*/
$identity = false;
}
$desc[$this->foldCase($row[$column_name])] = array(
'SCHEMA_NAME' => $this->foldCase($row[$owner]),
'TABLE_NAME' => $this->foldCase($row[$table_name]),
'COLUMN_NAME' => $this->foldCase($row[$column_name]),
'COLUMN_POSITION' => $row[$column_id],
'DATA_TYPE' => $row[$data_type],
'DEFAULT' => $row[$data_default],
'NULLABLE' => (bool) ($row[$nullable] == 'Y'),
'LENGTH' => $row[$data_length],
'SCALE' => $row[$data_scale],
'PRECISION' => $row[$data_precision],
'UNSIGNED' => null, // @todo
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
}
return $desc;
} | [
"public",
"function",
"describeTable",
"(",
"$",
"tableName",
",",
"$",
"schemaName",
"=",
"null",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getServerVersion",
"(",
")",
";",
"if",
"(",
"(",
"$",
"version",
"===",
"null",
")",
"||",
"version_c... | Returns the column descriptions for a table.
The return value is an associative array keyed by the column name,
as returned by the RDBMS.
The value of each array element is an associative array
with the following keys:
SCHEMA_NAME => string; name of schema
TABLE_NAME => string;
COLUMN_NAME => string; column name
COLUMN_POSITION => number; ordinal position of column in table
DATA_TYPE => string; SQL datatype name of column
DEFAULT => string; default expression of column, null if none
NULLABLE => boolean; true if column can have nulls
LENGTH => number; length of CHAR/VARCHAR
SCALE => number; scale of NUMERIC/DECIMAL
PRECISION => number; precision of NUMERIC/DECIMAL
UNSIGNED => boolean; unsigned property of an integer type
PRIMARY => boolean; true if column is part of the primary key
PRIMARY_POSITION => integer; position of column in primary key
IDENTITY => integer; true if column is auto-generated with unique values
@todo Discover integer unsigned property.
@param string $tableName
@param string $schemaName OPTIONAL
@return array | [
"Returns",
"the",
"column",
"descriptions",
"for",
"a",
"table",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Oci.php#L180-L272 | train | Describes a table | [
30522,
2270,
3853,
6235,
10880,
1006,
1002,
2795,
18442,
1010,
1002,
8040,
28433,
18442,
1027,
19701,
1007,
1063,
1002,
2544,
1027,
1002,
2023,
1011,
1028,
4152,
2121,
6299,
27774,
1006,
1007,
1025,
2065,
1006,
1006,
1002,
2544,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Abstract.php | Zend_Db_Adapter_Abstract.query | public function query($sql, $bind = array())
{
// connect to the database if needed
$this->_connect();
// is the $sql a Zend_Db_Select object?
if ($sql instanceof Zend_Db_Select) {
if (empty($bind)) {
$bind = $sql->getBind();
}
$sql = $sql->assemble();
}
// make sure $bind to an array;
// don't use (array) typecasting because
// because $bind may be a Zend_Db_Expr object
if (!is_array($bind)) {
$bind = array($bind);
}
// prepare and execute the statement with profiling
$stmt = $this->prepare($sql);
$stmt->execute($bind);
// return the results embedded in the prepared statement object
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
} | php | public function query($sql, $bind = array())
{
// connect to the database if needed
$this->_connect();
// is the $sql a Zend_Db_Select object?
if ($sql instanceof Zend_Db_Select) {
if (empty($bind)) {
$bind = $sql->getBind();
}
$sql = $sql->assemble();
}
// make sure $bind to an array;
// don't use (array) typecasting because
// because $bind may be a Zend_Db_Expr object
if (!is_array($bind)) {
$bind = array($bind);
}
// prepare and execute the statement with profiling
$stmt = $this->prepare($sql);
$stmt->execute($bind);
// return the results embedded in the prepared statement object
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
} | [
"public",
"function",
"query",
"(",
"$",
"sql",
",",
"$",
"bind",
"=",
"array",
"(",
")",
")",
"{",
"// connect to the database if needed",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"// is the $sql a Zend_Db_Select object?",
"if",
"(",
"$",
"sql",
"instanc... | Prepares and executes an SQL statement with bound data.
@param mixed $sql The SQL statement with placeholders.
May be a string or Zend_Db_Select.
@param mixed $bind An array of data to bind to the placeholders.
@return Zend_Db_Statement_Interface | [
"Prepares",
"and",
"executes",
"an",
"SQL",
"statement",
"with",
"bound",
"data",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Abstract.php#L456-L484 | train | Execute a statement with profiling | [
30522,
2270,
3853,
23032,
1006,
1002,
29296,
1010,
1002,
14187,
1027,
9140,
1006,
1007,
1007,
1063,
1013,
1013,
7532,
2000,
1996,
7809,
2065,
2734,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1013,
1013,
2003,
1996,
1002,
29296,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/GPM/Installer.php | Installer.install | public static function install($zip, $destination, $options = [], $extracted = null, $keepExtracted = false)
{
$destination = rtrim($destination, DS);
$options = array_merge(self::$options, $options);
$install_path = rtrim($destination . DS . ltrim($options['install_path'], DS), DS);
if (!self::isGravInstance($destination) || !self::isValidDestination($install_path,
$options['exclude_checks'])
) {
return false;
}
if ((self::lastErrorCode() === self::IS_LINK && $options['ignore_symlinks']) ||
(self::lastErrorCode() === self::EXISTS && !$options['overwrite'])
) {
return false;
}
// Create a tmp location
$tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
$tmp = $tmp_dir . '/Grav-' . uniqid('', false);
if (!$extracted) {
$extracted = self::unZip($zip, $tmp);
if (!$extracted) {
Folder::delete($tmp);
return false;
}
}
if (!file_exists($extracted)) {
self::$error = self::INVALID_SOURCE;
return false;
}
$is_install = true;
$installer = self::loadInstaller($extracted, $is_install);
if (isset($options['is_update']) && $options['is_update'] === true) {
$method = 'preUpdate';
} else {
$method = 'preInstall';
}
if ($installer && method_exists($installer, $method)) {
$method_result = $installer::$method();
if ($method_result !== true) {
self::$error = 'An error occurred';
if (is_string($method_result)) {
self::$error = $method_result;
}
return false;
}
}
if (!$options['sophisticated']) {
if ($options['theme']) {
self::copyInstall($extracted, $install_path);
} else {
self::moveInstall($extracted, $install_path);
}
} else {
self::sophisticatedInstall($extracted, $install_path, $options['ignores'], $keepExtracted);
}
Folder::delete($tmp);
if (isset($options['is_update']) && $options['is_update'] === true) {
$method = 'postUpdate';
} else {
$method = 'postInstall';
}
self::$message = '';
if ($installer && method_exists($installer, $method)) {
self::$message = $installer::$method();
}
self::$error = self::OK;
return true;
} | php | public static function install($zip, $destination, $options = [], $extracted = null, $keepExtracted = false)
{
$destination = rtrim($destination, DS);
$options = array_merge(self::$options, $options);
$install_path = rtrim($destination . DS . ltrim($options['install_path'], DS), DS);
if (!self::isGravInstance($destination) || !self::isValidDestination($install_path,
$options['exclude_checks'])
) {
return false;
}
if ((self::lastErrorCode() === self::IS_LINK && $options['ignore_symlinks']) ||
(self::lastErrorCode() === self::EXISTS && !$options['overwrite'])
) {
return false;
}
// Create a tmp location
$tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true);
$tmp = $tmp_dir . '/Grav-' . uniqid('', false);
if (!$extracted) {
$extracted = self::unZip($zip, $tmp);
if (!$extracted) {
Folder::delete($tmp);
return false;
}
}
if (!file_exists($extracted)) {
self::$error = self::INVALID_SOURCE;
return false;
}
$is_install = true;
$installer = self::loadInstaller($extracted, $is_install);
if (isset($options['is_update']) && $options['is_update'] === true) {
$method = 'preUpdate';
} else {
$method = 'preInstall';
}
if ($installer && method_exists($installer, $method)) {
$method_result = $installer::$method();
if ($method_result !== true) {
self::$error = 'An error occurred';
if (is_string($method_result)) {
self::$error = $method_result;
}
return false;
}
}
if (!$options['sophisticated']) {
if ($options['theme']) {
self::copyInstall($extracted, $install_path);
} else {
self::moveInstall($extracted, $install_path);
}
} else {
self::sophisticatedInstall($extracted, $install_path, $options['ignores'], $keepExtracted);
}
Folder::delete($tmp);
if (isset($options['is_update']) && $options['is_update'] === true) {
$method = 'postUpdate';
} else {
$method = 'postInstall';
}
self::$message = '';
if ($installer && method_exists($installer, $method)) {
self::$message = $installer::$method();
}
self::$error = self::OK;
return true;
} | [
"public",
"static",
"function",
"install",
"(",
"$",
"zip",
",",
"$",
"destination",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"extracted",
"=",
"null",
",",
"$",
"keepExtracted",
"=",
"false",
")",
"{",
"$",
"destination",
"=",
"rtrim",
"(",
"$"... | Installs a given package to a given destination.
@param string $zip the local path to ZIP package
@param string $destination The local path to the Grav Instance
@param array $options Options to use for installing. ie, ['install_path' => 'user/themes/antimatter']
@param string $extracted The local path to the extacted ZIP package
@param bool $keepExtracted True if you want to keep the original files
@return bool True if everything went fine, False otherwise. | [
"Installs",
"a",
"given",
"package",
"to",
"a",
"given",
"destination",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/Installer.php#L81-L164 | train | Installs a Grav instance | [
30522,
2270,
10763,
3853,
16500,
1006,
1002,
14101,
1010,
1002,
7688,
1010,
1002,
7047,
1027,
1031,
1033,
1010,
1002,
15901,
1027,
19701,
1010,
1002,
2562,
10288,
24301,
1027,
6270,
1007,
1063,
1002,
7688,
1027,
19387,
20026,
1006,
1002,
76... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Renderer/Csv.php | Csv.flattenColumnArray | private function flattenColumnArray($columns, &$csvRow = array(), $csvColumnNameTemplate = '%s')
{
foreach ($columns as $name => $value) {
$csvName = sprintf($csvColumnNameTemplate, $this->getCsvColumnName($name));
if (is_array($value)) {
// if we're translating column names and this is an array of arrays, the column name
// format becomes a bit more complicated. also in this case, we assume $value is not
// nested beyond 2 levels (ie, array(0 => array(0 => 1, 1 => 2)), but not array(
// 0 => array(0 => array(), 1 => array())) )
if ($this->translateColumnNames
&& is_array(reset($value))
) {
foreach ($value as $level1Key => $level1Value) {
$inner = $name == 'goals' ? Piwik::translate('Goals_GoalX', $level1Key) : $name . ' ' . $level1Key;
$columnNameTemplate = '%s (' . $inner . ')';
$this->flattenColumnArray($level1Value, $csvRow, $columnNameTemplate);
}
} else {
$this->flattenColumnArray($value, $csvRow, $csvName . '_%s');
}
} else {
$csvRow[$csvName] = $value;
}
}
return $csvRow;
} | php | private function flattenColumnArray($columns, &$csvRow = array(), $csvColumnNameTemplate = '%s')
{
foreach ($columns as $name => $value) {
$csvName = sprintf($csvColumnNameTemplate, $this->getCsvColumnName($name));
if (is_array($value)) {
// if we're translating column names and this is an array of arrays, the column name
// format becomes a bit more complicated. also in this case, we assume $value is not
// nested beyond 2 levels (ie, array(0 => array(0 => 1, 1 => 2)), but not array(
// 0 => array(0 => array(), 1 => array())) )
if ($this->translateColumnNames
&& is_array(reset($value))
) {
foreach ($value as $level1Key => $level1Value) {
$inner = $name == 'goals' ? Piwik::translate('Goals_GoalX', $level1Key) : $name . ' ' . $level1Key;
$columnNameTemplate = '%s (' . $inner . ')';
$this->flattenColumnArray($level1Value, $csvRow, $columnNameTemplate);
}
} else {
$this->flattenColumnArray($value, $csvRow, $csvName . '_%s');
}
} else {
$csvRow[$csvName] = $value;
}
}
return $csvRow;
} | [
"private",
"function",
"flattenColumnArray",
"(",
"$",
"columns",
",",
"&",
"$",
"csvRow",
"=",
"array",
"(",
")",
",",
"$",
"csvColumnNameTemplate",
"=",
"'%s'",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{"... | Flattens an array of column values so they can be outputted as CSV (which does not support
nested structures). | [
"Flattens",
"an",
"array",
"of",
"column",
"values",
"so",
"they",
"can",
"be",
"outputted",
"as",
"CSV",
"(",
"which",
"does",
"not",
"support",
"nested",
"structures",
")",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Renderer/Csv.php#L328-L356 | train | Flattens the columns array | [
30522,
2797,
3853,
4257,
6528,
25778,
2819,
11802,
9447,
1006,
1002,
7753,
1010,
1004,
1002,
20116,
19716,
5004,
1027,
9140,
1006,
1007,
1010,
1002,
20116,
25465,
4747,
2819,
9516,
11368,
6633,
15725,
1027,
1005,
1003,
1055,
1005,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/DynamoDbStore.php | DynamoDbStore.lock | public function lock($name, $seconds = 0, $owner = null)
{
return new DynamoDbLock($this, $this->prefix.$name, $seconds, $owner);
} | php | public function lock($name, $seconds = 0, $owner = null)
{
return new DynamoDbLock($this, $this->prefix.$name, $seconds, $owner);
} | [
"public",
"function",
"lock",
"(",
"$",
"name",
",",
"$",
"seconds",
"=",
"0",
",",
"$",
"owner",
"=",
"null",
")",
"{",
"return",
"new",
"DynamoDbLock",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"prefix",
".",
"$",
"name",
",",
"$",
"seconds",
"... | Get a lock instance.
@param string $name
@param int $seconds
@param string|null $owner
@return \Illuminate\Contracts\Cache\Lock | [
"Get",
"a",
"lock",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/DynamoDbStore.php#L404-L407 | train | Lock a DynamoDb object | [
30522,
2270,
3853,
5843,
1006,
1002,
2171,
1010,
1002,
3823,
1027,
1014,
1010,
1002,
3954,
1027,
19701,
1007,
1063,
2709,
2047,
17205,
18939,
7878,
1006,
1002,
2023,
1010,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
2171,
1010,
1002,
3823,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php | IniFileLoader.load | public function load($resource, $type = null)
{
$path = $this->locator->locate($resource);
$this->container->fileExists($path);
// first pass to catch parsing errors
$result = parse_ini_file($path, true);
if (false === $result || [] === $result) {
throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $resource));
}
// real raw parsing
$result = parse_ini_file($path, true, INI_SCANNER_RAW);
if (isset($result['parameters']) && \is_array($result['parameters'])) {
foreach ($result['parameters'] as $key => $value) {
$this->container->setParameter($key, $this->phpize($value));
}
}
} | php | public function load($resource, $type = null)
{
$path = $this->locator->locate($resource);
$this->container->fileExists($path);
// first pass to catch parsing errors
$result = parse_ini_file($path, true);
if (false === $result || [] === $result) {
throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $resource));
}
// real raw parsing
$result = parse_ini_file($path, true, INI_SCANNER_RAW);
if (isset($result['parameters']) && \is_array($result['parameters'])) {
foreach ($result['parameters'] as $key => $value) {
$this->container->setParameter($key, $this->phpize($value));
}
}
} | [
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"locator",
"->",
"locate",
"(",
"$",
"resource",
")",
";",
"$",
"this",
"->",
"container",
"->",
"fileExists",
"(",
"$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php#L27-L47 | train | Loads the parameters from a ini file | [
30522,
2270,
3853,
7170,
1006,
1002,
7692,
1010,
1002,
2828,
1027,
19701,
1007,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
8840,
11266,
2953,
1011,
1028,
12453,
1006,
1002,
7692,
1007,
1025,
1002,
2023,
1011,
1028,
11661,
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... |
z-song/laravel-admin | src/Grid/Filter/Where.php | Where.getQueryHash | public static function getQueryHash(\Closure $closure, $label = '')
{
$reflection = new \ReflectionFunction($closure);
return md5($reflection->getFileName().$reflection->getStartLine().$reflection->getEndLine().$label);
} | php | public static function getQueryHash(\Closure $closure, $label = '')
{
$reflection = new \ReflectionFunction($closure);
return md5($reflection->getFileName().$reflection->getStartLine().$reflection->getEndLine().$label);
} | [
"public",
"static",
"function",
"getQueryHash",
"(",
"\\",
"Closure",
"$",
"closure",
",",
"$",
"label",
"=",
"''",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"closure",
")",
";",
"return",
"md5",
"(",
"$",
"reflection... | Get the hash string of query closure.
@param \Closure $closure
@param string $label
@return string | [
"Get",
"the",
"hash",
"string",
"of",
"query",
"closure",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/Where.php#L49-L54 | train | Get Query Hash | [
30522,
2270,
10763,
3853,
2131,
4226,
2854,
14949,
2232,
1006,
1032,
8503,
1002,
8503,
1010,
1002,
3830,
1027,
1005,
1005,
1007,
1063,
1002,
9185,
1027,
2047,
1032,
9185,
11263,
27989,
1006,
1002,
8503,
1007,
1025,
2709,
9108,
2629,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/Access/Gate.php | Gate.resolvePolicyCallback | protected function resolvePolicyCallback($user, $ability, array $arguments, $policy)
{
if (! is_callable([$policy, $this->formatAbilityToMethod($ability)])) {
return false;
}
return function () use ($user, $ability, $arguments, $policy) {
// This callback will be responsible for calling the policy's before method and
// running this policy method if necessary. This is used to when objects are
// mapped to policy objects in the user's configurations or on this class.
$result = $this->callPolicyBefore(
$policy, $user, $ability, $arguments
);
// When we receive a non-null result from this before method, we will return it
// as the "final" results. This will allow developers to override the checks
// in this policy to return the result for all rules defined in the class.
if (! is_null($result)) {
return $result;
}
$method = $this->formatAbilityToMethod($ability);
return $this->callPolicyMethod($policy, $method, $user, $arguments);
};
} | php | protected function resolvePolicyCallback($user, $ability, array $arguments, $policy)
{
if (! is_callable([$policy, $this->formatAbilityToMethod($ability)])) {
return false;
}
return function () use ($user, $ability, $arguments, $policy) {
// This callback will be responsible for calling the policy's before method and
// running this policy method if necessary. This is used to when objects are
// mapped to policy objects in the user's configurations or on this class.
$result = $this->callPolicyBefore(
$policy, $user, $ability, $arguments
);
// When we receive a non-null result from this before method, we will return it
// as the "final" results. This will allow developers to override the checks
// in this policy to return the result for all rules defined in the class.
if (! is_null($result)) {
return $result;
}
$method = $this->formatAbilityToMethod($ability);
return $this->callPolicyMethod($policy, $method, $user, $arguments);
};
} | [
"protected",
"function",
"resolvePolicyCallback",
"(",
"$",
"user",
",",
"$",
"ability",
",",
"array",
"$",
"arguments",
",",
"$",
"policy",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"[",
"$",
"policy",
",",
"$",
"this",
"->",
"formatAbilityToMethod",
... | Resolve the callback for a policy check.
@param \Illuminate\Contracts\Auth\Authenticatable $user
@param string $ability
@param array $arguments
@param mixed $policy
@return bool|callable | [
"Resolve",
"the",
"callback",
"for",
"a",
"policy",
"check",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Access/Gate.php#L616-L641 | train | Returns a callback for the given policy method. | [
30522,
5123,
3853,
10663,
18155,
2594,
2100,
9289,
20850,
8684,
1006,
1002,
5310,
1010,
1002,
3754,
1010,
9140,
1002,
9918,
1010,
1002,
3343,
1007,
1063,
2065,
1006,
999,
2003,
1035,
2655,
3085,
1006,
1031,
1002,
3343,
1010,
1002,
2023,
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... |
php-ai/php-ml | src/Classification/Ensemble/Bagging.php | Bagging.setSubsetRatio | public function setSubsetRatio(float $ratio)
{
if ($ratio < 0.1 || $ratio > 1.0) {
throw new InvalidArgumentException('Subset ratio should be between 0.1 and 1.0');
}
$this->subsetRatio = $ratio;
return $this;
} | php | public function setSubsetRatio(float $ratio)
{
if ($ratio < 0.1 || $ratio > 1.0) {
throw new InvalidArgumentException('Subset ratio should be between 0.1 and 1.0');
}
$this->subsetRatio = $ratio;
return $this;
} | [
"public",
"function",
"setSubsetRatio",
"(",
"float",
"$",
"ratio",
")",
"{",
"if",
"(",
"$",
"ratio",
"<",
"0.1",
"||",
"$",
"ratio",
">",
"1.0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Subset ratio should be between 0.1 and 1.0'",
")",
"... | This method determines the ratio of samples used to create the 'bootstrap' subset,
e.g., random samples drawn from the original dataset with replacement (allow repeats),
to train each base classifier.
@return $this
@throws InvalidArgumentException | [
"This",
"method",
"determines",
"the",
"ratio",
"of",
"samples",
"used",
"to",
"create",
"the",
"bootstrap",
"subset",
"e",
".",
"g",
".",
"random",
"samples",
"drawn",
"from",
"the",
"original",
"dataset",
"with",
"replacement",
"(",
"allow",
"repeats",
")"... | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Ensemble/Bagging.php#L73-L82 | train | Set subset ratio | [
30522,
2270,
3853,
4520,
12083,
13462,
8609,
3695,
1006,
14257,
1002,
6463,
1007,
1063,
2065,
1006,
1002,
6463,
1026,
1014,
1012,
1015,
1064,
1064,
1002,
6463,
1028,
1015,
1012,
1014,
1007,
1063,
5466,
2047,
19528,
2906,
22850,
15781,
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... |
octobercms/october | modules/system/controllers/Updates.php | Updates.onRemovePlugin | public function onRemovePlugin()
{
if ($pluginCode = post('code')) {
PluginManager::instance()->deletePlugin($pluginCode);
Flash::success(Lang::get('system::lang.plugins.remove_success'));
}
return Redirect::refresh();
} | php | public function onRemovePlugin()
{
if ($pluginCode = post('code')) {
PluginManager::instance()->deletePlugin($pluginCode);
Flash::success(Lang::get('system::lang.plugins.remove_success'));
}
return Redirect::refresh();
} | [
"public",
"function",
"onRemovePlugin",
"(",
")",
"{",
"if",
"(",
"$",
"pluginCode",
"=",
"post",
"(",
"'code'",
")",
")",
"{",
"PluginManager",
"::",
"instance",
"(",
")",
"->",
"deletePlugin",
"(",
"$",
"pluginCode",
")",
";",
"Flash",
"::",
"success",... | Rollback and remove a single plugin from the system.
@return void | [
"Rollback",
"and",
"remove",
"a",
"single",
"plugin",
"from",
"the",
"system",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/controllers/Updates.php#L745-L753 | train | Remove a plugin | [
30522,
2270,
3853,
2006,
28578,
21818,
24759,
15916,
2378,
1006,
1007,
1063,
2065,
1006,
1002,
13354,
2378,
16044,
1027,
2695,
1006,
1005,
3642,
1005,
1007,
1007,
1063,
13354,
2378,
24805,
4590,
1024,
1024,
6013,
1006,
1007,
1011,
1028,
397... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Mailer/Transport/Smtp/Stream/SocketStream.php | SocketStream.setEncryption | public function setEncryption(string $encryption): self
{
$encryption = strtolower($encryption);
if ('tls' === $encryption) {
$this->protocol = 'tcp';
$this->tls = true;
} else {
$this->protocol = $encryption;
$this->tls = false;
}
return $this;
} | php | public function setEncryption(string $encryption): self
{
$encryption = strtolower($encryption);
if ('tls' === $encryption) {
$this->protocol = 'tcp';
$this->tls = true;
} else {
$this->protocol = $encryption;
$this->tls = false;
}
return $this;
} | [
"public",
"function",
"setEncryption",
"(",
"string",
"$",
"encryption",
")",
":",
"self",
"{",
"$",
"encryption",
"=",
"strtolower",
"(",
"$",
"encryption",
")",
";",
"if",
"(",
"'tls'",
"===",
"$",
"encryption",
")",
"{",
"$",
"this",
"->",
"protocol",... | Sets the encryption type (tls or ssl). | [
"Sets",
"the",
"encryption",
"type",
"(",
"tls",
"or",
"ssl",
")",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mailer/Transport/Smtp/Stream/SocketStream.php#L79-L91 | train | Set the encryption protocol | [
30522,
2270,
3853,
2275,
2368,
26775,
22571,
3508,
1006,
5164,
1002,
21999,
1007,
1024,
2969,
1063,
1002,
21999,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
21999,
1007,
1025,
2065,
1006,
1005,
1056,
4877,
1005,
1027,
1027,
1027,
1002,
2199... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ArchivePurger.php | ArchivePurger.purgeArchivesWithPeriodRange | public function purgeArchivesWithPeriodRange(Date $date)
{
$numericTable = ArchiveTableCreator::getNumericTable($date);
$blobTable = ArchiveTableCreator::getBlobTable($date);
$deletedCount = $this->model->deleteArchivesWithPeriod(
$numericTable, $blobTable, Piwik::$idPeriods['range'], $this->purgeCustomRangesOlderThan);
$level = $deletedCount == 0 ? LogLevel::DEBUG : LogLevel::INFO;
$this->logger->log($level, "Purged {count} range archive rows from {numericTable} & {blobTable}.", array(
'count' => $deletedCount,
'numericTable' => $numericTable,
'blobTable' => $blobTable
));
$this->logger->debug(" [ purged archives older than {threshold} ]", array('threshold' => $this->purgeCustomRangesOlderThan));
return $deletedCount;
} | php | public function purgeArchivesWithPeriodRange(Date $date)
{
$numericTable = ArchiveTableCreator::getNumericTable($date);
$blobTable = ArchiveTableCreator::getBlobTable($date);
$deletedCount = $this->model->deleteArchivesWithPeriod(
$numericTable, $blobTable, Piwik::$idPeriods['range'], $this->purgeCustomRangesOlderThan);
$level = $deletedCount == 0 ? LogLevel::DEBUG : LogLevel::INFO;
$this->logger->log($level, "Purged {count} range archive rows from {numericTable} & {blobTable}.", array(
'count' => $deletedCount,
'numericTable' => $numericTable,
'blobTable' => $blobTable
));
$this->logger->debug(" [ purged archives older than {threshold} ]", array('threshold' => $this->purgeCustomRangesOlderThan));
return $deletedCount;
} | [
"public",
"function",
"purgeArchivesWithPeriodRange",
"(",
"Date",
"$",
"date",
")",
"{",
"$",
"numericTable",
"=",
"ArchiveTableCreator",
"::",
"getNumericTable",
"(",
"$",
"date",
")",
";",
"$",
"blobTable",
"=",
"ArchiveTableCreator",
"::",
"getBlobTable",
"(",... | Deleting "Custom Date Range" reports after 1 day, since they can be re-processed and would take up un-necessary space.
@param $date Date
@return int The total number of rows deleted from both the numeric & blob table. | [
"Deleting",
"Custom",
"Date",
"Range",
"reports",
"after",
"1",
"day",
"since",
"they",
"can",
"be",
"re",
"-",
"processed",
"and",
"would",
"take",
"up",
"un",
"-",
"necessary",
"space",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/ArchivePurger.php#L252-L270 | train | Purges all archives with a period range. | [
30522,
2270,
3853,
24694,
2906,
5428,
6961,
24415,
4842,
3695,
24914,
3351,
1006,
3058,
1002,
3058,
1007,
1063,
1002,
16371,
25531,
10880,
1027,
8756,
10880,
16748,
8844,
1024,
1024,
2131,
19172,
22420,
10880,
1006,
1002,
3058,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
slimphp/Slim | Slim/App.php | App.respond | public function respond(ResponseInterface $response)
{
// Send response
if (!headers_sent()) {
// Headers
foreach ($response->getHeaders() as $name => $values) {
$first = stripos($name, 'Set-Cookie') === 0 ? false : true;
foreach ($values as $value) {
header(sprintf('%s: %s', $name, $value), $first);
$first = false;
}
}
// Set the status _after_ the headers, because of PHP's "helpful" behavior with location headers.
// See https://github.com/slimphp/Slim/issues/1730
// Status
header(sprintf(
'HTTP/%s %s %s',
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getReasonPhrase()
), true, $response->getStatusCode());
}
// Body
$request = $this->container->get('request');
if (!$this->isEmptyResponse($response) && !$this->isHeadRequest($request)) {
$body = $response->getBody();
if ($body->isSeekable()) {
$body->rewind();
}
$settings = $this->container->get('settings');
$chunkSize = $settings['responseChunkSize'];
$contentLength = $response->getHeaderLine('Content-Length');
if (!$contentLength) {
$contentLength = $body->getSize();
}
if (isset($contentLength)) {
$amountToRead = $contentLength;
while ($amountToRead > 0 && !$body->eof()) {
$data = $body->read(min((int)$chunkSize, (int)$amountToRead));
echo $data;
$amountToRead -= strlen($data);
if (connection_status() != CONNECTION_NORMAL) {
break;
}
}
} else {
while (!$body->eof()) {
echo $body->read((int)$chunkSize);
if (connection_status() != CONNECTION_NORMAL) {
break;
}
}
}
}
} | php | public function respond(ResponseInterface $response)
{
// Send response
if (!headers_sent()) {
// Headers
foreach ($response->getHeaders() as $name => $values) {
$first = stripos($name, 'Set-Cookie') === 0 ? false : true;
foreach ($values as $value) {
header(sprintf('%s: %s', $name, $value), $first);
$first = false;
}
}
// Set the status _after_ the headers, because of PHP's "helpful" behavior with location headers.
// See https://github.com/slimphp/Slim/issues/1730
// Status
header(sprintf(
'HTTP/%s %s %s',
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getReasonPhrase()
), true, $response->getStatusCode());
}
// Body
$request = $this->container->get('request');
if (!$this->isEmptyResponse($response) && !$this->isHeadRequest($request)) {
$body = $response->getBody();
if ($body->isSeekable()) {
$body->rewind();
}
$settings = $this->container->get('settings');
$chunkSize = $settings['responseChunkSize'];
$contentLength = $response->getHeaderLine('Content-Length');
if (!$contentLength) {
$contentLength = $body->getSize();
}
if (isset($contentLength)) {
$amountToRead = $contentLength;
while ($amountToRead > 0 && !$body->eof()) {
$data = $body->read(min((int)$chunkSize, (int)$amountToRead));
echo $data;
$amountToRead -= strlen($data);
if (connection_status() != CONNECTION_NORMAL) {
break;
}
}
} else {
while (!$body->eof()) {
echo $body->read((int)$chunkSize);
if (connection_status() != CONNECTION_NORMAL) {
break;
}
}
}
}
} | [
"public",
"function",
"respond",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"// Send response",
"if",
"(",
"!",
"headers_sent",
"(",
")",
")",
"{",
"// Headers",
"foreach",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"name",
"=... | Send the response to the client
@param ResponseInterface $response | [
"Send",
"the",
"response",
"to",
"the",
"client"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/App.php#L407-L469 | train | Send response to the browser | [
30522,
2270,
3853,
6869,
1006,
3433,
18447,
2121,
12172,
1002,
3433,
1007,
1063,
1013,
1013,
4604,
3433,
2065,
1006,
999,
20346,
2015,
1035,
2741,
1006,
1007,
1007,
1063,
1013,
1013,
20346,
2015,
18921,
6776,
1006,
1002,
3433,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Console/ListenCommand.php | ListenCommand.setOutputHandler | protected function setOutputHandler(Listener $listener)
{
$listener->setOutputHandler(function ($type, $line) {
$this->output->write($line);
});
} | php | protected function setOutputHandler(Listener $listener)
{
$listener->setOutputHandler(function ($type, $line) {
$this->output->write($line);
});
} | [
"protected",
"function",
"setOutputHandler",
"(",
"Listener",
"$",
"listener",
")",
"{",
"$",
"listener",
"->",
"setOutputHandler",
"(",
"function",
"(",
"$",
"type",
",",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"write",
"(",
"$",
"line... | Set the options on the queue listener.
@param \Illuminate\Queue\Listener $listener
@return void | [
"Set",
"the",
"options",
"on",
"the",
"queue",
"listener",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Console/ListenCommand.php#L108-L113 | train | Set Output Handler | [
30522,
5123,
3853,
2275,
5833,
18780,
11774,
3917,
1006,
19373,
1002,
19373,
1007,
1063,
1002,
19373,
1011,
1028,
2275,
5833,
18780,
11774,
3917,
1006,
3853,
1006,
1002,
2828,
1010,
1002,
2240,
1007,
1063,
1002,
2023,
1011,
1028,
6434,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Updates/3.0.0-b1.php | Updates_3_0_0_b1.getMigrations | public function getMigrations(Updater $updater)
{
$db = Db::get();
$allGoals = $db->fetchAll(sprintf("SELECT DISTINCT idgoal FROM %s", Common::prefixTable('goal')));
$allDashboards = $db->fetchAll(sprintf("SELECT * FROM %s", Common::prefixTable('user_dashboard')));
$migrations = $this->getDashboardMigrations($allDashboards, $allGoals);
$migrations = $this->getPluginSettingsMigrations($migrations);
$migrations = $this->getSiteSettingsMigrations($migrations);
$migrations = $this->getBigIntPreventOverflowMigrations($migrations);
return $migrations;
} | php | public function getMigrations(Updater $updater)
{
$db = Db::get();
$allGoals = $db->fetchAll(sprintf("SELECT DISTINCT idgoal FROM %s", Common::prefixTable('goal')));
$allDashboards = $db->fetchAll(sprintf("SELECT * FROM %s", Common::prefixTable('user_dashboard')));
$migrations = $this->getDashboardMigrations($allDashboards, $allGoals);
$migrations = $this->getPluginSettingsMigrations($migrations);
$migrations = $this->getSiteSettingsMigrations($migrations);
$migrations = $this->getBigIntPreventOverflowMigrations($migrations);
return $migrations;
} | [
"public",
"function",
"getMigrations",
"(",
"Updater",
"$",
"updater",
")",
"{",
"$",
"db",
"=",
"Db",
"::",
"get",
"(",
")",
";",
"$",
"allGoals",
"=",
"$",
"db",
"->",
"fetchAll",
"(",
"sprintf",
"(",
"\"SELECT DISTINCT idgoal FROM %s\"",
",",
"Common",
... | Here you can define one or multiple SQL statements that should be executed during the update.
@param Updater $updater
@return Migration[] | [
"Here",
"you",
"can",
"define",
"one",
"or",
"multiple",
"SQL",
"statements",
"that",
"should",
"be",
"executed",
"during",
"the",
"update",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updates/3.0.0-b1.php#L46-L58 | train | Get all migrations for the given updater | [
30522,
2270,
3853,
2131,
4328,
29397,
2015,
1006,
10651,
2099,
1002,
10651,
2099,
1007,
1063,
1002,
16962,
1027,
16962,
1024,
1024,
2131,
1006,
1007,
1025,
1002,
2035,
3995,
9777,
1027,
1002,
16962,
1011,
1028,
18584,
8095,
1006,
9043,
2546... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/API.php | API.getUsers | public function getUsers($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTable(Archiver::USERID_ARCHIVE_RECORD);
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
} | php | public function getUsers($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTable(Archiver::USERID_ARCHIVE_RECORD);
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
return $dataTable;
} | [
"public",
"function",
"getUsers",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"$",
"archive",
"=",
"Archive",
"::",
"build... | Get a report of all User Ids.
@param int $idSite
@param string $period
@param int $date
@param string|bool $segment
@return DataTable | [
"Get",
"a",
"report",
"of",
"all",
"User",
"Ids",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserId/API.php#L35-L45 | train | Get users in archive | [
30522,
2270,
3853,
2131,
20330,
2015,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
8584,
6305,
9623,
2015,
1006,
1002,
8909,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/RouteCollection.php | RouteCollection.refreshActionLookups | public function refreshActionLookups()
{
$this->actionList = [];
foreach ($this->allRoutes as $route) {
if (isset($route->getAction()['controller'])) {
$this->addToActionList($route->getAction(), $route);
}
}
} | php | public function refreshActionLookups()
{
$this->actionList = [];
foreach ($this->allRoutes as $route) {
if (isset($route->getAction()['controller'])) {
$this->addToActionList($route->getAction(), $route);
}
}
} | [
"public",
"function",
"refreshActionLookups",
"(",
")",
"{",
"$",
"this",
"->",
"actionList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"allRoutes",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"route",
"->",
"getAction",
... | Refresh the action look-up table.
This is done in case any actions are overwritten with new controllers.
@return void | [
"Refresh",
"the",
"action",
"look",
"-",
"up",
"table",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/RouteCollection.php#L138-L147 | train | Refresh action lookup list | [
30522,
2270,
3853,
25416,
21898,
18908,
3258,
4135,
21940,
4523,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2895,
9863,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2035,
22494,
4570,
2004,
1002,
2799,
1007,
1063,
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/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.validateDateFormat | public function validateDateFormat($attribute, $value, $parameters)
{
$this->requireParameterCount(1, $parameters, 'date_format');
if (! is_string($value) && ! is_numeric($value)) {
return false;
}
$format = $parameters[0];
$date = DateTime::createFromFormat('!'.$format, $value);
return $date && $date->format($format) == $value;
} | php | public function validateDateFormat($attribute, $value, $parameters)
{
$this->requireParameterCount(1, $parameters, 'date_format');
if (! is_string($value) && ! is_numeric($value)) {
return false;
}
$format = $parameters[0];
$date = DateTime::createFromFormat('!'.$format, $value);
return $date && $date->format($format) == $value;
} | [
"public",
"function",
"validateDateFormat",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"requireParameterCount",
"(",
"1",
",",
"$",
"parameters",
",",
"'date_format'",
")",
";",
"if",
"(",
"!",
"is_string... | Validate that an attribute matches a date format.
@param string $attribute
@param mixed $value
@param array $parameters
@return bool | [
"Validate",
"that",
"an",
"attribute",
"matches",
"a",
"date",
"format",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L397-L410 | train | This method is used to validate the date_format attribute. | [
30522,
2270,
3853,
9398,
4383,
3686,
14192,
4017,
1006,
1002,
17961,
1010,
1002,
3643,
1010,
1002,
11709,
1007,
1063,
1002,
2023,
1011,
1028,
5478,
28689,
22828,
3597,
16671,
1006,
1015,
1010,
1002,
11709,
1010,
1005,
3058,
1035,
4289,
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/Notifications/Channels/MailChannel.php | MailChannel.getRecipients | protected function getRecipients($notifiable, $notification, $message)
{
if (is_string($recipients = $notifiable->routeNotificationFor('mail', $notification))) {
$recipients = [$recipients];
}
return collect($recipients)->mapWithKeys(function ($recipient, $email) {
return is_numeric($email)
? [$email => (is_string($recipient) ? $recipient : $recipient->email)]
: [$email => $recipient];
})->all();
} | php | protected function getRecipients($notifiable, $notification, $message)
{
if (is_string($recipients = $notifiable->routeNotificationFor('mail', $notification))) {
$recipients = [$recipients];
}
return collect($recipients)->mapWithKeys(function ($recipient, $email) {
return is_numeric($email)
? [$email => (is_string($recipient) ? $recipient : $recipient->email)]
: [$email => $recipient];
})->all();
} | [
"protected",
"function",
"getRecipients",
"(",
"$",
"notifiable",
",",
"$",
"notification",
",",
"$",
"message",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"recipients",
"=",
"$",
"notifiable",
"->",
"routeNotificationFor",
"(",
"'mail'",
",",
"$",
"notific... | Get the recipients of the given message.
@param mixed $notifiable
@param \Illuminate\Notifications\Notification $notification
@param \Illuminate\Notifications\Messages\MailMessage $message
@return mixed | [
"Get",
"the",
"recipients",
"of",
"the",
"given",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Notifications/Channels/MailChannel.php#L198-L209 | train | Get all recipients | [
30522,
5123,
3853,
2131,
2890,
6895,
14756,
7666,
1006,
1002,
2025,
10128,
19210,
1010,
1002,
26828,
1010,
1002,
4471,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
15991,
1027,
1002,
2025,
10128,
19210,
1011,
1028,
2799,
17048,
903... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Jssdk/Client.php | Client.shareAddressConfig | public function shareAddressConfig($accessToken, bool $json = true)
{
if ($accessToken instanceof AccessTokenInterface) {
$accessToken = $accessToken->getToken();
}
$params = [
'appId' => $this->app['config']->app_id,
'scope' => 'jsapi_address',
'timeStamp' => strval(time()),
'nonceStr' => uniqid(),
'signType' => 'SHA1',
];
$signParams = [
'appid' => $params['appId'],
'url' => $this->getUrl(),
'timestamp' => $params['timeStamp'],
'noncestr' => $params['nonceStr'],
'accesstoken' => strval($accessToken),
];
ksort($signParams);
$params['addrSign'] = sha1(urldecode(http_build_query($signParams)));
return $json ? json_encode($params) : $params;
} | php | public function shareAddressConfig($accessToken, bool $json = true)
{
if ($accessToken instanceof AccessTokenInterface) {
$accessToken = $accessToken->getToken();
}
$params = [
'appId' => $this->app['config']->app_id,
'scope' => 'jsapi_address',
'timeStamp' => strval(time()),
'nonceStr' => uniqid(),
'signType' => 'SHA1',
];
$signParams = [
'appid' => $params['appId'],
'url' => $this->getUrl(),
'timestamp' => $params['timeStamp'],
'noncestr' => $params['nonceStr'],
'accesstoken' => strval($accessToken),
];
ksort($signParams);
$params['addrSign'] = sha1(urldecode(http_build_query($signParams)));
return $json ? json_encode($params) : $params;
} | [
"public",
"function",
"shareAddressConfig",
"(",
"$",
"accessToken",
",",
"bool",
"$",
"json",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"accessToken",
"instanceof",
"AccessTokenInterface",
")",
"{",
"$",
"accessToken",
"=",
"$",
"accessToken",
"->",
"getToken",
... | Generate js config for share user address.
@param string|\Overtrue\Socialite\AccessTokenInterface $accessToken
@param bool $json
@return string|array | [
"Generate",
"js",
"config",
"for",
"share",
"user",
"address",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Jssdk/Client.php#L107-L134 | train | Get address config | [
30522,
2270,
3853,
3745,
4215,
16200,
4757,
8663,
8873,
2290,
1006,
1002,
3229,
18715,
2368,
1010,
22017,
2140,
1002,
1046,
3385,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
3229,
18715,
2368,
6013,
11253,
3229,
18715,
18595,
10111,
12881,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.