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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matomo-org/matomo | libs/Zend/Mail.php | Zend_Mail.setDate | public function setDate($date = null)
{
if ($this->_date === null) {
if ($date === null) {
$date = date('r');
} else if (is_int($date)) {
$date = date('r', $date);
} else if (is_string($date)) {
$date = strtotime($date);
if ($date === false || $date < 0) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('String representations of Date Header must be ' .
'strtotime()-compatible');
}
$date = date('r', $date);
} else if ($date instanceof Zend_Date) {
$date = $date->get(Zend_Date::RFC_2822);
} else {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception(__METHOD__ . ' only accepts UNIX timestamps, Zend_Date objects, ' .
' and strtotime()-compatible strings');
}
$this->_date = $date;
$this->_storeHeader('Date', $date);
} else {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Date Header set twice');
}
return $this;
} | php | public function setDate($date = null)
{
if ($this->_date === null) {
if ($date === null) {
$date = date('r');
} else if (is_int($date)) {
$date = date('r', $date);
} else if (is_string($date)) {
$date = strtotime($date);
if ($date === false || $date < 0) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('String representations of Date Header must be ' .
'strtotime()-compatible');
}
$date = date('r', $date);
} else if ($date instanceof Zend_Date) {
$date = $date->get(Zend_Date::RFC_2822);
} else {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception(__METHOD__ . ' only accepts UNIX timestamps, Zend_Date objects, ' .
' and strtotime()-compatible strings');
}
$this->_date = $date;
$this->_storeHeader('Date', $date);
} else {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Date Header set twice');
}
return $this;
} | [
"public",
"function",
"setDate",
"(",
"$",
"date",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_date",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"date",
"===",
"null",
")",
"{",
"$",
"date",
"=",
"date",
"(",
"'r'",
")",
";",
"}",
"e... | Sets Date-header
@param timestamp|string|Zend_Date $date
@return Zend_Mail Provides fluent interface
@throws Zend_Mail_Exception if called subsequent times or wrong date format. | [
"Sets",
"Date",
"-",
"header"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L968-L1006 | train | Set Date Header | [
30522,
2270,
3853,
2275,
13701,
1006,
1002,
3058,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
3058,
1027,
1027,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
3058,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
3058,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Console/AdminCommand.php | AdminCommand.handle | public function handle()
{
$this->line(static::$logo);
$this->line(Admin::getLongVersion());
$this->comment('');
$this->comment('Available commands:');
$this->listAdminCommands();
} | php | public function handle()
{
$this->line(static::$logo);
$this->line(Admin::getLongVersion());
$this->comment('');
$this->comment('Available commands:');
$this->listAdminCommands();
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"static",
"::",
"$",
"logo",
")",
";",
"$",
"this",
"->",
"line",
"(",
"Admin",
"::",
"getLongVersion",
"(",
")",
")",
";",
"$",
"this",
"->",
"comment",
"(",
"''",
")... | Execute the console command. | [
"Execute",
"the",
"console",
"command",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/AdminCommand.php#L41-L50 | train | Handle the admin command | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2240,
1006,
10763,
1024,
1024,
1002,
8154,
1007,
1025,
1002,
2023,
1011,
1028,
2240,
1006,
4748,
10020,
1024,
1024,
2131,
10052,
27774,
1006,
1007,
1007,
1025,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Kernel/Traits/Observable.php | Observable.resolveHandlerAndCondition | protected function resolveHandlerAndCondition($handler, $condition): array
{
if (is_int($handler) || (is_string($handler) && !class_exists($handler))) {
list($handler, $condition) = [$condition, $handler];
}
return [$this->makeClosure($handler), $condition];
} | php | protected function resolveHandlerAndCondition($handler, $condition): array
{
if (is_int($handler) || (is_string($handler) && !class_exists($handler))) {
list($handler, $condition) = [$condition, $handler];
}
return [$this->makeClosure($handler), $condition];
} | [
"protected",
"function",
"resolveHandlerAndCondition",
"(",
"$",
"handler",
",",
"$",
"condition",
")",
":",
"array",
"{",
"if",
"(",
"is_int",
"(",
"$",
"handler",
")",
"||",
"(",
"is_string",
"(",
"$",
"handler",
")",
"&&",
"!",
"class_exists",
"(",
"$... | @param $handler
@param $condition
@return array
@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
@throws \ReflectionException | [
"@param",
"$handler",
"@param",
"$condition"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/Traits/Observable.php#L242-L249 | train | Resolves handler and condition | [
30522,
5123,
3853,
10663,
11774,
3917,
5685,
8663,
20562,
1006,
1002,
28213,
1010,
1002,
4650,
1007,
1024,
9140,
1063,
2065,
1006,
2003,
1035,
20014,
1006,
1002,
28213,
30524,
2709,
1031,
1002,
2023,
1011,
1028,
2191,
20464,
2891,
5397,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select.joinCross | public function joinCross($name, $cols = self::SQL_WILDCARD, $schema = null)
{
return $this->_join(self::CROSS_JOIN, $name, null, $cols, $schema);
} | php | public function joinCross($name, $cols = self::SQL_WILDCARD, $schema = null)
{
return $this->_join(self::CROSS_JOIN, $name, null, $cols, $schema);
} | [
"public",
"function",
"joinCross",
"(",
"$",
"name",
",",
"$",
"cols",
"=",
"self",
"::",
"SQL_WILDCARD",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_join",
"(",
"self",
"::",
"CROSS_JOIN",
",",
"$",
"name",
",",
"null",... | Add a CROSS JOIN table and colums to the query.
A cross join is a cartesian product; there is no join condition.
The $name and $cols parameters follow the same logic
as described in the from() method.
@param array|string|Zend_Db_Expr $name The table name.
@param array|string $cols The columns to select from the joined table.
@param string $schema The database name to specify, if any.
@return Zend_Db_Select This Zend_Db_Select object. | [
"Add",
"a",
"CROSS",
"JOIN",
"table",
"and",
"colums",
"to",
"the",
"query",
".",
"A",
"cross",
"join",
"is",
"a",
"cartesian",
"product",
";",
"there",
"is",
"no",
"join",
"condition",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L416-L419 | train | Join cross table | [
30522,
2270,
3853,
3693,
16458,
1006,
1002,
2171,
1010,
1002,
8902,
2015,
1027,
2969,
1024,
1024,
29296,
1035,
3748,
11522,
1010,
1002,
8040,
28433,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
1035,
3693,
1006,
2969,
1024,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/DBStats/API.php | API.getMetricDataSummaryByYear | public function getMetricDataSummaryByYear()
{
Piwik::checkUserHasSuperUserAccess();
$dataTable = $this->getMetricDataSummary();
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\API::getArchiveTableYear'));
return $dataTable;
} | php | public function getMetricDataSummaryByYear()
{
Piwik::checkUserHasSuperUserAccess();
$dataTable = $this->getMetricDataSummary();
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\API::getArchiveTableYear'));
return $dataTable;
} | [
"public",
"function",
"getMetricDataSummaryByYear",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getMetricDataSummary",
"(",
")",
";",
"$",
"dataTable",
"->",
"filter",
"(",
"'GroupBy'",
... | Returns a datatable describing how much space is taken up by each numeric
archive table, grouped by year.
@return DataTable A datatable with three columns: 'data_size', 'index_size', 'row_count'. | [
"Returns",
"a",
"datatable",
"describing",
"how",
"much",
"space",
"is",
"taken",
"up",
"by",
"each",
"numeric",
"archive",
"table",
"grouped",
"by",
"year",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DBStats/API.php#L136-L145 | train | Returns the data table grouped by year | [
30522,
2270,
3853,
2131,
12589,
2850,
10230,
2819,
7849,
2100,
3762,
29100,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1025,
1002,
2951,
10880,
1027,
1002,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php | FilesystemTagAwareAdapter.doSave | protected function doSave(array $values, ?int $lifetime, array $addTagData = [], array $removeTagData = []): array
{
$failed = $this->doSaveCache($values, $lifetime);
$fs = $this->getFilesystem();
// Add Tags as symlinks
foreach ($addTagData as $tagId => $ids) {
$tagFolder = $this->getTagFolder($tagId);
foreach ($ids as $id) {
if ($failed && \in_array($id, $failed, true)) {
continue;
}
$file = $this->getFile($id);
$fs->symlink($file, $this->getFile($id, true, $tagFolder));
}
}
// Unlink removed Tags
$files = [];
foreach ($removeTagData as $tagId => $ids) {
$tagFolder = $this->getTagFolder($tagId);
foreach ($ids as $id) {
if ($failed && \in_array($id, $failed, true)) {
continue;
}
$files[] = $this->getFile($id, false, $tagFolder);
}
}
$fs->remove($files);
return $failed;
} | php | protected function doSave(array $values, ?int $lifetime, array $addTagData = [], array $removeTagData = []): array
{
$failed = $this->doSaveCache($values, $lifetime);
$fs = $this->getFilesystem();
// Add Tags as symlinks
foreach ($addTagData as $tagId => $ids) {
$tagFolder = $this->getTagFolder($tagId);
foreach ($ids as $id) {
if ($failed && \in_array($id, $failed, true)) {
continue;
}
$file = $this->getFile($id);
$fs->symlink($file, $this->getFile($id, true, $tagFolder));
}
}
// Unlink removed Tags
$files = [];
foreach ($removeTagData as $tagId => $ids) {
$tagFolder = $this->getTagFolder($tagId);
foreach ($ids as $id) {
if ($failed && \in_array($id, $failed, true)) {
continue;
}
$files[] = $this->getFile($id, false, $tagFolder);
}
}
$fs->remove($files);
return $failed;
} | [
"protected",
"function",
"doSave",
"(",
"array",
"$",
"values",
",",
"?",
"int",
"$",
"lifetime",
",",
"array",
"$",
"addTagData",
"=",
"[",
"]",
",",
"array",
"$",
"removeTagData",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"failed",
"=",
"$",
"t... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php#L56-L89 | train | Save cache values | [
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,
6366,
15900,
2850,
2696,
1027,
1031,
1033,
1007,
1024,
9140,
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... |
octobercms/october | modules/system/behaviors/SettingsModel.php | SettingsModel.afterModelSave | public function afterModelSave()
{
Cache::forget($this->getCacheKey());
try {
Artisan::call('queue:restart');
} catch (Exception $e) {
Log::warning($e->getMessage());
}
} | php | public function afterModelSave()
{
Cache::forget($this->getCacheKey());
try {
Artisan::call('queue:restart');
} catch (Exception $e) {
Log::warning($e->getMessage());
}
} | [
"public",
"function",
"afterModelSave",
"(",
")",
"{",
"Cache",
"::",
"forget",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
")",
";",
"try",
"{",
"Artisan",
"::",
"call",
"(",
"'queue:restart'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
... | After the model is saved, clear the cached query entry
and restart queue workers so they have the latest settings
@return void | [
"After",
"the",
"model",
"is",
"saved",
"clear",
"the",
"cached",
"query",
"entry",
"and",
"restart",
"queue",
"workers",
"so",
"they",
"have",
"the",
"latest",
"settings"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/behaviors/SettingsModel.php#L205-L214 | train | After model save | [
30522,
2270,
3853,
2044,
5302,
9247,
3736,
3726,
1006,
1007,
1063,
17053,
1024,
1024,
5293,
1006,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
14839,
1006,
1007,
1007,
1025,
3046,
1063,
2396,
29196,
1024,
1024,
2655,
1006,
1005,
24240,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineTransport.php | DoctrineTransport.all | public function all(int $limit = null): iterable
{
return ($this->receiver ?? $this->getReceiver())->all($limit);
} | php | public function all(int $limit = null): iterable
{
return ($this->receiver ?? $this->getReceiver())->all($limit);
} | [
"public",
"function",
"all",
"(",
"int",
"$",
"limit",
"=",
"null",
")",
":",
"iterable",
"{",
"return",
"(",
"$",
"this",
"->",
"receiver",
"??",
"$",
"this",
"->",
"getReceiver",
"(",
")",
")",
"->",
"all",
"(",
"$",
"limit",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/Doctrine/DoctrineTransport.php#L74-L77 | train | Get all records from the receiver | [
30522,
2270,
3853,
2035,
1006,
20014,
1002,
5787,
1027,
19701,
1007,
1024,
2009,
6906,
3468,
1063,
2709,
1006,
1002,
2023,
1011,
1028,
8393,
1029,
1029,
1002,
2023,
1011,
1028,
2131,
2890,
3401,
16402,
1006,
1007,
1007,
1011,
1028,
2035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Session/SessionManager.php | SessionManager.createRedisDriver | protected function createRedisDriver()
{
$handler = $this->createCacheHandler('redis');
$handler->getCache()->getStore()->setConnection(
$this->app['config']['session.connection']
);
return $this->buildSession($handler);
} | php | protected function createRedisDriver()
{
$handler = $this->createCacheHandler('redis');
$handler->getCache()->getStore()->setConnection(
$this->app['config']['session.connection']
);
return $this->buildSession($handler);
} | [
"protected",
"function",
"createRedisDriver",
"(",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"createCacheHandler",
"(",
"'redis'",
")",
";",
"$",
"handler",
"->",
"getCache",
"(",
")",
"->",
"getStore",
"(",
")",
"->",
"setConnection",
"(",
"$",
... | Create an instance of the Redis session driver.
@return \Illuminate\Session\Store | [
"Create",
"an",
"instance",
"of",
"the",
"Redis",
"session",
"driver",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Session/SessionManager.php#L119-L128 | train | Create the Redis Session Driver | [
30522,
5123,
3853,
3443,
5596,
2483,
23663,
2099,
1006,
1007,
1063,
1002,
28213,
1027,
1002,
2023,
1011,
1028,
3443,
3540,
5403,
11774,
3917,
1006,
1005,
2417,
2483,
1005,
1007,
1025,
1002,
28213,
1011,
1028,
2131,
3540,
5403,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/QuickForm2.php | QuickForm2.addElement | public function addElement($elementOrType, $name = null, $attributes = null,
array $data = array())
{
if ($name != 'submit') {
$this->a_formElements[] = $name;
}
return parent::addElement($elementOrType, $name, $attributes, $data);
} | php | public function addElement($elementOrType, $name = null, $attributes = null,
array $data = array())
{
if ($name != 'submit') {
$this->a_formElements[] = $name;
}
return parent::addElement($elementOrType, $name, $attributes, $data);
} | [
"public",
"function",
"addElement",
"(",
"$",
"elementOrType",
",",
"$",
"name",
"=",
"null",
",",
"$",
"attributes",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"name",
"!=",
"'submit'",
")",
"{",
"$",... | Wrapper around HTML_QuickForm2_Container's addElement()
@param string|HTML_QuickForm2_Node $elementOrType Either type name (treated
case-insensitively) or an element instance
@param mixed $name Element name
@param mixed $attributes Element attributes
@param array $data Element-specific data
@return HTML_QuickForm2_Node Added element
@throws HTML_QuickForm2_InvalidArgumentException
@throws HTML_QuickForm2_NotFoundException | [
"Wrapper",
"around",
"HTML_QuickForm2_Container",
"s",
"addElement",
"()"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/QuickForm2.php#L70-L78 | train | Add an element to the form | [
30522,
2270,
3853,
5587,
12260,
3672,
1006,
1002,
5783,
11589,
18863,
1010,
1002,
2171,
1027,
19701,
1010,
1002,
12332,
1027,
19701,
1010,
9140,
1002,
2951,
1027,
9140,
1006,
1007,
1007,
1063,
2065,
1006,
1002,
2171,
999,
1027,
1005,
12040,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.php | Zend_Cache.factory | public static function factory($frontend, $backend, $frontendOptions = array(), $backendOptions = array(), $customFrontendNaming = false, $customBackendNaming = false, $autoload = false)
{
if (is_string($backend)) {
$backendObject = self::_makeBackend($backend, $backendOptions, $customBackendNaming, $autoload);
} else {
if ((is_object($backend)) && (in_array('Zend_Cache_Backend_Interface', class_implements($backend)))) {
$backendObject = $backend;
} else {
self::throwException('backend must be a backend name (string) or an object which implements Zend_Cache_Backend_Interface');
}
}
if (is_string($frontend)) {
$frontendObject = self::_makeFrontend($frontend, $frontendOptions, $customFrontendNaming, $autoload);
} else {
if (is_object($frontend)) {
$frontendObject = $frontend;
} else {
self::throwException('frontend must be a frontend name (string) or an object');
}
}
$frontendObject->setBackend($backendObject);
return $frontendObject;
} | php | public static function factory($frontend, $backend, $frontendOptions = array(), $backendOptions = array(), $customFrontendNaming = false, $customBackendNaming = false, $autoload = false)
{
if (is_string($backend)) {
$backendObject = self::_makeBackend($backend, $backendOptions, $customBackendNaming, $autoload);
} else {
if ((is_object($backend)) && (in_array('Zend_Cache_Backend_Interface', class_implements($backend)))) {
$backendObject = $backend;
} else {
self::throwException('backend must be a backend name (string) or an object which implements Zend_Cache_Backend_Interface');
}
}
if (is_string($frontend)) {
$frontendObject = self::_makeFrontend($frontend, $frontendOptions, $customFrontendNaming, $autoload);
} else {
if (is_object($frontend)) {
$frontendObject = $frontend;
} else {
self::throwException('frontend must be a frontend name (string) or an object');
}
}
$frontendObject->setBackend($backendObject);
return $frontendObject;
} | [
"public",
"static",
"function",
"factory",
"(",
"$",
"frontend",
",",
"$",
"backend",
",",
"$",
"frontendOptions",
"=",
"array",
"(",
")",
",",
"$",
"backendOptions",
"=",
"array",
"(",
")",
",",
"$",
"customFrontendNaming",
"=",
"false",
",",
"$",
"cust... | Factory
@param mixed $frontend frontend name (string) or Zend_Cache_Frontend_ object
@param mixed $backend backend name (string) or Zend_Cache_Backend_ object
@param array $frontendOptions associative array of options for the corresponding frontend constructor
@param array $backendOptions associative array of options for the corresponding backend constructor
@param boolean $customFrontendNaming if true, the frontend argument is used as a complete class name ; if false, the frontend argument is used as the end of "Zend_Cache_Frontend_[...]" class name
@param boolean $customBackendNaming if true, the backend argument is used as a complete class name ; if false, the backend argument is used as the end of "Zend_Cache_Backend_[...]" class name
@param boolean $autoload if true, there will no // require_once for backend and frontend (useful only for custom backends/frontends)
@throws Zend_Cache_Exception
@return Zend_Cache_Core|Zend_Cache_Frontend | [
"Factory"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache.php#L91-L113 | train | Create a new Zend_Cache_Backend_Interface object | [
30522,
2270,
10763,
3853,
4713,
1006,
1002,
2392,
10497,
1010,
1002,
2067,
10497,
1010,
1002,
2392,
10497,
7361,
9285,
1027,
9140,
1006,
1007,
1010,
1002,
2067,
10497,
7361,
9285,
1027,
9140,
1006,
1007,
1010,
1002,
7661,
12792,
10497,
2898... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Columns/Dimension.php | Dimension.uninstall | public function uninstall()
{
if (empty($this->columnName) || empty($this->columnType) || empty($this->dbTableName)) {
return;
}
try {
$sql = "ALTER TABLE `" . Common::prefixTable($this->dbTableName) . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
} | php | public function uninstall()
{
if (empty($this->columnName) || empty($this->columnType) || empty($this->dbTableName)) {
return;
}
try {
$sql = "ALTER TABLE `" . Common::prefixTable($this->dbTableName) . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
} | [
"public",
"function",
"uninstall",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"columnName",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"columnType",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"dbTableName",
")",
")",
"{",
"return",
... | Uninstalls the dimension if a {@link $columnName} and {@link columnType} is set. In case you perform any custom
actions during {@link install()} - for instance adding an index - you should make sure to undo those actions by
overwriting this method. Make sure to call this parent method to make sure the uninstallation of the column
will be done.
@throws Exception
@api | [
"Uninstalls",
"the",
"dimension",
"if",
"a",
"{"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L314-L328 | train | Uninstalls the column | [
30522,
2270,
3853,
4895,
7076,
9080,
2140,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
5930,
18442,
1007,
1064,
1064,
4064,
1006,
1002,
2023,
1011,
1028,
5930,
13874,
1007,
1064,
1064,
4064,
1006,
1002,
2023,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field/UploadField.php | UploadField.move | public function move($directory, $name = null)
{
$this->dir($directory);
$this->name($name);
return $this;
} | php | public function move($directory, $name = null)
{
$this->dir($directory);
$this->name($name);
return $this;
} | [
"public",
"function",
"move",
"(",
"$",
"directory",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"dir",
"(",
"$",
"directory",
")",
";",
"$",
"this",
"->",
"name",
"(",
"$",
"name",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Specify the directory and name for upload file.
@param string $directory
@param null|string $name
@return $this | [
"Specify",
"the",
"directory",
"and",
"name",
"for",
"upload",
"file",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/UploadField.php#L181-L188 | train | Move the current directory and name of the current file | [
30522,
2270,
3853,
2693,
1006,
1002,
14176,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
16101,
1006,
1002,
14176,
1007,
1025,
1002,
2023,
1011,
1028,
2171,
1006,
1002,
2171,
1007,
1025,
2709,
1002,
2023,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Traits/RedisTrait.php | RedisTrait.doClear | protected function doClear($namespace)
{
$cleared = true;
if ($this->redis instanceof \Predis\Client) {
$evalArgs = [0, $namespace];
} else {
$evalArgs = [[$namespace], 0];
}
foreach ($this->getHosts() as $host) {
if (!isset($namespace[0])) {
$cleared = $host->flushDb() && $cleared;
continue;
}
$info = $host->info('Server');
$info = isset($info['Server']) ? $info['Server'] : $info;
if (!version_compare($info['redis_version'], '2.8', '>=')) {
// As documented in Redis documentation (http://redis.io/commands/keys) using KEYS
// can hang your server when it is executed against large databases (millions of items).
// Whenever you hit this scale, you should really consider upgrading to Redis 2.8 or above.
$cleared = $host->eval("local keys=redis.call('KEYS',ARGV[1]..'*') for i=1,#keys,5000 do redis.call('DEL',unpack(keys,i,math.min(i+4999,#keys))) end return 1", $evalArgs[0], $evalArgs[1]) && $cleared;
continue;
}
$cursor = null;
do {
$keys = $host instanceof \Predis\Client ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000);
if (isset($keys[1]) && \is_array($keys[1])) {
$cursor = $keys[0];
$keys = $keys[1];
}
if ($keys) {
$this->doDelete($keys);
}
} while ($cursor = (int) $cursor);
}
return $cleared;
} | php | protected function doClear($namespace)
{
$cleared = true;
if ($this->redis instanceof \Predis\Client) {
$evalArgs = [0, $namespace];
} else {
$evalArgs = [[$namespace], 0];
}
foreach ($this->getHosts() as $host) {
if (!isset($namespace[0])) {
$cleared = $host->flushDb() && $cleared;
continue;
}
$info = $host->info('Server');
$info = isset($info['Server']) ? $info['Server'] : $info;
if (!version_compare($info['redis_version'], '2.8', '>=')) {
// As documented in Redis documentation (http://redis.io/commands/keys) using KEYS
// can hang your server when it is executed against large databases (millions of items).
// Whenever you hit this scale, you should really consider upgrading to Redis 2.8 or above.
$cleared = $host->eval("local keys=redis.call('KEYS',ARGV[1]..'*') for i=1,#keys,5000 do redis.call('DEL',unpack(keys,i,math.min(i+4999,#keys))) end return 1", $evalArgs[0], $evalArgs[1]) && $cleared;
continue;
}
$cursor = null;
do {
$keys = $host instanceof \Predis\Client ? $host->scan($cursor, 'MATCH', $namespace.'*', 'COUNT', 1000) : $host->scan($cursor, $namespace.'*', 1000);
if (isset($keys[1]) && \is_array($keys[1])) {
$cursor = $keys[0];
$keys = $keys[1];
}
if ($keys) {
$this->doDelete($keys);
}
} while ($cursor = (int) $cursor);
}
return $cleared;
} | [
"protected",
"function",
"doClear",
"(",
"$",
"namespace",
")",
"{",
"$",
"cleared",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"redis",
"instanceof",
"\\",
"Predis",
"\\",
"Client",
")",
"{",
"$",
"evalArgs",
"=",
"[",
"0",
",",
"$",
"namespace... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/RedisTrait.php#L321-L361 | train | Clear all cache entries for a namespace | [
30522,
5123,
3853,
9986,
19738,
2099,
1006,
1002,
3415,
15327,
1007,
1063,
1002,
5985,
1027,
2995,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
2417,
2483,
6013,
11253,
1032,
3653,
10521,
1032,
7396,
1007,
1063,
1002,
9345,
8017,
5620,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/UrlHelper.php | UrlHelper.getQueryFromUrl | public static function getQueryFromUrl($url, array $additionalParamsToAdd = array())
{
$url = @parse_url($url);
$query = '';
if (!empty($url['query'])) {
$query .= $url['query'];
}
if (!empty($additionalParamsToAdd)) {
if (!empty($query)) {
$query .= '&';
}
$query .= Url::getQueryStringFromParameters($additionalParamsToAdd);
}
return $query;
} | php | public static function getQueryFromUrl($url, array $additionalParamsToAdd = array())
{
$url = @parse_url($url);
$query = '';
if (!empty($url['query'])) {
$query .= $url['query'];
}
if (!empty($additionalParamsToAdd)) {
if (!empty($query)) {
$query .= '&';
}
$query .= Url::getQueryStringFromParameters($additionalParamsToAdd);
}
return $query;
} | [
"public",
"static",
"function",
"getQueryFromUrl",
"(",
"$",
"url",
",",
"array",
"$",
"additionalParamsToAdd",
"=",
"array",
"(",
")",
")",
"{",
"$",
"url",
"=",
"@",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"query",
"=",
"''",
";",
"if",
"(",
... | Returns the query part from any valid url and adds additional parameters to the query part if needed.
@param string $url Any url eg `"http://example.com/piwik/?foo=bar"`
@param array $additionalParamsToAdd If not empty the given parameters will be added to the query.
@return string eg. `"foo=bar&foo2=bar2"`
@api | [
"Returns",
"the",
"query",
"part",
"from",
"any",
"valid",
"url",
"and",
"adds",
"additional",
"parameters",
"to",
"the",
"query",
"part",
"if",
"needed",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/UrlHelper.php#L320-L338 | train | Returns the query string from a URL | [
30522,
2270,
10763,
3853,
2131,
4226,
2854,
19699,
5358,
3126,
2140,
1006,
1002,
24471,
2140,
1010,
9140,
1002,
3176,
28689,
5244,
3406,
4215,
2094,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
24471,
2140,
1027,
1030,
11968,
3366,
1035,
24471... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php | EncoderFactory.getEncoder | public function getEncoder($user)
{
$encoderKey = null;
if ($user instanceof EncoderAwareInterface && (null !== $encoderName = $user->getEncoderName())) {
if (!\array_key_exists($encoderName, $this->encoders)) {
throw new \RuntimeException(sprintf('The encoder "%s" was not configured.', $encoderName));
}
$encoderKey = $encoderName;
} else {
foreach ($this->encoders as $class => $encoder) {
if ((\is_object($user) && $user instanceof $class) || (!\is_object($user) && (is_subclass_of($user, $class) || $user == $class))) {
$encoderKey = $class;
break;
}
}
}
if (null === $encoderKey) {
throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', \is_object($user) ? \get_class($user) : $user));
}
if (!$this->encoders[$encoderKey] instanceof PasswordEncoderInterface) {
$this->encoders[$encoderKey] = $this->createEncoder($this->encoders[$encoderKey]);
}
return $this->encoders[$encoderKey];
} | php | public function getEncoder($user)
{
$encoderKey = null;
if ($user instanceof EncoderAwareInterface && (null !== $encoderName = $user->getEncoderName())) {
if (!\array_key_exists($encoderName, $this->encoders)) {
throw new \RuntimeException(sprintf('The encoder "%s" was not configured.', $encoderName));
}
$encoderKey = $encoderName;
} else {
foreach ($this->encoders as $class => $encoder) {
if ((\is_object($user) && $user instanceof $class) || (!\is_object($user) && (is_subclass_of($user, $class) || $user == $class))) {
$encoderKey = $class;
break;
}
}
}
if (null === $encoderKey) {
throw new \RuntimeException(sprintf('No encoder has been configured for account "%s".', \is_object($user) ? \get_class($user) : $user));
}
if (!$this->encoders[$encoderKey] instanceof PasswordEncoderInterface) {
$this->encoders[$encoderKey] = $this->createEncoder($this->encoders[$encoderKey]);
}
return $this->encoders[$encoderKey];
} | [
"public",
"function",
"getEncoder",
"(",
"$",
"user",
")",
"{",
"$",
"encoderKey",
"=",
"null",
";",
"if",
"(",
"$",
"user",
"instanceof",
"EncoderAwareInterface",
"&&",
"(",
"null",
"!==",
"$",
"encoderName",
"=",
"$",
"user",
"->",
"getEncoderName",
"(",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Encoder/EncoderFactory.php#L31-L59 | train | Get the encoder for the given user | [
30522,
2270,
3853,
2131,
2368,
16044,
2099,
1006,
1002,
5310,
1007,
1063,
1002,
4372,
16044,
25074,
2100,
1027,
19701,
1025,
2065,
1006,
1002,
5310,
6013,
11253,
4372,
16044,
2527,
8059,
18447,
2121,
12172,
1004,
1004,
1006,
19701,
999,
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... |
dompdf/dompdf | src/Dompdf.php | Dompdf.setPaper | public function setPaper($size, $orientation = "portrait")
{
$this->paperSize = $size;
$this->paperOrientation = $orientation;
return $this;
} | php | public function setPaper($size, $orientation = "portrait")
{
$this->paperSize = $size;
$this->paperOrientation = $orientation;
return $this;
} | [
"public",
"function",
"setPaper",
"(",
"$",
"size",
",",
"$",
"orientation",
"=",
"\"portrait\"",
")",
"{",
"$",
"this",
"->",
"paperSize",
"=",
"$",
"size",
";",
"$",
"this",
"->",
"paperOrientation",
"=",
"$",
"orientation",
";",
"return",
"$",
"this",... | Sets the paper size & orientation
@param string|array $size 'letter', 'legal', 'A4', etc. {@link Dompdf\Adapter\CPDF::$PAPER_SIZES}
@param string $orientation 'portrait' or 'landscape'
@return $this | [
"Sets",
"the",
"paper",
"size",
"&",
"orientation"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L1042-L1047 | train | Set Paper Size and Orientation | [
30522,
2270,
3853,
2275,
23298,
1006,
1002,
2946,
1010,
1002,
10296,
1027,
1000,
6533,
1000,
1007,
1063,
1002,
2023,
1011,
1028,
4981,
4697,
1027,
1002,
2946,
1025,
1002,
2023,
1011,
1028,
3259,
10050,
19304,
1027,
1002,
10296,
1025,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/VisitExcluded.php | VisitExcluded.isVisitorIpExcluded | protected function isVisitorIpExcluded()
{
$excludedIps = $this->getAttributes('excluded_ips', 'global_excluded_ips');
if (!empty($excludedIps)) {
$ip = IP::fromBinaryIP($this->ip);
if ($ip->isInRanges($excludedIps)) {
Common::printDebug('Visitor IP ' . $ip->toString() . ' is excluded from being tracked');
return true;
}
}
return false;
} | php | protected function isVisitorIpExcluded()
{
$excludedIps = $this->getAttributes('excluded_ips', 'global_excluded_ips');
if (!empty($excludedIps)) {
$ip = IP::fromBinaryIP($this->ip);
if ($ip->isInRanges($excludedIps)) {
Common::printDebug('Visitor IP ' . $ip->toString() . ' is excluded from being tracked');
return true;
}
}
return false;
} | [
"protected",
"function",
"isVisitorIpExcluded",
"(",
")",
"{",
"$",
"excludedIps",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
"'excluded_ips'",
",",
"'global_excluded_ips'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludedIps",
")",
")",
"{",
"$",
... | Checks if the visitor ip is in the excluded list
@return bool | [
"Checks",
"if",
"the",
"visitor",
"ip",
"is",
"in",
"the",
"excluded",
"list"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/VisitExcluded.php#L273-L286 | train | Checks if the visitor IP is excluded from being tracked | [
30522,
5123,
3853,
2003,
11365,
15660,
15457,
2595,
20464,
13936,
1006,
1007,
1063,
1002,
12421,
11514,
2015,
1027,
1002,
2023,
1011,
1028,
2131,
19321,
3089,
8569,
4570,
1006,
1005,
12421,
1035,
12997,
2015,
1005,
1010,
1005,
3795,
1035,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.init | public function init(\SplFileInfo $file, $extension = null)
{
$config = Grav::instance()['config'];
// some extension logic
if (empty($extension)) {
$this->extension('.' . $file->getExtension());
} else {
$this->extension($extension);
}
// extract page language from page extension
$language = trim(basename($this->extension(), 'md'), '.') ?: null;
$this->language($language);
$this->hide_home_route = $config->get('system.home.hide_in_urls', false);
$this->home_route = $this->adjustRouteCase($config->get('system.home.alias'));
$this->filePath($file->getPathname());
$this->modified($file->getMTime());
$this->id($this->modified() . md5($this->filePath()));
$this->routable(true);
$this->header();
$this->date();
$this->metadata();
$this->url();
$this->visible();
$this->modularTwig(strpos($this->slug(), '_') === 0);
$this->setPublishState();
$this->published();
$this->urlExtension();
return $this;
} | php | public function init(\SplFileInfo $file, $extension = null)
{
$config = Grav::instance()['config'];
// some extension logic
if (empty($extension)) {
$this->extension('.' . $file->getExtension());
} else {
$this->extension($extension);
}
// extract page language from page extension
$language = trim(basename($this->extension(), 'md'), '.') ?: null;
$this->language($language);
$this->hide_home_route = $config->get('system.home.hide_in_urls', false);
$this->home_route = $this->adjustRouteCase($config->get('system.home.alias'));
$this->filePath($file->getPathname());
$this->modified($file->getMTime());
$this->id($this->modified() . md5($this->filePath()));
$this->routable(true);
$this->header();
$this->date();
$this->metadata();
$this->url();
$this->visible();
$this->modularTwig(strpos($this->slug(), '_') === 0);
$this->setPublishState();
$this->published();
$this->urlExtension();
return $this;
} | [
"public",
"function",
"init",
"(",
"\\",
"SplFileInfo",
"$",
"file",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"Grav",
"::",
"instance",
"(",
")",
"[",
"'config'",
"]",
";",
"// some extension logic",
"if",
"(",
"empty",
"(",
"$... | Initializes the page instance variables based on a file
@param \SplFileInfo $file The file information for the .md file that the page represents
@param string $extension
@return $this | [
"Initializes",
"the",
"page",
"instance",
"variables",
"based",
"on",
"a",
"file"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L130-L163 | train | Initializes the page object | [
30522,
2270,
3853,
1999,
4183,
1006,
1032,
11867,
10270,
9463,
2378,
14876,
1002,
5371,
1010,
1002,
5331,
1027,
19701,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1031,
1005,
9530,
8873,
2290,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Events/Ev.php | Ev.del | public function del($fd, $flag)
{
switch ($flag) {
case self::EV_READ:
case self::EV_WRITE:
$fd_key = (int)$fd;
if (isset($this->_allEvents[$fd_key][$flag])) {
$this->_allEvents[$fd_key][$flag]->stop();
unset($this->_allEvents[$fd_key][$flag]);
}
if (empty($this->_allEvents[$fd_key])) {
unset($this->_allEvents[$fd_key]);
}
break;
case self::EV_SIGNAL:
$fd_key = (int)$fd;
if (isset($this->_eventSignal[$fd_key])) {
$this->_eventSignal[$fd_key]->stop();
unset($this->_eventSignal[$fd_key]);
}
break;
case self::EV_TIMER:
case self::EV_TIMER_ONCE:
if (isset($this->_eventTimer[$fd])) {
$this->_eventTimer[$fd]->stop();
unset($this->_eventTimer[$fd]);
}
break;
}
return true;
} | php | public function del($fd, $flag)
{
switch ($flag) {
case self::EV_READ:
case self::EV_WRITE:
$fd_key = (int)$fd;
if (isset($this->_allEvents[$fd_key][$flag])) {
$this->_allEvents[$fd_key][$flag]->stop();
unset($this->_allEvents[$fd_key][$flag]);
}
if (empty($this->_allEvents[$fd_key])) {
unset($this->_allEvents[$fd_key]);
}
break;
case self::EV_SIGNAL:
$fd_key = (int)$fd;
if (isset($this->_eventSignal[$fd_key])) {
$this->_eventSignal[$fd_key]->stop();
unset($this->_eventSignal[$fd_key]);
}
break;
case self::EV_TIMER:
case self::EV_TIMER_ONCE:
if (isset($this->_eventTimer[$fd])) {
$this->_eventTimer[$fd]->stop();
unset($this->_eventTimer[$fd]);
}
break;
}
return true;
} | [
"public",
"function",
"del",
"(",
"$",
"fd",
",",
"$",
"flag",
")",
"{",
"switch",
"(",
"$",
"flag",
")",
"{",
"case",
"self",
"::",
"EV_READ",
":",
"case",
"self",
"::",
"EV_WRITE",
":",
"$",
"fd_key",
"=",
"(",
"int",
")",
"$",
"fd",
";",
"if... | Remove a timer.
{@inheritdoc} | [
"Remove",
"a",
"timer",
".",
"{"
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Events/Ev.php#L94-L124 | train | De - register event | [
30522,
2270,
3853,
3972,
1006,
1002,
1042,
2094,
1010,
1002,
5210,
1007,
1063,
6942,
1006,
1002,
5210,
1007,
1063,
2553,
2969,
1024,
1024,
23408,
1035,
3191,
1024,
2553,
2969,
1024,
1024,
23408,
1035,
4339,
1024,
1002,
1042,
2094,
1035,
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... |
symfony/symfony | src/Symfony/Component/Cache/Traits/FilesystemTrait.php | FilesystemTrait.doHave | protected function doHave($id)
{
$file = $this->getFile($id);
return file_exists($file) && (@filemtime($file) > time() || $this->doFetch([$id]));
} | php | protected function doHave($id)
{
$file = $this->getFile($id);
return file_exists($file) && (@filemtime($file) > time() || $this->doFetch([$id]));
} | [
"protected",
"function",
"doHave",
"(",
"$",
"id",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"id",
")",
";",
"return",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"(",
"@",
"filemtime",
"(",
"$",
"file",
")",
">",
"time"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/FilesystemTrait.php#L84-L89 | train | DoHave - check if the cache has been updated | [
30522,
5123,
3853,
26528,
3726,
1006,
1002,
8909,
1007,
1063,
1002,
5371,
1027,
1002,
2023,
1011,
1028,
2131,
8873,
2571,
1006,
1002,
8909,
1007,
1025,
2709,
5371,
30524,
1033,
1007,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getFilters | public function getFilters()
{
return [
new \Twig_SimpleFilter('*ize', [$this, 'inflectorFilter']),
new \Twig_SimpleFilter('absolute_url', [$this, 'absoluteUrlFilter']),
new \Twig_SimpleFilter('contains', [$this, 'containsFilter']),
new \Twig_SimpleFilter('chunk_split', [$this, 'chunkSplitFilter']),
new \Twig_SimpleFilter('nicenumber', [$this, 'niceNumberFunc']),
new \Twig_SimpleFilter('nicefilesize', [$this, 'niceFilesizeFunc']),
new \Twig_SimpleFilter('nicetime', [$this, 'nicetimeFunc']),
new \Twig_SimpleFilter('defined', [$this, 'definedDefaultFilter']),
new \Twig_SimpleFilter('ends_with', [$this, 'endsWithFilter']),
new \Twig_SimpleFilter('fieldName', [$this, 'fieldNameFilter']),
new \Twig_SimpleFilter('ksort', [$this, 'ksortFilter']),
new \Twig_SimpleFilter('ltrim', [$this, 'ltrimFilter']),
new \Twig_SimpleFilter('markdown', [$this, 'markdownFunction'], ['is_safe' => ['html']]),
new \Twig_SimpleFilter('md5', [$this, 'md5Filter']),
new \Twig_SimpleFilter('base32_encode', [$this, 'base32EncodeFilter']),
new \Twig_SimpleFilter('base32_decode', [$this, 'base32DecodeFilter']),
new \Twig_SimpleFilter('base64_encode', [$this, 'base64EncodeFilter']),
new \Twig_SimpleFilter('base64_decode', [$this, 'base64DecodeFilter']),
new \Twig_SimpleFilter('randomize', [$this, 'randomizeFilter']),
new \Twig_SimpleFilter('modulus', [$this, 'modulusFilter']),
new \Twig_SimpleFilter('rtrim', [$this, 'rtrimFilter']),
new \Twig_SimpleFilter('pad', [$this, 'padFilter']),
new \Twig_SimpleFilter('regex_replace', [$this, 'regexReplace']),
new \Twig_SimpleFilter('safe_email', [$this, 'safeEmailFilter']),
new \Twig_SimpleFilter('safe_truncate', ['\Grav\Common\Utils', 'safeTruncate']),
new \Twig_SimpleFilter('safe_truncate_html', ['\Grav\Common\Utils', 'safeTruncateHTML']),
new \Twig_SimpleFilter('sort_by_key', [$this, 'sortByKeyFilter']),
new \Twig_SimpleFilter('starts_with', [$this, 'startsWithFilter']),
new \Twig_SimpleFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
new \Twig_SimpleFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
new \Twig_SimpleFilter('json_decode', [$this, 'jsonDecodeFilter']),
new \Twig_SimpleFilter('array_unique', 'array_unique'),
new \Twig_SimpleFilter('basename', 'basename'),
new \Twig_SimpleFilter('dirname', 'dirname'),
new \Twig_SimpleFilter('print_r', 'print_r'),
new \Twig_SimpleFilter('yaml_encode', [$this, 'yamlEncodeFilter']),
new \Twig_SimpleFilter('yaml_decode', [$this, 'yamlDecodeFilter']),
new \Twig_SimpleFilter('nicecron', [$this, 'niceCronFilter']),
// Translations
new \Twig_SimpleFilter('t', [$this, 'translate'], ['needs_environment' => true]),
new \Twig_SimpleFilter('tl', [$this, 'translateLanguage']),
new \Twig_SimpleFilter('ta', [$this, 'translateArray']),
// Casting values
new \Twig_SimpleFilter('string', [$this, 'stringFilter']),
new \Twig_SimpleFilter('int', [$this, 'intFilter'], ['is_safe' => ['all']]),
new \Twig_SimpleFilter('bool', [$this, 'boolFilter']),
new \Twig_SimpleFilter('float', [$this, 'floatFilter'], ['is_safe' => ['all']]),
new \Twig_SimpleFilter('array', [$this, 'arrayFilter']),
// Object Types
new \Twig_SimpleFilter('get_type', [$this, 'getTypeFunc']),
new \Twig_SimpleFilter('of_type', [$this, 'ofTypeFunc'])
];
} | php | public function getFilters()
{
return [
new \Twig_SimpleFilter('*ize', [$this, 'inflectorFilter']),
new \Twig_SimpleFilter('absolute_url', [$this, 'absoluteUrlFilter']),
new \Twig_SimpleFilter('contains', [$this, 'containsFilter']),
new \Twig_SimpleFilter('chunk_split', [$this, 'chunkSplitFilter']),
new \Twig_SimpleFilter('nicenumber', [$this, 'niceNumberFunc']),
new \Twig_SimpleFilter('nicefilesize', [$this, 'niceFilesizeFunc']),
new \Twig_SimpleFilter('nicetime', [$this, 'nicetimeFunc']),
new \Twig_SimpleFilter('defined', [$this, 'definedDefaultFilter']),
new \Twig_SimpleFilter('ends_with', [$this, 'endsWithFilter']),
new \Twig_SimpleFilter('fieldName', [$this, 'fieldNameFilter']),
new \Twig_SimpleFilter('ksort', [$this, 'ksortFilter']),
new \Twig_SimpleFilter('ltrim', [$this, 'ltrimFilter']),
new \Twig_SimpleFilter('markdown', [$this, 'markdownFunction'], ['is_safe' => ['html']]),
new \Twig_SimpleFilter('md5', [$this, 'md5Filter']),
new \Twig_SimpleFilter('base32_encode', [$this, 'base32EncodeFilter']),
new \Twig_SimpleFilter('base32_decode', [$this, 'base32DecodeFilter']),
new \Twig_SimpleFilter('base64_encode', [$this, 'base64EncodeFilter']),
new \Twig_SimpleFilter('base64_decode', [$this, 'base64DecodeFilter']),
new \Twig_SimpleFilter('randomize', [$this, 'randomizeFilter']),
new \Twig_SimpleFilter('modulus', [$this, 'modulusFilter']),
new \Twig_SimpleFilter('rtrim', [$this, 'rtrimFilter']),
new \Twig_SimpleFilter('pad', [$this, 'padFilter']),
new \Twig_SimpleFilter('regex_replace', [$this, 'regexReplace']),
new \Twig_SimpleFilter('safe_email', [$this, 'safeEmailFilter']),
new \Twig_SimpleFilter('safe_truncate', ['\Grav\Common\Utils', 'safeTruncate']),
new \Twig_SimpleFilter('safe_truncate_html', ['\Grav\Common\Utils', 'safeTruncateHTML']),
new \Twig_SimpleFilter('sort_by_key', [$this, 'sortByKeyFilter']),
new \Twig_SimpleFilter('starts_with', [$this, 'startsWithFilter']),
new \Twig_SimpleFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
new \Twig_SimpleFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
new \Twig_SimpleFilter('json_decode', [$this, 'jsonDecodeFilter']),
new \Twig_SimpleFilter('array_unique', 'array_unique'),
new \Twig_SimpleFilter('basename', 'basename'),
new \Twig_SimpleFilter('dirname', 'dirname'),
new \Twig_SimpleFilter('print_r', 'print_r'),
new \Twig_SimpleFilter('yaml_encode', [$this, 'yamlEncodeFilter']),
new \Twig_SimpleFilter('yaml_decode', [$this, 'yamlDecodeFilter']),
new \Twig_SimpleFilter('nicecron', [$this, 'niceCronFilter']),
// Translations
new \Twig_SimpleFilter('t', [$this, 'translate'], ['needs_environment' => true]),
new \Twig_SimpleFilter('tl', [$this, 'translateLanguage']),
new \Twig_SimpleFilter('ta', [$this, 'translateArray']),
// Casting values
new \Twig_SimpleFilter('string', [$this, 'stringFilter']),
new \Twig_SimpleFilter('int', [$this, 'intFilter'], ['is_safe' => ['all']]),
new \Twig_SimpleFilter('bool', [$this, 'boolFilter']),
new \Twig_SimpleFilter('float', [$this, 'floatFilter'], ['is_safe' => ['all']]),
new \Twig_SimpleFilter('array', [$this, 'arrayFilter']),
// Object Types
new \Twig_SimpleFilter('get_type', [$this, 'getTypeFunc']),
new \Twig_SimpleFilter('of_type', [$this, 'ofTypeFunc'])
];
} | [
"public",
"function",
"getFilters",
"(",
")",
"{",
"return",
"[",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"'*ize'",
",",
"[",
"$",
"this",
",",
"'inflectorFilter'",
"]",
")",
",",
"new",
"\\",
"Twig_SimpleFilter",
"(",
"'absolute_url'",
",",
"[",
"$",
"this... | Return a list of all filters.
@return array | [
"Return",
"a",
"list",
"of",
"all",
"filters",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TwigExtension.php#L72-L130 | train | Get all filters | [
30522,
2270,
3853,
2131,
8873,
21928,
2015,
1006,
1007,
1063,
2709,
1031,
2047,
1032,
1056,
16279,
1035,
3722,
8873,
21928,
1006,
1005,
1008,
1045,
4371,
1005,
1010,
1031,
1002,
2023,
1010,
1005,
1999,
21031,
16761,
8873,
21928,
1005,
1033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Worker.php | Worker.monitorWorkersForLinux | protected static function monitorWorkersForLinux()
{
static::$_status = static::STATUS_RUNNING;
while (1) {
// Calls signal handlers for pending signals.
pcntl_signal_dispatch();
// Suspends execution of the current process until a child has exited, or until a signal is delivered
$status = 0;
$pid = pcntl_wait($status, WUNTRACED);
// Calls signal handlers for pending signals again.
pcntl_signal_dispatch();
// If a child has already exited.
if ($pid > 0) {
// Find out witch worker process exited.
foreach (static::$_pidMap as $worker_id => $worker_pid_array) {
if (isset($worker_pid_array[$pid])) {
$worker = static::$_workers[$worker_id];
// Exit status.
if ($status !== 0) {
static::log("worker[" . $worker->name . ":$pid] exit with status $status");
}
// For Statistics.
if (!isset(static::$_globalStatistics['worker_exit_info'][$worker_id][$status])) {
static::$_globalStatistics['worker_exit_info'][$worker_id][$status] = 0;
}
static::$_globalStatistics['worker_exit_info'][$worker_id][$status]++;
// Clear process data.
unset(static::$_pidMap[$worker_id][$pid]);
// Mark id is available.
$id = static::getId($worker_id, $pid);
static::$_idMap[$worker_id][$id] = 0;
break;
}
}
// Is still running state then fork a new worker process.
if (static::$_status !== static::STATUS_SHUTDOWN) {
static::forkWorkers();
// If reloading continue.
if (isset(static::$_pidsToRestart[$pid])) {
unset(static::$_pidsToRestart[$pid]);
static::reload();
}
}
}
// If shutdown state and all child processes exited then master process exit.
if (static::$_status === static::STATUS_SHUTDOWN && !static::getAllWorkerPids()) {
static::exitAndClearAll();
}
}
} | php | protected static function monitorWorkersForLinux()
{
static::$_status = static::STATUS_RUNNING;
while (1) {
// Calls signal handlers for pending signals.
pcntl_signal_dispatch();
// Suspends execution of the current process until a child has exited, or until a signal is delivered
$status = 0;
$pid = pcntl_wait($status, WUNTRACED);
// Calls signal handlers for pending signals again.
pcntl_signal_dispatch();
// If a child has already exited.
if ($pid > 0) {
// Find out witch worker process exited.
foreach (static::$_pidMap as $worker_id => $worker_pid_array) {
if (isset($worker_pid_array[$pid])) {
$worker = static::$_workers[$worker_id];
// Exit status.
if ($status !== 0) {
static::log("worker[" . $worker->name . ":$pid] exit with status $status");
}
// For Statistics.
if (!isset(static::$_globalStatistics['worker_exit_info'][$worker_id][$status])) {
static::$_globalStatistics['worker_exit_info'][$worker_id][$status] = 0;
}
static::$_globalStatistics['worker_exit_info'][$worker_id][$status]++;
// Clear process data.
unset(static::$_pidMap[$worker_id][$pid]);
// Mark id is available.
$id = static::getId($worker_id, $pid);
static::$_idMap[$worker_id][$id] = 0;
break;
}
}
// Is still running state then fork a new worker process.
if (static::$_status !== static::STATUS_SHUTDOWN) {
static::forkWorkers();
// If reloading continue.
if (isset(static::$_pidsToRestart[$pid])) {
unset(static::$_pidsToRestart[$pid]);
static::reload();
}
}
}
// If shutdown state and all child processes exited then master process exit.
if (static::$_status === static::STATUS_SHUTDOWN && !static::getAllWorkerPids()) {
static::exitAndClearAll();
}
}
} | [
"protected",
"static",
"function",
"monitorWorkersForLinux",
"(",
")",
"{",
"static",
"::",
"$",
"_status",
"=",
"static",
"::",
"STATUS_RUNNING",
";",
"while",
"(",
"1",
")",
"{",
"// Calls signal handlers for pending signals.",
"pcntl_signal_dispatch",
"(",
")",
"... | Monitor all child processes.
@return void | [
"Monitor",
"all",
"child",
"processes",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L1582-L1636 | train | Monitor workers for Linux processes | [
30522,
5123,
10763,
3853,
8080,
6198,
2545,
29278,
4115,
5602,
1006,
1007,
1063,
10763,
1024,
1024,
1002,
1035,
3570,
1027,
10763,
1024,
1024,
3570,
1035,
2770,
1025,
2096,
1006,
1015,
1007,
1063,
1013,
1013,
4455,
4742,
28213,
2015,
2005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Protocol/Imap.php | Zend_Mail_Protocol_Imap.logout | public function logout()
{
$result = false;
if ($this->_socket) {
try {
$result = $this->requestAndResponse('LOGOUT', array(), true);
} catch (Zend_Mail_Protocol_Exception $e) {
// ignoring exception
}
fclose($this->_socket);
$this->_socket = null;
}
return $result;
} | php | public function logout()
{
$result = false;
if ($this->_socket) {
try {
$result = $this->requestAndResponse('LOGOUT', array(), true);
} catch (Zend_Mail_Protocol_Exception $e) {
// ignoring exception
}
fclose($this->_socket);
$this->_socket = null;
}
return $result;
} | [
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"_socket",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"requestAndResponse",
"(",
"'LOGOUT'",
",",
"array",
"(",
")",
",... | logout of imap server
@return bool success | [
"logout",
"of",
"imap",
"server"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L454-L467 | train | Logout - Sends logout - Request and returns true if successful | [
30522,
2270,
3853,
8154,
4904,
1006,
1007,
1063,
1002,
2765,
1027,
6270,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
22278,
1007,
1063,
3046,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
5227,
5685,
6072,
26029,
3366,
1006,
1005,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Http/Resources/Json/ResourceCollection.php | ResourceCollection.toResponse | public function toResponse($request)
{
return $this->resource instanceof AbstractPaginator
? (new PaginatedResourceResponse($this))->toResponse($request)
: parent::toResponse($request);
} | php | public function toResponse($request)
{
return $this->resource instanceof AbstractPaginator
? (new PaginatedResourceResponse($this))->toResponse($request)
: parent::toResponse($request);
} | [
"public",
"function",
"toResponse",
"(",
"$",
"request",
")",
"{",
"return",
"$",
"this",
"->",
"resource",
"instanceof",
"AbstractPaginator",
"?",
"(",
"new",
"PaginatedResourceResponse",
"(",
"$",
"this",
")",
")",
"->",
"toResponse",
"(",
"$",
"request",
... | Create an HTTP response that represents the object.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\JsonResponse | [
"Create",
"an",
"HTTP",
"response",
"that",
"represents",
"the",
"object",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Resources/Json/ResourceCollection.php#L68-L73 | train | Returns the response for the resource | [
30522,
2270,
3853,
9538,
13102,
5644,
2063,
1006,
1002,
5227,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7692,
6013,
11253,
10061,
4502,
20876,
4263,
1029,
1006,
2047,
6643,
20876,
3064,
6072,
8162,
17119,
2229,
26029,
3366,
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... |
matomo-org/matomo | core/Archive.php | Archive.build | public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false)
{
return StaticContainer::get(ArchiveQueryFactory::class)->build($idSites, $period, $strDate, $segment,
$_restrictSitesToLogin);
} | php | public static function build($idSites, $period, $strDate, $segment = false, $_restrictSitesToLogin = false)
{
return StaticContainer::get(ArchiveQueryFactory::class)->build($idSites, $period, $strDate, $segment,
$_restrictSitesToLogin);
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"idSites",
",",
"$",
"period",
",",
"$",
"strDate",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"_restrictSitesToLogin",
"=",
"false",
")",
"{",
"return",
"StaticContainer",
"::",
"get",
"(",
"ArchiveQuer... | Returns a new Archive instance that will query archive data for the given set of
sites and periods, using an optional Segment.
This method uses data that is found in query parameters, so the parameters to this
function can be string values.
If you want to create an Archive instance with an array of Period instances, use
{@link Archive::factory()}.
@param string|int|array $idSites A single ID (eg, `'1'`), multiple IDs (eg, `'1,2,3'` or `array(1, 2, 3)`),
or `'all'`.
@param string $period 'day', `'week'`, `'month'`, `'year'` or `'range'`
@param Date|string $strDate 'YYYY-MM-DD', magic keywords (ie, 'today'; {@link Date::factory()}
or date range (ie, 'YYYY-MM-DD,YYYY-MM-DD').
@param bool|false|string $segment Segment definition or false if no segment should be used. {@link Piwik\Segment}
@param bool|false|string $_restrictSitesToLogin Used only when running as a scheduled task.
@return ArchiveQuery | [
"Returns",
"a",
"new",
"Archive",
"instance",
"that",
"will",
"query",
"archive",
"data",
"for",
"the",
"given",
"set",
"of",
"sites",
"and",
"periods",
"using",
"an",
"optional",
"Segment",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive.php#L209-L213 | train | Build archive archive | [
30522,
2270,
10763,
3853,
3857,
1006,
1002,
8909,
28032,
2229,
1010,
1002,
2558,
1010,
1002,
2358,
13639,
2618,
1010,
1002,
6903,
1027,
6270,
1010,
1002,
1035,
21573,
28032,
4355,
12898,
11528,
1027,
6270,
1007,
1063,
2709,
10763,
8663,
182... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Http/Kernel.php | Kernel.prependMiddleware | public function prependMiddleware($middleware)
{
if (array_search($middleware, $this->middleware) === false) {
array_unshift($this->middleware, $middleware);
}
return $this;
} | php | public function prependMiddleware($middleware)
{
if (array_search($middleware, $this->middleware) === false) {
array_unshift($this->middleware, $middleware);
}
return $this;
} | [
"public",
"function",
"prependMiddleware",
"(",
"$",
"middleware",
")",
"{",
"if",
"(",
"array_search",
"(",
"$",
"middleware",
",",
"$",
"this",
"->",
"middleware",
")",
"===",
"false",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"middleware",
",",... | Add a new middleware to beginning of the stack if it does not already exist.
@param string $middleware
@return $this | [
"Add",
"a",
"new",
"middleware",
"to",
"beginning",
"of",
"the",
"stack",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Http/Kernel.php#L272-L279 | train | Prepends a middleware to the beginning of the stack | [
30522,
2270,
3853,
17463,
10497,
4328,
20338,
8059,
1006,
1002,
2690,
8059,
1007,
1063,
2065,
1006,
9140,
1035,
3945,
1006,
1002,
2690,
8059,
1010,
1002,
2023,
1011,
1028,
2690,
8059,
1007,
1027,
1027,
1027,
6270,
1007,
1063,
9140,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Worker.php | Worker.reinstallSignal | protected static function reinstallSignal()
{
if (static::$_OS !== OS_TYPE_LINUX) {
return;
}
// uninstall stop signal handler
pcntl_signal(SIGINT, SIG_IGN, false);
// uninstall graceful stop signal handler
pcntl_signal(SIGTERM, SIG_IGN, false);
// uninstall reload signal handler
pcntl_signal(SIGUSR1, SIG_IGN, false);
// uninstall graceful reload signal handler
pcntl_signal(SIGQUIT, SIG_IGN, false);
// uninstall status signal handler
pcntl_signal(SIGUSR2, SIG_IGN, false);
// reinstall stop signal handler
static::$globalEvent->add(SIGINT, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall graceful stop signal handler
static::$globalEvent->add(SIGTERM, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall reload signal handler
static::$globalEvent->add(SIGUSR1, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall graceful reload signal handler
static::$globalEvent->add(SIGQUIT, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall status signal handler
static::$globalEvent->add(SIGUSR2, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall connection status signal handler
static::$globalEvent->add(SIGIO, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
} | php | protected static function reinstallSignal()
{
if (static::$_OS !== OS_TYPE_LINUX) {
return;
}
// uninstall stop signal handler
pcntl_signal(SIGINT, SIG_IGN, false);
// uninstall graceful stop signal handler
pcntl_signal(SIGTERM, SIG_IGN, false);
// uninstall reload signal handler
pcntl_signal(SIGUSR1, SIG_IGN, false);
// uninstall graceful reload signal handler
pcntl_signal(SIGQUIT, SIG_IGN, false);
// uninstall status signal handler
pcntl_signal(SIGUSR2, SIG_IGN, false);
// reinstall stop signal handler
static::$globalEvent->add(SIGINT, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall graceful stop signal handler
static::$globalEvent->add(SIGTERM, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall reload signal handler
static::$globalEvent->add(SIGUSR1, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall graceful reload signal handler
static::$globalEvent->add(SIGQUIT, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall status signal handler
static::$globalEvent->add(SIGUSR2, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
// reinstall connection status signal handler
static::$globalEvent->add(SIGIO, EventInterface::EV_SIGNAL, array('\Workerman\Worker', 'signalHandler'));
} | [
"protected",
"static",
"function",
"reinstallSignal",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"_OS",
"!==",
"OS_TYPE_LINUX",
")",
"{",
"return",
";",
"}",
"// uninstall stop signal handler",
"pcntl_signal",
"(",
"SIGINT",
",",
"SIG_IGN",
",",
"false",
"... | Reinstall signal handler.
@return void | [
"Reinstall",
"signal",
"handler",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L1078-L1105 | train | Reinstalls signal handlers | [
30522,
5123,
10763,
3853,
19222,
9080,
4877,
23773,
2389,
1006,
1007,
1063,
2065,
1006,
10763,
1024,
1024,
1002,
1035,
9808,
999,
1027,
1027,
9808,
1035,
2828,
1035,
11603,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
4895,
7076,
9080,
2140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.prependColumn | protected function prependColumn($column = '', $label = '')
{
$column = new Column($column, $label);
$column->setGrid($this);
return tap($column, function ($value) {
$this->columns->prepend($value);
});
} | php | protected function prependColumn($column = '', $label = '')
{
$column = new Column($column, $label);
$column->setGrid($this);
return tap($column, function ($value) {
$this->columns->prepend($value);
});
} | [
"protected",
"function",
"prependColumn",
"(",
"$",
"column",
"=",
"''",
",",
"$",
"label",
"=",
"''",
")",
"{",
"$",
"column",
"=",
"new",
"Column",
"(",
"$",
"column",
",",
"$",
"label",
")",
";",
"$",
"column",
"->",
"setGrid",
"(",
"$",
"this",... | Prepend column to grid.
@param string $column
@param string $label
@return Column | [
"Prepend",
"column",
"to",
"grid",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L416-L424 | train | Prepend a column to the grid. | [
30522,
5123,
3853,
17463,
10497,
25778,
2819,
2078,
1006,
1002,
5930,
1027,
1005,
1005,
1010,
1002,
3830,
1027,
1005,
1005,
1007,
1063,
1002,
5930,
1027,
2047,
5930,
1006,
1002,
5930,
1010,
1002,
3830,
1007,
1025,
1002,
5930,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/Concerns/InteractsWithInput.php | InteractsWithInput.anyFilled | public function anyFilled($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
foreach ($keys as $key) {
if ($this->filled($key)) {
return true;
}
}
return false;
} | php | public function anyFilled($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
foreach ($keys as $key) {
if ($this->filled($key)) {
return true;
}
}
return false;
} | [
"public",
"function",
"anyFilled",
"(",
"$",
"keys",
")",
"{",
"$",
"keys",
"=",
"is_array",
"(",
"$",
"keys",
")",
"?",
"$",
"keys",
":",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
... | Determine if the request contains a non-empty value for any of the given inputs.
@param string|array $keys
@return bool | [
"Determine",
"if",
"the",
"request",
"contains",
"a",
"non",
"-",
"empty",
"value",
"for",
"any",
"of",
"the",
"given",
"inputs",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Concerns/InteractsWithInput.php#L140-L151 | train | Any filled in the array | [
30522,
2270,
3853,
2151,
8873,
11001,
1006,
1002,
6309,
1007,
1063,
1002,
6309,
1027,
2003,
1035,
9140,
1006,
1002,
6309,
1007,
1029,
1002,
6309,
1024,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
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... |
matomo-org/matomo | libs/Zend/Validate/NotEmpty.php | Zend_Validate_NotEmpty.isValid | public function isValid($value)
{
if ($value !== null && !is_string($value) && !is_int($value) && !is_float($value) &&
!is_bool($value) && !is_array($value) && !is_object($value)) {
$this->_error(self::INVALID);
return false;
}
$type = $this->getType();
$this->_setValue($value);
$object = false;
// OBJECT_COUNT (countable object)
if ($type >= self::OBJECT_COUNT) {
$type -= self::OBJECT_COUNT;
$object = true;
if (is_object($value) && ($value instanceof Countable) && (count($value) == 0)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// OBJECT_STRING (object's toString)
if ($type >= self::OBJECT_STRING) {
$type -= self::OBJECT_STRING;
$object = true;
if ((is_object($value) && (!method_exists($value, '__toString'))) ||
(is_object($value) && (method_exists($value, '__toString')) && (((string) $value) == ""))) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// OBJECT (object)
if ($type >= self::OBJECT) {
$type -= self::OBJECT;
// fall trough, objects are always not empty
} else if ($object === false) {
// object not allowed but object given -> return false
if (is_object($value)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// SPACE (' ')
if ($type >= self::SPACE) {
$type -= self::SPACE;
if (is_string($value) && (preg_match('/^\s+$/s', $value))) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// NULL (null)
if ($type >= self::NULL) {
$type -= self::NULL;
if ($value === null) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// EMPTY_ARRAY (array())
if ($type >= self::EMPTY_ARRAY) {
$type -= self::EMPTY_ARRAY;
if (is_array($value) && ($value == array())) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// ZERO ('0')
if ($type >= self::ZERO) {
$type -= self::ZERO;
if (is_string($value) && ($value == '0')) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// STRING ('')
if ($type >= self::STRING) {
$type -= self::STRING;
if (is_string($value) && ($value == '')) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// FLOAT (0.0)
if ($type >= self::FLOAT) {
$type -= self::FLOAT;
if (is_float($value) && ($value == 0.0)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// INTEGER (0)
if ($type >= self::INTEGER) {
$type -= self::INTEGER;
if (is_int($value) && ($value == 0)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// BOOLEAN (false)
if ($type >= self::BOOLEAN) {
$type -= self::BOOLEAN;
if (is_bool($value) && ($value == false)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
return true;
} | php | public function isValid($value)
{
if ($value !== null && !is_string($value) && !is_int($value) && !is_float($value) &&
!is_bool($value) && !is_array($value) && !is_object($value)) {
$this->_error(self::INVALID);
return false;
}
$type = $this->getType();
$this->_setValue($value);
$object = false;
// OBJECT_COUNT (countable object)
if ($type >= self::OBJECT_COUNT) {
$type -= self::OBJECT_COUNT;
$object = true;
if (is_object($value) && ($value instanceof Countable) && (count($value) == 0)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// OBJECT_STRING (object's toString)
if ($type >= self::OBJECT_STRING) {
$type -= self::OBJECT_STRING;
$object = true;
if ((is_object($value) && (!method_exists($value, '__toString'))) ||
(is_object($value) && (method_exists($value, '__toString')) && (((string) $value) == ""))) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// OBJECT (object)
if ($type >= self::OBJECT) {
$type -= self::OBJECT;
// fall trough, objects are always not empty
} else if ($object === false) {
// object not allowed but object given -> return false
if (is_object($value)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// SPACE (' ')
if ($type >= self::SPACE) {
$type -= self::SPACE;
if (is_string($value) && (preg_match('/^\s+$/s', $value))) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// NULL (null)
if ($type >= self::NULL) {
$type -= self::NULL;
if ($value === null) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// EMPTY_ARRAY (array())
if ($type >= self::EMPTY_ARRAY) {
$type -= self::EMPTY_ARRAY;
if (is_array($value) && ($value == array())) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// ZERO ('0')
if ($type >= self::ZERO) {
$type -= self::ZERO;
if (is_string($value) && ($value == '0')) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// STRING ('')
if ($type >= self::STRING) {
$type -= self::STRING;
if (is_string($value) && ($value == '')) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// FLOAT (0.0)
if ($type >= self::FLOAT) {
$type -= self::FLOAT;
if (is_float($value) && ($value == 0.0)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// INTEGER (0)
if ($type >= self::INTEGER) {
$type -= self::INTEGER;
if (is_int($value) && ($value == 0)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
// BOOLEAN (false)
if ($type >= self::BOOLEAN) {
$type -= self::BOOLEAN;
if (is_bool($value) && ($value == false)) {
$this->_error(self::IS_EMPTY);
return false;
}
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
"&&",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"!",
"is_int",
"(",
"$",
"value",
")",
"&&",
"!",
"is_float",
"(",
"$",
"value",
")",
"&&"... | Defined by Zend_Validate_Interface
Returns true if and only if $value is not an empty value.
@param string $value
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/NotEmpty.php#L158-L278 | train | Valida o valor de una peticion | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
3643,
999,
1027,
1027,
19701,
1004,
1004,
999,
2003,
1035,
5164,
1006,
1002,
3643,
1007,
1004,
1004,
999,
2003,
1035,
20014,
1006,
1002,
3643,
1007,
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/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php | FormTypeCsrfExtension.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['csrf_protection']) {
return;
}
$builder
->addEventSubscriber(new CsrfValidationListener(
$options['csrf_field_name'],
$options['csrf_token_manager'],
$options['csrf_token_id'] ?: ($builder->getName() ?: \get_class($builder->getType()->getInnerType())),
$options['csrf_message'],
$this->translator,
$this->translationDomain,
$this->serverParams
))
;
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['csrf_protection']) {
return;
}
$builder
->addEventSubscriber(new CsrfValidationListener(
$options['csrf_field_name'],
$options['csrf_token_manager'],
$options['csrf_token_id'] ?: ($builder->getName() ?: \get_class($builder->getType()->getInnerType())),
$options['csrf_message'],
$this->translator,
$this->translationDomain,
$this->serverParams
))
;
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"options",
"[",
"'csrf_protection'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"builder",
"->",
"addEventSubscriber",
... | Adds a CSRF field to the form when the CSRF protection is enabled.
@param FormBuilderInterface $builder The form builder
@param array $options The options | [
"Adds",
"a",
"CSRF",
"field",
"to",
"the",
"form",
"when",
"the",
"CSRF",
"protection",
"is",
"enabled",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php#L60-L77 | train | Adds the CSRF protection to the form builder | [
30522,
2270,
3853,
3857,
14192,
1006,
2433,
8569,
23891,
6657,
3334,
12172,
1002,
12508,
1010,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
999,
1002,
7047,
1031,
1005,
20116,
12881,
1035,
3860,
1005,
1033,
1007,
1063,
2709,
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/Form/Traits/FormTrait.php | FormTrait.parseRequest | protected function parseRequest(ServerRequestInterface $request): array
{
$method = $request->getMethod();
if (!\in_array($method, ['PUT', 'POST', 'PATCH'])) {
throw new \RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
}
$body = $request->getParsedBody();
$data = isset($body['data']) ? $this->decodeData($body['data']) : null;
$flash = $this->getFlash();
/*
if (null !== $data) {
$flash->setData($data);
$flash->save();
}
*/
$blueprint = $this->getBlueprint();
$includeOriginal = (bool)($blueprint->form()['images']['original'] ?? null);
$files = $flash->getFilesByFields($includeOriginal);
$data = $blueprint->processForm($data ?? [], $body['toggleable_data'] ?? []);
return [
$data,
$files ?? []
];
} | php | protected function parseRequest(ServerRequestInterface $request): array
{
$method = $request->getMethod();
if (!\in_array($method, ['PUT', 'POST', 'PATCH'])) {
throw new \RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
}
$body = $request->getParsedBody();
$data = isset($body['data']) ? $this->decodeData($body['data']) : null;
$flash = $this->getFlash();
/*
if (null !== $data) {
$flash->setData($data);
$flash->save();
}
*/
$blueprint = $this->getBlueprint();
$includeOriginal = (bool)($blueprint->form()['images']['original'] ?? null);
$files = $flash->getFilesByFields($includeOriginal);
$data = $blueprint->processForm($data ?? [], $body['toggleable_data'] ?? []);
return [
$data,
$files ?? []
];
} | [
"protected",
"function",
"parseRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"array",
"{",
"$",
"method",
"=",
"$",
"request",
"->",
"getMethod",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"method",
",",
"[",
"'PUT'",... | Parse PSR-7 ServerRequest into data and files.
@param ServerRequestInterface $request
@return array | [
"Parse",
"PSR",
"-",
"7",
"ServerRequest",
"into",
"data",
"and",
"files",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/Traits/FormTrait.php#L446-L474 | train | Parse the request and return the data and files | [
30522,
5123,
3853,
11968,
8043,
2063,
15500,
1006,
8241,
2890,
15500,
18447,
2121,
12172,
1002,
5227,
1007,
1024,
9140,
1063,
1002,
4118,
1027,
1002,
5227,
1011,
1028,
2131,
11368,
6806,
2094,
1006,
1007,
1025,
2065,
1006,
999,
1032,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Exceptions/Handler.php | Handler.prepareException | protected function prepareException(Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
} elseif ($e instanceof AuthorizationException) {
$e = new AccessDeniedHttpException($e->getMessage(), $e);
} elseif ($e instanceof TokenMismatchException) {
$e = new HttpException(419, $e->getMessage(), $e);
}
return $e;
} | php | protected function prepareException(Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
} elseif ($e instanceof AuthorizationException) {
$e = new AccessDeniedHttpException($e->getMessage(), $e);
} elseif ($e instanceof TokenMismatchException) {
$e = new HttpException(419, $e->getMessage(), $e);
}
return $e;
} | [
"protected",
"function",
"prepareException",
"(",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"ModelNotFoundException",
")",
"{",
"$",
"e",
"=",
"new",
"NotFoundHttpException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
... | Prepare exception for rendering.
@param \Exception $e
@return \Exception | [
"Prepare",
"exception",
"for",
"rendering",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Exceptions/Handler.php#L197-L208 | train | Prepare exception for the next call | [
30522,
5123,
3853,
7374,
10288,
24422,
1006,
6453,
1002,
1041,
1007,
1063,
2065,
1006,
1002,
1041,
6013,
11253,
2944,
17048,
14876,
8630,
10288,
24422,
1007,
1063,
1002,
1041,
1027,
2047,
2025,
14876,
8630,
11039,
25856,
10288,
24422,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreAdminHome/OptOutManager.php | OptOutManager.addJavaScript | public function addJavaScript($javascript, $inline = true)
{
$type = $inline ? 'inline' : 'external';
$this->javascripts[$type][] = $javascript;
} | php | public function addJavaScript($javascript, $inline = true)
{
$type = $inline ? 'inline' : 'external';
$this->javascripts[$type][] = $javascript;
} | [
"public",
"function",
"addJavaScript",
"(",
"$",
"javascript",
",",
"$",
"inline",
"=",
"true",
")",
"{",
"$",
"type",
"=",
"$",
"inline",
"?",
"'inline'",
":",
"'external'",
";",
"$",
"this",
"->",
"javascripts",
"[",
"$",
"type",
"]",
"[",
"]",
"="... | Add a javascript file|code into the OptOut View
Note: This method will not escape the inline javascript code!
@param string $javascript
@param bool $inline | [
"Add",
"a",
"javascript",
"file|code",
"into",
"the",
"OptOut",
"View",
"Note",
":",
"This",
"method",
"will",
"not",
"escape",
"the",
"inline",
"javascript",
"code!"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreAdminHome/OptOutManager.php#L65-L69 | train | Add JavaScript to the page | [
30522,
2270,
3853,
5587,
3900,
12044,
23235,
1006,
1002,
9262,
22483,
1010,
1002,
23881,
1027,
2995,
1007,
1063,
1002,
2828,
1027,
1002,
23881,
1029,
1005,
23881,
1005,
1024,
1005,
6327,
1005,
1025,
1002,
2023,
1011,
1028,
9262,
22483,
2015... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/API/Proxy.php | Proxy.setDocumentation | private function setDocumentation($rClass, $className)
{
// Doc comment
$doc = $rClass->getDocComment();
$doc = str_replace(" * " . PHP_EOL, "<br>", $doc);
// boldify the first line only if there is more than one line, otherwise too much bold
if (substr_count($doc, '<br>') > 1) {
$firstLineBreak = strpos($doc, "<br>");
$doc = "<div class='apiFirstLine'>" . substr($doc, 0, $firstLineBreak) . "</div>" . substr($doc, $firstLineBreak + strlen("<br>"));
}
$doc = preg_replace("/(@package)[a-z _A-Z]*/", "", $doc);
$doc = preg_replace("/(@method).*/", "", $doc);
$doc = str_replace(array("\t", "\n", "/**", "*/", " * ", " *", " ", "\t*", " * @package"), " ", $doc);
// replace 'foo' and `bar` and "foobar" with code blocks... much magic
$doc = preg_replace('/`(.*?)`/', '<code>$1</code>', $doc);
$this->metadataArray[$className]['__documentation'] = $doc;
} | php | private function setDocumentation($rClass, $className)
{
// Doc comment
$doc = $rClass->getDocComment();
$doc = str_replace(" * " . PHP_EOL, "<br>", $doc);
// boldify the first line only if there is more than one line, otherwise too much bold
if (substr_count($doc, '<br>') > 1) {
$firstLineBreak = strpos($doc, "<br>");
$doc = "<div class='apiFirstLine'>" . substr($doc, 0, $firstLineBreak) . "</div>" . substr($doc, $firstLineBreak + strlen("<br>"));
}
$doc = preg_replace("/(@package)[a-z _A-Z]*/", "", $doc);
$doc = preg_replace("/(@method).*/", "", $doc);
$doc = str_replace(array("\t", "\n", "/**", "*/", " * ", " *", " ", "\t*", " * @package"), " ", $doc);
// replace 'foo' and `bar` and "foobar" with code blocks... much magic
$doc = preg_replace('/`(.*?)`/', '<code>$1</code>', $doc);
$this->metadataArray[$className]['__documentation'] = $doc;
} | [
"private",
"function",
"setDocumentation",
"(",
"$",
"rClass",
",",
"$",
"className",
")",
"{",
"// Doc comment",
"$",
"doc",
"=",
"$",
"rClass",
"->",
"getDocComment",
"(",
")",
";",
"$",
"doc",
"=",
"str_replace",
"(",
"\" * \"",
".",
"PHP_EOL",
",",
"... | Will be displayed in the API page
@param ReflectionClass $rClass Instance of ReflectionClass
@param string $className Name of the class | [
"Will",
"be",
"displayed",
"in",
"the",
"API",
"page"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Proxy.php#L100-L118 | train | Set documentation for class | [
30522,
2797,
3853,
2275,
3527,
24894,
19304,
1006,
1002,
22110,
27102,
1010,
1002,
2465,
18442,
1007,
1063,
1013,
1013,
9986,
7615,
1002,
9986,
1027,
1002,
22110,
27102,
1011,
1028,
2131,
3527,
21408,
20058,
3372,
1006,
1007,
1025,
1002,
99... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Piwik.php | Piwik.redirectToModule | public static function redirectToModule($newModule, $newAction = '', $parameters = array())
{
$newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
Url::redirectToUrl($newUrl);
} | php | public static function redirectToModule($newModule, $newAction = '', $parameters = array())
{
$newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
Url::redirectToUrl($newUrl);
} | [
"public",
"static",
"function",
"redirectToModule",
"(",
"$",
"newModule",
",",
"$",
"newAction",
"=",
"''",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"newUrl",
"=",
"'index.php'",
".",
"Url",
"::",
"getCurrentQueryStringWithParametersModi... | Redirects the current request to a new module and action.
@param string $newModule The target module, eg, `'UserCountry'`.
@param string $newAction The target controller action, eg, `'index'`.
@param array $parameters The query parameter values to modify before redirecting.
@api | [
"Redirects",
"the",
"current",
"request",
"to",
"a",
"new",
"module",
"and",
"action",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L630-L637 | train | Redirects to module action | [
30522,
2270,
10763,
3853,
2417,
7442,
6593,
20389,
7716,
9307,
1006,
1002,
2047,
5302,
8566,
2571,
1010,
1002,
2047,
18908,
3258,
1027,
1005,
1005,
1010,
1002,
11709,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
2047,
30524,
14343,
3372,
4226,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Abstract.php | Zend_Mail_Storage_Abstract.seek | public function seek($pos)
{
if ($this->_iterationMax === null) {
$this->_iterationMax = $this->countMessages();
}
if ($pos > $this->_iterationMax) {
throw new OutOfBoundsException('this position does not exist');
}
$this->_iterationPos = $pos;
} | php | public function seek($pos)
{
if ($this->_iterationMax === null) {
$this->_iterationMax = $this->countMessages();
}
if ($pos > $this->_iterationMax) {
throw new OutOfBoundsException('this position does not exist');
}
$this->_iterationPos = $pos;
} | [
"public",
"function",
"seek",
"(",
"$",
"pos",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_iterationMax",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_iterationMax",
"=",
"$",
"this",
"->",
"countMessages",
"(",
")",
";",
"}",
"if",
"(",
"$",
"pos",... | SeekableIterator::seek()
@param int $pos
@return void
@throws OutOfBoundsException | [
"SeekableIterator",
"::",
"seek",
"()"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Abstract.php#L354-L364 | train | Seek to a specific position in the message array | [
30522,
2270,
3853,
6148,
1006,
1002,
13433,
2015,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
27758,
17848,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
27758,
17848,
1027,
1002,
2023,
1011,
1028,
4175,
7834,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Referrers/API.php | API.removeSubtableMetadata | private function removeSubtableMetadata($dataTable)
{
if ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $childTable) {
$this->removeSubtableMetadata($childTable);
}
} else {
foreach ($dataTable->getRows() as $row) {
$row->deleteMetadata('idsubdatatable_in_db');
}
}
} | php | private function removeSubtableMetadata($dataTable)
{
if ($dataTable instanceof DataTable\Map) {
foreach ($dataTable->getDataTables() as $childTable) {
$this->removeSubtableMetadata($childTable);
}
} else {
foreach ($dataTable->getRows() as $row) {
$row->deleteMetadata('idsubdatatable_in_db');
}
}
} | [
"private",
"function",
"removeSubtableMetadata",
"(",
"$",
"dataTable",
")",
"{",
"if",
"(",
"$",
"dataTable",
"instanceof",
"DataTable",
"\\",
"Map",
")",
"{",
"foreach",
"(",
"$",
"dataTable",
"->",
"getDataTables",
"(",
")",
"as",
"$",
"childTable",
")",
... | Removes idsubdatatable_in_db metadata from a DataTable. Used by Social tables since
they use fake subtable IDs.
@param DataTable $dataTable | [
"Removes",
"idsubdatatable_in_db",
"metadata",
"from",
"a",
"DataTable",
".",
"Used",
"by",
"Social",
"tables",
"since",
"they",
"use",
"fake",
"subtable",
"IDs",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/API.php#L542-L553 | train | Remove subtable metadata | [
30522,
2797,
3853,
20362,
12083,
10880,
11368,
8447,
2696,
1006,
1002,
2951,
10880,
1007,
1063,
2065,
1006,
1002,
2951,
10880,
6013,
11253,
2951,
10880,
1032,
4949,
1007,
1063,
18921,
6776,
1006,
1002,
2951,
10880,
1011,
1028,
2131,
2850,
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... |
octobercms/october | modules/system/console/ThemeUse.php | ThemeUse.handle | public function handle()
{
if (!$this->confirmToProceed('Change the active theme?')) {
return;
}
$newThemeName = $this->argument('name');
$newTheme = Theme::load($newThemeName);
if (!$newTheme->exists($newThemeName)) {
return $this->error(sprintf('The theme %s does not exist.', $newThemeName));
}
if ($newTheme->isActiveTheme()) {
return $this->error(sprintf('%s is already the active theme.', $newTheme->getId()));
}
$activeTheme = Theme::getActiveTheme();
$from = $activeTheme ? $activeTheme->getId() : 'nothing';
$this->info(sprintf('Switching theme from %s to %s', $from, $newTheme->getId()));
Theme::setActiveTheme($newThemeName);
} | php | public function handle()
{
if (!$this->confirmToProceed('Change the active theme?')) {
return;
}
$newThemeName = $this->argument('name');
$newTheme = Theme::load($newThemeName);
if (!$newTheme->exists($newThemeName)) {
return $this->error(sprintf('The theme %s does not exist.', $newThemeName));
}
if ($newTheme->isActiveTheme()) {
return $this->error(sprintf('%s is already the active theme.', $newTheme->getId()));
}
$activeTheme = Theme::getActiveTheme();
$from = $activeTheme ? $activeTheme->getId() : 'nothing';
$this->info(sprintf('Switching theme from %s to %s', $from, $newTheme->getId()));
Theme::setActiveTheme($newThemeName);
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"confirmToProceed",
"(",
"'Change the active theme?'",
")",
")",
"{",
"return",
";",
"}",
"$",
"newThemeName",
"=",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
";",
... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/console/ThemeUse.php#L36-L59 | train | Switches the active theme to the new one. | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
12210,
14399,
3217,
3401,
2098,
1006,
1005,
2689,
1996,
3161,
4323,
1029,
1005,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
25597,
29122,
8189,
4168,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.validateBoolean | public function validateBoolean($attribute, $value)
{
$acceptable = [true, false, 0, 1, '0', '1'];
return in_array($value, $acceptable, true);
} | php | public function validateBoolean($attribute, $value)
{
$acceptable = [true, false, 0, 1, '0', '1'];
return in_array($value, $acceptable, true);
} | [
"public",
"function",
"validateBoolean",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"acceptable",
"=",
"[",
"true",
",",
"false",
",",
"0",
",",
"1",
",",
"'0'",
",",
"'1'",
"]",
";",
"return",
"in_array",
"(",
"$",
"value",
",",
"$",... | Validate that an attribute is a boolean.
@param string $attribute
@param mixed $value
@return bool | [
"Validate",
"that",
"an",
"attribute",
"is",
"a",
"boolean",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L348-L353 | train | Validate that an attribute is a boolean value | [
30522,
2270,
3853,
9398,
3686,
5092,
9890,
2319,
1006,
1002,
17961,
1010,
1002,
3643,
1007,
1063,
1002,
11701,
1027,
1031,
2995,
1010,
6270,
1010,
1014,
1010,
1015,
1010,
1005,
1014,
1005,
1010,
1005,
1015,
1005,
1033,
1025,
2709,
1999,
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... |
z-song/laravel-admin | src/Form/EmbeddedForm.php | EmbeddedForm.prepare | public function prepare($input)
{
foreach ($input as $key => $record) {
$this->setFieldOriginalValue($key);
$input[$key] = $this->prepareValue($key, $record);
}
return $input;
} | php | public function prepare($input)
{
foreach ($input as $key => $record) {
$this->setFieldOriginalValue($key);
$input[$key] = $this->prepareValue($key, $record);
}
return $input;
} | [
"public",
"function",
"prepare",
"(",
"$",
"input",
")",
"{",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"record",
")",
"{",
"$",
"this",
"->",
"setFieldOriginalValue",
"(",
"$",
"key",
")",
";",
"$",
"input",
"[",
"$",
"key",
"]",
... | Prepare for insert or update.
@param array $input
@return mixed | [
"Prepare",
"for",
"insert",
"or",
"update",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/EmbeddedForm.php#L145-L153 | train | Prepare input array for saving to DB | [
30522,
2270,
3853,
7374,
1006,
1002,
7953,
1007,
1063,
18921,
6776,
1006,
1002,
7953,
2004,
1002,
3145,
1027,
1028,
1002,
2501,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
3790,
10050,
24965,
10175,
5657,
1006,
1002,
3145,
1007,
1025,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Filter.php | Filter.onFilterUpdate | public function onFilterUpdate()
{
$this->defineFilterScopes();
if (!$scope = post('scopeName')) {
return;
}
$scope = $this->getScope($scope);
switch ($scope->type) {
case 'group':
$active = $this->optionsFromAjax(post('options.active'));
$this->setScopeValue($scope, $active);
break;
case 'checkbox':
$checked = post('value') == 'true';
$this->setScopeValue($scope, $checked);
break;
case 'switch':
$value = post('value');
$this->setScopeValue($scope, $value);
break;
case 'date':
$dates = $this->datesFromAjax(post('options.dates'));
if (!empty($dates)) {
list($date) = $dates;
}
else {
$date = null;
}
$this->setScopeValue($scope, $date);
break;
case 'daterange':
$dates = $this->datesFromAjax(post('options.dates'));
if (!empty($dates)) {
list($after, $before) = $dates;
$dates = [$after, $before];
}
else {
$dates = null;
}
$this->setScopeValue($scope, $dates);
break;
case 'number':
$numbers = $this->numbersFromAjax(post('options.numbers'));
if (!empty($numbers)) {
list($number) = $numbers;
}
else {
$number = null;
}
$this->setScopeValue($scope, $number);
break;
case 'numberrange':
$numbers = $this->numbersFromAjax(post('options.numbers'));
if (!empty($numbers)) {
list($min, $max) = $numbers;
$numbers = [$min, $max];
}
else {
$numbers = null;
}
$this->setScopeValue($scope, $numbers);
break;
case 'text':
$values = post('options.value');
if ($values !== null && $values !== '') {
list($value) = $values;
}
else {
$value = null;
}
$this->setScopeValue($scope, $value);
break;
}
/*
* Trigger class event, merge results as viewable array
*/
$params = func_get_args();
$result = $this->fireEvent('filter.update', [$params]);
if ($result && is_array($result)) {
return call_user_func_array('array_merge', $result);
}
} | php | public function onFilterUpdate()
{
$this->defineFilterScopes();
if (!$scope = post('scopeName')) {
return;
}
$scope = $this->getScope($scope);
switch ($scope->type) {
case 'group':
$active = $this->optionsFromAjax(post('options.active'));
$this->setScopeValue($scope, $active);
break;
case 'checkbox':
$checked = post('value') == 'true';
$this->setScopeValue($scope, $checked);
break;
case 'switch':
$value = post('value');
$this->setScopeValue($scope, $value);
break;
case 'date':
$dates = $this->datesFromAjax(post('options.dates'));
if (!empty($dates)) {
list($date) = $dates;
}
else {
$date = null;
}
$this->setScopeValue($scope, $date);
break;
case 'daterange':
$dates = $this->datesFromAjax(post('options.dates'));
if (!empty($dates)) {
list($after, $before) = $dates;
$dates = [$after, $before];
}
else {
$dates = null;
}
$this->setScopeValue($scope, $dates);
break;
case 'number':
$numbers = $this->numbersFromAjax(post('options.numbers'));
if (!empty($numbers)) {
list($number) = $numbers;
}
else {
$number = null;
}
$this->setScopeValue($scope, $number);
break;
case 'numberrange':
$numbers = $this->numbersFromAjax(post('options.numbers'));
if (!empty($numbers)) {
list($min, $max) = $numbers;
$numbers = [$min, $max];
}
else {
$numbers = null;
}
$this->setScopeValue($scope, $numbers);
break;
case 'text':
$values = post('options.value');
if ($values !== null && $values !== '') {
list($value) = $values;
}
else {
$value = null;
}
$this->setScopeValue($scope, $value);
break;
}
/*
* Trigger class event, merge results as viewable array
*/
$params = func_get_args();
$result = $this->fireEvent('filter.update', [$params]);
if ($result && is_array($result)) {
return call_user_func_array('array_merge', $result);
}
} | [
"public",
"function",
"onFilterUpdate",
"(",
")",
"{",
"$",
"this",
"->",
"defineFilterScopes",
"(",
")",
";",
"if",
"(",
"!",
"$",
"scope",
"=",
"post",
"(",
"'scopeName'",
")",
")",
"{",
"return",
";",
"}",
"$",
"scope",
"=",
"$",
"this",
"->",
"... | Update a filter scope value.
@return array | [
"Update",
"a",
"filter",
"scope",
"value",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L181-L287 | train | Called when filter is updated | [
30522,
2270,
3853,
2006,
8873,
21928,
6279,
13701,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
9375,
8873,
21928,
26127,
2015,
1006,
1007,
1025,
2065,
1006,
999,
1002,
9531,
1027,
2695,
1006,
1005,
9531,
18442,
1005,
1007,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Route.php | Route.setRequirement | public function setRequirement($key, $regex)
{
$this->requirements[$key] = $this->sanitizeRequirement($key, $regex);
$this->compiled = null;
return $this;
} | php | public function setRequirement($key, $regex)
{
$this->requirements[$key] = $this->sanitizeRequirement($key, $regex);
$this->compiled = null;
return $this;
} | [
"public",
"function",
"setRequirement",
"(",
"$",
"key",
",",
"$",
"regex",
")",
"{",
"$",
"this",
"->",
"requirements",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"sanitizeRequirement",
"(",
"$",
"key",
",",
"$",
"regex",
")",
";",
"$",
"this",
... | Sets a requirement for the given key.
@param string $key The key
@param string $regex The regex
@return $this | [
"Sets",
"a",
"requirement",
"for",
"the",
"given",
"key",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Route.php#L504-L510 | train | Set a requirement for the current language | [
30522,
2270,
3853,
2275,
2890,
15549,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
19723,
10288,
1007,
1063,
1002,
2023,
1011,
1028,
5918,
1031,
1002,
3145,
1033,
1027,
1002,
2023,
1011,
1028,
2624,
25090,
6290,
2063,
15549,
28578,
4765,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Uri.php | Uri.convertUrl | public static function convertUrl(PageInterface $page, $url, $type = 'link', $absolute = false, $route_only = false)
{
$grav = Grav::instance();
$uri = $grav['uri'];
// Link processing should prepend language
$language = $grav['language'];
$language_append = '';
if ($type === 'link' && $language->enabled()) {
$language_append = $language->getLanguageURLPrefix();
}
// Handle Excerpt style $url array
$url_path = is_array($url) ? $url['path'] : $url;
$external = false;
$base = $grav['base_url_relative'];
$base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
$pages_dir = $grav['locator']->findResource('page://');
// if absolute and starts with a base_url move on
if (isset($url['scheme']) && Utils::startsWith($url['scheme'], 'http')) {
$external = true;
} elseif ($url_path === '' && isset($url['fragment'])) {
$external = true;
} elseif ($url_path === '/' || ($base_url !== '' && Utils::startsWith($url_path, $base_url))) {
$url_path = $base_url . $url_path;
} else {
// see if page is relative to this or absolute
if (Utils::startsWith($url_path, '/')) {
$normalized_url = Utils::normalizePath($base_url . $url_path);
$normalized_path = Utils::normalizePath($pages_dir . $url_path);
} else {
$page_route = ($page->home() && !empty($url_path)) ? $page->rawRoute() : $page->route();
$normalized_url = $base_url . Utils::normalizePath(rtrim($page_route, '/') . '/' . $url_path);
$normalized_path = Utils::normalizePath($page->path() . '/' . $url_path);
}
// special check to see if path checking is required.
$just_path = str_replace($normalized_url, '', $normalized_path);
if ($normalized_url === '/' || $just_path === $page->path()) {
$url_path = $normalized_url;
} else {
$url_bits = static::parseUrl($normalized_path);
$full_path = $url_bits['path'];
$raw_full_path = rawurldecode($full_path);
if (file_exists($raw_full_path)) {
$full_path = $raw_full_path;
} elseif (!file_exists($full_path)) {
$full_path = false;
}
if ($full_path) {
$path_info = pathinfo($full_path);
$page_path = $path_info['dirname'];
$filename = '';
if ($url_path === '..') {
$page_path = $full_path;
} else {
// save the filename if a file is part of the path
if (is_file($full_path)) {
if ($path_info['extension'] !== 'md') {
$filename = '/' . $path_info['basename'];
}
} else {
$page_path = $full_path;
}
}
// get page instances and try to find one that fits
$instances = $grav['pages']->instances();
if (isset($instances[$page_path])) {
/** @var PageInterface $target */
$target = $instances[$page_path];
$url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
$url_path = Uri::buildUrl($url_bits);
} else {
$url_path = $normalized_url;
}
} else {
$url_path = $normalized_url;
}
}
}
// handle absolute URLs
if (\is_array($url) && !$external && ($absolute === true || $grav['config']->get('system.absolute_urls', false))) {
$url['scheme'] = $uri->scheme(true);
$url['host'] = $uri->host();
$url['port'] = $uri->port(true);
// check if page exists for this route, and if so, check if it has SSL enabled
$pages = $grav['pages'];
$routes = $pages->routes();
// if this is an image, get the proper path
$url_bits = pathinfo($url_path);
if (isset($url_bits['extension'])) {
$target_path = $url_bits['dirname'];
} else {
$target_path = $url_path;
}
// strip base from this path
$target_path = str_replace($uri->rootUrl(), '', $target_path);
// set to / if root
if (empty($target_path)) {
$target_path = '/';
}
// look to see if this page exists and has ssl enabled
if (isset($routes[$target_path])) {
$target_page = $pages->get($routes[$target_path]);
if ($target_page) {
$ssl_enabled = $target_page->ssl();
if ($ssl_enabled !== null) {
if ($ssl_enabled) {
$url['scheme'] = 'https';
} else {
$url['scheme'] = 'http';
}
}
}
}
}
// Handle route only
if ($route_only) {
$url_path = str_replace(static::filterPath($base_url), '', $url_path);
}
// transform back to string/array as needed
if (is_array($url)) {
$url['path'] = $url_path;
} else {
$url = $url_path;
}
return $url;
} | php | public static function convertUrl(PageInterface $page, $url, $type = 'link', $absolute = false, $route_only = false)
{
$grav = Grav::instance();
$uri = $grav['uri'];
// Link processing should prepend language
$language = $grav['language'];
$language_append = '';
if ($type === 'link' && $language->enabled()) {
$language_append = $language->getLanguageURLPrefix();
}
// Handle Excerpt style $url array
$url_path = is_array($url) ? $url['path'] : $url;
$external = false;
$base = $grav['base_url_relative'];
$base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
$pages_dir = $grav['locator']->findResource('page://');
// if absolute and starts with a base_url move on
if (isset($url['scheme']) && Utils::startsWith($url['scheme'], 'http')) {
$external = true;
} elseif ($url_path === '' && isset($url['fragment'])) {
$external = true;
} elseif ($url_path === '/' || ($base_url !== '' && Utils::startsWith($url_path, $base_url))) {
$url_path = $base_url . $url_path;
} else {
// see if page is relative to this or absolute
if (Utils::startsWith($url_path, '/')) {
$normalized_url = Utils::normalizePath($base_url . $url_path);
$normalized_path = Utils::normalizePath($pages_dir . $url_path);
} else {
$page_route = ($page->home() && !empty($url_path)) ? $page->rawRoute() : $page->route();
$normalized_url = $base_url . Utils::normalizePath(rtrim($page_route, '/') . '/' . $url_path);
$normalized_path = Utils::normalizePath($page->path() . '/' . $url_path);
}
// special check to see if path checking is required.
$just_path = str_replace($normalized_url, '', $normalized_path);
if ($normalized_url === '/' || $just_path === $page->path()) {
$url_path = $normalized_url;
} else {
$url_bits = static::parseUrl($normalized_path);
$full_path = $url_bits['path'];
$raw_full_path = rawurldecode($full_path);
if (file_exists($raw_full_path)) {
$full_path = $raw_full_path;
} elseif (!file_exists($full_path)) {
$full_path = false;
}
if ($full_path) {
$path_info = pathinfo($full_path);
$page_path = $path_info['dirname'];
$filename = '';
if ($url_path === '..') {
$page_path = $full_path;
} else {
// save the filename if a file is part of the path
if (is_file($full_path)) {
if ($path_info['extension'] !== 'md') {
$filename = '/' . $path_info['basename'];
}
} else {
$page_path = $full_path;
}
}
// get page instances and try to find one that fits
$instances = $grav['pages']->instances();
if (isset($instances[$page_path])) {
/** @var PageInterface $target */
$target = $instances[$page_path];
$url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
$url_path = Uri::buildUrl($url_bits);
} else {
$url_path = $normalized_url;
}
} else {
$url_path = $normalized_url;
}
}
}
// handle absolute URLs
if (\is_array($url) && !$external && ($absolute === true || $grav['config']->get('system.absolute_urls', false))) {
$url['scheme'] = $uri->scheme(true);
$url['host'] = $uri->host();
$url['port'] = $uri->port(true);
// check if page exists for this route, and if so, check if it has SSL enabled
$pages = $grav['pages'];
$routes = $pages->routes();
// if this is an image, get the proper path
$url_bits = pathinfo($url_path);
if (isset($url_bits['extension'])) {
$target_path = $url_bits['dirname'];
} else {
$target_path = $url_path;
}
// strip base from this path
$target_path = str_replace($uri->rootUrl(), '', $target_path);
// set to / if root
if (empty($target_path)) {
$target_path = '/';
}
// look to see if this page exists and has ssl enabled
if (isset($routes[$target_path])) {
$target_page = $pages->get($routes[$target_path]);
if ($target_page) {
$ssl_enabled = $target_page->ssl();
if ($ssl_enabled !== null) {
if ($ssl_enabled) {
$url['scheme'] = 'https';
} else {
$url['scheme'] = 'http';
}
}
}
}
}
// Handle route only
if ($route_only) {
$url_path = str_replace(static::filterPath($base_url), '', $url_path);
}
// transform back to string/array as needed
if (is_array($url)) {
$url['path'] = $url_path;
} else {
$url = $url_path;
}
return $url;
} | [
"public",
"static",
"function",
"convertUrl",
"(",
"PageInterface",
"$",
"page",
",",
"$",
"url",
",",
"$",
"type",
"=",
"'link'",
",",
"$",
"absolute",
"=",
"false",
",",
"$",
"route_only",
"=",
"false",
")",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"in... | Converts links from absolute '/' or relative (../..) to a Grav friendly format
@param PageInterface $page the current page to use as reference
@param string|array $url the URL as it was written in the markdown
@param string $type the type of URL, image | link
@param bool $absolute if null, will use system default, if true will use absolute links internally
@param bool $route_only only return the route, not full URL path
@return string|array the more friendly formatted url | [
"Converts",
"links",
"from",
"absolute",
"/",
"or",
"relative",
"(",
"..",
"/",
"..",
")",
"to",
"a",
"Grav",
"friendly",
"format"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L745-L891 | train | Convert a URL to a page | [
30522,
2270,
10763,
3853,
10463,
3126,
2140,
1006,
3931,
18447,
2121,
12172,
1002,
3931,
1010,
1002,
24471,
2140,
1010,
1002,
2828,
1027,
1005,
4957,
1005,
1010,
1002,
7619,
1027,
6270,
1010,
1002,
2799,
1035,
2069,
1027,
6270,
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/Pagination/AbstractPaginator.php | AbstractPaginator.getUrlRange | public function getUrlRange($start, $end)
{
return collect(range($start, $end))->mapWithKeys(function ($page) {
return [$page => $this->url($page)];
})->all();
} | php | public function getUrlRange($start, $end)
{
return collect(range($start, $end))->mapWithKeys(function ($page) {
return [$page => $this->url($page)];
})->all();
} | [
"public",
"function",
"getUrlRange",
"(",
"$",
"start",
",",
"$",
"end",
")",
"{",
"return",
"collect",
"(",
"range",
"(",
"$",
"start",
",",
"$",
"end",
")",
")",
"->",
"mapWithKeys",
"(",
"function",
"(",
"$",
"page",
")",
"{",
"return",
"[",
"$"... | Create a range of pagination URLs.
@param int $start
@param int $end
@return array | [
"Create",
"a",
"range",
"of",
"pagination",
"URLs",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Pagination/AbstractPaginator.php#L147-L152 | train | Get Page Url Range | [
30522,
2270,
3853,
2131,
3126,
20974,
22043,
1006,
1002,
2707,
1010,
1002,
2203,
1007,
1063,
2709,
8145,
1006,
2846,
1006,
1002,
2707,
1010,
1002,
2203,
1007,
1007,
1011,
1028,
4949,
24415,
14839,
2015,
1006,
3853,
1006,
1002,
3931,
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/Show/Tools.php | Tools.render | public function render()
{
$output = $this->renderCustomTools($this->prepends);
foreach ($this->tools as $tool) {
$renderMethod = 'render'.ucfirst($tool);
$output .= $this->$renderMethod();
}
return $output.$this->renderCustomTools($this->appends);
} | php | public function render()
{
$output = $this->renderCustomTools($this->prepends);
foreach ($this->tools as $tool) {
$renderMethod = 'render'.ucfirst($tool);
$output .= $this->$renderMethod();
}
return $output.$this->renderCustomTools($this->appends);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"renderCustomTools",
"(",
"$",
"this",
"->",
"prepends",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"tools",
"as",
"$",
"tool",
")",
"{",
"$",
"renderMethod",
"="... | Render tools.
@return string | [
"Render",
"tools",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show/Tools.php#L314-L324 | train | Render the content of the page | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
6434,
1027,
1002,
2023,
1011,
1028,
17552,
7874,
20389,
3406,
27896,
1006,
1002,
2023,
1011,
1028,
17463,
10497,
2015,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
5906,
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... |
laravel/framework | src/Illuminate/Events/Dispatcher.php | Dispatcher.createQueuedHandlerCallable | protected function createQueuedHandlerCallable($class, $method)
{
return function () use ($class, $method) {
$arguments = array_map(function ($a) {
return is_object($a) ? clone $a : $a;
}, func_get_args());
if ($this->handlerWantsToBeQueued($class, $arguments)) {
$this->queueHandler($class, $method, $arguments);
}
};
} | php | protected function createQueuedHandlerCallable($class, $method)
{
return function () use ($class, $method) {
$arguments = array_map(function ($a) {
return is_object($a) ? clone $a : $a;
}, func_get_args());
if ($this->handlerWantsToBeQueued($class, $arguments)) {
$this->queueHandler($class, $method, $arguments);
}
};
} | [
"protected",
"function",
"createQueuedHandlerCallable",
"(",
"$",
"class",
",",
"$",
"method",
")",
"{",
"return",
"function",
"(",
")",
"use",
"(",
"$",
"class",
",",
"$",
"method",
")",
"{",
"$",
"arguments",
"=",
"array_map",
"(",
"function",
"(",
"$"... | Create a callable for putting an event handler on the queue.
@param string $class
@param string $method
@return \Closure | [
"Create",
"a",
"callable",
"for",
"putting",
"an",
"event",
"handler",
"on",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Events/Dispatcher.php#L423-L434 | train | Creates a callable that will be executed when a handler is asked to be queued. | [
30522,
5123,
3853,
3443,
4226,
5657,
17516,
4859,
3917,
9289,
20470,
2571,
1006,
1002,
2465,
1010,
1002,
4118,
1007,
1063,
2709,
3853,
1006,
1007,
2224,
1006,
1002,
2465,
1010,
1002,
4118,
1007,
1063,
1002,
9918,
1027,
9140,
1035,
4949,
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/Framework/File/Formatter/CsvFormatter.php | CsvFormatter.decode | public function decode($data, $delimiter = null): array
{
$delimiter = $delimiter ?? $this->getDelimiter();
$lines = preg_split('/\r\n|\r|\n/', $data);
if ($lines === false) {
throw new \RuntimeException('Decoding CSV failed');
}
// Get the field names
$header = str_getcsv(array_shift($lines), $delimiter);
// Get the data
$list = [];
foreach ($lines as $line) {
$list[] = array_combine($header, str_getcsv($line, $delimiter));
}
return $list;
} | php | public function decode($data, $delimiter = null): array
{
$delimiter = $delimiter ?? $this->getDelimiter();
$lines = preg_split('/\r\n|\r|\n/', $data);
if ($lines === false) {
throw new \RuntimeException('Decoding CSV failed');
}
// Get the field names
$header = str_getcsv(array_shift($lines), $delimiter);
// Get the data
$list = [];
foreach ($lines as $line) {
$list[] = array_combine($header, str_getcsv($line, $delimiter));
}
return $list;
} | [
"public",
"function",
"decode",
"(",
"$",
"data",
",",
"$",
"delimiter",
"=",
"null",
")",
":",
"array",
"{",
"$",
"delimiter",
"=",
"$",
"delimiter",
"??",
"$",
"this",
"->",
"getDelimiter",
"(",
")",
";",
"$",
"lines",
"=",
"preg_split",
"(",
"'/\\... | {@inheritdoc}
@see FileFormatterInterface::decode() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/File/Formatter/CsvFormatter.php#L70-L89 | train | Decode CSV data into array of array of terms | [
30522,
2270,
3853,
21933,
3207,
1006,
1002,
2951,
1010,
1002,
3972,
27605,
3334,
1027,
19701,
1007,
1024,
9140,
1063,
1002,
3972,
27605,
3334,
1027,
1002,
3972,
27605,
3334,
1029,
1029,
1002,
2023,
1011,
1028,
2131,
9247,
27605,
3334,
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/DataTable.php | DataTable.addRow | public function addRow(Row $row)
{
// if there is a upper limit on the number of allowed rows and the table is full,
// add the new row to the summary row
if ($this->maximumAllowedRows > 0
&& $this->getRowsCount() >= $this->maximumAllowedRows - 1
) {
if ($this->summaryRow === null) {
// create the summary row if necessary
$columns = array('label' => self::LABEL_SUMMARY_ROW) + $row->getColumns();
$this->addSummaryRow(new Row(array(Row::COLUMNS => $columns)));
} else {
$this->summaryRow->sumRow(
$row, $enableCopyMetadata = false, $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME));
}
return $this->summaryRow;
}
$this->rows[] = $row;
if (!$this->indexNotUpToDate
&& $this->rebuildIndexContinuously
) {
$label = $row->getColumn('label');
if ($label !== false) {
$this->rowsIndexByLabel[$label] = count($this->rows) - 1;
}
}
return $row;
} | php | public function addRow(Row $row)
{
// if there is a upper limit on the number of allowed rows and the table is full,
// add the new row to the summary row
if ($this->maximumAllowedRows > 0
&& $this->getRowsCount() >= $this->maximumAllowedRows - 1
) {
if ($this->summaryRow === null) {
// create the summary row if necessary
$columns = array('label' => self::LABEL_SUMMARY_ROW) + $row->getColumns();
$this->addSummaryRow(new Row(array(Row::COLUMNS => $columns)));
} else {
$this->summaryRow->sumRow(
$row, $enableCopyMetadata = false, $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME));
}
return $this->summaryRow;
}
$this->rows[] = $row;
if (!$this->indexNotUpToDate
&& $this->rebuildIndexContinuously
) {
$label = $row->getColumn('label');
if ($label !== false) {
$this->rowsIndexByLabel[$label] = count($this->rows) - 1;
}
}
return $row;
} | [
"public",
"function",
"addRow",
"(",
"Row",
"$",
"row",
")",
"{",
"// if there is a upper limit on the number of allowed rows and the table is full,",
"// add the new row to the summary row",
"if",
"(",
"$",
"this",
"->",
"maximumAllowedRows",
">",
"0",
"&&",
"$",
"this",
... | Adds a row to this table.
If {@link setMaximumAllowedRows()} was called and the current row count is
at the maximum, the new row will be summed to the summary row. If there is no summary row,
this row is set as the summary row.
@param Row $row
@return Row `$row` or the summary row if we're at the maximum number of rows. | [
"Adds",
"a",
"row",
"to",
"this",
"table",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L790-L819 | train | Add a new row to the table | [
30522,
2270,
3853,
5587,
10524,
1006,
5216,
1002,
5216,
1007,
1063,
1013,
1013,
2065,
2045,
2003,
1037,
3356,
5787,
2006,
1996,
2193,
1997,
3039,
10281,
1998,
1996,
2795,
2003,
2440,
1010,
1013,
1013,
5587,
1996,
2047,
5216,
2000,
1996,
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/Mime/Header/AbstractHeader.php | AbstractHeader.tokensToString | private function tokensToString(array $tokens): string
{
$lineCount = 0;
$headerLines = [];
$headerLines[] = $this->name.': ';
$currentLine = &$headerLines[$lineCount++];
// Build all tokens back into compliant header
foreach ($tokens as $i => $token) {
// Line longer than specified maximum or token was just a new line
if (("\r\n" === $token) ||
($i > 0 && \strlen($currentLine.$token) > $this->lineLength)
&& 0 < \strlen($currentLine)) {
$headerLines[] = '';
$currentLine = &$headerLines[$lineCount++];
}
// Append token to the line
if ("\r\n" !== $token) {
$currentLine .= $token;
}
}
// Implode with FWS (RFC 2822, 2.2.3)
return implode("\r\n", $headerLines);
} | php | private function tokensToString(array $tokens): string
{
$lineCount = 0;
$headerLines = [];
$headerLines[] = $this->name.': ';
$currentLine = &$headerLines[$lineCount++];
// Build all tokens back into compliant header
foreach ($tokens as $i => $token) {
// Line longer than specified maximum or token was just a new line
if (("\r\n" === $token) ||
($i > 0 && \strlen($currentLine.$token) > $this->lineLength)
&& 0 < \strlen($currentLine)) {
$headerLines[] = '';
$currentLine = &$headerLines[$lineCount++];
}
// Append token to the line
if ("\r\n" !== $token) {
$currentLine .= $token;
}
}
// Implode with FWS (RFC 2822, 2.2.3)
return implode("\r\n", $headerLines);
} | [
"private",
"function",
"tokensToString",
"(",
"array",
"$",
"tokens",
")",
":",
"string",
"{",
"$",
"lineCount",
"=",
"0",
";",
"$",
"headerLines",
"=",
"[",
"]",
";",
"$",
"headerLines",
"[",
"]",
"=",
"$",
"this",
"->",
"name",
".",
"': '",
";",
... | Takes an array of tokens which appear in the header and turns them into
an RFC 2822 compliant string, adding FWSP where needed.
@param string[] $tokens | [
"Takes",
"an",
"array",
"of",
"tokens",
"which",
"appear",
"in",
"the",
"header",
"and",
"turns",
"them",
"into",
"an",
"RFC",
"2822",
"compliant",
"string",
"adding",
"FWSP",
"where",
"needed",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/Header/AbstractHeader.php#L255-L280 | train | Converts the header tokens into a string | [
30522,
2797,
3853,
19204,
16033,
3367,
4892,
1006,
9140,
1002,
19204,
2015,
1007,
1024,
5164,
1063,
1002,
2240,
3597,
16671,
1027,
1014,
1025,
1002,
30524,
1011,
1028,
2171,
1012,
1005,
1024,
1005,
1025,
1002,
2783,
4179,
1027,
1004,
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/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.validateFilled | public function validateFilled($attribute, $value)
{
if (Arr::has($this->data, $attribute)) {
return $this->validateRequired($attribute, $value);
}
return true;
} | php | public function validateFilled($attribute, $value)
{
if (Arr::has($this->data, $attribute)) {
return $this->validateRequired($attribute, $value);
}
return true;
} | [
"public",
"function",
"validateFilled",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"if",
"(",
"Arr",
"::",
"has",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"attribute",
")",
")",
"{",
"return",
"$",
"this",
"->",
"validateRequired",
"(",
"$"... | Validate the given attribute is filled if it is present.
@param string $attribute
@param mixed $value
@return bool | [
"Validate",
"the",
"given",
"attribute",
"is",
"filled",
"if",
"it",
"is",
"present",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L865-L872 | train | ValidateFilled - Filled attribute | [
30522,
2270,
3853,
9398,
3686,
8873,
11001,
1006,
1002,
17961,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
12098,
2099,
1024,
1024,
2038,
1006,
1002,
2023,
1011,
1028,
2951,
1010,
1002,
17961,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php | InteractsWithPivotTable.attachUsingCustomClass | protected function attachUsingCustomClass($id, array $attributes)
{
$records = $this->formatAttachRecords(
$this->parseIds($id), $attributes
);
foreach ($records as $record) {
$this->newPivot($record, false)->save();
}
} | php | protected function attachUsingCustomClass($id, array $attributes)
{
$records = $this->formatAttachRecords(
$this->parseIds($id), $attributes
);
foreach ($records as $record) {
$this->newPivot($record, false)->save();
}
} | [
"protected",
"function",
"attachUsingCustomClass",
"(",
"$",
"id",
",",
"array",
"$",
"attributes",
")",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"formatAttachRecords",
"(",
"$",
"this",
"->",
"parseIds",
"(",
"$",
"id",
")",
",",
"$",
"attributes",
... | Attach a model to the parent using a custom class.
@param mixed $id
@param array $attributes
@return void | [
"Attach",
"a",
"model",
"to",
"the",
"parent",
"using",
"a",
"custom",
"class",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php#L261-L270 | train | Attaches the pivot records using a custom class. | [
30522,
5123,
3853,
22476,
18161,
7874,
20389,
26266,
1006,
1002,
8909,
1010,
9140,
1002,
12332,
1007,
1063,
1002,
2636,
1027,
1002,
2023,
1011,
1028,
4289,
19321,
6776,
2890,
27108,
5104,
1006,
1002,
2023,
1011,
1028,
11968,
20240,
5104,
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/Period/Month.php | Month.processOptimalSubperiods | protected function processOptimalSubperiods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate)
|| $startDate == $endDate
) {
$week = new Week($startDate);
$startOfWeek = $week->getDateStart();
$endOfWeek = $week->getDateEnd();
if ($endOfWeek->isLater($endDate)) {
$this->fillDayPeriods($startDate, $endDate);
} elseif ($startOfWeek == $startDate) {
$this->addSubperiod($week);
} else {
$this->fillDayPeriods($startDate, $endOfWeek);
}
$startDate = $endOfWeek->addDay(1);
}
} | php | protected function processOptimalSubperiods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate)
|| $startDate == $endDate
) {
$week = new Week($startDate);
$startOfWeek = $week->getDateStart();
$endOfWeek = $week->getDateEnd();
if ($endOfWeek->isLater($endDate)) {
$this->fillDayPeriods($startDate, $endDate);
} elseif ($startOfWeek == $startDate) {
$this->addSubperiod($week);
} else {
$this->fillDayPeriods($startDate, $endOfWeek);
}
$startDate = $endOfWeek->addDay(1);
}
} | [
"protected",
"function",
"processOptimalSubperiods",
"(",
"$",
"startDate",
",",
"$",
"endDate",
")",
"{",
"while",
"(",
"$",
"startDate",
"->",
"isEarlier",
"(",
"$",
"endDate",
")",
"||",
"$",
"startDate",
"==",
"$",
"endDate",
")",
"{",
"$",
"week",
"... | Determine which kind of period is best to use.
See Range.test.php
@param Date $startDate
@param Date $endDate | [
"Determine",
"which",
"kind",
"of",
"period",
"is",
"best",
"to",
"use",
".",
"See",
"Range",
".",
"test",
".",
"php"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Period/Month.php#L83-L102 | train | Process Optimal Subperiods | [
30522,
5123,
3853,
2832,
7361,
3775,
9067,
6342,
2497,
4842,
3695,
5104,
1006,
1002,
2707,
13701,
1010,
1002,
2203,
13701,
1007,
1063,
2096,
1006,
1002,
2707,
13701,
1011,
1028,
2003,
14644,
14355,
1006,
1002,
2203,
13701,
1007,
1064,
1064,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/WinCache.php | Zend_Cache_Backend_WinCache.getIds | public function getIds()
{
$res = array();
$array = wincache_ucache_info();
$records = $array['ucache_entries'];
foreach ($records as $record) {
$res[] = $record['key_name'];
}
return $res;
} | php | public function getIds()
{
$res = array();
$array = wincache_ucache_info();
$records = $array['ucache_entries'];
foreach ($records as $record) {
$res[] = $record['key_name'];
}
return $res;
} | [
"public",
"function",
"getIds",
"(",
")",
"{",
"$",
"res",
"=",
"array",
"(",
")",
";",
"$",
"array",
"=",
"wincache_ucache_info",
"(",
")",
";",
"$",
"records",
"=",
"$",
"array",
"[",
"'ucache_entries'",
"]",
";",
"foreach",
"(",
"$",
"records",
"a... | Return an array of stored cache ids
@return array array of stored cache ids (string) | [
"Return",
"an",
"array",
"of",
"stored",
"cache",
"ids"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/WinCache.php#L256-L265 | train | Get all the ids of all the usercache entries | [
30522,
2270,
3853,
2131,
9821,
1006,
1007,
1063,
1002,
24501,
1027,
9140,
1006,
1007,
1025,
1002,
9140,
1027,
2663,
3540,
5403,
1035,
15384,
15395,
1035,
18558,
1006,
1007,
1025,
1002,
2636,
1027,
1002,
9140,
1031,
1005,
15384,
15395,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/FormBuilder.php | FormBuilder.has | public function has($name)
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
return isset($this->unresolvedChildren[$name]) || isset($this->children[$name]);
} | php | public function has($name)
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
return isset($this->unresolvedChildren[$name]) || isset($this->children[$name]);
} | [
"public",
"function",
"has",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'",
")",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormBuilder.php#L137-L144 | train | Checks if a form has a child form with the given name. | [
30522,
2270,
3853,
2038,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5299,
1007,
1063,
5466,
2047,
2919,
11368,
6806,
16409,
24164,
2595,
24422,
1006,
1005,
2433,
8569,
23891,
2099,
4725,
3685,
2022,
11570,
4902,
2320,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DomCrawler/Crawler.php | Crawler.reduce | public function reduce(\Closure $closure)
{
$nodes = [];
foreach ($this->nodes as $i => $node) {
if (false !== $closure($this->createSubCrawler($node), $i)) {
$nodes[] = $node;
}
}
return $this->createSubCrawler($nodes);
} | php | public function reduce(\Closure $closure)
{
$nodes = [];
foreach ($this->nodes as $i => $node) {
if (false !== $closure($this->createSubCrawler($node), $i)) {
$nodes[] = $node;
}
}
return $this->createSubCrawler($nodes);
} | [
"public",
"function",
"reduce",
"(",
"\\",
"Closure",
"$",
"closure",
")",
"{",
"$",
"nodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"i",
"=>",
"$",
"node",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"closure",
... | Reduces the list of nodes by calling an anonymous function.
To remove a node from the list, the anonymous function must return false.
@param \Closure $closure An anonymous function
@return self | [
"Reduces",
"the",
"list",
"of",
"nodes",
"by",
"calling",
"an",
"anonymous",
"function",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/Crawler.php#L387-L397 | train | Reduce nodes to single node | [
30522,
2270,
3853,
5547,
1006,
1032,
8503,
1002,
8503,
1007,
1063,
1002,
14164,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
14164,
2004,
1002,
1045,
1027,
1028,
1002,
13045,
1007,
1063,
2065,
1006,
6270,
999,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpClient/ScopingHttpClient.php | ScopingHttpClient.stream | public function stream($responses, float $timeout = null): ResponseStreamInterface
{
return $this->client->stream($responses, $timeout);
} | php | public function stream($responses, float $timeout = null): ResponseStreamInterface
{
return $this->client->stream($responses, $timeout);
} | [
"public",
"function",
"stream",
"(",
"$",
"responses",
",",
"float",
"$",
"timeout",
"=",
"null",
")",
":",
"ResponseStreamInterface",
"{",
"return",
"$",
"this",
"->",
"client",
"->",
"stream",
"(",
"$",
"responses",
",",
"$",
"timeout",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/ScopingHttpClient.php#L87-L90 | train | Stream responses from the server | [
30522,
2270,
3853,
5460,
1006,
1002,
10960,
1010,
14257,
1002,
2051,
5833,
1027,
19701,
1007,
1024,
10960,
25379,
18447,
2121,
12172,
1063,
2709,
1002,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Process/Process.php | Process.isRunning | public function isRunning()
{
if (self::STATUS_STARTED !== $this->status) {
return false;
}
$this->updateStatus(false);
return $this->processInformation['running'];
} | php | public function isRunning()
{
if (self::STATUS_STARTED !== $this->status) {
return false;
}
$this->updateStatus(false);
return $this->processInformation['running'];
} | [
"public",
"function",
"isRunning",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"STATUS_STARTED",
"!==",
"$",
"this",
"->",
"status",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"updateStatus",
"(",
"false",
")",
";",
"return",
"$",
"this",
... | Checks if the process is currently running.
@return bool true if the process is currently running, false otherwise | [
"Checks",
"if",
"the",
"process",
"is",
"currently",
"running",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L845-L854 | train | Returns true if the process is currently running false if not. | [
30522,
2270,
3853,
2003,
15532,
5582,
1006,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
3570,
1035,
2318,
999,
1027,
1027,
1002,
2023,
1011,
1028,
3570,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
2023,
1011,
1028,
14409,
29336,
2271,
1006,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php | ServerStopCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
try {
$server = new WebServer($this->pidFileDirectory);
$server->stop($input->getOption('pidfile'));
$io->success('Stopped the web server.');
} catch (\Exception $e) {
$io->error($e->getMessage());
return 1;
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
try {
$server = new WebServer($this->pidFileDirectory);
$server->stop($input->getOption('pidfile'));
$io->success('Stopped the web server.');
} catch (\Exception $e) {
$io->error($e->getMessage());
return 1;
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
"instanceof",
"ConsoleOutputInterface",
"?",
"$",
"output",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebServerBundle/Command/ServerStopCommand.php#L62-L75 | train | Stop the web server | [
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,
6013,
11253,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.orHaving | public function orHaving($column, $operator = null, $value = null)
{
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
return $this->having($column, $operator, $value, 'or');
} | php | public function orHaving($column, $operator = null, $value = null)
{
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
return $this->having($column, $operator, $value, 'or');
} | [
"public",
"function",
"orHaving",
"(",
"$",
"column",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"[",
"$",
"value",
",",
"$",
"operator",
"]",
"=",
"$",
"this",
"->",
"prepareValueAndOperator",
"(",
"$",
"value",
","... | Add a "or having" clause to the query.
@param string $column
@param string|null $operator
@param string|null $value
@return \Illuminate\Database\Query\Builder|static | [
"Add",
"a",
"or",
"having",
"clause",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L1732-L1739 | train | Add a HAVING clause to the query. | [
30522,
2270,
3853,
2030,
3270,
6455,
1006,
1002,
5930,
1010,
1002,
6872,
1027,
19701,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
1031,
1002,
3643,
1010,
1002,
6872,
1033,
1027,
1002,
2023,
1011,
1028,
7374,
10175,
5657,
28574,
4842,
8844,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HasManyThrough.php | HasManyThrough.getRelationExistenceQueryForThroughSelfRelation | public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
{
$table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();
$query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());
if ($this->throughParentSoftDeletes()) {
$query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
}
return $query->select($columns)->whereColumn(
$parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
);
} | php | public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
{
$table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();
$query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());
if ($this->throughParentSoftDeletes()) {
$query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
}
return $query->select($columns)->whereColumn(
$parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
);
} | [
"public",
"function",
"getRelationExistenceQueryForThroughSelfRelation",
"(",
"Builder",
"$",
"query",
",",
"Builder",
"$",
"parentQuery",
",",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"throughParent",
"->",
"getTab... | Add the constraints for a relationship query on the same table as the through parent.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Builder $parentQuery
@param array|mixed $columns
@return \Illuminate\Database\Eloquent\Builder | [
"Add",
"the",
"constraints",
"for",
"a",
"relationship",
"query",
"on",
"the",
"same",
"table",
"as",
"the",
"through",
"parent",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php#L551-L564 | train | Get Query for relation existence for a throughSelfRelation | [
30522,
2270,
3853,
2131,
16570,
3370,
10288,
27870,
5897,
4226,
2854,
15628,
22494,
5603,
11246,
19699,
10581,
3508,
1006,
12508,
1002,
23032,
1010,
12508,
1002,
6687,
4226,
2854,
1010,
1002,
7753,
1027,
1031,
1005,
1008,
1005,
1033,
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/Field/File.php | File.prepare | public function prepare($file)
{
if (request()->has(static::FILE_DELETE_FLAG)) {
return $this->destroy();
}
$this->name = $this->getStoreName($file);
return $this->uploadAndDeleteOriginal($file);
} | php | public function prepare($file)
{
if (request()->has(static::FILE_DELETE_FLAG)) {
return $this->destroy();
}
$this->name = $this->getStoreName($file);
return $this->uploadAndDeleteOriginal($file);
} | [
"public",
"function",
"prepare",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"has",
"(",
"static",
"::",
"FILE_DELETE_FLAG",
")",
")",
"{",
"return",
"$",
"this",
"->",
"destroy",
"(",
")",
";",
"}",
"$",
"this",
"->",
"name",... | Prepare for saving.
@param UploadedFile|array $file
@return mixed|string | [
"Prepare",
"for",
"saving",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/File.php#L103-L112 | train | Prepare the store and upload the file | [
30522,
2270,
3853,
7374,
1006,
1002,
5371,
1007,
1063,
2065,
1006,
5227,
1006,
1007,
1011,
1028,
2038,
1006,
10763,
1024,
1024,
5371,
1035,
3972,
12870,
1035,
5210,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
6033,
1006,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php | SqlServerGrammar.wrapTable | public function wrapTable($table)
{
if ($table instanceof Blueprint && $table->temporary) {
$this->setTablePrefix('#');
}
return parent::wrapTable($table);
} | php | public function wrapTable($table)
{
if ($table instanceof Blueprint && $table->temporary) {
$this->setTablePrefix('#');
}
return parent::wrapTable($table);
} | [
"public",
"function",
"wrapTable",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"instanceof",
"Blueprint",
"&&",
"$",
"table",
"->",
"temporary",
")",
"{",
"$",
"this",
"->",
"setTablePrefix",
"(",
"'#'",
")",
";",
"}",
"return",
"parent",
"::... | Wrap a table in keyword identifiers.
@param \Illuminate\Database\Query\Expression|string $table
@return string | [
"Wrap",
"a",
"table",
"in",
"keyword",
"identifiers",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php#L819-L826 | train | Wrap table in a temporary table | [
30522,
2270,
3853,
10236,
10880,
1006,
1002,
2795,
1007,
1063,
2065,
1006,
1002,
2795,
6013,
11253,
2630,
16550,
1004,
1004,
1002,
2795,
1011,
1028,
5741,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
10880,
28139,
8873,
2595,
1006,
1005,
1001,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Adapter/PDFLib.php | PDFLib._close | protected function _close()
{
$this->_place_objects();
// Close all pages
$this->_pdf->suspend_page("");
for ($p = 1; $p <= $this->_page_count; $p++) {
$this->_pdf->resume_page("pagenumber=$p");
$this->_pdf->end_page_ext("");
}
$this->_pdf->end_document("");
} | php | protected function _close()
{
$this->_place_objects();
// Close all pages
$this->_pdf->suspend_page("");
for ($p = 1; $p <= $this->_page_count; $p++) {
$this->_pdf->resume_page("pagenumber=$p");
$this->_pdf->end_page_ext("");
}
$this->_pdf->end_document("");
} | [
"protected",
"function",
"_close",
"(",
")",
"{",
"$",
"this",
"->",
"_place_objects",
"(",
")",
";",
"// Close all pages",
"$",
"this",
"->",
"_pdf",
"->",
"suspend_page",
"(",
"\"\"",
")",
";",
"for",
"(",
"$",
"p",
"=",
"1",
";",
"$",
"p",
"<=",
... | Close the pdf | [
"Close",
"the",
"pdf"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/PDFLib.php#L288-L300 | train | Close all pages and document | [
30522,
5123,
3853,
1035,
2485,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
2173,
1035,
5200,
1006,
1007,
1025,
1013,
1013,
2485,
2035,
5530,
1002,
2023,
1011,
1028,
1035,
11135,
1011,
1028,
28324,
1035,
3931,
1006,
1000,
1000,
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/Console/Migrations/MigrateMakeCommand.php | MigrateMakeCommand.handle | public function handle()
{
// It's possible for the developer to specify the tables to modify in this
// schema operation. The developer may also specify if this table needs
// to be freshly created so we can create the appropriate migrations.
$name = Str::snake(trim($this->input->getArgument('name')));
$table = $this->input->getOption('table');
$create = $this->input->getOption('create') ?: false;
// If no table was given as an option but a create option is given then we
// will use the "create" option as the table name. This allows the devs
// to pass a table name into this option as a short-cut for creating.
if (! $table && is_string($create)) {
$table = $create;
$create = true;
}
// Next, we will attempt to guess the table name if this the migration has
// "create" in the name. This will allow us to provide a convenient way
// of creating migrations that create new tables for the application.
if (! $table) {
[$table, $create] = TableGuesser::guess($name);
}
// Now we are ready to write the migration out to disk. Once we've written
// the migration out, we will dump-autoload for the entire framework to
// make sure that the migrations are registered by the class loaders.
$this->writeMigration($name, $table, $create);
$this->composer->dumpAutoloads();
} | php | public function handle()
{
// It's possible for the developer to specify the tables to modify in this
// schema operation. The developer may also specify if this table needs
// to be freshly created so we can create the appropriate migrations.
$name = Str::snake(trim($this->input->getArgument('name')));
$table = $this->input->getOption('table');
$create = $this->input->getOption('create') ?: false;
// If no table was given as an option but a create option is given then we
// will use the "create" option as the table name. This allows the devs
// to pass a table name into this option as a short-cut for creating.
if (! $table && is_string($create)) {
$table = $create;
$create = true;
}
// Next, we will attempt to guess the table name if this the migration has
// "create" in the name. This will allow us to provide a convenient way
// of creating migrations that create new tables for the application.
if (! $table) {
[$table, $create] = TableGuesser::guess($name);
}
// Now we are ready to write the migration out to disk. Once we've written
// the migration out, we will dump-autoload for the entire framework to
// make sure that the migrations are registered by the class loaders.
$this->writeMigration($name, $table, $create);
$this->composer->dumpAutoloads();
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"// It's possible for the developer to specify the tables to modify in this",
"// schema operation. The developer may also specify if this table needs",
"// to be freshly created so we can create the appropriate migrations.",
"$",
"name",
"=",
"... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php#L63-L96 | train | Handle the migration | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1013,
1013,
2009,
1005,
1055,
2825,
2005,
1996,
9722,
2000,
20648,
1996,
7251,
2000,
19933,
1999,
2023,
1013,
1013,
8040,
28433,
3169,
1012,
1996,
9722,
2089,
2036,
20648,
2065,
2023,
2795,
3791,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DomCrawler/FormFieldRegistry.php | FormFieldRegistry.create | private static function create($base, array $values)
{
$registry = new static();
$registry->base = $base;
$registry->fields = $values;
return $registry;
} | php | private static function create($base, array $values)
{
$registry = new static();
$registry->base = $base;
$registry->fields = $values;
return $registry;
} | [
"private",
"static",
"function",
"create",
"(",
"$",
"base",
",",
"array",
"$",
"values",
")",
"{",
"$",
"registry",
"=",
"new",
"static",
"(",
")",
";",
"$",
"registry",
"->",
"base",
"=",
"$",
"base",
";",
"$",
"registry",
"->",
"fields",
"=",
"$... | Creates an instance of the class.
This function is made private because it allows overriding the $base and
the $values properties without any type checking.
@param string $base The fully qualified name of the base field
@param array $values The values of the fields
@return static | [
"Creates",
"an",
"instance",
"of",
"the",
"class",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/FormFieldRegistry.php#L154-L161 | train | Create a new instance of the class | [
30522,
2797,
10763,
3853,
3443,
1006,
1002,
2918,
1010,
9140,
1002,
5300,
1007,
1063,
1002,
15584,
1027,
2047,
10763,
1006,
1007,
1025,
1002,
15584,
1011,
1028,
2918,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Filter/Pattern.php | Pattern.filter | public function filter($table)
{
foreach ($table->getRows() as $key => $row) {
//instead search must handle
// - negative search with -piwik
// - exact match with ""
// see (?!pattern) A subexpression that performs a negative lookahead search, which matches the search string at any point where a string not matching pattern begins.
$value = $row->getColumn($this->columnToFilter);
if ($value === false) {
$value = $row->getMetadata($this->columnToFilter);
}
if (!self::match($this->patternToSearchQuoted, $value, $this->invertedMatch)) {
$table->deleteRow($key);
}
}
} | php | public function filter($table)
{
foreach ($table->getRows() as $key => $row) {
//instead search must handle
// - negative search with -piwik
// - exact match with ""
// see (?!pattern) A subexpression that performs a negative lookahead search, which matches the search string at any point where a string not matching pattern begins.
$value = $row->getColumn($this->columnToFilter);
if ($value === false) {
$value = $row->getMetadata($this->columnToFilter);
}
if (!self::match($this->patternToSearchQuoted, $value, $this->invertedMatch)) {
$table->deleteRow($key);
}
}
} | [
"public",
"function",
"filter",
"(",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"getRows",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"//instead search must handle",
"// - negative search with -piwik",
"// - exact match with \"\"",
... | See {@link Pattern}.
@param DataTable $table | [
"See",
"{",
"@link",
"Pattern",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/Pattern.php#L83-L98 | train | Filter the table | [
30522,
2270,
3853,
11307,
1006,
1002,
2795,
1007,
1063,
18921,
6776,
1006,
1002,
2795,
1011,
1028,
2131,
10524,
2015,
1006,
1007,
2004,
1002,
3145,
1027,
1028,
1002,
5216,
1007,
1063,
1013,
1013,
2612,
3945,
2442,
5047,
1013,
1013,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php | TransformsRequest.clean | protected function clean($request)
{
$this->cleanParameterBag($request->query);
if ($request->isJson()) {
$this->cleanParameterBag($request->json());
} elseif ($request->request !== $request->query) {
$this->cleanParameterBag($request->request);
}
} | php | protected function clean($request)
{
$this->cleanParameterBag($request->query);
if ($request->isJson()) {
$this->cleanParameterBag($request->json());
} elseif ($request->request !== $request->query) {
$this->cleanParameterBag($request->request);
}
} | [
"protected",
"function",
"clean",
"(",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"cleanParameterBag",
"(",
"$",
"request",
"->",
"query",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isJson",
"(",
")",
")",
"{",
"$",
"this",
"->",
"cleanParameterBag"... | Clean the request's data.
@param \Illuminate\Http\Request $request
@return void | [
"Clean",
"the",
"request",
"s",
"data",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php#L30-L39 | train | Clean the request object | [
30522,
5123,
3853,
4550,
1006,
1002,
5227,
1007,
1063,
1002,
2023,
1011,
1028,
4550,
28689,
22828,
16078,
1006,
1002,
5227,
1011,
1028,
23032,
1007,
1025,
2065,
1006,
1002,
5227,
1011,
1028,
2003,
22578,
2239,
1006,
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 | core/Piwik.php | Piwik.secureDiv | public static function secureDiv($i1, $i2)
{
if (is_numeric($i1) && is_numeric($i2) && floatval($i2) != 0) {
return $i1 / $i2;
}
return 0;
} | php | public static function secureDiv($i1, $i2)
{
if (is_numeric($i1) && is_numeric($i2) && floatval($i2) != 0) {
return $i1 / $i2;
}
return 0;
} | [
"public",
"static",
"function",
"secureDiv",
"(",
"$",
"i1",
",",
"$",
"i2",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"i1",
")",
"&&",
"is_numeric",
"(",
"$",
"i2",
")",
"&&",
"floatval",
"(",
"$",
"i2",
")",
"!=",
"0",
")",
"{",
"return",
... | Computes the division of i1 by i2. If either i1 or i2 are not number, or if i2 has a value of zero
we return 0 to avoid the division by zero.
@param number $i1
@param number $i2
@return number The result of the division or zero | [
"Computes",
"the",
"division",
"of",
"i1",
"by",
"i2",
".",
"If",
"either",
"i1",
"or",
"i2",
"are",
"not",
"number",
"or",
"if",
"i2",
"has",
"a",
"value",
"of",
"zero",
"we",
"return",
"0",
"to",
"avoid",
"the",
"division",
"by",
"zero",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L104-L110 | train | Safely divides two numbers | [
30522,
2270,
10763,
3853,
7119,
12848,
1006,
1002,
1045,
2487,
1010,
1002,
1045,
2475,
1007,
1063,
2065,
1006,
2003,
1035,
16371,
25531,
1006,
1002,
1045,
2487,
1007,
1004,
1004,
2003,
1035,
16371,
25531,
1006,
1002,
1045,
2475,
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... |
symfony/symfony | src/Symfony/Component/Debug/ErrorHandler.php | ErrorHandler.handleFatalError | public static function handleFatalError(array $error = null)
{
if (null === self::$reservedMemory) {
return;
}
$handler = self::$reservedMemory = null;
$handlers = [];
$previousHandler = null;
$sameHandlerLimit = 10;
while (!\is_array($handler) || !$handler[0] instanceof self) {
$handler = set_exception_handler('var_dump');
restore_exception_handler();
if (!$handler) {
break;
}
restore_exception_handler();
if ($handler !== $previousHandler) {
array_unshift($handlers, $handler);
$previousHandler = $handler;
} elseif (0 === --$sameHandlerLimit) {
$handler = null;
break;
}
}
foreach ($handlers as $h) {
set_exception_handler($h);
}
if (!$handler) {
return;
}
if ($handler !== $h) {
$handler[0]->setExceptionHandler($h);
}
$handler = $handler[0];
$handlers = [];
if ($exit = null === $error) {
$error = error_get_last();
}
if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
// Let's not throw anymore but keep logging
$handler->throwAt(0, true);
$trace = isset($error['backtrace']) ? $error['backtrace'] : null;
if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
$exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
} else {
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
}
} else {
$exception = null;
}
try {
if (null !== $exception) {
self::$exitCode = 255;
$handler->handleException($exception, $error);
}
} catch (FatalErrorException $e) {
// Ignore this re-throw
}
if ($exit && self::$exitCode) {
$exitCode = self::$exitCode;
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
}
} | php | public static function handleFatalError(array $error = null)
{
if (null === self::$reservedMemory) {
return;
}
$handler = self::$reservedMemory = null;
$handlers = [];
$previousHandler = null;
$sameHandlerLimit = 10;
while (!\is_array($handler) || !$handler[0] instanceof self) {
$handler = set_exception_handler('var_dump');
restore_exception_handler();
if (!$handler) {
break;
}
restore_exception_handler();
if ($handler !== $previousHandler) {
array_unshift($handlers, $handler);
$previousHandler = $handler;
} elseif (0 === --$sameHandlerLimit) {
$handler = null;
break;
}
}
foreach ($handlers as $h) {
set_exception_handler($h);
}
if (!$handler) {
return;
}
if ($handler !== $h) {
$handler[0]->setExceptionHandler($h);
}
$handler = $handler[0];
$handlers = [];
if ($exit = null === $error) {
$error = error_get_last();
}
if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
// Let's not throw anymore but keep logging
$handler->throwAt(0, true);
$trace = isset($error['backtrace']) ? $error['backtrace'] : null;
if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
$exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
} else {
$exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
}
} else {
$exception = null;
}
try {
if (null !== $exception) {
self::$exitCode = 255;
$handler->handleException($exception, $error);
}
} catch (FatalErrorException $e) {
// Ignore this re-throw
}
if ($exit && self::$exitCode) {
$exitCode = self::$exitCode;
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
}
} | [
"public",
"static",
"function",
"handleFatalError",
"(",
"array",
"$",
"error",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"reservedMemory",
")",
"{",
"return",
";",
"}",
"$",
"handler",
"=",
"self",
"::",
"$",
"reservedMemory",
... | Shutdown registered function for handling PHP fatal errors.
@param array $error An array as returned by error_get_last()
@internal | [
"Shutdown",
"registered",
"function",
"for",
"handling",
"PHP",
"fatal",
"errors",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Debug/ErrorHandler.php#L593-L664 | train | Handles fatal errors | [
30522,
2270,
10763,
3853,
5047,
27753,
9453,
18933,
2099,
1006,
9140,
1002,
7561,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
2969,
1024,
1024,
1002,
9235,
4168,
5302,
2854,
1007,
1063,
2709,
1025,
1065,
1002,
28213,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/MediaLibrary.php | MediaLibrary.filterItemList | protected function filterItemList(&$itemList, $filter)
{
if (!$filter)
return;
$result = [];
foreach ($itemList as $item) {
if ($item->getFileType() == $filter) {
$result[] = $item;
}
}
$itemList = $result;
} | php | protected function filterItemList(&$itemList, $filter)
{
if (!$filter)
return;
$result = [];
foreach ($itemList as $item) {
if ($item->getFileType() == $filter) {
$result[] = $item;
}
}
$itemList = $result;
} | [
"protected",
"function",
"filterItemList",
"(",
"&",
"$",
"itemList",
",",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"$",
"filter",
")",
"return",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"itemList",
"as",
"$",
"item",
")",
"{",
... | Filters item list by file type.
@param array $itemList Specifies the item list to sort.
@param string $filter Determines the document type filtering preference.
Supported values are 'image', 'video', 'audio', 'document' (see FILE_TYPE_XXX constants of MediaLibraryItem class). | [
"Filters",
"item",
"list",
"by",
"file",
"type",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L736-L749 | train | Filter item list by file type | [
30522,
5123,
3853,
11307,
4221,
19968,
2923,
1006,
1004,
1002,
8875,
9863,
1010,
1002,
11307,
1007,
1063,
2065,
1006,
999,
1002,
11307,
1007,
2709,
1025,
1002,
2765,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
8875,
9863,
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/Bundle/WebProfilerBundle/Controller/ProfilerController.php | ProfilerController.toolbarAction | public function toolbarAction(Request $request, $token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
}
if ($request->hasSession() && ($session = $request->getSession()) && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
if ('empty' === $token || null === $token) {
return new Response('', 200, ['Content-Type' => 'text/html']);
}
$this->profiler->disable();
if (!$profile = $this->profiler->loadProfile($token)) {
return new Response('', 404, ['Content-Type' => 'text/html']);
}
$url = null;
try {
$url = $this->generator->generate('_profiler', ['token' => $token]);
} catch (\Exception $e) {
// the profiler is not enabled
}
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', [
'request' => $request,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getNames($profile),
'profiler_url' => $url,
'token' => $token,
'profiler_markup_version' => 2, // 1 = original toolbar, 2 = Symfony 2.8+ toolbar
]);
} | php | public function toolbarAction(Request $request, $token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
}
if ($request->hasSession() && ($session = $request->getSession()) && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
if ('empty' === $token || null === $token) {
return new Response('', 200, ['Content-Type' => 'text/html']);
}
$this->profiler->disable();
if (!$profile = $this->profiler->loadProfile($token)) {
return new Response('', 404, ['Content-Type' => 'text/html']);
}
$url = null;
try {
$url = $this->generator->generate('_profiler', ['token' => $token]);
} catch (\Exception $e) {
// the profiler is not enabled
}
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', [
'request' => $request,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getNames($profile),
'profiler_url' => $url,
'token' => $token,
'profiler_markup_version' => 2, // 1 = original toolbar, 2 = Symfony 2.8+ toolbar
]);
} | [
"public",
"function",
"toolbarAction",
"(",
"Request",
"$",
"request",
",",
"$",
"token",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"profiler",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The profiler must be enabled.'",
")",
";",
... | Renders the Web Debug Toolbar.
@param Request $request The current HTTP Request
@param string $token The profiler token
@return Response A Response instance
@throws NotFoundHttpException | [
"Renders",
"the",
"Web",
"Debug",
"Toolbar",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php#L118-L154 | train | Renders the profiler toolbar | [
30522,
2270,
3853,
6994,
20709,
7542,
1006,
5227,
1002,
5227,
1010,
1002,
19204,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
6337,
2099,
1007,
1063,
5466,
2047,
2025,
14876,
8630,
11039,
25856,
10288,
24422,
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/HttpClient/HttpClientTrait.php | HttpClientTrait.normalizeHeaders | private static function normalizeHeaders(array $headers): array
{
$normalizedHeaders = [];
foreach ($headers as $name => $values) {
if (\is_int($name)) {
[$name, $values] = explode(':', $values, 2);
$values = [ltrim($values)];
} elseif (!\is_iterable($values)) {
$values = (array) $values;
}
$normalizedHeaders[$name = strtolower($name)] = [];
foreach ($values as $value) {
$normalizedHeaders[$name][] = $value;
}
}
return $normalizedHeaders;
} | php | private static function normalizeHeaders(array $headers): array
{
$normalizedHeaders = [];
foreach ($headers as $name => $values) {
if (\is_int($name)) {
[$name, $values] = explode(':', $values, 2);
$values = [ltrim($values)];
} elseif (!\is_iterable($values)) {
$values = (array) $values;
}
$normalizedHeaders[$name = strtolower($name)] = [];
foreach ($values as $value) {
$normalizedHeaders[$name][] = $value;
}
}
return $normalizedHeaders;
} | [
"private",
"static",
"function",
"normalizeHeaders",
"(",
"array",
"$",
"headers",
")",
":",
"array",
"{",
"$",
"normalizedHeaders",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"\\",
... | Normalizes headers by putting their names as lowercased keys.
@return string[][] | [
"Normalizes",
"headers",
"by",
"putting",
"their",
"names",
"as",
"lowercased",
"keys",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/HttpClientTrait.php#L195-L215 | train | Normalize the headers array | [
30522,
2797,
10763,
3853,
3671,
4697,
4974,
2545,
1006,
9140,
1002,
20346,
2015,
1007,
1024,
9140,
1063,
1002,
3671,
3550,
4974,
2545,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
20346,
2015,
2004,
1002,
2171,
1027,
1028,
1002,
5300,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Nonce.php | Nonce.verifyNonce | public static function verifyNonce($id, $cnonce)
{
$ns = new SessionNamespace($id);
$nonce = $ns->nonce;
// validate token
if (empty($cnonce) || $cnonce !== $nonce) {
return false;
}
// validate referrer
$referrer = Url::getReferrer();
if (!empty($referrer) && !Url::isLocalUrl($referrer)) {
return false;
}
// validate origin
$origin = self::getOrigin();
if (!empty($origin) &&
($origin == 'null'
|| !in_array($origin, self::getAcceptableOrigins()))
) {
return false;
}
return true;
} | php | public static function verifyNonce($id, $cnonce)
{
$ns = new SessionNamespace($id);
$nonce = $ns->nonce;
// validate token
if (empty($cnonce) || $cnonce !== $nonce) {
return false;
}
// validate referrer
$referrer = Url::getReferrer();
if (!empty($referrer) && !Url::isLocalUrl($referrer)) {
return false;
}
// validate origin
$origin = self::getOrigin();
if (!empty($origin) &&
($origin == 'null'
|| !in_array($origin, self::getAcceptableOrigins()))
) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"verifyNonce",
"(",
"$",
"id",
",",
"$",
"cnonce",
")",
"{",
"$",
"ns",
"=",
"new",
"SessionNamespace",
"(",
"$",
"id",
")",
";",
"$",
"nonce",
"=",
"$",
"ns",
"->",
"nonce",
";",
"// validate token",
"if",
"(",
"empty... | Returns if a nonce is valid and comes from a valid request.
A nonce is valid if it matches the current nonce and if the current nonce
has not expired.
The request is valid if the referrer is a local URL (see {@link Url::isLocalUrl()})
and if the HTTP origin is valid (see {@link getAcceptableOrigins()}).
@param string $id The nonce's unique ID. See {@link getNonce()}.
@param string $cnonce Nonce sent from client.
@return bool `true` if valid; `false` otherwise. | [
"Returns",
"if",
"a",
"nonce",
"is",
"valid",
"and",
"comes",
"from",
"a",
"valid",
"request",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Nonce.php#L70-L96 | train | verifyNonce - Verify that the nonce is valid | [
30522,
2270,
10763,
3853,
20410,
8540,
3401,
1006,
1002,
8909,
1010,
1002,
27166,
2239,
3401,
1007,
1063,
1002,
24978,
1027,
2047,
5219,
18442,
23058,
1006,
1002,
8909,
1007,
1025,
1002,
2512,
3401,
1027,
1002,
24978,
1011,
1028,
2512,
3401... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/PluginManager.php | PluginManager.loadDisabled | protected function loadDisabled()
{
$path = $this->metaFile;
if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
foreach ($configDisabled as $disabled) {
$this->disabledPlugins[$disabled] = true;
}
}
if (File::exists($path)) {
$disabled = json_decode(File::get($path), true) ?: [];
$this->disabledPlugins = array_merge($this->disabledPlugins, $disabled);
}
else {
$this->populateDisabledPluginsFromDb();
$this->writeDisabled();
}
} | php | protected function loadDisabled()
{
$path = $this->metaFile;
if (($configDisabled = Config::get('cms.disablePlugins')) && is_array($configDisabled)) {
foreach ($configDisabled as $disabled) {
$this->disabledPlugins[$disabled] = true;
}
}
if (File::exists($path)) {
$disabled = json_decode(File::get($path), true) ?: [];
$this->disabledPlugins = array_merge($this->disabledPlugins, $disabled);
}
else {
$this->populateDisabledPluginsFromDb();
$this->writeDisabled();
}
} | [
"protected",
"function",
"loadDisabled",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"metaFile",
";",
"if",
"(",
"(",
"$",
"configDisabled",
"=",
"Config",
"::",
"get",
"(",
"'cms.disablePlugins'",
")",
")",
"&&",
"is_array",
"(",
"$",
"configDis... | Loads all disables plugins from the meta file. | [
"Loads",
"all",
"disables",
"plugins",
"from",
"the",
"meta",
"file",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/PluginManager.php#L492-L510 | train | Load disabled plugins from meta file | [
30522,
5123,
3853,
7170,
10521,
3085,
2094,
1006,
1007,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
18804,
8873,
2571,
1025,
2065,
1006,
1006,
1002,
9530,
8873,
2290,
10521,
3085,
2094,
1027,
9530,
8873,
2290,
1024,
1024,
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... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.onLoadSetup | public function onLoadSetup()
{
$this->vars['columns'] = $this->getSetupListColumns();
$this->vars['perPageOptions'] = $this->getSetupPerPageOptions();
$this->vars['recordsPerPage'] = $this->recordsPerPage;
return $this->makePartial('setup_form');
} | php | public function onLoadSetup()
{
$this->vars['columns'] = $this->getSetupListColumns();
$this->vars['perPageOptions'] = $this->getSetupPerPageOptions();
$this->vars['recordsPerPage'] = $this->recordsPerPage;
return $this->makePartial('setup_form');
} | [
"public",
"function",
"onLoadSetup",
"(",
")",
"{",
"$",
"this",
"->",
"vars",
"[",
"'columns'",
"]",
"=",
"$",
"this",
"->",
"getSetupListColumns",
"(",
")",
";",
"$",
"this",
"->",
"vars",
"[",
"'perPageOptions'",
"]",
"=",
"$",
"this",
"->",
"getSet... | Event handler to display the list set up. | [
"Event",
"handler",
"to",
"display",
"the",
"list",
"set",
"up",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1574-L1580 | train | Load setup page | [
30522,
2270,
3853,
2006,
11066,
13462,
6279,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
13075,
2015,
1031,
1005,
7753,
1005,
1033,
1027,
1002,
2023,
1011,
1028,
4152,
3388,
6279,
9863,
25778,
2819,
3619,
1006,
1007,
1025,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ImageMedium.php | ImageMedium.sourceParsedownElement | public function sourceParsedownElement(array $attributes, $reset = true)
{
empty($attributes['src']) && $attributes['src'] = $this->url(false);
$srcset = $this->srcset($reset);
if ($srcset) {
empty($attributes['srcset']) && $attributes['srcset'] = $srcset;
$attributes['sizes'] = $this->sizes();
}
return ['name' => 'img', 'attributes' => $attributes];
} | php | public function sourceParsedownElement(array $attributes, $reset = true)
{
empty($attributes['src']) && $attributes['src'] = $this->url(false);
$srcset = $this->srcset($reset);
if ($srcset) {
empty($attributes['srcset']) && $attributes['srcset'] = $srcset;
$attributes['sizes'] = $this->sizes();
}
return ['name' => 'img', 'attributes' => $attributes];
} | [
"public",
"function",
"sourceParsedownElement",
"(",
"array",
"$",
"attributes",
",",
"$",
"reset",
"=",
"true",
")",
"{",
"empty",
"(",
"$",
"attributes",
"[",
"'src'",
"]",
")",
"&&",
"$",
"attributes",
"[",
"'src'",
"]",
"=",
"$",
"this",
"->",
"url... | Parsedown element for source display mode
@param array $attributes
@param bool $reset
@return array | [
"Parsedown",
"element",
"for",
"source",
"display",
"mode"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ImageMedium.php#L341-L352 | train | Parse source parsedown element | [
30522,
2270,
3853,
3120,
19362,
6924,
12384,
12260,
3672,
1006,
9140,
1002,
12332,
1010,
1002,
25141,
1027,
2995,
1007,
1063,
4064,
1006,
1002,
12332,
1031,
1005,
5034,
2278,
1005,
1033,
1007,
1004,
1004,
1002,
12332,
1031,
1005,
5034,
2278... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php | MarkdownDescriptor.describeContainerTags | protected function describeContainerTags(ContainerBuilder $builder, array $options = [])
{
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
$this->write("Container tags\n==============");
foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) {
$this->write("\n\n".$tag."\n".str_repeat('-', \strlen($tag)));
foreach ($definitions as $serviceId => $definition) {
$this->write("\n\n");
$this->describeContainerDefinition($definition, ['omit_tags' => true, 'id' => $serviceId]);
}
}
} | php | protected function describeContainerTags(ContainerBuilder $builder, array $options = [])
{
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
$this->write("Container tags\n==============");
foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) {
$this->write("\n\n".$tag."\n".str_repeat('-', \strlen($tag)));
foreach ($definitions as $serviceId => $definition) {
$this->write("\n\n");
$this->describeContainerDefinition($definition, ['omit_tags' => true, 'id' => $serviceId]);
}
}
} | [
"protected",
"function",
"describeContainerTags",
"(",
"ContainerBuilder",
"$",
"builder",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"showHidden",
"=",
"isset",
"(",
"$",
"options",
"[",
"'show_hidden'",
"]",
")",
"&&",
"$",
"options",
"[... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php#L88-L100 | train | Describes the container tags | [
30522,
5123,
3853,
6235,
8663,
18249,
8743,
26454,
1006,
11661,
8569,
23891,
2099,
1002,
12508,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
2265,
27511,
4181,
1027,
26354,
3388,
1006,
1002,
7047,
1031,
1005,
2265,
1035,
5023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.buildSort | protected function buildSort($path, array $pages, $order_by = 'default', $manual = null, $sort_flags = null)
{
$list = [];
$header_default = null;
$header_query = null;
// do this header query work only once
if (strpos($order_by, 'header.') === 0) {
$header_query = explode('|', str_replace('header.', '', $order_by));
if (isset($header_query[1])) {
$header_default = $header_query[1];
}
}
foreach ($pages as $key => $info) {
$child = $this->instances[$key] ?? null;
if (!$child) {
throw new \RuntimeException("Page does not exist: {$key}");
}
switch ($order_by) {
case 'title':
$list[$key] = $child->title();
break;
case 'date':
$list[$key] = $child->date();
$sort_flags = SORT_REGULAR;
break;
case 'modified':
$list[$key] = $child->modified();
$sort_flags = SORT_REGULAR;
break;
case 'publish_date':
$list[$key] = $child->publishDate();
$sort_flags = SORT_REGULAR;
break;
case 'unpublish_date':
$list[$key] = $child->unpublishDate();
$sort_flags = SORT_REGULAR;
break;
case 'slug':
$list[$key] = $child->slug();
break;
case 'basename':
$list[$key] = basename($key);
break;
case 'folder':
$list[$key] = $child->folder();
break;
case (is_string($header_query[0])):
$child_header = new Header((array)$child->header());
$header_value = $child_header->get($header_query[0]);
if (is_array($header_value)) {
$list[$key] = implode(',',$header_value);
} elseif ($header_value) {
$list[$key] = $header_value;
} else {
$list[$key] = $header_default ?: $key;
}
$sort_flags = $sort_flags ?: SORT_REGULAR;
break;
case 'manual':
case 'default':
default:
$list[$key] = $key;
$sort_flags = $sort_flags ?: SORT_REGULAR;
}
}
if (!$sort_flags) {
$sort_flags = SORT_NATURAL | SORT_FLAG_CASE;
}
// handle special case when order_by is random
if ($order_by === 'random') {
$list = $this->arrayShuffle($list);
} else {
// else just sort the list according to specified key
if (extension_loaded('intl') && $this->grav['config']->get('system.intl_enabled')) {
$locale = setlocale(LC_COLLATE, 0); //`setlocale` with a 0 param returns the current locale set
$col = Collator::create($locale);
if ($col) {
if (($sort_flags & SORT_NATURAL) === SORT_NATURAL) {
$list = preg_replace_callback('~([0-9]+)\.~', function($number) {
return sprintf('%032d.', $number[0]);
}, $list);
$list_vals = array_values($list);
if (is_numeric(array_shift($list_vals))) {
$sort_flags = Collator::SORT_REGULAR;
} else {
$sort_flags = Collator::SORT_STRING;
}
}
$col->asort($list, $sort_flags);
} else {
asort($list, $sort_flags);
}
} else {
asort($list, $sort_flags);
}
}
// Move manually ordered items into the beginning of the list. Order of the unlisted items does not change.
if (is_array($manual) && !empty($manual)) {
$new_list = [];
$i = count($manual);
foreach ($list as $key => $dummy) {
$info = $pages[$key];
$order = \array_search($info['slug'], $manual, true);
if ($order === false) {
$order = $i++;
}
$new_list[$key] = (int)$order;
}
$list = $new_list;
// Apply manual ordering to the list.
asort($list);
}
foreach ($list as $key => $sort) {
$info = $pages[$key];
$this->sort[$path][$order_by][$key] = $info;
}
} | php | protected function buildSort($path, array $pages, $order_by = 'default', $manual = null, $sort_flags = null)
{
$list = [];
$header_default = null;
$header_query = null;
// do this header query work only once
if (strpos($order_by, 'header.') === 0) {
$header_query = explode('|', str_replace('header.', '', $order_by));
if (isset($header_query[1])) {
$header_default = $header_query[1];
}
}
foreach ($pages as $key => $info) {
$child = $this->instances[$key] ?? null;
if (!$child) {
throw new \RuntimeException("Page does not exist: {$key}");
}
switch ($order_by) {
case 'title':
$list[$key] = $child->title();
break;
case 'date':
$list[$key] = $child->date();
$sort_flags = SORT_REGULAR;
break;
case 'modified':
$list[$key] = $child->modified();
$sort_flags = SORT_REGULAR;
break;
case 'publish_date':
$list[$key] = $child->publishDate();
$sort_flags = SORT_REGULAR;
break;
case 'unpublish_date':
$list[$key] = $child->unpublishDate();
$sort_flags = SORT_REGULAR;
break;
case 'slug':
$list[$key] = $child->slug();
break;
case 'basename':
$list[$key] = basename($key);
break;
case 'folder':
$list[$key] = $child->folder();
break;
case (is_string($header_query[0])):
$child_header = new Header((array)$child->header());
$header_value = $child_header->get($header_query[0]);
if (is_array($header_value)) {
$list[$key] = implode(',',$header_value);
} elseif ($header_value) {
$list[$key] = $header_value;
} else {
$list[$key] = $header_default ?: $key;
}
$sort_flags = $sort_flags ?: SORT_REGULAR;
break;
case 'manual':
case 'default':
default:
$list[$key] = $key;
$sort_flags = $sort_flags ?: SORT_REGULAR;
}
}
if (!$sort_flags) {
$sort_flags = SORT_NATURAL | SORT_FLAG_CASE;
}
// handle special case when order_by is random
if ($order_by === 'random') {
$list = $this->arrayShuffle($list);
} else {
// else just sort the list according to specified key
if (extension_loaded('intl') && $this->grav['config']->get('system.intl_enabled')) {
$locale = setlocale(LC_COLLATE, 0); //`setlocale` with a 0 param returns the current locale set
$col = Collator::create($locale);
if ($col) {
if (($sort_flags & SORT_NATURAL) === SORT_NATURAL) {
$list = preg_replace_callback('~([0-9]+)\.~', function($number) {
return sprintf('%032d.', $number[0]);
}, $list);
$list_vals = array_values($list);
if (is_numeric(array_shift($list_vals))) {
$sort_flags = Collator::SORT_REGULAR;
} else {
$sort_flags = Collator::SORT_STRING;
}
}
$col->asort($list, $sort_flags);
} else {
asort($list, $sort_flags);
}
} else {
asort($list, $sort_flags);
}
}
// Move manually ordered items into the beginning of the list. Order of the unlisted items does not change.
if (is_array($manual) && !empty($manual)) {
$new_list = [];
$i = count($manual);
foreach ($list as $key => $dummy) {
$info = $pages[$key];
$order = \array_search($info['slug'], $manual, true);
if ($order === false) {
$order = $i++;
}
$new_list[$key] = (int)$order;
}
$list = $new_list;
// Apply manual ordering to the list.
asort($list);
}
foreach ($list as $key => $sort) {
$info = $pages[$key];
$this->sort[$path][$order_by][$key] = $info;
}
} | [
"protected",
"function",
"buildSort",
"(",
"$",
"path",
",",
"array",
"$",
"pages",
",",
"$",
"order_by",
"=",
"'default'",
",",
"$",
"manual",
"=",
"null",
",",
"$",
"sort_flags",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"$",
"heade... | @param string $path
@param array $pages
@param string $order_by
@param array|null $manual
@param int|null $sort_flags
@throws \RuntimeException
@internal | [
"@param",
"string",
"$path",
"@param",
"array",
"$pages",
"@param",
"string",
"$order_by",
"@param",
"array|null",
"$manual",
"@param",
"int|null",
"$sort_flags"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L1254-L1383 | train | Build the sort list | [
30522,
5123,
3853,
16473,
11589,
1006,
1002,
4130,
1010,
9140,
1002,
5530,
1010,
1002,
2344,
1035,
2011,
1027,
1005,
12398,
1005,
1010,
1002,
6410,
1027,
19701,
1010,
1002,
4066,
1035,
9245,
1027,
19701,
1007,
1063,
1002,
2862,
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/Cache/Adapter/Psr16Adapter.php | Psr16Adapter.doSave | protected function doSave(array $values, $lifetime)
{
return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime);
} | php | protected function doSave(array $values, $lifetime)
{
return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime);
} | [
"protected",
"function",
"doSave",
"(",
"array",
"$",
"values",
",",
"$",
"lifetime",
")",
"{",
"return",
"$",
"this",
"->",
"pool",
"->",
"setMultiple",
"(",
"$",
"values",
",",
"0",
"===",
"$",
"lifetime",
"?",
"null",
":",
"$",
"lifetime",
")",
";... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php#L77-L80 | train | Save the values into the pool | [
30522,
5123,
3853,
9998,
10696,
1006,
9140,
1002,
5300,
1010,
1002,
6480,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4770,
1011,
1028,
2275,
12274,
7096,
11514,
2571,
1006,
1002,
5300,
1010,
1014,
1027,
1027,
1027,
30524,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Controller.php | Controller.middleware | public function middleware($middleware, array $options = [])
{
foreach ((array) $middleware as $m) {
$this->middleware[] = [
'middleware' => $m,
'options' => &$options,
];
}
return new ControllerMiddlewareOptions($options);
} | php | public function middleware($middleware, array $options = [])
{
foreach ((array) $middleware as $m) {
$this->middleware[] = [
'middleware' => $m,
'options' => &$options,
];
}
return new ControllerMiddlewareOptions($options);
} | [
"public",
"function",
"middleware",
"(",
"$",
"middleware",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"middleware",
"as",
"$",
"m",
")",
"{",
"$",
"this",
"->",
"middleware",
"[",
"]",
"=",
"[",
... | Register middleware on the controller.
@param array|string|\Closure $middleware
@param array $options
@return \Illuminate\Routing\ControllerMiddlewareOptions | [
"Register",
"middleware",
"on",
"the",
"controller",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Controller.php#L23-L33 | train | Create a middleware array | [
30522,
2270,
3853,
2690,
8059,
1006,
1002,
2690,
8059,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
18921,
6776,
1006,
1006,
9140,
1007,
1002,
2690,
8059,
2004,
1002,
1049,
1007,
1063,
1002,
2023,
1011,
1028,
2690,
8059,
1031,
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 | plugins/Annotations/AnnotationList.php | AnnotationList.update | public function update($idSite, $idNote, $date = null, $note = null, $starred = null)
{
$this->checkIdSiteIsLoaded($idSite);
$this->checkNoteExists($idSite, $idNote);
$annotation =& $this->annotations[$idSite][$idNote];
if ($date !== null) {
$annotation['date'] = Date::factory($date)->toString('Y-m-d');
}
if ($note !== null) {
$annotation['note'] = $note;
}
if ($starred !== null) {
$annotation['starred'] = $starred;
}
} | php | public function update($idSite, $idNote, $date = null, $note = null, $starred = null)
{
$this->checkIdSiteIsLoaded($idSite);
$this->checkNoteExists($idSite, $idNote);
$annotation =& $this->annotations[$idSite][$idNote];
if ($date !== null) {
$annotation['date'] = Date::factory($date)->toString('Y-m-d');
}
if ($note !== null) {
$annotation['note'] = $note;
}
if ($starred !== null) {
$annotation['starred'] = $starred;
}
} | [
"public",
"function",
"update",
"(",
"$",
"idSite",
",",
"$",
"idNote",
",",
"$",
"date",
"=",
"null",
",",
"$",
"note",
"=",
"null",
",",
"$",
"starred",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"checkIdSiteIsLoaded",
"(",
"$",
"idSite",
")",
";"... | Modifies an annotation in this instance's collection of annotations.
Note: This method does not perist the change in the DB. The save method must
be called for that.
@param int $idSite The ID of the site whose annotation will be updated.
@param int $idNote The ID of the note.
@param string|null $date The new date of the annotation, eg '2012-01-01'. If
null, no change is made.
@param string|null $note The new text of the annotation. If null, no change
is made.
@param int|null $starred Either 1 or 0, whether the annotation should be
starred or not. If null, no change is made.
@throws Exception if $idSite is not an ID that was supplied upon construction.
@throws Exception if $idNote does not refer to valid note for the site. | [
"Modifies",
"an",
"annotation",
"in",
"this",
"instance",
"s",
"collection",
"of",
"annotations",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L130-L145 | train | Update an annotation | [
30522,
2270,
3853,
10651,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
8909,
22074,
1010,
1002,
3058,
1027,
19701,
1010,
1002,
3602,
1027,
19701,
1010,
1002,
5652,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
4638,
9821,
4221,
2483,
17468... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FlexIndex.php | FlexIndex.getFlexKeys | public function getFlexKeys(): array
{
// Get storage keys for the objects.
$keys = [];
$type = $this->_flexDirectory->getFlexType() . '.obj:';
foreach ($this->getEntries() as $key => $value) {
$keys[$key] = $value['flex_key'] ?? $type . $value['storage_key'];
}
return $keys;
} | php | public function getFlexKeys(): array
{
// Get storage keys for the objects.
$keys = [];
$type = $this->_flexDirectory->getFlexType() . '.obj:';
foreach ($this->getEntries() as $key => $value) {
$keys[$key] = $value['flex_key'] ?? $type . $value['storage_key'];
}
return $keys;
} | [
"public",
"function",
"getFlexKeys",
"(",
")",
":",
"array",
"{",
"// Get storage keys for the objects.",
"$",
"keys",
"=",
"[",
"]",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"_flexDirectory",
"->",
"getFlexType",
"(",
")",
".",
"'.obj:'",
";",
"foreach",
... | {@inheritdoc}
@see FlexCollectionInterface::getFlexKeys() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/FlexIndex.php#L180-L191 | train | Get the flex keys for the objects | [
30522,
2270,
3853,
2131,
21031,
2595,
14839,
2015,
1006,
1007,
1024,
9140,
1063,
1013,
1013,
2131,
5527,
6309,
2005,
1996,
5200,
1012,
1002,
6309,
1027,
1031,
1033,
1025,
1002,
2828,
1027,
1002,
2023,
1011,
1028,
1035,
23951,
4305,
2890,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/ResponseTrait.php | ResponseTrait.withCookie | public function withCookie($cookie)
{
if (is_string($cookie) && function_exists('cookie')) {
$cookie = call_user_func_array('cookie', func_get_args());
}
$this->headers->setCookie($cookie);
return $this;
} | php | public function withCookie($cookie)
{
if (is_string($cookie) && function_exists('cookie')) {
$cookie = call_user_func_array('cookie', func_get_args());
}
$this->headers->setCookie($cookie);
return $this;
} | [
"public",
"function",
"withCookie",
"(",
"$",
"cookie",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"cookie",
")",
"&&",
"function_exists",
"(",
"'cookie'",
")",
")",
"{",
"$",
"cookie",
"=",
"call_user_func_array",
"(",
"'cookie'",
",",
"func_get_args",
"... | Add a cookie to the response.
@param \Symfony\Component\HttpFoundation\Cookie|mixed $cookie
@return $this | [
"Add",
"a",
"cookie",
"to",
"the",
"response",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/ResponseTrait.php#L108-L117 | train | Set the cookie to the response | [
30522,
2270,
3853,
2007,
3597,
23212,
2063,
1006,
1002,
17387,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
17387,
1007,
1004,
1004,
3853,
1035,
6526,
1006,
1005,
17387,
1005,
1007,
1007,
1063,
1002,
17387,
1027,
2655,
1035,
5310,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.handleRelationColumn | protected function handleRelationColumn($method, $label)
{
$model = $this->model()->eloquent();
if (!method_exists($model, $method)) {
return false;
}
if (!($relation = $model->$method()) instanceof Relations\Relation) {
return false;
}
if ($relation instanceof Relations\HasOne ||
$relation instanceof Relations\BelongsTo ||
$relation instanceof Relations\MorphOne
) {
$this->model()->with($method);
return $this->addColumn($method, $label)->setRelation(Str::snake($method));
}
if ($relation instanceof Relations\HasMany
|| $relation instanceof Relations\BelongsToMany
|| $relation instanceof Relations\MorphToMany
) {
$this->model()->with($method);
return $this->addColumn(Str::snake($method), $label);
}
return false;
} | php | protected function handleRelationColumn($method, $label)
{
$model = $this->model()->eloquent();
if (!method_exists($model, $method)) {
return false;
}
if (!($relation = $model->$method()) instanceof Relations\Relation) {
return false;
}
if ($relation instanceof Relations\HasOne ||
$relation instanceof Relations\BelongsTo ||
$relation instanceof Relations\MorphOne
) {
$this->model()->with($method);
return $this->addColumn($method, $label)->setRelation(Str::snake($method));
}
if ($relation instanceof Relations\HasMany
|| $relation instanceof Relations\BelongsToMany
|| $relation instanceof Relations\MorphToMany
) {
$this->model()->with($method);
return $this->addColumn(Str::snake($method), $label);
}
return false;
} | [
"protected",
"function",
"handleRelationColumn",
"(",
"$",
"method",
",",
"$",
"label",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
"(",
")",
"->",
"eloquent",
"(",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"model",
",",
"$",
... | Handle relation column for grid.
@param string $method
@param string $label
@return bool|Column | [
"Handle",
"relation",
"column",
"for",
"grid",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L828-L859 | train | Handle relation column | [
30522,
5123,
3853,
28213,
10581,
3508,
25778,
2819,
2078,
1006,
1002,
4118,
1010,
1002,
3830,
1007,
1063,
1002,
2944,
1027,
1002,
2023,
1011,
1028,
2944,
1006,
1007,
1011,
1028,
3449,
2080,
15417,
1006,
1007,
1025,
2065,
1006,
999,
4118,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Ibm.php | Zend_Db_Adapter_Pdo_Ibm.insert | public function insert($table, array $bind)
{
$this->_connect();
$newbind = array();
if (is_array($bind)) {
foreach ($bind as $name => $value) {
if($value !== null) {
$newbind[$name] = $value;
}
}
}
return parent::insert($table, $newbind);
} | php | public function insert($table, array $bind)
{
$this->_connect();
$newbind = array();
if (is_array($bind)) {
foreach ($bind as $name => $value) {
if($value !== null) {
$newbind[$name] = $value;
}
}
}
return parent::insert($table, $newbind);
} | [
"public",
"function",
"insert",
"(",
"$",
"table",
",",
"array",
"$",
"bind",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"$",
"newbind",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"bind",
")",
")",
"{",
"foreach",
... | Inserts a table row with specified data.
Special handling for PDO_IBM
remove empty slots
@param mixed $table The table to insert data into.
@param array $bind Column-value pairs.
@return int The number of affected rows. | [
"Inserts",
"a",
"table",
"row",
"with",
"specified",
"data",
".",
"Special",
"handling",
"for",
"PDO_IBM",
"remove",
"empty",
"slots"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm.php#L257-L270 | train | Inserts a new record into the database | [
30522,
2270,
3853,
19274,
1006,
1002,
2795,
1010,
9140,
1002,
14187,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1002,
2047,
8428,
2094,
1027,
9140,
1006,
1007,
1025,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
14187,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php | SwitchUserListener.attemptExitUser | private function attemptExitUser(Request $request)
{
if (null === ($currentToken = $this->tokenStorage->getToken()) || null === $original = $this->getOriginalToken($currentToken)) {
throw new AuthenticationCredentialsNotFoundException('Could not find original Token object.');
}
if (null !== $this->dispatcher && $original->getUser() instanceof UserInterface) {
$user = $this->provider->refreshUser($original->getUser());
$switchEvent = new SwitchUserEvent($request, $user, $original);
$this->dispatcher->dispatch($switchEvent, SecurityEvents::SWITCH_USER);
$original = $switchEvent->getToken();
}
return $original;
} | php | private function attemptExitUser(Request $request)
{
if (null === ($currentToken = $this->tokenStorage->getToken()) || null === $original = $this->getOriginalToken($currentToken)) {
throw new AuthenticationCredentialsNotFoundException('Could not find original Token object.');
}
if (null !== $this->dispatcher && $original->getUser() instanceof UserInterface) {
$user = $this->provider->refreshUser($original->getUser());
$switchEvent = new SwitchUserEvent($request, $user, $original);
$this->dispatcher->dispatch($switchEvent, SecurityEvents::SWITCH_USER);
$original = $switchEvent->getToken();
}
return $original;
} | [
"private",
"function",
"attemptExitUser",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"null",
"===",
"(",
"$",
"currentToken",
"=",
"$",
"this",
"->",
"tokenStorage",
"->",
"getToken",
"(",
")",
")",
"||",
"null",
"===",
"$",
"original",
"=",
... | Attempts to exit from an already switched user.
@return TokenInterface The original TokenInterface instance
@throws AuthenticationCredentialsNotFoundException | [
"Attempts",
"to",
"exit",
"from",
"an",
"already",
"switched",
"user",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php#L175-L189 | train | Attempt to exit the user | [
30522,
2797,
3853,
3535,
10288,
4183,
20330,
1006,
5227,
1002,
5227,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1006,
1002,
2783,
18715,
2368,
1027,
1002,
2023,
1011,
1028,
19204,
23809,
4270,
1011,
1028,
2131,
18715,
2368,
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... |
octobercms/october | modules/backend/classes/Controller.php | Controller.getId | public function getId($suffix = null)
{
$id = class_basename(get_called_class()) . '-' . $this->action;
if ($suffix !== null) {
$id .= '-' . $suffix;
}
return $id;
} | php | public function getId($suffix = null)
{
$id = class_basename(get_called_class()) . '-' . $this->action;
if ($suffix !== null) {
$id .= '-' . $suffix;
}
return $id;
} | [
"public",
"function",
"getId",
"(",
"$",
"suffix",
"=",
"null",
")",
"{",
"$",
"id",
"=",
"class_basename",
"(",
"get_called_class",
"(",
")",
")",
".",
"'-'",
".",
"$",
"this",
"->",
"action",
";",
"if",
"(",
"$",
"suffix",
"!==",
"null",
")",
"{"... | Returns a unique ID for the controller and route. Useful in creating HTML markup. | [
"Returns",
"a",
"unique",
"ID",
"for",
"the",
"controller",
"and",
"route",
".",
"Useful",
"in",
"creating",
"HTML",
"markup",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L632-L640 | train | Returns the id of the current action | [
30522,
2270,
3853,
2131,
3593,
1006,
1002,
16809,
1027,
19701,
1007,
1063,
1002,
8909,
1027,
2465,
1035,
2918,
18442,
1006,
2131,
1035,
2170,
1035,
2465,
1006,
1007,
1007,
1012,
1005,
1011,
1005,
1012,
1002,
2023,
1011,
1028,
2895,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Writable/Maildir.php | Zend_Mail_Storage_Writable_Maildir._createUniqueId | protected function _createUniqueId()
{
$id = '';
$id .= function_exists('microtime') ? microtime(true) : (time() . ' ' . rand(0, 100000));
$id .= '.' . (function_exists('posix_getpid') ? posix_getpid() : rand(50, 65535));
$id .= '.' . php_uname('n');
return $id;
} | php | protected function _createUniqueId()
{
$id = '';
$id .= function_exists('microtime') ? microtime(true) : (time() . ' ' . rand(0, 100000));
$id .= '.' . (function_exists('posix_getpid') ? posix_getpid() : rand(50, 65535));
$id .= '.' . php_uname('n');
return $id;
} | [
"protected",
"function",
"_createUniqueId",
"(",
")",
"{",
"$",
"id",
"=",
"''",
";",
"$",
"id",
".=",
"function_exists",
"(",
"'microtime'",
")",
"?",
"microtime",
"(",
"true",
")",
":",
"(",
"time",
"(",
")",
".",
"' '",
".",
"rand",
"(",
"0",
",... | create a uniqueid for maildir filename
This is nearly the format defined in the maildir standard. The microtime() call should already
create a uniqueid, the pid is for multicore/-cpu machine that manage to call this function at the
exact same time, and uname() gives us the hostname for multiple machines accessing the same storage.
If someone disables posix we create a random number of the same size, so this method should also
work on Windows - if you manage to get maildir working on Windows.
Microtime could also be disabled, altough I've never seen it.
@return string new uniqueid | [
"create",
"a",
"uniqueid",
"for",
"maildir",
"filename"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L412-L420 | train | Create unique id for the current thread | [
30522,
5123,
3853,
1035,
3443,
19496,
4226,
3593,
1006,
1007,
1063,
1002,
8909,
1027,
1005,
1005,
1025,
1002,
8909,
1012,
1027,
3853,
1035,
6526,
1006,
1005,
12702,
7292,
1005,
1007,
1029,
12702,
7292,
1006,
2995,
1007,
1024,
1006,
2051,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Worker.php | Worker.pauseWorker | protected function pauseWorker(WorkerOptions $options, $lastRestart)
{
$this->sleep($options->sleep > 0 ? $options->sleep : 1);
$this->stopIfNecessary($options, $lastRestart);
} | php | protected function pauseWorker(WorkerOptions $options, $lastRestart)
{
$this->sleep($options->sleep > 0 ? $options->sleep : 1);
$this->stopIfNecessary($options, $lastRestart);
} | [
"protected",
"function",
"pauseWorker",
"(",
"WorkerOptions",
"$",
"options",
",",
"$",
"lastRestart",
")",
"{",
"$",
"this",
"->",
"sleep",
"(",
"$",
"options",
"->",
"sleep",
">",
"0",
"?",
"$",
"options",
"->",
"sleep",
":",
"1",
")",
";",
"$",
"t... | Pause the worker for the current loop.
@param \Illuminate\Queue\WorkerOptions $options
@param int $lastRestart
@return void | [
"Pause",
"the",
"worker",
"for",
"the",
"current",
"loop",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Worker.php#L185-L190 | train | Pause the worker and stop the process if it is running | [
30522,
5123,
3853,
8724,
6198,
2121,
1006,
7309,
7361,
9285,
1002,
7047,
1010,
1002,
2197,
28533,
8445,
1007,
1063,
1002,
2023,
1011,
1028,
3637,
1006,
1002,
7047,
1011,
1028,
3637,
1028,
1014,
1029,
1002,
7047,
1011,
1028,
3637,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Guess/Guess.php | Guess.getBestGuess | public static function getBestGuess(array $guesses)
{
$result = null;
$maxConfidence = -1;
foreach ($guesses as $guess) {
if ($maxConfidence < $confidence = $guess->getConfidence()) {
$maxConfidence = $confidence;
$result = $guess;
}
}
return $result;
} | php | public static function getBestGuess(array $guesses)
{
$result = null;
$maxConfidence = -1;
foreach ($guesses as $guess) {
if ($maxConfidence < $confidence = $guess->getConfidence()) {
$maxConfidence = $confidence;
$result = $guess;
}
}
return $result;
} | [
"public",
"static",
"function",
"getBestGuess",
"(",
"array",
"$",
"guesses",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"maxConfidence",
"=",
"-",
"1",
";",
"foreach",
"(",
"$",
"guesses",
"as",
"$",
"guess",
")",
"{",
"if",
"(",
"$",
"maxConfi... | Returns the guess most likely to be correct from a list of guesses.
If there are multiple guesses with the same, highest confidence, the
returned guess is any of them.
@param Guess[] $guesses An array of guesses
@return self|null | [
"Returns",
"the",
"guess",
"most",
"likely",
"to",
"be",
"correct",
"from",
"a",
"list",
"of",
"guesses",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Guess/Guess.php#L67-L80 | train | Returns the best guess | [
30522,
2270,
10763,
3853,
2131,
12681,
2102,
22967,
2015,
1006,
9140,
1002,
3984,
2229,
1007,
1063,
1002,
2765,
1027,
19701,
1025,
1002,
4098,
8663,
20740,
5897,
1027,
1011,
1015,
1025,
18921,
6776,
1006,
1002,
3984,
2229,
2004,
1002,
3984,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | Events/Select.php | Select.del | public function del($fd, $flag)
{
$fd_key = (int)$fd;
switch ($flag) {
case self::EV_READ:
unset($this->_allEvents[$fd_key][$flag], $this->_readFds[$fd_key]);
if (empty($this->_allEvents[$fd_key])) {
unset($this->_allEvents[$fd_key]);
}
return true;
case self::EV_WRITE:
unset($this->_allEvents[$fd_key][$flag], $this->_writeFds[$fd_key]);
if (empty($this->_allEvents[$fd_key])) {
unset($this->_allEvents[$fd_key]);
}
return true;
case self::EV_EXCEPT:
unset($this->_allEvents[$fd_key][$flag], $this->_exceptFds[$fd_key]);
if(empty($this->_allEvents[$fd_key]))
{
unset($this->_allEvents[$fd_key]);
}
return true;
case self::EV_SIGNAL:
if(DIRECTORY_SEPARATOR !== '/') {
return false;
}
unset($this->_signalEvents[$fd_key]);
pcntl_signal($fd, SIG_IGN);
break;
case self::EV_TIMER:
case self::EV_TIMER_ONCE;
unset($this->_eventTimer[$fd_key]);
return true;
}
return false;
} | php | public function del($fd, $flag)
{
$fd_key = (int)$fd;
switch ($flag) {
case self::EV_READ:
unset($this->_allEvents[$fd_key][$flag], $this->_readFds[$fd_key]);
if (empty($this->_allEvents[$fd_key])) {
unset($this->_allEvents[$fd_key]);
}
return true;
case self::EV_WRITE:
unset($this->_allEvents[$fd_key][$flag], $this->_writeFds[$fd_key]);
if (empty($this->_allEvents[$fd_key])) {
unset($this->_allEvents[$fd_key]);
}
return true;
case self::EV_EXCEPT:
unset($this->_allEvents[$fd_key][$flag], $this->_exceptFds[$fd_key]);
if(empty($this->_allEvents[$fd_key]))
{
unset($this->_allEvents[$fd_key]);
}
return true;
case self::EV_SIGNAL:
if(DIRECTORY_SEPARATOR !== '/') {
return false;
}
unset($this->_signalEvents[$fd_key]);
pcntl_signal($fd, SIG_IGN);
break;
case self::EV_TIMER:
case self::EV_TIMER_ONCE;
unset($this->_eventTimer[$fd_key]);
return true;
}
return false;
} | [
"public",
"function",
"del",
"(",
"$",
"fd",
",",
"$",
"flag",
")",
"{",
"$",
"fd_key",
"=",
"(",
"int",
")",
"$",
"fd",
";",
"switch",
"(",
"$",
"flag",
")",
"{",
"case",
"self",
"::",
"EV_READ",
":",
"unset",
"(",
"$",
"this",
"->",
"_allEven... | {@inheritdoc} | [
"{"
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Events/Select.php#L175-L211 | train | Delete all events | [
30522,
2270,
3853,
3972,
1006,
1002,
1042,
2094,
1010,
1002,
5210,
1007,
1063,
1002,
1042,
2094,
1035,
3145,
1027,
1006,
20014,
1007,
1002,
1042,
2094,
1025,
6942,
1006,
1002,
5210,
1007,
1063,
2553,
2969,
1024,
1024,
23408,
1035,
3191,
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/ViewDataTable/Manager.php | Manager.getAvailableViewDataTables | public static function getAvailableViewDataTables()
{
$cache = Cache::getTransientCache();
$cacheId = 'ViewDataTable.getAvailableViewDataTables';
$dataTables = $cache->fetch($cacheId);
if (!empty($dataTables)) {
return $dataTables;
}
$klassToExtend = '\\Piwik\\Plugin\\ViewDataTable';
/** @var string[] $visualizations */
$visualizations = PluginManager::getInstance()->findMultipleComponents('Visualizations', $klassToExtend);
$result = array();
foreach ($visualizations as $viz) {
if (!class_exists($viz)) {
throw new \Exception("Invalid visualization class '$viz' found in Visualization.getAvailableVisualizations.");
}
if (!is_subclass_of($viz, $klassToExtend)) {
throw new \Exception("ViewDataTable class '$viz' does not extend Plugin/ViewDataTable");
}
$vizId = $viz::getViewDataTableId();
if (isset($result[$vizId])) {
throw new \Exception("ViewDataTable ID '$vizId' is already in use!");
}
$result[$vizId] = $viz;
}
/**
* Triggered to filter available DataTable visualizations.
*
* Plugins that want to disable certain visualizations should subscribe to
* this event and remove visualizations from the incoming array.
*
* **Example**
*
* public function filterViewDataTable(&$visualizations)
* {
* unset($visualizations[HtmlTable::ID]);
* }
*
* @param array &$visualizations An array of all available visualizations indexed by visualization ID.
* @since Piwik 3.0.0
*/
Piwik::postEvent('ViewDataTable.filterViewDataTable', array(&$result));
$cache->save($cacheId, $result);
return $result;
} | php | public static function getAvailableViewDataTables()
{
$cache = Cache::getTransientCache();
$cacheId = 'ViewDataTable.getAvailableViewDataTables';
$dataTables = $cache->fetch($cacheId);
if (!empty($dataTables)) {
return $dataTables;
}
$klassToExtend = '\\Piwik\\Plugin\\ViewDataTable';
/** @var string[] $visualizations */
$visualizations = PluginManager::getInstance()->findMultipleComponents('Visualizations', $klassToExtend);
$result = array();
foreach ($visualizations as $viz) {
if (!class_exists($viz)) {
throw new \Exception("Invalid visualization class '$viz' found in Visualization.getAvailableVisualizations.");
}
if (!is_subclass_of($viz, $klassToExtend)) {
throw new \Exception("ViewDataTable class '$viz' does not extend Plugin/ViewDataTable");
}
$vizId = $viz::getViewDataTableId();
if (isset($result[$vizId])) {
throw new \Exception("ViewDataTable ID '$vizId' is already in use!");
}
$result[$vizId] = $viz;
}
/**
* Triggered to filter available DataTable visualizations.
*
* Plugins that want to disable certain visualizations should subscribe to
* this event and remove visualizations from the incoming array.
*
* **Example**
*
* public function filterViewDataTable(&$visualizations)
* {
* unset($visualizations[HtmlTable::ID]);
* }
*
* @param array &$visualizations An array of all available visualizations indexed by visualization ID.
* @since Piwik 3.0.0
*/
Piwik::postEvent('ViewDataTable.filterViewDataTable', array(&$result));
$cache->save($cacheId, $result);
return $result;
} | [
"public",
"static",
"function",
"getAvailableViewDataTables",
"(",
")",
"{",
"$",
"cache",
"=",
"Cache",
"::",
"getTransientCache",
"(",
")",
";",
"$",
"cacheId",
"=",
"'ViewDataTable.getAvailableViewDataTables'",
";",
"$",
"dataTables",
"=",
"$",
"cache",
"->",
... | Returns all registered visualization classes. Uses the 'Visualization.getAvailable'
event to retrieve visualizations.
@return array Array mapping visualization IDs with their associated visualization classes.
@throws \Exception If a visualization class does not exist or if a duplicate visualization ID
is found.
@return array | [
"Returns",
"all",
"registered",
"visualization",
"classes",
".",
"Uses",
"the",
"Visualization",
".",
"getAvailable",
"event",
"to",
"retrieve",
"visualizations",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Manager.php#L66-L122 | train | Returns an array of all available viewDataTable visualizations. | [
30522,
2270,
10763,
3853,
2131,
12462,
11733,
3468,
8584,
2850,
29336,
3085,
2015,
1006,
1007,
1063,
1002,
17053,
1027,
17053,
1024,
1024,
2131,
6494,
3619,
11638,
3540,
5403,
1006,
1007,
1025,
1002,
17053,
3593,
1027,
1005,
3193,
2850,
293... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormField.php | FormField.filterPresetAttributes | protected function filterPresetAttributes($attributes, $position = 'field')
{
if (!$this->preset || $position != 'field') {
return $attributes;
}
if (!is_array($this->preset)) {
$this->preset = ['field' => $this->preset, 'type' => 'slug'];
}
$presetField = array_get($this->preset, 'field');
$presetType = array_get($this->preset, 'type');
if ($this->arrayName) {
$fullPresetField = $this->arrayName.'['.implode('][', HtmlHelper::nameToArray($presetField)).']';
}
else {
$fullPresetField = $presetField;
}
$newAttributes = [
'data-input-preset' => '[name="'.$fullPresetField.'"]',
'data-input-preset-type' => $presetType,
'data-input-preset-closest-parent' => 'form'
];
if ($prefixInput = array_get($this->preset, 'prefixInput')) {
$newAttributes['data-input-preset-prefix-input'] = $prefixInput;
}
return $attributes + $newAttributes;
} | php | protected function filterPresetAttributes($attributes, $position = 'field')
{
if (!$this->preset || $position != 'field') {
return $attributes;
}
if (!is_array($this->preset)) {
$this->preset = ['field' => $this->preset, 'type' => 'slug'];
}
$presetField = array_get($this->preset, 'field');
$presetType = array_get($this->preset, 'type');
if ($this->arrayName) {
$fullPresetField = $this->arrayName.'['.implode('][', HtmlHelper::nameToArray($presetField)).']';
}
else {
$fullPresetField = $presetField;
}
$newAttributes = [
'data-input-preset' => '[name="'.$fullPresetField.'"]',
'data-input-preset-type' => $presetType,
'data-input-preset-closest-parent' => 'form'
];
if ($prefixInput = array_get($this->preset, 'prefixInput')) {
$newAttributes['data-input-preset-prefix-input'] = $prefixInput;
}
return $attributes + $newAttributes;
} | [
"protected",
"function",
"filterPresetAttributes",
"(",
"$",
"attributes",
",",
"$",
"position",
"=",
"'field'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"preset",
"||",
"$",
"position",
"!=",
"'field'",
")",
"{",
"return",
"$",
"attributes",
";",
"}... | Adds attributes used specifically by the Input Preset API
@param array $attributes
@param string $position
@return array | [
"Adds",
"attributes",
"used",
"specifically",
"by",
"the",
"Input",
"Preset",
"API"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L526-L557 | train | Filter attributes for preset field | [
30522,
5123,
3853,
11307,
28994,
12928,
4779,
3089,
8569,
4570,
1006,
1002,
12332,
1010,
1002,
2597,
1027,
1005,
2492,
1005,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
3653,
13462,
1064,
1064,
1002,
2597,
999,
1027,
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... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Sqlite.php | Zend_Db_Adapter_Pdo_Sqlite.describeTable | public function describeTable($tableName, $schemaName = null)
{
$sql = 'PRAGMA ';
if ($schemaName) {
$sql .= $this->quoteIdentifier($schemaName) . '.';
}
$sql .= 'table_info('.$this->quoteIdentifier($tableName).')';
$stmt = $this->query($sql);
/**
* Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
*/
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$cid = 0;
$name = 1;
$type = 2;
$notnull = 3;
$dflt_value = 4;
$pk = 5;
$desc = array();
$p = 1;
foreach ($result as $key => $row) {
list($length, $scale, $precision, $primary, $primaryPosition, $identity) =
array(null, null, null, false, null, false);
if (preg_match('/^((?:var)?char)\((\d+)\)/i', $row[$type], $matches)) {
$row[$type] = $matches[1];
$length = $matches[2];
} else if (preg_match('/^decimal\((\d+),(\d+)\)/i', $row[$type], $matches)) {
$row[$type] = 'DECIMAL';
$precision = $matches[1];
$scale = $matches[2];
}
if ((bool) $row[$pk]) {
$primary = true;
$primaryPosition = $p;
/**
* SQLite INTEGER primary key is always auto-increment.
*/
$identity = (bool) ($row[$type] == 'INTEGER');
++$p;
}
$desc[$this->foldCase($row[$name])] = array(
'SCHEMA_NAME' => $this->foldCase($schemaName),
'TABLE_NAME' => $this->foldCase($tableName),
'COLUMN_NAME' => $this->foldCase($row[$name]),
'COLUMN_POSITION' => $row[$cid]+1,
'DATA_TYPE' => $row[$type],
'DEFAULT' => $row[$dflt_value],
'NULLABLE' => ! (bool) $row[$notnull],
'LENGTH' => $length,
'SCALE' => $scale,
'PRECISION' => $precision,
'UNSIGNED' => null, // Sqlite3 does not support unsigned data
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
}
return $desc;
} | php | public function describeTable($tableName, $schemaName = null)
{
$sql = 'PRAGMA ';
if ($schemaName) {
$sql .= $this->quoteIdentifier($schemaName) . '.';
}
$sql .= 'table_info('.$this->quoteIdentifier($tableName).')';
$stmt = $this->query($sql);
/**
* Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
*/
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$cid = 0;
$name = 1;
$type = 2;
$notnull = 3;
$dflt_value = 4;
$pk = 5;
$desc = array();
$p = 1;
foreach ($result as $key => $row) {
list($length, $scale, $precision, $primary, $primaryPosition, $identity) =
array(null, null, null, false, null, false);
if (preg_match('/^((?:var)?char)\((\d+)\)/i', $row[$type], $matches)) {
$row[$type] = $matches[1];
$length = $matches[2];
} else if (preg_match('/^decimal\((\d+),(\d+)\)/i', $row[$type], $matches)) {
$row[$type] = 'DECIMAL';
$precision = $matches[1];
$scale = $matches[2];
}
if ((bool) $row[$pk]) {
$primary = true;
$primaryPosition = $p;
/**
* SQLite INTEGER primary key is always auto-increment.
*/
$identity = (bool) ($row[$type] == 'INTEGER');
++$p;
}
$desc[$this->foldCase($row[$name])] = array(
'SCHEMA_NAME' => $this->foldCase($schemaName),
'TABLE_NAME' => $this->foldCase($tableName),
'COLUMN_NAME' => $this->foldCase($row[$name]),
'COLUMN_POSITION' => $row[$cid]+1,
'DATA_TYPE' => $row[$type],
'DEFAULT' => $row[$dflt_value],
'NULLABLE' => ! (bool) $row[$notnull],
'LENGTH' => $length,
'SCALE' => $scale,
'PRECISION' => $precision,
'UNSIGNED' => null, // Sqlite3 does not support unsigned data
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
}
return $desc;
} | [
"public",
"function",
"describeTable",
"(",
"$",
"tableName",
",",
"$",
"schemaName",
"=",
"null",
")",
"{",
"$",
"sql",
"=",
"'PRAGMA '",
";",
"if",
"(",
"$",
"schemaName",
")",
"{",
"$",
"sql",
".=",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
... | Returns the column descriptions for a table.
The return value is an associative array keyed by the column name,
as returned by the RDBMS.
The value of each array element is an associative array
with the following keys:
SCHEMA_NAME => string; name of database or schema
TABLE_NAME => string;
COLUMN_NAME => string; column name
COLUMN_POSITION => number; ordinal position of column in table
DATA_TYPE => string; SQL datatype name of column
DEFAULT => string; default expression of column, null if none
NULLABLE => boolean; true if column can have nulls
LENGTH => number; length of CHAR/VARCHAR
SCALE => number; scale of NUMERIC/DECIMAL
PRECISION => number; precision of NUMERIC/DECIMAL
UNSIGNED => boolean; unsigned property of an integer type
PRIMARY => boolean; true if column is part of the primary key
PRIMARY_POSITION => integer; position of column in primary key
IDENTITY => integer; true if column is auto-generated with unique values
@param string $tableName
@param string $schemaName OPTIONAL
@return array | [
"Returns",
"the",
"column",
"descriptions",
"for",
"a",
"table",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Sqlite.php#L198-L263 | train | Describes a table | [
30522,
2270,
3853,
6235,
10880,
1006,
1002,
2795,
18442,
1010,
1002,
8040,
28433,
18442,
1027,
19701,
1007,
1063,
1002,
29296,
1027,
1005,
10975,
8490,
2863,
1005,
1025,
2065,
1006,
1002,
8040,
28433,
18442,
1007,
1063,
1002,
29296,
1012,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/AcceptHeader.php | AcceptHeader.add | public function add(AcceptHeaderItem $item)
{
$this->items[$item->getValue()] = $item;
$this->sorted = false;
return $this;
} | php | public function add(AcceptHeaderItem $item)
{
$this->items[$item->getValue()] = $item;
$this->sorted = false;
return $this;
} | [
"public",
"function",
"add",
"(",
"AcceptHeaderItem",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"item",
"->",
"getValue",
"(",
")",
"]",
"=",
"$",
"item",
";",
"$",
"this",
"->",
"sorted",
"=",
"false",
";",
"return",
"$",
"this"... | Adds an item.
@return $this | [
"Adds",
"an",
"item",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/AcceptHeader.php#L107-L113 | train | Add accept header item | [
30522,
2270,
3853,
5587,
1006,
5138,
4974,
11124,
18532,
1002,
8875,
1007,
1063,
1002,
2023,
1011,
1028,
5167,
1031,
1002,
8875,
1011,
1028,
2131,
10175,
5657,
1006,
1007,
1033,
1027,
1002,
8875,
1025,
1002,
2023,
1011,
1028,
19616,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreHome/Controller.php | Controller.makeRowEvolution | private function makeRowEvolution($isMultiRowEvolution, $graphType = null)
{
if ($isMultiRowEvolution) {
return new MultiRowEvolution($this->idSite, $this->date, $graphType);
} else {
return new RowEvolution($this->idSite, $this->date, $graphType);
}
} | php | private function makeRowEvolution($isMultiRowEvolution, $graphType = null)
{
if ($isMultiRowEvolution) {
return new MultiRowEvolution($this->idSite, $this->date, $graphType);
} else {
return new RowEvolution($this->idSite, $this->date, $graphType);
}
} | [
"private",
"function",
"makeRowEvolution",
"(",
"$",
"isMultiRowEvolution",
",",
"$",
"graphType",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"isMultiRowEvolution",
")",
"{",
"return",
"new",
"MultiRowEvolution",
"(",
"$",
"this",
"->",
"idSite",
",",
"$",
"this... | Utility function. Creates a RowEvolution instance. | [
"Utility",
"function",
".",
"Creates",
"a",
"RowEvolution",
"instance",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreHome/Controller.php#L239-L246 | train | Create RowEvolution object | [
30522,
2797,
3853,
9338,
29385,
6767,
7630,
3508,
1006,
1002,
2003,
12274,
7096,
9711,
8545,
6767,
7630,
3508,
1010,
1002,
10629,
13874,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2003,
12274,
7096,
9711,
8545,
6767,
7630,
3508,
1007,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/HeaderBag.php | HeaderBag.set | public function set($key, $values, $replace = true)
{
$key = str_replace('_', '-', strtolower($key));
if (\is_array($values)) {
$values = array_values($values);
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
}
} else {
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = [$values];
} else {
$this->headers[$key][] = $values;
}
}
if ('cache-control' === $key) {
$this->cacheControl = $this->parseCacheControl(implode(', ', $this->headers[$key]));
}
} | php | public function set($key, $values, $replace = true)
{
$key = str_replace('_', '-', strtolower($key));
if (\is_array($values)) {
$values = array_values($values);
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
}
} else {
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = [$values];
} else {
$this->headers[$key][] = $values;
}
}
if ('cache-control' === $key) {
$this->cacheControl = $this->parseCacheControl(implode(', ', $this->headers[$key]));
}
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"values",
",",
"$",
"replace",
"=",
"true",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"strtolower",
"(",
"$",
"key",
")",
")",
";",
"if",
"(",
"\\",
"is_array",
... | Sets a header by name.
@param string $key The key
@param string|string[] $values The value or an array of values
@param bool $replace Whether to replace the actual value or not (true by default) | [
"Sets",
"a",
"header",
"by",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/HeaderBag.php#L137-L160 | train | Set the header value | [
30522,
2270,
3853,
2275,
1006,
1002,
3145,
1010,
1002,
5300,
1010,
1002,
5672,
1027,
2995,
1007,
1063,
1002,
3145,
1027,
2358,
2099,
1035,
5672,
1006,
1005,
1035,
1005,
1010,
1005,
1011,
1005,
1010,
2358,
5339,
12898,
13777,
1006,
1002,
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/MySqlGrammar.php | MySqlGrammar.compileJsonContains | protected function compileJsonContains($column, $value)
{
[$field, $path] = $this->wrapJsonFieldAndPath($column);
return 'json_contains('.$field.', '.$value.$path.')';
} | php | protected function compileJsonContains($column, $value)
{
[$field, $path] = $this->wrapJsonFieldAndPath($column);
return 'json_contains('.$field.', '.$value.$path.')';
} | [
"protected",
"function",
"compileJsonContains",
"(",
"$",
"column",
",",
"$",
"value",
")",
"{",
"[",
"$",
"field",
",",
"$",
"path",
"]",
"=",
"$",
"this",
"->",
"wrapJsonFieldAndPath",
"(",
"$",
"column",
")",
";",
"return",
"'json_contains('",
".",
"$... | Compile a "JSON contains" statement into SQL.
@param string $column
@param string $value
@return string | [
"Compile",
"a",
"JSON",
"contains",
"statement",
"into",
"SQL",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php#L65-L70 | train | Compiles JSON contains statement into valid PHP. | [
30522,
5123,
3853,
4012,
22090,
22578,
2239,
8663,
18249,
2015,
1006,
1002,
5930,
1010,
1002,
3643,
1007,
1063,
1031,
1002,
2492,
1010,
1002,
4130,
1033,
1027,
1002,
2023,
1011,
1028,
10236,
22578,
2239,
3790,
5685,
15069,
1006,
1002,
5930,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.