repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matomo-org/matomo | libs/Zend/Mail/Protocol/Imap.php | Zend_Mail_Protocol_Imap.readLine | public function readLine(&$tokens = array(), $wantedTag = '*', $dontParse = false)
{
$line = $this->_nextTaggedLine($tag);
if (!$dontParse) {
$tokens = $this->_decodeLine($line);
} else {
$tokens = $line;
}
// if tag is wanted tag we might be at the end of a multiline response
return $tag == $wantedTag;
} | php | public function readLine(&$tokens = array(), $wantedTag = '*', $dontParse = false)
{
$line = $this->_nextTaggedLine($tag);
if (!$dontParse) {
$tokens = $this->_decodeLine($line);
} else {
$tokens = $line;
}
// if tag is wanted tag we might be at the end of a multiline response
return $tag == $wantedTag;
} | [
"public",
"function",
"readLine",
"(",
"&",
"$",
"tokens",
"=",
"array",
"(",
")",
",",
"$",
"wantedTag",
"=",
"'*'",
",",
"$",
"dontParse",
"=",
"false",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"_nextTaggedLine",
"(",
"$",
"tag",
")",
";",
... | read a response "line" (could also be more than one real line if response has {..}<NL>)
and do a simple decode
@param array|string $tokens decoded tokens are returned by reference, if $dontParse
is true the unparsed line is returned here
@param string $wantedTag check for this tag for response code. Default '*' is
continuation tag.
@param bool $dontParse if true only the unparsed line is returned $tokens
@return bool if returned tag matches wanted tag
@throws Zend_Mail_Protocol_Exception | [
"read",
"a",
"response",
"line",
"(",
"could",
"also",
"be",
"more",
"than",
"one",
"real",
"line",
"if",
"response",
"has",
"{",
"..",
"}",
"<NL",
">",
")",
"and",
"do",
"a",
"simple",
"decode"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L283-L294 | train | Read a line from the stream and return the tokens | [
30522,
2270,
3853,
3191,
4179,
1006,
1004,
1002,
19204,
2015,
1027,
9140,
1006,
1007,
1010,
1002,
2359,
15900,
1027,
1005,
1008,
1005,
1010,
1002,
2123,
25856,
11650,
2063,
1027,
6270,
1007,
1063,
1002,
2240,
1027,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Yaml/Parser.php | Parser.moveToNextLine | private function moveToNextLine(): bool
{
if ($this->currentLineNb >= \count($this->lines) - 1) {
return false;
}
$this->currentLine = $this->lines[++$this->currentLineNb];
return true;
} | php | private function moveToNextLine(): bool
{
if ($this->currentLineNb >= \count($this->lines) - 1) {
return false;
}
$this->currentLine = $this->lines[++$this->currentLineNb];
return true;
} | [
"private",
"function",
"moveToNextLine",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"currentLineNb",
">=",
"\\",
"count",
"(",
"$",
"this",
"->",
"lines",
")",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"curr... | Moves the parser to the next line.
@return bool | [
"Moves",
"the",
"parser",
"to",
"the",
"next",
"line",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Yaml/Parser.php#L609-L618 | train | Move to the next line | [
30522,
2797,
3853,
2693,
5524,
18413,
4179,
1006,
1007,
1024,
22017,
2140,
30524,
1009,
1009,
1002,
2023,
1011,
1028,
2783,
4179,
27698,
1033,
1025,
2709,
2995,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/API.php | API.getSitesAccessForUser | public function getSitesAccessForUser($userLogin, $limit = null, $offset = 0, $filter_search = null, $filter_access = null)
{
Piwik::checkUserHasSomeAdminAccess();
$this->checkUserExists($userLogin);
if (Piwik::hasTheUserSuperUserAccess($userLogin)) {
throw new \Exception("This method should not be used with superusers.");
}
$idSites = null;
if (!Piwik::hasUserSuperUserAccess()) {
$idSites = $this->access->getSitesIdWithAdminAccess();
if (empty($idSites)) { // sanity check
throw new \Exception("The current admin user does not have access to any sites.");
}
}
list($sites, $totalResults) = $this->model->getSitesAccessFromUserWithFilters($userLogin, $limit, $offset, $filter_search, $filter_access, $idSites);
foreach ($sites as &$siteAccess) {
list($siteAccess['role'], $siteAccess['capabilities']) = $this->getRoleAndCapabilitiesFromAccess($siteAccess['access']);
$siteAccess['role'] = empty($siteAccess['role']) ? 'noaccess' : reset($siteAccess['role']);
unset($siteAccess['access']);
}
$hasAccessToAny = $this->model->getSiteAccessCount($userLogin) > 0;
Common::sendHeader('X-Matomo-Total-Results: ' . $totalResults);
if ($hasAccessToAny) {
Common::sendHeader('X-Matomo-Has-Some: 1');
}
return $sites;
} | php | public function getSitesAccessForUser($userLogin, $limit = null, $offset = 0, $filter_search = null, $filter_access = null)
{
Piwik::checkUserHasSomeAdminAccess();
$this->checkUserExists($userLogin);
if (Piwik::hasTheUserSuperUserAccess($userLogin)) {
throw new \Exception("This method should not be used with superusers.");
}
$idSites = null;
if (!Piwik::hasUserSuperUserAccess()) {
$idSites = $this->access->getSitesIdWithAdminAccess();
if (empty($idSites)) { // sanity check
throw new \Exception("The current admin user does not have access to any sites.");
}
}
list($sites, $totalResults) = $this->model->getSitesAccessFromUserWithFilters($userLogin, $limit, $offset, $filter_search, $filter_access, $idSites);
foreach ($sites as &$siteAccess) {
list($siteAccess['role'], $siteAccess['capabilities']) = $this->getRoleAndCapabilitiesFromAccess($siteAccess['access']);
$siteAccess['role'] = empty($siteAccess['role']) ? 'noaccess' : reset($siteAccess['role']);
unset($siteAccess['access']);
}
$hasAccessToAny = $this->model->getSiteAccessCount($userLogin) > 0;
Common::sendHeader('X-Matomo-Total-Results: ' . $totalResults);
if ($hasAccessToAny) {
Common::sendHeader('X-Matomo-Has-Some: 1');
}
return $sites;
} | [
"public",
"function",
"getSitesAccessForUser",
"(",
"$",
"userLogin",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"filter_search",
"=",
"null",
",",
"$",
"filter_access",
"=",
"null",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeAd... | For each website ID, returns the access level of the given $userLogin (if the user is not a superuser).
If the user doesn't have any access to a website ('noaccess'),
this website will not be in the returned array.
If the user doesn't have any access, the returned array will be an empty array.
@param string $userLogin User that has to be valid
@param int|null $limit
@param int|null $offset
@param string|null $filter_search text to search for in site name, URLs, or group.
@param string|null $filter_access access level to select for, can be 'some', 'view' or 'admin' (by default 'some')
@return array The returned array has the format
array(
['idsite' => 1, 'site_name' => 'the site', 'access' => 'admin'],
['idsite' => 2, 'site_name' => 'the other site', 'access' => 'view'],
...
)
@throws Exception | [
"For",
"each",
"website",
"ID",
"returns",
"the",
"access",
"level",
"of",
"the",
"given",
"$userLogin",
"(",
"if",
"the",
"user",
"is",
"not",
"a",
"superuser",
")",
".",
"If",
"the",
"user",
"doesn",
"t",
"have",
"any",
"access",
"to",
"a",
"website"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/API.php#L533-L564 | train | Returns the list of sites that the user has access to | [
30522,
2270,
3853,
4152,
7616,
6305,
9623,
22747,
21694,
2121,
1006,
1002,
5310,
21197,
2378,
1010,
1002,
5787,
1027,
19701,
1010,
1002,
16396,
1027,
1014,
1010,
1002,
11307,
1035,
3945,
1027,
19701,
1010,
1002,
11307,
1035,
3229,
1027,
197... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RankingQuery.php | RankingQuery.partitionResultIntoMultipleGroups | public function partitionResultIntoMultipleGroups($partitionColumn, $possibleValues)
{
if ($this->partitionColumn !== false) {
throw new Exception("partitionResultIntoMultipleGroups can only be used once");
}
$this->partitionColumn = $partitionColumn;
$this->partitionColumnValues = $possibleValues;
$this->addColumn($partitionColumn);
} | php | public function partitionResultIntoMultipleGroups($partitionColumn, $possibleValues)
{
if ($this->partitionColumn !== false) {
throw new Exception("partitionResultIntoMultipleGroups can only be used once");
}
$this->partitionColumn = $partitionColumn;
$this->partitionColumnValues = $possibleValues;
$this->addColumn($partitionColumn);
} | [
"public",
"function",
"partitionResultIntoMultipleGroups",
"(",
"$",
"partitionColumn",
",",
"$",
"possibleValues",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"partitionColumn",
"!==",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"partitionResultIntoMultipleG... | This method can be used to parition the result based on the possible values of one
table column. This means the query will split the result set into other sets of rows
for each possible value you provide (where the rows of each set have a column value
that equals a possible value). Each of these new sets of rows will be individually
limited resulting in several limited result sets.
For example, you can run a query aggregating some data on the log_action table and
partition by log_action.type with the possible values of {@link Piwik\Tracker\Action::TYPE_PAGE_URL},
{@link Piwik\Tracker\Action::TYPE_OUTLINK}, {@link Piwik\Tracker\Action::TYPE_DOWNLOAD}.
The result will be three separate result sets that are aggregated the same ways, but for rows
where `log_action.type = TYPE_OUTLINK`, for rows where `log_action.type = TYPE_ACTION_URL` and for
rows `log_action.type = TYPE_DOWNLOAD`.
@param $partitionColumn string The column name to partion by.
@param $possibleValues Array of possible column values.
@throws Exception if method is used more than once. | [
"This",
"method",
"can",
"be",
"used",
"to",
"parition",
"the",
"result",
"based",
"on",
"the",
"possible",
"values",
"of",
"one",
"table",
"column",
".",
"This",
"means",
"the",
"query",
"will",
"split",
"the",
"result",
"set",
"into",
"other",
"sets",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/RankingQuery.php#L201-L210 | train | This method is used to partition the result into multiple groups. | [
30522,
2270,
3853,
13571,
6072,
11314,
18447,
5358,
11314,
11514,
23115,
22107,
2015,
1006,
1002,
13571,
25778,
2819,
2078,
1010,
1002,
2825,
10175,
15808,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
13571,
25778,
2819,
2078,
999,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Report.php | Report.getMetricsForTable | public static function getMetricsForTable(DataTable $dataTable, Report $report = null, $baseType = 'Piwik\\Plugin\\Metric')
{
$metrics = $dataTable->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME) ?: array();
if (!empty($report)) {
$metrics = array_merge($metrics, $report->getProcessedMetricsById());
}
$result = array();
/** @var Metric $metric */
foreach ($metrics as $metric) {
if (!($metric instanceof $baseType)) {
continue;
}
$result[$metric->getName()] = $metric;
}
return $result;
} | php | public static function getMetricsForTable(DataTable $dataTable, Report $report = null, $baseType = 'Piwik\\Plugin\\Metric')
{
$metrics = $dataTable->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME) ?: array();
if (!empty($report)) {
$metrics = array_merge($metrics, $report->getProcessedMetricsById());
}
$result = array();
/** @var Metric $metric */
foreach ($metrics as $metric) {
if (!($metric instanceof $baseType)) {
continue;
}
$result[$metric->getName()] = $metric;
}
return $result;
} | [
"public",
"static",
"function",
"getMetricsForTable",
"(",
"DataTable",
"$",
"dataTable",
",",
"Report",
"$",
"report",
"=",
"null",
",",
"$",
"baseType",
"=",
"'Piwik\\\\Plugin\\\\Metric'",
")",
"{",
"$",
"metrics",
"=",
"$",
"dataTable",
"->",
"getMetadata",
... | Returns the Metrics that are displayed by a DataTable of a certain Report type.
Includes ProcessedMetrics and Metrics.
@param DataTable $dataTable
@param Report|null $report
@param string $baseType The base type each metric class needs to be of.
@return Metric[]
@api | [
"Returns",
"the",
"Metrics",
"that",
"are",
"displayed",
"by",
"a",
"DataTable",
"of",
"a",
"certain",
"Report",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Report.php#L973-L993 | train | Returns all metrics for a DataTable and a report. | [
30522,
2270,
10763,
3853,
2131,
12589,
22747,
11589,
3085,
1006,
2951,
10880,
1002,
2951,
10880,
1010,
3189,
1002,
3189,
1027,
19701,
1010,
1002,
2918,
13874,
1027,
1005,
14255,
9148,
2243,
1032,
1032,
13354,
2378,
1032,
1032,
12046,
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... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.dateFormats | public static function dateFormats()
{
$now = new \DateTime();
$date_formats = [
'd-m-Y H:i' => 'd-m-Y H:i (e.g. '.$now->format('d-m-Y H:i').')',
'Y-m-d H:i' => 'Y-m-d H:i (e.g. '.$now->format('Y-m-d H:i').')',
'm/d/Y h:i a' => 'm/d/Y h:i a (e.g. '.$now->format('m/d/Y h:i a').')',
'H:i d-m-Y' => 'H:i d-m-Y (e.g. '.$now->format('H:i d-m-Y').')',
'h:i a m/d/Y' => 'h:i a m/d/Y (e.g. '.$now->format('h:i a m/d/Y').')',
];
$default_format = Grav::instance()['config']->get('system.pages.dateformat.default');
if ($default_format) {
$date_formats = array_merge([$default_format => $default_format.' (e.g. '.$now->format($default_format).')'], $date_formats);
}
return $date_formats;
} | php | public static function dateFormats()
{
$now = new \DateTime();
$date_formats = [
'd-m-Y H:i' => 'd-m-Y H:i (e.g. '.$now->format('d-m-Y H:i').')',
'Y-m-d H:i' => 'Y-m-d H:i (e.g. '.$now->format('Y-m-d H:i').')',
'm/d/Y h:i a' => 'm/d/Y h:i a (e.g. '.$now->format('m/d/Y h:i a').')',
'H:i d-m-Y' => 'H:i d-m-Y (e.g. '.$now->format('H:i d-m-Y').')',
'h:i a m/d/Y' => 'h:i a m/d/Y (e.g. '.$now->format('h:i a m/d/Y').')',
];
$default_format = Grav::instance()['config']->get('system.pages.dateformat.default');
if ($default_format) {
$date_formats = array_merge([$default_format => $default_format.' (e.g. '.$now->format($default_format).')'], $date_formats);
}
return $date_formats;
} | [
"public",
"static",
"function",
"dateFormats",
"(",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"date_formats",
"=",
"[",
"'d-m-Y H:i'",
"=>",
"'d-m-Y H:i (e.g. '",
".",
"$",
"now",
"->",
"format",
"(",
"'d-m-Y H:i'",
")",
"."... | Return the Grav date formats allowed
@return array | [
"Return",
"the",
"Grav",
"date",
"formats",
"allowed"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L365-L382 | train | Return a list of date formats | [
30522,
2270,
10763,
3853,
3058,
14192,
11149,
1006,
1007,
1063,
1002,
2085,
1027,
2047,
1032,
3058,
7292,
1006,
1007,
1025,
1002,
3058,
1035,
11630,
1027,
1031,
1005,
1040,
1011,
1049,
1011,
1061,
1044,
1024,
1045,
1005,
1027,
1028,
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/Container/Container.php | Container.resolving | public function resolving($abstract, Closure $callback = null)
{
if (is_string($abstract)) {
$abstract = $this->getAlias($abstract);
}
if (is_null($callback) && $abstract instanceof Closure) {
$this->globalResolvingCallbacks[] = $abstract;
} else {
$this->resolvingCallbacks[$abstract][] = $callback;
}
} | php | public function resolving($abstract, Closure $callback = null)
{
if (is_string($abstract)) {
$abstract = $this->getAlias($abstract);
}
if (is_null($callback) && $abstract instanceof Closure) {
$this->globalResolvingCallbacks[] = $abstract;
} else {
$this->resolvingCallbacks[$abstract][] = $callback;
}
} | [
"public",
"function",
"resolving",
"(",
"$",
"abstract",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"abstract",
")",
")",
"{",
"$",
"abstract",
"=",
"$",
"this",
"->",
"getAlias",
"(",
"$",
"abstract",
"... | Register a new resolving callback.
@param \Closure|string $abstract
@param \Closure|null $callback
@return void | [
"Register",
"a",
"new",
"resolving",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L983-L994 | train | Adds a resolving callback to the list of resolving callbacks | [
30522,
2270,
3853,
29304,
1006,
1002,
10061,
1010,
8503,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
10061,
1007,
1007,
1063,
1002,
10061,
1027,
1002,
2023,
1011,
1028,
2131,
22786,
2015,
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... |
overtrue/wechat | src/MiniProgram/NearbyPoi/Client.php | Client.setVisibility | public function setVisibility(string $poiId, int $status)
{
if (!in_array($status, [0, 1], true)) {
throw new InvalidArgumentException('status should be 0 or 1.');
}
return $this->httpPostJson('wxa/setnearbypoishowstatus', [
'poi_id' => $poiId,
'status' => $status,
]);
} | php | public function setVisibility(string $poiId, int $status)
{
if (!in_array($status, [0, 1], true)) {
throw new InvalidArgumentException('status should be 0 or 1.');
}
return $this->httpPostJson('wxa/setnearbypoishowstatus', [
'poi_id' => $poiId,
'status' => $status,
]);
} | [
"public",
"function",
"setVisibility",
"(",
"string",
"$",
"poiId",
",",
"int",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"status",
",",
"[",
"0",
",",
"1",
"]",
",",
"true",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentExcepti... | Set nearby poi show status.
@param string $poiId
@param int $status
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string | [
"Set",
"nearby",
"poi",
"show",
"status",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/MiniProgram/NearbyPoi/Client.php#L82-L92 | train | Set nearby poi status | [
30522,
2270,
3853,
2275,
11365,
13464,
1006,
5164,
1002,
13433,
6137,
2094,
1010,
20014,
1002,
3570,
1007,
1063,
2065,
1006,
999,
1999,
1035,
9140,
1006,
1002,
3570,
1010,
1031,
1014,
1010,
1015,
1033,
1010,
2995,
1007,
1007,
1063,
5466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/File/AbstractFile.php | AbstractFile.lock | public function lock(bool $block = true): bool
{
if (!$this->handle) {
if (!$this->mkdir($this->getPath())) {
throw new \RuntimeException('Creating directory failed for ' . $this->filepath);
}
$this->handle = @fopen($this->filepath, 'cb+');
if (!$this->handle) {
$error = error_get_last();
throw new \RuntimeException("Opening file for writing failed on error {$error['message']}");
}
}
$lock = $block ? LOCK_EX : LOCK_EX | LOCK_NB;
// Some filesystems do not support file locks, only fail if another process holds the lock.
$this->locked = flock($this->handle, $lock, $wouldblock) || !$wouldblock;
return $this->locked;
} | php | public function lock(bool $block = true): bool
{
if (!$this->handle) {
if (!$this->mkdir($this->getPath())) {
throw new \RuntimeException('Creating directory failed for ' . $this->filepath);
}
$this->handle = @fopen($this->filepath, 'cb+');
if (!$this->handle) {
$error = error_get_last();
throw new \RuntimeException("Opening file for writing failed on error {$error['message']}");
}
}
$lock = $block ? LOCK_EX : LOCK_EX | LOCK_NB;
// Some filesystems do not support file locks, only fail if another process holds the lock.
$this->locked = flock($this->handle, $lock, $wouldblock) || !$wouldblock;
return $this->locked;
} | [
"public",
"function",
"lock",
"(",
"bool",
"$",
"block",
"=",
"true",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"handle",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"mkdir",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
... | {@inheritdoc}
@see FileInterface::lock() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/File/AbstractFile.php#L177-L197 | train | Locks the file | [
30522,
2270,
3853,
5843,
1006,
22017,
2140,
1002,
3796,
1027,
2995,
1007,
1024,
22017,
2140,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
5047,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
12395,
4305,
2099,
1006,
1002,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.onSearch | public function onSearch()
{
$this->setSearchTerm(Input::get('search'));
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list'),
'#'.$this->getId('folder-path') => $this->makePartial('folder-path')
];
} | php | public function onSearch()
{
$this->setSearchTerm(Input::get('search'));
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list'),
'#'.$this->getId('folder-path') => $this->makePartial('folder-path')
];
} | [
"public",
"function",
"onSearch",
"(",
")",
"{",
"$",
"this",
"->",
"setSearchTerm",
"(",
"Input",
"::",
"get",
"(",
"'search'",
")",
")",
";",
"$",
"this",
"->",
"prepareVars",
"(",
")",
";",
"return",
"[",
"'#'",
".",
"$",
"this",
"->",
"getId",
... | Perform search AJAX handler
@return array | [
"Perform",
"search",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L115-L125 | train | onSearch - Called by the search - handler | [
30522,
2270,
3853,
2006,
17310,
11140,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
4520,
14644,
10143,
2121,
2213,
1006,
7953,
1024,
1024,
2131,
1006,
1005,
3945,
1005,
1007,
1007,
1025,
1002,
2023,
1011,
1028,
7374,
10755,
2015,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/Grammar.php | Grammar.whereJsonBoolean | protected function whereJsonBoolean(Builder $query, $where)
{
$column = $this->wrapJsonBooleanSelector($where['column']);
$value = $this->wrapJsonBooleanValue(
$this->parameter($where['value'])
);
return $column.' '.$where['operator'].' '.$value;
} | php | protected function whereJsonBoolean(Builder $query, $where)
{
$column = $this->wrapJsonBooleanSelector($where['column']);
$value = $this->wrapJsonBooleanValue(
$this->parameter($where['value'])
);
return $column.' '.$where['operator'].' '.$value;
} | [
"protected",
"function",
"whereJsonBoolean",
"(",
"Builder",
"$",
"query",
",",
"$",
"where",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"wrapJsonBooleanSelector",
"(",
"$",
"where",
"[",
"'column'",
"]",
")",
";",
"$",
"value",
"=",
"$",
"this",
... | Compile a "where JSON boolean" clause.
@param \Illuminate\Database\Query\Builder $query
@param array $where
@return string | [
"Compile",
"a",
"where",
"JSON",
"boolean",
"clause",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/Grammar.php#L549-L558 | train | Internal method to wrap the where JSON boolean clause into a string | [
30522,
5123,
3853,
2073,
22578,
2239,
5092,
9890,
2319,
1006,
12508,
1002,
23032,
1010,
1002,
2073,
1007,
1063,
1002,
5930,
1027,
1002,
2023,
1011,
1028,
10236,
22578,
2239,
5092,
9890,
30524,
2709,
1002,
5930,
1012,
1005,
1005,
1012,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/Store.php | Store.persistResponse | private function persistResponse(Response $response)
{
$headers = $response->headers->all();
$headers['X-Status'] = [$response->getStatusCode()];
return $headers;
} | php | private function persistResponse(Response $response)
{
$headers = $response->headers->all();
$headers['X-Status'] = [$response->getStatusCode()];
return $headers;
} | [
"private",
"function",
"persistResponse",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"headers",
"=",
"$",
"response",
"->",
"headers",
"->",
"all",
"(",
")",
";",
"$",
"headers",
"[",
"'X-Status'",
"]",
"=",
"[",
"$",
"response",
"->",
"getStatusCo... | Persists the Response HTTP headers.
@return array An array of HTTP headers | [
"Persists",
"the",
"Response",
"HTTP",
"headers",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/Store.php#L462-L468 | train | Persist Response to cache | [
30522,
2797,
3853,
29486,
6072,
26029,
3366,
1006,
3433,
1002,
3433,
1007,
1063,
1002,
20346,
2015,
1027,
1002,
3433,
1011,
1028,
20346,
2015,
1011,
1028,
2035,
1006,
1007,
1025,
1002,
20346,
2015,
1031,
1005,
1060,
1011,
3570,
1005,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/FrameDecorator/Text.php | Text.get_margin_height | function get_margin_height()
{
// This function is called in add_frame_to_line() and is used to
// determine the line height, so we actually want to return the
// 'line-height' property, not the actual margin box
$style = $this->get_parent()->get_style();
$font = $style->font_family;
$size = $style->font_size;
/*
Helpers::pre_r('-----');
Helpers::pre_r($style->line_height);
Helpers::pre_r($style->font_size);
Helpers::pre_r($this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
Helpers::pre_r(($style->line_height / $size) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
*/
return ($style->line_height / ($size > 0 ? $size : 1)) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size);
} | php | function get_margin_height()
{
// This function is called in add_frame_to_line() and is used to
// determine the line height, so we actually want to return the
// 'line-height' property, not the actual margin box
$style = $this->get_parent()->get_style();
$font = $style->font_family;
$size = $style->font_size;
/*
Helpers::pre_r('-----');
Helpers::pre_r($style->line_height);
Helpers::pre_r($style->font_size);
Helpers::pre_r($this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
Helpers::pre_r(($style->line_height / $size) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size));
*/
return ($style->line_height / ($size > 0 ? $size : 1)) * $this->_dompdf->getFontMetrics()->getFontHeight($font, $size);
} | [
"function",
"get_margin_height",
"(",
")",
"{",
"// This function is called in add_frame_to_line() and is used to",
"// determine the line height, so we actually want to return the",
"// 'line-height' property, not the actual margin box",
"$",
"style",
"=",
"$",
"this",
"->",
"get_parent... | Vertical margins & padding do not apply to text frames
http://www.w3.org/TR/CSS21/visudet.html#inline-non-replaced:
The vertical padding, border and margin of an inline, non-replaced box
start at the top and bottom of the content area, not the
'line-height'. But only the 'line-height' is used to calculate the
height of the line box.
@return float|int | [
"Vertical",
"margins",
"&",
"padding",
"do",
"not",
"apply",
"to",
"text",
"frames"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameDecorator/Text.php#L96-L114 | train | Return the margin height of the line | [
30522,
3853,
2131,
1035,
7785,
1035,
4578,
1006,
1007,
1063,
1013,
1013,
2023,
3853,
2003,
2170,
1999,
5587,
1035,
4853,
1035,
2000,
1035,
2240,
1006,
1007,
1998,
2003,
2109,
2000,
1013,
1013,
5646,
1996,
2240,
4578,
1010,
2061,
2057,
294... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Login/PasswordResetter.php | PasswordResetter.savePasswordResetInfo | private function savePasswordResetInfo($login, $newPassword, $keySuffix)
{
$optionName = $this->getPasswordResetInfoOptionName($login);
$optionData = [
'hash' => $this->passwordHelper->hash(UsersManager::getPasswordHash($newPassword)),
'keySuffix' => $keySuffix,
];
$optionData = json_encode($optionData);
Option::set($optionName, $optionData);
} | php | private function savePasswordResetInfo($login, $newPassword, $keySuffix)
{
$optionName = $this->getPasswordResetInfoOptionName($login);
$optionData = [
'hash' => $this->passwordHelper->hash(UsersManager::getPasswordHash($newPassword)),
'keySuffix' => $keySuffix,
];
$optionData = json_encode($optionData);
Option::set($optionName, $optionData);
} | [
"private",
"function",
"savePasswordResetInfo",
"(",
"$",
"login",
",",
"$",
"newPassword",
",",
"$",
"keySuffix",
")",
"{",
"$",
"optionName",
"=",
"$",
"this",
"->",
"getPasswordResetInfoOptionName",
"(",
"$",
"login",
")",
";",
"$",
"optionData",
"=",
"["... | Stores password reset info for a specific login.
@param string $login The user login for whom a password change was requested.
@param string $newPassword The new password to set.
@param string $keySuffix The suffix used in generating a token. | [
"Stores",
"password",
"reset",
"info",
"for",
"a",
"specific",
"login",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/PasswordResetter.php#L461-L471 | train | Save password reset info to option | [
30522,
2797,
3853,
3828,
15194,
18351,
6072,
20624,
2078,
14876,
1006,
1002,
8833,
2378,
1010,
1002,
2047,
15194,
18351,
1010,
1002,
6309,
16093,
8873,
2595,
1007,
1063,
1002,
5724,
18442,
1027,
1002,
2023,
1011,
1028,
2131,
15194,
18351,
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/DependencyInjection/Container.php | Container.make | private function make(string $id, int $invalidBehavior)
{
if (isset($this->loading[$id])) {
throw new ServiceCircularReferenceException($id, array_merge(array_keys($this->loading), [$id]));
}
$this->loading[$id] = true;
try {
if (isset($this->fileMap[$id])) {
return /* self::IGNORE_ON_UNINITIALIZED_REFERENCE */ 4 === $invalidBehavior ? null : $this->load($this->fileMap[$id]);
} elseif (isset($this->methodMap[$id])) {
return /* self::IGNORE_ON_UNINITIALIZED_REFERENCE */ 4 === $invalidBehavior ? null : $this->{$this->methodMap[$id]}();
}
} catch (\Exception $e) {
unset($this->services[$id]);
throw $e;
} finally {
unset($this->loading[$id]);
}
if (/* self::EXCEPTION_ON_INVALID_REFERENCE */ 1 === $invalidBehavior) {
if (!$id) {
throw new ServiceNotFoundException($id);
}
if (isset($this->syntheticIds[$id])) {
throw new ServiceNotFoundException($id, null, null, [], sprintf('The "%s" service is synthetic, it needs to be set at boot time before it can be used.', $id));
}
if (isset($this->getRemovedIds()[$id])) {
throw new ServiceNotFoundException($id, null, null, [], sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $id));
}
$alternatives = [];
foreach ($this->getServiceIds() as $knownId) {
if ('' === $knownId || '.' === $knownId[0]) {
continue;
}
$lev = levenshtein($id, $knownId);
if ($lev <= \strlen($id) / 3 || false !== strpos($knownId, $id)) {
$alternatives[] = $knownId;
}
}
throw new ServiceNotFoundException($id, null, null, $alternatives);
}
} | php | private function make(string $id, int $invalidBehavior)
{
if (isset($this->loading[$id])) {
throw new ServiceCircularReferenceException($id, array_merge(array_keys($this->loading), [$id]));
}
$this->loading[$id] = true;
try {
if (isset($this->fileMap[$id])) {
return /* self::IGNORE_ON_UNINITIALIZED_REFERENCE */ 4 === $invalidBehavior ? null : $this->load($this->fileMap[$id]);
} elseif (isset($this->methodMap[$id])) {
return /* self::IGNORE_ON_UNINITIALIZED_REFERENCE */ 4 === $invalidBehavior ? null : $this->{$this->methodMap[$id]}();
}
} catch (\Exception $e) {
unset($this->services[$id]);
throw $e;
} finally {
unset($this->loading[$id]);
}
if (/* self::EXCEPTION_ON_INVALID_REFERENCE */ 1 === $invalidBehavior) {
if (!$id) {
throw new ServiceNotFoundException($id);
}
if (isset($this->syntheticIds[$id])) {
throw new ServiceNotFoundException($id, null, null, [], sprintf('The "%s" service is synthetic, it needs to be set at boot time before it can be used.', $id));
}
if (isset($this->getRemovedIds()[$id])) {
throw new ServiceNotFoundException($id, null, null, [], sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $id));
}
$alternatives = [];
foreach ($this->getServiceIds() as $knownId) {
if ('' === $knownId || '.' === $knownId[0]) {
continue;
}
$lev = levenshtein($id, $knownId);
if ($lev <= \strlen($id) / 3 || false !== strpos($knownId, $id)) {
$alternatives[] = $knownId;
}
}
throw new ServiceNotFoundException($id, null, null, $alternatives);
}
} | [
"private",
"function",
"make",
"(",
"string",
"$",
"id",
",",
"int",
"$",
"invalidBehavior",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"loading",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"ServiceCircularReferenceException",
"(",
... | Creates a service.
As a separate method to allow "get()" to use the really fast `??` operator. | [
"Creates",
"a",
"service",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Container.php#L233-L279 | train | Makes a service by its id | [
30522,
2797,
3853,
2191,
1006,
5164,
1002,
8909,
1010,
20014,
1002,
19528,
4783,
3270,
25500,
2099,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
30524,
1007,
1063,
5466,
2047,
2326,
6895,
11890,
7934,
2890,
25523,
10288,
24422,
1006,
1002,
89... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php | ContentSecurityPolicyHandler.updateCspHeaders | private function updateCspHeaders(Response $response, array $nonces = [])
{
$nonces = array_replace([
'csp_script_nonce' => $this->generateNonce(),
'csp_style_nonce' => $this->generateNonce(),
], $nonces);
$ruleIsSet = false;
$headers = $this->getCspHeaders($response);
foreach ($headers as $header => $directives) {
foreach (['script-src' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce'] as $type => $tokenName) {
if ($this->authorizesInline($directives, $type)) {
continue;
}
if (!isset($headers[$header][$type])) {
if (isset($headers[$header]['default-src'])) {
$headers[$header][$type] = $headers[$header]['default-src'];
} else {
// If there is no script-src/style-src and no default-src, no additional rules required.
continue;
}
}
$ruleIsSet = true;
if (!\in_array('\'unsafe-inline\'', $headers[$header][$type], true)) {
$headers[$header][$type][] = '\'unsafe-inline\'';
}
$headers[$header][$type][] = sprintf('\'nonce-%s\'', $nonces[$tokenName]);
}
}
if (!$ruleIsSet) {
return $nonces;
}
foreach ($headers as $header => $directives) {
$response->headers->set($header, $this->generateCspHeader($directives));
}
return $nonces;
} | php | private function updateCspHeaders(Response $response, array $nonces = [])
{
$nonces = array_replace([
'csp_script_nonce' => $this->generateNonce(),
'csp_style_nonce' => $this->generateNonce(),
], $nonces);
$ruleIsSet = false;
$headers = $this->getCspHeaders($response);
foreach ($headers as $header => $directives) {
foreach (['script-src' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce'] as $type => $tokenName) {
if ($this->authorizesInline($directives, $type)) {
continue;
}
if (!isset($headers[$header][$type])) {
if (isset($headers[$header]['default-src'])) {
$headers[$header][$type] = $headers[$header]['default-src'];
} else {
// If there is no script-src/style-src and no default-src, no additional rules required.
continue;
}
}
$ruleIsSet = true;
if (!\in_array('\'unsafe-inline\'', $headers[$header][$type], true)) {
$headers[$header][$type][] = '\'unsafe-inline\'';
}
$headers[$header][$type][] = sprintf('\'nonce-%s\'', $nonces[$tokenName]);
}
}
if (!$ruleIsSet) {
return $nonces;
}
foreach ($headers as $header => $directives) {
$response->headers->set($header, $this->generateCspHeader($directives));
}
return $nonces;
} | [
"private",
"function",
"updateCspHeaders",
"(",
"Response",
"$",
"response",
",",
"array",
"$",
"nonces",
"=",
"[",
"]",
")",
"{",
"$",
"nonces",
"=",
"array_replace",
"(",
"[",
"'csp_script_nonce'",
"=>",
"$",
"this",
"->",
"generateNonce",
"(",
")",
",",... | Updates Content-Security-Policy headers in a response.
@return array | [
"Updates",
"Content",
"-",
"Security",
"-",
"Policy",
"headers",
"in",
"a",
"response",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php#L119-L160 | train | Update the CSP headers | [
30522,
2797,
3853,
10651,
6169,
8458,
13775,
2545,
1006,
3433,
1002,
3433,
1010,
9140,
1002,
2512,
9623,
1027,
1031,
1033,
1007,
1063,
1002,
2512,
9623,
1027,
9140,
1035,
5672,
1006,
1031,
1005,
20116,
2361,
1035,
5896,
1035,
2512,
3401,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/View/Concerns/ManagesStacks.php | ManagesStacks.yieldPushContent | public function yieldPushContent($section, $default = '')
{
if (! isset($this->pushes[$section]) && ! isset($this->prepends[$section])) {
return $default;
}
$output = '';
if (isset($this->prepends[$section])) {
$output .= implode(array_reverse($this->prepends[$section]));
}
if (isset($this->pushes[$section])) {
$output .= implode($this->pushes[$section]);
}
return $output;
} | php | public function yieldPushContent($section, $default = '')
{
if (! isset($this->pushes[$section]) && ! isset($this->prepends[$section])) {
return $default;
}
$output = '';
if (isset($this->prepends[$section])) {
$output .= implode(array_reverse($this->prepends[$section]));
}
if (isset($this->pushes[$section])) {
$output .= implode($this->pushes[$section]);
}
return $output;
} | [
"public",
"function",
"yieldPushContent",
"(",
"$",
"section",
",",
"$",
"default",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"pushes",
"[",
"$",
"section",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"prepends... | Get the string contents of a push section.
@param string $section
@param string $default
@return string | [
"Get",
"the",
"string",
"contents",
"of",
"a",
"push",
"section",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Concerns/ManagesStacks.php#L149-L166 | train | Yields the content of a push section | [
30522,
2270,
3853,
10750,
12207,
16257,
28040,
3372,
1006,
1002,
2930,
1010,
1002,
12398,
1027,
1005,
1005,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
13956,
1031,
1002,
2930,
1033,
1007,
1004,
1004,
999,
26354,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Filechecks.php | Filechecks.canAutoUpdate | public static function canAutoUpdate()
{
if (!is_writable(PIWIK_INCLUDE_PATH . '/') ||
!is_writable(PIWIK_DOCUMENT_ROOT . '/index.php') ||
!is_writable(PIWIK_INCLUDE_PATH . '/core') ||
!is_writable(PIWIK_USER_PATH . '/config/global.ini.php')
) {
return false;
}
return true;
} | php | public static function canAutoUpdate()
{
if (!is_writable(PIWIK_INCLUDE_PATH . '/') ||
!is_writable(PIWIK_DOCUMENT_ROOT . '/index.php') ||
!is_writable(PIWIK_INCLUDE_PATH . '/core') ||
!is_writable(PIWIK_USER_PATH . '/config/global.ini.php')
) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"canAutoUpdate",
"(",
")",
"{",
"if",
"(",
"!",
"is_writable",
"(",
"PIWIK_INCLUDE_PATH",
".",
"'/'",
")",
"||",
"!",
"is_writable",
"(",
"PIWIK_DOCUMENT_ROOT",
".",
"'/index.php'",
")",
"||",
"!",
"is_writable",
"(",
"PIWIK_INC... | Check if this installation can be auto-updated.
For performance, we look for clues rather than an exhaustive test.
@return bool | [
"Check",
"if",
"this",
"installation",
"can",
"be",
"auto",
"-",
"updated",
".",
"For",
"performance",
"we",
"look",
"for",
"clues",
"rather",
"than",
"an",
"exhaustive",
"test",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filechecks.php#L21-L31 | train | Can auto update | [
30522,
2270,
10763,
3853,
2064,
4887,
24826,
17299,
3686,
1006,
1007,
1063,
2065,
1006,
999,
2003,
1035,
25697,
3085,
1006,
14255,
9148,
2243,
1035,
2421,
1035,
4130,
1012,
1005,
1013,
1005,
1007,
1064,
1064,
999,
2003,
1035,
25697,
3085,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/ViewCacheCommand.php | ViewCacheCommand.compileViews | protected function compileViews(Collection $views)
{
$compiler = $this->laravel['view']->getEngineResolver()->resolve('blade')->getCompiler();
$views->map(function (SplFileInfo $file) use ($compiler) {
$compiler->compile($file->getRealPath());
});
} | php | protected function compileViews(Collection $views)
{
$compiler = $this->laravel['view']->getEngineResolver()->resolve('blade')->getCompiler();
$views->map(function (SplFileInfo $file) use ($compiler) {
$compiler->compile($file->getRealPath());
});
} | [
"protected",
"function",
"compileViews",
"(",
"Collection",
"$",
"views",
")",
"{",
"$",
"compiler",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'view'",
"]",
"->",
"getEngineResolver",
"(",
")",
"->",
"resolve",
"(",
"'blade'",
")",
"->",
"getCompiler",
"(",... | Compile the given view files.
@param \Illuminate\Support\Collection $views
@return void | [
"Compile",
"the",
"given",
"view",
"files",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/ViewCacheCommand.php#L48-L55 | train | Compile all views | [
30522,
5123,
3853,
4012,
22090,
8584,
2015,
1006,
3074,
1002,
5328,
1007,
1063,
30524,
5328,
1011,
1028,
4949,
1006,
3853,
1006,
11867,
10270,
9463,
2378,
14876,
1002,
5371,
1007,
2224,
1006,
1002,
21624,
1007,
1063,
1002,
21624,
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... |
octobercms/october | modules/cms/widgets/TemplateList.php | TemplateList.render | public function render()
{
$toolbarClass = Str::contains($this->controlClass, 'hero') ? 'separator' : null;
$this->vars['toolbarClass'] = $toolbarClass;
return $this->makePartial('body', [
'data' => $this->getData()
]);
} | php | public function render()
{
$toolbarClass = Str::contains($this->controlClass, 'hero') ? 'separator' : null;
$this->vars['toolbarClass'] = $toolbarClass;
return $this->makePartial('body', [
'data' => $this->getData()
]);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"toolbarClass",
"=",
"Str",
"::",
"contains",
"(",
"$",
"this",
"->",
"controlClass",
",",
"'hero'",
")",
"?",
"'separator'",
":",
"null",
";",
"$",
"this",
"->",
"vars",
"[",
"'toolbarClass'",
"]",
"... | Renders the widget.
@return string | [
"Renders",
"the",
"widget",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/widgets/TemplateList.php#L112-L121 | train | Render the body of the form | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
6994,
8237,
26266,
1027,
2358,
2099,
1024,
1024,
3397,
1006,
1002,
2023,
1011,
1028,
2491,
26266,
1010,
1005,
5394,
1005,
1007,
1029,
1005,
19802,
25879,
2953,
1005,
1024,
19701,
1025,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Traits/PdoTrait.php | PdoTrait.doHave | protected function doHave($id)
{
$sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)";
$stmt = $this->getConnection()->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
$stmt->execute();
return (bool) $stmt->fetchColumn();
} | php | protected function doHave($id)
{
$sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)";
$stmt = $this->getConnection()->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->bindValue(':time', time(), \PDO::PARAM_INT);
$stmt->execute();
return (bool) $stmt->fetchColumn();
} | [
"protected",
"function",
"doHave",
"(",
"$",
"id",
")",
"{",
"$",
"sql",
"=",
"\"SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)\"",
";",
"$",
"stmt",
"=",
"$",
"this",
"->",
"getConnection",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/PdoTrait.php#L215-L225 | train | Does the actual work of checking if the record exists in the database | [
30522,
5123,
3853,
26528,
3726,
1006,
1002,
8909,
1007,
1063,
1002,
29296,
1027,
1000,
7276,
1015,
2013,
1002,
2023,
1011,
1028,
2795,
2073,
1002,
2023,
1011,
1028,
8909,
25778,
1027,
1024,
8909,
1998,
1006,
1002,
2023,
1011,
1028,
6480,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Helper/SlotsHelper.php | SlotsHelper.start | public function start($name)
{
if (\in_array($name, $this->openSlots)) {
throw new \InvalidArgumentException(sprintf('A slot named "%s" is already started.', $name));
}
$this->openSlots[] = $name;
$this->slots[$name] = '';
ob_start();
ob_implicit_flush(0);
} | php | public function start($name)
{
if (\in_array($name, $this->openSlots)) {
throw new \InvalidArgumentException(sprintf('A slot named "%s" is already started.', $name));
}
$this->openSlots[] = $name;
$this->slots[$name] = '';
ob_start();
ob_implicit_flush(0);
} | [
"public",
"function",
"start",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"openSlots",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'A slot named \"%s\" is al... | Starts a new slot.
This method starts an output buffer that will be
closed when the stop() method is called.
@param string $name The slot name
@throws \InvalidArgumentException if a slot with the same name is already started | [
"Starts",
"a",
"new",
"slot",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Templating/Helper/SlotsHelper.php#L34-L45 | train | Start a new slot | [
30522,
2270,
3853,
2707,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
1032,
1999,
1035,
9140,
1006,
1002,
2171,
1010,
1002,
2023,
1011,
1028,
7480,
10994,
2015,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422,
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/Plugin.php | Plugin.offsetExists | public function offsetExists($offset)
{
$this->loadBlueprint();
if ($offset === 'title') {
$offset = 'name';
}
return isset($this->blueprint[$offset]);
} | php | public function offsetExists($offset)
{
$this->loadBlueprint();
if ($offset === 'title') {
$offset = 'name';
}
return isset($this->blueprint[$offset]);
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"$",
"this",
"->",
"loadBlueprint",
"(",
")",
";",
"if",
"(",
"$",
"offset",
"===",
"'title'",
")",
"{",
"$",
"offset",
"=",
"'name'",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
... | Whether or not an offset exists.
@param string $offset An offset to check for.
@return bool Returns TRUE on success or FALSE on failure. | [
"Whether",
"or",
"not",
"an",
"offset",
"exists",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Plugin.php#L190-L198 | train | Checks if a value exists in blueprint | [
30522,
2270,
3853,
16396,
10288,
5130,
1006,
1002,
16396,
1007,
1063,
1002,
2023,
1011,
1028,
7170,
16558,
5657,
16550,
1006,
1007,
1025,
2065,
1006,
1002,
16396,
1027,
1027,
1027,
1005,
2516,
1005,
1007,
1063,
1002,
16396,
1027,
1005,
2171... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/CustomerService/ServiceProvider.php | ServiceProvider.register | public function register(Container $app)
{
$app['customer_service'] = function ($app) {
return new Client($app);
};
$app['customer_service_session'] = function ($app) {
return new SessionClient($app);
};
} | php | public function register(Container $app)
{
$app['customer_service'] = function ($app) {
return new Client($app);
};
$app['customer_service_session'] = function ($app) {
return new SessionClient($app);
};
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'customer_service'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Client",
"(",
"$",
"app",
")",
";",
"}",
";",
"$",
"app",
"[",
"'cus... | {@inheritdoc}. | [
"{"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/CustomerService/ServiceProvider.php#L27-L36 | train | Register the customer service and session | [
30522,
2270,
3853,
4236,
1006,
11661,
1002,
10439,
1007,
1063,
1002,
10439,
1031,
1005,
8013,
1035,
2326,
1005,
1033,
1027,
3853,
1006,
1002,
10439,
1007,
1063,
2709,
2047,
7396,
1006,
1002,
10439,
1007,
1025,
1065,
1025,
1002,
10439,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Annotations/Controller.php | Controller.getAnnotationManager | public function getAnnotationManager($fetch = false, $date = false, $period = false, $lastN = false)
{
$this->checkSitePermission();
if ($date === false) {
$date = Common::getRequestVar('date', false);
}
if ($period === false) {
$period = Common::getRequestVar('period', 'day');
}
if ($lastN === false) {
$lastN = Common::getRequestVar('lastN', false);
}
// create & render the view
$view = new View('@Annotations/getAnnotationManager');
$allAnnotations = Request::processRequest(
'Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
$view->annotations = empty($allAnnotations[$this->idSite]) ? array() : $allAnnotations[$this->idSite];
$view->period = $period;
$view->lastN = $lastN;
list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
$view->startDate = $startDate->toString();
$view->endDate = $endDate->toString();
if ($startDate->toString() !== $endDate->toString()) {
$view->selectedDate = Date::today()->toString();
} else {
$view->selectedDate = $endDate->toString();
}
$dateFormat = Date::DATE_FORMAT_SHORT;
$view->startDatePretty = $startDate->getLocalized($dateFormat);
$view->endDatePretty = $endDate->getLocalized($dateFormat);
$view->canUserAddNotes = AnnotationList::canUserAddNotesFor($this->idSite);
return $view->render();
} | php | public function getAnnotationManager($fetch = false, $date = false, $period = false, $lastN = false)
{
$this->checkSitePermission();
if ($date === false) {
$date = Common::getRequestVar('date', false);
}
if ($period === false) {
$period = Common::getRequestVar('period', 'day');
}
if ($lastN === false) {
$lastN = Common::getRequestVar('lastN', false);
}
// create & render the view
$view = new View('@Annotations/getAnnotationManager');
$allAnnotations = Request::processRequest(
'Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN));
$view->annotations = empty($allAnnotations[$this->idSite]) ? array() : $allAnnotations[$this->idSite];
$view->period = $period;
$view->lastN = $lastN;
list($startDate, $endDate) = API::getDateRangeForPeriod($date, $period, $lastN);
$view->startDate = $startDate->toString();
$view->endDate = $endDate->toString();
if ($startDate->toString() !== $endDate->toString()) {
$view->selectedDate = Date::today()->toString();
} else {
$view->selectedDate = $endDate->toString();
}
$dateFormat = Date::DATE_FORMAT_SHORT;
$view->startDatePretty = $startDate->getLocalized($dateFormat);
$view->endDatePretty = $endDate->getLocalized($dateFormat);
$view->canUserAddNotes = AnnotationList::canUserAddNotesFor($this->idSite);
return $view->render();
} | [
"public",
"function",
"getAnnotationManager",
"(",
"$",
"fetch",
"=",
"false",
",",
"$",
"date",
"=",
"false",
",",
"$",
"period",
"=",
"false",
",",
"$",
"lastN",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"checkSitePermission",
"(",
")",
";",
"if",
... | Controller action that returns HTML displaying annotations for a site and
specific date range.
Query Param Input:
- idSite: The ID of the site to get annotations for. Only one allowed.
- date: The date to get annotations for. If lastN is not supplied, this is the start date,
otherwise the start date in the last period.
- period: The period type.
- lastN: If supplied, the last N # of periods will be included w/ the range specified
by date + period.
Output:
- HTML displaying annotations for a specific range.
@param bool $fetch True if the annotation manager should be returned as a string,
false if it should be echo-ed.
@param bool|string $date Override for 'date' query parameter.
@param bool|string $period Override for 'period' query parameter.
@param bool|string $lastN Override for 'lastN' query parameter.
@return string|void | [
"Controller",
"action",
"that",
"returns",
"HTML",
"displaying",
"annotations",
"for",
"a",
"site",
"and",
"specific",
"date",
"range",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L44-L87 | train | Returns the annotation manager | [
30522,
2270,
3853,
2131,
11639,
17287,
3508,
24805,
4590,
1006,
1002,
18584,
1027,
6270,
1010,
1002,
3058,
1027,
6270,
1010,
1002,
2558,
1027,
6270,
1010,
1002,
2197,
2078,
1027,
6270,
1007,
1063,
1002,
2023,
1011,
1028,
14148,
4221,
4842,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TokenParser/TwigTokenParserThrow.php | TwigTokenParserThrow.parse | public function parse(Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$code = $stream->expect(Token::NUMBER_TYPE)->getValue();
$message = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(Token::BLOCK_END_TYPE);
return new TwigNodeThrow($code, $message, $lineno, $this->getTag());
} | php | public function parse(Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$code = $stream->expect(Token::NUMBER_TYPE)->getValue();
$message = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(Token::BLOCK_END_TYPE);
return new TwigNodeThrow($code, $message, $lineno, $this->getTag());
} | [
"public",
"function",
"parse",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"lineno",
"=",
"$",
"token",
"->",
"getLine",
"(",
")",
";",
"$",
"stream",
"=",
"$",
"this",
"->",
"parser",
"->",
"getStream",
"(",
")",
";",
"$",
"code",
"=",
"$",
"stre... | Parses a token and returns a node.
@param Token $token A Twig_Token instance
@return Node A Twig_Node instance | [
"Parses",
"a",
"token",
"and",
"returns",
"a",
"node",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserThrow.php#L33-L43 | train | Parse a throw token | [
30522,
2270,
3853,
11968,
3366,
1006,
19204,
1002,
19204,
1007,
1063,
1002,
17517,
2080,
1027,
1002,
19204,
1011,
1028,
2131,
4179,
1006,
1007,
1025,
1002,
5460,
1027,
1002,
2023,
1011,
1028,
11968,
8043,
1011,
1028,
4152,
25379,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Pagination/PaginationServiceProvider.php | PaginationServiceProvider.register | public function register()
{
Paginator::viewFactoryResolver(function () {
return $this->app['view'];
});
Paginator::currentPathResolver(function () {
return $this->app['request']->url();
});
Paginator::currentPageResolver(function ($pageName = 'page') {
$page = $this->app['request']->input($pageName);
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
return (int) $page;
}
return 1;
});
} | php | public function register()
{
Paginator::viewFactoryResolver(function () {
return $this->app['view'];
});
Paginator::currentPathResolver(function () {
return $this->app['request']->url();
});
Paginator::currentPageResolver(function ($pageName = 'page') {
$page = $this->app['request']->input($pageName);
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
return (int) $page;
}
return 1;
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"Paginator",
"::",
"viewFactoryResolver",
"(",
"function",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"[",
"'view'",
"]",
";",
"}",
")",
";",
"Paginator",
"::",
"currentPathResolver",
"(",
"function"... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Pagination/PaginationServiceProvider.php#L30-L49 | train | Register the view factory resolver and page resolver | [
30522,
2270,
3853,
4236,
1006,
1007,
1063,
6643,
20876,
4263,
1024,
1024,
3193,
21450,
6072,
4747,
6299,
1006,
3853,
1006,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
3193,
1005,
1033,
1025,
1065,
1007,
1025,
6643,
20876,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Renderer/Array.php | HTML_QuickForm2_Renderer_Array.pushScalar | public function pushScalar(array $element)
{
if (!empty($element['required'])) {
$this->hasRequired = true;
}
if (empty($this->containers)) {
$this->array += $element;
} else {
$this->containers[count($this->containers) - 1][] = $element;
}
} | php | public function pushScalar(array $element)
{
if (!empty($element['required'])) {
$this->hasRequired = true;
}
if (empty($this->containers)) {
$this->array += $element;
} else {
$this->containers[count($this->containers) - 1][] = $element;
}
} | [
"public",
"function",
"pushScalar",
"(",
"array",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"element",
"[",
"'required'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"hasRequired",
"=",
"true",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
... | Stores an array representing "scalar" element in the form array
@param array | [
"Stores",
"an",
"array",
"representing",
"scalar",
"element",
"in",
"the",
"form",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Array.php#L247-L257 | train | Pushes an array to the end of the array | [
30522,
2270,
3853,
5245,
15782,
8017,
1006,
9140,
1002,
5783,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
5783,
1031,
1005,
3223,
1005,
1033,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
2038,
2890,
15549,
5596,
1027,
2995,
1025,
1065,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Controllers/RoleController.php | RoleController.detail | protected function detail($id)
{
$roleModel = config('admin.database.roles_model');
$show = new Show($roleModel::findOrFail($id));
$show->id('ID');
$show->slug(trans('admin.slug'));
$show->name(trans('admin.name'));
$show->permissions(trans('admin.permissions'))->as(function ($permission) {
return $permission->pluck('name');
})->label();
$show->created_at(trans('admin.created_at'));
$show->updated_at(trans('admin.updated_at'));
return $show;
} | php | protected function detail($id)
{
$roleModel = config('admin.database.roles_model');
$show = new Show($roleModel::findOrFail($id));
$show->id('ID');
$show->slug(trans('admin.slug'));
$show->name(trans('admin.name'));
$show->permissions(trans('admin.permissions'))->as(function ($permission) {
return $permission->pluck('name');
})->label();
$show->created_at(trans('admin.created_at'));
$show->updated_at(trans('admin.updated_at'));
return $show;
} | [
"protected",
"function",
"detail",
"(",
"$",
"id",
")",
"{",
"$",
"roleModel",
"=",
"config",
"(",
"'admin.database.roles_model'",
")",
";",
"$",
"show",
"=",
"new",
"Show",
"(",
"$",
"roleModel",
"::",
"findOrFail",
"(",
"$",
"id",
")",
")",
";",
"$",... | Make a show builder.
@param mixed $id
@return Show | [
"Make",
"a",
"show",
"builder",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Controllers/RoleController.php#L119-L135 | train | Detail show. | [
30522,
5123,
3853,
6987,
1006,
1002,
8909,
1007,
1063,
1002,
2535,
5302,
9247,
1027,
9530,
8873,
2290,
1006,
1005,
4748,
10020,
1012,
7809,
1012,
4395,
1035,
2944,
1005,
1007,
1025,
1002,
2265,
1027,
2047,
2265,
1006,
1002,
2535,
5302,
92... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Settings/Storage/Storage.php | Storage.setValue | public function setValue($key, $value)
{
$this->loadSettingsIfNotDoneYet();
$this->isDirty = true;
$this->settingsValues[$key] = $value;
} | php | public function setValue($key, $value)
{
$this->loadSettingsIfNotDoneYet();
$this->isDirty = true;
$this->settingsValues[$key] = $value;
} | [
"public",
"function",
"setValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"loadSettingsIfNotDoneYet",
"(",
")",
";",
"$",
"this",
"->",
"isDirty",
"=",
"true",
";",
"$",
"this",
"->",
"settingsValues",
"[",
"$",
"key",
"]",
"... | Sets (overwrites) the value of a setting in memory. To persist the change across requests, {@link save()} must be
called.
@param string $key The name / key of a setting
@param mixed $value The value that shall be set for the given setting. | [
"Sets",
"(",
"overwrites",
")",
"the",
"value",
"of",
"a",
"setting",
"in",
"memory",
".",
"To",
"persist",
"the",
"change",
"across",
"requests",
"{",
"@link",
"save",
"()",
"}",
"must",
"be",
"called",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Settings/Storage/Storage.php#L100-L106 | train | Set a setting value | [
30522,
2270,
3853,
2275,
10175,
5657,
1006,
1002,
3145,
1010,
1002,
3643,
1007,
1063,
1002,
2023,
1011,
1028,
15665,
18319,
3070,
5332,
2546,
17048,
5280,
17683,
2102,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
2003,
4305,
5339,
2100,
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/models/Preference.php | Preference.getEditorThemeOptions | public function getEditorThemeOptions()
{
$themeDir = new DirectoryIterator("modules/backend/formwidgets/codeeditor/assets/vendor/ace/");
$themes = [];
// Iterate through the themes
foreach ($themeDir as $node) {
// If this file is a theme (starting by "theme-")
if (!$node->isDir() && substr($node->getFileName(), 0, 6) == 'theme-') {
// Remove the theme- prefix and the .js suffix, create an user friendly and capitalized name
$themeId = substr($node->getFileName(), 6, -3);
$themeName = ucwords(str_replace("_", " ", $themeId));
// Add the values to the themes array
if ($themeId != static::DEFAULT_THEME) {
$themes[$themeId] = $themeName;
}
}
}
// Sort the theme alphabetically, and push the default theme
asort($themes);
return [static::DEFAULT_THEME => ucwords(static::DEFAULT_THEME)] + $themes;
} | php | public function getEditorThemeOptions()
{
$themeDir = new DirectoryIterator("modules/backend/formwidgets/codeeditor/assets/vendor/ace/");
$themes = [];
// Iterate through the themes
foreach ($themeDir as $node) {
// If this file is a theme (starting by "theme-")
if (!$node->isDir() && substr($node->getFileName(), 0, 6) == 'theme-') {
// Remove the theme- prefix and the .js suffix, create an user friendly and capitalized name
$themeId = substr($node->getFileName(), 6, -3);
$themeName = ucwords(str_replace("_", " ", $themeId));
// Add the values to the themes array
if ($themeId != static::DEFAULT_THEME) {
$themes[$themeId] = $themeName;
}
}
}
// Sort the theme alphabetically, and push the default theme
asort($themes);
return [static::DEFAULT_THEME => ucwords(static::DEFAULT_THEME)] + $themes;
} | [
"public",
"function",
"getEditorThemeOptions",
"(",
")",
"{",
"$",
"themeDir",
"=",
"new",
"DirectoryIterator",
"(",
"\"modules/backend/formwidgets/codeeditor/assets/vendor/ace/\"",
")",
";",
"$",
"themes",
"=",
"[",
"]",
";",
"// Iterate through the themes",
"foreach",
... | Returns the theme options for the backend editor.
@return array | [
"Returns",
"the",
"theme",
"options",
"for",
"the",
"backend",
"editor",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/models/Preference.php#L271-L296 | train | Get the theme options for the code editor | [
30522,
2270,
3853,
2131,
2098,
15660,
10760,
26247,
16790,
2015,
1006,
1007,
1063,
1002,
11773,
4313,
1027,
2047,
14176,
21646,
8844,
1006,
1000,
14184,
1013,
2067,
10497,
1013,
2433,
9148,
28682,
1013,
3642,
2098,
15660,
1013,
7045,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
slimphp/Slim | Slim/Http/Headers.php | Headers.createFromEnvironment | public static function createFromEnvironment(Environment $environment)
{
$data = [];
$environment = self::determineAuthorization($environment);
foreach ($environment as $key => $value) {
$key = strtoupper($key);
if (isset(static::$special[$key]) || strpos($key, 'HTTP_') === 0) {
if ($key !== 'HTTP_CONTENT_LENGTH') {
$data[$key] = $value;
}
}
}
return new static($data);
} | php | public static function createFromEnvironment(Environment $environment)
{
$data = [];
$environment = self::determineAuthorization($environment);
foreach ($environment as $key => $value) {
$key = strtoupper($key);
if (isset(static::$special[$key]) || strpos($key, 'HTTP_') === 0) {
if ($key !== 'HTTP_CONTENT_LENGTH') {
$data[$key] = $value;
}
}
}
return new static($data);
} | [
"public",
"static",
"function",
"createFromEnvironment",
"(",
"Environment",
"$",
"environment",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"environment",
"=",
"self",
"::",
"determineAuthorization",
"(",
"$",
"environment",
")",
";",
"foreach",
"(",
"$... | Create new headers collection with data extracted from the application Environment object
@param Environment $environment The Slim application Environment
@return self | [
"Create",
"new",
"headers",
"collection",
"with",
"data",
"extracted",
"from",
"the",
"application",
"Environment",
"object"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Headers.php#L47-L61 | train | Create a new instance from the environment variables | [
30522,
2270,
10763,
3853,
3443,
19699,
8462,
2078,
21663,
2239,
3672,
1006,
4044,
1002,
4044,
1007,
1063,
1002,
2951,
1027,
1031,
1033,
1025,
1002,
4044,
1027,
2969,
1024,
1024,
5646,
4887,
27844,
3989,
1006,
1002,
4044,
1007,
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... |
laravel/framework | src/Illuminate/Validation/Concerns/ReplacesAttributes.php | ReplacesAttributes.replaceRequiredWithout | protected function replaceRequiredWithout($message, $attribute, $rule, $parameters)
{
return $this->replaceRequiredWith($message, $attribute, $rule, $parameters);
} | php | protected function replaceRequiredWithout($message, $attribute, $rule, $parameters)
{
return $this->replaceRequiredWith($message, $attribute, $rule, $parameters);
} | [
"protected",
"function",
"replaceRequiredWithout",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"replaceRequiredWith",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"ru... | Replace all place-holders for the required_without rule.
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@return string | [
"Replace",
"all",
"place",
"-",
"holders",
"for",
"the",
"required_without",
"rule",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php#L218-L221 | train | Replace all place - holders for the required_without rule. | [
30522,
5123,
3853,
5672,
2890,
15549,
5596,
24415,
5833,
1006,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5672,
2890,
15549,
5596,
24415,
1006,
1002,
4471,
1010,
1002,
17961... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/Controller.php | Controller.anonymousSettings | public function anonymousSettings()
{
Piwik::checkUserHasSuperUserAccess();
$view = new View('@UsersManager/anonymousSettings');
$view->availableDefaultDates = $this->getDefaultDates();
$this->initViewAnonymousUserSettings($view);
$this->setBasicVariablesView($view);
return $view->render();
} | php | public function anonymousSettings()
{
Piwik::checkUserHasSuperUserAccess();
$view = new View('@UsersManager/anonymousSettings');
$view->availableDefaultDates = $this->getDefaultDates();
$this->initViewAnonymousUserSettings($view);
$this->setBasicVariablesView($view);
return $view->render();
} | [
"public",
"function",
"anonymousSettings",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"$",
"view",
"=",
"new",
"View",
"(",
"'@UsersManager/anonymousSettings'",
")",
";",
"$",
"view",
"->",
"availableDefaultDates",
"=",
"$",
"thi... | The "Anonymous Settings" admin UI screen view | [
"The",
"Anonymous",
"Settings",
"admin",
"UI",
"screen",
"view"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/Controller.php#L243-L255 | train | Returns the anonymous settings. | [
30522,
2270,
3853,
10812,
21678,
8613,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1025,
1002,
3193,
1027,
2047,
3193,
1006,
1005,
1030,
5198,
24805,
4590,
1013,
1081... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php | AbstractTagAwareAdapter.invalidateTags | public function invalidateTags(array $tags)
{
if (empty($tags)) {
return false;
}
$tagIds = [];
foreach (\array_unique($tags) as $tag) {
$tagIds[] = $this->getId(self::TAGS_PREFIX.$tag);
}
if ($this->doInvalidate($tagIds)) {
return true;
}
return false;
} | php | public function invalidateTags(array $tags)
{
if (empty($tags)) {
return false;
}
$tagIds = [];
foreach (\array_unique($tags) as $tag) {
$tagIds[] = $this->getId(self::TAGS_PREFIX.$tag);
}
if ($this->doInvalidate($tagIds)) {
return true;
}
return false;
} | [
"public",
"function",
"invalidateTags",
"(",
"array",
"$",
"tags",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"tags",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"tagIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"\\",
"array_unique",
"(",
"$",
"tags"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php#L264-L280 | train | Invalidate all tags | [
30522,
2270,
3853,
19528,
3686,
15900,
2015,
1006,
9140,
1002,
22073,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
22073,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
6415,
9821,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1032,
9140,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Filesystem/Folder.php | Folder.shift | public static function shift(&$path)
{
$parts = explode('/', trim($path, '/'), 2);
$result = array_shift($parts);
$path = array_shift($parts);
return $result ?: null;
} | php | public static function shift(&$path)
{
$parts = explode('/', trim($path, '/'), 2);
$result = array_shift($parts);
$path = array_shift($parts);
return $result ?: null;
} | [
"public",
"static",
"function",
"shift",
"(",
"&",
"$",
"path",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"path",
",",
"'/'",
")",
",",
"2",
")",
";",
"$",
"result",
"=",
"array_shift",
"(",
"$",
"parts",
")",
"... | Shift first directory out of the path.
@param string $path
@return string | [
"Shift",
"first",
"directory",
"out",
"of",
"the",
"path",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Filesystem/Folder.php#L180-L187 | train | Shift the path off the beginning of the array | [
30522,
2270,
10763,
3853,
5670,
1006,
1004,
1002,
4130,
1007,
1063,
1002,
3033,
1027,
15044,
1006,
1005,
1013,
1005,
1010,
12241,
1006,
1002,
4130,
1010,
1005,
1013,
1005,
1007,
1010,
1016,
1007,
1025,
1002,
2765,
1027,
9140,
1035,
5670,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Filesystem.php | Filesystem.deleteAllCacheOnUpdate | public static function deleteAllCacheOnUpdate($pluginName = false)
{
AssetManager::getInstance()->removeMergedAssets($pluginName);
View::clearCompiledTemplates();
TrackerCache::deleteTrackerCache();
PiwikCache::flushAll();
self::clearPhpCaches();
$pluginManager = Plugin\Manager::getInstance();
$plugins = $pluginManager->getLoadedPlugins();
foreach ($plugins as $plugin) {
$plugin->reloadPluginInformation();
}
/**
* Triggered after all non-memory caches are cleared (eg, via the cache:clear
* command).
*/
Piwik::postEvent('Filesystem.allCachesCleared');
} | php | public static function deleteAllCacheOnUpdate($pluginName = false)
{
AssetManager::getInstance()->removeMergedAssets($pluginName);
View::clearCompiledTemplates();
TrackerCache::deleteTrackerCache();
PiwikCache::flushAll();
self::clearPhpCaches();
$pluginManager = Plugin\Manager::getInstance();
$plugins = $pluginManager->getLoadedPlugins();
foreach ($plugins as $plugin) {
$plugin->reloadPluginInformation();
}
/**
* Triggered after all non-memory caches are cleared (eg, via the cache:clear
* command).
*/
Piwik::postEvent('Filesystem.allCachesCleared');
} | [
"public",
"static",
"function",
"deleteAllCacheOnUpdate",
"(",
"$",
"pluginName",
"=",
"false",
")",
"{",
"AssetManager",
"::",
"getInstance",
"(",
")",
"->",
"removeMergedAssets",
"(",
"$",
"pluginName",
")",
";",
"View",
"::",
"clearCompiledTemplates",
"(",
")... | Called on Core install, update, plugin enable/disable
Will clear all cache that could be affected by the change in configuration being made | [
"Called",
"on",
"Core",
"install",
"update",
"plugin",
"enable",
"/",
"disable",
"Will",
"clear",
"all",
"cache",
"that",
"could",
"be",
"affected",
"by",
"the",
"change",
"in",
"configuration",
"being",
"made"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L29-L48 | train | Clears all caches on update | [
30522,
2270,
10763,
3853,
3972,
12870,
8095,
3540,
28099,
6279,
13701,
1006,
1002,
13354,
23111,
14074,
1027,
6270,
1007,
1063,
11412,
24805,
4590,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
6366,
5017,
5999,
27241,
3215,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Controllers/PermissionController.php | PermissionController.show | public function show($id, Content $content)
{
return $content
->header(trans('admin.permissions'))
->description(trans('admin.detail'))
->body($this->detail($id));
} | php | public function show($id, Content $content)
{
return $content
->header(trans('admin.permissions'))
->description(trans('admin.detail'))
->body($this->detail($id));
} | [
"public",
"function",
"show",
"(",
"$",
"id",
",",
"Content",
"$",
"content",
")",
"{",
"return",
"$",
"content",
"->",
"header",
"(",
"trans",
"(",
"'admin.permissions'",
")",
")",
"->",
"description",
"(",
"trans",
"(",
"'admin.detail'",
")",
")",
"->"... | Show interface.
@param mixed $id
@param Content $content
@return Content | [
"Show",
"interface",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Controllers/PermissionController.php#L39-L45 | train | Show the detail page | [
30522,
2270,
3853,
2265,
1006,
1002,
8909,
1010,
4180,
1002,
4180,
1007,
1063,
2709,
1002,
4180,
1011,
1028,
20346,
1006,
9099,
1006,
1005,
4748,
10020,
1012,
6656,
2015,
1005,
1007,
1007,
1011,
1028,
6412,
1006,
9099,
1006,
1005,
4748,
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/Security/Core/Exception/CustomUserMessageAuthenticationException.php | CustomUserMessageAuthenticationException.__unserialize | public function __unserialize(array $data): void
{
[$parentData, $this->messageKey, $this->messageData] = $data;
parent::__unserialize($parentData);
} | php | public function __unserialize(array $data): void
{
[$parentData, $this->messageKey, $this->messageData] = $data;
parent::__unserialize($parentData);
} | [
"public",
"function",
"__unserialize",
"(",
"array",
"$",
"data",
")",
":",
"void",
"{",
"[",
"$",
"parentData",
",",
"$",
"this",
"->",
"messageKey",
",",
"$",
"this",
"->",
"messageData",
"]",
"=",
"$",
"data",
";",
"parent",
"::",
"__unserialize",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php#L69-L73 | train | Unserialize the data from the parent class | [
30522,
2270,
3853,
1035,
1035,
4895,
8043,
4818,
4697,
1006,
9140,
1002,
2951,
1007,
1024,
11675,
1063,
1031,
1002,
6687,
2850,
2696,
1010,
1002,
2023,
1011,
1028,
4471,
14839,
1010,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CacheWarmer/ValidatorCacheWarmer.php | ValidatorCacheWarmer.doWarmUp | protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
{
if (!method_exists($this->validatorBuilder, 'getLoaders')) {
return false;
}
$loaders = $this->validatorBuilder->getLoaders();
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayAdapter));
foreach ($this->extractSupportedLoaders($loaders) as $loader) {
foreach ($loader->getMappedClasses() as $mappedClass) {
try {
if ($metadataFactory->hasMetadataFor($mappedClass)) {
$metadataFactory->getMetadataFor($mappedClass);
}
} catch (\ReflectionException $e) {
// ignore failing reflection
} catch (AnnotationException $e) {
// ignore failing annotations
}
}
}
return true;
} | php | protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
{
if (!method_exists($this->validatorBuilder, 'getLoaders')) {
return false;
}
$loaders = $this->validatorBuilder->getLoaders();
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), new Psr6Cache($arrayAdapter));
foreach ($this->extractSupportedLoaders($loaders) as $loader) {
foreach ($loader->getMappedClasses() as $mappedClass) {
try {
if ($metadataFactory->hasMetadataFor($mappedClass)) {
$metadataFactory->getMetadataFor($mappedClass);
}
} catch (\ReflectionException $e) {
// ignore failing reflection
} catch (AnnotationException $e) {
// ignore failing annotations
}
}
}
return true;
} | [
"protected",
"function",
"doWarmUp",
"(",
"$",
"cacheDir",
",",
"ArrayAdapter",
"$",
"arrayAdapter",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"validatorBuilder",
",",
"'getLoaders'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php#L50-L74 | train | Warm up the validator | [
30522,
5123,
3853,
23268,
27292,
6279,
1006,
1002,
17053,
4305,
2099,
1010,
9140,
8447,
13876,
2121,
1002,
9140,
8447,
13876,
2121,
1007,
1063,
2065,
1006,
999,
4118,
1035,
6526,
1006,
1002,
2023,
1011,
1028,
9398,
8844,
8569,
23891,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/Handler/CurlMultiHandler.php | CurlMultiHandler.execute | public function execute()
{
$queue = P\queue();
while ($this->handles || !$queue->isEmpty()) {
// If there are no transfers, then sleep for the next delay
if (!$this->active && $this->delays) {
usleep($this->timeToNext());
}
$this->tick();
}
} | php | public function execute()
{
$queue = P\queue();
while ($this->handles || !$queue->isEmpty()) {
// If there are no transfers, then sleep for the next delay
if (!$this->active && $this->delays) {
usleep($this->timeToNext());
}
$this->tick();
}
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"queue",
"=",
"P",
"\\",
"queue",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"handles",
"||",
"!",
"$",
"queue",
"->",
"isEmpty",
"(",
")",
")",
"{",
"// If there are no transfers, then sleep for ... | Runs until all outstanding connections have completed. | [
"Runs",
"until",
"all",
"outstanding",
"connections",
"have",
"completed",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Handler/CurlMultiHandler.php#L122-L133 | train | Execute the delay loop | [
30522,
2270,
3853,
15389,
1006,
1007,
1063,
1002,
24240,
1027,
1052,
1032,
24240,
1006,
1007,
1025,
2096,
1006,
1002,
2023,
1011,
1028,
16024,
1064,
1064,
999,
1002,
24240,
1011,
1028,
2003,
6633,
13876,
2100,
1006,
1007,
1007,
1063,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php | Broadcaster.resolveBinding | protected function resolveBinding($key, $value, $callbackParameters)
{
$newValue = $this->resolveExplicitBindingIfPossible($key, $value);
return $newValue === $value ? $this->resolveImplicitBindingIfPossible(
$key, $value, $callbackParameters
) : $newValue;
} | php | protected function resolveBinding($key, $value, $callbackParameters)
{
$newValue = $this->resolveExplicitBindingIfPossible($key, $value);
return $newValue === $value ? $this->resolveImplicitBindingIfPossible(
$key, $value, $callbackParameters
) : $newValue;
} | [
"protected",
"function",
"resolveBinding",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"callbackParameters",
")",
"{",
"$",
"newValue",
"=",
"$",
"this",
"->",
"resolveExplicitBindingIfPossible",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"return",
"$... | Resolve the given parameter binding.
@param string $key
@param string $value
@param array $callbackParameters
@return mixed | [
"Resolve",
"the",
"given",
"parameter",
"binding",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php#L163-L170 | train | Resolves a binding value if possible. | [
30522,
5123,
3853,
10663,
8428,
4667,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
1002,
2655,
5963,
28689,
22828,
2015,
1007,
1063,
1002,
2047,
10175,
5657,
1027,
1002,
2023,
1011,
1028,
10663,
10288,
24759,
28775,
2102,
8428,
4667,
10128,
68... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DBStats/MySQLMetadataProvider.php | MySQLMetadataProvider.getRowCountsByArchiveName | private function getRowCountsByArchiveName($statuses, $getRowSizeMethod, $forceCache = false,
$otherSelects = array(), $otherDataTableColumns = array())
{
$extraCols = '';
if (!empty($otherSelects)) {
$extraCols = ', ' . implode(', ', $otherSelects);
}
$cols = array_merge(array('row_count'), $otherDataTableColumns);
$dataTable = new DataTable();
foreach ($statuses as $status) {
$dataTableOptionName = $this->getCachedOptionName($status['Name'], 'byArchiveName');
// if option exists && !$forceCache, use the cached data, otherwise create the
$cachedData = Option::get($dataTableOptionName);
if ($cachedData !== false && !$forceCache) {
$table = DataTable::fromSerializedArray($cachedData);
} else {
$table = new DataTable();
$table->addRowsFromSimpleArray($this->dataAccess->getRowCountsByArchiveName($status['Name'], $extraCols));
$reduceArchiveRowName = array($this, 'reduceArchiveRowName');
$table->filter('GroupBy', array('label', $reduceArchiveRowName));
$serializedTables = $table->getSerialized();
$serializedTable = reset($serializedTables);
Option::set($dataTableOptionName, $serializedTable);
}
// add estimated_size column
$getEstimatedSize = array($this, $getRowSizeMethod);
$table->filter('ColumnCallbackAddColumn',
array($cols, 'estimated_size', $getEstimatedSize, array($status)));
$dataTable->addDataTable($table);
}
return $dataTable;
} | php | private function getRowCountsByArchiveName($statuses, $getRowSizeMethod, $forceCache = false,
$otherSelects = array(), $otherDataTableColumns = array())
{
$extraCols = '';
if (!empty($otherSelects)) {
$extraCols = ', ' . implode(', ', $otherSelects);
}
$cols = array_merge(array('row_count'), $otherDataTableColumns);
$dataTable = new DataTable();
foreach ($statuses as $status) {
$dataTableOptionName = $this->getCachedOptionName($status['Name'], 'byArchiveName');
// if option exists && !$forceCache, use the cached data, otherwise create the
$cachedData = Option::get($dataTableOptionName);
if ($cachedData !== false && !$forceCache) {
$table = DataTable::fromSerializedArray($cachedData);
} else {
$table = new DataTable();
$table->addRowsFromSimpleArray($this->dataAccess->getRowCountsByArchiveName($status['Name'], $extraCols));
$reduceArchiveRowName = array($this, 'reduceArchiveRowName');
$table->filter('GroupBy', array('label', $reduceArchiveRowName));
$serializedTables = $table->getSerialized();
$serializedTable = reset($serializedTables);
Option::set($dataTableOptionName, $serializedTable);
}
// add estimated_size column
$getEstimatedSize = array($this, $getRowSizeMethod);
$table->filter('ColumnCallbackAddColumn',
array($cols, 'estimated_size', $getEstimatedSize, array($status)));
$dataTable->addDataTable($table);
}
return $dataTable;
} | [
"private",
"function",
"getRowCountsByArchiveName",
"(",
"$",
"statuses",
",",
"$",
"getRowSizeMethod",
",",
"$",
"forceCache",
"=",
"false",
",",
"$",
"otherSelects",
"=",
"array",
"(",
")",
",",
"$",
"otherDataTableColumns",
"=",
"array",
"(",
")",
")",
"{... | Utility function. Gets row count of a set of tables grouped by the 'name' column.
This is the implementation of the getRowCountsAndSizeBy... functions. | [
"Utility",
"function",
".",
"Gets",
"row",
"count",
"of",
"a",
"set",
"of",
"tables",
"grouped",
"by",
"the",
"name",
"column",
".",
"This",
"is",
"the",
"implementation",
"of",
"the",
"getRowCountsAndSizeBy",
"...",
"functions",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DBStats/MySQLMetadataProvider.php#L194-L232 | train | Returns the row counts by archive name | [
30522,
2797,
3853,
2131,
10524,
3597,
16671,
14478,
2906,
5428,
8159,
14074,
1006,
1002,
3570,
2229,
1010,
1002,
2131,
10524,
5332,
4371,
11368,
6806,
2094,
1010,
1002,
2486,
3540,
5403,
1027,
6270,
1010,
1002,
2500,
12260,
16649,
1027,
914... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter.php | Filter.conditions | public function conditions()
{
$inputs = Arr::dot(Input::all());
$inputs = array_filter($inputs, function ($input) {
return $input !== '' && !is_null($input);
});
$this->sanitizeInputs($inputs);
if (empty($inputs)) {
return [];
}
$params = [];
foreach ($inputs as $key => $value) {
Arr::set($params, $key, $value);
}
$conditions = [];
$this->removeIDFilterIfNeeded();
foreach ($this->filters() as $filter) {
if (in_array($column = $filter->getColumn(), $this->layoutOnlyFilterColumns)) {
$filter->default(Arr::get($params, $column));
} else {
$conditions[] = $filter->condition($params);
}
}
return tap(array_filter($conditions), function ($conditions) {
if (!empty($conditions)) {
$this->expand();
}
});
} | php | public function conditions()
{
$inputs = Arr::dot(Input::all());
$inputs = array_filter($inputs, function ($input) {
return $input !== '' && !is_null($input);
});
$this->sanitizeInputs($inputs);
if (empty($inputs)) {
return [];
}
$params = [];
foreach ($inputs as $key => $value) {
Arr::set($params, $key, $value);
}
$conditions = [];
$this->removeIDFilterIfNeeded();
foreach ($this->filters() as $filter) {
if (in_array($column = $filter->getColumn(), $this->layoutOnlyFilterColumns)) {
$filter->default(Arr::get($params, $column));
} else {
$conditions[] = $filter->condition($params);
}
}
return tap(array_filter($conditions), function ($conditions) {
if (!empty($conditions)) {
$this->expand();
}
});
} | [
"public",
"function",
"conditions",
"(",
")",
"{",
"$",
"inputs",
"=",
"Arr",
"::",
"dot",
"(",
"Input",
"::",
"all",
"(",
")",
")",
";",
"$",
"inputs",
"=",
"array_filter",
"(",
"$",
"inputs",
",",
"function",
"(",
"$",
"input",
")",
"{",
"return"... | Get all conditions of the filters.
@return array | [
"Get",
"all",
"conditions",
"of",
"the",
"filters",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter.php#L292-L329 | train | Returns the conditions for the layout. | [
30522,
2270,
3853,
3785,
1006,
1007,
1063,
1002,
20407,
1027,
12098,
2099,
1024,
1024,
11089,
1006,
7953,
1024,
1024,
2035,
1006,
1007,
1007,
1025,
1002,
20407,
1027,
9140,
1035,
11307,
1006,
1002,
20407,
1010,
3853,
1006,
1002,
7953,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Kernel/Traits/HasAttributes.php | HasAttributes.setAttribute | public function setAttribute($attribute, $value)
{
Arr::set($this->attributes, $attribute, $value);
return $this;
} | php | public function setAttribute($attribute, $value)
{
Arr::set($this->attributes, $attribute, $value);
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"Arr",
"::",
"set",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"attribute",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set attribute.
@param string $attribute
@param string $value
@return $this | [
"Set",
"attribute",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/Traits/HasAttributes.php#L55-L60 | train | Set attribute value | [
30522,
2270,
3853,
2275,
19321,
3089,
8569,
2618,
1006,
1002,
17961,
1010,
1002,
3643,
1007,
1063,
12098,
2099,
1024,
1024,
2275,
1006,
1002,
2023,
1011,
1028,
12332,
1010,
1002,
17961,
1010,
1002,
3643,
1007,
1025,
2709,
1002,
2023,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/GeoIPAutoUpdater.php | GeoIPAutoUpdater.getOldAndNewPathsForBrokenDb | private function getOldAndNewPathsForBrokenDb($possibleDbNames)
{
$pathToDb = GeoIp::getPathToGeoIpDatabase($possibleDbNames);
$newPath = false;
if ($pathToDb !== false) {
$newPath = $pathToDb . ".broken";
}
return array($pathToDb, $newPath);
} | php | private function getOldAndNewPathsForBrokenDb($possibleDbNames)
{
$pathToDb = GeoIp::getPathToGeoIpDatabase($possibleDbNames);
$newPath = false;
if ($pathToDb !== false) {
$newPath = $pathToDb . ".broken";
}
return array($pathToDb, $newPath);
} | [
"private",
"function",
"getOldAndNewPathsForBrokenDb",
"(",
"$",
"possibleDbNames",
")",
"{",
"$",
"pathToDb",
"=",
"GeoIp",
"::",
"getPathToGeoIpDatabase",
"(",
"$",
"possibleDbNames",
")",
";",
"$",
"newPath",
"=",
"false",
";",
"if",
"(",
"$",
"pathToDb",
"... | Returns the path to a GeoIP database and a path to rename it to if it's broken.
@param array $possibleDbNames The possible names of the database.
@return array Array with two elements, the path to the existing database, and
the path to rename it to if it is broken. The second will end
with something like .broken . | [
"Returns",
"the",
"path",
"to",
"a",
"GeoIP",
"database",
"and",
"a",
"path",
"to",
"rename",
"it",
"to",
"if",
"it",
"s",
"broken",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/GeoIPAutoUpdater.php#L616-L626 | train | Get old and new paths for broken database | [
30522,
2797,
3853,
2131,
11614,
5685,
2638,
2860,
15069,
22747,
2953,
29162,
18939,
1006,
1002,
2825,
18939,
18442,
2015,
1007,
1063,
1002,
4130,
3406,
18939,
1027,
20248,
11514,
1024,
1024,
2131,
15069,
3406,
3351,
10448,
17299,
6790,
15058,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/CodeParser.php | CodeParser.rebuild | protected function rebuild($path)
{
$uniqueName = str_replace('.', '', uniqid('', true)).'_'.md5(mt_rand());
$className = 'Cms'.$uniqueName.'Class';
$body = $this->object->code;
$body = preg_replace('/^\s*function/m', 'public function', $body);
$codeNamespaces = [];
$pattern = '/(use\s+[a-z0-9_\\\\]+(\s+as\s+[a-z0-9_]+)?;\n?)/mi';
preg_match_all($pattern, $body, $namespaces);
$body = preg_replace($pattern, '', $body);
$parentClass = $this->object->getCodeClassParent();
if ($parentClass !== null) {
$parentClass = ' extends '.$parentClass;
}
$fileContents = '<?php '.PHP_EOL;
foreach ($namespaces[0] as $namespace) {
$fileContents .= $namespace;
}
$fileContents .= 'class '.$className.$parentClass.PHP_EOL;
$fileContents .= '{'.PHP_EOL;
$fileContents .= $body.PHP_EOL;
$fileContents .= '}'.PHP_EOL;
$this->validate($fileContents);
$this->makeDirectorySafe(dirname($path));
$this->writeContentSafe($path, $fileContents);
return $className;
} | php | protected function rebuild($path)
{
$uniqueName = str_replace('.', '', uniqid('', true)).'_'.md5(mt_rand());
$className = 'Cms'.$uniqueName.'Class';
$body = $this->object->code;
$body = preg_replace('/^\s*function/m', 'public function', $body);
$codeNamespaces = [];
$pattern = '/(use\s+[a-z0-9_\\\\]+(\s+as\s+[a-z0-9_]+)?;\n?)/mi';
preg_match_all($pattern, $body, $namespaces);
$body = preg_replace($pattern, '', $body);
$parentClass = $this->object->getCodeClassParent();
if ($parentClass !== null) {
$parentClass = ' extends '.$parentClass;
}
$fileContents = '<?php '.PHP_EOL;
foreach ($namespaces[0] as $namespace) {
$fileContents .= $namespace;
}
$fileContents .= 'class '.$className.$parentClass.PHP_EOL;
$fileContents .= '{'.PHP_EOL;
$fileContents .= $body.PHP_EOL;
$fileContents .= '}'.PHP_EOL;
$this->validate($fileContents);
$this->makeDirectorySafe(dirname($path));
$this->writeContentSafe($path, $fileContents);
return $className;
} | [
"protected",
"function",
"rebuild",
"(",
"$",
"path",
")",
"{",
"$",
"uniqueName",
"=",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"uniqid",
"(",
"''",
",",
"true",
")",
")",
".",
"'_'",
".",
"md5",
"(",
"mt_rand",
"(",
")",
")",
";",
"$",
"class... | Rebuilds the current file cache.
@param string The path in which the cached file should be stored | [
"Rebuilds",
"the",
"current",
"file",
"cache",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/CodeParser.php#L123-L159 | train | Rebuilds the code for the class | [
30522,
5123,
3853,
14591,
1006,
1002,
4130,
1007,
1063,
1002,
4310,
18442,
1027,
2358,
2099,
1035,
5672,
1006,
1005,
1012,
1005,
1010,
1005,
1005,
1010,
4895,
18515,
3593,
1006,
1005,
1005,
1010,
2995,
1007,
1007,
1012,
1005,
1035,
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 | plugins/ScheduledReports/API.php | API.deleteReport | public function deleteReport($idReport)
{
$APIScheduledReports = $this->getReports($idSite = false, $periodSearch = false, $idReport);
$report = reset($APIScheduledReports);
Piwik::checkUserHasSuperUserAccessOrIsTheUser($report['login']);
$this->getModel()->updateReport($idReport, array(
'deleted' => 1,
));
self::$cache = array();
} | php | public function deleteReport($idReport)
{
$APIScheduledReports = $this->getReports($idSite = false, $periodSearch = false, $idReport);
$report = reset($APIScheduledReports);
Piwik::checkUserHasSuperUserAccessOrIsTheUser($report['login']);
$this->getModel()->updateReport($idReport, array(
'deleted' => 1,
));
self::$cache = array();
} | [
"public",
"function",
"deleteReport",
"(",
"$",
"idReport",
")",
"{",
"$",
"APIScheduledReports",
"=",
"$",
"this",
"->",
"getReports",
"(",
"$",
"idSite",
"=",
"false",
",",
"$",
"periodSearch",
"=",
"false",
",",
"$",
"idReport",
")",
";",
"$",
"report... | Deletes a specific report
@param int $idReport | [
"Deletes",
"a",
"specific",
"report"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ScheduledReports/API.php#L196-L207 | train | Delete a report | [
30522,
2270,
3853,
3972,
15141,
13699,
11589,
1006,
1002,
8909,
2890,
6442,
1007,
1063,
1002,
17928,
22842,
8566,
3709,
2890,
25378,
1027,
1002,
2023,
1011,
1028,
2131,
2890,
25378,
1006,
1002,
8909,
28032,
2063,
1027,
6270,
1010,
1002,
699... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ShakeAround/DeviceClient.php | DeviceClient.update | public function update(array $deviceIdentifier, string $comment)
{
$params = [
'device_identifier' => $deviceIdentifier,
'comment' => $comment,
];
return $this->httpPostJson('shakearound/device/update', $params);
} | php | public function update(array $deviceIdentifier, string $comment)
{
$params = [
'device_identifier' => $deviceIdentifier,
'comment' => $comment,
];
return $this->httpPostJson('shakearound/device/update', $params);
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"deviceIdentifier",
",",
"string",
"$",
"comment",
")",
"{",
"$",
"params",
"=",
"[",
"'device_identifier'",
"=>",
"$",
"deviceIdentifier",
",",
"'comment'",
"=>",
"$",
"comment",
",",
"]",
";",
"return",
... | Update a device comment.
@param array $deviceIdentifier
@param string $comment
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string | [
"Update",
"a",
"device",
"comment",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/ShakeAround/DeviceClient.php#L58-L66 | train | Update the device | [
30522,
2270,
3853,
10651,
1006,
9140,
1002,
5080,
5178,
16778,
8873,
2121,
1010,
5164,
1002,
7615,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
5080,
1035,
8909,
4765,
18095,
1005,
1027,
1028,
1002,
5080,
5178,
16778,
8873,
2121,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/DatabaseStore.php | DatabaseStore.decrement | public function decrement($key, $value = 1)
{
return $this->incrementOrDecrement($key, $value, function ($current, $value) {
return $current - $value;
});
} | php | public function decrement($key, $value = 1)
{
return $this->incrementOrDecrement($key, $value, function ($current, $value) {
return $current - $value;
});
} | [
"public",
"function",
"decrement",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"incrementOrDecrement",
"(",
"$",
"key",
",",
"$",
"value",
",",
"function",
"(",
"$",
"current",
",",
"$",
"value",
")",
"{",
"... | Decrement the value of an item in the cache.
@param string $key
@param mixed $value
@return int|bool | [
"Decrement",
"the",
"value",
"of",
"an",
"item",
"in",
"the",
"cache",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/DatabaseStore.php#L132-L137 | train | Decrement value of a key | [
30522,
2270,
3853,
11703,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
3643,
1027,
1015,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4297,
28578,
4765,
8551,
8586,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
3853,
1006,
1002,
2783,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/Loader.php | Loader.findFallbackObject | protected function findFallbackObject($name)
{
if (strpos($name, '::') !== false) {
return false;
}
if (array_key_exists($name, $this->fallbackCache)) {
return $this->fallbackCache[$name];
}
return $this->fallbackCache[$name] = CmsPartial::find($name);
} | php | protected function findFallbackObject($name)
{
if (strpos($name, '::') !== false) {
return false;
}
if (array_key_exists($name, $this->fallbackCache)) {
return $this->fallbackCache[$name];
}
return $this->fallbackCache[$name] = CmsPartial::find($name);
} | [
"protected",
"function",
"findFallbackObject",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'::'",
")",
"!==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"thi... | Looks up a fallback CMS partial object.
@return Cms\Classes\Partial | [
"Looks",
"up",
"a",
"fallback",
"CMS",
"partial",
"object",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/Loader.php#L138-L149 | train | Find the fallback object by name | [
30522,
5123,
3853,
2424,
13976,
5963,
16429,
20614,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
2358,
14536,
2891,
1006,
1002,
2171,
1010,
1005,
1024,
1024,
1005,
1007,
999,
1027,
1027,
6270,
1007,
1063,
2709,
6270,
1025,
1065,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/FormatsMessages.php | FormatsMessages.replaceAttributePlaceholder | protected function replaceAttributePlaceholder($message, $value)
{
return str_replace(
[':attribute', ':ATTRIBUTE', ':Attribute'],
[$value, Str::upper($value), Str::ucfirst($value)],
$message
);
} | php | protected function replaceAttributePlaceholder($message, $value)
{
return str_replace(
[':attribute', ':ATTRIBUTE', ':Attribute'],
[$value, Str::upper($value), Str::ucfirst($value)],
$message
);
} | [
"protected",
"function",
"replaceAttributePlaceholder",
"(",
"$",
"message",
",",
"$",
"value",
")",
"{",
"return",
"str_replace",
"(",
"[",
"':attribute'",
",",
"':ATTRIBUTE'",
",",
"':Attribute'",
"]",
",",
"[",
"$",
"value",
",",
"Str",
"::",
"upper",
"("... | Replace the :attribute placeholder in the given message.
@param string $message
@param string $value
@return string | [
"Replace",
"the",
":",
"attribute",
"placeholder",
"in",
"the",
"given",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/FormatsMessages.php#L277-L284 | train | Replace attribute placeholder with value | [
30522,
5123,
3853,
5672,
19321,
3089,
8569,
2618,
24759,
10732,
14528,
1006,
1002,
4471,
1010,
1002,
3643,
1007,
1063,
2709,
2358,
2099,
1035,
5672,
1006,
1031,
1005,
1024,
17961,
1005,
1010,
1005,
1024,
17961,
1005,
1010,
1005,
1024,
17961... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db/Adapter/Pdo/Mysql.php | Mysql.query | public function query($sql, $bind = array())
{
if (!is_string($sql)) {
return parent::query($sql, $bind);
}
if (isset($this->cachePreparedStatement[$sql])) {
if (!is_array($bind)) {
$bind = array($bind);
}
$stmt = $this->cachePreparedStatement[$sql];
$stmt->execute($bind);
return $stmt;
}
$stmt = parent::query($sql, $bind);
$this->cachePreparedStatement[$sql] = $stmt;
return $stmt;
} | php | public function query($sql, $bind = array())
{
if (!is_string($sql)) {
return parent::query($sql, $bind);
}
if (isset($this->cachePreparedStatement[$sql])) {
if (!is_array($bind)) {
$bind = array($bind);
}
$stmt = $this->cachePreparedStatement[$sql];
$stmt->execute($bind);
return $stmt;
}
$stmt = parent::query($sql, $bind);
$this->cachePreparedStatement[$sql] = $stmt;
return $stmt;
} | [
"public",
"function",
"query",
"(",
"$",
"sql",
",",
"$",
"bind",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"sql",
")",
")",
"{",
"return",
"parent",
"::",
"query",
"(",
"$",
"sql",
",",
"$",
"bind",
")",
";",
"... | Prepares and executes an SQL statement with bound data.
Caches prepared statements to avoid preparing the same query more than once
@param string|Zend_Db_Select $sql The SQL statement with placeholders.
@param array $bind An array of data to bind to the placeholders.
@return Zend_Db_Statement_Interface | [
"Prepares",
"and",
"executes",
"an",
"SQL",
"statement",
"with",
"bound",
"data",
".",
"Caches",
"prepared",
"statements",
"to",
"avoid",
"preparing",
"the",
"same",
"query",
"more",
"than",
"once"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Adapter/Pdo/Mysql.php#L280-L299 | train | Queries the database and returns the resultset | [
30522,
2270,
3853,
23032,
1006,
1002,
29296,
1010,
1002,
14187,
1027,
9140,
1006,
1007,
1007,
1063,
2065,
1006,
999,
2003,
1035,
5164,
1006,
1002,
29296,
1007,
1007,
1063,
2709,
6687,
1024,
1024,
23032,
1006,
1002,
29296,
1010,
1002,
14187,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/PhpEngine.php | PhpEngine.evaluate | protected function evaluate(Storage $template, array $parameters = [])
{
$this->evalTemplate = $template;
$this->evalParameters = $parameters;
unset($template, $parameters);
if (isset($this->evalParameters['this'])) {
throw new \InvalidArgumentException('Invalid parameter (this)');
}
if (isset($this->evalParameters['view'])) {
throw new \InvalidArgumentException('Invalid parameter (view)');
}
// the view variable is exposed to the require file below
$view = $this;
if ($this->evalTemplate instanceof FileStorage) {
extract($this->evalParameters, EXTR_SKIP);
$this->evalParameters = null;
ob_start();
require $this->evalTemplate;
$this->evalTemplate = null;
return ob_get_clean();
} elseif ($this->evalTemplate instanceof StringStorage) {
extract($this->evalParameters, EXTR_SKIP);
$this->evalParameters = null;
ob_start();
eval('; ?>'.$this->evalTemplate.'<?php ;');
$this->evalTemplate = null;
return ob_get_clean();
}
return false;
} | php | protected function evaluate(Storage $template, array $parameters = [])
{
$this->evalTemplate = $template;
$this->evalParameters = $parameters;
unset($template, $parameters);
if (isset($this->evalParameters['this'])) {
throw new \InvalidArgumentException('Invalid parameter (this)');
}
if (isset($this->evalParameters['view'])) {
throw new \InvalidArgumentException('Invalid parameter (view)');
}
// the view variable is exposed to the require file below
$view = $this;
if ($this->evalTemplate instanceof FileStorage) {
extract($this->evalParameters, EXTR_SKIP);
$this->evalParameters = null;
ob_start();
require $this->evalTemplate;
$this->evalTemplate = null;
return ob_get_clean();
} elseif ($this->evalTemplate instanceof StringStorage) {
extract($this->evalParameters, EXTR_SKIP);
$this->evalParameters = null;
ob_start();
eval('; ?>'.$this->evalTemplate.'<?php ;');
$this->evalTemplate = null;
return ob_get_clean();
}
return false;
} | [
"protected",
"function",
"evaluate",
"(",
"Storage",
"$",
"template",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"evalTemplate",
"=",
"$",
"template",
";",
"$",
"this",
"->",
"evalParameters",
"=",
"$",
"parameters",
";"... | Evaluates a template.
@param Storage $template The template to render
@param array $parameters An array of parameters to pass to the template
@return string|false The evaluated template, or false if the engine is unable to render the template
@throws \InvalidArgumentException | [
"Evaluates",
"a",
"template",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Templating/PhpEngine.php#L130-L168 | train | Evaluate the template and parameters | [
30522,
5123,
3853,
16157,
1006,
5527,
1002,
23561,
1010,
9140,
1002,
11709,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
9345,
7096,
6633,
15725,
1027,
1002,
23561,
1025,
1002,
2023,
1011,
1028,
9345,
14277,
5400,
22828,
2015,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php | ProfilerListener.onKernelResponse | public function onKernelResponse(FilterResponseEvent $event)
{
$master = $event->isMasterRequest();
if ($this->onlyMasterRequests && !$master) {
return;
}
if ($this->onlyException && null === $this->exception) {
return;
}
$request = $event->getRequest();
$exception = $this->exception;
$this->exception = null;
if (null !== $this->matcher && !$this->matcher->matches($request)) {
return;
}
if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) {
return;
}
$this->profiles[$request] = $profile;
$this->parents[$request] = $this->requestStack->getParentRequest();
} | php | public function onKernelResponse(FilterResponseEvent $event)
{
$master = $event->isMasterRequest();
if ($this->onlyMasterRequests && !$master) {
return;
}
if ($this->onlyException && null === $this->exception) {
return;
}
$request = $event->getRequest();
$exception = $this->exception;
$this->exception = null;
if (null !== $this->matcher && !$this->matcher->matches($request)) {
return;
}
if (!$profile = $this->profiler->collect($request, $event->getResponse(), $exception)) {
return;
}
$this->profiles[$request] = $profile;
$this->parents[$request] = $this->requestStack->getParentRequest();
} | [
"public",
"function",
"onKernelResponse",
"(",
"FilterResponseEvent",
"$",
"event",
")",
"{",
"$",
"master",
"=",
"$",
"event",
"->",
"isMasterRequest",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"onlyMasterRequests",
"&&",
"!",
"$",
"master",
")",
"{",
... | Handles the onKernelResponse event. | [
"Handles",
"the",
"onKernelResponse",
"event",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php#L74-L100 | train | Called when kernel response event is dispatched. | [
30522,
2270,
3853,
2006,
5484,
11877,
6072,
26029,
3366,
1006,
11307,
6072,
26029,
19763,
15338,
1002,
2724,
1007,
1063,
1002,
3040,
1027,
1002,
2724,
1011,
1028,
2003,
8706,
2890,
15500,
1006,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/ExampleTracker/Columns/ExampleConversionDimension.php | ExampleConversionDimension.onGoalConversion | public function onGoalConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
$goalId = $goalManager->getGoalColumn('idgoal');
if ($visitor->isVisitorKnown()) {
return $goalId;
}
return false;
} | php | public function onGoalConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
$goalId = $goalManager->getGoalColumn('idgoal');
if ($visitor->isVisitorKnown()) {
return $goalId;
}
return false;
} | [
"public",
"function",
"onGoalConversion",
"(",
"Request",
"$",
"request",
",",
"Visitor",
"$",
"visitor",
",",
"$",
"action",
",",
"GoalManager",
"$",
"goalManager",
")",
"{",
"$",
"goalId",
"=",
"$",
"goalManager",
"->",
"getGoalColumn",
"(",
"'idgoal'",
")... | This event is triggered when an any custom goal is converted. In this example we would store a the id of the
goal in the 'example_conversion_dimension' column if the visitor is known and nothing otherwise.
Return boolean false if you do not want to change the value in some cases. If you do not want to perform any
action on an ecommerce order at all it is recommended to just remove this method.
@param Request $request
@param Visitor $visitor
@param Action|null $action
@param GoalManager $goalManager
@return mixed|false | [
"This",
"event",
"is",
"triggered",
"when",
"an",
"any",
"custom",
"goal",
"is",
"converted",
".",
"In",
"this",
"example",
"we",
"would",
"store",
"a",
"the",
"id",
"of",
"the",
"goal",
"in",
"the",
"example_conversion_dimension",
"column",
"if",
"the",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleTracker/Columns/ExampleConversionDimension.php#L121-L130 | train | This method is called when a goal is converted. | [
30522,
2270,
3853,
2006,
3995,
2389,
8663,
27774,
1006,
5227,
1002,
5227,
1010,
10367,
1002,
10367,
1010,
1002,
2895,
1010,
3125,
24805,
4590,
1002,
3125,
24805,
4590,
1007,
1063,
1002,
3125,
3593,
1027,
1002,
3125,
24805,
4590,
1011,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php | Transformer.padLeft | protected function padLeft(string $value, int $length): string
{
return str_pad($value, $length, '0', STR_PAD_LEFT);
} | php | protected function padLeft(string $value, int $length): string
{
return str_pad($value, $length, '0', STR_PAD_LEFT);
} | [
"protected",
"function",
"padLeft",
"(",
"string",
"$",
"value",
",",
"int",
"$",
"length",
")",
":",
"string",
"{",
"return",
"str_pad",
"(",
"$",
"value",
",",
"$",
"length",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"}"
] | Pad a string with zeros to the left.
@param string $value The string to be padded
@param int $length The length to pad
@return string The padded string | [
"Pad",
"a",
"string",
"with",
"zeros",
"to",
"the",
"left",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php#L62-L65 | train | Pad left with zeroes | [
30522,
5123,
3853,
11687,
2571,
6199,
1006,
5164,
1002,
3643,
1010,
20014,
1002,
3091,
1007,
1024,
5164,
1063,
2709,
2358,
2099,
1035,
11687,
1006,
1002,
3643,
1010,
1002,
3091,
1010,
1005,
1014,
1005,
1010,
2358,
2099,
1035,
11687,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Transitions/API.php | API.getTransitionsForAction | public function getTransitionsForAction($actionName, $actionType, $idSite, $period, $date,
$segment = false, $limitBeforeGrouping = false, $parts = 'all')
{
Piwik::checkUserHasViewAccess($idSite);
// get idaction of the requested action
$idaction = $this->deriveIdAction($actionName, $actionType);
if ($idaction < 0) {
throw new Exception('NoDataForAction');
}
// prepare log aggregator
$segment = new Segment($segment, $idSite);
$site = new Site($idSite);
$period = Period\Factory::build($period, $date);
$params = new ArchiveProcessor\Parameters($site, $period, $segment);
$logAggregator = new LogAggregator($params);
// prepare the report
$report = array(
'date' => Period\Factory::build($period->getLabel(), $date)->getLocalizedShortString()
);
$partsArray = explode(',', $parts);
if ($parts == 'all' || in_array('internalReferrers', $partsArray)) {
$this->addInternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
}
if ($parts == 'all' || in_array('followingActions', $partsArray)) {
$includeLoops = $parts != 'all' && !in_array('internalReferrers', $partsArray);
$this->addFollowingActions($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping, $includeLoops);
}
if ($parts == 'all' || in_array('externalReferrers', $partsArray)) {
$this->addExternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
}
// derive the number of exits from the other metrics
if ($parts == 'all') {
$report['pageMetrics']['exits'] = $report['pageMetrics']['pageviews']
- $this->getTotalTransitionsToFollowingActions()
- $report['pageMetrics']['loops'];
}
// replace column names in the data tables
$reportNames = array(
'previousPages' => true,
'previousSiteSearches' => false,
'followingPages' => true,
'followingSiteSearches' => false,
'outlinks' => true,
'downloads' => true
);
foreach ($reportNames as $reportName => $replaceLabel) {
if (isset($report[$reportName])) {
$columnNames = array(Metrics::INDEX_NB_ACTIONS => 'referrals');
if ($replaceLabel) {
$columnNames[Metrics::INDEX_NB_ACTIONS] = 'referrals';
}
$report[$reportName]->filter('ReplaceColumnNames', array($columnNames));
}
}
return $report;
} | php | public function getTransitionsForAction($actionName, $actionType, $idSite, $period, $date,
$segment = false, $limitBeforeGrouping = false, $parts = 'all')
{
Piwik::checkUserHasViewAccess($idSite);
// get idaction of the requested action
$idaction = $this->deriveIdAction($actionName, $actionType);
if ($idaction < 0) {
throw new Exception('NoDataForAction');
}
// prepare log aggregator
$segment = new Segment($segment, $idSite);
$site = new Site($idSite);
$period = Period\Factory::build($period, $date);
$params = new ArchiveProcessor\Parameters($site, $period, $segment);
$logAggregator = new LogAggregator($params);
// prepare the report
$report = array(
'date' => Period\Factory::build($period->getLabel(), $date)->getLocalizedShortString()
);
$partsArray = explode(',', $parts);
if ($parts == 'all' || in_array('internalReferrers', $partsArray)) {
$this->addInternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
}
if ($parts == 'all' || in_array('followingActions', $partsArray)) {
$includeLoops = $parts != 'all' && !in_array('internalReferrers', $partsArray);
$this->addFollowingActions($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping, $includeLoops);
}
if ($parts == 'all' || in_array('externalReferrers', $partsArray)) {
$this->addExternalReferrers($logAggregator, $report, $idaction, $actionType, $limitBeforeGrouping);
}
// derive the number of exits from the other metrics
if ($parts == 'all') {
$report['pageMetrics']['exits'] = $report['pageMetrics']['pageviews']
- $this->getTotalTransitionsToFollowingActions()
- $report['pageMetrics']['loops'];
}
// replace column names in the data tables
$reportNames = array(
'previousPages' => true,
'previousSiteSearches' => false,
'followingPages' => true,
'followingSiteSearches' => false,
'outlinks' => true,
'downloads' => true
);
foreach ($reportNames as $reportName => $replaceLabel) {
if (isset($report[$reportName])) {
$columnNames = array(Metrics::INDEX_NB_ACTIONS => 'referrals');
if ($replaceLabel) {
$columnNames[Metrics::INDEX_NB_ACTIONS] = 'referrals';
}
$report[$reportName]->filter('ReplaceColumnNames', array($columnNames));
}
}
return $report;
} | [
"public",
"function",
"getTransitionsForAction",
"(",
"$",
"actionName",
",",
"$",
"actionType",
",",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"limitBeforeGrouping",
"=",
"false",
",",
"$",
"parts",
... | General method to get transitions for an action
@param $actionName
@param $actionType "url"|"title"
@param $idSite
@param $period
@param $date
@param bool $segment
@param bool $limitBeforeGrouping
@param string $parts
@return array
@throws Exception | [
"General",
"method",
"to",
"get",
"transitions",
"for",
"an",
"action"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Transitions/API.php#L61-L123 | train | Get all the transitions for the requested action | [
30522,
2270,
3853,
2131,
6494,
3619,
22753,
22747,
6525,
7542,
1006,
1002,
2895,
18442,
1010,
1002,
2895,
13874,
1010,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1010,
1002,
5787,
4783,
29278,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Mime.php | Zend_Mime.encode | public static function encode($str, $encoding, $EOL = self::LINEEND)
{
switch ($encoding) {
case self::ENCODING_BASE64:
return self::encodeBase64($str, self::LINELENGTH, $EOL);
case self::ENCODING_QUOTEDPRINTABLE:
return self::encodeQuotedPrintable($str, self::LINELENGTH, $EOL);
default:
/**
* @todo 7Bit and 8Bit is currently handled the same way.
*/
return $str;
}
} | php | public static function encode($str, $encoding, $EOL = self::LINEEND)
{
switch ($encoding) {
case self::ENCODING_BASE64:
return self::encodeBase64($str, self::LINELENGTH, $EOL);
case self::ENCODING_QUOTEDPRINTABLE:
return self::encodeQuotedPrintable($str, self::LINELENGTH, $EOL);
default:
/**
* @todo 7Bit and 8Bit is currently handled the same way.
*/
return $str;
}
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"str",
",",
"$",
"encoding",
",",
"$",
"EOL",
"=",
"self",
"::",
"LINEEND",
")",
"{",
"switch",
"(",
"$",
"encoding",
")",
"{",
"case",
"self",
"::",
"ENCODING_BASE64",
":",
"return",
"self",
"::",
... | Encode the given string with the given encoding.
@param string $str
@param string $encoding
@param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
@return string | [
"Encode",
"the",
"given",
"string",
"with",
"the",
"given",
"encoding",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime.php#L315-L330 | train | Encode string with encoding | [
30522,
2270,
10763,
3853,
4372,
16044,
1006,
1002,
2358,
2099,
1010,
1002,
17181,
1010,
1002,
1041,
4747,
1027,
2969,
1024,
1024,
2240,
10497,
1007,
1063,
6942,
1006,
1002,
17181,
1007,
1063,
2553,
2969,
1024,
1024,
17181,
1035,
2918,
21084... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Form/FormFlash.php | FormFlash.addUploadedFile | public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string
{
$tmp_dir = $this->getTmpDir();
$tmp_name = Utils::generateRandomString(12);
$name = $upload->getClientFilename();
// Prepare upload data for later save
$data = [
'name' => $name,
'type' => $upload->getClientMediaType(),
'size' => $upload->getSize(),
'tmp_name' => $tmp_name
];
Folder::create($tmp_dir);
$upload->moveTo("{$tmp_dir}/{$tmp_name}");
$this->addFileInternal($field, $name, $data, $crop);
return $name;
} | php | public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string
{
$tmp_dir = $this->getTmpDir();
$tmp_name = Utils::generateRandomString(12);
$name = $upload->getClientFilename();
// Prepare upload data for later save
$data = [
'name' => $name,
'type' => $upload->getClientMediaType(),
'size' => $upload->getSize(),
'tmp_name' => $tmp_name
];
Folder::create($tmp_dir);
$upload->moveTo("{$tmp_dir}/{$tmp_name}");
$this->addFileInternal($field, $name, $data, $crop);
return $name;
} | [
"public",
"function",
"addUploadedFile",
"(",
"UploadedFileInterface",
"$",
"upload",
",",
"string",
"$",
"field",
"=",
"null",
",",
"array",
"$",
"crop",
"=",
"null",
")",
":",
"string",
"{",
"$",
"tmp_dir",
"=",
"$",
"this",
"->",
"getTmpDir",
"(",
")"... | Add uploaded file to the form flash.
@param UploadedFileInterface $upload
@param string|null $field
@param array|null $crop
@return string Return name of the file | [
"Add",
"uploaded",
"file",
"to",
"the",
"form",
"flash",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/FormFlash.php#L235-L255 | train | Add an uploaded file to the form | [
30522,
2270,
3853,
5587,
6279,
17468,
8873,
2571,
1006,
21345,
8873,
19856,
3334,
12172,
1002,
2039,
11066,
1010,
5164,
1002,
2492,
1027,
19701,
1010,
9140,
1002,
10416,
1027,
19701,
1007,
1024,
5164,
1063,
1002,
1056,
8737,
1035,
16101,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Form.php | Form.addError | public function addError(FormError $error)
{
if (null === $error->getOrigin()) {
$error->setOrigin($this);
}
if ($this->parent && $this->config->getErrorBubbling()) {
$this->parent->addError($error);
} else {
$this->errors[] = $error;
}
return $this;
} | php | public function addError(FormError $error)
{
if (null === $error->getOrigin()) {
$error->setOrigin($this);
}
if ($this->parent && $this->config->getErrorBubbling()) {
$this->parent->addError($error);
} else {
$this->errors[] = $error;
}
return $this;
} | [
"public",
"function",
"addError",
"(",
"FormError",
"$",
"error",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"error",
"->",
"getOrigin",
"(",
")",
")",
"{",
"$",
"error",
"->",
"setOrigin",
"(",
"$",
"this",
")",
";",
"}",
"if",
"(",
"$",
"this",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Form.php#L680-L693 | train | addError - Add an error to the form | [
30522,
2270,
3853,
5587,
2121,
29165,
1006,
2280,
29165,
1002,
7561,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
7561,
1011,
1028,
2131,
10050,
11528,
1006,
1007,
1007,
1063,
1002,
7561,
1011,
1028,
2275,
10050,
11528,
1006,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/ComponentBase.php | ComponentBase.renderPartial | public function renderPartial()
{
$this->controller->setComponentContext($this);
$result = call_user_func_array([$this->controller, 'renderPartial'], func_get_args());
$this->controller->setComponentContext(null);
return $result;
} | php | public function renderPartial()
{
$this->controller->setComponentContext($this);
$result = call_user_func_array([$this->controller, 'renderPartial'], func_get_args());
$this->controller->setComponentContext(null);
return $result;
} | [
"public",
"function",
"renderPartial",
"(",
")",
"{",
"$",
"this",
"->",
"controller",
"->",
"setComponentContext",
"(",
"$",
"this",
")",
";",
"$",
"result",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"controller",
",",
"'renderPartial'",
"]"... | Renders a requested partial in context of this component,
see Cms\Classes\Controller@renderPartial for usage. | [
"Renders",
"a",
"requested",
"partial",
"in",
"context",
"of",
"this",
"component",
"see",
"Cms",
"\\",
"Classes",
"\\",
"Controller"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/ComponentBase.php#L140-L146 | train | This method is called by the controller to render the partial. | [
30522,
2270,
3853,
17552,
19362,
20925,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
11486,
1011,
1028,
2275,
9006,
29513,
3372,
8663,
18209,
1006,
1002,
2023,
1007,
1025,
1002,
2765,
1027,
2655,
1035,
5310,
1035,
4569,
2278,
1035,
9140,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/FilesystemManager.php | FilesystemManager.callCustomCreator | protected function callCustomCreator(array $config)
{
$driver = $this->customCreators[$config['driver']]($this->app, $config);
if ($driver instanceof FilesystemInterface) {
return $this->adapt($driver);
}
return $driver;
} | php | protected function callCustomCreator(array $config)
{
$driver = $this->customCreators[$config['driver']]($this->app, $config);
if ($driver instanceof FilesystemInterface) {
return $this->adapt($driver);
}
return $driver;
} | [
"protected",
"function",
"callCustomCreator",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"customCreators",
"[",
"$",
"config",
"[",
"'driver'",
"]",
"]",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"config",
")",
";",
... | Call a custom driver creator.
@param array $config
@return \Illuminate\Contracts\Filesystem\Filesystem | [
"Call",
"a",
"custom",
"driver",
"creator",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/FilesystemManager.php#L137-L146 | train | Call custom creator | [
30522,
5123,
3853,
2655,
7874,
20389,
16748,
8844,
1006,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
4062,
1027,
1002,
2023,
1011,
1028,
7661,
16748,
18926,
1031,
1002,
9530,
8873,
2290,
1031,
1005,
4062,
1005,
1033,
1033,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select.where | public function where($cond, $value = null, $type = null)
{
$this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, true);
return $this;
} | php | public function where($cond, $value = null, $type = null)
{
$this->_parts[self::WHERE][] = $this->_where($cond, $value, $type, true);
return $this;
} | [
"public",
"function",
"where",
"(",
"$",
"cond",
",",
"$",
"value",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"WHERE",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"_where",
"(",
"$",
"cond"... | Adds a WHERE condition to the query by AND.
If a value is passed as the second param, it will be quoted
and replaced into the condition wherever a question-mark
appears. Array values are quoted and comma-separated.
<code>
// simplest but non-secure
$select->where("id = $id");
// secure (ID is quoted but matched anyway)
$select->where('id = ?', $id);
// alternatively, with named binding
$select->where('id = :id');
</code>
Note that it is more correct to use named bindings in your
queries for values other than strings. When you use named
bindings, don't forget to pass the values when actually
making a query:
<code>
$db->fetchAll($select, array('id' => 5));
</code>
@param string $cond The WHERE condition.
@param mixed $value OPTIONAL The value to quote into the condition.
@param int $type OPTIONAL The type of the given value
@return Zend_Db_Select This Zend_Db_Select object. | [
"Adds",
"a",
"WHERE",
"condition",
"to",
"the",
"query",
"by",
"AND",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L473-L478 | train | Adds a WHERE clause to the current query. | [
30522,
2270,
3853,
2073,
1006,
1002,
9530,
2094,
1010,
1002,
3643,
1027,
19701,
1010,
1002,
2828,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
2969,
1024,
1024,
2073,
1033,
1031,
1033,
1027,
1002,
2023,
1011,
1028,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/PropertyAccess/PropertyPath.php | PropertyPath.getElement | public function getElement($index)
{
if (!isset($this->elements[$index])) {
throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index));
}
return $this->elements[$index];
} | php | public function getElement($index)
{
if (!isset($this->elements[$index])) {
throw new OutOfBoundsException(sprintf('The index %s is not within the property path', $index));
}
return $this->elements[$index];
} | [
"public",
"function",
"getElement",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The index %s is not within t... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/PropertyAccess/PropertyPath.php#L173-L180 | train | Returns the element at the given index | [
30522,
2270,
3853,
2131,
12260,
3672,
1006,
1002,
5950,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
3787,
1031,
1002,
5950,
1033,
1007,
1007,
1063,
5466,
2047,
2041,
11253,
15494,
3366,
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... |
matomo-org/matomo | plugins/UsersManager/Controller.php | Controller.index | public function index()
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeAdminAccess();
$view = new View('@UsersManager/index');
$IdSitesAdmin = Request::processRequest('SitesManager.getSitesIdWithAdminAccess');
$idSiteSelected = 1;
if (count($IdSitesAdmin) > 0) {
$defaultWebsiteId = $IdSitesAdmin[0];
$idSiteSelected = $this->idSite ?: $defaultWebsiteId;
}
if (!Piwik::isUserHasAdminAccess($idSiteSelected) && count($IdSitesAdmin) > 0) {
// make sure to show a website where user actually has admin access
$idSiteSelected = $IdSitesAdmin[0];
}
$defaultReportSiteName = Site::getNameFor($idSiteSelected);
$view->idSiteSelected = $idSiteSelected;
$view->defaultReportSiteName = $defaultReportSiteName;
$view->currentUserRole = Piwik::hasUserSuperUserAccess() ? 'superuser' : 'admin';
$view->accessLevels = [
['key' => 'noaccess', 'value' => Piwik::translate('UsersManager_PrivNone')],
['key' => 'view', 'value' => Piwik::translate('UsersManager_PrivView')],
['key' => 'write', 'value' => Piwik::translate('UsersManager_PrivWrite')],
['key' => 'admin', 'value' => Piwik::translate('UsersManager_PrivAdmin')],
['key' => 'superuser', 'value' => Piwik::translate('Installation_SuperUser'), 'disabled' => true],
];
$view->filterAccessLevels = [
['key' => '', 'value' => Piwik::translate('UsersManager_ShowAll')],
['key' => 'noaccess', 'value' => Piwik::translate('UsersManager_PrivNone')],
['key' => 'some', 'value' => Piwik::translate('UsersManager_AtLeastView')],
['key' => 'view', 'value' => Piwik::translate('UsersManager_PrivView')],
['key' => 'write', 'value' => Piwik::translate('UsersManager_PrivWrite')],
['key' => 'admin', 'value' => Piwik::translate('UsersManager_PrivAdmin')],
['key' => 'superuser', 'value' => Piwik::translate('Installation_SuperUser')],
];
$capabilities = Request::processRequest('UsersManager.getAvailableCapabilities', [], []);
foreach ($capabilities as $capability) {
$capabilityEntry = [
'key' => $capability['id'], 'value' => $capability['category'] . ': ' . $capability['name'],
];
$view->accessLevels[] = $capabilityEntry;
$view->filterAccessLevels[] = $capabilityEntry;
}
$this->setBasicVariablesView($view);
return $view->render();
} | php | public function index()
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeAdminAccess();
$view = new View('@UsersManager/index');
$IdSitesAdmin = Request::processRequest('SitesManager.getSitesIdWithAdminAccess');
$idSiteSelected = 1;
if (count($IdSitesAdmin) > 0) {
$defaultWebsiteId = $IdSitesAdmin[0];
$idSiteSelected = $this->idSite ?: $defaultWebsiteId;
}
if (!Piwik::isUserHasAdminAccess($idSiteSelected) && count($IdSitesAdmin) > 0) {
// make sure to show a website where user actually has admin access
$idSiteSelected = $IdSitesAdmin[0];
}
$defaultReportSiteName = Site::getNameFor($idSiteSelected);
$view->idSiteSelected = $idSiteSelected;
$view->defaultReportSiteName = $defaultReportSiteName;
$view->currentUserRole = Piwik::hasUserSuperUserAccess() ? 'superuser' : 'admin';
$view->accessLevels = [
['key' => 'noaccess', 'value' => Piwik::translate('UsersManager_PrivNone')],
['key' => 'view', 'value' => Piwik::translate('UsersManager_PrivView')],
['key' => 'write', 'value' => Piwik::translate('UsersManager_PrivWrite')],
['key' => 'admin', 'value' => Piwik::translate('UsersManager_PrivAdmin')],
['key' => 'superuser', 'value' => Piwik::translate('Installation_SuperUser'), 'disabled' => true],
];
$view->filterAccessLevels = [
['key' => '', 'value' => Piwik::translate('UsersManager_ShowAll')],
['key' => 'noaccess', 'value' => Piwik::translate('UsersManager_PrivNone')],
['key' => 'some', 'value' => Piwik::translate('UsersManager_AtLeastView')],
['key' => 'view', 'value' => Piwik::translate('UsersManager_PrivView')],
['key' => 'write', 'value' => Piwik::translate('UsersManager_PrivWrite')],
['key' => 'admin', 'value' => Piwik::translate('UsersManager_PrivAdmin')],
['key' => 'superuser', 'value' => Piwik::translate('Installation_SuperUser')],
];
$capabilities = Request::processRequest('UsersManager.getAvailableCapabilities', [], []);
foreach ($capabilities as $capability) {
$capabilityEntry = [
'key' => $capability['id'], 'value' => $capability['category'] . ': ' . $capability['name'],
];
$view->accessLevels[] = $capabilityEntry;
$view->filterAccessLevels[] = $capabilityEntry;
}
$this->setBasicVariablesView($view);
return $view->render();
} | [
"public",
"function",
"index",
"(",
")",
"{",
"Piwik",
"::",
"checkUserIsNotAnonymous",
"(",
")",
";",
"Piwik",
"::",
"checkUserHasSomeAdminAccess",
"(",
")",
";",
"$",
"view",
"=",
"new",
"View",
"(",
"'@UsersManager/index'",
")",
";",
"$",
"IdSitesAdmin",
... | The "Manage Users and Permissions" Admin UI screen | [
"The",
"Manage",
"Users",
"and",
"Permissions",
"Admin",
"UI",
"screen"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/Controller.php#L51-L105 | train | Displays the users administration screen | [
30522,
2270,
3853,
5950,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
2483,
17048,
6761,
4890,
27711,
1006,
1007,
1025,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
4215,
22311,
9468,
7971,
1006,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Piwik.php | Piwik.redirectToModule | public static function redirectToModule($newModule, $newAction = '', $parameters = array())
{
$newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
Url::redirectToUrl($newUrl);
} | php | public static function redirectToModule($newModule, $newAction = '', $parameters = array())
{
$newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
Url::redirectToUrl($newUrl);
} | [
"public",
"static",
"function",
"redirectToModule",
"(",
"$",
"newModule",
",",
"$",
"newAction",
"=",
"''",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"newUrl",
"=",
"'index.php'",
".",
"Url",
"::",
"getCurrentQueryStringWithParametersModi... | Redirects the current request to a new module and action.
@param string $newModule The target module, eg, `'UserCountry'`.
@param string $newAction The target controller action, eg, `'index'`.
@param array $parameters The query parameter values to modify before redirecting.
@api | [
"Redirects",
"the",
"current",
"request",
"to",
"a",
"new",
"module",
"and",
"action",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L630-L637 | train | Redirects to module action | [
30522,
2270,
10763,
3853,
2417,
7442,
6593,
20389,
7716,
9307,
1006,
1002,
2047,
5302,
8566,
2571,
1010,
1002,
2047,
18908,
3258,
1027,
1005,
1005,
1010,
1002,
11709,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
2047,
30524,
14343,
3372,
4226,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php | DoctrineChoiceLoader.loadChoicesForValues | public function loadChoicesForValues(array $values, $value = null)
{
// Performance optimization
// Also prevents the generation of "WHERE id IN ()" queries through the
// object loader. At least with MySQL and on the development machine
// this was tested on, no exception was thrown for such invalid
// statements, consequently no test fails when this code is removed.
// https://github.com/symfony/symfony/pull/8981#issuecomment-24230557
if (empty($values)) {
return [];
}
// Optimize performance in case we have an object loader and
// a single-field identifier
$optimize = $this->idReader && (null === $value || \is_array($value) && $this->idReader === $value[0]);
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
$objectsById = [];
$objects = [];
// Maintain order and indices from the given $values
// An alternative approach to the following loop is to add the
// "INDEX BY" clause to the Doctrine query in the loader,
// but I'm not sure whether that's doable in a generic fashion.
foreach ($unorderedObjects as $object) {
$objectsById[(string) $this->idReader->getIdValue($object)] = $object;
}
foreach ($values as $i => $id) {
if (isset($objectsById[$id])) {
$objects[$i] = $objectsById[$id];
}
}
return $objects;
}
return $this->loadChoiceList($value)->getChoicesForValues($values);
} | php | public function loadChoicesForValues(array $values, $value = null)
{
// Performance optimization
// Also prevents the generation of "WHERE id IN ()" queries through the
// object loader. At least with MySQL and on the development machine
// this was tested on, no exception was thrown for such invalid
// statements, consequently no test fails when this code is removed.
// https://github.com/symfony/symfony/pull/8981#issuecomment-24230557
if (empty($values)) {
return [];
}
// Optimize performance in case we have an object loader and
// a single-field identifier
$optimize = $this->idReader && (null === $value || \is_array($value) && $this->idReader === $value[0]);
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);
$objectsById = [];
$objects = [];
// Maintain order and indices from the given $values
// An alternative approach to the following loop is to add the
// "INDEX BY" clause to the Doctrine query in the loader,
// but I'm not sure whether that's doable in a generic fashion.
foreach ($unorderedObjects as $object) {
$objectsById[(string) $this->idReader->getIdValue($object)] = $object;
}
foreach ($values as $i => $id) {
if (isset($objectsById[$id])) {
$objects[$i] = $objectsById[$id];
}
}
return $objects;
}
return $this->loadChoiceList($value)->getChoicesForValues($values);
} | [
"public",
"function",
"loadChoicesForValues",
"(",
"array",
"$",
"values",
",",
"$",
"value",
"=",
"null",
")",
"{",
"// Performance optimization",
"// Also prevents the generation of \"WHERE id IN ()\" queries through the",
"// object loader. At least with MySQL and on the developme... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php#L126-L165 | train | Returns the choices for the given values. | [
30522,
2270,
3853,
7170,
9905,
23522,
29278,
10175,
15808,
1006,
9140,
1002,
5300,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
1013,
1013,
2836,
20600,
1013,
1013,
2036,
16263,
1996,
4245,
1997,
1000,
2073,
8909,
1999,
1006,
1007,
1000,
1086... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/UserAccessFilter.php | UserAccessFilter.filterLoginIndexedArray | public function filterLoginIndexedArray($arrayIndexedByLogin)
{
if ($this->access->hasSuperUserAccess()) {
return $arrayIndexedByLogin; // this part is not needed but makes it faster for super user.
}
$allowedLogins = $this->filterLogins(array_keys($arrayIndexedByLogin));
return array_intersect_key($arrayIndexedByLogin, array_flip($allowedLogins));
} | php | public function filterLoginIndexedArray($arrayIndexedByLogin)
{
if ($this->access->hasSuperUserAccess()) {
return $arrayIndexedByLogin; // this part is not needed but makes it faster for super user.
}
$allowedLogins = $this->filterLogins(array_keys($arrayIndexedByLogin));
return array_intersect_key($arrayIndexedByLogin, array_flip($allowedLogins));
} | [
"public",
"function",
"filterLoginIndexedArray",
"(",
"$",
"arrayIndexedByLogin",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"access",
"->",
"hasSuperUserAccess",
"(",
")",
")",
"{",
"return",
"$",
"arrayIndexedByLogin",
";",
"// this part is not needed but makes it fast... | Removes all array values where the current user has no permission to see the existence of a given login index/key.
@param array $arrayIndexedByLogin An array that is indexed by login / usernames. Eg:
array('username1' => 5, 'username2' => array(...), ...)
@return array | [
"Removes",
"all",
"array",
"values",
"where",
"the",
"current",
"user",
"has",
"no",
"permission",
"to",
"see",
"the",
"existence",
"of",
"a",
"given",
"login",
"index",
"/",
"key",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/UserAccessFilter.php#L68-L77 | train | Filter the array indexed by login | [
30522,
2270,
3853,
11307,
21197,
5498,
13629,
19068,
2906,
9447,
1006,
1002,
9140,
22254,
10288,
2098,
3762,
21197,
2378,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3229,
1011,
1028,
2038,
6342,
4842,
20330,
6305,
9623,
2015,
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... |
octobercms/october | modules/backend/behaviors/RelationController.php | RelationController.relationRender | public function relationRender($field, $options = [])
{
/*
* Session key
*/
if (is_string($options)) {
$options = ['sessionKey' => $options];
}
if (isset($options['sessionKey'])) {
$this->sessionKey = $options['sessionKey'];
}
/*
* Apply options and extra config
*/
$allowConfig = ['readOnly', 'recordUrl', 'recordOnClick'];
$extraConfig = array_only($options, $allowConfig);
$this->extraConfig = $extraConfig;
$this->applyExtraConfig($extraConfig, $field);
/*
* Initialize
*/
$this->validateField($field);
$this->prepareVars();
/*
* Determine the partial to use based on the supplied section option
*/
$section = $options['section'] ?? null;
switch (strtolower($section)) {
case 'toolbar':
return $this->toolbarWidget ? $this->toolbarWidget->render() : null;
case 'view':
return $this->relationMakePartial('view');
default:
return $this->relationMakePartial('container');
}
} | php | public function relationRender($field, $options = [])
{
/*
* Session key
*/
if (is_string($options)) {
$options = ['sessionKey' => $options];
}
if (isset($options['sessionKey'])) {
$this->sessionKey = $options['sessionKey'];
}
/*
* Apply options and extra config
*/
$allowConfig = ['readOnly', 'recordUrl', 'recordOnClick'];
$extraConfig = array_only($options, $allowConfig);
$this->extraConfig = $extraConfig;
$this->applyExtraConfig($extraConfig, $field);
/*
* Initialize
*/
$this->validateField($field);
$this->prepareVars();
/*
* Determine the partial to use based on the supplied section option
*/
$section = $options['section'] ?? null;
switch (strtolower($section)) {
case 'toolbar':
return $this->toolbarWidget ? $this->toolbarWidget->render() : null;
case 'view':
return $this->relationMakePartial('view');
default:
return $this->relationMakePartial('container');
}
} | [
"public",
"function",
"relationRender",
"(",
"$",
"field",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"/*\n * Session key\n */",
"if",
"(",
"is_string",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"[",
"'sessionKey'",
"=>",
... | Renders the relationship manager.
@param string $field The relationship field.
@param array $options
@return string Rendered HTML for the relationship manager. | [
"Renders",
"the",
"relationship",
"manager",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/RelationController.php#L393-L434 | train | Render the related field | [
30522,
2270,
3853,
7189,
7389,
4063,
1006,
1002,
2492,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1013,
1008,
1008,
5219,
3145,
1008,
1013,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
7047,
1007,
1007,
1063,
1002,
7047,
1027,
1031,
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/Payment/Notify/Handler.php | Handler.toResponse | public function toResponse(): Response
{
$base = [
'return_code' => is_null($this->fail) ? static::SUCCESS : static::FAIL,
'return_msg' => $this->fail,
];
$attributes = array_merge($base, $this->attributes);
if ($this->sign) {
$attributes['sign'] = Support\generate_sign($attributes, $this->app->getKey());
}
return new Response(XML::build($attributes));
} | php | public function toResponse(): Response
{
$base = [
'return_code' => is_null($this->fail) ? static::SUCCESS : static::FAIL,
'return_msg' => $this->fail,
];
$attributes = array_merge($base, $this->attributes);
if ($this->sign) {
$attributes['sign'] = Support\generate_sign($attributes, $this->app->getKey());
}
return new Response(XML::build($attributes));
} | [
"public",
"function",
"toResponse",
"(",
")",
":",
"Response",
"{",
"$",
"base",
"=",
"[",
"'return_code'",
"=>",
"is_null",
"(",
"$",
"this",
"->",
"fail",
")",
"?",
"static",
"::",
"SUCCESS",
":",
"static",
"::",
"FAIL",
",",
"'return_msg'",
"=>",
"$... | Build xml and return the response to WeChat.
@return \Symfony\Component\HttpFoundation\Response | [
"Build",
"xml",
"and",
"return",
"the",
"response",
"to",
"WeChat",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Notify/Handler.php#L105-L119 | train | Return Response object | [
30522,
2270,
3853,
9538,
13102,
5644,
2063,
1006,
1007,
1024,
3433,
1063,
1002,
2918,
1027,
1031,
1005,
2709,
1035,
3642,
1005,
1027,
1028,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
8246,
1007,
1029,
10763,
1024,
1024,
3112,
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/Archive/DataTableFactory.php | DataTableFactory.prettifyIndexLabel | private function prettifyIndexLabel($labelType, $label)
{
if ($labelType == self::TABLE_METADATA_PERIOD_INDEX) { // prettify period labels
$period = $this->periods[$label];
$label = $period->getLabel();
if ($label === 'week' || $label === 'range') {
return $period->getRangeString();
}
return $period->getPrettyString();
}
return $label;
} | php | private function prettifyIndexLabel($labelType, $label)
{
if ($labelType == self::TABLE_METADATA_PERIOD_INDEX) { // prettify period labels
$period = $this->periods[$label];
$label = $period->getLabel();
if ($label === 'week' || $label === 'range') {
return $period->getRangeString();
}
return $period->getPrettyString();
}
return $label;
} | [
"private",
"function",
"prettifyIndexLabel",
"(",
"$",
"labelType",
",",
"$",
"label",
")",
"{",
"if",
"(",
"$",
"labelType",
"==",
"self",
"::",
"TABLE_METADATA_PERIOD_INDEX",
")",
"{",
"// prettify period labels",
"$",
"period",
"=",
"$",
"this",
"->",
"peri... | Returns the pretty version of an index label.
@param string $labelType eg, 'site', 'period', etc.
@param string $label eg, '0', '1', '2012-01-01,2012-01-31', etc.
@return string | [
"Returns",
"the",
"pretty",
"version",
"of",
"an",
"index",
"label",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataTableFactory.php#L432-L444 | train | Prettify index label | [
30522,
2797,
3853,
3653,
6916,
12031,
22254,
10288,
20470,
2884,
1006,
1002,
3830,
13874,
1010,
1002,
3830,
1007,
1063,
2065,
1006,
1002,
3830,
13874,
1027,
1027,
2969,
1024,
1024,
2795,
1035,
27425,
1035,
2558,
1035,
5950,
1007,
1063,
1013... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Container/Container.php | Container.getCallbacksForType | protected function getCallbacksForType($abstract, $object, array $callbacksPerType)
{
$results = [];
foreach ($callbacksPerType as $type => $callbacks) {
if ($type === $abstract || $object instanceof $type) {
$results = array_merge($results, $callbacks);
}
}
return $results;
} | php | protected function getCallbacksForType($abstract, $object, array $callbacksPerType)
{
$results = [];
foreach ($callbacksPerType as $type => $callbacks) {
if ($type === $abstract || $object instanceof $type) {
$results = array_merge($results, $callbacks);
}
}
return $results;
} | [
"protected",
"function",
"getCallbacksForType",
"(",
"$",
"abstract",
",",
"$",
"object",
",",
"array",
"$",
"callbacksPerType",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"callbacksPerType",
"as",
"$",
"type",
"=>",
"$",
"callbacks... | Get all callbacks for a given type.
@param string $abstract
@param object $object
@param array $callbacksPerType
@return array | [
"Get",
"all",
"callbacks",
"for",
"a",
"given",
"type",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L1059-L1070 | train | Get all callbacks for a given type | [
30522,
5123,
3853,
2131,
9289,
20850,
8684,
22747,
11589,
18863,
1006,
1002,
10061,
1010,
1002,
4874,
1010,
9140,
1002,
30524,
1006,
1002,
2828,
1027,
1027,
1027,
1002,
10061,
1064,
1064,
1002,
4874,
6013,
11253,
1002,
2828,
1007,
1063,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | HasAttributes.getArrayAttributeWithValue | protected function getArrayAttributeWithValue($path, $key, $value)
{
return tap($this->getArrayAttributeByKey($key), function (&$array) use ($path, $value) {
Arr::set($array, str_replace('->', '.', $path), $value);
});
} | php | protected function getArrayAttributeWithValue($path, $key, $value)
{
return tap($this->getArrayAttributeByKey($key), function (&$array) use ($path, $value) {
Arr::set($array, str_replace('->', '.', $path), $value);
});
} | [
"protected",
"function",
"getArrayAttributeWithValue",
"(",
"$",
"path",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"return",
"tap",
"(",
"$",
"this",
"->",
"getArrayAttributeByKey",
"(",
"$",
"key",
")",
",",
"function",
"(",
"&",
"$",
"array",
")",
... | Get an array attribute with the given key and value set.
@param string $path
@param string $key
@param mixed $value
@return $this | [
"Get",
"an",
"array",
"attribute",
"with",
"the",
"given",
"key",
"and",
"value",
"set",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L652-L657 | train | Get array attribute with value | [
30522,
5123,
3853,
2131,
2906,
29539,
4779,
3089,
8569,
2618,
24415,
10175,
5657,
1006,
1002,
4130,
1010,
1002,
3145,
1010,
1002,
3643,
1007,
1063,
2709,
11112,
1006,
1002,
2023,
1011,
1028,
2131,
2906,
29539,
4779,
3089,
8569,
2618,
3762,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/MiniProgram/UniformMessage/Client.php | Client.formatMpMessage | protected function formatMpMessage(array $data = [])
{
$params = $this->baseFormat($data, $this->mpMessage);
if (empty($params['miniprogram']['appid'])) {
$params['miniprogram']['appid'] = $this->app['config']['app_id'];
}
$params['data'] = $this->formatData($params['data'] ?? []);
return $params;
} | php | protected function formatMpMessage(array $data = [])
{
$params = $this->baseFormat($data, $this->mpMessage);
if (empty($params['miniprogram']['appid'])) {
$params['miniprogram']['appid'] = $this->app['config']['app_id'];
}
$params['data'] = $this->formatData($params['data'] ?? []);
return $params;
} | [
"protected",
"function",
"formatMpMessage",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"baseFormat",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"mpMessage",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"par... | @param array $data
@return array | [
"@param",
"array",
"$data"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/MiniProgram/UniformMessage/Client.php#L108-L119 | train | Formats the MP message | [
30522,
5123,
3853,
4289,
8737,
7834,
3736,
3351,
1006,
9140,
1002,
2951,
1027,
1031,
1033,
1007,
1063,
1002,
11498,
5244,
1027,
1002,
2023,
1011,
1028,
2918,
14192,
4017,
1006,
1002,
2951,
1010,
1002,
2023,
1011,
1028,
6131,
7834,
3736,
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... |
z-song/laravel-admin | src/Layout/Column.php | Column.build | public function build()
{
$this->startColumn();
foreach ($this->contents as $content) {
if ($content instanceof Renderable || $content instanceof Grid) {
echo $content->render();
} else {
echo (string) $content;
}
}
$this->endColumn();
} | php | public function build()
{
$this->startColumn();
foreach ($this->contents as $content) {
if ($content instanceof Renderable || $content instanceof Grid) {
echo $content->render();
} else {
echo (string) $content;
}
}
$this->endColumn();
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"startColumn",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"contents",
"as",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"content",
"instanceof",
"Renderable",
"||",
"$",
"content",
... | Build column html. | [
"Build",
"column",
"html",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Layout/Column.php#L94-L107 | train | Build the column | [
30522,
2270,
3853,
3857,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2707,
25778,
2819,
2078,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
8417,
2004,
1002,
4180,
1007,
1063,
2065,
1006,
1002,
4180,
6013,
11253,
17552,
3085,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Support/NamespacedItemResolver.php | NamespacedItemResolver.parseNamespacedSegments | protected function parseNamespacedSegments($key)
{
[$namespace, $item] = explode('::', $key);
// First we'll just explode the first segment to get the namespace and group
// since the item should be in the remaining segments. Once we have these
// two pieces of data we can proceed with parsing out the item's value.
$itemSegments = explode('.', $item);
$groupAndItem = array_slice(
$this->parseBasicSegments($itemSegments), 1
);
return array_merge([$namespace], $groupAndItem);
} | php | protected function parseNamespacedSegments($key)
{
[$namespace, $item] = explode('::', $key);
// First we'll just explode the first segment to get the namespace and group
// since the item should be in the remaining segments. Once we have these
// two pieces of data we can proceed with parsing out the item's value.
$itemSegments = explode('.', $item);
$groupAndItem = array_slice(
$this->parseBasicSegments($itemSegments), 1
);
return array_merge([$namespace], $groupAndItem);
} | [
"protected",
"function",
"parseNamespacedSegments",
"(",
"$",
"key",
")",
"{",
"[",
"$",
"namespace",
",",
"$",
"item",
"]",
"=",
"explode",
"(",
"'::'",
",",
"$",
"key",
")",
";",
"// First we'll just explode the first segment to get the namespace and group",
"// s... | Parse an array of namespaced segments.
@param string $key
@return array | [
"Parse",
"an",
"array",
"of",
"namespaced",
"segments",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/NamespacedItemResolver.php#L75-L89 | train | Parse the namespace segments and return the namespace and item s value. | [
30522,
5123,
3853,
11968,
5054,
14074,
23058,
5104,
13910,
8163,
1006,
1002,
30524,
2074,
15044,
1996,
2034,
6903,
2000,
2131,
1996,
3415,
15327,
1998,
2177,
1013,
1013,
2144,
1996,
8875,
2323,
2022,
1999,
1996,
3588,
9214,
1012,
2320,
2057... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.php | Form.isHasOneRelation | protected function isHasOneRelation($inserts)
{
$first = current($inserts);
if (!is_array($first)) {
return false;
}
if (is_array(current($first))) {
return false;
}
return Arr::isAssoc($first);
} | php | protected function isHasOneRelation($inserts)
{
$first = current($inserts);
if (!is_array($first)) {
return false;
}
if (is_array(current($first))) {
return false;
}
return Arr::isAssoc($first);
} | [
"protected",
"function",
"isHasOneRelation",
"(",
"$",
"inserts",
")",
"{",
"$",
"first",
"=",
"current",
"(",
"$",
"inserts",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"first",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_array",... | Is input data is has-one relation.
@param array $inserts
@return bool | [
"Is",
"input",
"data",
"is",
"has",
"-",
"one",
"relation",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form.php#L954-L967 | train | Returns true if the insert is a has - one relation | [
30522,
5123,
3853,
2003,
14949,
5643,
16570,
3370,
1006,
1002,
19274,
2015,
1007,
1063,
1002,
2034,
1027,
2783,
1006,
1002,
30524,
1006,
1002,
2034,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/Model.php | Model.getUsersHavingSuperUserAccess | public function getUsersHavingSuperUserAccess()
{
$db = $this->getDb();
$users = $db->fetchAll("SELECT login, email, token_auth, superuser_access
FROM " . Common::prefixTable("user") . "
WHERE superuser_access = 1
ORDER BY date_registered ASC");
return $users;
} | php | public function getUsersHavingSuperUserAccess()
{
$db = $this->getDb();
$users = $db->fetchAll("SELECT login, email, token_auth, superuser_access
FROM " . Common::prefixTable("user") . "
WHERE superuser_access = 1
ORDER BY date_registered ASC");
return $users;
} | [
"public",
"function",
"getUsersHavingSuperUserAccess",
"(",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
";",
"$",
"users",
"=",
"$",
"db",
"->",
"fetchAll",
"(",
"\"SELECT login, email, token_auth, superuser_access\n ... | Note that this returns the token_auth which is as private as the password!
@return array[] containing login, email and token_auth | [
"Note",
"that",
"this",
"returns",
"the",
"token_auth",
"which",
"is",
"as",
"private",
"as",
"the",
"password!"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/Model.php#L307-L316 | train | Get all users having superuser access | [
30522,
2270,
3853,
2131,
20330,
7377,
6455,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1063,
1002,
16962,
1027,
1002,
2023,
1011,
1028,
2131,
18939,
1006,
1007,
1025,
1002,
5198,
1027,
1002,
16962,
1011,
1028,
18584,
8095,
1006,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select.columns | public function columns($cols = '*', $correlationName = null)
{
if ($correlationName === null && count($this->_parts[self::FROM])) {
$correlationNameKeys = array_keys($this->_parts[self::FROM]);
$correlationName = current($correlationNameKeys);
}
if (!array_key_exists($correlationName, $this->_parts[self::FROM])) {
/**
* @see Zend_Db_Select_Exception
*/
// require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception("No table has been specified for the FROM clause");
}
$this->_tableCols($correlationName, $cols);
return $this;
} | php | public function columns($cols = '*', $correlationName = null)
{
if ($correlationName === null && count($this->_parts[self::FROM])) {
$correlationNameKeys = array_keys($this->_parts[self::FROM]);
$correlationName = current($correlationNameKeys);
}
if (!array_key_exists($correlationName, $this->_parts[self::FROM])) {
/**
* @see Zend_Db_Select_Exception
*/
// require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception("No table has been specified for the FROM clause");
}
$this->_tableCols($correlationName, $cols);
return $this;
} | [
"public",
"function",
"columns",
"(",
"$",
"cols",
"=",
"'*'",
",",
"$",
"correlationName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"correlationName",
"===",
"null",
"&&",
"count",
"(",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"FROM",
"]",
")",... | Specifies the columns used in the FROM clause.
The parameter can be a single string or Zend_Db_Expr object,
or else an array of strings or Zend_Db_Expr objects.
@param array|string|Zend_Db_Expr $cols The columns to select from this table.
@param string $correlationName Correlation name of target table. OPTIONAL
@return Zend_Db_Select This Zend_Db_Select object. | [
"Specifies",
"the",
"columns",
"used",
"in",
"the",
"FROM",
"clause",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L243-L261 | train | Set the columns for the FROM clause | [
30522,
2270,
3853,
7753,
1006,
1002,
8902,
2015,
1027,
1005,
1008,
1005,
1010,
1002,
16902,
18442,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
16902,
18442,
1027,
1027,
1027,
19701,
1004,
1004,
4175,
1006,
1002,
2023,
1011,
1028,
1035,
3033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DataCollector/TimeDataCollector.php | TimeDataCollector.collect | public function collect(Request $request, Response $response, \Exception $exception = null)
{
if (null !== $this->kernel) {
$startTime = $this->kernel->getStartTime();
} else {
$startTime = $request->server->get('REQUEST_TIME_FLOAT');
}
$this->data = [
'token' => $response->headers->get('X-Debug-Token'),
'start_time' => $startTime * 1000,
'events' => [],
'stopwatch_installed' => \class_exists(Stopwatch::class, false),
];
} | php | public function collect(Request $request, Response $response, \Exception $exception = null)
{
if (null !== $this->kernel) {
$startTime = $this->kernel->getStartTime();
} else {
$startTime = $request->server->get('REQUEST_TIME_FLOAT');
}
$this->data = [
'token' => $response->headers->get('X-Debug-Token'),
'start_time' => $startTime * 1000,
'events' => [],
'stopwatch_installed' => \class_exists(Stopwatch::class, false),
];
} | [
"public",
"function",
"collect",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"\\",
"Exception",
"$",
"exception",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"kernel",
")",
"{",
"$",
"startTime",
"=",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php#L38-L52 | train | Collects information about the current request and response | [
30522,
2270,
3853,
8145,
1006,
5227,
1002,
5227,
1010,
3433,
1002,
3433,
1010,
1032,
6453,
1002,
6453,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
16293,
1007,
1063,
1002,
2707,
7292,
1027,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.recordEcommerceItems | protected function recordEcommerceItems($goal, $items)
{
$itemInCartBySku = array();
foreach ($items as $item) {
$itemInCartBySku[$item[0]] = $item;
}
$itemsInDb = $this->getModel()->getAllItemsCurrentlyInTheCart($goal, self::ITEM_IDORDER_ABANDONED_CART);
// Look at which items need to be deleted, which need to be added or updated, based on the SKU
$skuFoundInDb = $itemsToUpdate = array();
foreach ($itemsInDb as $itemInDb) {
$skuFoundInDb[] = $itemInDb['idaction_sku'];
// Ensure price comparisons will have the same assumption
$itemInDb['price'] = $this->getRevenue($itemInDb['price']);
$itemInDbOriginal = $itemInDb;
$itemInDb = array_values($itemInDb);
// Cast all as string, because what comes out of the fetchAll() are strings
$itemInDb = $this->getItemRowCast($itemInDb);
//Item in the cart in the DB, but not anymore in the cart
if (!isset($itemInCartBySku[$itemInDb[0]])) {
$itemToUpdate = array_merge($itemInDb,
array('deleted' => 1,
'idorder_original_value' => $itemInDbOriginal['idorder_original_value']
)
);
$itemsToUpdate[] = $itemToUpdate;
Common::printDebug("Item found in the previous Cart, but no in the current cart/order");
Common::printDebug($itemToUpdate);
continue;
}
$newItem = $itemInCartBySku[$itemInDb[0]];
$newItem = $this->getItemRowCast($newItem);
if (count($itemInDb) != count($newItem)) {
Common::printDebug("ERROR: Different format in items from cart and DB");
throw new Exception(" Item in DB and Item in cart have a different format, this is not expected... " . var_export($itemInDb, true) . var_export($newItem, true));
}
Common::printDebug("Item has changed since the last cart. Previous item stored in cart in database:");
Common::printDebug($itemInDb);
Common::printDebug("New item to UPDATE the previous row:");
$newItem['idorder_original_value'] = $itemInDbOriginal['idorder_original_value'];
Common::printDebug($newItem);
$itemsToUpdate[] = $newItem;
}
// Items to UPDATE
$this->updateEcommerceItems($goal, $itemsToUpdate);
// Items to INSERT
$itemsToInsert = array();
foreach ($items as $item) {
if (!in_array($item[0], $skuFoundInDb)) {
$itemsToInsert[] = $item;
}
}
$this->insertEcommerceItems($goal, $itemsToInsert);
} | php | protected function recordEcommerceItems($goal, $items)
{
$itemInCartBySku = array();
foreach ($items as $item) {
$itemInCartBySku[$item[0]] = $item;
}
$itemsInDb = $this->getModel()->getAllItemsCurrentlyInTheCart($goal, self::ITEM_IDORDER_ABANDONED_CART);
// Look at which items need to be deleted, which need to be added or updated, based on the SKU
$skuFoundInDb = $itemsToUpdate = array();
foreach ($itemsInDb as $itemInDb) {
$skuFoundInDb[] = $itemInDb['idaction_sku'];
// Ensure price comparisons will have the same assumption
$itemInDb['price'] = $this->getRevenue($itemInDb['price']);
$itemInDbOriginal = $itemInDb;
$itemInDb = array_values($itemInDb);
// Cast all as string, because what comes out of the fetchAll() are strings
$itemInDb = $this->getItemRowCast($itemInDb);
//Item in the cart in the DB, but not anymore in the cart
if (!isset($itemInCartBySku[$itemInDb[0]])) {
$itemToUpdate = array_merge($itemInDb,
array('deleted' => 1,
'idorder_original_value' => $itemInDbOriginal['idorder_original_value']
)
);
$itemsToUpdate[] = $itemToUpdate;
Common::printDebug("Item found in the previous Cart, but no in the current cart/order");
Common::printDebug($itemToUpdate);
continue;
}
$newItem = $itemInCartBySku[$itemInDb[0]];
$newItem = $this->getItemRowCast($newItem);
if (count($itemInDb) != count($newItem)) {
Common::printDebug("ERROR: Different format in items from cart and DB");
throw new Exception(" Item in DB and Item in cart have a different format, this is not expected... " . var_export($itemInDb, true) . var_export($newItem, true));
}
Common::printDebug("Item has changed since the last cart. Previous item stored in cart in database:");
Common::printDebug($itemInDb);
Common::printDebug("New item to UPDATE the previous row:");
$newItem['idorder_original_value'] = $itemInDbOriginal['idorder_original_value'];
Common::printDebug($newItem);
$itemsToUpdate[] = $newItem;
}
// Items to UPDATE
$this->updateEcommerceItems($goal, $itemsToUpdate);
// Items to INSERT
$itemsToInsert = array();
foreach ($items as $item) {
if (!in_array($item[0], $skuFoundInDb)) {
$itemsToInsert[] = $item;
}
}
$this->insertEcommerceItems($goal, $itemsToInsert);
} | [
"protected",
"function",
"recordEcommerceItems",
"(",
"$",
"goal",
",",
"$",
"items",
")",
"{",
"$",
"itemInCartBySku",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"itemInCartBySku",
"[",
"$",
"item",
"[... | Loads the Ecommerce items from the request and records them in the DB
@param array $goal
@param array $items
@throws Exception
@return int Number of items in the cart | [
"Loads",
"the",
"Ecommerce",
"items",
"from",
"the",
"request",
"and",
"records",
"them",
"in",
"the",
"DB"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L383-L447 | train | Records Ecommerce Items | [
30522,
5123,
3853,
2501,
8586,
5358,
5017,
3401,
4221,
5244,
1006,
1002,
3125,
1010,
1002,
5167,
1007,
1063,
1002,
8875,
2378,
10010,
2102,
3762,
6711,
2226,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
5167,
2004,
1002,
8875,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Transport/Sendmail.php | Zend_Mail_Transport_Sendmail._sendMail | public function _sendMail()
{
if ($this->parameters === null) {
set_error_handler(array($this, '_handleMailErrors'));
$result = mail(
$this->recipients,
$this->_mail->getSubject(),
$this->body,
$this->header);
restore_error_handler();
} else {
if(!is_string($this->parameters)) {
/**
* @see Zend_Mail_Transport_Exception
*
* Exception is thrown here because
* $parameters is a public property
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception(
'Parameters were set but are not a string'
);
}
set_error_handler(array($this, '_handleMailErrors'));
$result = mail(
$this->recipients,
$this->_mail->getSubject(),
$this->body,
$this->header,
$this->parameters);
restore_error_handler();
}
if ($this->_errstr !== null || !$result) {
/**
* @see Zend_Mail_Transport_Exception
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr);
}
} | php | public function _sendMail()
{
if ($this->parameters === null) {
set_error_handler(array($this, '_handleMailErrors'));
$result = mail(
$this->recipients,
$this->_mail->getSubject(),
$this->body,
$this->header);
restore_error_handler();
} else {
if(!is_string($this->parameters)) {
/**
* @see Zend_Mail_Transport_Exception
*
* Exception is thrown here because
* $parameters is a public property
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception(
'Parameters were set but are not a string'
);
}
set_error_handler(array($this, '_handleMailErrors'));
$result = mail(
$this->recipients,
$this->_mail->getSubject(),
$this->body,
$this->header,
$this->parameters);
restore_error_handler();
}
if ($this->_errstr !== null || !$result) {
/**
* @see Zend_Mail_Transport_Exception
*/
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('Unable to send mail. ' . $this->_errstr);
}
} | [
"public",
"function",
"_sendMail",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parameters",
"===",
"null",
")",
"{",
"set_error_handler",
"(",
"array",
"(",
"$",
"this",
",",
"'_handleMailErrors'",
")",
")",
";",
"$",
"result",
"=",
"mail",
"(",
"$",... | Send mail using PHP native mail()
@access public
@return void
@throws Zend_Mail_Transport_Exception if parameters is set
but not a string
@throws Zend_Mail_Transport_Exception on mail() failure | [
"Send",
"mail",
"using",
"PHP",
"native",
"mail",
"()"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Transport/Sendmail.php#L98-L139 | train | Send the mail | [
30522,
2270,
3853,
1035,
4604,
21397,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11709,
1027,
1027,
1027,
19701,
1007,
1063,
2275,
1035,
7561,
1035,
28213,
1006,
9140,
1006,
1002,
2023,
1010,
1005,
1035,
5047,
21397,
2121,
29165,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.pathMatchesSearch | protected function pathMatchesSearch($path, $words)
{
$path = Str::lower($path);
foreach ($words as $word) {
$word = trim($word);
if (!strlen($word)) {
continue;
}
if (!Str::contains($path, $word)) {
return false;
}
}
return true;
} | php | protected function pathMatchesSearch($path, $words)
{
$path = Str::lower($path);
foreach ($words as $word) {
$word = trim($word);
if (!strlen($word)) {
continue;
}
if (!Str::contains($path, $word)) {
return false;
}
}
return true;
} | [
"protected",
"function",
"pathMatchesSearch",
"(",
"$",
"path",
",",
"$",
"words",
")",
"{",
"$",
"path",
"=",
"Str",
"::",
"lower",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"words",
"as",
"$",
"word",
")",
"{",
"$",
"word",
"=",
"trim",
... | Determines if file path contains all words form the search term.
@param string $path Specifies a path to examine.
@param array $words A list of words to check against.
@return boolean | [
"Determines",
"if",
"file",
"path",
"contains",
"all",
"words",
"form",
"the",
"search",
"term",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L775-L791 | train | Checks if a path matches a search word | [
30522,
5123,
3853,
4130,
18900,
8376,
17310,
11140,
1006,
1002,
4130,
1010,
1002,
2616,
1007,
1063,
1002,
4130,
1027,
2358,
2099,
1024,
1024,
2896,
1006,
1002,
4130,
1007,
1025,
18921,
6776,
1006,
1002,
2616,
2004,
1002,
2773,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php | ProfilerController.searchResultsAction | public function searchResultsAction(Request $request, $token)
{
$this->denyAccessIfProfilerDisabled();
if (null !== $this->cspHandler) {
$this->cspHandler->disableCsp();
}
$profile = $this->profiler->loadProfile($token);
$ip = $request->query->get('ip');
$method = $request->query->get('method');
$statusCode = $request->query->get('status_code');
$url = $request->query->get('url');
$start = $request->query->get('start', null);
$end = $request->query->get('end', null);
$limit = $request->query->get('limit');
return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', [
'request' => $request,
'token' => $token,
'profile' => $profile,
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode),
'ip' => $ip,
'method' => $method,
'status_code' => $statusCode,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
'panel' => null,
]), 200, ['Content-Type' => 'text/html']);
} | php | public function searchResultsAction(Request $request, $token)
{
$this->denyAccessIfProfilerDisabled();
if (null !== $this->cspHandler) {
$this->cspHandler->disableCsp();
}
$profile = $this->profiler->loadProfile($token);
$ip = $request->query->get('ip');
$method = $request->query->get('method');
$statusCode = $request->query->get('status_code');
$url = $request->query->get('url');
$start = $request->query->get('start', null);
$end = $request->query->get('end', null);
$limit = $request->query->get('limit');
return new Response($this->twig->render('@WebProfiler/Profiler/results.html.twig', [
'request' => $request,
'token' => $token,
'profile' => $profile,
'tokens' => $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode),
'ip' => $ip,
'method' => $method,
'status_code' => $statusCode,
'url' => $url,
'start' => $start,
'end' => $end,
'limit' => $limit,
'panel' => null,
]), 200, ['Content-Type' => 'text/html']);
} | [
"public",
"function",
"searchResultsAction",
"(",
"Request",
"$",
"request",
",",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"denyAccessIfProfilerDisabled",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"cspHandler",
")",
"{",
"$",
"this",
... | Renders the search results.
@param Request $request The current HTTP Request
@param string $token The token
@return Response A Response instance
@throws NotFoundHttpException | [
"Renders",
"the",
"search",
"results",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php#L220-L252 | train | Returns the search results for a specific profile | [
30522,
2270,
3853,
3945,
6072,
11314,
3736,
7542,
1006,
5227,
1002,
5227,
1010,
1002,
19204,
1007,
1063,
1002,
2023,
1011,
1028,
9772,
6305,
9623,
5332,
22540,
3217,
8873,
3917,
10521,
3085,
2094,
1006,
1007,
1025,
2065,
1006,
19701,
999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Encoder/XmlEncoder.php | XmlEncoder.decode | public function decode($data, $format, array $context = [])
{
if ('' === trim($data)) {
throw new NotEncodableValueException('Invalid XML data, it can not be empty.');
}
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(true);
libxml_clear_errors();
$dom = new \DOMDocument();
$dom->loadXML($data, $context[self::LOAD_OPTIONS] ?? $this->defaultContext[self::LOAD_OPTIONS]);
libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);
if ($error = libxml_get_last_error()) {
libxml_clear_errors();
throw new NotEncodableValueException($error->message);
}
$rootNode = null;
$decoderIgnoredNodeTypes = $context[self::DECODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::DECODER_IGNORED_NODE_TYPES];
foreach ($dom->childNodes as $child) {
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
throw new NotEncodableValueException('Document types are not allowed.');
}
if (!$rootNode && !\in_array($child->nodeType, $decoderIgnoredNodeTypes, true)) {
$rootNode = $child;
}
}
// todo: throw an exception if the root node name is not correctly configured (bc)
if ($rootNode->hasChildNodes()) {
$xpath = new \DOMXPath($dom);
$data = [];
foreach ($xpath->query('namespace::*', $dom->documentElement) as $nsNode) {
$data['@'.$nsNode->nodeName] = $nsNode->nodeValue;
}
unset($data['@xmlns:xml']);
if (empty($data)) {
return $this->parseXml($rootNode, $context);
}
return array_merge($data, (array) $this->parseXml($rootNode, $context));
}
if (!$rootNode->hasAttributes()) {
return $rootNode->nodeValue;
}
$data = [];
foreach ($rootNode->attributes as $attrKey => $attr) {
$data['@'.$attrKey] = $attr->nodeValue;
}
$data['#'] = $rootNode->nodeValue;
return $data;
} | php | public function decode($data, $format, array $context = [])
{
if ('' === trim($data)) {
throw new NotEncodableValueException('Invalid XML data, it can not be empty.');
}
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(true);
libxml_clear_errors();
$dom = new \DOMDocument();
$dom->loadXML($data, $context[self::LOAD_OPTIONS] ?? $this->defaultContext[self::LOAD_OPTIONS]);
libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);
if ($error = libxml_get_last_error()) {
libxml_clear_errors();
throw new NotEncodableValueException($error->message);
}
$rootNode = null;
$decoderIgnoredNodeTypes = $context[self::DECODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::DECODER_IGNORED_NODE_TYPES];
foreach ($dom->childNodes as $child) {
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
throw new NotEncodableValueException('Document types are not allowed.');
}
if (!$rootNode && !\in_array($child->nodeType, $decoderIgnoredNodeTypes, true)) {
$rootNode = $child;
}
}
// todo: throw an exception if the root node name is not correctly configured (bc)
if ($rootNode->hasChildNodes()) {
$xpath = new \DOMXPath($dom);
$data = [];
foreach ($xpath->query('namespace::*', $dom->documentElement) as $nsNode) {
$data['@'.$nsNode->nodeName] = $nsNode->nodeValue;
}
unset($data['@xmlns:xml']);
if (empty($data)) {
return $this->parseXml($rootNode, $context);
}
return array_merge($data, (array) $this->parseXml($rootNode, $context));
}
if (!$rootNode->hasAttributes()) {
return $rootNode->nodeValue;
}
$data = [];
foreach ($rootNode->attributes as $attrKey => $attr) {
$data['@'.$attrKey] = $attr->nodeValue;
}
$data['#'] = $rootNode->nodeValue;
return $data;
} | [
"public",
"function",
"decode",
"(",
"$",
"data",
",",
"$",
"format",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"''",
"===",
"trim",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"NotEncodableValueException",
"(",
"'Invalid... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php#L124-L188 | train | Decodes XML data into an array | [
30522,
2270,
3853,
21933,
3207,
1006,
1002,
2951,
1010,
1002,
4289,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1005,
1005,
1027,
1027,
1027,
12241,
1006,
1002,
2951,
1007,
1007,
1063,
5466,
2047,
3602,
15305,
20782,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.manipulateDataTableMap | protected function manipulateDataTableMap($dataTable)
{
$result = $dataTable->getEmptyClone();
foreach ($dataTable->getDataTables() as $tableLabel => $childTable) {
$newTable = $this->manipulate($childTable);
$result->addTable($newTable, $tableLabel);
}
return $result;
} | php | protected function manipulateDataTableMap($dataTable)
{
$result = $dataTable->getEmptyClone();
foreach ($dataTable->getDataTables() as $tableLabel => $childTable) {
$newTable = $this->manipulate($childTable);
$result->addTable($newTable, $tableLabel);
}
return $result;
} | [
"protected",
"function",
"manipulateDataTableMap",
"(",
"$",
"dataTable",
")",
"{",
"$",
"result",
"=",
"$",
"dataTable",
"->",
"getEmptyClone",
"(",
")",
";",
"foreach",
"(",
"$",
"dataTable",
"->",
"getDataTables",
"(",
")",
"as",
"$",
"tableLabel",
"=>",
... | Manipulates child DataTables of a DataTable\Map. See @manipulate for more info.
@param DataTable\Map $dataTable
@return DataTable\Map | [
"Manipulates",
"child",
"DataTables",
"of",
"a",
"DataTable",
"\\",
"Map",
".",
"See",
"@manipulate",
"for",
"more",
"info",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/DataTableManipulator.php#L78-L86 | train | manipulate a data table | [
30522,
5123,
3853,
20063,
6790,
10880,
2863,
2361,
1006,
1002,
2951,
10880,
1007,
1063,
1002,
2765,
1027,
1002,
2951,
10880,
1011,
1028,
2131,
6633,
13876,
2100,
20464,
5643,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2951,
10880,
1011,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/formwidgets/FileUpload.php | FileUpload.onSortAttachments | public function onSortAttachments()
{
if ($sortData = post('sortOrder')) {
$ids = array_keys($sortData);
$orders = array_values($sortData);
$fileModel = $this->getRelationModel();
$fileModel->setSortableOrder($ids, $orders);
}
} | php | public function onSortAttachments()
{
if ($sortData = post('sortOrder')) {
$ids = array_keys($sortData);
$orders = array_values($sortData);
$fileModel = $this->getRelationModel();
$fileModel->setSortableOrder($ids, $orders);
}
} | [
"public",
"function",
"onSortAttachments",
"(",
")",
"{",
"if",
"(",
"$",
"sortData",
"=",
"post",
"(",
"'sortOrder'",
")",
")",
"{",
"$",
"ids",
"=",
"array_keys",
"(",
"$",
"sortData",
")",
";",
"$",
"orders",
"=",
"array_values",
"(",
"$",
"sortData... | Sorts file attachments. | [
"Sorts",
"file",
"attachments",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/FileUpload.php#L288-L297 | train | onSortAttachments callback. | [
30522,
2270,
3853,
2006,
21748,
29336,
2696,
22729,
2015,
1006,
1007,
1063,
2065,
1006,
1002,
4066,
2850,
2696,
1027,
2695,
1006,
1005,
4066,
8551,
2121,
1005,
1007,
1007,
1063,
1002,
8909,
2015,
1027,
9140,
1035,
6309,
1006,
1002,
4066,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Command/Command.php | Command.getHelper | public function getHelper($name)
{
if (null === $this->helperSet) {
throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
}
return $this->helperSet->get($name);
} | php | public function getHelper($name)
{
if (null === $this->helperSet) {
throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
}
return $this->helperSet->get($name);
} | [
"public",
"function",
"getHelper",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"helperSet",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot retrieve helper \"%s\" because there is no HelperSet defined. Did you for... | Gets a helper instance by name.
@param string $name The helper name
@return mixed The helper value
@throws LogicException if no HelperSet is defined
@throws InvalidArgumentException if the helper is not defined | [
"Gets",
"a",
"helper",
"instance",
"by",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Command/Command.php#L632-L639 | train | Returns the helper with the given name | [
30522,
2270,
3853,
2131,
16001,
4842,
1006,
1002,
30524,
1000,
1003,
1055,
1000,
2138,
2045,
2003,
2053,
2393,
2545,
3388,
4225,
1012,
2106,
2017,
5293,
2000,
5587,
2115,
3094,
2000,
1996,
4646,
2030,
2000,
2275,
1996,
4646,
2006,
1996,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/Controller.php | Controller.addComponent | public function addComponent($name, $alias, $properties, $addToLayout = false)
{
$manager = ComponentManager::instance();
if ($addToLayout) {
if (!$componentObj = $manager->makeComponent($name, $this->layoutObj, $properties)) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
}
$componentObj->alias = $alias;
$this->vars[$alias] = $this->layout->components[$alias] = $componentObj;
}
else {
if (!$componentObj = $manager->makeComponent($name, $this->pageObj, $properties)) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
}
$componentObj->alias = $alias;
$this->vars[$alias] = $this->page->components[$alias] = $componentObj;
}
$this->setComponentPropertiesFromParams($componentObj);
$componentObj->init();
return $componentObj;
} | php | public function addComponent($name, $alias, $properties, $addToLayout = false)
{
$manager = ComponentManager::instance();
if ($addToLayout) {
if (!$componentObj = $manager->makeComponent($name, $this->layoutObj, $properties)) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
}
$componentObj->alias = $alias;
$this->vars[$alias] = $this->layout->components[$alias] = $componentObj;
}
else {
if (!$componentObj = $manager->makeComponent($name, $this->pageObj, $properties)) {
throw new CmsException(Lang::get('cms::lang.component.not_found', ['name'=>$name]));
}
$componentObj->alias = $alias;
$this->vars[$alias] = $this->page->components[$alias] = $componentObj;
}
$this->setComponentPropertiesFromParams($componentObj);
$componentObj->init();
return $componentObj;
} | [
"public",
"function",
"addComponent",
"(",
"$",
"name",
",",
"$",
"alias",
",",
"$",
"properties",
",",
"$",
"addToLayout",
"=",
"false",
")",
"{",
"$",
"manager",
"=",
"ComponentManager",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"addToLayout",
... | Adds a component to the page object
@param mixed $name Component class name or short name
@param string $alias Alias to give the component
@param array $properties Component properties
@param bool $addToLayout Add to layout, instead of page
@return ComponentBase Component object | [
"Adds",
"a",
"component",
"to",
"the",
"page",
"object"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Controller.php#L1442-L1466 | train | Creates a new component object and sets it s properties. | [
30522,
2270,
3853,
5587,
9006,
29513,
3372,
1006,
1002,
2171,
1010,
1002,
14593,
1010,
1002,
5144,
1010,
1002,
5587,
3406,
8485,
5833,
1027,
6270,
1007,
1063,
1002,
3208,
1027,
6922,
24805,
4590,
1024,
1024,
6013,
1006,
1007,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Scheduler/Scheduler.php | Scheduler.pushExecutedJob | private function pushExecutedJob(Job $job)
{
$this->executed_jobs[] = $job;
$command = $job->getCommand();
$args = $job->getArguments();
// If callable, log the string Closure
if (is_callable($command)) {
$command = \is_string($command) ? $command : 'Closure';
}
$this->addSchedulerVerboseOutput("<green>Success</green>: <white>{$command} {$args}</white>");
return $job;
} | php | private function pushExecutedJob(Job $job)
{
$this->executed_jobs[] = $job;
$command = $job->getCommand();
$args = $job->getArguments();
// If callable, log the string Closure
if (is_callable($command)) {
$command = \is_string($command) ? $command : 'Closure';
}
$this->addSchedulerVerboseOutput("<green>Success</green>: <white>{$command} {$args}</white>");
return $job;
} | [
"private",
"function",
"pushExecutedJob",
"(",
"Job",
"$",
"job",
")",
"{",
"$",
"this",
"->",
"executed_jobs",
"[",
"]",
"=",
"$",
"job",
";",
"$",
"command",
"=",
"$",
"job",
"->",
"getCommand",
"(",
")",
";",
"$",
"args",
"=",
"$",
"job",
"->",
... | Push a succesfully executed job.
@param Job $job
@return Job | [
"Push",
"a",
"succesfully",
"executed",
"job",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L328-L340 | train | Push a job to executed_jobs | [
30522,
2797,
3853,
5245,
10288,
8586,
12926,
5558,
2497,
1006,
3105,
1002,
3105,
1007,
1063,
1002,
2023,
1011,
1028,
6472,
1035,
5841,
1031,
1033,
1027,
1002,
3105,
1025,
1002,
30524,
8833,
1996,
5164,
8503,
2065,
1006,
2003,
1035,
2655,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Widgets/Box.php | Box.content | public function content($content)
{
if ($content instanceof Renderable) {
$this->content = $content->render();
} else {
$this->content = (string) $content;
}
return $this;
} | php | public function content($content)
{
if ($content instanceof Renderable) {
$this->content = $content->render();
} else {
$this->content = (string) $content;
}
return $this;
} | [
"public",
"function",
"content",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"content",
"instanceof",
"Renderable",
")",
"{",
"$",
"this",
"->",
"content",
"=",
"$",
"content",
"->",
"render",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
... | Set box content.
@param string $content
@return $this | [
"Set",
"box",
"content",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Widgets/Box.php#L55-L64 | train | Set the content of the page | [
30522,
2270,
3853,
4180,
1006,
1002,
4180,
1007,
1063,
2065,
1006,
1002,
4180,
6013,
11253,
17552,
3085,
1007,
1063,
1002,
2023,
1011,
1028,
4180,
1027,
1002,
4180,
1011,
1028,
17552,
1006,
1007,
1025,
1065,
2842,
1063,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Connection.php | Connection.setTablePrefix | public function setTablePrefix($prefix)
{
$this->tablePrefix = $prefix;
$this->getQueryGrammar()->setTablePrefix($prefix);
return $this;
} | php | public function setTablePrefix($prefix)
{
$this->tablePrefix = $prefix;
$this->getQueryGrammar()->setTablePrefix($prefix);
return $this;
} | [
"public",
"function",
"setTablePrefix",
"(",
"$",
"prefix",
")",
"{",
"$",
"this",
"->",
"tablePrefix",
"=",
"$",
"prefix",
";",
"$",
"this",
"->",
"getQueryGrammar",
"(",
")",
"->",
"setTablePrefix",
"(",
"$",
"prefix",
")",
";",
"return",
"$",
"this",
... | Set the table prefix in use by the connection.
@param string $prefix
@return $this | [
"Set",
"the",
"table",
"prefix",
"in",
"use",
"by",
"the",
"connection",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connection.php#L1219-L1226 | train | Set Table Prefix | [
30522,
2270,
3853,
2275,
10880,
28139,
8873,
2595,
1006,
1002,
17576,
1007,
1063,
1002,
2023,
1011,
1028,
2795,
28139,
8873,
2595,
1027,
1002,
17576,
1025,
1002,
2023,
1011,
1028,
2131,
4226,
2854,
13113,
7849,
1006,
1007,
1011,
1028,
2275,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field/MultipleSelect.php | MultipleSelect.getOtherKey | protected function getOtherKey()
{
if ($this->otherKey) {
return $this->otherKey;
}
if (is_callable([$this->form->model(), $this->column]) &&
($relation = $this->form->model()->{$this->column}()) instanceof BelongsToMany
) {
/* @var BelongsToMany $relation */
$fullKey = $relation->getQualifiedRelatedPivotKeyName();
$fullKeyArray = explode('.', $fullKey);
return $this->otherKey = end($fullKeyArray);
}
throw new \Exception('Column of this field must be a `BelongsToMany` relation.');
} | php | protected function getOtherKey()
{
if ($this->otherKey) {
return $this->otherKey;
}
if (is_callable([$this->form->model(), $this->column]) &&
($relation = $this->form->model()->{$this->column}()) instanceof BelongsToMany
) {
/* @var BelongsToMany $relation */
$fullKey = $relation->getQualifiedRelatedPivotKeyName();
$fullKeyArray = explode('.', $fullKey);
return $this->otherKey = end($fullKeyArray);
}
throw new \Exception('Column of this field must be a `BelongsToMany` relation.');
} | [
"protected",
"function",
"getOtherKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"otherKey",
")",
"{",
"return",
"$",
"this",
"->",
"otherKey",
";",
"}",
"if",
"(",
"is_callable",
"(",
"[",
"$",
"this",
"->",
"form",
"->",
"model",
"(",
")",
",... | Get other key for this many-to-many relation.
@throws \Exception
@return string | [
"Get",
"other",
"key",
"for",
"this",
"many",
"-",
"to",
"-",
"many",
"relation",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/MultipleSelect.php#L24-L41 | train | Return the name of the other key of this field | [
30522,
5123,
3853,
2131,
14573,
2121,
14839,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2060,
14839,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2060,
14839,
1025,
1065,
2065,
1006,
2003,
1035,
2655,
3085,
1006,
1031,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Column.php | Column.sorter | public function sorter()
{
if (!$this->sortable) {
return '';
}
$icon = 'fa-sort';
$type = 'desc';
if ($this->isSorted()) {
$type = $this->sort['type'] == 'desc' ? 'asc' : 'desc';
$icon .= "-amount-{$this->sort['type']}";
}
// set sort value
$sort = ['column' => $this->name, 'type' => $type];
if (isset($this->cast)) {
$sort['cast'] = $this->cast;
}
$query = app('request')->all();
$query = array_merge($query, [$this->grid->model()->getSortName() => $sort]);
$url = url()->current().'?'.http_build_query($query);
return "<a class=\"fa fa-fw $icon\" href=\"$url\"></a>";
} | php | public function sorter()
{
if (!$this->sortable) {
return '';
}
$icon = 'fa-sort';
$type = 'desc';
if ($this->isSorted()) {
$type = $this->sort['type'] == 'desc' ? 'asc' : 'desc';
$icon .= "-amount-{$this->sort['type']}";
}
// set sort value
$sort = ['column' => $this->name, 'type' => $type];
if (isset($this->cast)) {
$sort['cast'] = $this->cast;
}
$query = app('request')->all();
$query = array_merge($query, [$this->grid->model()->getSortName() => $sort]);
$url = url()->current().'?'.http_build_query($query);
return "<a class=\"fa fa-fw $icon\" href=\"$url\"></a>";
} | [
"public",
"function",
"sorter",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sortable",
")",
"{",
"return",
"''",
";",
"}",
"$",
"icon",
"=",
"'fa-sort'",
";",
"$",
"type",
"=",
"'desc'",
";",
"if",
"(",
"$",
"this",
"->",
"isSorted",
"(",
... | Create the column sorter.
@return string | [
"Create",
"the",
"column",
"sorter",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Column.php#L557-L583 | train | Returns the sorter icon | [
30522,
30524,
4066,
3085,
1007,
1063,
2709,
1005,
1005,
1025,
1065,
1002,
12696,
1027,
1005,
6904,
1011,
4066,
1005,
1025,
1002,
2828,
1027,
1005,
4078,
2278,
1005,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
26354,
15613,
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... |
laravel/framework | src/Illuminate/Events/Dispatcher.php | Dispatcher.forget | public function forget($event)
{
if (Str::contains($event, '*')) {
unset($this->wildcards[$event]);
} else {
unset($this->listeners[$event]);
}
} | php | public function forget($event)
{
if (Str::contains($event, '*')) {
unset($this->wildcards[$event]);
} else {
unset($this->listeners[$event]);
}
} | [
"public",
"function",
"forget",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"Str",
"::",
"contains",
"(",
"$",
"event",
",",
"'*'",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"wildcards",
"[",
"$",
"event",
"]",
")",
";",
"}",
"else",
"{",
"un... | Remove a set of listeners from the dispatcher.
@param string $event
@return void | [
"Remove",
"a",
"set",
"of",
"listeners",
"from",
"the",
"dispatcher",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Events/Dispatcher.php#L515-L522 | train | Forget an event | [
30522,
2270,
3853,
5293,
1006,
1002,
2724,
1007,
1063,
2065,
1006,
2358,
2099,
1024,
1024,
3397,
1006,
1002,
2724,
1010,
1005,
1008,
1005,
1007,
1007,
1063,
4895,
13462,
1006,
1002,
2023,
1011,
1028,
3748,
17965,
1031,
1002,
2724,
1033,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Queue.php | Queue.createObjectPayload | protected function createObjectPayload($job, $queue)
{
$payload = $this->withCreatePayloadHooks($queue, [
'displayName' => $this->getDisplayName($job),
'job' => 'Illuminate\Queue\CallQueuedHandler@call',
'maxTries' => $job->tries ?? null,
'delay' => $this->getJobRetryDelay($job),
'timeout' => $job->timeout ?? null,
'timeoutAt' => $this->getJobExpiration($job),
'data' => [
'commandName' => $job,
'command' => $job,
],
]);
return array_merge($payload, [
'data' => [
'commandName' => get_class($job),
'command' => serialize(clone $job),
],
]);
} | php | protected function createObjectPayload($job, $queue)
{
$payload = $this->withCreatePayloadHooks($queue, [
'displayName' => $this->getDisplayName($job),
'job' => 'Illuminate\Queue\CallQueuedHandler@call',
'maxTries' => $job->tries ?? null,
'delay' => $this->getJobRetryDelay($job),
'timeout' => $job->timeout ?? null,
'timeoutAt' => $this->getJobExpiration($job),
'data' => [
'commandName' => $job,
'command' => $job,
],
]);
return array_merge($payload, [
'data' => [
'commandName' => get_class($job),
'command' => serialize(clone $job),
],
]);
} | [
"protected",
"function",
"createObjectPayload",
"(",
"$",
"job",
",",
"$",
"queue",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"withCreatePayloadHooks",
"(",
"$",
"queue",
",",
"[",
"'displayName'",
"=>",
"$",
"this",
"->",
"getDisplayName",
"(",
"$... | Create a payload for an object-based queue handler.
@param mixed $job
@param string $queue
@return array | [
"Create",
"a",
"payload",
"for",
"an",
"object",
"-",
"based",
"queue",
"handler",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Queue.php#L121-L142 | train | Create payload for queue object | [
30522,
5123,
3853,
3443,
16429,
20614,
4502,
8516,
10441,
2094,
1006,
1002,
3105,
1010,
1002,
24240,
1007,
1063,
1002,
18093,
1027,
1002,
2023,
1011,
1028,
2007,
16748,
3686,
4502,
8516,
10441,
16425,
14659,
2015,
1006,
1002,
24240,
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 | libs/HTML/QuickForm2/Node.php | HTML_QuickForm2_Node.removeRule | public function removeRule(HTML_QuickForm2_Rule $rule)
{
foreach ($this->rules as $i => $r) {
if ($r[0] === $rule) {
unset($this->rules[$i]);
break;
}
}
return $rule;
} | php | public function removeRule(HTML_QuickForm2_Rule $rule)
{
foreach ($this->rules as $i => $r) {
if ($r[0] === $rule) {
unset($this->rules[$i]);
break;
}
}
return $rule;
} | [
"public",
"function",
"removeRule",
"(",
"HTML_QuickForm2_Rule",
"$",
"rule",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"i",
"=>",
"$",
"r",
")",
"{",
"if",
"(",
"$",
"r",
"[",
"0",
"]",
"===",
"$",
"rule",
")",
"{",
"unset... | Removes a validation rule
The method will *not* throw an Exception if the rule wasn't added to the
element.
@param HTML_QuickForm2_Rule Validation rule to remove
@return HTML_QuickForm2_Rule Removed rule | [
"Removes",
"a",
"validation",
"rule"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Node.php#L528-L537 | train | Removes a rule from the list of rules | [
30522,
2270,
3853,
6366,
6820,
2571,
1006,
16129,
1035,
4248,
14192,
2475,
1035,
3627,
1002,
3627,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
3513,
2004,
1002,
1045,
1027,
1028,
1002,
1054,
1007,
1063,
2065,
1006,
1002,
1054,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Db.php | Db.recordProfiling | public function recordProfiling()
{
if (is_null($this->connection)) {
return;
}
// turn off the profiler so we don't profile the following queries
self::$profiling = false;
foreach ($this->queriesProfiling as $query => $info) {
$time = $info['sum_time_ms'];
$time = Common::forceDotAsSeparatorForDecimalPoint($time);
$count = $info['count'];
$queryProfiling = "INSERT INTO " . Common::prefixTable('log_profiling') . "
(query,count,sum_time_ms) VALUES (?,$count,$time)
ON DUPLICATE KEY UPDATE count=count+$count,sum_time_ms=sum_time_ms+$time";
$this->query($queryProfiling, array($query));
}
// turn back on profiling
self::$profiling = true;
} | php | public function recordProfiling()
{
if (is_null($this->connection)) {
return;
}
// turn off the profiler so we don't profile the following queries
self::$profiling = false;
foreach ($this->queriesProfiling as $query => $info) {
$time = $info['sum_time_ms'];
$time = Common::forceDotAsSeparatorForDecimalPoint($time);
$count = $info['count'];
$queryProfiling = "INSERT INTO " . Common::prefixTable('log_profiling') . "
(query,count,sum_time_ms) VALUES (?,$count,$time)
ON DUPLICATE KEY UPDATE count=count+$count,sum_time_ms=sum_time_ms+$time";
$this->query($queryProfiling, array($query));
}
// turn back on profiling
self::$profiling = true;
} | [
"public",
"function",
"recordProfiling",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"{",
"return",
";",
"}",
"// turn off the profiler so we don't profile the following queries",
"self",
"::",
"$",
"profiling",
"=",
"false... | When destroyed, if SQL profiled enabled, logs the SQL profiling information | [
"When",
"destroyed",
"if",
"SQL",
"profiled",
"enabled",
"logs",
"the",
"SQL",
"profiling",
"information"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Db.php#L99-L121 | train | Records the query profiling | [
30522,
2270,
3853,
2501,
21572,
8873,
2989,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
4434,
1007,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
2735,
2125,
1996,
6337,
2099,
2061,
2057,
2123,
1005,
1056,
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/Security/Http/Firewall/SwitchUserListener.php | SwitchUserListener.attemptSwitchUser | private function attemptSwitchUser(Request $request, $username)
{
$token = $this->tokenStorage->getToken();
$originalToken = $this->getOriginalToken($token);
if (null !== $originalToken) {
if ($token->getUsername() === $username) {
return $token;
}
throw new \LogicException(sprintf('You are already switched to "%s" user.', $token->getUsername()));
}
$user = $this->provider->loadUserByUsername($username);
if (false === $this->accessDecisionManager->decide($token, [$this->role], $user)) {
$exception = new AccessDeniedException();
$exception->setAttributes($this->role);
throw $exception;
}
if (null !== $this->logger) {
$this->logger->info('Attempting to switch to user.', ['username' => $username]);
}
$this->userChecker->checkPostAuth($user);
$roles = $user->getRoles();
$roles[] = new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $this->tokenStorage->getToken(), false);
$token = new SwitchUserToken($user, $user->getPassword(), $this->providerKey, $roles, $token);
if (null !== $this->dispatcher) {
$switchEvent = new SwitchUserEvent($request, $token->getUser(), $token);
$this->dispatcher->dispatch($switchEvent, SecurityEvents::SWITCH_USER);
// use the token from the event in case any listeners have replaced it.
$token = $switchEvent->getToken();
}
return $token;
} | php | private function attemptSwitchUser(Request $request, $username)
{
$token = $this->tokenStorage->getToken();
$originalToken = $this->getOriginalToken($token);
if (null !== $originalToken) {
if ($token->getUsername() === $username) {
return $token;
}
throw new \LogicException(sprintf('You are already switched to "%s" user.', $token->getUsername()));
}
$user = $this->provider->loadUserByUsername($username);
if (false === $this->accessDecisionManager->decide($token, [$this->role], $user)) {
$exception = new AccessDeniedException();
$exception->setAttributes($this->role);
throw $exception;
}
if (null !== $this->logger) {
$this->logger->info('Attempting to switch to user.', ['username' => $username]);
}
$this->userChecker->checkPostAuth($user);
$roles = $user->getRoles();
$roles[] = new SwitchUserRole('ROLE_PREVIOUS_ADMIN', $this->tokenStorage->getToken(), false);
$token = new SwitchUserToken($user, $user->getPassword(), $this->providerKey, $roles, $token);
if (null !== $this->dispatcher) {
$switchEvent = new SwitchUserEvent($request, $token->getUser(), $token);
$this->dispatcher->dispatch($switchEvent, SecurityEvents::SWITCH_USER);
// use the token from the event in case any listeners have replaced it.
$token = $switchEvent->getToken();
}
return $token;
} | [
"private",
"function",
"attemptSwitchUser",
"(",
"Request",
"$",
"request",
",",
"$",
"username",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"tokenStorage",
"->",
"getToken",
"(",
")",
";",
"$",
"originalToken",
"=",
"$",
"this",
"->",
"getOriginalTok... | Attempts to switch to another user.
@param Request $request A Request instance
@param string $username
@return TokenInterface|null The new TokenInterface if successfully switched, null otherwise
@throws \LogicException
@throws AccessDeniedException | [
"Attempts",
"to",
"switch",
"to",
"another",
"user",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php#L125-L166 | train | Try to switch to a user | [
30522,
2797,
3853,
4740,
9148,
10649,
20330,
1006,
5227,
1002,
5227,
1010,
1002,
5310,
18442,
1007,
1063,
1002,
19204,
1027,
1002,
2023,
1011,
1028,
19204,
23809,
4270,
1011,
1028,
2131,
18715,
2368,
1006,
1007,
1025,
1002,
2434,
18715,
236... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.