repo stringclasses 21 values | path stringlengths 10 105 | func_name stringlengths 6 64 | original_string stringlengths 105 15.6k | language stringclasses 1 value | code stringlengths 105 15.6k | code_tokens listlengths 29 2.15k | docstring stringlengths 11 2.85k | docstring_tokens listlengths 1 290 | sha stringclasses 21 values | url stringlengths 100 194 | partition stringclasses 1 value | summary stringlengths 8 319 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
laravel/framework | src/Illuminate/Container/Container.php | Container.tagged | public function tagged($tag)
{
if (! isset($this->tags[$tag])) {
return [];
}
return new RewindableGenerator(function () use ($tag) {
foreach ($this->tags[$tag] as $abstract) {
yield $this->make($abstract);
}
}, count($this->tags[$tag]));
} | php | public function tagged($tag)
{
if (! isset($this->tags[$tag])) {
return [];
}
return new RewindableGenerator(function () use ($tag) {
foreach ($this->tags[$tag] as $abstract) {
yield $this->make($abstract);
}
}, count($this->tags[$tag]));
} | [
"public",
"function",
"tagged",
"(",
"$",
"tag",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"new",
"RewindableGenerator",
"(",
"function",
"(",
"... | Resolve all of the bindings for a given tag.
@param string $tag
@return iterable | [
"Resolve",
"all",
"of",
"the",
"bindings",
"for",
"a",
"given",
"tag",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L462-L473 | train | Return an array of tagged abstracts | [
30522,
2270,
3853,
26610,
1006,
1002,
6415,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
22073,
1031,
1002,
6415,
1033,
1007,
1007,
1063,
2709,
1031,
1033,
1025,
1065,
2709,
2047,
2128,
11101,
3085,
6914,
6906,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Twig/TwigExtension.php | TwigExtension.nicetimeFunc | public function nicetimeFunc($date, $long_strings = true, $show_tense = true)
{
if (empty($date)) {
return $this->grav['language']->translate('GRAV.NICETIME.NO_DATE_PROVIDED', null, true);
}
if ($long_strings) {
$periods = [
'NICETIME.SECOND',
'NICETIME.MINUTE',
'NICETIME.HOUR',
'NICETIME.DAY',
'NICETIME.WEEK',
'NICETIME.MONTH',
'NICETIME.YEAR',
'NICETIME.DECADE'
];
} else {
$periods = [
'NICETIME.SEC',
'NICETIME.MIN',
'NICETIME.HR',
'NICETIME.DAY',
'NICETIME.WK',
'NICETIME.MO',
'NICETIME.YR',
'NICETIME.DEC'
];
}
$lengths = ['60', '60', '24', '7', '4.35', '12', '10'];
$now = time();
// check if unix timestamp
if ((string)(int)$date === (string)$date) {
$unix_date = $date;
} else {
$unix_date = strtotime($date);
}
// check validity of date
if (empty($unix_date)) {
return $this->grav['language']->translate('GRAV.NICETIME.BAD_DATE', null, true);
}
// is it future date or past date
if ($now > $unix_date) {
$difference = $now - $unix_date;
$tense = $this->grav['language']->translate('GRAV.NICETIME.AGO', null, true);
} elseif ($now == $unix_date) {
$difference = $now - $unix_date;
$tense = $this->grav['language']->translate('GRAV.NICETIME.JUST_NOW', null, false);
} else {
$difference = $unix_date - $now;
$tense = $this->grav['language']->translate('GRAV.NICETIME.FROM_NOW', null, true);
}
for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if ($difference != 1) {
$periods[$j] .= '_PLURAL';
}
if ($this->grav['language']->getTranslation($this->grav['language']->getLanguage(),
$periods[$j] . '_MORE_THAN_TWO')
) {
if ($difference > 2) {
$periods[$j] .= '_MORE_THAN_TWO';
}
}
$periods[$j] = $this->grav['language']->translate('GRAV.'.$periods[$j], null, true);
if ($now == $unix_date) {
return $tense;
}
$time = "{$difference} {$periods[$j]}";
$time .= $show_tense ? " {$tense}" : '';
return $time;
} | php | public function nicetimeFunc($date, $long_strings = true, $show_tense = true)
{
if (empty($date)) {
return $this->grav['language']->translate('GRAV.NICETIME.NO_DATE_PROVIDED', null, true);
}
if ($long_strings) {
$periods = [
'NICETIME.SECOND',
'NICETIME.MINUTE',
'NICETIME.HOUR',
'NICETIME.DAY',
'NICETIME.WEEK',
'NICETIME.MONTH',
'NICETIME.YEAR',
'NICETIME.DECADE'
];
} else {
$periods = [
'NICETIME.SEC',
'NICETIME.MIN',
'NICETIME.HR',
'NICETIME.DAY',
'NICETIME.WK',
'NICETIME.MO',
'NICETIME.YR',
'NICETIME.DEC'
];
}
$lengths = ['60', '60', '24', '7', '4.35', '12', '10'];
$now = time();
// check if unix timestamp
if ((string)(int)$date === (string)$date) {
$unix_date = $date;
} else {
$unix_date = strtotime($date);
}
// check validity of date
if (empty($unix_date)) {
return $this->grav['language']->translate('GRAV.NICETIME.BAD_DATE', null, true);
}
// is it future date or past date
if ($now > $unix_date) {
$difference = $now - $unix_date;
$tense = $this->grav['language']->translate('GRAV.NICETIME.AGO', null, true);
} elseif ($now == $unix_date) {
$difference = $now - $unix_date;
$tense = $this->grav['language']->translate('GRAV.NICETIME.JUST_NOW', null, false);
} else {
$difference = $unix_date - $now;
$tense = $this->grav['language']->translate('GRAV.NICETIME.FROM_NOW', null, true);
}
for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if ($difference != 1) {
$periods[$j] .= '_PLURAL';
}
if ($this->grav['language']->getTranslation($this->grav['language']->getLanguage(),
$periods[$j] . '_MORE_THAN_TWO')
) {
if ($difference > 2) {
$periods[$j] .= '_MORE_THAN_TWO';
}
}
$periods[$j] = $this->grav['language']->translate('GRAV.'.$periods[$j], null, true);
if ($now == $unix_date) {
return $tense;
}
$time = "{$difference} {$periods[$j]}";
$time .= $show_tense ? " {$tense}" : '';
return $time;
} | [
"public",
"function",
"nicetimeFunc",
"(",
"$",
"date",
",",
"$",
"long_strings",
"=",
"true",
",",
"$",
"show_tense",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"date",
")",
")",
"{",
"return",
"$",
"this",
"->",
"grav",
"[",
"'language'",... | displays a facebook style 'time ago' formatted date/time
@param string $date
@param bool $long_strings
@param bool $show_tense
@return bool | [
"displays",
"a",
"facebook",
"style",
"time",
"ago",
"formatted",
"date",
"/",
"time"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TwigExtension.php#L489-L577 | train | Return nicetime string | [
30522,
2270,
3853,
3835,
7292,
11263,
12273,
1006,
1002,
3058,
1010,
1002,
2146,
1035,
7817,
1027,
2995,
1010,
1002,
2265,
1035,
9049,
1027,
2995,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
3058,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
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... |
laravel/framework | src/Illuminate/Database/Query/Grammars/Grammar.php | Grammar.compileUpdate | public function compileUpdate(Builder $query, $values)
{
$table = $this->wrapTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements.
$columns = collect($values)->map(function ($value, $key) {
return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
// If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries
// can get join statements to attach to other tables when they're needed.
$joins = '';
if (isset($query->joins)) {
$joins = ' '.$this->compileJoins($query, $query->joins);
}
// Of course, update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run.
$wheres = $this->compileWheres($query);
return trim("update {$table}{$joins} set $columns $wheres");
} | php | public function compileUpdate(Builder $query, $values)
{
$table = $this->wrapTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements.
$columns = collect($values)->map(function ($value, $key) {
return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
// If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries
// can get join statements to attach to other tables when they're needed.
$joins = '';
if (isset($query->joins)) {
$joins = ' '.$this->compileJoins($query, $query->joins);
}
// Of course, update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run.
$wheres = $this->compileWheres($query);
return trim("update {$table}{$joins} set $columns $wheres");
} | [
"public",
"function",
"compileUpdate",
"(",
"Builder",
"$",
"query",
",",
"$",
"values",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"wrapTable",
"(",
"$",
"query",
"->",
"from",
")",
";",
"// Each one of the columns in the update statements needs to be wrappe... | Compile an update statement into SQL.
@param \Illuminate\Database\Query\Builder $query
@param array $values
@return string | [
"Compile",
"an",
"update",
"statement",
"into",
"SQL",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/Grammar.php#L908-L934 | train | Compiles an update query into SQL | [
30522,
2270,
3853,
4012,
22090,
6279,
13701,
1006,
12508,
1002,
23032,
1010,
1002,
5300,
1007,
1063,
1002,
2795,
1027,
1002,
2023,
1011,
1028,
10236,
10880,
1006,
1002,
23032,
1011,
1028,
2013,
1007,
1025,
1013,
1013,
2169,
2028,
1997,
1996... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Exporters/CsvExporter.php | CsvExporter.export | public function export()
{
$filename = $this->getTable().'.csv';
$headers = [
'Content-Encoding' => 'UTF-8',
'Content-Type' => 'text/csv;charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"$filename\"",
];
response()->stream(function () {
$handle = fopen('php://output', 'w');
$titles = [];
$this->chunk(function ($records) use ($handle, &$titles) {
if (empty($titles)) {
$titles = $this->getHeaderRowFromRecords($records);
// Add CSV headers
fputcsv($handle, $titles);
}
foreach ($records as $record) {
fputcsv($handle, $this->getFormattedRecord($record));
}
});
// Close the output stream
fclose($handle);
}, 200, $headers)->send();
exit;
} | php | public function export()
{
$filename = $this->getTable().'.csv';
$headers = [
'Content-Encoding' => 'UTF-8',
'Content-Type' => 'text/csv;charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"$filename\"",
];
response()->stream(function () {
$handle = fopen('php://output', 'w');
$titles = [];
$this->chunk(function ($records) use ($handle, &$titles) {
if (empty($titles)) {
$titles = $this->getHeaderRowFromRecords($records);
// Add CSV headers
fputcsv($handle, $titles);
}
foreach ($records as $record) {
fputcsv($handle, $this->getFormattedRecord($record));
}
});
// Close the output stream
fclose($handle);
}, 200, $headers)->send();
exit;
} | [
"public",
"function",
"export",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
".",
"'.csv'",
";",
"$",
"headers",
"=",
"[",
"'Content-Encoding'",
"=>",
"'UTF-8'",
",",
"'Content-Type'",
"=>",
"'text/csv;charset=UTF-8'",
",",
... | {@inheritdoc} | [
"{"
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Exporters/CsvExporter.php#L15-L48 | train | Export the table to CSV | [
30522,
2270,
3853,
9167,
1006,
1007,
1063,
1002,
5371,
18442,
1027,
1002,
2023,
1011,
1028,
2131,
10880,
1006,
1007,
1012,
1005,
1012,
20116,
2615,
1005,
1025,
1002,
20346,
2015,
1027,
1031,
1005,
4180,
1011,
17181,
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/Database/Query/Grammars/PostgresGrammar.php | PostgresGrammar.whereBasic | protected function whereBasic(Builder $query, $where)
{
if (Str::contains(strtolower($where['operator']), 'like')) {
return sprintf(
'%s::text %s %s',
$this->wrap($where['column']),
$where['operator'],
$this->parameter($where['value'])
);
}
return parent::whereBasic($query, $where);
} | php | protected function whereBasic(Builder $query, $where)
{
if (Str::contains(strtolower($where['operator']), 'like')) {
return sprintf(
'%s::text %s %s',
$this->wrap($where['column']),
$where['operator'],
$this->parameter($where['value'])
);
}
return parent::whereBasic($query, $where);
} | [
"protected",
"function",
"whereBasic",
"(",
"Builder",
"$",
"query",
",",
"$",
"where",
")",
"{",
"if",
"(",
"Str",
"::",
"contains",
"(",
"strtolower",
"(",
"$",
"where",
"[",
"'operator'",
"]",
")",
",",
"'like'",
")",
")",
"{",
"return",
"sprintf",
... | {@inheritdoc}
@param \Illuminate\Database\Query\Builder $query
@param array $where
@return string | [
"{",
"@inheritdoc",
"}"
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php#L50-L62 | train | Protected whereBasic. Gets the where clause for the query. | [
30522,
5123,
3853,
2073,
22083,
2594,
1006,
12508,
1002,
23032,
1010,
1002,
2073,
1007,
1063,
2065,
1006,
2358,
2099,
1024,
1024,
3397,
1006,
2358,
5339,
12898,
13777,
1006,
1002,
2073,
1031,
1005,
6872,
1005,
1033,
1007,
1010,
1005,
2066,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Filter.php | Filter.setScopeValue | public function setScopeValue($scope, $value)
{
if (is_string($scope)) {
$scope = $this->getScope($scope);
}
$cacheKey = 'scope-'.$scope->scopeName;
$this->putSession($cacheKey, $value);
$scope->value = $value;
} | php | public function setScopeValue($scope, $value)
{
if (is_string($scope)) {
$scope = $this->getScope($scope);
}
$cacheKey = 'scope-'.$scope->scopeName;
$this->putSession($cacheKey, $value);
$scope->value = $value;
} | [
"public",
"function",
"setScopeValue",
"(",
"$",
"scope",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"scope",
"=",
"$",
"this",
"->",
"getScope",
"(",
"$",
"scope",
")",
";",
"}",
"$",
"cacheKey",
... | Sets an scope value for this widget instance. | [
"Sets",
"an",
"scope",
"value",
"for",
"this",
"widget",
"instance",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L866-L876 | train | Set the value of a scope | [
30522,
2270,
3853,
4520,
16186,
10175,
5657,
1006,
1002,
9531,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
9531,
1007,
1007,
1063,
1002,
9531,
1027,
1002,
2023,
1011,
1028,
4152,
16186,
1006,
1002,
9531,
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... |
z-song/laravel-admin | src/Form.php | Form.update | public function update($id, $data = null)
{
$data = ($data) ?: request()->all();
$isEditable = $this->isEditable($data);
if (($response = $this->handleColumnUpdates($id, $data)) instanceof Response) {
return $response;
}
/* @var Model $this->model */
$builder = $this->model();
if ($this->isSoftDeletes) {
$builder = $builder->withTrashed();
}
$this->model = $builder->with($this->getRelations())->findOrFail($id);
$this->setFieldOriginalValue();
// Handle validation errors.
if ($validationMessages = $this->validationMessages($data)) {
if (!$isEditable) {
return back()->withInput()->withErrors($validationMessages);
}
return response()->json(['errors' => Arr::dot($validationMessages->getMessages())], 422);
}
if (($response = $this->prepare($data)) instanceof Response) {
return $response;
}
DB::transaction(function () {
$updates = $this->prepareUpdate($this->updates);
foreach ($updates as $column => $value) {
/* @var Model $this->model */
$this->model->setAttribute($column, $value);
}
$this->model->save();
$this->updateRelation($this->relations);
});
if (($result = $this->callSaved()) instanceof Response) {
return $result;
}
if ($response = $this->ajaxResponse(trans('admin.update_succeeded'))) {
return $response;
}
return $this->redirectAfterUpdate($id);
} | php | public function update($id, $data = null)
{
$data = ($data) ?: request()->all();
$isEditable = $this->isEditable($data);
if (($response = $this->handleColumnUpdates($id, $data)) instanceof Response) {
return $response;
}
/* @var Model $this->model */
$builder = $this->model();
if ($this->isSoftDeletes) {
$builder = $builder->withTrashed();
}
$this->model = $builder->with($this->getRelations())->findOrFail($id);
$this->setFieldOriginalValue();
// Handle validation errors.
if ($validationMessages = $this->validationMessages($data)) {
if (!$isEditable) {
return back()->withInput()->withErrors($validationMessages);
}
return response()->json(['errors' => Arr::dot($validationMessages->getMessages())], 422);
}
if (($response = $this->prepare($data)) instanceof Response) {
return $response;
}
DB::transaction(function () {
$updates = $this->prepareUpdate($this->updates);
foreach ($updates as $column => $value) {
/* @var Model $this->model */
$this->model->setAttribute($column, $value);
}
$this->model->save();
$this->updateRelation($this->relations);
});
if (($result = $this->callSaved()) instanceof Response) {
return $result;
}
if ($response = $this->ajaxResponse(trans('admin.update_succeeded'))) {
return $response;
}
return $this->redirectAfterUpdate($id);
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"(",
"$",
"data",
")",
"?",
":",
"request",
"(",
")",
"->",
"all",
"(",
")",
";",
"$",
"isEditable",
"=",
"$",
"this",
"->",
"isEditable"... | Handle update.
@param int $id
@param null $data
@return bool|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|mixed|null|Response | [
"Handle",
"update",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form.php#L504-L560 | train | Update a single record | [
30522,
2270,
3853,
10651,
1006,
1002,
8909,
1010,
1002,
2951,
1027,
19701,
1007,
1063,
1002,
2951,
1027,
1006,
1002,
2951,
1007,
1029,
1024,
5227,
1006,
1007,
1011,
1028,
2035,
1006,
1007,
1025,
1002,
2003,
2098,
6590,
3468,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | HasAttributes.getRelationshipFromMethod | protected function getRelationshipFromMethod($method)
{
$relation = $this->$method();
if (! $relation instanceof Relation) {
throw new LogicException(sprintf(
'%s::%s must return a relationship instance.', static::class, $method
));
}
return tap($relation->getResults(), function ($results) use ($method) {
$this->setRelation($method, $results);
});
} | php | protected function getRelationshipFromMethod($method)
{
$relation = $this->$method();
if (! $relation instanceof Relation) {
throw new LogicException(sprintf(
'%s::%s must return a relationship instance.', static::class, $method
));
}
return tap($relation->getResults(), function ($results) use ($method) {
$this->setRelation($method, $results);
});
} | [
"protected",
"function",
"getRelationshipFromMethod",
"(",
"$",
"method",
")",
"{",
"$",
"relation",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"if",
"(",
"!",
"$",
"relation",
"instanceof",
"Relation",
")",
"{",
"throw",
"new",
"LogicException"... | Get a relationship value from a method.
@param string $method
@return mixed
@throws \LogicException | [
"Get",
"a",
"relationship",
"value",
"from",
"a",
"method",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L411-L424 | train | Get a relationship from the method. | [
30522,
5123,
3853,
2131,
16570,
10708,
5605,
19699,
5358,
11368,
6806,
2094,
1006,
1002,
4118,
1007,
1063,
1002,
7189,
1027,
1002,
2023,
1011,
1028,
1002,
4118,
1006,
1007,
1025,
2065,
1006,
999,
1002,
7189,
6013,
11253,
7189,
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... |
laravel/framework | src/Illuminate/Foundation/Console/Presets/None.php | None.updateBootstrapping | protected static function updateBootstrapping()
{
file_put_contents(resource_path('sass/app.scss'), ''.PHP_EOL);
copy(__DIR__.'/none-stubs/app.js', resource_path('js/app.js'));
copy(__DIR__.'/none-stubs/bootstrap.js', resource_path('js/bootstrap.js'));
} | php | protected static function updateBootstrapping()
{
file_put_contents(resource_path('sass/app.scss'), ''.PHP_EOL);
copy(__DIR__.'/none-stubs/app.js', resource_path('js/app.js'));
copy(__DIR__.'/none-stubs/bootstrap.js', resource_path('js/bootstrap.js'));
} | [
"protected",
"static",
"function",
"updateBootstrapping",
"(",
")",
"{",
"file_put_contents",
"(",
"resource_path",
"(",
"'sass/app.scss'",
")",
",",
"''",
".",
"PHP_EOL",
")",
";",
"copy",
"(",
"__DIR__",
".",
"'/none-stubs/app.js'",
",",
"resource_path",
"(",
... | Write the stubs for the Sass and JavaScript files.
@return void | [
"Write",
"the",
"stubs",
"for",
"the",
"Sass",
"and",
"JavaScript",
"files",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/Presets/None.php#L55-L60 | train | Update the bootstrapping of the module | [
30522,
5123,
10763,
3853,
10651,
27927,
20528,
14853,
1006,
1007,
1063,
5371,
1035,
2404,
1035,
8417,
1006,
7692,
1035,
4130,
1006,
1005,
21871,
2015,
1013,
10439,
1012,
8040,
4757,
1005,
1007,
1010,
1005,
1005,
1012,
25718,
1035,
1041,
474... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.frontmatter | public function frontmatter($var = null)
{
if ($var) {
$this->frontmatter = (string)$var;
// Update also file object.
$file = $this->file();
if ($file) {
$file->frontmatter((string)$var);
}
// Force content re-processing.
$this->id(time() . md5($this->filePath()));
}
if (!$this->frontmatter) {
$this->header();
}
return $this->frontmatter;
} | php | public function frontmatter($var = null)
{
if ($var) {
$this->frontmatter = (string)$var;
// Update also file object.
$file = $this->file();
if ($file) {
$file->frontmatter((string)$var);
}
// Force content re-processing.
$this->id(time() . md5($this->filePath()));
}
if (!$this->frontmatter) {
$this->header();
}
return $this->frontmatter;
} | [
"public",
"function",
"frontmatter",
"(",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"var",
")",
"{",
"$",
"this",
"->",
"frontmatter",
"=",
"(",
"string",
")",
"$",
"var",
";",
"// Update also file object.",
"$",
"file",
"=",
"$",
"this",
"-... | Gets and Sets the page frontmatter
@param string|null $var
@return string | [
"Gets",
"and",
"Sets",
"the",
"page",
"frontmatter"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L283-L303 | train | Return frontmatter of file | [
30522,
2270,
3853,
2392,
18900,
3334,
1006,
1002,
13075,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
13075,
1007,
1063,
1002,
2023,
1011,
1028,
2392,
18900,
3334,
1027,
1006,
5164,
1007,
1002,
13075,
1025,
1013,
1013,
10651,
2036,
5371,
4874... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/Controller.php | Controller.onHideBackendHint | public function onHideBackendHint()
{
if (!$name = post('name')) {
throw new ApplicationException('Missing a hint name.');
}
$preferences = UserPreference::forUser();
$hiddenHints = $preferences->get('backend::hints.hidden', []);
$hiddenHints[$name] = 1;
$preferences->set('backend::hints.hidden', $hiddenHints);
} | php | public function onHideBackendHint()
{
if (!$name = post('name')) {
throw new ApplicationException('Missing a hint name.');
}
$preferences = UserPreference::forUser();
$hiddenHints = $preferences->get('backend::hints.hidden', []);
$hiddenHints[$name] = 1;
$preferences->set('backend::hints.hidden', $hiddenHints);
} | [
"public",
"function",
"onHideBackendHint",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"name",
"=",
"post",
"(",
"'name'",
")",
")",
"{",
"throw",
"new",
"ApplicationException",
"(",
"'Missing a hint name.'",
")",
";",
"}",
"$",
"preferences",
"=",
"UserPreference",... | Ajax handler to hide a backend hint, once hidden the partial
will no longer display for the user.
@return void | [
"Ajax",
"handler",
"to",
"hide",
"a",
"backend",
"hint",
"once",
"hidden",
"the",
"partial",
"will",
"no",
"longer",
"display",
"for",
"the",
"user",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L689-L700 | train | Hides a backend hint | [
30522,
2270,
3853,
2006,
26100,
5963,
10497,
10606,
2102,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2171,
1027,
2695,
1006,
1005,
2171,
1005,
1007,
1007,
1063,
5466,
2047,
4646,
10288,
24422,
1006,
1005,
4394,
1037,
9374,
2171,
1012,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Element/Select.php | HTML_QuickForm2_Element_Select.loadOptionsFromArray | protected function loadOptionsFromArray(
HTML_QuickForm2_Element_Select_OptionContainer $container, $options
)
{
foreach ($options as $key => $value) {
if (is_array($value)) {
$optgroup = $container->addOptgroup($key);
$this->loadOptionsFromArray($optgroup, $value);
} else {
$container->addOption($value, $key);
}
}
} | php | protected function loadOptionsFromArray(
HTML_QuickForm2_Element_Select_OptionContainer $container, $options
)
{
foreach ($options as $key => $value) {
if (is_array($value)) {
$optgroup = $container->addOptgroup($key);
$this->loadOptionsFromArray($optgroup, $value);
} else {
$container->addOption($value, $key);
}
}
} | [
"protected",
"function",
"loadOptionsFromArray",
"(",
"HTML_QuickForm2_Element_Select_OptionContainer",
"$",
"container",
",",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
... | Adds options from given array into given container
@param HTML_QuickForm2_Element_Select_OptionContainer options will be
added to this container
@param array options array | [
"Adds",
"options",
"from",
"given",
"array",
"into",
"given",
"container"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Element/Select.php#L514-L526 | train | Load Options from array into the Select OptionContainer | [
30522,
5123,
3853,
7170,
7361,
9285,
19699,
9626,
11335,
2100,
1006,
16129,
1035,
4248,
14192,
2475,
1035,
5783,
1035,
7276,
1035,
5724,
8663,
18249,
2121,
1002,
11661,
1010,
1002,
7047,
1007,
1063,
18921,
6776,
1006,
1002,
7047,
2004,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/MessageCatalogue.php | MessageCatalogue.deleteMetadata | public function deleteMetadata($key = '', $domain = 'messages')
{
if ('' == $domain) {
$this->metadata = [];
} elseif ('' == $key) {
unset($this->metadata[$domain]);
} else {
unset($this->metadata[$domain][$key]);
}
} | php | public function deleteMetadata($key = '', $domain = 'messages')
{
if ('' == $domain) {
$this->metadata = [];
} elseif ('' == $key) {
unset($this->metadata[$domain]);
} else {
unset($this->metadata[$domain][$key]);
}
} | [
"public",
"function",
"deleteMetadata",
"(",
"$",
"key",
"=",
"''",
",",
"$",
"domain",
"=",
"'messages'",
")",
"{",
"if",
"(",
"''",
"==",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"metadata",
"=",
"[",
"]",
";",
"}",
"elseif",
"(",
"''",
"=="... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/MessageCatalogue.php#L277-L286 | train | Delete metadata from the current object | [
30522,
2270,
3853,
3972,
12870,
11368,
8447,
2696,
1006,
1002,
3145,
1027,
1005,
30524,
1005,
1027,
1027,
1002,
3145,
1007,
1063,
4895,
13462,
1006,
1002,
2023,
1011,
1028,
27425,
1031,
1002,
5884,
1033,
1007,
1025,
1065,
2842,
1063,
4895,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getInlineMessage | protected function getInlineMessage($attribute, $rule)
{
$inlineEntry = $this->getFromLocalArray($attribute, Str::snake($rule));
return is_array($inlineEntry) && in_array($rule, $this->sizeRules)
? $inlineEntry[$this->getAttributeType($attribute)]
: $inlineEntry;
} | php | protected function getInlineMessage($attribute, $rule)
{
$inlineEntry = $this->getFromLocalArray($attribute, Str::snake($rule));
return is_array($inlineEntry) && in_array($rule, $this->sizeRules)
? $inlineEntry[$this->getAttributeType($attribute)]
: $inlineEntry;
} | [
"protected",
"function",
"getInlineMessage",
"(",
"$",
"attribute",
",",
"$",
"rule",
")",
"{",
"$",
"inlineEntry",
"=",
"$",
"this",
"->",
"getFromLocalArray",
"(",
"$",
"attribute",
",",
"Str",
"::",
"snake",
"(",
"$",
"rule",
")",
")",
";",
"return",
... | Get the proper inline error message for standard and size rules.
@param string $attribute
@param string $rule
@return string|null | [
"Get",
"the",
"proper",
"inline",
"error",
"message",
"for",
"standard",
"and",
"size",
"rules",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/FormatsMessages.php#L73-L80 | train | Get inline message | [
30522,
5123,
3853,
2131,
2378,
4179,
7834,
3736,
3351,
1006,
1002,
17961,
1010,
1002,
3627,
1007,
1063,
1002,
23881,
4765,
2854,
1027,
1002,
2023,
1011,
1028,
2131,
19699,
5358,
4135,
25015,
11335,
2100,
1006,
1002,
17961,
1010,
2358,
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... |
laravel/framework | src/Illuminate/Auth/Middleware/Authorize.php | Authorize.handle | public function handle($request, Closure $next, $ability, ...$models)
{
$this->gate->authorize($ability, $this->getGateArguments($request, $models));
return $next($request);
} | php | public function handle($request, Closure $next, $ability, ...$models)
{
$this->gate->authorize($ability, $this->getGateArguments($request, $models));
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
",",
"$",
"ability",
",",
"...",
"$",
"models",
")",
"{",
"$",
"this",
"->",
"gate",
"->",
"authorize",
"(",
"$",
"ability",
",",
"$",
"this",
"->",
"getGateArguments",
... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@param string $ability
@param array|null ...$models
@return mixed
@throws \Illuminate\Auth\AuthenticationException
@throws \Illuminate\Auth\Access\AuthorizationException | [
"Handle",
"an",
"incoming",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Middleware/Authorize.php#L41-L46 | train | Authorize the request and return the response. | [
30522,
2270,
3853,
5047,
1006,
1002,
5227,
1010,
8503,
1002,
2279,
1010,
1002,
3754,
1010,
1012,
1012,
1012,
1002,
4275,
1007,
1063,
1002,
2023,
1011,
1028,
4796,
1011,
1028,
3166,
4697,
1006,
1002,
3754,
1010,
1002,
2023,
1011,
1028,
213... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Feedback/API.php | API.sendFeedbackForFeature | public function sendFeedbackForFeature($featureName, $like, $message = false)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeViewAccess();
$featureName = $this->getEnglishTranslationForFeatureName($featureName);
$likeText = 'Yes';
if (empty($like)) {
$likeText = 'No';
}
$body = sprintf("Feature: %s\nLike: %s\n", $featureName, $likeText, $message);
$feedbackMessage = "";
if (!empty($message) && $message != 'undefined') {
$feedbackMessage = sprintf("Feedback:\n%s\n", trim($message));
}
$body .= $feedbackMessage ? $feedbackMessage : " \n";
$subject = sprintf("%s for %s %s",
empty($like) ? "-1" : "+1",
$featureName,
empty($feedbackMessage) ? "" : "(w/ feedback)"
);
$this->sendMail($subject, $body);
} | php | public function sendFeedbackForFeature($featureName, $like, $message = false)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeViewAccess();
$featureName = $this->getEnglishTranslationForFeatureName($featureName);
$likeText = 'Yes';
if (empty($like)) {
$likeText = 'No';
}
$body = sprintf("Feature: %s\nLike: %s\n", $featureName, $likeText, $message);
$feedbackMessage = "";
if (!empty($message) && $message != 'undefined') {
$feedbackMessage = sprintf("Feedback:\n%s\n", trim($message));
}
$body .= $feedbackMessage ? $feedbackMessage : " \n";
$subject = sprintf("%s for %s %s",
empty($like) ? "-1" : "+1",
$featureName,
empty($feedbackMessage) ? "" : "(w/ feedback)"
);
$this->sendMail($subject, $body);
} | [
"public",
"function",
"sendFeedbackForFeature",
"(",
"$",
"featureName",
",",
"$",
"like",
",",
"$",
"message",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserIsNotAnonymous",
"(",
")",
";",
"Piwik",
"::",
"checkUserHasSomeViewAccess",
"(",
")",
";",
"$",
... | Sends feedback for a specific feature to the Matomo team or alternatively to the email address configured in the
config: "feedback_email_address".
@param string $featureName The name of a feature you want to give feedback to.
@param bool|int $like Whether you like the feature or not
@param string|bool $message A message containing the actual feedback | [
"Sends",
"feedback",
"for",
"a",
"specific",
"feature",
"to",
"the",
"Matomo",
"team",
"or",
"alternatively",
"to",
"the",
"email",
"address",
"configured",
"in",
"the",
"config",
":",
"feedback_email_address",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Feedback/API.php#L34-L61 | train | Sends a feedback message for a feature name | [
30522,
2270,
3853,
4604,
7959,
2098,
5963,
29278,
7959,
4017,
5397,
1006,
1002,
3444,
18442,
1010,
1002,
2066,
1010,
1002,
4471,
1027,
6270,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
2483,
17048,
6761,
4890,
27711,
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... |
z-song/laravel-admin | src/Admin.php | Admin.getModel | public function getModel($model)
{
if ($model instanceof Model) {
return $model;
}
if (is_string($model) && class_exists($model)) {
return $this->getModel(new $model());
}
throw new InvalidArgumentException("$model is not a valid model");
} | php | public function getModel($model)
{
if ($model instanceof Model) {
return $model;
}
if (is_string($model) && class_exists($model)) {
return $this->getModel(new $model());
}
throw new InvalidArgumentException("$model is not a valid model");
} | [
"public",
"function",
"getModel",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"instanceof",
"Model",
")",
"{",
"return",
"$",
"model",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"model",
")",
"&&",
"class_exists",
"(",
"$",
"model",
")",
... | @param $model
@return mixed | [
"@param",
"$model"
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Admin.php#L140-L151 | train | Get Model Object | [
30522,
30524,
1007,
1063,
2065,
1006,
1002,
2944,
6013,
11253,
2944,
1007,
1063,
2709,
1002,
2944,
1025,
1065,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
2944,
1007,
1004,
1004,
2465,
1035,
6526,
1006,
1002,
2944,
1007,
1007,
1063,
2709,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Url.php | Url.isLocalUrl | public static function isLocalUrl($url)
{
if (empty($url)) {
return true;
}
// handle host name mangling
$requestUri = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : '';
$parseRequest = @parse_url($requestUri);
$hosts = array(self::getHost(), self::getCurrentHost());
if (!empty($parseRequest['host'])) {
$hosts[] = $parseRequest['host'];
}
// drop port numbers from hostnames and IP addresses
$hosts = array_map(array('self', 'getHostSanitized'), $hosts);
$disableHostCheck = Config::getInstance()->General['enable_trusted_host_check'] == 0;
// compare scheme and host
$parsedUrl = @parse_url($url);
$host = IPUtils::sanitizeIp(@$parsedUrl['host']);
return !empty($host)
&& ($disableHostCheck || in_array($host, $hosts))
&& !empty($parsedUrl['scheme'])
&& in_array($parsedUrl['scheme'], array('http', 'https'));
} | php | public static function isLocalUrl($url)
{
if (empty($url)) {
return true;
}
// handle host name mangling
$requestUri = isset($_SERVER['SCRIPT_URI']) ? $_SERVER['SCRIPT_URI'] : '';
$parseRequest = @parse_url($requestUri);
$hosts = array(self::getHost(), self::getCurrentHost());
if (!empty($parseRequest['host'])) {
$hosts[] = $parseRequest['host'];
}
// drop port numbers from hostnames and IP addresses
$hosts = array_map(array('self', 'getHostSanitized'), $hosts);
$disableHostCheck = Config::getInstance()->General['enable_trusted_host_check'] == 0;
// compare scheme and host
$parsedUrl = @parse_url($url);
$host = IPUtils::sanitizeIp(@$parsedUrl['host']);
return !empty($host)
&& ($disableHostCheck || in_array($host, $hosts))
&& !empty($parsedUrl['scheme'])
&& in_array($parsedUrl['scheme'], array('http', 'https'));
} | [
"public",
"static",
"function",
"isLocalUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"return",
"true",
";",
"}",
"// handle host name mangling",
"$",
"requestUri",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_U... | Returns `true` if the URL points to something on the same host, `false` if otherwise.
@param string $url
@return bool True if local; false otherwise.
@api | [
"Returns",
"true",
"if",
"the",
"URL",
"points",
"to",
"something",
"on",
"the",
"same",
"host",
"false",
"if",
"otherwise",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Url.php#L536-L561 | train | Check if the given URL is a local URL | [
30522,
2270,
10763,
3853,
2003,
4135,
9289,
3126,
2140,
1006,
1002,
24471,
2140,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
24471,
2140,
1007,
1007,
1063,
2709,
2995,
1025,
1065,
1013,
1013,
5047,
3677,
2171,
2158,
18483,
1002,
5227,
9496,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ImportExportController.php | ImportExportController.checkPermissionsForType | protected function checkPermissionsForType($type)
{
if (
($permissions = $this->getConfig($type.'[permissions]')) &&
(!BackendAuth::getUser()->hasAnyAccess((array) $permissions))
) {
return Response::make(View::make('backend::access_denied'), 403);
}
} | php | protected function checkPermissionsForType($type)
{
if (
($permissions = $this->getConfig($type.'[permissions]')) &&
(!BackendAuth::getUser()->hasAnyAccess((array) $permissions))
) {
return Response::make(View::make('backend::access_denied'), 403);
}
} | [
"protected",
"function",
"checkPermissionsForType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"(",
"$",
"permissions",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"$",
"type",
".",
"'[permissions]'",
")",
")",
"&&",
"(",
"!",
"BackendAuth",
"::",
"getUser",
"... | Checks to see if the import/export is controlled by permissions
and if the logged in user has permissions.
@return \View | [
"Checks",
"to",
"see",
"if",
"the",
"import",
"/",
"export",
"is",
"controlled",
"by",
"permissions",
"and",
"if",
"the",
"logged",
"in",
"user",
"has",
"permissions",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/ImportExportController.php#L676-L684 | train | Check if user has any access to the given type | [
30522,
5123,
3853,
4638,
4842,
25481,
22747,
11589,
18863,
1006,
1002,
2828,
1007,
1063,
2065,
1006,
1006,
1002,
6656,
2015,
1027,
1002,
2023,
1011,
1028,
2131,
8663,
8873,
2290,
1006,
1002,
2828,
1012,
1005,
1031,
6656,
2015,
1033,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Widget/WidgetsList.php | WidgetsList.addWidgetConfig | public function addWidgetConfig(WidgetConfig $widget)
{
if ($widget instanceof WidgetContainerConfig) {
$this->addContainer($widget);
} elseif (Development::isEnabled()) {
$this->checkIsValidWidget($widget);
}
$this->widgets[] = $widget;
} | php | public function addWidgetConfig(WidgetConfig $widget)
{
if ($widget instanceof WidgetContainerConfig) {
$this->addContainer($widget);
} elseif (Development::isEnabled()) {
$this->checkIsValidWidget($widget);
}
$this->widgets[] = $widget;
} | [
"public",
"function",
"addWidgetConfig",
"(",
"WidgetConfig",
"$",
"widget",
")",
"{",
"if",
"(",
"$",
"widget",
"instanceof",
"WidgetContainerConfig",
")",
"{",
"$",
"this",
"->",
"addContainer",
"(",
"$",
"widget",
")",
";",
"}",
"elseif",
"(",
"Developmen... | Adds a new widget to the widget config. Please make sure the widget is enabled before adding a widget as
no such checks will be performed.
@param WidgetConfig $widget | [
"Adds",
"a",
"new",
"widget",
"to",
"the",
"widget",
"config",
".",
"Please",
"make",
"sure",
"the",
"widget",
"is",
"enabled",
"before",
"adding",
"a",
"widget",
"as",
"no",
"such",
"checks",
"will",
"be",
"performed",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Widget/WidgetsList.php#L51-L60 | train | Adds a widget to the list of widgets | [
30522,
2270,
3853,
5587,
9148,
24291,
8663,
8873,
2290,
1006,
15536,
24291,
8663,
8873,
2290,
1002,
15536,
24291,
1007,
1063,
2065,
1006,
1002,
15536,
24291,
6013,
11253,
15536,
24291,
8663,
18249,
2121,
8663,
8873,
2290,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Sqlite.php | Zend_Cache_Backend_Sqlite._checkAndBuildStructure | private function _checkAndBuildStructure()
{
if (!($this->_structureChecked)) {
if (!$this->_checkStructureVersion()) {
$this->_buildStructure();
if (!$this->_checkStructureVersion()) {
Zend_Cache::throwException("Impossible to build cache structure in " . $this->_options['cache_db_complete_path']);
}
}
$this->_structureChecked = true;
}
return true;
} | php | private function _checkAndBuildStructure()
{
if (!($this->_structureChecked)) {
if (!$this->_checkStructureVersion()) {
$this->_buildStructure();
if (!$this->_checkStructureVersion()) {
Zend_Cache::throwException("Impossible to build cache structure in " . $this->_options['cache_db_complete_path']);
}
}
$this->_structureChecked = true;
}
return true;
} | [
"private",
"function",
"_checkAndBuildStructure",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"_structureChecked",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_checkStructureVersion",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_buildStruct... | Check if the database structure is ok (with the good version), if no : build it
@throws Zend_Cache_Exception
@return boolean True if ok | [
"Check",
"if",
"the",
"database",
"structure",
"is",
"ok",
"(",
"with",
"the",
"good",
"version",
")",
"if",
"no",
":",
"build",
"it"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Sqlite.php#L664-L676 | train | Check and build cache structure | [
30522,
2797,
3853,
1035,
4638,
5685,
8569,
4014,
5104,
18300,
5397,
1006,
1007,
1063,
2065,
1006,
999,
1006,
1002,
2023,
1011,
1028,
1035,
3252,
5403,
18141,
1007,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
14148,
18300,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php | CachePoolListCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->table(['Pool name'], array_map(function ($pool) {
return [$pool];
}, $this->poolNames));
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->table(['Pool name'], array_map(function ($pool) {
return [$pool];
}, $this->poolNames));
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"io",
"->",
"table",
"(",
"[",
"'Pool... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolListCommand.php#L54-L61 | train | Print the pool names | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
22834,
1027,
2047,
25353,
2213,
14876,
4890,
21756,
2571,
1006,
1002,
7953,
1010,
1002,
6434,
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 | libs/Zend/Mail/Storage/Imap.php | Zend_Mail_Storage_Imap.getSize | public function getSize($id = 0)
{
if ($id) {
return $this->_protocol->fetch('RFC822.SIZE', $id);
}
return $this->_protocol->fetch('RFC822.SIZE', 1, INF);
} | php | public function getSize($id = 0)
{
if ($id) {
return $this->_protocol->fetch('RFC822.SIZE', $id);
}
return $this->_protocol->fetch('RFC822.SIZE', 1, INF);
} | [
"public",
"function",
"getSize",
"(",
"$",
"id",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"_protocol",
"->",
"fetch",
"(",
"'RFC822.SIZE'",
",",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_prot... | get a list of messages with number and size
@param int $id number of message
@return int|array size of given message of list with all messages as array(num => size)
@throws Zend_Mail_Protocol_Exception | [
"get",
"a",
"list",
"of",
"messages",
"with",
"number",
"and",
"size"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Imap.php#L146-L152 | train | Get size of the certificate | [
30522,
2270,
3853,
4152,
4697,
1006,
1002,
8909,
1027,
1014,
1007,
1063,
2065,
1006,
1002,
8909,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
1035,
8778,
1011,
1028,
18584,
1006,
1005,
14645,
2620,
19317,
1012,
2946,
1005,
1010,
1002,
8909,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/API/RowEvolution.php | RowEvolution.cleanOriginalLabel | private function cleanOriginalLabel($label)
{
$label = str_replace(LabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label);
$label = SafeDecodeLabel::decodeLabelSafe($label);
return $label;
} | php | private function cleanOriginalLabel($label)
{
$label = str_replace(LabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label);
$label = SafeDecodeLabel::decodeLabelSafe($label);
return $label;
} | [
"private",
"function",
"cleanOriginalLabel",
"(",
"$",
"label",
")",
"{",
"$",
"label",
"=",
"str_replace",
"(",
"LabelFilter",
"::",
"SEPARATOR_RECURSIVE_LABEL",
",",
"' - '",
",",
"$",
"label",
")",
";",
"$",
"label",
"=",
"SafeDecodeLabel",
"::",
"decodeLab... | Returns a prettier, more comprehensible version of a row evolution label for display. | [
"Returns",
"a",
"prettier",
"more",
"comprehensible",
"version",
"of",
"a",
"row",
"evolution",
"label",
"for",
"display",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/RowEvolution.php#L535-L540 | train | Clean original label | [
30522,
2797,
3853,
4550,
10050,
24965,
20470,
2884,
1006,
1002,
3830,
1007,
1063,
1002,
3830,
1027,
2358,
2099,
1035,
5672,
1006,
3830,
8873,
21928,
1024,
1024,
19802,
25879,
2953,
1035,
28667,
9236,
3512,
1035,
3830,
1010,
1005,
1011,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Menu/MenuAbstract.php | MenuAbstract.buildMenuItem | private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false, $icon = false, $onclick = false)
{
if (!isset($this->menu[$menuName])) {
$this->menu[$menuName] = array(
'_hasSubmenu' => false,
'_order' => $order
);
}
if (empty($subMenuName)) {
$this->menu[$menuName]['_url'] = $url;
$this->menu[$menuName]['_order'] = $order;
$this->menu[$menuName]['_name'] = $menuName;
$this->menu[$menuName]['_tooltip'] = $tooltip;
if (!empty($this->menuIcons[$menuName])) {
$this->menu[$menuName]['_icon'] = $this->menuIcons[$menuName];
} else {
$this->menu[$menuName]['_icon'] = '';
}
}
if (!empty($subMenuName)) {
$this->menu[$menuName][$subMenuName]['_url'] = $url;
$this->menu[$menuName][$subMenuName]['_order'] = $order;
$this->menu[$menuName][$subMenuName]['_name'] = $subMenuName;
$this->menu[$menuName][$subMenuName]['_tooltip'] = $tooltip;
$this->menu[$menuName][$subMenuName]['_icon'] = $icon;
$this->menu[$menuName][$subMenuName]['_onclick'] = $onclick;
$this->menu[$menuName]['_hasSubmenu'] = true;
if (!array_key_exists('_tooltip', $this->menu[$menuName])) {
$this->menu[$menuName]['_tooltip'] = $tooltip;
}
}
} | php | private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false, $icon = false, $onclick = false)
{
if (!isset($this->menu[$menuName])) {
$this->menu[$menuName] = array(
'_hasSubmenu' => false,
'_order' => $order
);
}
if (empty($subMenuName)) {
$this->menu[$menuName]['_url'] = $url;
$this->menu[$menuName]['_order'] = $order;
$this->menu[$menuName]['_name'] = $menuName;
$this->menu[$menuName]['_tooltip'] = $tooltip;
if (!empty($this->menuIcons[$menuName])) {
$this->menu[$menuName]['_icon'] = $this->menuIcons[$menuName];
} else {
$this->menu[$menuName]['_icon'] = '';
}
}
if (!empty($subMenuName)) {
$this->menu[$menuName][$subMenuName]['_url'] = $url;
$this->menu[$menuName][$subMenuName]['_order'] = $order;
$this->menu[$menuName][$subMenuName]['_name'] = $subMenuName;
$this->menu[$menuName][$subMenuName]['_tooltip'] = $tooltip;
$this->menu[$menuName][$subMenuName]['_icon'] = $icon;
$this->menu[$menuName][$subMenuName]['_onclick'] = $onclick;
$this->menu[$menuName]['_hasSubmenu'] = true;
if (!array_key_exists('_tooltip', $this->menu[$menuName])) {
$this->menu[$menuName]['_tooltip'] = $tooltip;
}
}
} | [
"private",
"function",
"buildMenuItem",
"(",
"$",
"menuName",
",",
"$",
"subMenuName",
",",
"$",
"url",
",",
"$",
"order",
"=",
"50",
",",
"$",
"tooltip",
"=",
"false",
",",
"$",
"icon",
"=",
"false",
",",
"$",
"onclick",
"=",
"false",
")",
"{",
"i... | Builds a single menu item
@param string $menuName
@param string $subMenuName
@param string $url
@param int $order
@param bool|string $tooltip Tooltip to display. | [
"Builds",
"a",
"single",
"menu",
"item"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Menu/MenuAbstract.php#L152-L185 | train | Build menu item | [
30522,
2797,
3853,
3857,
3549,
14663,
6633,
1006,
1002,
12183,
18442,
1010,
1002,
4942,
3549,
9521,
4168,
1010,
1002,
24471,
2140,
1010,
1002,
2344,
1027,
2753,
1010,
1002,
6994,
25101,
1027,
6270,
1010,
1002,
12696,
1027,
6270,
1010,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/Grammar.php | Grammar.compileWheres | protected function compileWheres(Builder $query)
{
// Each type of where clauses has its own compiler function which is responsible
// for actually creating the where clauses SQL. This helps keep the code nice
// and maintainable since each clause has a very small method that it uses.
if (is_null($query->wheres)) {
return '';
}
// If we actually have some where clauses, we will strip off the first boolean
// operator, which is added by the query builders for convenience so we can
// avoid checking for the first clauses in each of the compilers methods.
if (count($sql = $this->compileWheresToArray($query)) > 0) {
return $this->concatenateWhereClauses($query, $sql);
}
return '';
} | php | protected function compileWheres(Builder $query)
{
// Each type of where clauses has its own compiler function which is responsible
// for actually creating the where clauses SQL. This helps keep the code nice
// and maintainable since each clause has a very small method that it uses.
if (is_null($query->wheres)) {
return '';
}
// If we actually have some where clauses, we will strip off the first boolean
// operator, which is added by the query builders for convenience so we can
// avoid checking for the first clauses in each of the compilers methods.
if (count($sql = $this->compileWheresToArray($query)) > 0) {
return $this->concatenateWhereClauses($query, $sql);
}
return '';
} | [
"protected",
"function",
"compileWheres",
"(",
"Builder",
"$",
"query",
")",
"{",
"// Each type of where clauses has its own compiler function which is responsible",
"// for actually creating the where clauses SQL. This helps keep the code nice",
"// and maintainable since each clause has a ve... | Compile the "where" portions of the query.
@param \Illuminate\Database\Query\Builder $query
@return string | [
"Compile",
"the",
"where",
"portions",
"of",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/Grammar.php#L178-L195 | train | Compiles the where clauses into a string | [
30522,
5123,
3853,
4012,
22090,
2860,
5886,
2229,
1006,
12508,
1002,
23032,
1007,
1063,
1013,
1013,
2169,
2828,
1997,
2073,
24059,
2038,
2049,
2219,
21624,
3853,
2029,
2003,
3625,
1013,
1013,
2005,
2941,
4526,
1996,
2073,
24059,
29296,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Filesystem.php | Filesystem.copy | public static function copy($source, $dest, $excludePhp = false)
{
if ($excludePhp) {
if (self::hasPHPExtension($source)) {
return true;
}
}
$success = self::tryToCopyFileAndVerifyItWasCopied($source, $dest);
if (!$success) {
$success = self::tryToCopyFileAndVerifyItWasCopied($source, $dest);
}
if (!$success) {
$ex = new FailedCopyException("Error while creating/copying file from $source to <code>" . Common::sanitizeInputValue($dest)
. "</code>. Content of copied file is different.");
$ex->setIsHtmlMessage();
throw $ex;
}
return true;
} | php | public static function copy($source, $dest, $excludePhp = false)
{
if ($excludePhp) {
if (self::hasPHPExtension($source)) {
return true;
}
}
$success = self::tryToCopyFileAndVerifyItWasCopied($source, $dest);
if (!$success) {
$success = self::tryToCopyFileAndVerifyItWasCopied($source, $dest);
}
if (!$success) {
$ex = new FailedCopyException("Error while creating/copying file from $source to <code>" . Common::sanitizeInputValue($dest)
. "</code>. Content of copied file is different.");
$ex->setIsHtmlMessage();
throw $ex;
}
return true;
} | [
"public",
"static",
"function",
"copy",
"(",
"$",
"source",
",",
"$",
"dest",
",",
"$",
"excludePhp",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"excludePhp",
")",
"{",
"if",
"(",
"self",
"::",
"hasPHPExtension",
"(",
"$",
"source",
")",
")",
"{",
"re... | Copies a file from `$source` to `$dest`.
@param string $source A path to a file, eg. './tmp/latest/index.php'. The file must exist.
@param string $dest A path to a file, eg. './index.php'. The file does not have to exist.
@param bool $excludePhp Whether to avoid copying files if the file is related to PHP
(includes .php, .tpl, .twig files).
@throws Exception If the file cannot be copied.
@return true
@api | [
"Copies",
"a",
"file",
"from",
"$source",
"to",
"$dest",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L314-L336 | train | Copy file from source to destination | [
30522,
2270,
10763,
3853,
6100,
1006,
1002,
3120,
1010,
1002,
4078,
2102,
1010,
1002,
23329,
8458,
2361,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
23329,
8458,
2361,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
2038,
8458,
5051,
18413,
6132,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/ArchiveProcessor/Loader.php | Loader.loadExistingArchiveIdFromDb | protected function loadExistingArchiveIdFromDb()
{
$noArchiveFound = array(false, false, false);
// see isArchiveTemporary()
$minDatetimeArchiveProcessedUTC = $this->getMinTimeArchiveProcessed();
if ($this->isArchivingForcedToTrigger()) {
return $noArchiveFound;
}
$idAndVisits = ArchiveSelector::getArchiveIdAndVisits($this->params, $minDatetimeArchiveProcessedUTC);
if (!$idAndVisits) {
return $noArchiveFound;
}
return $idAndVisits;
} | php | protected function loadExistingArchiveIdFromDb()
{
$noArchiveFound = array(false, false, false);
// see isArchiveTemporary()
$minDatetimeArchiveProcessedUTC = $this->getMinTimeArchiveProcessed();
if ($this->isArchivingForcedToTrigger()) {
return $noArchiveFound;
}
$idAndVisits = ArchiveSelector::getArchiveIdAndVisits($this->params, $minDatetimeArchiveProcessedUTC);
if (!$idAndVisits) {
return $noArchiveFound;
}
return $idAndVisits;
} | [
"protected",
"function",
"loadExistingArchiveIdFromDb",
"(",
")",
"{",
"$",
"noArchiveFound",
"=",
"array",
"(",
"false",
",",
"false",
",",
"false",
")",
";",
"// see isArchiveTemporary()",
"$",
"minDatetimeArchiveProcessedUTC",
"=",
"$",
"this",
"->",
"getMinTimeA... | Returns the idArchive if the archive is available in the database for the requested plugin.
Returns false if the archive needs to be processed.
@return array | [
"Returns",
"the",
"idArchive",
"if",
"the",
"archive",
"is",
"available",
"in",
"the",
"database",
"for",
"the",
"requested",
"plugin",
".",
"Returns",
"false",
"if",
"the",
"archive",
"needs",
"to",
"be",
"processed",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor/Loader.php#L170-L188 | train | Load existing archive id from DB | [
30522,
5123,
3853,
7170,
10288,
2923,
28234,
11140,
3512,
3593,
19699,
5358,
18939,
1006,
1007,
1063,
1002,
2053,
2906,
5428,
3726,
14876,
8630,
1027,
9140,
1006,
6270,
1010,
6270,
1010,
6270,
1007,
1025,
1013,
1013,
2156,
18061,
11140,
351... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/Regex.php | Zend_Validate_Regex.setPattern | public function setPattern($pattern)
{
$this->_pattern = (string) $pattern;
$status = @preg_match($this->_pattern, "Test");
if (false === $status) {
// require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'");
}
return $this;
} | php | public function setPattern($pattern)
{
$this->_pattern = (string) $pattern;
$status = @preg_match($this->_pattern, "Test");
if (false === $status) {
// require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Internal error while using the pattern '$this->_pattern'");
}
return $this;
} | [
"public",
"function",
"setPattern",
"(",
"$",
"pattern",
")",
"{",
"$",
"this",
"->",
"_pattern",
"=",
"(",
"string",
")",
"$",
"pattern",
";",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"$",
"this",
"->",
"_pattern",
",",
"\"Test\"",
")",
";",
"if"... | Sets the pattern option
@param string $pattern
@throws Zend_Validate_Exception if there is a fatal error in pattern matching
@return Zend_Validate_Regex Provides a fluent interface | [
"Sets",
"the",
"pattern",
"option"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Regex.php#L104-L115 | train | Set the pattern | [
30522,
2270,
3853,
2275,
4502,
12079,
2078,
1006,
1002,
5418,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
5418,
1027,
1006,
5164,
1007,
1002,
5418,
1025,
1002,
3570,
1027,
1030,
3653,
2290,
1035,
2674,
1006,
1002,
2023,
1011,
1028,
1035,
54... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php | MoneyToLocalizedStringTransformer.reverseTransform | public function reverseTransform($value)
{
$value = parent::reverseTransform($value);
if (null !== $value && 1 !== $this->divisor) {
$value = (float) (string) ($value * $this->divisor);
}
return $value;
} | php | public function reverseTransform($value)
{
$value = parent::reverseTransform($value);
if (null !== $value && 1 !== $this->divisor) {
$value = (float) (string) ($value * $this->divisor);
}
return $value;
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"parent",
"::",
"reverseTransform",
"(",
"$",
"value",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"value",
"&&",
"1",
"!==",
"$",
"this",
"->",
"divisor",
")",
"{... | Transforms a localized money string into a normalized format.
@param string $value Localized money string
@return int|float Normalized number
@throws TransformationFailedException if the given value is not a string
or if the value can not be transformed | [
"Transforms",
"a",
"localized",
"money",
"string",
"into",
"a",
"normalized",
"format",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php#L77-L85 | train | Transform a value to a number | [
30522,
2270,
3853,
7901,
6494,
3619,
14192,
1006,
1002,
3643,
1007,
1063,
1002,
3643,
1027,
6687,
1024,
1024,
7901,
6494,
3619,
14192,
1006,
1002,
3643,
1007,
1025,
2065,
1006,
19701,
999,
1027,
1027,
1002,
3643,
1004,
1004,
1015,
999,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Connection/UdpConnection.php | UdpConnection.send | public function send($send_buffer, $raw = false)
{
if (false === $raw && $this->protocol) {
$parser = $this->protocol;
$send_buffer = $parser::encode($send_buffer, $this);
if ($send_buffer === '') {
return null;
}
}
return strlen($send_buffer) === stream_socket_sendto($this->_socket, $send_buffer, 0, $this->_remoteAddress);
} | php | public function send($send_buffer, $raw = false)
{
if (false === $raw && $this->protocol) {
$parser = $this->protocol;
$send_buffer = $parser::encode($send_buffer, $this);
if ($send_buffer === '') {
return null;
}
}
return strlen($send_buffer) === stream_socket_sendto($this->_socket, $send_buffer, 0, $this->_remoteAddress);
} | [
"public",
"function",
"send",
"(",
"$",
"send_buffer",
",",
"$",
"raw",
"=",
"false",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"raw",
"&&",
"$",
"this",
"->",
"protocol",
")",
"{",
"$",
"parser",
"=",
"$",
"this",
"->",
"protocol",
";",
"$",
"se... | Sends data on the connection.
@param string $send_buffer
@param bool $raw
@return void|boolean | [
"Sends",
"data",
"on",
"the",
"connection",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/UdpConnection.php#L62-L72 | train | Send the given data to the remote server | [
30522,
2270,
3853,
4604,
1006,
1002,
4604,
1035,
17698,
1010,
1002,
6315,
1027,
6270,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
1002,
6315,
1004,
1004,
1002,
2023,
1011,
1028,
8778,
1007,
1063,
1002,
11968,
8043,
1027,
1002,
2023,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/GPM/GPM.php | GPM.getPackagesThatDependOnPackage | public function getPackagesThatDependOnPackage($slug)
{
$plugins = $this->getInstalledPlugins();
$themes = $this->getInstalledThemes();
$packages = array_merge($plugins->toArray(), $themes->toArray());
$dependent_packages = [];
foreach ($packages as $package_name => $package) {
if (isset($package['dependencies'])) {
foreach ($package['dependencies'] as $dependency) {
if (is_array($dependency) && isset($dependency['name'])) {
$dependency = $dependency['name'];
}
if ($dependency === $slug) {
$dependent_packages[] = $package_name;
}
}
}
}
return $dependent_packages;
} | php | public function getPackagesThatDependOnPackage($slug)
{
$plugins = $this->getInstalledPlugins();
$themes = $this->getInstalledThemes();
$packages = array_merge($plugins->toArray(), $themes->toArray());
$dependent_packages = [];
foreach ($packages as $package_name => $package) {
if (isset($package['dependencies'])) {
foreach ($package['dependencies'] as $dependency) {
if (is_array($dependency) && isset($dependency['name'])) {
$dependency = $dependency['name'];
}
if ($dependency === $slug) {
$dependent_packages[] = $package_name;
}
}
}
}
return $dependent_packages;
} | [
"public",
"function",
"getPackagesThatDependOnPackage",
"(",
"$",
"slug",
")",
"{",
"$",
"plugins",
"=",
"$",
"this",
"->",
"getInstalledPlugins",
"(",
")",
";",
"$",
"themes",
"=",
"$",
"this",
"->",
"getInstalledThemes",
"(",
")",
";",
"$",
"packages",
"... | Return the list of packages that have the passed one as dependency
@param string $slug The slug name of the package
@return array | [
"Return",
"the",
"list",
"of",
"packages",
"that",
"have",
"the",
"passed",
"one",
"as",
"dependency"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/GPM.php#L718-L741 | train | Get packages that depend on a package | [
30522,
2270,
3853,
2131,
23947,
13923,
8322,
2102,
3207,
11837,
5280,
23947,
4270,
1006,
1002,
23667,
1007,
1063,
1002,
13354,
7076,
1027,
1002,
2023,
1011,
1028,
2131,
7076,
9080,
3709,
24759,
15916,
7076,
1006,
1007,
1025,
1002,
6991,
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/system/classes/UpdateManager.php | UpdateManager.createServerUrl | protected function createServerUrl($uri)
{
$gateway = Config::get('cms.updateServer', 'http://gateway.octobercms.com/api');
if (substr($gateway, -1) != '/') {
$gateway .= '/';
}
return $gateway . $uri;
} | php | protected function createServerUrl($uri)
{
$gateway = Config::get('cms.updateServer', 'http://gateway.octobercms.com/api');
if (substr($gateway, -1) != '/') {
$gateway .= '/';
}
return $gateway . $uri;
} | [
"protected",
"function",
"createServerUrl",
"(",
"$",
"uri",
")",
"{",
"$",
"gateway",
"=",
"Config",
"::",
"get",
"(",
"'cms.updateServer'",
",",
"'http://gateway.octobercms.com/api'",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"gateway",
",",
"-",
"1",
")",
... | Create a complete gateway server URL from supplied URI
@param string $uri URI
@return string URL | [
"Create",
"a",
"complete",
"gateway",
"server",
"URL",
"from",
"supplied",
"URI"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/UpdateManager.php#L904-L912 | train | Create the server URL | [
30522,
5123,
3853,
9005,
2121,
6299,
3126,
2140,
1006,
1002,
24471,
2072,
1007,
1063,
1002,
11909,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
1006,
1005,
4642,
2015,
1012,
14409,
2121,
6299,
1005,
1010,
1005,
8299,
1024,
1013,
1013,
11909,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | PostgresGrammar.compileUpdateColumns | protected function compileUpdateColumns($query, $values)
{
// When gathering the columns for an update statement, we'll wrap each of the
// columns and convert it to a parameter value. Then we will concatenate a
// list of the columns that can be added into this update query clauses.
return collect($values)->map(function ($value, $key) use ($query) {
$column = Str::after($key, $query->from.'.');
if ($this->isJsonSelector($key)) {
return $this->compileJsonUpdateColumn($column, $value);
}
return $this->wrap($column).' = '.$this->parameter($value);
})->implode(', ');
} | php | protected function compileUpdateColumns($query, $values)
{
// When gathering the columns for an update statement, we'll wrap each of the
// columns and convert it to a parameter value. Then we will concatenate a
// list of the columns that can be added into this update query clauses.
return collect($values)->map(function ($value, $key) use ($query) {
$column = Str::after($key, $query->from.'.');
if ($this->isJsonSelector($key)) {
return $this->compileJsonUpdateColumn($column, $value);
}
return $this->wrap($column).' = '.$this->parameter($value);
})->implode(', ');
} | [
"protected",
"function",
"compileUpdateColumns",
"(",
"$",
"query",
",",
"$",
"values",
")",
"{",
"// When gathering the columns for an update statement, we'll wrap each of the",
"// columns and convert it to a parameter value. Then we will concatenate a",
"// list of the columns that can ... | Compile the columns for the update statement.
@param \Illuminate\Database\Query\Builder $query
@param array $values
@return string | [
"Compile",
"the",
"columns",
"for",
"the",
"update",
"statement",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php#L245-L259 | train | Compiles the update columns for an update statement. | [
30522,
5123,
3853,
4012,
22090,
6279,
13701,
25778,
2819,
3619,
1006,
1002,
23032,
1010,
1002,
5300,
1007,
1063,
1013,
1013,
2043,
7215,
1996,
7753,
2005,
2019,
30524,
12556,
1037,
1013,
1013,
2862,
1997,
1996,
7753,
2008,
2064,
2022,
2794,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.getOptionsFromModel | protected function getOptionsFromModel($field, $fieldOptions)
{
/*
* Advanced usage, supplied options are callable
*/
if (is_array($fieldOptions) && is_callable($fieldOptions)) {
$fieldOptions = call_user_func($fieldOptions, $this, $field);
}
/*
* Refer to the model method or any of its behaviors
*/
if (!is_array($fieldOptions) && !$fieldOptions) {
try {
list($model, $attribute) = $field->resolveModelAttribute($this->model, $field->fieldName);
}
catch (Exception $ex) {
throw new ApplicationException(Lang::get('backend::lang.field.options_method_invalid_model', [
'model' => get_class($this->model),
'field' => $field->fieldName
]));
}
$methodName = 'get'.studly_case($attribute).'Options';
if (
!$this->objectMethodExists($model, $methodName) &&
!$this->objectMethodExists($model, 'getDropdownOptions')
) {
throw new ApplicationException(Lang::get('backend::lang.field.options_method_not_exists', [
'model' => get_class($model),
'method' => $methodName,
'field' => $field->fieldName
]));
}
if ($this->objectMethodExists($model, $methodName)) {
$fieldOptions = $model->$methodName($field->value, $this->data);
}
else {
$fieldOptions = $model->getDropdownOptions($attribute, $field->value, $this->data);
}
}
/*
* Field options are an explicit method reference
*/
elseif (is_string($fieldOptions)) {
if (!$this->objectMethodExists($this->model, $fieldOptions)) {
throw new ApplicationException(Lang::get('backend::lang.field.options_method_not_exists', [
'model' => get_class($this->model),
'method' => $fieldOptions,
'field' => $field->fieldName
]));
}
$fieldOptions = $this->model->$fieldOptions($field->value, $field->fieldName, $this->data);
}
return $fieldOptions;
} | php | protected function getOptionsFromModel($field, $fieldOptions)
{
/*
* Advanced usage, supplied options are callable
*/
if (is_array($fieldOptions) && is_callable($fieldOptions)) {
$fieldOptions = call_user_func($fieldOptions, $this, $field);
}
/*
* Refer to the model method or any of its behaviors
*/
if (!is_array($fieldOptions) && !$fieldOptions) {
try {
list($model, $attribute) = $field->resolveModelAttribute($this->model, $field->fieldName);
}
catch (Exception $ex) {
throw new ApplicationException(Lang::get('backend::lang.field.options_method_invalid_model', [
'model' => get_class($this->model),
'field' => $field->fieldName
]));
}
$methodName = 'get'.studly_case($attribute).'Options';
if (
!$this->objectMethodExists($model, $methodName) &&
!$this->objectMethodExists($model, 'getDropdownOptions')
) {
throw new ApplicationException(Lang::get('backend::lang.field.options_method_not_exists', [
'model' => get_class($model),
'method' => $methodName,
'field' => $field->fieldName
]));
}
if ($this->objectMethodExists($model, $methodName)) {
$fieldOptions = $model->$methodName($field->value, $this->data);
}
else {
$fieldOptions = $model->getDropdownOptions($attribute, $field->value, $this->data);
}
}
/*
* Field options are an explicit method reference
*/
elseif (is_string($fieldOptions)) {
if (!$this->objectMethodExists($this->model, $fieldOptions)) {
throw new ApplicationException(Lang::get('backend::lang.field.options_method_not_exists', [
'model' => get_class($this->model),
'method' => $fieldOptions,
'field' => $field->fieldName
]));
}
$fieldOptions = $this->model->$fieldOptions($field->value, $field->fieldName, $this->data);
}
return $fieldOptions;
} | [
"protected",
"function",
"getOptionsFromModel",
"(",
"$",
"field",
",",
"$",
"fieldOptions",
")",
"{",
"/*\n * Advanced usage, supplied options are callable\n */",
"if",
"(",
"is_array",
"(",
"$",
"fieldOptions",
")",
"&&",
"is_callable",
"(",
"$",
"fiel... | Looks at the model for defined options.
@param $field
@param $fieldOptions
@return mixed | [
"Looks",
"at",
"the",
"model",
"for",
"defined",
"options",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L1227-L1286 | train | Returns options from model method or attribute | [
30522,
5123,
3853,
2131,
7361,
9285,
19699,
5358,
5302,
9247,
1006,
1002,
2492,
1010,
1002,
2492,
7361,
9285,
1007,
1063,
1013,
1008,
1008,
3935,
8192,
1010,
8127,
7047,
2024,
2655,
3085,
1008,
1013,
2065,
1006,
2003,
1035,
9140,
1006,
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/models/User.php | User.sendInvitation | public function sendInvitation()
{
$data = [
'name' => $this->full_name,
'login' => $this->login,
'password' => $this->getOriginalHashValue('password'),
'link' => Backend::url('backend'),
];
Mail::send('backend::mail.invite', $data, function ($message) {
$message->to($this->email, $this->full_name);
});
} | php | public function sendInvitation()
{
$data = [
'name' => $this->full_name,
'login' => $this->login,
'password' => $this->getOriginalHashValue('password'),
'link' => Backend::url('backend'),
];
Mail::send('backend::mail.invite', $data, function ($message) {
$message->to($this->email, $this->full_name);
});
} | [
"public",
"function",
"sendInvitation",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"full_name",
",",
"'login'",
"=>",
"$",
"this",
"->",
"login",
",",
"'password'",
"=>",
"$",
"this",
"->",
"getOriginalHashValue",
"(",
"'pas... | Sends an invitation to the user using template "backend::mail.invite".
@return void | [
"Sends",
"an",
"invitation",
"to",
"the",
"user",
"using",
"template",
"backend",
"::",
"mail",
".",
"invite",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/models/User.php#L146-L158 | train | Send invite email | [
30522,
2270,
3853,
4604,
2378,
28403,
3508,
1006,
1007,
1063,
1002,
2951,
1027,
1031,
1005,
2171,
1005,
1027,
1028,
1002,
2023,
1011,
1028,
2440,
1035,
2171,
1010,
1005,
8833,
2378,
1005,
1027,
1028,
1002,
2023,
1011,
1028,
8833,
2378,
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... |
laravel/framework | src/Illuminate/Queue/SyncQueue.php | SyncQueue.raiseExceptionOccurredJobEvent | protected function raiseExceptionOccurredJobEvent(Job $job, $e)
{
if ($this->container->bound('events')) {
$this->container['events']->dispatch(new Events\JobExceptionOccurred($this->connectionName, $job, $e));
}
} | php | protected function raiseExceptionOccurredJobEvent(Job $job, $e)
{
if ($this->container->bound('events')) {
$this->container['events']->dispatch(new Events\JobExceptionOccurred($this->connectionName, $job, $e));
}
} | [
"protected",
"function",
"raiseExceptionOccurredJobEvent",
"(",
"Job",
"$",
"job",
",",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"bound",
"(",
"'events'",
")",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'events'",
"]",
... | Raise the exception occurred queue job event.
@param \Illuminate\Contracts\Queue\Job $job
@param \Exception $e
@return void | [
"Raise",
"the",
"exception",
"occurred",
"queue",
"job",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/SyncQueue.php#L99-L104 | train | Throws an exception occurred event for the given job | [
30522,
5123,
3853,
5333,
10288,
24422,
10085,
10841,
20529,
5558,
4783,
15338,
1006,
3105,
1002,
3105,
1010,
1002,
1041,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11661,
1011,
1028,
5391,
1006,
1005,
2824,
1005,
1007,
1007,
1063,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Manager.php | Zend_Cache_Manager.getCaches | public function getCaches()
{
$caches = $this->_caches;
foreach ($this->_optionTemplates as $name => $tmp) {
if (!isset($caches[$name])) {
$caches[$name] = $this->getCache($name);
}
}
return $caches;
} | php | public function getCaches()
{
$caches = $this->_caches;
foreach ($this->_optionTemplates as $name => $tmp) {
if (!isset($caches[$name])) {
$caches[$name] = $this->getCache($name);
}
}
return $caches;
} | [
"public",
"function",
"getCaches",
"(",
")",
"{",
"$",
"caches",
"=",
"$",
"this",
"->",
"_caches",
";",
"foreach",
"(",
"$",
"this",
"->",
"_optionTemplates",
"as",
"$",
"name",
"=>",
"$",
"tmp",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"cache... | Fetch all available caches
@return array An array of all available caches with it's names as key | [
"Fetch",
"all",
"available",
"caches"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Manager.php#L184-L193 | train | Get all caches | [
30522,
2270,
3853,
2131,
3540,
8376,
1006,
1007,
1063,
1002,
17053,
2015,
1027,
1002,
2023,
1011,
1028,
1035,
17053,
2015,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
1035,
5724,
18532,
15725,
2015,
2004,
1002,
2171,
1027,
1028,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select._renderOrder | protected function _renderOrder($sql)
{
if ($this->_parts[self::ORDER]) {
$order = array();
foreach ($this->_parts[self::ORDER] as $term) {
if (is_array($term)) {
if(is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) {
$order[] = (int)trim($term[0]) . ' ' . $term[1];
} else {
$order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1];
}
} else if (is_numeric($term) && strval(intval($term)) == $term) {
$order[] = (int)trim($term);
} else {
$order[] = $this->_adapter->quoteIdentifier($term, true);
}
}
$sql .= ' ' . self::SQL_ORDER_BY . ' ' . implode(', ', $order);
}
return $sql;
} | php | protected function _renderOrder($sql)
{
if ($this->_parts[self::ORDER]) {
$order = array();
foreach ($this->_parts[self::ORDER] as $term) {
if (is_array($term)) {
if(is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) {
$order[] = (int)trim($term[0]) . ' ' . $term[1];
} else {
$order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1];
}
} else if (is_numeric($term) && strval(intval($term)) == $term) {
$order[] = (int)trim($term);
} else {
$order[] = $this->_adapter->quoteIdentifier($term, true);
}
}
$sql .= ' ' . self::SQL_ORDER_BY . ' ' . implode(', ', $order);
}
return $sql;
} | [
"protected",
"function",
"_renderOrder",
"(",
"$",
"sql",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"ORDER",
"]",
")",
"{",
"$",
"order",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_parts",
"[",
"s... | Render ORDER clause
@param string $sql SQL query
@return string | [
"Render",
"ORDER",
"clause"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1225-L1246 | train | Render order by | [
30522,
5123,
3853,
1035,
17552,
8551,
2121,
1006,
1002,
29296,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
2969,
1024,
1024,
2344,
1033,
1007,
1063,
1002,
2344,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/ValidatorBuilder.php | ValidatorBuilder.enableAnnotationMapping | public function enableAnnotationMapping(Reader $annotationReader = null)
{
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot enable annotation mapping after setting a custom metadata factory. Configure your metadata factory instead.');
}
if (null === $annotationReader) {
if (!class_exists(AnnotationReader::class) || !class_exists(ArrayCache::class)) {
throw new LogicException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and doctrine/cache to be installed.');
}
$annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
}
$this->annotationReader = $annotationReader;
return $this;
} | php | public function enableAnnotationMapping(Reader $annotationReader = null)
{
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot enable annotation mapping after setting a custom metadata factory. Configure your metadata factory instead.');
}
if (null === $annotationReader) {
if (!class_exists(AnnotationReader::class) || !class_exists(ArrayCache::class)) {
throw new LogicException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and doctrine/cache to be installed.');
}
$annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
}
$this->annotationReader = $annotationReader;
return $this;
} | [
"public",
"function",
"enableAnnotationMapping",
"(",
"Reader",
"$",
"annotationReader",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"metadataFactory",
")",
"{",
"throw",
"new",
"ValidatorException",
"(",
"'You cannot enable annotation mappin... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/ValidatorBuilder.php#L189-L206 | train | Enable annotation based constraint mapping | [
30522,
2270,
3853,
9585,
11639,
17287,
3508,
2863,
14853,
1006,
8068,
1002,
5754,
17287,
3508,
16416,
4063,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
27425,
21450,
1007,
1063,
5466,
2047,
9398,
884... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail.php | Zend_Mail._encodeHeader | protected function _encodeHeader($value)
{
if (Zend_Mime::isPrintable($value) === false) {
if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) {
$value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
} else {
$value = Zend_Mime::encodeBase64Header($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
}
}
return $value;
} | php | protected function _encodeHeader($value)
{
if (Zend_Mime::isPrintable($value) === false) {
if ($this->getHeaderEncoding() === Zend_Mime::ENCODING_QUOTEDPRINTABLE) {
$value = Zend_Mime::encodeQuotedPrintableHeader($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
} else {
$value = Zend_Mime::encodeBase64Header($value, $this->getCharset(), Zend_Mime::LINELENGTH, Zend_Mime::LINEEND);
}
}
return $value;
} | [
"protected",
"function",
"_encodeHeader",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"Zend_Mime",
"::",
"isPrintable",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getHeaderEncoding",
"(",
")",
"===",
"Zend_Mime",
"::",
... | Encode header fields
Encodes header content according to RFC1522 if it contains non-printable
characters.
@param string $value
@return string | [
"Encode",
"header",
"fields"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L500-L511 | train | Encode header value | [
30522,
5123,
3853,
1035,
4372,
16044,
4974,
2121,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
16729,
2094,
1035,
2771,
4168,
1024,
1024,
2003,
16550,
3085,
1006,
1002,
3643,
1007,
1027,
1027,
1027,
6270,
1007,
1063,
2065,
1006,
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... |
laravel/framework | src/Illuminate/Database/Connection.php | Connection.bindValues | public function bindValues($statement, $bindings)
{
foreach ($bindings as $key => $value) {
$statement->bindValue(
is_string($key) ? $key : $key + 1, $value,
is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR
);
}
} | php | public function bindValues($statement, $bindings)
{
foreach ($bindings as $key => $value) {
$statement->bindValue(
is_string($key) ? $key : $key + 1, $value,
is_int($value) ? PDO::PARAM_INT : PDO::PARAM_STR
);
}
} | [
"public",
"function",
"bindValues",
"(",
"$",
"statement",
",",
"$",
"bindings",
")",
"{",
"foreach",
"(",
"$",
"bindings",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"statement",
"->",
"bindValue",
"(",
"is_string",
"(",
"$",
"key",
")",
"... | Bind values to their parameters in the given statement.
@param \PDOStatement $statement
@param array $bindings
@return void | [
"Bind",
"values",
"to",
"their",
"parameters",
"in",
"the",
"given",
"statement",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connection.php#L570-L578 | train | Binds values to a statement | [
30522,
2270,
3853,
14187,
10175,
15808,
1006,
1002,
4861,
1010,
1002,
8031,
2015,
1007,
1063,
18921,
6776,
1006,
1002,
8031,
2015,
2004,
1002,
3145,
1027,
1028,
1002,
3643,
1007,
1063,
1002,
4861,
1011,
1028,
14187,
10175,
5657,
1006,
2003,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php | MySqlGrammar.modifyNullable | protected function modifyNullable(Blueprint $blueprint, Fluent $column)
{
if (is_null($column->virtualAs) && is_null($column->storedAs)) {
return $column->nullable ? ' null' : ' not null';
}
} | php | protected function modifyNullable(Blueprint $blueprint, Fluent $column)
{
if (is_null($column->virtualAs) && is_null($column->storedAs)) {
return $column->nullable ? ' null' : ' not null';
}
} | [
"protected",
"function",
"modifyNullable",
"(",
"Blueprint",
"$",
"blueprint",
",",
"Fluent",
"$",
"column",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"column",
"->",
"virtualAs",
")",
"&&",
"is_null",
"(",
"$",
"column",
"->",
"storedAs",
")",
")",
"{",... | Get the SQL for a nullable column modifier.
@param \Illuminate\Database\Schema\Blueprint $blueprint
@param \Illuminate\Support\Fluent $column
@return string|null | [
"Get",
"the",
"SQL",
"for",
"a",
"nullable",
"column",
"modifier",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php#L940-L945 | train | Modify the nullable modifier for a column. | [
30522,
5123,
3853,
19933,
11231,
4571,
3468,
1006,
2630,
16550,
1002,
2630,
16550,
1010,
19376,
1002,
5930,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
5930,
1011,
1028,
7484,
3022,
1007,
1004,
1004,
2003,
1035,
19701,
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/Cache/Frontend/File.php | Zend_Cache_Frontend_File.setOption | public function setOption($name, $value)
{
if ($name == 'master_file') {
$this->setMasterFile($value);
} else if ($name == 'master_files') {
$this->setMasterFiles($value);
} else {
parent::setOption($name, $value);
}
} | php | public function setOption($name, $value)
{
if ($name == 'master_file') {
$this->setMasterFile($value);
} else if ($name == 'master_files') {
$this->setMasterFiles($value);
} else {
parent::setOption($name, $value);
}
} | [
"public",
"function",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"'master_file'",
")",
"{",
"$",
"this",
"->",
"setMasterFile",
"(",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"$",
"name",
"==",
... | Public frontend to set an option
Just a wrapper to get a specific behaviour for master_file
@param string $name Name of the option
@param mixed $value Value of the option
@throws Zend_Cache_Exception
@return void | [
"Public",
"frontend",
"to",
"set",
"an",
"option"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/File.php#L156-L165 | train | Set the value of an option in the current context | [
30522,
2270,
3853,
2275,
7361,
3508,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
2171,
1027,
1027,
1005,
3040,
1035,
5371,
1005,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
8706,
8873,
2571,
1006,
1002,
3643,
1007,
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... |
matomo-org/matomo | libs/Zend/Validate/File/Count.php | Zend_Validate_File_Count.setMax | public function setMax($max)
{
if (is_array($max) and isset($max['max'])) {
$max = $max['max'];
}
if (!is_string($max) and !is_numeric($max)) {
// require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception ('Invalid options to validator provided');
}
$max = (integer) $max;
if (($this->_min !== null) && ($max < $this->_min)) {
// require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but "
. "$max < {$this->_min}");
}
$this->_max = $max;
return $this;
} | php | public function setMax($max)
{
if (is_array($max) and isset($max['max'])) {
$max = $max['max'];
}
if (!is_string($max) and !is_numeric($max)) {
// require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception ('Invalid options to validator provided');
}
$max = (integer) $max;
if (($this->_min !== null) && ($max < $this->_min)) {
// require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("The maximum must be greater than or equal to the minimum file count, but "
. "$max < {$this->_min}");
}
$this->_max = $max;
return $this;
} | [
"public",
"function",
"setMax",
"(",
"$",
"max",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"max",
")",
"and",
"isset",
"(",
"$",
"max",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"max",
"=",
"$",
"max",
"[",
"'max'",
"]",
";",
"}",
"if",
"(",
... | Sets the maximum file count
@param integer|array $max The maximum file count
@return Zend_Validate_StringLength Provides a fluent interface
@throws Zend_Validate_Exception When max is smaller than min | [
"Sets",
"the",
"maximum",
"file",
"count"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/File/Count.php#L187-L207 | train | Set maximum file count | [
30522,
2270,
3853,
2275,
17848,
1006,
1002,
4098,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
4098,
1007,
1998,
26354,
3388,
1006,
1002,
4098,
1031,
1005,
4098,
1005,
1033,
1007,
1007,
1063,
1002,
4098,
1027,
1002,
4098,
1031,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/ValidatesWhenResolvedTrait.php | ValidatesWhenResolvedTrait.validateResolved | public function validateResolved()
{
$this->prepareForValidation();
if (! $this->passesAuthorization()) {
$this->failedAuthorization();
}
$instance = $this->getValidatorInstance();
if ($instance->fails()) {
$this->failedValidation($instance);
}
} | php | public function validateResolved()
{
$this->prepareForValidation();
if (! $this->passesAuthorization()) {
$this->failedAuthorization();
}
$instance = $this->getValidatorInstance();
if ($instance->fails()) {
$this->failedValidation($instance);
}
} | [
"public",
"function",
"validateResolved",
"(",
")",
"{",
"$",
"this",
"->",
"prepareForValidation",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"passesAuthorization",
"(",
")",
")",
"{",
"$",
"this",
"->",
"failedAuthorization",
"(",
")",
";",
"}",... | Validate the class instance.
@return void | [
"Validate",
"the",
"class",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/ValidatesWhenResolvedTrait.php#L15-L28 | train | Validate the resolved values | [
30522,
2270,
3853,
9398,
24932,
2229,
16116,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
7374,
29278,
10175,
8524,
3508,
1006,
1007,
1025,
2065,
1006,
999,
1002,
2023,
1011,
1028,
5235,
4887,
27844,
3989,
1006,
1007,
1007,
1063,
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... |
laravel/framework | src/Illuminate/Support/Collection.php | Collection.avg | public function avg($callback = null)
{
$callback = $this->valueRetriever($callback);
$items = $this->map(function ($value) use ($callback) {
return $callback($value);
})->filter(function ($value) {
return ! is_null($value);
});
if ($count = $items->count()) {
return $items->sum() / $count;
}
} | php | public function avg($callback = null)
{
$callback = $this->valueRetriever($callback);
$items = $this->map(function ($value) use ($callback) {
return $callback($value);
})->filter(function ($value) {
return ! is_null($value);
});
if ($count = $items->count()) {
return $items->sum() / $count;
}
} | [
"public",
"function",
"avg",
"(",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"valueRetriever",
"(",
"$",
"callback",
")",
";",
"$",
"items",
"=",
"$",
"this",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
")... | Get the average value of a given key.
@param callable|string|null $callback
@return mixed | [
"Get",
"the",
"average",
"value",
"of",
"a",
"given",
"key",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Collection.php#L144-L157 | train | Return the average value of the collection | [
30522,
2270,
3853,
20704,
2290,
1006,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
1002,
2655,
5963,
1027,
1002,
2023,
1011,
1028,
3643,
13465,
7373,
6299,
1006,
1002,
2655,
5963,
1007,
1025,
1002,
5167,
1027,
1002,
2023,
1011,
1028,
4949,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Command/DebugCommand.php | DebugCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->title('Messenger');
$mapping = $this->mapping;
if ($bus = $input->getArgument('bus')) {
if (!isset($mapping[$bus])) {
throw new RuntimeException(sprintf('Bus "%s" does not exist. Known buses are %s.', $bus, implode(', ', array_keys($this->mapping))));
}
$mapping = [$bus => $mapping[$bus]];
}
foreach ($mapping as $bus => $handlersByMessage) {
$io->section($bus);
$tableRows = [];
foreach ($handlersByMessage as $message => $handlers) {
$tableRows[] = [sprintf('<fg=cyan>%s</fg=cyan>', $message)];
foreach ($handlers as $handler) {
$tableRows[] = [
sprintf(' handled by <info>%s</>', $handler[0]).$this->formatConditions($handler[1]),
];
}
}
if ($tableRows) {
$io->text('The following messages can be dispatched:');
$io->newLine();
$io->table([], $tableRows);
} else {
$io->warning(sprintf('No handled message found in bus "%s".', $bus));
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->title('Messenger');
$mapping = $this->mapping;
if ($bus = $input->getArgument('bus')) {
if (!isset($mapping[$bus])) {
throw new RuntimeException(sprintf('Bus "%s" does not exist. Known buses are %s.', $bus, implode(', ', array_keys($this->mapping))));
}
$mapping = [$bus => $mapping[$bus]];
}
foreach ($mapping as $bus => $handlersByMessage) {
$io->section($bus);
$tableRows = [];
foreach ($handlersByMessage as $message => $handlers) {
$tableRows[] = [sprintf('<fg=cyan>%s</fg=cyan>', $message)];
foreach ($handlers as $handler) {
$tableRows[] = [
sprintf(' handled by <info>%s</>', $handler[0]).$this->formatConditions($handler[1]),
];
}
}
if ($tableRows) {
$io->text('The following messages can be dispatched:');
$io->newLine();
$io->table([], $tableRows);
} else {
$io->warning(sprintf('No handled message found in bus "%s".', $bus));
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"io",
"->",
"title",
"(",
"'Messenger'"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Command/DebugCommand.php#L67-L101 | train | Displays the messages | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
22834,
1027,
2047,
25353,
2213,
14876,
4890,
21756,
2571,
1006,
1002,
7953,
1010,
1002,
6434,
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... |
octobercms/october | modules/backend/classes/AuthManager.php | AuthManager.registerPermissions | public function registerPermissions($owner, array $definitions)
{
foreach ($definitions as $code => $definition) {
$permission = (object)array_merge(self::$permissionDefaults, array_merge($definition, [
'code' => $code,
'owner' => $owner
]));
$this->permissions[] = $permission;
}
} | php | public function registerPermissions($owner, array $definitions)
{
foreach ($definitions as $code => $definition) {
$permission = (object)array_merge(self::$permissionDefaults, array_merge($definition, [
'code' => $code,
'owner' => $owner
]));
$this->permissions[] = $permission;
}
} | [
"public",
"function",
"registerPermissions",
"(",
"$",
"owner",
",",
"array",
"$",
"definitions",
")",
"{",
"foreach",
"(",
"$",
"definitions",
"as",
"$",
"code",
"=>",
"$",
"definition",
")",
"{",
"$",
"permission",
"=",
"(",
"object",
")",
"array_merge",... | Registers the back-end permission items.
The argument is an array of the permissions. The array keys represent the
permission codes, specific for the plugin/module. Each element in the
array should be an associative array with the following keys:
- label - specifies the menu label localization string key, required.
- order - a position of the item in the menu, optional.
- comment - a brief comment that describes the permission, optional.
- tab - assign this permission to a tabbed group, optional.
@param string $owner Specifies the menu items owner plugin or module in the format Vendor/Module.
@param array $definitions An array of the menu item definitions. | [
"Registers",
"the",
"back",
"-",
"end",
"permission",
"items",
".",
"The",
"argument",
"is",
"an",
"array",
"of",
"the",
"permissions",
".",
"The",
"array",
"keys",
"represent",
"the",
"permission",
"codes",
"specific",
"for",
"the",
"plugin",
"/",
"module",... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/AuthManager.php#L87-L97 | train | Register permissions for the user | [
30522,
2270,
3853,
4236,
4842,
25481,
2015,
1006,
1002,
3954,
1010,
9140,
1002,
15182,
1007,
1063,
18921,
6776,
1006,
1002,
15182,
2004,
1002,
3642,
1027,
1028,
1002,
6210,
1007,
1063,
1002,
6656,
1027,
1006,
4874,
1007,
9140,
1035,
13590,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Data/Data.php | Data.setDefaults | public function setDefaults(array $data)
{
$this->items = $this->blueprints()->mergeData($data, $this->items);
return $this;
} | php | public function setDefaults(array $data)
{
$this->items = $this->blueprints()->mergeData($data, $this->items);
return $this;
} | [
"public",
"function",
"setDefaults",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"items",
"=",
"$",
"this",
"->",
"blueprints",
"(",
")",
"->",
"mergeData",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"items",
")",
";",
"return",
"$",
"th... | Set default values to the configuration if variables were not set.
@param array $data
@return $this | [
"Set",
"default",
"values",
"to",
"the",
"configuration",
"if",
"variables",
"were",
"not",
"set",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Data.php#L179-L184 | train | Set the default values of all items in the tree | [
30522,
2270,
3853,
2275,
3207,
7011,
11314,
2015,
1006,
9140,
1002,
2951,
1007,
1063,
1002,
2023,
1011,
1028,
5167,
1027,
1002,
2023,
1011,
1028,
2630,
16550,
2015,
1006,
1007,
1011,
1028,
5314,
6790,
1006,
1002,
2951,
1010,
1002,
2023,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Row.php | Row.sumSubtable | public function sumSubtable(DataTable $subTable)
{
if ($this->isSubtableLoaded) {
$thisSubTable = $this->getSubtable();
} else {
$this->warnIfSubtableAlreadyExists();
$thisSubTable = new DataTable();
$this->setSubtable($thisSubTable);
}
$columnOps = $subTable->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$thisSubTable->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnOps);
$thisSubTable->addDataTable($subTable);
} | php | public function sumSubtable(DataTable $subTable)
{
if ($this->isSubtableLoaded) {
$thisSubTable = $this->getSubtable();
} else {
$this->warnIfSubtableAlreadyExists();
$thisSubTable = new DataTable();
$this->setSubtable($thisSubTable);
}
$columnOps = $subTable->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$thisSubTable->setMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME, $columnOps);
$thisSubTable->addDataTable($subTable);
} | [
"public",
"function",
"sumSubtable",
"(",
"DataTable",
"$",
"subTable",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSubtableLoaded",
")",
"{",
"$",
"thisSubTable",
"=",
"$",
"this",
"->",
"getSubtable",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->"... | Sums a DataTable to this row's subtable. If this row has no subtable a new
one is created.
See {@link Piwik\DataTable::addDataTable()} to learn how DataTables are summed.
@param DataTable $subTable Table to sum to this row's subtable. | [
"Sums",
"a",
"DataTable",
"to",
"this",
"row",
"s",
"subtable",
".",
"If",
"this",
"row",
"has",
"no",
"subtable",
"a",
"new",
"one",
"is",
"created",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L282-L295 | train | Sums a DataTable to this subtable | [
30522,
2270,
3853,
20571,
12083,
30524,
2023,
1011,
1028,
4152,
12083,
10880,
1006,
1007,
1025,
1065,
2842,
1063,
1002,
2023,
1011,
1028,
11582,
10128,
6342,
19279,
3085,
2389,
16416,
5149,
10288,
5130,
1006,
1007,
1025,
1002,
2023,
6342,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/ReplacesAttributes.php | ReplacesAttributes.replaceBefore | protected function replaceBefore($message, $attribute, $rule, $parameters)
{
if (! strtotime($parameters[0])) {
return str_replace(':date', $this->getDisplayableAttribute($parameters[0]), $message);
}
return str_replace(':date', $this->getDisplayableValue($attribute, $parameters[0]), $message);
} | php | protected function replaceBefore($message, $attribute, $rule, $parameters)
{
if (! strtotime($parameters[0])) {
return str_replace(':date', $this->getDisplayableAttribute($parameters[0]), $message);
}
return str_replace(':date', $this->getDisplayableValue($attribute, $parameters[0]), $message);
} | [
"protected",
"function",
"replaceBefore",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"!",
"strtotime",
"(",
"$",
"parameters",
"[",
"0",
"]",
")",
")",
"{",
"return",
"str_replace",
"(",
... | Replace all place-holders for the before rule.
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@return string | [
"Replace",
"all",
"place",
"-",
"holders",
"for",
"the",
"before",
"rule",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php#L386-L393 | train | Replace all place - holders for the before rule. | [
30522,
5123,
3853,
5672,
4783,
29278,
2063,
1006,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
1007,
1063,
2065,
1006,
999,
2358,
5339,
4140,
14428,
1006,
1002,
11709,
1031,
1014,
1033,
1007,
1007,
1063,
2709,
2358,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Payment/Order/Client.php | Client.close | public function close(string $tradeNo)
{
$params = [
'appid' => $this->app['config']->app_id,
'out_trade_no' => $tradeNo,
];
return $this->request($this->wrap('pay/closeorder'), $params);
} | php | public function close(string $tradeNo)
{
$params = [
'appid' => $this->app['config']->app_id,
'out_trade_no' => $tradeNo,
];
return $this->request($this->wrap('pay/closeorder'), $params);
} | [
"public",
"function",
"close",
"(",
"string",
"$",
"tradeNo",
")",
"{",
"$",
"params",
"=",
"[",
"'appid'",
"=>",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"app_id",
",",
"'out_trade_no'",
"=>",
"$",
"tradeNo",
",",
"]",
";",
"return",
"$... | Close order by out_trade_no.
@param string $tradeNo
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Close",
"order",
"by",
"out_trade_no",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Order/Client.php#L95-L103 | train | Close order. | [
30522,
2270,
3853,
2485,
1006,
5164,
1002,
3119,
3630,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
10439,
3593,
1005,
1027,
1028,
30524,
10236,
1006,
1005,
3477,
1013,
2485,
8551,
2121,
1005,
1007,
1010,
1002,
11498,
5244,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php | MySqlGrammar.compilePrimary | public function compilePrimary(Blueprint $blueprint, Fluent $command)
{
$command->name(null);
return $this->compileKey($blueprint, $command, 'primary key');
} | php | public function compilePrimary(Blueprint $blueprint, Fluent $command)
{
$command->name(null);
return $this->compileKey($blueprint, $command, 'primary key');
} | [
"public",
"function",
"compilePrimary",
"(",
"Blueprint",
"$",
"blueprint",
",",
"Fluent",
"$",
"command",
")",
"{",
"$",
"command",
"->",
"name",
"(",
"null",
")",
";",
"return",
"$",
"this",
"->",
"compileKey",
"(",
"$",
"blueprint",
",",
"$",
"command... | Compile a primary key command.
@param \Illuminate\Database\Schema\Blueprint $blueprint
@param \Illuminate\Support\Fluent $command
@return string | [
"Compile",
"a",
"primary",
"key",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php#L166-L171 | train | Compiles a primary key | [
30522,
2270,
3853,
4012,
22090,
18098,
9581,
2854,
1006,
2630,
16550,
1002,
2630,
16550,
1010,
19376,
1002,
3094,
1007,
1063,
1002,
3094,
1011,
1028,
2171,
1006,
19701,
1007,
1025,
2709,
1002,
2023,
1011,
1028,
4012,
22090,
14839,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Visit/VisitProperties.php | VisitProperties.getProperty | public function getProperty($name)
{
return isset($this->visitInfo[$name]) ? $this->visitInfo[$name] : null;
} | php | public function getProperty($name)
{
return isset($this->visitInfo[$name]) ? $this->visitInfo[$name] : null;
} | [
"public",
"function",
"getProperty",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"visitInfo",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"visitInfo",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] | Returns a visit property, or `null` if none is set.
@param string $name The property name.
@return mixed | [
"Returns",
"a",
"visit",
"property",
"or",
"null",
"if",
"none",
"is",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Visit/VisitProperties.php#L30-L33 | train | Get a property value | [
30522,
2270,
3853,
2131,
21572,
4842,
3723,
1006,
1002,
2171,
1007,
1063,
2709,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
3942,
2378,
14876,
1031,
1002,
2171,
1033,
1007,
1029,
1002,
2023,
1011,
1028,
3942,
2378,
14876,
1031,
1002,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spatie/laravel-permission | src/Traits/HasPermissions.php | HasPermissions.getPermissionsViaRoles | public function getPermissionsViaRoles(): Collection
{
return $this->load('roles', 'roles.permissions')
->roles->flatMap(function ($role) {
return $role->permissions;
})->sort()->values();
} | php | public function getPermissionsViaRoles(): Collection
{
return $this->load('roles', 'roles.permissions')
->roles->flatMap(function ($role) {
return $role->permissions;
})->sort()->values();
} | [
"public",
"function",
"getPermissionsViaRoles",
"(",
")",
":",
"Collection",
"{",
"return",
"$",
"this",
"->",
"load",
"(",
"'roles'",
",",
"'roles.permissions'",
")",
"->",
"roles",
"->",
"flatMap",
"(",
"function",
"(",
"$",
"role",
")",
"{",
"return",
"... | Return all the permissions the model has via roles. | [
"Return",
"all",
"the",
"permissions",
"the",
"model",
"has",
"via",
"roles",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Traits/HasPermissions.php#L263-L269 | train | Get permissions via roles | [
30522,
2270,
3853,
2131,
4842,
25481,
2015,
9035,
13153,
2229,
1006,
1007,
1024,
3074,
1063,
2709,
1002,
2023,
1011,
1028,
7170,
1006,
1005,
4395,
1005,
1010,
1005,
4395,
1012,
6656,
2015,
1005,
1007,
1011,
1028,
4395,
1011,
1028,
4257,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/RateLimiter.php | RateLimiter.hit | public function hit($key, $decaySeconds = 60)
{
$this->cache->add(
$key.':timer', $this->availableAt($decaySeconds), $decaySeconds
);
$added = $this->cache->add($key, 0, $decaySeconds);
$hits = (int) $this->cache->increment($key);
if (! $added && $hits == 1) {
$this->cache->put($key, 1, $decaySeconds);
}
return $hits;
} | php | public function hit($key, $decaySeconds = 60)
{
$this->cache->add(
$key.':timer', $this->availableAt($decaySeconds), $decaySeconds
);
$added = $this->cache->add($key, 0, $decaySeconds);
$hits = (int) $this->cache->increment($key);
if (! $added && $hits == 1) {
$this->cache->put($key, 1, $decaySeconds);
}
return $hits;
} | [
"public",
"function",
"hit",
"(",
"$",
"key",
",",
"$",
"decaySeconds",
"=",
"60",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"add",
"(",
"$",
"key",
".",
"':timer'",
",",
"$",
"this",
"->",
"availableAt",
"(",
"$",
"decaySeconds",
")",
",",
"$",
... | Increment the counter for a given key for a given decay time.
@param string $key
@param int $decaySeconds
@return int | [
"Increment",
"the",
"counter",
"for",
"a",
"given",
"key",
"for",
"a",
"given",
"decay",
"time",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/RateLimiter.php#L57-L72 | train | Hit the cache for the given key | [
30522,
2270,
3853,
2718,
1006,
1002,
3145,
1010,
1002,
13121,
3366,
8663,
5104,
1027,
3438,
1007,
1063,
1002,
2023,
1011,
1028,
17053,
1011,
1028,
5587,
1006,
1002,
3145,
1012,
1005,
1024,
25309,
1005,
1010,
1002,
2023,
1011,
1028,
2800,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Loader.php | HTML_QuickForm2_Loader.loadClass | public static function loadClass($className, $includeFile = null)
{
if (class_exists($className, false) || interface_exists($className, false)) {
return true;
}
if (empty($includeFile)) {
$includeFile = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
}
// Do not silence the errors with @, parse errors will not be seen
include $includeFile;
// Still no class?
if (!class_exists($className, false) && !interface_exists($className, false)) {
if (!self::fileExists($includeFile)) {
throw new HTML_QuickForm2_NotFoundException(
"File '$includeFile' was not found"
);
} else {
throw new HTML_QuickForm2_NotFoundException(
"Class '$className' was not found within file '$includeFile'"
);
}
}
} | php | public static function loadClass($className, $includeFile = null)
{
if (class_exists($className, false) || interface_exists($className, false)) {
return true;
}
if (empty($includeFile)) {
$includeFile = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
}
// Do not silence the errors with @, parse errors will not be seen
include $includeFile;
// Still no class?
if (!class_exists($className, false) && !interface_exists($className, false)) {
if (!self::fileExists($includeFile)) {
throw new HTML_QuickForm2_NotFoundException(
"File '$includeFile' was not found"
);
} else {
throw new HTML_QuickForm2_NotFoundException(
"Class '$className' was not found within file '$includeFile'"
);
}
}
} | [
"public",
"static",
"function",
"loadClass",
"(",
"$",
"className",
",",
"$",
"includeFile",
"=",
"null",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
"||",
"interface_exists",
"(",
"$",
"className",
",",
"false",
")",
"... | Tries to load a given class
If no $includeFile was provided, $className will be used with underscores
replaced with path separators and '.php' extension appended
@param string Class name to load
@param string Name of the file (supposedly) containing the given class
@throws HTML_QuickForm2_NotFoundException If the file either can't be
loaded or doesn't contain the given class | [
"Tries",
"to",
"load",
"a",
"given",
"class"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Loader.php#L74-L98 | train | Load class by name | [
30522,
2270,
10763,
3853,
7170,
26266,
1006,
1002,
2465,
18442,
1010,
1002,
2421,
8873,
2571,
1027,
19701,
1007,
1063,
2065,
1006,
2465,
1035,
6526,
1006,
1002,
2465,
18442,
1010,
6270,
1007,
1064,
1064,
8278,
1035,
6526,
1006,
1002,
2465,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformer.php | IntlTimeZoneToStringTransformer.transform | public function transform($intlTimeZone)
{
if (null === $intlTimeZone) {
return;
}
if ($this->multiple) {
if (!\is_array($intlTimeZone)) {
throw new TransformationFailedException('Expected an array of \IntlTimeZone objects.');
}
return array_map([new self(), 'transform'], $intlTimeZone);
}
if (!$intlTimeZone instanceof \IntlTimeZone) {
throw new TransformationFailedException('Expected a \IntlTimeZone object.');
}
return $intlTimeZone->getID();
} | php | public function transform($intlTimeZone)
{
if (null === $intlTimeZone) {
return;
}
if ($this->multiple) {
if (!\is_array($intlTimeZone)) {
throw new TransformationFailedException('Expected an array of \IntlTimeZone objects.');
}
return array_map([new self(), 'transform'], $intlTimeZone);
}
if (!$intlTimeZone instanceof \IntlTimeZone) {
throw new TransformationFailedException('Expected a \IntlTimeZone object.');
}
return $intlTimeZone->getID();
} | [
"public",
"function",
"transform",
"(",
"$",
"intlTimeZone",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"intlTimeZone",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"multiple",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"int... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntlTimeZoneToStringTransformer.php#L34-L53 | train | Transform a \ IntlTimeZone object into a single time zone ID | [
30522,
2270,
3853,
10938,
1006,
1002,
20014,
7096,
14428,
15975,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
20014,
7096,
14428,
15975,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
1002,
2023,
1011,
1028,
3674,
1007,
1063,
2065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Connection.php | Connection.select | public function select($query, $bindings = [], $useReadPdo = true)
{
return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
if ($this->pretending()) {
return [];
}
// For select statements, we'll simply execute the query and return an array
// of the database result set. Each element in the array will be a single
// row from the database table, and will either be an array or objects.
$statement = $this->prepared($this->getPdoForSelect($useReadPdo)
->prepare($query));
$this->bindValues($statement, $this->prepareBindings($bindings));
$statement->execute();
return $statement->fetchAll();
});
} | php | public function select($query, $bindings = [], $useReadPdo = true)
{
return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
if ($this->pretending()) {
return [];
}
// For select statements, we'll simply execute the query and return an array
// of the database result set. Each element in the array will be a single
// row from the database table, and will either be an array or objects.
$statement = $this->prepared($this->getPdoForSelect($useReadPdo)
->prepare($query));
$this->bindValues($statement, $this->prepareBindings($bindings));
$statement->execute();
return $statement->fetchAll();
});
} | [
"public",
"function",
"select",
"(",
"$",
"query",
",",
"$",
"bindings",
"=",
"[",
"]",
",",
"$",
"useReadPdo",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"run",
"(",
"$",
"query",
",",
"$",
"bindings",
",",
"function",
"(",
"$",
"query",
... | Run a select statement against the database.
@param string $query
@param array $bindings
@param bool $useReadPdo
@return array | [
"Run",
"a",
"select",
"statement",
"against",
"the",
"database",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connection.php#L315-L334 | train | Select all rows from a database table | [
30522,
2270,
3853,
7276,
1006,
1002,
23032,
1010,
1002,
8031,
2015,
1027,
1031,
1033,
1010,
1002,
5310,
13775,
17299,
2080,
1027,
2995,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2448,
1006,
1002,
23032,
1010,
1002,
8031,
2015,
1010,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Loader/XmlFileLoader.php | XmlFileLoader.parseDefaultNode | private function parseDefaultNode(\DOMElement $node, $path)
{
if ($this->isElementValueNull($node)) {
return;
}
switch ($node->localName) {
case 'bool':
return 'true' === trim($node->nodeValue) || '1' === trim($node->nodeValue);
case 'int':
return (int) trim($node->nodeValue);
case 'float':
return (float) trim($node->nodeValue);
case 'string':
return trim($node->nodeValue);
case 'list':
$list = [];
foreach ($node->childNodes as $element) {
if (!$element instanceof \DOMElement) {
continue;
}
if (self::NAMESPACE_URI !== $element->namespaceURI) {
continue;
}
$list[] = $this->parseDefaultNode($element, $path);
}
return $list;
case 'map':
$map = [];
foreach ($node->childNodes as $element) {
if (!$element instanceof \DOMElement) {
continue;
}
if (self::NAMESPACE_URI !== $element->namespaceURI) {
continue;
}
$map[$element->getAttribute('key')] = $this->parseDefaultNode($element, $path);
}
return $map;
default:
throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "bool", "int", "float", "string", "list", or "map".', $node->localName, $path));
}
} | php | private function parseDefaultNode(\DOMElement $node, $path)
{
if ($this->isElementValueNull($node)) {
return;
}
switch ($node->localName) {
case 'bool':
return 'true' === trim($node->nodeValue) || '1' === trim($node->nodeValue);
case 'int':
return (int) trim($node->nodeValue);
case 'float':
return (float) trim($node->nodeValue);
case 'string':
return trim($node->nodeValue);
case 'list':
$list = [];
foreach ($node->childNodes as $element) {
if (!$element instanceof \DOMElement) {
continue;
}
if (self::NAMESPACE_URI !== $element->namespaceURI) {
continue;
}
$list[] = $this->parseDefaultNode($element, $path);
}
return $list;
case 'map':
$map = [];
foreach ($node->childNodes as $element) {
if (!$element instanceof \DOMElement) {
continue;
}
if (self::NAMESPACE_URI !== $element->namespaceURI) {
continue;
}
$map[$element->getAttribute('key')] = $this->parseDefaultNode($element, $path);
}
return $map;
default:
throw new \InvalidArgumentException(sprintf('Unknown tag "%s" used in file "%s". Expected "bool", "int", "float", "string", "list", or "map".', $node->localName, $path));
}
} | [
"private",
"function",
"parseDefaultNode",
"(",
"\\",
"DOMElement",
"$",
"node",
",",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isElementValueNull",
"(",
"$",
"node",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"$",
"node",
"->",
"l... | Recursively parses the value of a "default" element.
@param \DOMElement $node The node value
@param string $path Full path of the XML file being processed
@return array|bool|float|int|string The parsed value
@throws \InvalidArgumentException when the XML is invalid | [
"Recursively",
"parses",
"the",
"value",
"of",
"a",
"default",
"element",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Loader/XmlFileLoader.php#L374-L424 | train | Parses the default node | [
30522,
2797,
3853,
11968,
6924,
12879,
23505,
3630,
3207,
1006,
1032,
8514,
16930,
4765,
1002,
13045,
1010,
1002,
4130,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
12260,
3672,
10175,
24997,
18083,
1006,
1002,
13045,
1007,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Builder.php | Builder.fromQuery | public function fromQuery($query, $bindings = [])
{
return $this->hydrate(
$this->query->getConnection()->select($query, $bindings)
);
} | php | public function fromQuery($query, $bindings = [])
{
return $this->hydrate(
$this->query->getConnection()->select($query, $bindings)
);
} | [
"public",
"function",
"fromQuery",
"(",
"$",
"query",
",",
"$",
"bindings",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"hydrate",
"(",
"$",
"this",
"->",
"query",
"->",
"getConnection",
"(",
")",
"->",
"select",
"(",
"$",
"query",
",",
"... | Create a collection of models from a raw query.
@param string $query
@param array $bindings
@return \Illuminate\Database\Eloquent\Collection | [
"Create",
"a",
"collection",
"of",
"models",
"from",
"a",
"raw",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Builder.php#L309-L314 | train | Select from query and return array of result objects | [
30522,
2270,
3853,
2013,
4226,
2854,
1006,
1002,
23032,
1010,
1002,
8031,
2015,
1027,
1031,
1033,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
26018,
2618,
1006,
1002,
2023,
1011,
1028,
23032,
1011,
1028,
2131,
8663,
2638,
7542,
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... |
getgrav/grav | system/src/Grav/Common/Language/Language.php | Language.translateArray | public function translateArray($key, $index, $languages = null, $html_out = false)
{
if ($this->config->get('system.languages.translations', true)) {
if ($this->enabled() && $key) {
if (empty($languages)) {
if ($this->config->get('system.languages.translations_fallback', true)) {
$languages = $this->getFallbackLanguages();
} else {
$languages = (array)$this->getDefault();
}
}
} else {
$languages = ['en'];
}
foreach ((array)$languages as $lang) {
$translation_array = (array)Grav::instance()['languages']->get($lang . '.' . $key, null);
if ($translation_array && array_key_exists($index, $translation_array)) {
return $translation_array[$index];
}
}
}
if ($html_out) {
return '<span class="untranslated">' . $key . '[' . $index . ']</span>';
}
return $key . '[' . $index . ']';
} | php | public function translateArray($key, $index, $languages = null, $html_out = false)
{
if ($this->config->get('system.languages.translations', true)) {
if ($this->enabled() && $key) {
if (empty($languages)) {
if ($this->config->get('system.languages.translations_fallback', true)) {
$languages = $this->getFallbackLanguages();
} else {
$languages = (array)$this->getDefault();
}
}
} else {
$languages = ['en'];
}
foreach ((array)$languages as $lang) {
$translation_array = (array)Grav::instance()['languages']->get($lang . '.' . $key, null);
if ($translation_array && array_key_exists($index, $translation_array)) {
return $translation_array[$index];
}
}
}
if ($html_out) {
return '<span class="untranslated">' . $key . '[' . $index . ']</span>';
}
return $key . '[' . $index . ']';
} | [
"public",
"function",
"translateArray",
"(",
"$",
"key",
",",
"$",
"index",
",",
"$",
"languages",
"=",
"null",
",",
"$",
"html_out",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'system.languages.translations'",
","... | Translate Array
@param string $key
@param string $index
@param array|null $languages
@param bool $html_out
@return string | [
"Translate",
"Array"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L439-L467 | train | Returns the translation array for the given key and index | [
30522,
2270,
3853,
17637,
2906,
9447,
1006,
1002,
3145,
1010,
1002,
5950,
1010,
1002,
4155,
1027,
19701,
1010,
1002,
16129,
1035,
2041,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1011,
1028,
2131,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Updater.php | Updater.update | public function update($componentName)
{
$warningMessages = array();
$this->executeListenerHook('onComponentUpdateStarting', array($componentName));
foreach ($this->componentsWithUpdateFile[$componentName] as $file => $fileVersion) {
try {
require_once $file; // prefixed by PIWIK_INCLUDE_PATH
$className = $this->getUpdateClassName($componentName, $fileVersion);
if (!in_array($className, $this->updatedClasses)
&& class_exists($className, false)
) {
$this->executeListenerHook('onComponentUpdateFileStarting', array($componentName, $file, $className, $fileVersion));
$this->executeSingleUpdateClass($className);
$this->executeListenerHook('onComponentUpdateFileFinished', array($componentName, $file, $className, $fileVersion));
// makes sure to call Piwik\Columns\Updater only once as one call updates all dimensions at the same
// time for better performance
$this->updatedClasses[] = $className;
}
$this->markComponentSuccessfullyUpdated($componentName, $fileVersion);
} catch (UpdaterErrorException $e) {
$this->executeListenerHook('onError', array($componentName, $fileVersion, $e));
throw $e;
} catch (\Exception $e) {
$warningMessages[] = $e->getMessage();
$this->executeListenerHook('onWarning', array($componentName, $fileVersion, $e));
}
}
// to debug, create core/Updates/X.php, update the core/Version.php, throw an Exception in the try, and comment the following lines
$updatedVersion = $this->componentsWithNewVersion[$componentName][self::INDEX_NEW_VERSION];
$this->markComponentSuccessfullyUpdated($componentName, $updatedVersion);
$this->executeListenerHook('onComponentUpdateFinished', array($componentName, $updatedVersion, $warningMessages));
ServerFilesGenerator::createHtAccessFiles();
return $warningMessages;
} | php | public function update($componentName)
{
$warningMessages = array();
$this->executeListenerHook('onComponentUpdateStarting', array($componentName));
foreach ($this->componentsWithUpdateFile[$componentName] as $file => $fileVersion) {
try {
require_once $file; // prefixed by PIWIK_INCLUDE_PATH
$className = $this->getUpdateClassName($componentName, $fileVersion);
if (!in_array($className, $this->updatedClasses)
&& class_exists($className, false)
) {
$this->executeListenerHook('onComponentUpdateFileStarting', array($componentName, $file, $className, $fileVersion));
$this->executeSingleUpdateClass($className);
$this->executeListenerHook('onComponentUpdateFileFinished', array($componentName, $file, $className, $fileVersion));
// makes sure to call Piwik\Columns\Updater only once as one call updates all dimensions at the same
// time for better performance
$this->updatedClasses[] = $className;
}
$this->markComponentSuccessfullyUpdated($componentName, $fileVersion);
} catch (UpdaterErrorException $e) {
$this->executeListenerHook('onError', array($componentName, $fileVersion, $e));
throw $e;
} catch (\Exception $e) {
$warningMessages[] = $e->getMessage();
$this->executeListenerHook('onWarning', array($componentName, $fileVersion, $e));
}
}
// to debug, create core/Updates/X.php, update the core/Version.php, throw an Exception in the try, and comment the following lines
$updatedVersion = $this->componentsWithNewVersion[$componentName][self::INDEX_NEW_VERSION];
$this->markComponentSuccessfullyUpdated($componentName, $updatedVersion);
$this->executeListenerHook('onComponentUpdateFinished', array($componentName, $updatedVersion, $warningMessages));
ServerFilesGenerator::createHtAccessFiles();
return $warningMessages;
} | [
"public",
"function",
"update",
"(",
"$",
"componentName",
")",
"{",
"$",
"warningMessages",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"executeListenerHook",
"(",
"'onComponentUpdateStarting'",
",",
"array",
"(",
"$",
"componentName",
")",
")",
";",
"f... | Update the named component
@param string $componentName 'core', or plugin name
@throws \Exception|UpdaterErrorException
@return array of warning strings if applicable | [
"Update",
"the",
"named",
"component"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater.php#L290-L334 | train | Updates the component | [
30522,
2270,
3853,
10651,
1006,
1002,
6922,
18442,
1007,
1063,
1002,
5432,
7834,
3736,
8449,
1027,
9140,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
15389,
9863,
24454,
6806,
6559,
1006,
1005,
2006,
9006,
29513,
3372,
6279,
27122,
7559,
3436,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RedisTagAwareAdapter.php | RedisTagAwareAdapter.doSave | protected function doSave(array $values, ?int $lifetime, array $addTagData = [], array $delTagData = []): array
{
// serialize values
if (!$serialized = $this->marshaller->marshall($values, $failed)) {
return $failed;
}
// While pipeline isn't supported on RedisCluster, other setups will at least benefit from doing this in one op
$results = $this->pipeline(static function () use ($serialized, $lifetime, $addTagData, $delTagData) {
// Store cache items, force a ttl if none is set, as there is no MSETEX we need to set each one
foreach ($serialized as $id => $value) {
yield 'setEx' => [
$id,
0 >= $lifetime ? self::DEFAULT_CACHE_TTL : $lifetime,
$value,
];
}
// Add and Remove Tags
foreach ($addTagData as $tagId => $ids) {
yield 'sAdd' => array_merge([$tagId], $ids);
}
foreach ($delTagData as $tagId => $ids) {
yield 'sRem' => array_merge([$tagId], $ids);
}
});
foreach ($results as $id => $result) {
// Skip results of SADD/SREM operations, they'll be 1 or 0 depending on if set value already existed or not
if (\is_numeric($result)) {
continue;
}
// setEx results
if (true !== $result && (!$result instanceof Status || $result !== Status::get('OK'))) {
$failed[] = $id;
}
}
return $failed;
} | php | protected function doSave(array $values, ?int $lifetime, array $addTagData = [], array $delTagData = []): array
{
// serialize values
if (!$serialized = $this->marshaller->marshall($values, $failed)) {
return $failed;
}
// While pipeline isn't supported on RedisCluster, other setups will at least benefit from doing this in one op
$results = $this->pipeline(static function () use ($serialized, $lifetime, $addTagData, $delTagData) {
// Store cache items, force a ttl if none is set, as there is no MSETEX we need to set each one
foreach ($serialized as $id => $value) {
yield 'setEx' => [
$id,
0 >= $lifetime ? self::DEFAULT_CACHE_TTL : $lifetime,
$value,
];
}
// Add and Remove Tags
foreach ($addTagData as $tagId => $ids) {
yield 'sAdd' => array_merge([$tagId], $ids);
}
foreach ($delTagData as $tagId => $ids) {
yield 'sRem' => array_merge([$tagId], $ids);
}
});
foreach ($results as $id => $result) {
// Skip results of SADD/SREM operations, they'll be 1 or 0 depending on if set value already existed or not
if (\is_numeric($result)) {
continue;
}
// setEx results
if (true !== $result && (!$result instanceof Status || $result !== Status::get('OK'))) {
$failed[] = $id;
}
}
return $failed;
} | [
"protected",
"function",
"doSave",
"(",
"array",
"$",
"values",
",",
"?",
"int",
"$",
"lifetime",
",",
"array",
"$",
"addTagData",
"=",
"[",
"]",
",",
"array",
"$",
"delTagData",
"=",
"[",
"]",
")",
":",
"array",
"{",
"// serialize values",
"if",
"(",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php#L93-L133 | train | Save cache items | [
30522,
5123,
3853,
9998,
10696,
1006,
9140,
1002,
5300,
1010,
1029,
20014,
1002,
6480,
1010,
9140,
1002,
5587,
15900,
2850,
2696,
1027,
1031,
1033,
1010,
9140,
1002,
7160,
2290,
2850,
2696,
1027,
1031,
1033,
1007,
1024,
9140,
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... |
getgrav/grav | system/src/Grav/Common/Config/ConfigFileFinder.php | ConfigFileFinder.locateFile | public function locateFile(array $paths, $name, $ext = '.yaml')
{
$filename = preg_replace('|[.\/]+|', '/', $name) . $ext;
$list = [];
foreach ($paths as $folder) {
$path = trim(Folder::getRelativePath($folder), '/');
if (is_file("{$folder}/{$filename}")) {
$modified = filemtime("{$folder}/{$filename}");
} else {
$modified = 0;
}
$basename = $this->base . $name;
$list[$path] = [$basename => ['file' => "{$path}/{$filename}", 'modified' => $modified]];
}
return $list;
} | php | public function locateFile(array $paths, $name, $ext = '.yaml')
{
$filename = preg_replace('|[.\/]+|', '/', $name) . $ext;
$list = [];
foreach ($paths as $folder) {
$path = trim(Folder::getRelativePath($folder), '/');
if (is_file("{$folder}/{$filename}")) {
$modified = filemtime("{$folder}/{$filename}");
} else {
$modified = 0;
}
$basename = $this->base . $name;
$list[$path] = [$basename => ['file' => "{$path}/{$filename}", 'modified' => $modified]];
}
return $list;
} | [
"public",
"function",
"locateFile",
"(",
"array",
"$",
"paths",
",",
"$",
"name",
",",
"$",
"ext",
"=",
"'.yaml'",
")",
"{",
"$",
"filename",
"=",
"preg_replace",
"(",
"'|[.\\/]+|'",
",",
"'/'",
",",
"$",
"name",
")",
".",
"$",
"ext",
";",
"$",
"li... | Return all existing locations for a single file with a timestamp.
@param array $paths Filesystem paths to look up from.
@param string $name Configuration file to be located.
@param string $ext File extension (optional, defaults to .yaml).
@return array | [
"Return",
"all",
"existing",
"locations",
"for",
"a",
"single",
"file",
"with",
"a",
"timestamp",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Config/ConfigFileFinder.php#L127-L145 | train | Locates a file in a list of paths | [
30522,
2270,
3853,
12453,
8873,
2571,
1006,
9140,
1002,
10425,
1010,
1002,
2171,
1010,
1002,
4654,
2102,
1027,
1005,
1012,
8038,
19968,
1005,
1007,
1063,
1002,
5371,
18442,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
1064,
1031,
1012,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DoctrineProvider.php | DoctrineProvider.reset | public function reset()
{
if ($this->pool instanceof ResetInterface) {
$this->pool->reset();
}
$this->setNamespace($this->getNamespace());
} | php | public function reset()
{
if ($this->pool instanceof ResetInterface) {
$this->pool->reset();
}
$this->setNamespace($this->getNamespace());
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pool",
"instanceof",
"ResetInterface",
")",
"{",
"$",
"this",
"->",
"pool",
"->",
"reset",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setNamespace",
"(",
"$",
"this",
"->",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/DoctrineProvider.php#L41-L47 | train | Reset the namespace | [
30522,
2270,
3853,
25141,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
4770,
6013,
11253,
25141,
18447,
2121,
12172,
1007,
1063,
1002,
2023,
1011,
1028,
4770,
1011,
1028,
25141,
1006,
1007,
1025,
1065,
1002,
2023,
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... |
matomo-org/matomo | plugins/CoreAdminHome/API.php | API.deleteAllTrackingFailures | public function deleteAllTrackingFailures()
{
if (Piwik::hasUserSuperUserAccess()) {
$this->trackingFailures->deleteAllTrackingFailures();
} else {
Piwik::checkUserHasSomeAdminAccess();
$idSites = Access::getInstance()->getSitesIdWithAdminAccess();
Piwik::checkUserHasAdminAccess($idSites);
$this->trackingFailures->deleteTrackingFailures($idSites);
}
} | php | public function deleteAllTrackingFailures()
{
if (Piwik::hasUserSuperUserAccess()) {
$this->trackingFailures->deleteAllTrackingFailures();
} else {
Piwik::checkUserHasSomeAdminAccess();
$idSites = Access::getInstance()->getSitesIdWithAdminAccess();
Piwik::checkUserHasAdminAccess($idSites);
$this->trackingFailures->deleteTrackingFailures($idSites);
}
} | [
"public",
"function",
"deleteAllTrackingFailures",
"(",
")",
"{",
"if",
"(",
"Piwik",
"::",
"hasUserSuperUserAccess",
"(",
")",
")",
"{",
"$",
"this",
"->",
"trackingFailures",
"->",
"deleteAllTrackingFailures",
"(",
")",
";",
"}",
"else",
"{",
"Piwik",
"::",
... | Deletes all tracking failures this user has at least admin access to.
A super user will also delete tracking failures for sites that don't exist. | [
"Deletes",
"all",
"tracking",
"failures",
"this",
"user",
"has",
"at",
"least",
"admin",
"access",
"to",
".",
"A",
"super",
"user",
"will",
"also",
"delete",
"tracking",
"failures",
"for",
"sites",
"that",
"don",
"t",
"exist",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreAdminHome/API.php#L194-L204 | train | Delete all tracking failures for all sites | [
30522,
2270,
3853,
3972,
12870,
8095,
6494,
23177,
7011,
4014,
14900,
1006,
1007,
1063,
2065,
1006,
14255,
9148,
2243,
1024,
1024,
2038,
20330,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
9651,
7011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/Storage/FileStorage.php | FileStorage.getMediaPath | public function getMediaPath(string $key = null): string
{
return $key ? \dirname($this->getStoragePath($key)) . '/' . $key : $this->getStoragePath();
} | php | public function getMediaPath(string $key = null): string
{
return $key ? \dirname($this->getStoragePath($key)) . '/' . $key : $this->getStoragePath();
} | [
"public",
"function",
"getMediaPath",
"(",
"string",
"$",
"key",
"=",
"null",
")",
":",
"string",
"{",
"return",
"$",
"key",
"?",
"\\",
"dirname",
"(",
"$",
"this",
"->",
"getStoragePath",
"(",
"$",
"key",
")",
")",
".",
"'/'",
".",
"$",
"key",
":"... | {@inheritdoc}
@see FlexStorageInterface::getMediaPath() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/Storage/FileStorage.php#L41-L44 | train | Get Media Path | [
30522,
2270,
3853,
2131,
16969,
15069,
1006,
5164,
1002,
3145,
1027,
19701,
1007,
1024,
5164,
1063,
2709,
1002,
3145,
1029,
1032,
16101,
18442,
1006,
1002,
2023,
1011,
1028,
4152,
4263,
4270,
15069,
1006,
1002,
3145,
1007,
1007,
1012,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/SettingsServer.php | SettingsServer.isIIS | public static function isIIS()
{
$iis = isset($_SERVER['SERVER_SOFTWARE']) &&
preg_match('/^Microsoft-IIS\/(.+)/', $_SERVER['SERVER_SOFTWARE'], $matches) &&
version_compare($matches[1], '7') >= 0;
return $iis;
} | php | public static function isIIS()
{
$iis = isset($_SERVER['SERVER_SOFTWARE']) &&
preg_match('/^Microsoft-IIS\/(.+)/', $_SERVER['SERVER_SOFTWARE'], $matches) &&
version_compare($matches[1], '7') >= 0;
return $iis;
} | [
"public",
"static",
"function",
"isIIS",
"(",
")",
"{",
"$",
"iis",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_SOFTWARE'",
"]",
")",
"&&",
"preg_match",
"(",
"'/^Microsoft-IIS\\/(.+)/'",
",",
"$",
"_SERVER",
"[",
"'SERVER_SOFTWARE'",
"]",
",",
"$",
"... | Returns `true` if running on Microsoft IIS 7 (or above), `false` if otherwise.
@return bool
@api | [
"Returns",
"true",
"if",
"running",
"on",
"Microsoft",
"IIS",
"7",
"(",
"or",
"above",
")",
"false",
"if",
"otherwise",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/SettingsServer.php#L65-L72 | train | Return TRUE if current version is Microsoft IIS | [
30522,
2270,
10763,
3853,
2003,
6137,
2015,
1006,
1007,
1063,
1002,
2462,
2015,
1027,
26354,
3388,
1006,
1002,
1035,
30524,
2015,
1032,
1013,
1006,
1012,
1009,
1007,
1013,
1005,
1010,
1002,
1035,
8241,
1031,
1005,
8241,
1035,
4007,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Db.php | Db.fetchOne | public function fetchOne($query, $parameters = array())
{
$result = $this->fetch($query, $parameters);
return is_array($result) && !empty($result) ? reset($result) : false;
} | php | public function fetchOne($query, $parameters = array())
{
$result = $this->fetch($query, $parameters);
return is_array($result) && !empty($result) ? reset($result) : false;
} | [
"public",
"function",
"fetchOne",
"(",
"$",
"query",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"query",
",",
"$",
"parameters",
")",
";",
"return",
"is_array",
"(",
"$",
"res... | This function is a proxy to fetch(), used to maintain compatibility with Zend_Db interface
@see fetch()
@param string $query Query
@param array $parameters Parameters to bind
@return bool|mixed | [
"This",
"function",
"is",
"a",
"proxy",
"to",
"fetch",
"()",
"used",
"to",
"maintain",
"compatibility",
"with",
"Zend_Db",
"interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Db.php#L180-L184 | train | Fetch one record from the database | [
30522,
2270,
3853,
18584,
5643,
1006,
1002,
23032,
1010,
1002,
11709,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
18584,
1006,
1002,
23032,
1010,
1002,
11709,
1007,
1025,
2709,
2003,
1035,
9140,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.doCallback | protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra)
{
if (!empty($this->action_function) and is_callable($this->action_function)) {
call_user_func($this->action_function, $isSent, $to, $cc, $bcc, $subject, $body, $from, $extra);
}
} | php | protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from, $extra)
{
if (!empty($this->action_function) and is_callable($this->action_function)) {
call_user_func($this->action_function, $isSent, $to, $cc, $bcc, $subject, $body, $from, $extra);
}
} | [
"protected",
"function",
"doCallback",
"(",
"$",
"isSent",
",",
"$",
"to",
",",
"$",
"cc",
",",
"$",
"bcc",
",",
"$",
"subject",
",",
"$",
"body",
",",
"$",
"from",
",",
"$",
"extra",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
... | Perform a callback.
@param bool $isSent
@param array $to
@param array $cc
@param array $bcc
@param string $subject
@param string $body
@param string $from
@param array $extra | [
"Perform",
"a",
"callback",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L4504-L4509 | train | Callback function for the action function | [
30522,
5123,
3853,
9986,
8095,
5963,
1006,
1002,
26354,
4765,
1010,
1002,
2000,
1010,
1002,
10507,
1010,
1002,
4647,
2278,
1010,
1002,
3395,
1010,
1002,
2303,
1010,
1002,
2013,
1010,
1002,
4469,
1007,
1063,
2065,
1006,
999,
4064,
1006,
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/UpdateCheck.php | UpdateCheck.isNewestVersionAvailable | public static function isNewestVersionAvailable()
{
$latestVersion = self::getLatestVersion();
if (!empty($latestVersion)
&& version_compare(Version::VERSION, $latestVersion) == -1
) {
return $latestVersion;
}
return false;
} | php | public static function isNewestVersionAvailable()
{
$latestVersion = self::getLatestVersion();
if (!empty($latestVersion)
&& version_compare(Version::VERSION, $latestVersion) == -1
) {
return $latestVersion;
}
return false;
} | [
"public",
"static",
"function",
"isNewestVersionAvailable",
"(",
")",
"{",
"$",
"latestVersion",
"=",
"self",
"::",
"getLatestVersion",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"latestVersion",
")",
"&&",
"version_compare",
"(",
"Version",
"::",
"VE... | Returns version number of a newer Piwik release.
@return string|bool false if current version is the latest available,
or the latest version number if a newest release is available | [
"Returns",
"version",
"number",
"of",
"a",
"newer",
"Piwik",
"release",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/UpdateCheck.php#L96-L105 | train | Returns the latest version of the language | [
30522,
2270,
10763,
3853,
3475,
7974,
4355,
27774,
12462,
11733,
3468,
1006,
1007,
1063,
1002,
6745,
27774,
1027,
2969,
1024,
1024,
2131,
26786,
9189,
2545,
3258,
1006,
1007,
1025,
2065,
1006,
999,
4064,
1006,
1002,
6745,
27774,
1007,
1004,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Session/Namespace.php | Zend_Session_Namespace.setExpirationHops | public function setExpirationHops($hops, $variables = null, $hopCountOnUsageOnly = false)
{
if (parent::$_writable === false) {
/**
* @see Zend_Session_Exception
*/
// require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);
}
if ($hops <= 0) {
/**
* @see Zend_Session_Exception
*/
// require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception('Hops must be positive number.');
}
if ($variables === null) {
// apply expiration to entire namespace
if ($hopCountOnUsageOnly === false) {
$_SESSION['__ZF'][$this->_namespace]['ENGH'] = $hops;
} else {
$_SESSION['__ZF'][$this->_namespace]['ENNH'] = $hops;
}
} else {
if (is_string($variables)) {
$variables = array($variables);
}
foreach ($variables as $variable) {
if (!empty($variable)) {
if ($hopCountOnUsageOnly === false) {
$_SESSION['__ZF'][$this->_namespace]['ENVGH'][$variable] = $hops;
} else {
$_SESSION['__ZF'][$this->_namespace]['ENVNH'][$variable] = $hops;
}
}
}
}
} | php | public function setExpirationHops($hops, $variables = null, $hopCountOnUsageOnly = false)
{
if (parent::$_writable === false) {
/**
* @see Zend_Session_Exception
*/
// require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception(parent::_THROW_NOT_WRITABLE_MSG);
}
if ($hops <= 0) {
/**
* @see Zend_Session_Exception
*/
// require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception('Hops must be positive number.');
}
if ($variables === null) {
// apply expiration to entire namespace
if ($hopCountOnUsageOnly === false) {
$_SESSION['__ZF'][$this->_namespace]['ENGH'] = $hops;
} else {
$_SESSION['__ZF'][$this->_namespace]['ENNH'] = $hops;
}
} else {
if (is_string($variables)) {
$variables = array($variables);
}
foreach ($variables as $variable) {
if (!empty($variable)) {
if ($hopCountOnUsageOnly === false) {
$_SESSION['__ZF'][$this->_namespace]['ENVGH'][$variable] = $hops;
} else {
$_SESSION['__ZF'][$this->_namespace]['ENVNH'][$variable] = $hops;
}
}
}
}
} | [
"public",
"function",
"setExpirationHops",
"(",
"$",
"hops",
",",
"$",
"variables",
"=",
"null",
",",
"$",
"hopCountOnUsageOnly",
"=",
"false",
")",
"{",
"if",
"(",
"parent",
"::",
"$",
"_writable",
"===",
"false",
")",
"{",
"/**\n * @see Zend_Sess... | setExpirationHops() - expire the namespace, or specific variables after a specified
number of page hops
@param int $hops - how many "hops" (number of subsequent requests) before expiring
@param mixed $variables - OPTIONAL list of variables to expire (defaults to all)
@param boolean $hopCountOnUsageOnly - OPTIONAL if set, only count a hop/request if this namespace is used
@throws Zend_Session_Exception
@return void | [
"setExpirationHops",
"()",
"-",
"expire",
"the",
"namespace",
"or",
"specific",
"variables",
"after",
"a",
"specified",
"number",
"of",
"page",
"hops"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session/Namespace.php#L475-L518 | train | Set expiration hops | [
30522,
2270,
3853,
2275,
10288,
16781,
18471,
2015,
1006,
1002,
6154,
2015,
1010,
1002,
10857,
1027,
19701,
1010,
1002,
6154,
3597,
16671,
24891,
4270,
2239,
2135,
1027,
6270,
1007,
1063,
2065,
1006,
6687,
1024,
1024,
1002,
1035,
25697,
308... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Middleware.php | Middleware.retry | public static function retry(callable $decider, callable $delay = null)
{
return function (callable $handler) use ($decider, $delay) {
return new RetryMiddleware($decider, $handler, $delay);
};
} | php | public static function retry(callable $decider, callable $delay = null)
{
return function (callable $handler) use ($decider, $delay) {
return new RetryMiddleware($decider, $handler, $delay);
};
} | [
"public",
"static",
"function",
"retry",
"(",
"callable",
"$",
"decider",
",",
"callable",
"$",
"delay",
"=",
"null",
")",
"{",
"return",
"function",
"(",
"callable",
"$",
"handler",
")",
"use",
"(",
"$",
"decider",
",",
"$",
"delay",
")",
"{",
"return... | Middleware that retries requests based on the boolean result of
invoking the provided "decider" function.
If no delay function is provided, a simple implementation of exponential
backoff will be utilized.
@param callable $decider Function that accepts the number of retries,
a request, [response], and [exception] and
returns true if the request is to be retried.
@param callable $delay Function that accepts the number of retries and
returns the number of milliseconds to delay.
@return callable Returns a function that accepts the next handler. | [
"Middleware",
"that",
"retries",
"requests",
"based",
"on",
"the",
"boolean",
"result",
"of",
"invoking",
"the",
"provided",
"decider",
"function",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Middleware.php#L169-L174 | train | Creates a middleware that will retry the request | [
30522,
2270,
10763,
3853,
2128,
11129,
1006,
2655,
3085,
1002,
5630,
2099,
1010,
2655,
3085,
1002,
8536,
1027,
19701,
1007,
1063,
2709,
3853,
1006,
2655,
3085,
1002,
28213,
1007,
2224,
1006,
1002,
5630,
2099,
1010,
1002,
8536,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid.php | Grid.getCreateUrl | public function getCreateUrl()
{
$queryString = '';
if ($constraints = $this->model()->getConstraints()) {
$queryString = http_build_query($constraints);
}
return sprintf('%s/create%s',
$this->resource(),
$queryString ? ('?'.$queryString) : ''
);
} | php | public function getCreateUrl()
{
$queryString = '';
if ($constraints = $this->model()->getConstraints()) {
$queryString = http_build_query($constraints);
}
return sprintf('%s/create%s',
$this->resource(),
$queryString ? ('?'.$queryString) : ''
);
} | [
"public",
"function",
"getCreateUrl",
"(",
")",
"{",
"$",
"queryString",
"=",
"''",
";",
"if",
"(",
"$",
"constraints",
"=",
"$",
"this",
"->",
"model",
"(",
")",
"->",
"getConstraints",
"(",
")",
")",
"{",
"$",
"queryString",
"=",
"http_build_query",
... | Get create url.
@return string | [
"Get",
"create",
"url",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L667-L679 | train | Get create url | [
30522,
2270,
3853,
2131,
16748,
3686,
3126,
2140,
1006,
1007,
1063,
1002,
23032,
3367,
4892,
1027,
1005,
1005,
1025,
2065,
1006,
1002,
14679,
1027,
1002,
2023,
1011,
1028,
2944,
1006,
1007,
1011,
1028,
2131,
8663,
20528,
18447,
2015,
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... |
PHPMailer/PHPMailer | src/SMTP.php | SMTP.startTLS | public function startTLS()
{
if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
return false;
}
//Allow the best TLS version(s) we can
$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
//PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
//so add them back in manually if we can
if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
}
// Begin encrypted connection
set_error_handler([$this, 'errorHandler']);
$crypto_ok = stream_socket_enable_crypto(
$this->smtp_conn,
true,
$crypto_method
);
restore_error_handler();
return (bool) $crypto_ok;
} | php | public function startTLS()
{
if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
return false;
}
//Allow the best TLS version(s) we can
$crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
//PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
//so add them back in manually if we can
if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
}
// Begin encrypted connection
set_error_handler([$this, 'errorHandler']);
$crypto_ok = stream_socket_enable_crypto(
$this->smtp_conn,
true,
$crypto_method
);
restore_error_handler();
return (bool) $crypto_ok;
} | [
"public",
"function",
"startTLS",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sendCommand",
"(",
"'STARTTLS'",
",",
"'STARTTLS'",
",",
"220",
")",
")",
"{",
"return",
"false",
";",
"}",
"//Allow the best TLS version(s) we can",
"$",
"crypto_method",
"... | Initiate a TLS (encrypted) session.
@return bool | [
"Initiate",
"a",
"TLS",
"(",
"encrypted",
")",
"session",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/SMTP.php#L384-L410 | train | Starts the TLS connection | [
30522,
2270,
3853,
2707,
19646,
2015,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
4604,
9006,
2386,
2094,
1006,
1005,
2707,
19646,
2015,
1005,
1010,
1005,
2707,
19646,
2015,
1005,
1010,
10545,
1007,
1007,
1063,
2709,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Question/Question.php | Question.setAutocompleterCallback | public function setAutocompleterCallback(callable $callback = null): self
{
if ($this->hidden && null !== $callback) {
throw new LogicException('A hidden question cannot use the autocompleter.');
}
$this->autocompleterCallback = $callback;
return $this;
} | php | public function setAutocompleterCallback(callable $callback = null): self
{
if ($this->hidden && null !== $callback) {
throw new LogicException('A hidden question cannot use the autocompleter.');
}
$this->autocompleterCallback = $callback;
return $this;
} | [
"public",
"function",
"setAutocompleterCallback",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"hidden",
"&&",
"null",
"!==",
"$",
"callback",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'A hidde... | Sets the callback function used for the autocompleter.
The callback is passed the user input as argument and should return an iterable of corresponding suggestions.
@return $this | [
"Sets",
"the",
"callback",
"function",
"used",
"for",
"the",
"autocompleter",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Question/Question.php#L176-L185 | train | Sets the callback function to be called when the autocompleter is executed. | [
30522,
2270,
3853,
2275,
4887,
3406,
9006,
10814,
3334,
9289,
20850,
8684,
1006,
2655,
3085,
1002,
2655,
5963,
1027,
19701,
1007,
1024,
2969,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
30524,
10814,
3334,
1012,
1005,
1007,
1025,
1065,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/FlexDirectory.php | FlexDirectory.getIndex | public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface
{
$index = clone $this->loadIndex();
$index = $index->withKeyField($keyField);
if (null !== $keys) {
$index = $index->select($keys);
}
return $index->getIndex();
} | php | public function getIndex(array $keys = null, string $keyField = null): FlexIndexInterface
{
$index = clone $this->loadIndex();
$index = $index->withKeyField($keyField);
if (null !== $keys) {
$index = $index->select($keys);
}
return $index->getIndex();
} | [
"public",
"function",
"getIndex",
"(",
"array",
"$",
"keys",
"=",
"null",
",",
"string",
"$",
"keyField",
"=",
"null",
")",
":",
"FlexIndexInterface",
"{",
"$",
"index",
"=",
"clone",
"$",
"this",
"->",
"loadIndex",
"(",
")",
";",
"$",
"index",
"=",
... | Get the full collection of all stored objects.
Use $directory->getCollection() if you want a filtered collection.
@param array|null $keys Array of keys.
@param string|null $keyField Field to be used as the key.
@return FlexIndexInterface | [
"Get",
"the",
"full",
"collection",
"of",
"all",
"stored",
"objects",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/FlexDirectory.php#L212-L222 | train | Get index from the repository | [
30522,
2270,
3853,
2131,
22254,
10288,
1006,
9140,
1002,
6309,
1027,
19701,
1010,
5164,
1002,
3145,
3790,
1027,
19701,
1007,
1024,
23951,
22254,
10288,
18447,
2121,
12172,
1063,
1002,
5950,
1027,
17598,
1002,
2023,
1011,
1028,
7170,
22254,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable.php | DataTable.addDataTable | public function addDataTable(DataTable $tableToSum)
{
if ($tableToSum instanceof Simple) {
if ($tableToSum->getRowsCount() > 1) {
throw new Exception("Did not expect a Simple table with more than one row in addDataTable()");
}
$row = $tableToSum->getFirstRow();
$this->aggregateRowFromSimpleTable($row);
} else {
$columnAggregationOps = $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
foreach ($tableToSum->getRowsWithoutSummaryRow() as $row) {
$this->aggregateRowWithLabel($row, $columnAggregationOps);
}
// we do not use getRows() as this method might get called 100k times when aggregating many datatables and
// this takes a lot of time.
$row = $tableToSum->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($row) {
$this->aggregateRowWithLabel($row, $columnAggregationOps);
}
}
} | php | public function addDataTable(DataTable $tableToSum)
{
if ($tableToSum instanceof Simple) {
if ($tableToSum->getRowsCount() > 1) {
throw new Exception("Did not expect a Simple table with more than one row in addDataTable()");
}
$row = $tableToSum->getFirstRow();
$this->aggregateRowFromSimpleTable($row);
} else {
$columnAggregationOps = $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
foreach ($tableToSum->getRowsWithoutSummaryRow() as $row) {
$this->aggregateRowWithLabel($row, $columnAggregationOps);
}
// we do not use getRows() as this method might get called 100k times when aggregating many datatables and
// this takes a lot of time.
$row = $tableToSum->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($row) {
$this->aggregateRowWithLabel($row, $columnAggregationOps);
}
}
} | [
"public",
"function",
"addDataTable",
"(",
"DataTable",
"$",
"tableToSum",
")",
"{",
"if",
"(",
"$",
"tableToSum",
"instanceof",
"Simple",
")",
"{",
"if",
"(",
"$",
"tableToSum",
"->",
"getRowsCount",
"(",
")",
">",
"1",
")",
"{",
"throw",
"new",
"Except... | Sums a DataTable to this one.
This method will sum rows that have the same label. If a row is found in `$tableToSum` whose
label is not found in `$this`, the row will be added to `$this`.
If the subtables for this table are loaded, they will be summed as well.
Rows are summed together by summing individual columns. By default columns are summed by
adding one column value to another. Some columns cannot be aggregated this way. In these
cases, the {@link COLUMN_AGGREGATION_OPS_METADATA_NAME}
metadata can be used to specify a different type of operation.
@param \Piwik\DataTable $tableToSum
@throws Exception | [
"Sums",
"a",
"DataTable",
"to",
"this",
"one",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L625-L645 | train | Add a DataTable to the sum of all rows of this table | [
30522,
2270,
3853,
5587,
2850,
29336,
3085,
1006,
2951,
10880,
1002,
13855,
2891,
2819,
1007,
1063,
2065,
1006,
1002,
13855,
2891,
2819,
6013,
11253,
3722,
1007,
1063,
2065,
1006,
1002,
13855,
2891,
2819,
1011,
1028,
2131,
10524,
9363,
1667... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/models/MailTemplate.php | MailTemplate.allTemplates | public static function allTemplates()
{
$result = [];
$codes = array_keys(self::listAllTemplates());
foreach ($codes as $code) {
$result[] = self::findOrMakeTemplate($code);
}
return $result;
} | php | public static function allTemplates()
{
$result = [];
$codes = array_keys(self::listAllTemplates());
foreach ($codes as $code) {
$result[] = self::findOrMakeTemplate($code);
}
return $result;
} | [
"public",
"static",
"function",
"allTemplates",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"codes",
"=",
"array_keys",
"(",
"self",
"::",
"listAllTemplates",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"codes",
"as",
"$",
"code",
")",
"{",
... | Returns a list of all mail templates.
@return array Returns an array of the MailTemplate objects. | [
"Returns",
"a",
"list",
"of",
"all",
"mail",
"templates",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/models/MailTemplate.php#L65-L75 | train | Get all the templates | [
30522,
2270,
10763,
3853,
2035,
18532,
15725,
2015,
1006,
1007,
1063,
1002,
2765,
1027,
1031,
1033,
1025,
1002,
9537,
1027,
9140,
1035,
6309,
1006,
2969,
1024,
1024,
2862,
8095,
18532,
15725,
2015,
1006,
1007,
1007,
1025,
18921,
6776,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.renderField | public function renderField($field, $options = [])
{
$this->prepareVars();
if (is_string($field)) {
if (!isset($this->allFields[$field])) {
throw new ApplicationException(Lang::get(
'backend::lang.form.missing_definition',
compact('field')
));
}
$field = $this->allFields[$field];
}
if (!isset($options['useContainer'])) {
$options['useContainer'] = true;
}
$targetPartial = $options['useContainer'] ? 'field-container' : 'field';
return $this->makePartial($targetPartial, ['field' => $field]);
} | php | public function renderField($field, $options = [])
{
$this->prepareVars();
if (is_string($field)) {
if (!isset($this->allFields[$field])) {
throw new ApplicationException(Lang::get(
'backend::lang.form.missing_definition',
compact('field')
));
}
$field = $this->allFields[$field];
}
if (!isset($options['useContainer'])) {
$options['useContainer'] = true;
}
$targetPartial = $options['useContainer'] ? 'field-container' : 'field';
return $this->makePartial($targetPartial, ['field' => $field]);
} | [
"public",
"function",
"renderField",
"(",
"$",
"field",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"prepareVars",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
... | Renders a single form field
Options:
- useContainer: Wrap the result in a container, used by AJAX. Default: true
@param string|array $field The field name or definition
@param array $options
@return string|bool The rendered partial contents, or false if suppressing an exception | [
"Renders",
"a",
"single",
"form",
"field"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L240-L261 | train | Renders a single field | [
30522,
2270,
3853,
17552,
3790,
1006,
1002,
2492,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
7374,
10755,
2015,
1006,
1007,
1025,
2065,
30524,
2433,
1012,
4394,
1035,
6210,
1005,
1010,
9233,
1006,
1005,
2492,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php | SendMessageMiddleware.handle | public function handle(Envelope $envelope, StackInterface $stack): Envelope
{
$context = [
'message' => $envelope->getMessage(),
'class' => \get_class($envelope->getMessage()),
];
$handle = false;
$sender = null;
try {
if ($envelope->all(ReceivedStamp::class)) {
// it's a received message, do not send it back
$this->logger->info('Received message "{class}"', $context);
} else {
/** @var RedeliveryStamp|null $redeliveryStamp */
$redeliveryStamp = $envelope->last(RedeliveryStamp::class);
// dispatch event unless this is a redelivery
$shouldDispatchEvent = null === $redeliveryStamp;
foreach ($this->getSenders($envelope, $handle, $redeliveryStamp) as $alias => $sender) {
if (null !== $this->eventDispatcher && $shouldDispatchEvent) {
$event = new SendMessageToTransportsEvent($envelope);
$this->eventDispatcher->dispatch($event);
$envelope = $event->getEnvelope();
$shouldDispatchEvent = false;
}
$this->logger->info('Sending message "{class}" with "{sender}"', $context + ['sender' => \get_class($sender)]);
$envelope = $sender->send($envelope->with(new SentStamp(\get_class($sender), \is_string($alias) ? $alias : null)));
}
// if the message was marked (usually by SyncTransport) that it handlers
// MUST be called, mark them to be handled.
if (null !== $envelope->last(ForceCallHandlersStamp::class)) {
$handle = true;
}
// on a redelivery, only send back to queue: never call local handlers
if (null !== $redeliveryStamp) {
$handle = false;
}
}
if (null === $sender || $handle) {
return $stack->next()->handle($envelope, $stack);
}
} catch (\Throwable $e) {
$context['exception'] = $e;
$this->logger->warning('An exception occurred while handling message "{class}": '.$e->getMessage(), $context);
throw $e;
}
// message should only be sent and not be handled by the next middleware
return $envelope;
} | php | public function handle(Envelope $envelope, StackInterface $stack): Envelope
{
$context = [
'message' => $envelope->getMessage(),
'class' => \get_class($envelope->getMessage()),
];
$handle = false;
$sender = null;
try {
if ($envelope->all(ReceivedStamp::class)) {
// it's a received message, do not send it back
$this->logger->info('Received message "{class}"', $context);
} else {
/** @var RedeliveryStamp|null $redeliveryStamp */
$redeliveryStamp = $envelope->last(RedeliveryStamp::class);
// dispatch event unless this is a redelivery
$shouldDispatchEvent = null === $redeliveryStamp;
foreach ($this->getSenders($envelope, $handle, $redeliveryStamp) as $alias => $sender) {
if (null !== $this->eventDispatcher && $shouldDispatchEvent) {
$event = new SendMessageToTransportsEvent($envelope);
$this->eventDispatcher->dispatch($event);
$envelope = $event->getEnvelope();
$shouldDispatchEvent = false;
}
$this->logger->info('Sending message "{class}" with "{sender}"', $context + ['sender' => \get_class($sender)]);
$envelope = $sender->send($envelope->with(new SentStamp(\get_class($sender), \is_string($alias) ? $alias : null)));
}
// if the message was marked (usually by SyncTransport) that it handlers
// MUST be called, mark them to be handled.
if (null !== $envelope->last(ForceCallHandlersStamp::class)) {
$handle = true;
}
// on a redelivery, only send back to queue: never call local handlers
if (null !== $redeliveryStamp) {
$handle = false;
}
}
if (null === $sender || $handle) {
return $stack->next()->handle($envelope, $stack);
}
} catch (\Throwable $e) {
$context['exception'] = $e;
$this->logger->warning('An exception occurred while handling message "{class}": '.$e->getMessage(), $context);
throw $e;
}
// message should only be sent and not be handled by the next middleware
return $envelope;
} | [
"public",
"function",
"handle",
"(",
"Envelope",
"$",
"envelope",
",",
"StackInterface",
"$",
"stack",
")",
":",
"Envelope",
"{",
"$",
"context",
"=",
"[",
"'message'",
"=>",
"$",
"envelope",
"->",
"getMessage",
"(",
")",
",",
"'class'",
"=>",
"\\",
"get... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php#L49-L105 | train | Handle the message | [
30522,
2270,
3853,
5047,
1006,
11255,
1002,
11255,
1010,
9991,
18447,
2121,
12172,
1002,
9991,
1007,
1024,
11255,
1063,
1002,
6123,
1027,
1031,
1005,
4471,
1005,
1027,
1028,
1002,
11255,
1011,
1028,
2131,
7834,
3736,
3351,
1006,
1007,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field.php | Field.formatLabel | protected function formatLabel($arguments = [])
{
$column = is_array($this->column) ? current($this->column) : $this->column;
$label = isset($arguments[0]) ? $arguments[0] : ucfirst($column);
return str_replace(['.', '_'], ' ', $label);
} | php | protected function formatLabel($arguments = [])
{
$column = is_array($this->column) ? current($this->column) : $this->column;
$label = isset($arguments[0]) ? $arguments[0] : ucfirst($column);
return str_replace(['.', '_'], ' ', $label);
} | [
"protected",
"function",
"formatLabel",
"(",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"column",
"=",
"is_array",
"(",
"$",
"this",
"->",
"column",
")",
"?",
"current",
"(",
"$",
"this",
"->",
"column",
")",
":",
"$",
"this",
"->",
"column",
... | Format the label value.
@param array $arguments
@return string | [
"Format",
"the",
"label",
"value",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field.php#L273-L280 | train | Format the label of the column | [
30522,
5123,
3853,
4289,
20470,
2884,
1006,
1002,
9918,
1027,
1031,
1033,
1007,
1063,
1002,
5930,
1027,
2003,
1035,
9140,
1006,
1002,
2023,
1011,
1028,
5930,
1007,
1029,
2783,
1006,
1002,
2023,
1011,
1028,
5930,
1007,
1024,
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... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/Grammar.php | Grammar.compileForeign | public function compileForeign(Blueprint $blueprint, Fluent $command)
{
// We need to prepare several of the elements of the foreign key definition
// before we can create the SQL, such as wrapping the tables and convert
// an array of columns to comma-delimited strings for the SQL queries.
$sql = sprintf('alter table %s add constraint %s ',
$this->wrapTable($blueprint),
$this->wrap($command->index)
);
// Once we have the initial portion of the SQL statement we will add on the
// key name, table name, and referenced columns. These will complete the
// main portion of the SQL statement and this SQL will almost be done.
$sql .= sprintf('foreign key (%s) references %s (%s)',
$this->columnize($command->columns),
$this->wrapTable($command->on),
$this->columnize((array) $command->references)
);
// Once we have the basic foreign key creation statement constructed we can
// build out the syntax for what should happen on an update or delete of
// the affected columns, which will get something like "cascade", etc.
if (! is_null($command->onDelete)) {
$sql .= " on delete {$command->onDelete}";
}
if (! is_null($command->onUpdate)) {
$sql .= " on update {$command->onUpdate}";
}
return $sql;
} | php | public function compileForeign(Blueprint $blueprint, Fluent $command)
{
// We need to prepare several of the elements of the foreign key definition
// before we can create the SQL, such as wrapping the tables and convert
// an array of columns to comma-delimited strings for the SQL queries.
$sql = sprintf('alter table %s add constraint %s ',
$this->wrapTable($blueprint),
$this->wrap($command->index)
);
// Once we have the initial portion of the SQL statement we will add on the
// key name, table name, and referenced columns. These will complete the
// main portion of the SQL statement and this SQL will almost be done.
$sql .= sprintf('foreign key (%s) references %s (%s)',
$this->columnize($command->columns),
$this->wrapTable($command->on),
$this->columnize((array) $command->references)
);
// Once we have the basic foreign key creation statement constructed we can
// build out the syntax for what should happen on an update or delete of
// the affected columns, which will get something like "cascade", etc.
if (! is_null($command->onDelete)) {
$sql .= " on delete {$command->onDelete}";
}
if (! is_null($command->onUpdate)) {
$sql .= " on update {$command->onUpdate}";
}
return $sql;
} | [
"public",
"function",
"compileForeign",
"(",
"Blueprint",
"$",
"blueprint",
",",
"Fluent",
"$",
"command",
")",
"{",
"// We need to prepare several of the elements of the foreign key definition",
"// before we can create the SQL, such as wrapping the tables and convert",
"// an array o... | Compile a foreign key command.
@param \Illuminate\Database\Schema\Blueprint $blueprint
@param \Illuminate\Support\Fluent $command
@return string | [
"Compile",
"a",
"foreign",
"key",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/Grammar.php#L65-L96 | train | Compiles the foreign key definition | [
30522,
2270,
3853,
4012,
22090,
29278,
7416,
16206,
1006,
2630,
16550,
1002,
2630,
16550,
1010,
19376,
1002,
3094,
1007,
1063,
1013,
1013,
2057,
2342,
2000,
7374,
2195,
1997,
1996,
3787,
1997,
1996,
3097,
3145,
6210,
1013,
1013,
2077,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/HasOneThrough.php | HasOneThrough.initRelation | public function initRelation(array $models, $relation)
{
foreach ($models as $model) {
$model->setRelation($relation, $this->getDefaultFor($model));
}
return $models;
} | php | public function initRelation(array $models, $relation)
{
foreach ($models as $model) {
$model->setRelation($relation, $this->getDefaultFor($model));
}
return $models;
} | [
"public",
"function",
"initRelation",
"(",
"array",
"$",
"models",
",",
"$",
"relation",
")",
"{",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"setRelation",
"(",
"$",
"relation",
",",
"$",
"this",
"->",
"getDefault... | Initialize the relation on a set of models.
@param array $models
@param string $relation
@return array | [
"Initialize",
"the",
"relation",
"on",
"a",
"set",
"of",
"models",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasOneThrough.php#L30-L37 | train | Init a relation for a list of models | [
30522,
2270,
3853,
1999,
4183,
16570,
3370,
1006,
9140,
1002,
4275,
1010,
1002,
7189,
1007,
1063,
18921,
6776,
1006,
1002,
4275,
2004,
1002,
2944,
1007,
1063,
1002,
2944,
1011,
1028,
2275,
16570,
3370,
1006,
1002,
7189,
1010,
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... |
laravel/framework | src/Illuminate/View/Concerns/ManagesComponents.php | ManagesComponents.endSlot | public function endSlot()
{
last($this->componentStack);
$currentSlot = array_pop(
$this->slotStack[$this->currentComponent()]
);
$this->slots[$this->currentComponent()]
[$currentSlot] = new HtmlString(trim(ob_get_clean()));
} | php | public function endSlot()
{
last($this->componentStack);
$currentSlot = array_pop(
$this->slotStack[$this->currentComponent()]
);
$this->slots[$this->currentComponent()]
[$currentSlot] = new HtmlString(trim(ob_get_clean()));
} | [
"public",
"function",
"endSlot",
"(",
")",
"{",
"last",
"(",
"$",
"this",
"->",
"componentStack",
")",
";",
"$",
"currentSlot",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"slotStack",
"[",
"$",
"this",
"->",
"currentComponent",
"(",
")",
"]",
")",
";",
... | Save the slot content for rendering.
@return void | [
"Save",
"the",
"slot",
"content",
"for",
"rendering",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Concerns/ManagesComponents.php#L107-L117 | train | End a slot | [
30522,
2270,
3853,
4515,
10994,
1006,
1007,
1063,
2197,
1006,
1002,
2023,
1011,
1028,
6177,
2696,
3600,
1007,
1025,
1002,
14731,
10994,
1027,
9140,
1035,
3769,
1006,
1002,
2023,
1011,
1028,
19832,
2696,
3600,
1031,
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... |
octobercms/october | modules/backend/widgets/Form.php | Form.getFieldValue | protected function getFieldValue($field)
{
if (is_string($field)) {
if (!isset($this->allFields[$field])) {
throw new ApplicationException(Lang::get(
'backend::lang.form.missing_definition',
compact('field')
));
}
$field = $this->allFields[$field];
}
$defaultValue = !$this->model->exists
? $field->getDefaultFromData($this->data)
: null;
return $field->getValueFromData(
$this->data,
is_string($defaultValue) ? trans($defaultValue) : $defaultValue
);
} | php | protected function getFieldValue($field)
{
if (is_string($field)) {
if (!isset($this->allFields[$field])) {
throw new ApplicationException(Lang::get(
'backend::lang.form.missing_definition',
compact('field')
));
}
$field = $this->allFields[$field];
}
$defaultValue = !$this->model->exists
? $field->getDefaultFromData($this->data)
: null;
return $field->getValueFromData(
$this->data,
is_string($defaultValue) ? trans($defaultValue) : $defaultValue
);
} | [
"protected",
"function",
"getFieldValue",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"allFields",
"[",
"$",
"field",
"]",
")",
")",
"{",
"throw",
"new",
... | Looks up the field value.
@param mixed $field
@return string | [
"Looks",
"up",
"the",
"field",
"value",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L1061-L1082 | train | Get field value | [
30522,
5123,
3853,
2131,
3790,
10175,
5657,
1006,
1002,
2492,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
2492,
1007,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2035,
15155,
1031,
1002,
2492,
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... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php | DateIntervalType.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
$vars = [
'widget' => $options['widget'],
'with_invert' => $options['with_invert'],
];
foreach ($this->timeParts as $part) {
$vars['with_'.$part] = $options['with_'.$part];
}
$view->vars = array_replace($view->vars, $vars);
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
$vars = [
'widget' => $options['widget'],
'with_invert' => $options['with_invert'],
];
foreach ($this->timeParts as $part) {
$vars['with_'.$part] = $options['with_'.$part];
}
$view->vars = array_replace($view->vars, $vars);
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"$",
"vars",
"=",
"[",
"'widget'",
"=>",
"$",
"options",
"[",
"'widget'",
"]",
",",
"'with_invert'",
"=>",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php#L154-L164 | train | Build the view. | [
30522,
2270,
3853,
3857,
8584,
1006,
2433,
8584,
1002,
3193,
1010,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
9140,
1002,
7047,
1007,
1063,
1002,
13075,
2015,
1027,
1031,
1005,
15536,
24291,
1005,
1027,
1028,
1002,
7047,
1031,
1005,
15536,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.isAssociativeArray | public static function isAssociativeArray($array)
{
reset($array);
if (!is_numeric(key($array))
|| key($array) != 0
) {
// first key must be 0
return true;
}
// check that each key is == next key - 1 w/o actually indexing the array
while (true) {
$current = key($array);
next($array);
$next = key($array);
if ($next === null) {
break;
} elseif ($current + 1 != $next) {
return true;
}
}
return false;
} | php | public static function isAssociativeArray($array)
{
reset($array);
if (!is_numeric(key($array))
|| key($array) != 0
) {
// first key must be 0
return true;
}
// check that each key is == next key - 1 w/o actually indexing the array
while (true) {
$current = key($array);
next($array);
$next = key($array);
if ($next === null) {
break;
} elseif ($current + 1 != $next) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"isAssociativeArray",
"(",
"$",
"array",
")",
"{",
"reset",
"(",
"$",
"array",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"key",
"(",
"$",
"array",
")",
")",
"||",
"key",
"(",
"$",
"array",
")",
"!=",
"0",
")",
"... | Returns true if an array is an associative array, false if otherwise.
This method determines if an array is associative by checking that the
first element's key is 0, and that each successive element's key is
one greater than the last.
@param array $array
@return bool | [
"Returns",
"true",
"if",
"an",
"array",
"is",
"an",
"associative",
"array",
"false",
"if",
"otherwise",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L713-L739 | train | Checks if an array is associative | [
30522,
2270,
10763,
3853,
18061,
24137,
7405,
6024,
2906,
9447,
1006,
1002,
9140,
1007,
1063,
25141,
1006,
1002,
9140,
1007,
1025,
2065,
1006,
999,
2003,
1035,
16371,
25531,
1006,
3145,
1006,
1002,
9140,
1007,
1007,
1064,
1064,
3145,
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/Form/Field.php | Field.formatAttributes | protected function formatAttributes()
{
$html = [];
foreach ($this->attributes as $name => $value) {
$html[] = $name.'="'.e($value).'"';
}
return implode(' ', $html);
} | php | protected function formatAttributes()
{
$html = [];
foreach ($this->attributes as $name => $value) {
$html[] = $name.'="'.e($value).'"';
}
return implode(' ', $html);
} | [
"protected",
"function",
"formatAttributes",
"(",
")",
"{",
"$",
"html",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"html",
"[",
"]",
"=",
"$",
"name",
".",
"'=\"'",
... | Format the field attributes.
@return string | [
"Format",
"the",
"field",
"attributes",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field.php#L875-L884 | train | Formats the attributes for the page | [
30522,
5123,
3853,
4289,
19321,
3089,
8569,
4570,
1006,
1007,
1063,
1002,
16129,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
12332,
2004,
1002,
2171,
1027,
1028,
1002,
3643,
1007,
1063,
1002,
16129,
1031,
1033,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
php-ai/php-ml | src/Helper/OneVsRest.php | OneVsRest.reset | public function reset(): void
{
$this->classifiers = [];
$this->allLabels = [];
$this->costValues = [];
$this->resetBinary();
} | php | public function reset(): void
{
$this->classifiers = [];
$this->allLabels = [];
$this->costValues = [];
$this->resetBinary();
} | [
"public",
"function",
"reset",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"classifiers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"allLabels",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"costValues",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"resetBin... | Resets the classifier and the vars internally used by OneVsRest to create multiple classifiers. | [
"Resets",
"the",
"classifier",
"and",
"the",
"vars",
"internally",
"used",
"by",
"OneVsRest",
"to",
"create",
"multiple",
"classifiers",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/OneVsRest.php#L42-L49 | train | Reset the class hierarchy | [
30522,
2270,
3853,
25141,
1006,
1007,
1024,
11675,
1063,
1002,
2023,
1011,
1028,
2465,
28295,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
2035,
20470,
9050,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
3465,
10175,
15808,
1027,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Workflow/Registry.php | Registry.get | public function get($subject, $workflowName = null)
{
$matched = null;
foreach ($this->workflows as list($workflow, $supportStrategy)) {
if ($this->supports($workflow, $supportStrategy, $subject, $workflowName)) {
if ($matched) {
throw new InvalidArgumentException('At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.');
}
$matched = $workflow;
}
}
if (!$matched) {
throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', \get_class($subject)));
}
return $matched;
} | php | public function get($subject, $workflowName = null)
{
$matched = null;
foreach ($this->workflows as list($workflow, $supportStrategy)) {
if ($this->supports($workflow, $supportStrategy, $subject, $workflowName)) {
if ($matched) {
throw new InvalidArgumentException('At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.');
}
$matched = $workflow;
}
}
if (!$matched) {
throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', \get_class($subject)));
}
return $matched;
} | [
"public",
"function",
"get",
"(",
"$",
"subject",
",",
"$",
"workflowName",
"=",
"null",
")",
"{",
"$",
"matched",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"workflows",
"as",
"list",
"(",
"$",
"workflow",
",",
"$",
"supportStrategy",
")",
... | @param object $subject
@param string|null $workflowName
@return Workflow | [
"@param",
"object",
"$subject",
"@param",
"string|null",
"$workflowName"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Workflow/Registry.php#L49-L67 | train | Returns the workflow that supports the subject | [
30522,
2270,
3853,
2131,
1006,
1002,
3395,
1010,
1002,
2147,
12314,
18442,
1027,
19701,
1007,
1063,
1002,
10349,
1027,
19701,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2147,
12314,
2015,
2004,
2862,
1006,
1002,
2147,
12314,
1010,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Response.php | Response.setSharedMaxAge | public function setSharedMaxAge(int $value)
{
$this->setPublic();
$this->headers->addCacheControlDirective('s-maxage', $value);
return $this;
} | php | public function setSharedMaxAge(int $value)
{
$this->setPublic();
$this->headers->addCacheControlDirective('s-maxage', $value);
return $this;
} | [
"public",
"function",
"setSharedMaxAge",
"(",
"int",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setPublic",
"(",
")",
";",
"$",
"this",
"->",
"headers",
"->",
"addCacheControlDirective",
"(",
"'s-maxage'",
",",
"$",
"value",
")",
";",
"return",
"$",
"th... | Sets the number of seconds after which the response should no longer be considered fresh by shared caches.
This methods sets the Cache-Control s-maxage directive.
@return $this
@final | [
"Sets",
"the",
"number",
"of",
"seconds",
"after",
"which",
"the",
"response",
"should",
"no",
"longer",
"be",
"considered",
"fresh",
"by",
"shared",
"caches",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Response.php#L798-L804 | train | Set the maximum age of shared pages in the page. | [
30522,
2270,
3853,
4520,
8167,
2098,
17848,
4270,
1006,
20014,
1002,
3643,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
14289,
16558,
2594,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
20346,
2015,
1011,
1028,
5587,
3540,
5403,
8663,
13181,
6392,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable.php | DataTable.setMaximumDepthLevelAllowedAtLeast | public static function setMaximumDepthLevelAllowedAtLeast($atLeastLevel)
{
self::$maximumDepthLevelAllowed = max($atLeastLevel, self::$maximumDepthLevelAllowed);
if (self::$maximumDepthLevelAllowed < 1) {
self::$maximumDepthLevelAllowed = 1;
}
} | php | public static function setMaximumDepthLevelAllowedAtLeast($atLeastLevel)
{
self::$maximumDepthLevelAllowed = max($atLeastLevel, self::$maximumDepthLevelAllowed);
if (self::$maximumDepthLevelAllowed < 1) {
self::$maximumDepthLevelAllowed = 1;
}
} | [
"public",
"static",
"function",
"setMaximumDepthLevelAllowedAtLeast",
"(",
"$",
"atLeastLevel",
")",
"{",
"self",
"::",
"$",
"maximumDepthLevelAllowed",
"=",
"max",
"(",
"$",
"atLeastLevel",
",",
"self",
"::",
"$",
"maximumDepthLevelAllowed",
")",
";",
"if",
"(",
... | Sets the maximum depth level to at least a certain value. If the current value is
greater than `$atLeastLevel`, the maximum nesting level is not changed.
The maximum depth level determines the maximum number of subtable levels in the
DataTable tree. For example, if it is set to `2`, this DataTable is allowed to
have subtables, but the subtables are not.
@param int $atLeastLevel | [
"Sets",
"the",
"maximum",
"depth",
"level",
"to",
"at",
"least",
"a",
"certain",
"value",
".",
"If",
"the",
"current",
"value",
"is",
"greater",
"than",
"$atLeastLevel",
"the",
"maximum",
"nesting",
"level",
"is",
"not",
"changed",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L1591-L1597 | train | Set maximum depth level allowed at least | [
30522,
2270,
10763,
3853,
2275,
17848,
28591,
3207,
13876,
7317,
18697,
13837,
27663,
2850,
9286,
14083,
1006,
1002,
2012,
19738,
22516,
15985,
1007,
1063,
2969,
1024,
1024,
1002,
4555,
3207,
13876,
7317,
18697,
13837,
27663,
2094,
1027,
4098... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Message.php | Message.embedData | public function embedData($data, $name, $contentType = null)
{
$image = new Swift_Image($data, $name, $contentType);
return $this->swift->embed($image);
} | php | public function embedData($data, $name, $contentType = null)
{
$image = new Swift_Image($data, $name, $contentType);
return $this->swift->embed($image);
} | [
"public",
"function",
"embedData",
"(",
"$",
"data",
",",
"$",
"name",
",",
"$",
"contentType",
"=",
"null",
")",
"{",
"$",
"image",
"=",
"new",
"Swift_Image",
"(",
"$",
"data",
",",
"$",
"name",
",",
"$",
"contentType",
")",
";",
"return",
"$",
"t... | Embed in-memory data in the message and get the CID.
@param string $data
@param string $name
@param string|null $contentType
@return string | [
"Embed",
"in",
"-",
"memory",
"data",
"in",
"the",
"message",
"and",
"get",
"the",
"CID",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Message.php#L273-L278 | train | Embed an image in the current page | [
30522,
2270,
3853,
7861,
8270,
2850,
2696,
1006,
1002,
2951,
1010,
1002,
2171,
1010,
1002,
4180,
13874,
1027,
19701,
1007,
1063,
1002,
3746,
1027,
2047,
9170,
1035,
3746,
1006,
1002,
2951,
1010,
1002,
2171,
1010,
1002,
4180,
13874,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.set | public function set($name, $value = '')
{
if (property_exists($this, $name)) {
$this->$name = $value;
return true;
}
$this->setError($this->lang('variable_set') . $name);
return false;
} | php | public function set($name, $value = '')
{
if (property_exists($this, $name)) {
$this->$name = $value;
return true;
}
$this->setError($this->lang('variable_set') . $name);
return false;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"$",
"name",
"=",
"$",
"value",
";",
"return",
"true",
";... | Set or reset instance properties.
You should avoid this function - it's more verbose, less efficient, more error-prone and
harder to debug than setting properties directly.
Usage Example:
`$mail->set('SMTPSecure', 'tls');`
is the same as:
`$mail->SMTPSecure = 'tls';`.
@param string $name The property name to set
@param mixed $value The value to set the property to
@return bool | [
"Set",
"or",
"reset",
"instance",
"properties",
".",
"You",
"should",
"avoid",
"this",
"function",
"-",
"it",
"s",
"more",
"verbose",
"less",
"efficient",
"more",
"error",
"-",
"prone",
"and",
"harder",
"to",
"debug",
"than",
"setting",
"properties",
"direct... | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L4103-L4113 | train | Set a variable | [
30522,
2270,
3853,
2275,
1006,
1002,
2171,
1010,
1002,
3643,
1027,
1005,
1005,
1007,
1063,
2065,
1006,
3200,
1035,
6526,
1006,
1002,
2023,
1010,
1002,
2171,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
1002,
2171,
1027,
1002,
3643,
1025,
270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/Medium.php | Medium.relativePath | public function relativePath($reset = true)
{
$output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $this->get('filepath'));
$locator = Grav::instance()['locator'];
if ($locator->isStream($output)) {
$output = $locator->findResource($output, false);
}
if ($reset) {
$this->reset();
}
return str_replace(GRAV_ROOT, '', $output);
} | php | public function relativePath($reset = true)
{
$output = preg_replace('|^' . preg_quote(GRAV_ROOT, '|') . '|', '', $this->get('filepath'));
$locator = Grav::instance()['locator'];
if ($locator->isStream($output)) {
$output = $locator->findResource($output, false);
}
if ($reset) {
$this->reset();
}
return str_replace(GRAV_ROOT, '', $output);
} | [
"public",
"function",
"relativePath",
"(",
"$",
"reset",
"=",
"true",
")",
"{",
"$",
"output",
"=",
"preg_replace",
"(",
"'|^'",
".",
"preg_quote",
"(",
"GRAV_ROOT",
",",
"'|'",
")",
".",
"'|'",
",",
"''",
",",
"$",
"this",
"->",
"get",
"(",
"'filepa... | Return the relative path to file
@param bool $reset
@return mixed | [
"Return",
"the",
"relative",
"path",
"to",
"file"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/Medium.php#L243-L257 | train | Get the relative path to the file | [
30522,
2270,
3853,
5816,
15069,
1006,
1002,
25141,
1027,
2995,
1007,
1063,
1002,
6434,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
1064,
1034,
1005,
1012,
3653,
2290,
1035,
14686,
1006,
24665,
30524,
2023,
1011,
1028,
2131,
1006,
1005,
5371,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Iterator.php | Iterator.shuffle | public function shuffle()
{
$keys = array_keys($this->items);
shuffle($keys);
$new = [];
foreach ($keys as $key) {
$new[$key] = $this->items[$key];
}
$this->items = $new;
return $this;
} | php | public function shuffle()
{
$keys = array_keys($this->items);
shuffle($keys);
$new = [];
foreach ($keys as $key) {
$new[$key] = $this->items[$key];
}
$this->items = $new;
return $this;
} | [
"public",
"function",
"shuffle",
"(",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"items",
")",
";",
"shuffle",
"(",
"$",
"keys",
")",
";",
"$",
"new",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")"... | Shuffle items.
@return $this | [
"Shuffle",
"items",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Iterator.php#L154-L167 | train | Shuffle the array of items | [
30522,
2270,
3853,
23046,
1006,
1007,
1063,
1002,
6309,
1027,
9140,
1035,
6309,
1006,
1002,
2023,
1011,
1028,
5167,
1007,
1025,
23046,
1006,
1002,
6309,
1007,
1025,
1002,
2047,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
6309,
2004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.getParents | private static function getParents($rawRoutes)
{
$grav = Grav::instance();
/** @var Pages $pages */
$pages = $grav['pages'];
$parents = $pages->getList(null, 0, $rawRoutes);
if (isset($grav['admin'])) {
// Remove current route from parents
/** @var Admin $admin */
$admin = $grav['admin'];
$page = $admin->getPage($admin->route);
$page_route = $page->route();
if (isset($parents[$page_route])) {
unset($parents[$page_route]);
}
}
return $parents;
} | php | private static function getParents($rawRoutes)
{
$grav = Grav::instance();
/** @var Pages $pages */
$pages = $grav['pages'];
$parents = $pages->getList(null, 0, $rawRoutes);
if (isset($grav['admin'])) {
// Remove current route from parents
/** @var Admin $admin */
$admin = $grav['admin'];
$page = $admin->getPage($admin->route);
$page_route = $page->route();
if (isset($parents[$page_route])) {
unset($parents[$page_route]);
}
}
return $parents;
} | [
"private",
"static",
"function",
"getParents",
"(",
"$",
"rawRoutes",
")",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"/** @var Pages $pages */",
"$",
"pages",
"=",
"$",
"grav",
"[",
"'pages'",
"]",
";",
"$",
"parents",
"=",
"$",
"... | Get available parents routes
@param bool $rawRoutes get the raw route or the normal route
@return array | [
"Get",
"available",
"parents",
"routes"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L646-L670 | train | Get parents of current route | [
30522,
2797,
10763,
3853,
2131,
19362,
11187,
1006,
1002,
6315,
22494,
4570,
1007,
1063,
1002,
24665,
11431,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1025,
1013,
1008,
1008,
1030,
13075,
5530,
1002,
5530,
1008,
1013,
1002,
5530,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.