repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
overtrue/wechat | src/Kernel/AccessToken.php | AccessToken.setToken | public function setToken(string $token, int $lifetime = 7200): AccessTokenInterface
{
$this->getCache()->set($this->getCacheKey(), [
$this->tokenKey => $token,
'expires_in' => $lifetime,
], $lifetime - $this->safeSeconds);
if (!$this->getCache()->has($this->getCacheKey())) {
throw new RuntimeException('Failed to cache access token.');
}
return $this;
} | php | public function setToken(string $token, int $lifetime = 7200): AccessTokenInterface
{
$this->getCache()->set($this->getCacheKey(), [
$this->tokenKey => $token,
'expires_in' => $lifetime,
], $lifetime - $this->safeSeconds);
if (!$this->getCache()->has($this->getCacheKey())) {
throw new RuntimeException('Failed to cache access token.');
}
return $this;
} | [
"public",
"function",
"setToken",
"(",
"string",
"$",
"token",
",",
"int",
"$",
"lifetime",
"=",
"7200",
")",
":",
"AccessTokenInterface",
"{",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
",",
... | @param string $token
@param int $lifetime
@return \EasyWeChat\Kernel\Contracts\AccessTokenInterface
@throws \Psr\SimpleCache\InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\RuntimeException | [
"@param",
"string",
"$token",
"@param",
"int",
"$lifetime"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/AccessToken.php#L133-L145 | train | Set access token | [
30522,
2270,
3853,
2275,
18715,
2368,
1006,
5164,
1002,
19204,
1010,
20014,
1002,
6480,
1027,
22857,
2692,
1007,
1024,
3229,
18715,
18595,
10111,
12881,
10732,
1063,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
1006,
1007,
1011,
1028,
2275,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/Storage/FolderStorage.php | FolderStorage.updateRows | public function updateRows(array $rows): array
{
$list = [];
foreach ($rows as $key => $row) {
$key = (string)$key;
if (!$this->hasKey($key)) {
$list[$key] = null;
} else {
$path = $this->getPathFromKey($key);
$file = $this->getFile($path);
$list[$key] = $this->saveFile($file, $row);
}
}
return $list;
} | php | public function updateRows(array $rows): array
{
$list = [];
foreach ($rows as $key => $row) {
$key = (string)$key;
if (!$this->hasKey($key)) {
$list[$key] = null;
} else {
$path = $this->getPathFromKey($key);
$file = $this->getFile($path);
$list[$key] = $this->saveFile($file, $row);
}
}
return $list;
} | [
"public",
"function",
"updateRows",
"(",
"array",
"$",
"rows",
")",
":",
"array",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
... | {@inheritdoc}
@see FlexStorageInterface::updateRows() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/Storage/FolderStorage.php#L129-L144 | train | Updates rows in the table | [
30522,
2270,
3853,
10651,
10524,
2015,
1006,
9140,
1002,
10281,
1007,
1024,
9140,
1063,
1002,
2862,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
10281,
2004,
1002,
3145,
1027,
1028,
1002,
5216,
1007,
1063,
1002,
3145,
1027,
1006,
5164,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/Grammar.php | Grammar.compileSelect | public function compileSelect(Builder $query)
{
if ($query->unions && $query->aggregate) {
return $this->compileUnionAggregate($query);
}
// If the query does not have any columns set, we'll set the columns to the
// * character to just get all of the columns from the database. Then we
// can build the query and concatenate all the pieces together as one.
$original = $query->columns;
if (is_null($query->columns)) {
$query->columns = ['*'];
}
// To compile the query, we'll spin through each component of the query and
// see if that component exists. If it does we'll just call the compiler
// function for the component which is responsible for making the SQL.
$sql = trim($this->concatenate(
$this->compileComponents($query))
);
$query->columns = $original;
return $sql;
} | php | public function compileSelect(Builder $query)
{
if ($query->unions && $query->aggregate) {
return $this->compileUnionAggregate($query);
}
// If the query does not have any columns set, we'll set the columns to the
// * character to just get all of the columns from the database. Then we
// can build the query and concatenate all the pieces together as one.
$original = $query->columns;
if (is_null($query->columns)) {
$query->columns = ['*'];
}
// To compile the query, we'll spin through each component of the query and
// see if that component exists. If it does we'll just call the compiler
// function for the component which is responsible for making the SQL.
$sql = trim($this->concatenate(
$this->compileComponents($query))
);
$query->columns = $original;
return $sql;
} | [
"public",
"function",
"compileSelect",
"(",
"Builder",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
"->",
"unions",
"&&",
"$",
"query",
"->",
"aggregate",
")",
"{",
"return",
"$",
"this",
"->",
"compileUnionAggregate",
"(",
"$",
"query",
")",
";",
... | Compile a select query into SQL.
@param \Illuminate\Database\Query\Builder $query
@return string | [
"Compile",
"a",
"select",
"query",
"into",
"SQL",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/Grammar.php#L47-L72 | train | Compiles a select statement into SQL | [
30522,
2270,
3853,
4012,
22090,
11246,
22471,
1006,
12508,
1002,
23032,
1007,
1063,
2065,
1006,
1002,
23032,
1011,
1028,
9209,
1004,
1004,
1002,
23032,
1011,
1028,
9572,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4012,
22090,
19496,
7856,
13... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement/Pdo/Ibm.php | Zend_Db_Statement_Pdo_Ibm.fetchAll | public function fetchAll($style = null, $col = null)
{
$data = parent::fetchAll($style, $col);
$results = array();
$remove = $this->_adapter->foldCase('ZEND_DB_ROWNUM');
foreach ($data as $row) {
if (is_array($row) && array_key_exists($remove, $row)) {
unset($row[$remove]);
}
$results[] = $row;
}
return $results;
} | php | public function fetchAll($style = null, $col = null)
{
$data = parent::fetchAll($style, $col);
$results = array();
$remove = $this->_adapter->foldCase('ZEND_DB_ROWNUM');
foreach ($data as $row) {
if (is_array($row) && array_key_exists($remove, $row)) {
unset($row[$remove]);
}
$results[] = $row;
}
return $results;
} | [
"public",
"function",
"fetchAll",
"(",
"$",
"style",
"=",
"null",
",",
"$",
"col",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"parent",
"::",
"fetchAll",
"(",
"$",
"style",
",",
"$",
"col",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"... | Returns an array containing all of the result set rows.
Behaves like parent, but if limit()
is used, the final result removes the extra column
'zend_db_rownum'
@param int $style OPTIONAL Fetch mode.
@param int $col OPTIONAL Column number, if fetch mode is by column.
@return array Collection of rows, each in a format by the fetch mode.
@throws Zend_Db_Statement_Exception | [
"Returns",
"an",
"array",
"containing",
"all",
"of",
"the",
"result",
"set",
"rows",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Pdo/Ibm.php#L54-L67 | train | Fetch all records from the database | [
30522,
2270,
3853,
18584,
8095,
1006,
1002,
2806,
1027,
19701,
1010,
1002,
8902,
1027,
19701,
1007,
1063,
1002,
2951,
1027,
6687,
1024,
1024,
18584,
8095,
1006,
1002,
2806,
1010,
1002,
8902,
1007,
1025,
1002,
3463,
1027,
9140,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Twig/Node/TwigNodeThrow.php | TwigNodeThrow.compile | public function compile(Compiler $compiler)
{
$compiler->addDebugInfo($this);
$compiler
->write('throw new \RuntimeException(')
->subcompile($this->getNode('message'))
->write(', ')
->write($this->getAttribute('code') ?: 500)
->write(");\n");
} | php | public function compile(Compiler $compiler)
{
$compiler->addDebugInfo($this);
$compiler
->write('throw new \RuntimeException(')
->subcompile($this->getNode('message'))
->write(', ')
->write($this->getAttribute('code') ?: 500)
->write(");\n");
} | [
"public",
"function",
"compile",
"(",
"Compiler",
"$",
"compiler",
")",
"{",
"$",
"compiler",
"->",
"addDebugInfo",
"(",
"$",
"this",
")",
";",
"$",
"compiler",
"->",
"write",
"(",
"'throw new \\RuntimeException('",
")",
"->",
"subcompile",
"(",
"$",
"this",... | Compiles the node to PHP.
@param Compiler $compiler A Twig_Compiler instance
@throws \LogicException | [
"Compiles",
"the",
"node",
"to",
"PHP",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/Node/TwigNodeThrow.php#L40-L50 | train | Compiles the exception into PHP code | [
30522,
2270,
3853,
4012,
22090,
1006,
21624,
1002,
21624,
1007,
1063,
1002,
21624,
1011,
1028,
5587,
3207,
8569,
11528,
14876,
1006,
1002,
2023,
1007,
1025,
1002,
21624,
30524,
1006,
1005,
4471,
1005,
1007,
1007,
1011,
1028,
4339,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Console/Migrations/TableGuesser.php | TableGuesser.guess | public static function guess($migration)
{
foreach (self::CREATE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[1], $create = true];
}
}
foreach (self::CHANGE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[2], $create = false];
}
}
} | php | public static function guess($migration)
{
foreach (self::CREATE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[1], $create = true];
}
}
foreach (self::CHANGE_PATTERNS as $pattern) {
if (preg_match($pattern, $migration, $matches)) {
return [$matches[2], $create = false];
}
}
} | [
"public",
"static",
"function",
"guess",
"(",
"$",
"migration",
")",
"{",
"foreach",
"(",
"self",
"::",
"CREATE_PATTERNS",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"migration",
",",
"$",
"matches",
")",
")... | Attempt to guess the table name and "creation" status of the given migration.
@param string $migration
@return array | [
"Attempt",
"to",
"guess",
"the",
"table",
"name",
"and",
"creation",
"status",
"of",
"the",
"given",
"migration",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Console/Migrations/TableGuesser.php#L23-L36 | train | Guesses the migration name from the migration file. | [
30522,
2270,
10763,
3853,
3984,
1006,
1002,
9230,
1007,
1063,
18921,
6776,
1006,
2969,
1024,
1024,
3443,
1035,
7060,
2004,
1002,
5418,
1007,
1063,
2065,
1006,
3653,
2290,
1035,
2674,
1006,
1002,
5418,
1010,
1002,
9230,
1010,
1002,
3503,
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/Data/Validation.php | Validation.filter | public static function filter($value, array $field)
{
$validate = (array)($field['filter'] ?? $field['validate'] ?? null);
// If value isn't required, we will return null if empty value is given.
if (($value === null || $value === '') && empty($validate['required'])) {
return null;
}
if (!isset($field['type'])) {
$field['type'] = 'text';
}
$type = $field['filter']['type'] ?? $field['validate']['type'] ?? $field['type'];
$method = 'filter' . ucfirst(str_replace('-', '_', $type));
// If this is a YAML field validate/filter as such
if (isset($field['yaml']) && $field['yaml'] === true) {
$method = 'filterYaml';
}
if (!method_exists(__CLASS__, $method)) {
$method = isset($field['array']) && $field['array'] === true ? 'filterArray' : 'filterText';
}
return self::$method($value, $validate, $field);
} | php | public static function filter($value, array $field)
{
$validate = (array)($field['filter'] ?? $field['validate'] ?? null);
// If value isn't required, we will return null if empty value is given.
if (($value === null || $value === '') && empty($validate['required'])) {
return null;
}
if (!isset($field['type'])) {
$field['type'] = 'text';
}
$type = $field['filter']['type'] ?? $field['validate']['type'] ?? $field['type'];
$method = 'filter' . ucfirst(str_replace('-', '_', $type));
// If this is a YAML field validate/filter as such
if (isset($field['yaml']) && $field['yaml'] === true) {
$method = 'filterYaml';
}
if (!method_exists(__CLASS__, $method)) {
$method = isset($field['array']) && $field['array'] === true ? 'filterArray' : 'filterText';
}
return self::$method($value, $validate, $field);
} | [
"public",
"static",
"function",
"filter",
"(",
"$",
"value",
",",
"array",
"$",
"field",
")",
"{",
"$",
"validate",
"=",
"(",
"array",
")",
"(",
"$",
"field",
"[",
"'filter'",
"]",
"??",
"$",
"field",
"[",
"'validate'",
"]",
"??",
"null",
")",
";",... | Filter value against a blueprint field definition.
@param mixed $value
@param array $field
@return mixed Filtered value. | [
"Filter",
"value",
"against",
"a",
"blueprint",
"field",
"definition",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Validation.php#L87-L113 | train | Filter the value using the filter and validate methods. | [
30522,
2270,
10763,
3853,
11307,
1006,
1002,
3643,
1010,
9140,
1002,
2492,
1007,
1063,
1002,
9398,
3686,
1027,
1006,
9140,
1007,
1006,
1002,
2492,
1031,
1005,
11307,
1005,
1033,
1029,
1029,
1002,
2492,
1031,
1005,
9398,
3686,
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... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.onLoadPopup | public function onLoadPopup()
{
$this->bottomToolbar = Input::get('bottomToolbar', $this->bottomToolbar);
$this->cropAndInsertButton = Input::get('cropAndInsertButton', $this->cropAndInsertButton);
return $this->makePartial('popup-body');
} | php | public function onLoadPopup()
{
$this->bottomToolbar = Input::get('bottomToolbar', $this->bottomToolbar);
$this->cropAndInsertButton = Input::get('cropAndInsertButton', $this->cropAndInsertButton);
return $this->makePartial('popup-body');
} | [
"public",
"function",
"onLoadPopup",
"(",
")",
"{",
"$",
"this",
"->",
"bottomToolbar",
"=",
"Input",
"::",
"get",
"(",
"'bottomToolbar'",
",",
"$",
"this",
"->",
"bottomToolbar",
")",
";",
"$",
"this",
"->",
"cropAndInsertButton",
"=",
"Input",
"::",
"get... | Start image cropping session AJAX handler
@return array | [
"Start",
"image",
"cropping",
"session",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L683-L690 | train | Load popup content | [
30522,
2270,
3853,
2006,
11066,
16340,
6279,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
3953,
3406,
4747,
8237,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
3953,
3406,
4747,
8237,
1005,
1010,
1002,
2023,
1011,
1028,
3953,
3406,
4747,
8237,
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.encodeWords | protected function encodeWords(HeaderInterface $header, string $input, int $usedLength = -1): string
{
$value = '';
$tokens = $this->getEncodableWordTokens($input);
foreach ($tokens as $token) {
// See RFC 2822, Sect 2.2 (really 2.2 ??)
if ($this->tokenNeedsEncoding($token)) {
// Don't encode starting WSP
$firstChar = substr($token, 0, 1);
switch ($firstChar) {
case ' ':
case "\t":
$value .= $firstChar;
$token = substr($token, 1);
}
if (-1 == $usedLength) {
$usedLength = \strlen($header->getName().': ') + \strlen($value);
}
$value .= $this->getTokenAsEncodedWord($token, $usedLength);
} else {
$value .= $token;
}
}
return $value;
} | php | protected function encodeWords(HeaderInterface $header, string $input, int $usedLength = -1): string
{
$value = '';
$tokens = $this->getEncodableWordTokens($input);
foreach ($tokens as $token) {
// See RFC 2822, Sect 2.2 (really 2.2 ??)
if ($this->tokenNeedsEncoding($token)) {
// Don't encode starting WSP
$firstChar = substr($token, 0, 1);
switch ($firstChar) {
case ' ':
case "\t":
$value .= $firstChar;
$token = substr($token, 1);
}
if (-1 == $usedLength) {
$usedLength = \strlen($header->getName().': ') + \strlen($value);
}
$value .= $this->getTokenAsEncodedWord($token, $usedLength);
} else {
$value .= $token;
}
}
return $value;
} | [
"protected",
"function",
"encodeWords",
"(",
"HeaderInterface",
"$",
"header",
",",
"string",
"$",
"input",
",",
"int",
"$",
"usedLength",
"=",
"-",
"1",
")",
":",
"string",
"{",
"$",
"value",
"=",
"''",
";",
"$",
"tokens",
"=",
"$",
"this",
"->",
"g... | Encode needed word tokens within a string of input. | [
"Encode",
"needed",
"word",
"tokens",
"within",
"a",
"string",
"of",
"input",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/Header/AbstractHeader.php#L122-L148 | train | Encode all words in the input string | [
30522,
5123,
3853,
4372,
16044,
22104,
1006,
20346,
18447,
2121,
12172,
1002,
20346,
1010,
5164,
1002,
7953,
1010,
20014,
1002,
2109,
7770,
13512,
2232,
1027,
1011,
1015,
1007,
1024,
5164,
1063,
1002,
3643,
1027,
1005,
1005,
1025,
1002,
192... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Part.php | Zend_Mail_Part.countParts | public function countParts()
{
if ($this->_countParts) {
return $this->_countParts;
}
$this->_countParts = count($this->_parts);
if ($this->_countParts) {
return $this->_countParts;
}
if ($this->_mail && $this->_mail->hasFetchPart) {
// TODO: fetch part
// return
}
$this->_cacheContent();
$this->_countParts = count($this->_parts);
return $this->_countParts;
} | php | public function countParts()
{
if ($this->_countParts) {
return $this->_countParts;
}
$this->_countParts = count($this->_parts);
if ($this->_countParts) {
return $this->_countParts;
}
if ($this->_mail && $this->_mail->hasFetchPart) {
// TODO: fetch part
// return
}
$this->_cacheContent();
$this->_countParts = count($this->_parts);
return $this->_countParts;
} | [
"public",
"function",
"countParts",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_countParts",
")",
"{",
"return",
"$",
"this",
"->",
"_countParts",
";",
"}",
"$",
"this",
"->",
"_countParts",
"=",
"count",
"(",
"$",
"this",
"->",
"_parts",
")",
";"... | Count parts of a multipart part
@return int number of sub-parts | [
"Count",
"parts",
"of",
"a",
"multipart",
"part"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Part.php#L276-L296 | train | Count parts of the message | [
30522,
2270,
3853,
4175,
26950,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
4175,
26950,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
1035,
4175,
26950,
1025,
1065,
1002,
2023,
1011,
1028,
1035,
4175,
26950,
1027,
4175,
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/system/console/OctoberEnv.php | OctoberEnv.overwriteConfig | private function overwriteConfig()
{
foreach (array_keys($this->config()) as $config) {
$this->config = $config;
$this->configToEnv();
}
} | php | private function overwriteConfig()
{
foreach (array_keys($this->config()) as $config) {
$this->config = $config;
$this->configToEnv();
}
} | [
"private",
"function",
"overwriteConfig",
"(",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"config",
"(",
")",
")",
"as",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"$",
"config",
";",
"$",
"this",
"->",
"configToE... | Overwrite config file | [
"Overwrite",
"config",
"file"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/console/OctoberEnv.php#L66-L73 | train | Overwrite config with new values | [
30522,
2797,
3853,
2058,
26373,
8663,
8873,
2290,
1006,
1007,
1063,
18921,
6776,
1006,
9140,
1035,
6309,
1006,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1006,
1007,
1007,
2004,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
2023,
1011,
1028,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Redirector.php | Redirector.guest | public function guest($path, $status = 302, $headers = [], $secure = null)
{
$request = $this->generator->getRequest();
$intended = $request->method() === 'GET' && $request->route() && ! $request->expectsJson()
? $this->generator->full()
: $this->generator->previous();
if ($intended) {
$this->setIntendedUrl($intended);
}
return $this->to($path, $status, $headers, $secure);
} | php | public function guest($path, $status = 302, $headers = [], $secure = null)
{
$request = $this->generator->getRequest();
$intended = $request->method() === 'GET' && $request->route() && ! $request->expectsJson()
? $this->generator->full()
: $this->generator->previous();
if ($intended) {
$this->setIntendedUrl($intended);
}
return $this->to($path, $status, $headers, $secure);
} | [
"public",
"function",
"guest",
"(",
"$",
"path",
",",
"$",
"status",
"=",
"302",
",",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"generator",
"->",
"getRequest",
"(",
")",
";"... | Create a new redirect response, while putting the current URL in the session.
@param string $path
@param int $status
@param array $headers
@param bool $secure
@return \Illuminate\Http\RedirectResponse | [
"Create",
"a",
"new",
"redirect",
"response",
"while",
"putting",
"the",
"current",
"URL",
"in",
"the",
"session",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Redirector.php#L83-L96 | train | Redirect to intended URL | [
30522,
2270,
3853,
4113,
1006,
1002,
4130,
1010,
1002,
3570,
1027,
22060,
1010,
1002,
20346,
2015,
1027,
1031,
1033,
1010,
1002,
5851,
1027,
19701,
1007,
1063,
1002,
5227,
1027,
1002,
2023,
1011,
1028,
13103,
1011,
1028,
2131,
2890,
15500,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Traits/PdoTrait.php | PdoTrait.doClear | protected function doClear($namespace)
{
$conn = $this->getConnection();
if ('' === $namespace) {
if ('sqlite' === $this->driver) {
$sql = "DELETE FROM $this->table";
} else {
$sql = "TRUNCATE TABLE $this->table";
}
} else {
$sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'";
}
try {
$conn->exec($sql);
} catch (TableNotFoundException $e) {
}
return true;
} | php | protected function doClear($namespace)
{
$conn = $this->getConnection();
if ('' === $namespace) {
if ('sqlite' === $this->driver) {
$sql = "DELETE FROM $this->table";
} else {
$sql = "TRUNCATE TABLE $this->table";
}
} else {
$sql = "DELETE FROM $this->table WHERE $this->idCol LIKE '$namespace%'";
}
try {
$conn->exec($sql);
} catch (TableNotFoundException $e) {
}
return true;
} | [
"protected",
"function",
"doClear",
"(",
"$",
"namespace",
")",
"{",
"$",
"conn",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
";",
"if",
"(",
"''",
"===",
"$",
"namespace",
")",
"{",
"if",
"(",
"'sqlite'",
"===",
"$",
"this",
"->",
"driver",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/PdoTrait.php#L230-L250 | train | Clear all entries in the table with the specified namespace | [
30522,
5123,
3853,
9986,
19738,
2099,
1006,
1002,
3415,
15327,
1007,
1063,
1002,
9530,
2078,
1027,
1002,
2023,
1011,
1028,
2131,
8663,
2638,
7542,
1006,
1007,
1025,
2065,
1006,
1005,
1005,
1027,
1027,
1027,
1002,
3415,
15327,
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/Container/Container.php | Container.when | public function when($concrete)
{
$aliases = [];
foreach (Arr::wrap($concrete) as $c) {
$aliases[] = $this->getAlias($c);
}
return new ContextualBindingBuilder($this, $aliases);
} | php | public function when($concrete)
{
$aliases = [];
foreach (Arr::wrap($concrete) as $c) {
$aliases[] = $this->getAlias($c);
}
return new ContextualBindingBuilder($this, $aliases);
} | [
"public",
"function",
"when",
"(",
"$",
"concrete",
")",
"{",
"$",
"aliases",
"=",
"[",
"]",
";",
"foreach",
"(",
"Arr",
"::",
"wrap",
"(",
"$",
"concrete",
")",
"as",
"$",
"c",
")",
"{",
"$",
"aliases",
"[",
"]",
"=",
"$",
"this",
"->",
"getAl... | Define a contextual binding.
@param array|string $concrete
@return \Illuminate\Contracts\Container\ContextualBindingBuilder | [
"Define",
"a",
"contextual",
"binding",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L142-L151 | train | Returns a ContextualBindingBuilder for the given concrete class. | [
30522,
2270,
3853,
2043,
1006,
1002,
5509,
1007,
1063,
1002,
14593,
2229,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
12098,
2099,
1024,
1024,
10236,
1006,
1002,
5509,
1007,
2004,
1002,
1039,
1007,
1063,
1002,
14593,
2229,
1031,
1033,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/StringLength.php | Zend_Validate_StringLength.isValid | public function isValid($value)
{
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
if ($this->_encoding !== null) {
$length = iconv_strlen($value, $this->_encoding);
} else {
$length = iconv_strlen($value);
}
if ($length < $this->_min) {
$this->_error(self::TOO_SHORT);
}
if (null !== $this->_max && $this->_max < $length) {
$this->_error(self::TOO_LONG);
}
if (count($this->_messages)) {
return false;
} else {
return true;
}
} | php | public function isValid($value)
{
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
if ($this->_encoding !== null) {
$length = iconv_strlen($value, $this->_encoding);
} else {
$length = iconv_strlen($value);
}
if ($length < $this->_min) {
$this->_error(self::TOO_SHORT);
}
if (null !== $this->_max && $this->_max < $length) {
$this->_error(self::TOO_LONG);
}
if (count($this->_messages)) {
return false;
} else {
return true;
}
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"_error",
"(",
"self",
"::",
"INVALID",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_se... | Defined by Zend_Validate_Interface
Returns true if and only if the string length of $value is at least the min option and
no greater than the max option (when the max option is not null).
@param string $value
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/StringLength.php#L235-L262 | train | Check if the value is valid | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
999,
2003,
1035,
5164,
1006,
1002,
3643,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7561,
1006,
2969,
1024,
1024,
19528,
1007,
1025,
2709,
6270,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Simple/AbstractCache.php | AbstractCache.get | public function get($key, $default = null)
{
$id = $this->getId($key);
try {
foreach ($this->doFetch([$id]) as $value) {
return $value;
}
} catch (\Exception $e) {
CacheItem::log($this->logger, 'Failed to fetch key "{key}"', ['key' => $key, 'exception' => $e]);
}
return $default;
} | php | public function get($key, $default = null)
{
$id = $this->getId($key);
try {
foreach ($this->doFetch([$id]) as $value) {
return $value;
}
} catch (\Exception $e) {
CacheItem::log($this->logger, 'Failed to fetch key "{key}"', ['key' => $key, 'exception' => $e]);
}
return $default;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
"$",
"key",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"doFetch",
"(",
"[",
"$",
"id",
"]... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Simple/AbstractCache.php#L50-L63 | train | Get value from cache | [
30522,
2270,
3853,
2131,
1006,
1002,
3145,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
1002,
8909,
1027,
1002,
2023,
1011,
1028,
2131,
3593,
1006,
1002,
3145,
1007,
1025,
3046,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2079,
7959,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getName | public function getName()
{
if (!empty($this->nameSingular)) {
return Piwik::translate($this->nameSingular);
}
return $this->nameSingular;
} | php | public function getName()
{
if (!empty($this->nameSingular)) {
return Piwik::translate($this->nameSingular);
}
return $this->nameSingular;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"nameSingular",
")",
")",
"{",
"return",
"Piwik",
"::",
"translate",
"(",
"$",
"this",
"->",
"nameSingular",
")",
";",
"}",
"return",
"$",
"this",
"->",
... | Returns the translated name of this dimension which is typically in singular.
@return string | [
"Returns",
"the",
"translated",
"name",
"of",
"this",
"dimension",
"which",
"is",
"typically",
"in",
"singular",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L344-L351 | train | Returns the name of the language. | [
30522,
2270,
3853,
2131,
18442,
1006,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
2023,
1011,
1028,
3415,
2075,
7934,
1007,
1007,
1063,
2709,
14255,
9148,
2243,
1024,
1024,
17637,
1006,
1002,
2023,
1011,
1028,
3415,
2075,
7934,
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... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.getMimeByExtension | public static function getMimeByExtension($extension, $default = 'application/octet-stream')
{
$extension = strtolower($extension);
// look for some standard types
switch ($extension) {
case null:
return $default;
case 'json':
return 'application/json';
case 'html':
return 'text/html';
case 'atom':
return 'application/atom+xml';
case 'rss':
return 'application/rss+xml';
case 'xml':
return 'application/xml';
}
$media_types = Grav::instance()['config']->get('media.types');
if (isset($media_types[$extension])) {
if (isset($media_types[$extension]['mime'])) {
return $media_types[$extension]['mime'];
}
}
return $default;
} | php | public static function getMimeByExtension($extension, $default = 'application/octet-stream')
{
$extension = strtolower($extension);
// look for some standard types
switch ($extension) {
case null:
return $default;
case 'json':
return 'application/json';
case 'html':
return 'text/html';
case 'atom':
return 'application/atom+xml';
case 'rss':
return 'application/rss+xml';
case 'xml':
return 'application/xml';
}
$media_types = Grav::instance()['config']->get('media.types');
if (isset($media_types[$extension])) {
if (isset($media_types[$extension]['mime'])) {
return $media_types[$extension]['mime'];
}
}
return $default;
} | [
"public",
"static",
"function",
"getMimeByExtension",
"(",
"$",
"extension",
",",
"$",
"default",
"=",
"'application/octet-stream'",
")",
"{",
"$",
"extension",
"=",
"strtolower",
"(",
"$",
"extension",
")",
";",
"// look for some standard types",
"switch",
"(",
"... | Return the mimetype based on filename extension
@param string $extension Extension of file (eg "txt")
@param string $default
@return string | [
"Return",
"the",
"mimetype",
"based",
"on",
"filename",
"extension"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L596-L625 | train | Returns the mime type of a file based on its extension | [
30522,
2270,
10763,
3853,
2131,
4328,
4168,
3762,
10288,
29048,
1006,
1002,
5331,
1010,
1002,
12398,
1027,
1005,
4646,
1013,
13323,
3388,
1011,
5460,
1005,
1007,
1063,
1002,
5331,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
5331,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php | NamespacedAttributeBag.set | public function set($name, $value)
{
$attributes = &$this->resolveAttributePath($name, true);
$name = $this->resolveKey($name);
$attributes[$name] = $value;
} | php | public function set($name, $value)
{
$attributes = &$this->resolveAttributePath($name, true);
$name = $this->resolveKey($name);
$attributes[$name] = $value;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"attributes",
"=",
"&",
"$",
"this",
"->",
"resolveAttributePath",
"(",
"$",
"name",
",",
"true",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"resolveKey",
"(",
"$"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php#L69-L74 | train | Set an attribute value in the attributes array. | [
30522,
2270,
3853,
2275,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
1002,
12332,
1027,
1004,
1002,
2023,
1011,
1028,
10663,
19321,
3089,
8569,
2618,
15069,
1006,
1002,
2171,
1010,
2995,
1007,
1025,
1002,
2171,
1027,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Events/CallQueuedListener.php | CallQueuedListener.failed | public function failed($e)
{
$this->prepareData();
$handler = Container::getInstance()->make($this->class);
$parameters = array_merge($this->data, [$e]);
if (method_exists($handler, 'failed')) {
call_user_func_array([$handler, 'failed'], $parameters);
}
} | php | public function failed($e)
{
$this->prepareData();
$handler = Container::getInstance()->make($this->class);
$parameters = array_merge($this->data, [$e]);
if (method_exists($handler, 'failed')) {
call_user_func_array([$handler, 'failed'], $parameters);
}
} | [
"public",
"function",
"failed",
"(",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"prepareData",
"(",
")",
";",
"$",
"handler",
"=",
"Container",
"::",
"getInstance",
"(",
")",
"->",
"make",
"(",
"$",
"this",
"->",
"class",
")",
";",
"$",
"parameters",
"... | Call the failed method on the job instance.
The event instance and the exception will be passed.
@param \Exception $e
@return void | [
"Call",
"the",
"failed",
"method",
"on",
"the",
"job",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Events/CallQueuedListener.php#L114-L125 | train | Failed handler. | [
30522,
2270,
3853,
3478,
1006,
1002,
1041,
1007,
1063,
1002,
2023,
1011,
1028,
4810,
6790,
1006,
1007,
1025,
1002,
28213,
1027,
11661,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2191,
1006,
1002,
2023,
1011,
1028,
2465,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/ResourceRegistrar.php | ResourceRegistrar.getResourceMethods | protected function getResourceMethods($defaults, $options)
{
$methods = $defaults;
if (isset($options['only'])) {
$methods = array_intersect($methods, (array) $options['only']);
}
if (isset($options['except'])) {
$methods = array_diff($methods, (array) $options['except']);
}
return $methods;
} | php | protected function getResourceMethods($defaults, $options)
{
$methods = $defaults;
if (isset($options['only'])) {
$methods = array_intersect($methods, (array) $options['only']);
}
if (isset($options['except'])) {
$methods = array_diff($methods, (array) $options['except']);
}
return $methods;
} | [
"protected",
"function",
"getResourceMethods",
"(",
"$",
"defaults",
",",
"$",
"options",
")",
"{",
"$",
"methods",
"=",
"$",
"defaults",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'only'",
"]",
")",
")",
"{",
"$",
"methods",
"=",
"array_inter... | Get the applicable resource methods.
@param array $defaults
@param array $options
@return array | [
"Get",
"the",
"applicable",
"resource",
"methods",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/ResourceRegistrar.php#L153-L166 | train | Get the list of available resource methods | [
30522,
5123,
3853,
2131,
6072,
8162,
3401,
11368,
6806,
5104,
1006,
1002,
12398,
2015,
1010,
1002,
7047,
1007,
1063,
1002,
4725,
1027,
1002,
12398,
2015,
1025,
2065,
1006,
26354,
3388,
1006,
1002,
7047,
1031,
1005,
2069,
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... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php | GetSetMethodNormalizer.extractAttributes | protected function extractAttributes($object, $format = null, array $context = [])
{
$reflectionObject = new \ReflectionObject($object);
$reflectionMethods = $reflectionObject->getMethods(\ReflectionMethod::IS_PUBLIC);
$attributes = [];
foreach ($reflectionMethods as $method) {
if (!$this->isGetMethod($method)) {
continue;
}
$attributeName = lcfirst(substr($method->name, 0 === strpos($method->name, 'is') ? 2 : 3));
if ($this->isAllowedAttribute($object, $attributeName, $format, $context)) {
$attributes[] = $attributeName;
}
}
return $attributes;
} | php | protected function extractAttributes($object, $format = null, array $context = [])
{
$reflectionObject = new \ReflectionObject($object);
$reflectionMethods = $reflectionObject->getMethods(\ReflectionMethod::IS_PUBLIC);
$attributes = [];
foreach ($reflectionMethods as $method) {
if (!$this->isGetMethod($method)) {
continue;
}
$attributeName = lcfirst(substr($method->name, 0 === strpos($method->name, 'is') ? 2 : 3));
if ($this->isAllowedAttribute($object, $attributeName, $format, $context)) {
$attributes[] = $attributeName;
}
}
return $attributes;
} | [
"protected",
"function",
"extractAttributes",
"(",
"$",
"object",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"reflectionObject",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"object",
")",
";",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php#L100-L119 | train | Extract Attributes from Object | [
30522,
5123,
3853,
14817,
19321,
3089,
8569,
4570,
1006,
1002,
4874,
30524,
1002,
4874,
1007,
1025,
1002,
9185,
11368,
6806,
5104,
1027,
1002,
9185,
16429,
20614,
1011,
1028,
2131,
11368,
6806,
5104,
1006,
1032,
9185,
11368,
6806,
2094,
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... |
symfony/symfony | src/Symfony/Component/Inflector/Inflector.php | Inflector.singularize | public static function singularize(string $plural)
{
$pluralRev = strrev($plural);
$lowerPluralRev = strtolower($pluralRev);
$pluralLength = \strlen($lowerPluralRev);
// Check if the word is one which is not inflected, return early if so
if (\in_array($lowerPluralRev, self::$uninflected, true)) {
return $plural;
}
// The outer loop iterates over the entries of the plural table
// The inner loop $j iterates over the characters of the plural suffix
// in the plural table to compare them with the characters of the actual
// given plural suffix
foreach (self::$pluralMap as $map) {
$suffix = $map[0];
$suffixLength = $map[1];
$j = 0;
// Compare characters in the plural table and of the suffix of the
// given plural one by one
while ($suffix[$j] === $lowerPluralRev[$j]) {
// Let $j point to the next character
++$j;
// Successfully compared the last character
// Add an entry with the singular suffix to the singular array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $pluralLength) {
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
break;
}
if (!$map[3] && !$nextIsVocal) {
// suffix may not succeed a consonant but next char is one
break;
}
}
$newBase = substr($plural, 0, $pluralLength - $suffixLength);
$newSuffix = $map[4];
// Check whether the first character in the plural suffix
// is uppercased. If yes, uppercase the first character in
// the singular suffix too
$firstUpper = ctype_upper($pluralRev[$j - 1]);
if (\is_array($newSuffix)) {
$singulars = [];
foreach ($newSuffix as $newSuffixEntry) {
$singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
}
return $singulars;
}
return $newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix);
}
// Suffix is longer than word
if ($j === $pluralLength) {
break;
}
}
}
// Assume that plural and singular is identical
return $plural;
} | php | public static function singularize(string $plural)
{
$pluralRev = strrev($plural);
$lowerPluralRev = strtolower($pluralRev);
$pluralLength = \strlen($lowerPluralRev);
// Check if the word is one which is not inflected, return early if so
if (\in_array($lowerPluralRev, self::$uninflected, true)) {
return $plural;
}
// The outer loop iterates over the entries of the plural table
// The inner loop $j iterates over the characters of the plural suffix
// in the plural table to compare them with the characters of the actual
// given plural suffix
foreach (self::$pluralMap as $map) {
$suffix = $map[0];
$suffixLength = $map[1];
$j = 0;
// Compare characters in the plural table and of the suffix of the
// given plural one by one
while ($suffix[$j] === $lowerPluralRev[$j]) {
// Let $j point to the next character
++$j;
// Successfully compared the last character
// Add an entry with the singular suffix to the singular array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $pluralLength) {
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
break;
}
if (!$map[3] && !$nextIsVocal) {
// suffix may not succeed a consonant but next char is one
break;
}
}
$newBase = substr($plural, 0, $pluralLength - $suffixLength);
$newSuffix = $map[4];
// Check whether the first character in the plural suffix
// is uppercased. If yes, uppercase the first character in
// the singular suffix too
$firstUpper = ctype_upper($pluralRev[$j - 1]);
if (\is_array($newSuffix)) {
$singulars = [];
foreach ($newSuffix as $newSuffixEntry) {
$singulars[] = $newBase.($firstUpper ? ucfirst($newSuffixEntry) : $newSuffixEntry);
}
return $singulars;
}
return $newBase.($firstUpper ? ucfirst($newSuffix) : $newSuffix);
}
// Suffix is longer than word
if ($j === $pluralLength) {
break;
}
}
}
// Assume that plural and singular is identical
return $plural;
} | [
"public",
"static",
"function",
"singularize",
"(",
"string",
"$",
"plural",
")",
"{",
"$",
"pluralRev",
"=",
"strrev",
"(",
"$",
"plural",
")",
";",
"$",
"lowerPluralRev",
"=",
"strtolower",
"(",
"$",
"pluralRev",
")",
";",
"$",
"pluralLength",
"=",
"\\... | Returns the singular form of a word.
If the method can't determine the form with certainty, an array of the
possible singulars is returned.
@param string $plural A word in plural form
@return string|array The singular form or an array of possible singular forms | [
"Returns",
"the",
"singular",
"form",
"of",
"a",
"word",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Inflector/Inflector.php#L331-L405 | train | Returns the plural form of the word | [
30522,
2270,
10763,
3853,
13048,
4697,
1006,
5164,
1002,
13994,
1007,
1063,
1002,
13994,
2890,
2615,
1027,
2358,
14343,
2615,
1006,
1002,
13994,
1007,
1025,
1002,
2896,
24759,
11137,
2890,
2615,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
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/Session/SessionManager.php | SessionManager.buildSession | protected function buildSession($handler)
{
return $this->app['config']['session.encrypt']
? $this->buildEncryptedSession($handler)
: new Store($this->app['config']['session.cookie'], $handler);
} | php | protected function buildSession($handler)
{
return $this->app['config']['session.encrypt']
? $this->buildEncryptedSession($handler)
: new Store($this->app['config']['session.cookie'], $handler);
} | [
"protected",
"function",
"buildSession",
"(",
"$",
"handler",
")",
"{",
"return",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"[",
"'session.encrypt'",
"]",
"?",
"$",
"this",
"->",
"buildEncryptedSession",
"(",
"$",
"handler",
")",
":",
"new",
"Store",... | Build the session instance.
@param \SessionHandlerInterface $handler
@return \Illuminate\Session\Store | [
"Build",
"the",
"session",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Session/SessionManager.php#L173-L178 | train | Build session object | [
30522,
5123,
3853,
16473,
7971,
3258,
1006,
1002,
28213,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
9530,
8873,
2290,
1005,
1033,
1031,
1005,
5219,
1012,
4372,
26775,
22571,
2102,
1005,
1033,
1029,
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... |
getgrav/grav | system/src/Grav/Common/Taxonomy.php | Taxonomy.findTaxonomy | public function findTaxonomy($taxonomies, $operator = 'and')
{
$matches = [];
$results = [];
foreach ((array)$taxonomies as $taxonomy => $items) {
foreach ((array)$items as $item) {
if (isset($this->taxonomy_map[$taxonomy][$item])) {
$matches[] = $this->taxonomy_map[$taxonomy][$item];
} else {
$matches[] = [];
}
}
}
if (strtolower($operator) === 'or') {
foreach ($matches as $match) {
$results = array_merge($results, $match);
}
} else {
$results = $matches ? array_pop($matches) : [];
foreach ($matches as $match) {
$results = array_intersect_key($results, $match);
}
}
return new Collection($results, ['taxonomies' => $taxonomies]);
} | php | public function findTaxonomy($taxonomies, $operator = 'and')
{
$matches = [];
$results = [];
foreach ((array)$taxonomies as $taxonomy => $items) {
foreach ((array)$items as $item) {
if (isset($this->taxonomy_map[$taxonomy][$item])) {
$matches[] = $this->taxonomy_map[$taxonomy][$item];
} else {
$matches[] = [];
}
}
}
if (strtolower($operator) === 'or') {
foreach ($matches as $match) {
$results = array_merge($results, $match);
}
} else {
$results = $matches ? array_pop($matches) : [];
foreach ($matches as $match) {
$results = array_intersect_key($results, $match);
}
}
return new Collection($results, ['taxonomies' => $taxonomies]);
} | [
"public",
"function",
"findTaxonomy",
"(",
"$",
"taxonomies",
",",
"$",
"operator",
"=",
"'and'",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"taxonomies",
"as",
"$",
"ta... | Returns a new Page object with the sub-pages containing all the values set for a
particular taxonomy.
@param array $taxonomies taxonomies to search, eg ['tag'=>['animal','cat']]
@param string $operator can be 'or' or 'and' (defaults to 'and')
@return Collection Collection object set to contain matches found in the taxonomy map | [
"Returns",
"a",
"new",
"Page",
"object",
"with",
"the",
"sub",
"-",
"pages",
"containing",
"all",
"the",
"values",
"set",
"for",
"a",
"particular",
"taxonomy",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Taxonomy.php#L88-L115 | train | Find taxonomy by taxonomy name | [
30522,
2270,
3853,
2424,
2696,
22500,
16940,
1006,
1002,
28521,
20936,
2229,
1010,
1002,
6872,
1027,
1005,
1998,
1005,
1007,
1063,
1002,
3503,
1027,
1031,
1033,
1025,
1002,
3463,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1006,
9140,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php | CommandForV6.createRunner | protected function createRunner(): BaseRunner
{
$listener = new SymfonyTestsListener();
$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];
$registeredLocally = false;
foreach ($this->arguments['listeners'] as $registeredListener) {
if ($registeredListener instanceof SymfonyTestsListener) {
$registeredListener->globalListenerDisabled();
$registeredLocally = true;
break;
}
}
if (!$registeredLocally) {
$this->arguments['listeners'][] = $listener;
}
return parent::createRunner();
} | php | protected function createRunner(): BaseRunner
{
$listener = new SymfonyTestsListener();
$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];
$registeredLocally = false;
foreach ($this->arguments['listeners'] as $registeredListener) {
if ($registeredListener instanceof SymfonyTestsListener) {
$registeredListener->globalListenerDisabled();
$registeredLocally = true;
break;
}
}
if (!$registeredLocally) {
$this->arguments['listeners'][] = $listener;
}
return parent::createRunner();
} | [
"protected",
"function",
"createRunner",
"(",
")",
":",
"BaseRunner",
"{",
"$",
"listener",
"=",
"new",
"SymfonyTestsListener",
"(",
")",
";",
"$",
"this",
"->",
"arguments",
"[",
"'listeners'",
"]",
"=",
"isset",
"(",
"$",
"this",
"->",
"arguments",
"[",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php#L28-L49 | train | Creates the runner. | [
30522,
5123,
3853,
3443,
23195,
1006,
1007,
1024,
2918,
23195,
1063,
1002,
19373,
1027,
2047,
25353,
2213,
14876,
4890,
22199,
14540,
27870,
3678,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
9918,
1031,
1005,
13810,
1005,
1033,
1027,
26354,
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/Auth/SessionGuard.php | SessionGuard.fireFailedEvent | protected function fireFailedEvent($user, array $credentials)
{
if (isset($this->events)) {
$this->events->dispatch(new Events\Failed(
$this->name, $user, $credentials
));
}
} | php | protected function fireFailedEvent($user, array $credentials)
{
if (isset($this->events)) {
$this->events->dispatch(new Events\Failed(
$this->name, $user, $credentials
));
}
} | [
"protected",
"function",
"fireFailedEvent",
"(",
"$",
"user",
",",
"array",
"$",
"credentials",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
")",
")",
"{",
"$",
"this",
"->",
"events",
"->",
"dispatch",
"(",
"new",
"Events",
"\\",
... | Fire the failed authentication attempt event with the given arguments.
@param \Illuminate\Contracts\Auth\Authenticatable|null $user
@param array $credentials
@return void | [
"Fire",
"the",
"failed",
"authentication",
"attempt",
"event",
"with",
"the",
"given",
"arguments",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/SessionGuard.php#L645-L652 | train | Fires failed event | [
30522,
5123,
3853,
2543,
7011,
18450,
18697,
3372,
1006,
1002,
5310,
1010,
9140,
1002,
22496,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2824,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
2824,
1011,
1028,
18365,
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/Common.php | Common.getContinent | public static function getContinent($country)
{
/** @var RegionDataProvider $dataProvider */
$dataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$countryList = $dataProvider->getCountryList();
if ($country == 'ti') {
$country = 'cn';
}
return isset($countryList[$country]) ? $countryList[$country] : 'unk';
} | php | public static function getContinent($country)
{
/** @var RegionDataProvider $dataProvider */
$dataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$countryList = $dataProvider->getCountryList();
if ($country == 'ti') {
$country = 'cn';
}
return isset($countryList[$country]) ? $countryList[$country] : 'unk';
} | [
"public",
"static",
"function",
"getContinent",
"(",
"$",
"country",
")",
"{",
"/** @var RegionDataProvider $dataProvider */",
"$",
"dataProvider",
"=",
"StaticContainer",
"::",
"get",
"(",
"'Piwik\\Intl\\Data\\Provider\\RegionDataProvider'",
")",
";",
"$",
"countryList",
... | Returns the continent of a given country
@param string $country 2 letters iso code
@return string Continent (3 letters code : afr, asi, eur, amn, ams, oce) | [
"Returns",
"the",
"continent",
"of",
"a",
"given",
"country"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Common.php#L1073-L1085 | train | Get continent code for a country | [
30522,
2270,
10763,
3853,
2131,
8663,
10196,
3372,
1006,
1002,
2406,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
2555,
2850,
2696,
21572,
17258,
2121,
1002,
2951,
21572,
17258,
2121,
1008,
1013,
30524,
2140,
1032,
2951,
1032,
10802,
1032,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.objectUrl | public function objectUrl($path)
{
if (URL::isValidUrl($path)) {
return $path;
}
if ($this->storage) {
return $this->storage->url($path);
}
return Storage::disk(config('admin.upload.disk'))->url($path);
} | php | public function objectUrl($path)
{
if (URL::isValidUrl($path)) {
return $path;
}
if ($this->storage) {
return $this->storage->url($path);
}
return Storage::disk(config('admin.upload.disk'))->url($path);
} | [
"public",
"function",
"objectUrl",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"URL",
"::",
"isValidUrl",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"storage",
")",
"{",
"return",
"$",
"this",
"->",... | Get file visit url.
@param $path
@return string | [
"Get",
"file",
"visit",
"url",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/UploadField.php#L327-L338 | train | Return the object s URL | [
30522,
2270,
3853,
4874,
3126,
2140,
1006,
1002,
4130,
1007,
1063,
2065,
1006,
24471,
2140,
1024,
1024,
2003,
10175,
3593,
3126,
2140,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
1002,
4130,
1025,
1065,
2065,
1006,
1002,
2023,
1011,
1028,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Session/SaveHandler/DbTable.php | DbTable.gc | public function gc($maxlifetime)
{
$sql = 'DELETE FROM ' . $this->config['name']
. ' WHERE ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' < ?';
$this->query($sql, array(time()));
return true;
} | php | public function gc($maxlifetime)
{
$sql = 'DELETE FROM ' . $this->config['name']
. ' WHERE ' . $this->config['modifiedColumn'] . ' + ' . $this->config['lifetimeColumn'] . ' < ?';
$this->query($sql, array(time()));
return true;
} | [
"public",
"function",
"gc",
"(",
"$",
"maxlifetime",
")",
"{",
"$",
"sql",
"=",
"'DELETE FROM '",
".",
"$",
"this",
"->",
"config",
"[",
"'name'",
"]",
".",
"' WHERE '",
".",
"$",
"this",
"->",
"config",
"[",
"'modifiedColumn'",
"]",
".",
"' + '",
".",... | Garbage Collection - remove old session data older
than $maxlifetime (in seconds)
@param int $maxlifetime timestamp in seconds
@return bool always true | [
"Garbage",
"Collection",
"-",
"remove",
"old",
"session",
"data",
"older",
"than",
"$maxlifetime",
"(",
"in",
"seconds",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Session/SaveHandler/DbTable.php#L173-L181 | train | Garbage collector for all records in the table that have been modified earlier than the maxlifetime | [
30522,
2270,
3853,
1043,
2278,
1006,
1002,
4098,
15509,
7292,
1007,
1063,
1002,
29296,
1027,
1005,
3972,
12870,
2013,
1005,
1012,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1031,
1005,
2171,
1005,
1033,
1012,
1005,
2073,
1005,
1012,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php | FormValidator.getValidationGroups | private static function getValidationGroups(FormInterface $form)
{
// Determine the clicked button of the complete form tree
$clickedButton = null;
if (method_exists($form, 'getClickedButton')) {
$clickedButton = $form->getClickedButton();
}
if (null !== $clickedButton) {
$groups = $clickedButton->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
}
do {
$groups = $form->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
$form = $form->getParent();
} while (null !== $form);
return [Constraint::DEFAULT_GROUP];
} | php | private static function getValidationGroups(FormInterface $form)
{
// Determine the clicked button of the complete form tree
$clickedButton = null;
if (method_exists($form, 'getClickedButton')) {
$clickedButton = $form->getClickedButton();
}
if (null !== $clickedButton) {
$groups = $clickedButton->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
}
do {
$groups = $form->getConfig()->getOption('validation_groups');
if (null !== $groups) {
return self::resolveValidationGroups($groups, $form);
}
$form = $form->getParent();
} while (null !== $form);
return [Constraint::DEFAULT_GROUP];
} | [
"private",
"static",
"function",
"getValidationGroups",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"// Determine the clicked button of the complete form tree",
"$",
"clickedButton",
"=",
"null",
";",
"if",
"(",
"method_exists",
"(",
"$",
"form",
",",
"'getClickedButto... | Returns the validation groups of the given form.
@return string|GroupSequence|(string|GroupSequence)[] The validation groups | [
"Returns",
"the",
"validation",
"groups",
"of",
"the",
"given",
"form",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php#L153-L181 | train | Returns the validation groups of the complete form tree | [
30522,
2797,
10763,
3853,
2131,
10175,
8524,
3508,
17058,
2015,
1006,
2433,
18447,
2121,
12172,
1002,
2433,
1007,
1063,
1013,
1013,
5646,
1996,
13886,
6462,
1997,
1996,
3143,
2433,
3392,
1002,
13886,
8569,
15474,
1027,
19701,
1025,
2065,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Hashing/Argon2IdHasher.php | Argon2IdHasher.check | public function check($value, $hashedValue, array $options = [])
{
if ($this->verifyAlgorithm && $this->info($hashedValue)['algoName'] !== 'argon2id') {
throw new RuntimeException('This password does not use the Argon2id algorithm.');
}
if (strlen($hashedValue) === 0) {
return false;
}
return password_verify($value, $hashedValue);
} | php | public function check($value, $hashedValue, array $options = [])
{
if ($this->verifyAlgorithm && $this->info($hashedValue)['algoName'] !== 'argon2id') {
throw new RuntimeException('This password does not use the Argon2id algorithm.');
}
if (strlen($hashedValue) === 0) {
return false;
}
return password_verify($value, $hashedValue);
} | [
"public",
"function",
"check",
"(",
"$",
"value",
",",
"$",
"hashedValue",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"verifyAlgorithm",
"&&",
"$",
"this",
"->",
"info",
"(",
"$",
"hashedValue",
")",
"[",
"... | Check the given plain value against a hash.
@param string $value
@param string $hashedValue
@param array $options
@return bool | [
"Check",
"the",
"given",
"plain",
"value",
"against",
"a",
"hash",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Hashing/Argon2IdHasher.php#L17-L28 | train | Checks if the password matches the Argon2id algorithm | [
30522,
2270,
3853,
4638,
1006,
1002,
3643,
1010,
1002,
23325,
2098,
10175,
5657,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
20410,
2389,
20255,
8939,
2213,
1004,
1004,
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... |
z-song/laravel-admin | src/Show.php | Show.handleRelationField | protected function handleRelationField($method, $arguments)
{
if (!method_exists($this->model, $method)) {
return false;
}
if (!($relation = $this->model->$method()) instanceof EloquentRelation) {
return false;
}
if ($relation instanceof HasOne
|| $relation instanceof BelongsTo
|| $relation instanceof MorphOne
) {
$this->model->with($method);
if (count($arguments) == 1 && $arguments[0] instanceof \Closure) {
return $this->addRelation($method, $arguments[0]);
}
if (count($arguments) == 2 && $arguments[1] instanceof \Closure) {
return $this->addRelation($method, $arguments[1], $arguments[0]);
}
return $this->addField($method, Arr::get($arguments, 0))->setRelation(Str::snake($method));
}
if ($relation instanceof HasMany
|| $relation instanceof MorphMany
|| $relation instanceof BelongsToMany
|| $relation instanceof HasManyThrough
) {
if (empty($arguments) || (count($arguments) == 1 && is_string($arguments[0]))) {
return $this->showRelationAsField($method, $arguments[0] ?? '');
}
$this->model->with($method);
if (count($arguments) == 1 && is_callable($arguments[0])) {
return $this->addRelation($method, $arguments[0]);
} elseif (count($arguments) == 2 && is_callable($arguments[1])) {
return $this->addRelation($method, $arguments[1], $arguments[0]);
}
throw new \InvalidArgumentException('Invalid eloquent relation');
}
return false;
} | php | protected function handleRelationField($method, $arguments)
{
if (!method_exists($this->model, $method)) {
return false;
}
if (!($relation = $this->model->$method()) instanceof EloquentRelation) {
return false;
}
if ($relation instanceof HasOne
|| $relation instanceof BelongsTo
|| $relation instanceof MorphOne
) {
$this->model->with($method);
if (count($arguments) == 1 && $arguments[0] instanceof \Closure) {
return $this->addRelation($method, $arguments[0]);
}
if (count($arguments) == 2 && $arguments[1] instanceof \Closure) {
return $this->addRelation($method, $arguments[1], $arguments[0]);
}
return $this->addField($method, Arr::get($arguments, 0))->setRelation(Str::snake($method));
}
if ($relation instanceof HasMany
|| $relation instanceof MorphMany
|| $relation instanceof BelongsToMany
|| $relation instanceof HasManyThrough
) {
if (empty($arguments) || (count($arguments) == 1 && is_string($arguments[0]))) {
return $this->showRelationAsField($method, $arguments[0] ?? '');
}
$this->model->with($method);
if (count($arguments) == 1 && is_callable($arguments[0])) {
return $this->addRelation($method, $arguments[0]);
} elseif (count($arguments) == 2 && is_callable($arguments[1])) {
return $this->addRelation($method, $arguments[1], $arguments[0]);
}
throw new \InvalidArgumentException('Invalid eloquent relation');
}
return false;
} | [
"protected",
"function",
"handleRelationField",
"(",
"$",
"method",
",",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"model",
",",
"$",
"method",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"("... | Handle relation field.
@param string $method
@param array $arguments
@return $this|bool|Relation|Field | [
"Handle",
"relation",
"field",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show.php#L427-L475 | train | Handle relation field | [
30522,
5123,
3853,
28213,
10581,
3508,
3790,
1006,
1002,
4118,
1010,
1002,
9918,
1007,
1063,
2065,
1006,
999,
4118,
1035,
6526,
1006,
1002,
2023,
1011,
1028,
2944,
1010,
1002,
4118,
1007,
1007,
1063,
2709,
30524,
1006,
1007,
1007,
6013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Table/Abstract.php | Zend_Db_Table_Abstract._setupDatabaseAdapter | protected function _setupDatabaseAdapter()
{
if (! $this->_db) {
$this->_db = self::getDefaultAdapter();
if (!$this->_db instanceof Zend_Db_Adapter_Abstract) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this));
}
}
} | php | protected function _setupDatabaseAdapter()
{
if (! $this->_db) {
$this->_db = self::getDefaultAdapter();
if (!$this->_db instanceof Zend_Db_Adapter_Abstract) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this));
}
}
} | [
"protected",
"function",
"_setupDatabaseAdapter",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_db",
")",
"{",
"$",
"this",
"->",
"_db",
"=",
"self",
"::",
"getDefaultAdapter",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_db",
"instanceo... | Initialize database adapter.
@return void
@throws Zend_Db_Table_Exception | [
"Initialize",
"database",
"adapter",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Abstract.php#L749-L758 | train | Setup database adapter | [
30522,
5123,
3853,
1035,
16437,
2850,
2696,
15058,
8447,
13876,
2121,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
16962,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
16962,
1027,
2969,
1024,
1024,
2131,
3207,
7011,
11314,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreUpdater/UpdateCommunication.php | UpdateCommunication.isEnabled | public function isEnabled()
{
$isEnabled = (bool) Config::getInstance()->General['enable_update_communication'];
if($isEnabled === true && SettingsPiwik::isInternetEnabled() === true){
return true;
}
return false;
} | php | public function isEnabled()
{
$isEnabled = (bool) Config::getInstance()->General['enable_update_communication'];
if($isEnabled === true && SettingsPiwik::isInternetEnabled() === true){
return true;
}
return false;
} | [
"public",
"function",
"isEnabled",
"(",
")",
"{",
"$",
"isEnabled",
"=",
"(",
"bool",
")",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"General",
"[",
"'enable_update_communication'",
"]",
";",
"if",
"(",
"$",
"isEnabled",
"===",
"true",
"&&",
"Settings... | Checks whether update communication in general is enabled or not.
@return bool | [
"Checks",
"whether",
"update",
"communication",
"in",
"general",
"is",
"enabled",
"or",
"not",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreUpdater/UpdateCommunication.php#L32-L41 | train | Check if update communication is enabled | [
30522,
2270,
3853,
2003,
8189,
23242,
1006,
1007,
1063,
1002,
2003,
8189,
23242,
1027,
1006,
22017,
2140,
1007,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2236,
1031,
1005,
9585,
1035,
10651,
1035,
4807,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Mailer/Transport/Smtp/Auth/CramMd5Authenticator.php | CramMd5Authenticator.getResponse | private function getResponse(string $secret, string $challenge): string
{
if (\strlen($secret) > 64) {
$secret = pack('H32', md5($secret));
}
if (\strlen($secret) < 64) {
$secret = str_pad($secret, 64, \chr(0));
}
$kipad = substr($secret, 0, 64) ^ str_repeat(\chr(0x36), 64);
$kopad = substr($secret, 0, 64) ^ str_repeat(\chr(0x5C), 64);
$inner = pack('H32', md5($kipad.$challenge));
$digest = md5($kopad.$inner);
return $digest;
} | php | private function getResponse(string $secret, string $challenge): string
{
if (\strlen($secret) > 64) {
$secret = pack('H32', md5($secret));
}
if (\strlen($secret) < 64) {
$secret = str_pad($secret, 64, \chr(0));
}
$kipad = substr($secret, 0, 64) ^ str_repeat(\chr(0x36), 64);
$kopad = substr($secret, 0, 64) ^ str_repeat(\chr(0x5C), 64);
$inner = pack('H32', md5($kipad.$challenge));
$digest = md5($kopad.$inner);
return $digest;
} | [
"private",
"function",
"getResponse",
"(",
"string",
"$",
"secret",
",",
"string",
"$",
"challenge",
")",
":",
"string",
"{",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"secret",
")",
">",
"64",
")",
"{",
"$",
"secret",
"=",
"pack",
"(",
"'H32'",
",",
"m... | Generates a CRAM-MD5 response from a server challenge. | [
"Generates",
"a",
"CRAM",
"-",
"MD5",
"response",
"from",
"a",
"server",
"challenge",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mailer/Transport/Smtp/Auth/CramMd5Authenticator.php#L46-L63 | train | Generate the response from the server | [
30522,
2797,
3853,
2131,
6072,
26029,
3366,
1006,
5164,
1002,
3595,
1010,
5164,
1002,
4119,
1007,
1024,
5164,
1063,
2065,
1006,
1032,
2358,
20927,
2078,
1006,
1002,
3595,
1007,
1028,
4185,
1007,
1063,
1002,
3595,
1027,
5308,
1006,
1005,
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... |
octobercms/october | modules/system/classes/VersionManager.php | VersionManager.hasDatabaseHistory | protected function hasDatabaseHistory($code, $version, $script = null)
{
$historyInfo = $this->getDatabaseHistory($code);
if (!$historyInfo) {
return false;
}
foreach ($historyInfo as $history) {
if ($history->version != $version) {
continue;
}
if ($history->type == self::HISTORY_TYPE_COMMENT && !$script) {
return true;
}
if ($history->type == self::HISTORY_TYPE_SCRIPT && $history->detail == $script) {
return true;
}
}
return false;
} | php | protected function hasDatabaseHistory($code, $version, $script = null)
{
$historyInfo = $this->getDatabaseHistory($code);
if (!$historyInfo) {
return false;
}
foreach ($historyInfo as $history) {
if ($history->version != $version) {
continue;
}
if ($history->type == self::HISTORY_TYPE_COMMENT && !$script) {
return true;
}
if ($history->type == self::HISTORY_TYPE_SCRIPT && $history->detail == $script) {
return true;
}
}
return false;
} | [
"protected",
"function",
"hasDatabaseHistory",
"(",
"$",
"code",
",",
"$",
"version",
",",
"$",
"script",
"=",
"null",
")",
"{",
"$",
"historyInfo",
"=",
"$",
"this",
"->",
"getDatabaseHistory",
"(",
"$",
"code",
")",
";",
"if",
"(",
"!",
"$",
"history... | Checks if a plugin has an applied update version. | [
"Checks",
"if",
"a",
"plugin",
"has",
"an",
"applied",
"update",
"version",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/VersionManager.php#L449-L471 | train | Has database history | [
30522,
5123,
3853,
2038,
2850,
2696,
15058,
24158,
7062,
1006,
1002,
3642,
1010,
1002,
2544,
1010,
1002,
5896,
1027,
19701,
1007,
1063,
1002,
2381,
2378,
14876,
1027,
1002,
2023,
1011,
1028,
2131,
2850,
2696,
15058,
24158,
7062,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.getTargetDimensions | protected function getTargetDimensions($width, $height, $originalImagePath)
{
$originalDimensions = [$width, $height];
try {
$dimensions = getimagesize($originalImagePath);
if (!$dimensions) {
return $originalDimensions;
}
if ($dimensions[0] > $width || $dimensions[1] > $height) {
return $originalDimensions;
}
return $dimensions;
}
catch (Exception $ex) {
return $originalDimensions;
}
} | php | protected function getTargetDimensions($width, $height, $originalImagePath)
{
$originalDimensions = [$width, $height];
try {
$dimensions = getimagesize($originalImagePath);
if (!$dimensions) {
return $originalDimensions;
}
if ($dimensions[0] > $width || $dimensions[1] > $height) {
return $originalDimensions;
}
return $dimensions;
}
catch (Exception $ex) {
return $originalDimensions;
}
} | [
"protected",
"function",
"getTargetDimensions",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"originalImagePath",
")",
"{",
"$",
"originalDimensions",
"=",
"[",
"$",
"width",
",",
"$",
"height",
"]",
";",
"try",
"{",
"$",
"dimensions",
"=",
"getimagesi... | Get target dimensions
@param int $width
@param int $height
@param string $originalImagePath
@return void | [
"Get",
"target",
"dimensions"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L1453-L1472 | train | Returns target dimensions | [
30522,
5123,
3853,
2131,
7559,
18150,
22172,
6132,
8496,
1006,
1002,
9381,
1010,
1002,
4578,
1010,
1002,
2434,
9581,
3351,
15069,
1007,
1063,
1002,
2434,
22172,
6132,
8496,
1027,
1031,
1002,
9381,
1010,
1002,
4578,
1033,
1025,
3046,
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/Security/Http/RememberMe/AbstractRememberMeServices.php | AbstractRememberMeServices.logout | public function logout(Request $request, Response $response, TokenInterface $token)
{
$this->cancelCookie($request);
} | php | public function logout(Request $request, Response $response, TokenInterface $token)
{
$this->cancelCookie($request);
} | [
"public",
"function",
"logout",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"cancelCookie",
"(",
"$",
"request",
")",
";",
"}"
] | Implementation for LogoutHandlerInterface. Deletes the cookie. | [
"Implementation",
"for",
"LogoutHandlerInterface",
".",
"Deletes",
"the",
"cookie",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/RememberMe/AbstractRememberMeServices.php#L152-L155 | train | Logouts the user. | [
30522,
2270,
3853,
8154,
4904,
1006,
5227,
1002,
5227,
1010,
3433,
1002,
3433,
1010,
19204,
18447,
2121,
12172,
1002,
19204,
1007,
30524,
5227,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/CustomerService/Messenger.php | Messenger.message | public function message($message)
{
if (is_string($message)) {
$message = new Text($message);
}
$this->message = $message;
return $this;
} | php | public function message($message)
{
if (is_string($message)) {
$message = new Text($message);
}
$this->message = $message;
return $this;
} | [
"public",
"function",
"message",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"new",
"Text",
"(",
"$",
"message",
")",
";",
"}",
"$",
"this",
"->",
"message",
"=",
"$",
"message",
... | Set message to send.
@param string|Message $message
@return Messenger | [
"Set",
"message",
"to",
"send",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/CustomerService/Messenger.php#L71-L80 | train | Set the message | [
30522,
2270,
3853,
4471,
1006,
1002,
4471,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
4471,
1007,
1007,
1063,
1002,
4471,
1027,
2047,
3793,
1006,
1002,
4471,
1007,
1025,
1065,
1002,
2023,
1011,
1028,
4471,
1027,
1002,
4471,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/API.php | API.getUserLoginFromUserEmail | public function getUserLoginFromUserEmail($userEmail)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeAdminAccess();
$this->checkUserEmailExists($userEmail);
$user = $this->model->getUserByEmail($userEmail);
// any user with some admin access is allowed to find any user by email, no need to filter by access here
return $user['login'];
} | php | public function getUserLoginFromUserEmail($userEmail)
{
Piwik::checkUserIsNotAnonymous();
Piwik::checkUserHasSomeAdminAccess();
$this->checkUserEmailExists($userEmail);
$user = $this->model->getUserByEmail($userEmail);
// any user with some admin access is allowed to find any user by email, no need to filter by access here
return $user['login'];
} | [
"public",
"function",
"getUserLoginFromUserEmail",
"(",
"$",
"userEmail",
")",
"{",
"Piwik",
"::",
"checkUserIsNotAnonymous",
"(",
")",
";",
"Piwik",
"::",
"checkUserHasSomeAdminAccess",
"(",
")",
";",
"$",
"this",
"->",
"checkUserEmailExists",
"(",
"$",
"userEmai... | Returns the first login name of an existing user that has the given email address. If no user can be found for
this user an error will be returned.
@param string $userEmail
@return bool true if the user is known | [
"Returns",
"the",
"first",
"login",
"name",
"of",
"an",
"existing",
"user",
"that",
"has",
"the",
"given",
"email",
"address",
".",
"If",
"no",
"user",
"can",
"be",
"found",
"for",
"this",
"user",
"an",
"error",
"will",
"be",
"returned",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/API.php#L1012-L1024 | train | Returns the user login from the given email | [
30522,
2270,
3853,
2131,
20330,
21197,
2378,
19699,
5358,
20330,
14545,
4014,
1006,
1002,
5310,
14545,
4014,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
2483,
17048,
6761,
4890,
27711,
1006,
1007,
1025,
14255,
9148,
2243,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Filter/Truncate.php | Truncate.filter | public function filter($table)
{
if ($this->truncateAfter < 0) {
return;
}
$this->addSummaryRow($table);
$table->queueFilter('ReplaceSummaryRowLabel', array($this->labelSummaryRow));
if ($this->filterRecursive) {
foreach ($table->getRowsWithoutSummaryRow() as $row) {
if ($row->isSubtableLoaded()) {
$this->filter($row->getSubtable());
}
}
}
} | php | public function filter($table)
{
if ($this->truncateAfter < 0) {
return;
}
$this->addSummaryRow($table);
$table->queueFilter('ReplaceSummaryRowLabel', array($this->labelSummaryRow));
if ($this->filterRecursive) {
foreach ($table->getRowsWithoutSummaryRow() as $row) {
if ($row->isSubtableLoaded()) {
$this->filter($row->getSubtable());
}
}
}
} | [
"public",
"function",
"filter",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"truncateAfter",
"<",
"0",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"addSummaryRow",
"(",
"$",
"table",
")",
";",
"$",
"table",
"->",
"queueFilter",
... | Executes the filter, see {@link Truncate}.
@param DataTable $table | [
"Executes",
"the",
"filter",
"see",
"{",
"@link",
"Truncate",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/Truncate.php#L70-L86 | train | Filter the table | [
30522,
2270,
3853,
11307,
1006,
1002,
2795,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
19817,
4609,
16280,
10354,
3334,
1026,
1014,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
9909,
2819,
7849,
12541,
5004,
1006,
1002,
2795,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Common.php | Common.hash | public static function hash($str, $raw_output = false)
{
static $hashAlgorithm = null;
if (is_null($hashAlgorithm)) {
$hashAlgorithm = @Config::getInstance()->General['hash_algorithm'];
}
if ($hashAlgorithm) {
$hash = @hash($hashAlgorithm, $str, $raw_output);
if ($hash !== false) {
return $hash;
}
}
return md5($str, $raw_output);
} | php | public static function hash($str, $raw_output = false)
{
static $hashAlgorithm = null;
if (is_null($hashAlgorithm)) {
$hashAlgorithm = @Config::getInstance()->General['hash_algorithm'];
}
if ($hashAlgorithm) {
$hash = @hash($hashAlgorithm, $str, $raw_output);
if ($hash !== false) {
return $hash;
}
}
return md5($str, $raw_output);
} | [
"public",
"static",
"function",
"hash",
"(",
"$",
"str",
",",
"$",
"raw_output",
"=",
"false",
")",
"{",
"static",
"$",
"hashAlgorithm",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"hashAlgorithm",
")",
")",
"{",
"$",
"hashAlgorithm",
"=",
"@",
... | Configurable hash() algorithm (defaults to md5)
@param string $str String to be hashed
@param bool $raw_output
@return string Hash string | [
"Configurable",
"hash",
"()",
"algorithm",
"(",
"defaults",
"to",
"md5",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Common.php#L618-L634 | train | Hash a string | [
30522,
2270,
10763,
3853,
23325,
1006,
1002,
2358,
2099,
1010,
1002,
6315,
1035,
6434,
1027,
6270,
1007,
1063,
10763,
1002,
23325,
2389,
20255,
8939,
2213,
1027,
19701,
1025,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
23325,
2389,
20255,
89... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Data/Validation.php | Validation.typeText | public static function typeText($value, array $params, array $field)
{
if (!\is_string($value) && !is_numeric($value)) {
return false;
}
$value = (string)$value;
if (!empty($params['trim'])) {
$value = trim($value);
}
if (isset($params['min']) && \strlen($value) < $params['min']) {
return false;
}
if (isset($params['max']) && \strlen($value) > $params['max']) {
return false;
}
$min = $params['min'] ?? 0;
if (isset($params['step']) && (\strlen($value) - $min) % $params['step'] === 0) {
return false;
}
if ((!isset($params['multiline']) || !$params['multiline']) && preg_match('/\R/um', $value)) {
return false;
}
return true;
} | php | public static function typeText($value, array $params, array $field)
{
if (!\is_string($value) && !is_numeric($value)) {
return false;
}
$value = (string)$value;
if (!empty($params['trim'])) {
$value = trim($value);
}
if (isset($params['min']) && \strlen($value) < $params['min']) {
return false;
}
if (isset($params['max']) && \strlen($value) > $params['max']) {
return false;
}
$min = $params['min'] ?? 0;
if (isset($params['step']) && (\strlen($value) - $min) % $params['step'] === 0) {
return false;
}
if ((!isset($params['multiline']) || !$params['multiline']) && preg_match('/\R/um', $value)) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"typeText",
"(",
"$",
"value",
",",
"array",
"$",
"params",
",",
"array",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"value",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
... | HTML5 input: text
@param mixed $value Value to be validated.
@param array $params Validation parameters.
@param array $field Blueprint for the field.
@return bool True if validation succeeded. | [
"HTML5",
"input",
":",
"text"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Validation.php#L123-L153 | train | TypeText - Returns TRUE if the value is a text. | [
30522,
2270,
10763,
3853,
2828,
18209,
1006,
1002,
3643,
1010,
9140,
1002,
11498,
5244,
1010,
9140,
1002,
2492,
1007,
1063,
2065,
1006,
999,
1032,
2003,
1035,
5164,
1006,
1002,
3643,
1007,
1004,
1004,
999,
2003,
1035,
16371,
25531,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Route.php | Route.prepareForSerialization | public function prepareForSerialization()
{
if ($this->action['uses'] instanceof Closure) {
throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
}
$this->compileRoute();
unset($this->router, $this->container);
} | php | public function prepareForSerialization()
{
if ($this->action['uses'] instanceof Closure) {
throw new LogicException("Unable to prepare route [{$this->uri}] for serialization. Uses Closure.");
}
$this->compileRoute();
unset($this->router, $this->container);
} | [
"public",
"function",
"prepareForSerialization",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"action",
"[",
"'uses'",
"]",
"instanceof",
"Closure",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"Unable to prepare route [{$this->uri}] for serialization. Uses Closur... | Prepare the route instance for serialization.
@return void
@throws \LogicException | [
"Prepare",
"the",
"route",
"instance",
"for",
"serialization",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Route.php#L914-L923 | train | Prepares route for serialization | [
30522,
2270,
3853,
7374,
29278,
8043,
4818,
3989,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2895,
1031,
1005,
3594,
1005,
1033,
6013,
11253,
8503,
1007,
1063,
5466,
2047,
7961,
10288,
24422,
1006,
1000,
4039,
2000,
7374,
2799,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/NavigationManager.php | NavigationManager.removeMainMenuItem | public function removeMainMenuItem($owner, $code)
{
$itemKey = $this->makeItemKey($owner, $code);
unset($this->items[$itemKey]);
} | php | public function removeMainMenuItem($owner, $code)
{
$itemKey = $this->makeItemKey($owner, $code);
unset($this->items[$itemKey]);
} | [
"public",
"function",
"removeMainMenuItem",
"(",
"$",
"owner",
",",
"$",
"code",
")",
"{",
"$",
"itemKey",
"=",
"$",
"this",
"->",
"makeItemKey",
"(",
"$",
"owner",
",",
"$",
"code",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"it... | Removes a single main menu item | [
"Removes",
"a",
"single",
"main",
"menu",
"item"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/NavigationManager.php#L235-L239 | train | Remove a main menu item | [
30522,
2270,
3853,
6366,
24238,
3549,
14663,
6633,
1006,
1002,
3954,
1010,
1002,
3642,
1007,
1063,
1002,
8875,
14839,
1027,
1002,
2023,
1011,
1028,
2191,
4221,
2213,
14839,
1006,
1002,
3954,
1010,
1002,
3642,
1007,
1025,
4895,
13462,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Process/Process.php | Process.updateStatus | protected function updateStatus($blocking)
{
if (self::STATUS_STARTED !== $this->status) {
return;
}
$this->processInformation = proc_get_status($this->process);
$running = $this->processInformation['running'];
$this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
if ($this->fallbackStatus && $this->isSigchildEnabled()) {
$this->processInformation = $this->fallbackStatus + $this->processInformation;
}
if (!$running) {
$this->close();
}
} | php | protected function updateStatus($blocking)
{
if (self::STATUS_STARTED !== $this->status) {
return;
}
$this->processInformation = proc_get_status($this->process);
$running = $this->processInformation['running'];
$this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
if ($this->fallbackStatus && $this->isSigchildEnabled()) {
$this->processInformation = $this->fallbackStatus + $this->processInformation;
}
if (!$running) {
$this->close();
}
} | [
"protected",
"function",
"updateStatus",
"(",
"$",
"blocking",
")",
"{",
"if",
"(",
"self",
"::",
"STATUS_STARTED",
"!==",
"$",
"this",
"->",
"status",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"processInformation",
"=",
"proc_get_status",
"(",
"$",... | Updates the status of the process, reads pipes.
@param bool $blocking Whether to use a blocking read call | [
"Updates",
"the",
"status",
"of",
"the",
"process",
"reads",
"pipes",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L1337-L1355 | train | Update status of the process | [
30522,
5123,
3853,
14409,
29336,
2271,
1006,
1002,
10851,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
3570,
1035,
2318,
999,
1027,
1027,
1002,
2023,
1011,
1028,
3570,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
2832,
2378,
14192,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getHeaderValue | public function getHeaderValue($column)
{
$value = Lang::get($column->label);
/**
* @event backend.list.overrideHeaderValue
* Overrides the column header value in a list widget.
*
* If a value is returned from this event, it will be used as the value for the provided column.
* `$value` is passed by reference so modifying the variable in place is also supported. Example usage:
*
* Event::listen('backend.list.overrideHeaderValue', function($listWidget, $column, &$value) {
* $value .= '-modified';
* });
*
* Or
*
* $listWidget->bindEvent('list.overrideHeaderValue', function ($column, $value) {
* return 'Custom header value';
* });
*
*/
if ($response = $this->fireSystemEvent('backend.list.overrideHeaderValue', [$column, &$value])) {
$value = $response;
}
return $value;
} | php | public function getHeaderValue($column)
{
$value = Lang::get($column->label);
/**
* @event backend.list.overrideHeaderValue
* Overrides the column header value in a list widget.
*
* If a value is returned from this event, it will be used as the value for the provided column.
* `$value` is passed by reference so modifying the variable in place is also supported. Example usage:
*
* Event::listen('backend.list.overrideHeaderValue', function($listWidget, $column, &$value) {
* $value .= '-modified';
* });
*
* Or
*
* $listWidget->bindEvent('list.overrideHeaderValue', function ($column, $value) {
* return 'Custom header value';
* });
*
*/
if ($response = $this->fireSystemEvent('backend.list.overrideHeaderValue', [$column, &$value])) {
$value = $response;
}
return $value;
} | [
"public",
"function",
"getHeaderValue",
"(",
"$",
"column",
")",
"{",
"$",
"value",
"=",
"Lang",
"::",
"get",
"(",
"$",
"column",
"->",
"label",
")",
";",
"/**\n * @event backend.list.overrideHeaderValue\n * Overrides the column header value in a list widget... | Looks up the column header | [
"Looks",
"up",
"the",
"column",
"header"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L932-L959 | train | Returns the value of a column header | [
30522,
2270,
3853,
2131,
4974,
2121,
10175,
5657,
1006,
1002,
5930,
1007,
1063,
1002,
3643,
1027,
11374,
1024,
1024,
2131,
1006,
1002,
5930,
1011,
1028,
3830,
1007,
1025,
1013,
1008,
1008,
1008,
1030,
2724,
2067,
10497,
1012,
2862,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/RedirectMiddleware.php | RedirectMiddleware.checkRedirect | public function checkRedirect(
RequestInterface $request,
array $options,
ResponseInterface $response
) {
if (substr($response->getStatusCode(), 0, 1) != '3'
|| !$response->hasHeader('Location')
) {
return $response;
}
$this->guardMax($request, $options);
$nextRequest = $this->modifyRequest($request, $options, $response);
if (isset($options['allow_redirects']['on_redirect'])) {
call_user_func(
$options['allow_redirects']['on_redirect'],
$request,
$response,
$nextRequest->getUri()
);
}
/** @var PromiseInterface|ResponseInterface $promise */
$promise = $this($nextRequest, $options);
// Add headers to be able to track history of redirects.
if (!empty($options['allow_redirects']['track_redirects'])) {
return $this->withTracking(
$promise,
(string) $nextRequest->getUri(),
$response->getStatusCode()
);
}
return $promise;
} | php | public function checkRedirect(
RequestInterface $request,
array $options,
ResponseInterface $response
) {
if (substr($response->getStatusCode(), 0, 1) != '3'
|| !$response->hasHeader('Location')
) {
return $response;
}
$this->guardMax($request, $options);
$nextRequest = $this->modifyRequest($request, $options, $response);
if (isset($options['allow_redirects']['on_redirect'])) {
call_user_func(
$options['allow_redirects']['on_redirect'],
$request,
$response,
$nextRequest->getUri()
);
}
/** @var PromiseInterface|ResponseInterface $promise */
$promise = $this($nextRequest, $options);
// Add headers to be able to track history of redirects.
if (!empty($options['allow_redirects']['track_redirects'])) {
return $this->withTracking(
$promise,
(string) $nextRequest->getUri(),
$response->getStatusCode()
);
}
return $promise;
} | [
"public",
"function",
"checkRedirect",
"(",
"RequestInterface",
"$",
"request",
",",
"array",
"$",
"options",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"0",
",",
"1... | @param RequestInterface $request
@param array $options
@param ResponseInterface|PromiseInterface $response
@return ResponseInterface|PromiseInterface | [
"@param",
"RequestInterface",
"$request",
"@param",
"array",
"$options",
"@param",
"ResponseInterface|PromiseInterface",
"$response"
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/RedirectMiddleware.php#L83-L119 | train | Check if the response is a redirect | [
30522,
2270,
3853,
4638,
5596,
7442,
6593,
1006,
5227,
18447,
2121,
12172,
1002,
5227,
1010,
9140,
1002,
7047,
1010,
3433,
18447,
2121,
12172,
1002,
3433,
1007,
1063,
2065,
1006,
4942,
3367,
2099,
1006,
1002,
3433,
1011,
1028,
4152,
29336,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php | DoctrineExtractor.getProperties | public function getProperties($class, array $context = [])
{
try {
$metadata = $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
} catch (MappingException $exception) {
return;
} catch (OrmMappingException $exception) {
return;
}
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && $metadata->embeddedClasses) {
$properties = array_filter($properties, function ($property) {
return false === strpos($property, '.');
});
$properties = array_merge($properties, array_keys($metadata->embeddedClasses));
}
return $properties;
} | php | public function getProperties($class, array $context = [])
{
try {
$metadata = $this->entityManager ? $this->entityManager->getClassMetadata($class) : $this->classMetadataFactory->getMetadataFor($class);
} catch (MappingException $exception) {
return;
} catch (OrmMappingException $exception) {
return;
}
$properties = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
if ($metadata instanceof ClassMetadataInfo && class_exists('Doctrine\ORM\Mapping\Embedded') && $metadata->embeddedClasses) {
$properties = array_filter($properties, function ($property) {
return false === strpos($property, '.');
});
$properties = array_merge($properties, array_keys($metadata->embeddedClasses));
}
return $properties;
} | [
"public",
"function",
"getProperties",
"(",
"$",
"class",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"entityManager",
"?",
"$",
"this",
"->",
"entityManager",
"->",
"getClassMetadata",
"(",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php#L52-L73 | train | Get all the properties of a class | [
30522,
2270,
3853,
2131,
21572,
4842,
7368,
1006,
1002,
2465,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
3046,
1063,
1002,
27425,
1027,
1002,
2023,
1011,
1028,
9178,
24805,
4590,
1029,
1002,
2023,
1011,
1028,
9178,
24805,
4590,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AssetManager.php | AssetManager.isMergedAssetsDisabled | public function isMergedAssetsDisabled()
{
if (Config::getInstance()->Development['disable_merged_assets'] == 1) {
return true;
}
if (isset($_GET['disable_merged_assets']) && $_GET['disable_merged_assets'] == 1) {
return true;
}
return false;
} | php | public function isMergedAssetsDisabled()
{
if (Config::getInstance()->Development['disable_merged_assets'] == 1) {
return true;
}
if (isset($_GET['disable_merged_assets']) && $_GET['disable_merged_assets'] == 1) {
return true;
}
return false;
} | [
"public",
"function",
"isMergedAssetsDisabled",
"(",
")",
"{",
"if",
"(",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"Development",
"[",
"'disable_merged_assets'",
"]",
"==",
"1",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_... | Return the global option disable_merged_assets
@return boolean | [
"Return",
"the",
"global",
"option",
"disable_merged_assets"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/AssetManager.php#L262-L273 | train | Return true if merged assets are disabled | [
30522,
2270,
3853,
2003,
5017,
5999,
27241,
3215,
10521,
3085,
2094,
1006,
1007,
1063,
2065,
1006,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2458,
1031,
1005,
4487,
19150,
1035,
5314,
1035,
7045,
1005,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Mapping/ClassMetadata.php | ClassMetadata.setGroupSequenceProvider | public function setGroupSequenceProvider($active)
{
if ($this->hasGroupSequence()) {
throw new GroupDefinitionException('Defining a group sequence provider is not allowed with a static group sequence');
}
if (!$this->getReflectionClass()->implementsInterface('Symfony\Component\Validator\GroupSequenceProviderInterface')) {
throw new GroupDefinitionException(sprintf('Class "%s" must implement GroupSequenceProviderInterface', $this->name));
}
$this->groupSequenceProvider = $active;
} | php | public function setGroupSequenceProvider($active)
{
if ($this->hasGroupSequence()) {
throw new GroupDefinitionException('Defining a group sequence provider is not allowed with a static group sequence');
}
if (!$this->getReflectionClass()->implementsInterface('Symfony\Component\Validator\GroupSequenceProviderInterface')) {
throw new GroupDefinitionException(sprintf('Class "%s" must implement GroupSequenceProviderInterface', $this->name));
}
$this->groupSequenceProvider = $active;
} | [
"public",
"function",
"setGroupSequenceProvider",
"(",
"$",
"active",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasGroupSequence",
"(",
")",
")",
"{",
"throw",
"new",
"GroupDefinitionException",
"(",
"'Defining a group sequence provider is not allowed with a static group s... | Sets whether a group sequence provider should be used.
@param bool $active
@throws GroupDefinitionException | [
"Sets",
"whether",
"a",
"group",
"sequence",
"provider",
"should",
"be",
"used",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Mapping/ClassMetadata.php#L461-L472 | train | Set the group sequence provider | [
30522,
2270,
3853,
2275,
17058,
3366,
4226,
5897,
21572,
17258,
2121,
1006,
1002,
3161,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2038,
17058,
3366,
4226,
5897,
1006,
1007,
1007,
1063,
5466,
2047,
2177,
3207,
16294,
22753,
10288,
2442... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/BelongsTo.php | BelongsTo.associate | public function associate($model)
{
$ownerKey = $model instanceof Model ? $model->getAttribute($this->ownerKey) : $model;
$this->child->setAttribute($this->foreignKey, $ownerKey);
if ($model instanceof Model) {
$this->child->setRelation($this->relationName, $model);
} elseif ($this->child->isDirty($this->foreignKey)) {
$this->child->unsetRelation($this->relationName);
}
return $this->child;
} | php | public function associate($model)
{
$ownerKey = $model instanceof Model ? $model->getAttribute($this->ownerKey) : $model;
$this->child->setAttribute($this->foreignKey, $ownerKey);
if ($model instanceof Model) {
$this->child->setRelation($this->relationName, $model);
} elseif ($this->child->isDirty($this->foreignKey)) {
$this->child->unsetRelation($this->relationName);
}
return $this->child;
} | [
"public",
"function",
"associate",
"(",
"$",
"model",
")",
"{",
"$",
"ownerKey",
"=",
"$",
"model",
"instanceof",
"Model",
"?",
"$",
"model",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"ownerKey",
")",
":",
"$",
"model",
";",
"$",
"this",
"->",
"c... | Associate the model instance to the given parent.
@param \Illuminate\Database\Eloquent\Model|int|string $model
@return \Illuminate\Database\Eloquent\Model | [
"Associate",
"the",
"model",
"instance",
"to",
"the",
"given",
"parent",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php#L213-L226 | train | Associate a child model with the owner model | [
30522,
2270,
3853,
5482,
1006,
1002,
2944,
1007,
1063,
1002,
3954,
14839,
1027,
1002,
2944,
6013,
11253,
2944,
1029,
1002,
2944,
1011,
1028,
2131,
19321,
3089,
8569,
2618,
1006,
1002,
2023,
1011,
1028,
3954,
14839,
1007,
1024,
1002,
2944,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorFromClassMetadata.php | ClassDiscriminatorFromClassMetadata.getMappingForClass | public function getMappingForClass(string $class): ?ClassDiscriminatorMapping
{
if ($this->classMetadataFactory->hasMetadataFor($class)) {
return $this->classMetadataFactory->getMetadataFor($class)->getClassDiscriminatorMapping();
}
return null;
} | php | public function getMappingForClass(string $class): ?ClassDiscriminatorMapping
{
if ($this->classMetadataFactory->hasMetadataFor($class)) {
return $this->classMetadataFactory->getMetadataFor($class)->getClassDiscriminatorMapping();
}
return null;
} | [
"public",
"function",
"getMappingForClass",
"(",
"string",
"$",
"class",
")",
":",
"?",
"ClassDiscriminatorMapping",
"{",
"if",
"(",
"$",
"this",
"->",
"classMetadataFactory",
"->",
"hasMetadataFor",
"(",
"$",
"class",
")",
")",
"{",
"return",
"$",
"this",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Mapping/ClassDiscriminatorFromClassMetadata.php#L35-L42 | train | Returns the discriminator mapping for the given class. | [
30522,
2270,
3853,
2131,
2863,
14853,
29278,
26266,
1006,
5164,
1002,
2465,
1007,
1024,
1029,
2465,
10521,
26775,
27605,
27413,
2863,
14853,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2465,
11368,
8447,
2696,
21450,
1011,
1028,
2038,
11368,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FactoryBuilder.php | FactoryBuilder.applyStates | protected function applyStates(array $definition, array $attributes = [])
{
foreach ($this->activeStates as $state) {
if (! isset($this->states[$this->class][$state])) {
if ($this->stateHasAfterCallback($state)) {
continue;
}
throw new InvalidArgumentException("Unable to locate [{$state}] state for [{$this->class}].");
}
$definition = array_merge(
$definition,
$this->stateAttributes($state, $attributes)
);
}
return $definition;
} | php | protected function applyStates(array $definition, array $attributes = [])
{
foreach ($this->activeStates as $state) {
if (! isset($this->states[$this->class][$state])) {
if ($this->stateHasAfterCallback($state)) {
continue;
}
throw new InvalidArgumentException("Unable to locate [{$state}] state for [{$this->class}].");
}
$definition = array_merge(
$definition,
$this->stateAttributes($state, $attributes)
);
}
return $definition;
} | [
"protected",
"function",
"applyStates",
"(",
"array",
"$",
"definition",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"activeStates",
"as",
"$",
"state",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"th... | Apply the active states to the model definition array.
@param array $definition
@param array $attributes
@return array
@throws \InvalidArgumentException | [
"Apply",
"the",
"active",
"states",
"to",
"the",
"model",
"definition",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/FactoryBuilder.php#L312-L330 | train | Apply states to the definition | [
30522,
5123,
3853,
6611,
9153,
4570,
1006,
9140,
1002,
6210,
1010,
9140,
1002,
12332,
1027,
1031,
1033,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
3161,
9153,
4570,
2004,
1002,
2110,
1007,
1063,
2065,
1006,
999,
26354,
3388,
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/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php | DoctrineDataCollector.sanitizeParam | private function sanitizeParam($var): array
{
if (\is_object($var)) {
$className = \get_class($var);
return method_exists($var, '__toString') ?
[sprintf('/* Object(%s): */"%s"', $className, $var->__toString()), false] :
[sprintf('/* Object(%s) */', $className), false];
}
if (\is_array($var)) {
$a = [];
$original = true;
foreach ($var as $k => $v) {
list($value, $orig) = $this->sanitizeParam($v);
$original = $original && $orig;
$a[$k] = $value;
}
return [$a, $original];
}
if (\is_resource($var)) {
return [sprintf('/* Resource(%s) */', get_resource_type($var)), false];
}
return [$var, true];
} | php | private function sanitizeParam($var): array
{
if (\is_object($var)) {
$className = \get_class($var);
return method_exists($var, '__toString') ?
[sprintf('/* Object(%s): */"%s"', $className, $var->__toString()), false] :
[sprintf('/* Object(%s) */', $className), false];
}
if (\is_array($var)) {
$a = [];
$original = true;
foreach ($var as $k => $v) {
list($value, $orig) = $this->sanitizeParam($v);
$original = $original && $orig;
$a[$k] = $value;
}
return [$a, $original];
}
if (\is_resource($var)) {
return [sprintf('/* Resource(%s) */', get_resource_type($var)), false];
}
return [$var, true];
} | [
"private",
"function",
"sanitizeParam",
"(",
"$",
"var",
")",
":",
"array",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"var",
")",
")",
"{",
"$",
"className",
"=",
"\\",
"get_class",
"(",
"$",
"var",
")",
";",
"return",
"method_exists",
"(",
"$",
... | Sanitizes a param.
The return value is an array with the sanitized value and a boolean
indicating if the original value was kept (allowing to use the sanitized
value to explain the query). | [
"Sanitizes",
"a",
"param",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php#L177-L204 | train | Sanitize parameter value | [
30522,
2797,
3853,
2624,
25090,
4371,
28689,
2213,
1006,
1002,
13075,
1007,
1024,
9140,
1063,
2065,
1006,
1032,
2003,
1035,
4874,
1006,
1002,
13075,
1007,
1007,
1063,
1002,
2465,
18442,
1027,
1032,
2131,
1035,
2465,
1006,
1002,
13075,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Builder.php | Builder.registerCustomDoctrineType | public function registerCustomDoctrineType($class, $name, $type)
{
if (! $this->connection->isDoctrineAvailable()) {
throw new RuntimeException(
'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal).'
);
}
if (! Type::hasType($name)) {
Type::addType($name, $class);
$this->connection
->getDoctrineSchemaManager()
->getDatabasePlatform()
->registerDoctrineTypeMapping($type, $name);
}
} | php | public function registerCustomDoctrineType($class, $name, $type)
{
if (! $this->connection->isDoctrineAvailable()) {
throw new RuntimeException(
'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal).'
);
}
if (! Type::hasType($name)) {
Type::addType($name, $class);
$this->connection
->getDoctrineSchemaManager()
->getDatabasePlatform()
->registerDoctrineTypeMapping($type, $name);
}
} | [
"public",
"function",
"registerCustomDoctrineType",
"(",
"$",
"class",
",",
"$",
"name",
",",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
"->",
"isDoctrineAvailable",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
... | Register a custom Doctrine mapping type.
@param string $class
@param string $name
@param string $type
@return void
@throws \Doctrine\DBAL\DBALException | [
"Register",
"a",
"custom",
"Doctrine",
"mapping",
"type",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Builder.php#L299-L315 | train | Registers a custom Doctrine type | [
30522,
2270,
3853,
4236,
7874,
20389,
3527,
6593,
11467,
13874,
1006,
1002,
2465,
1010,
1002,
2171,
1010,
1002,
2828,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
4434,
1011,
1028,
2003,
3527,
6593,
11467,
12462,
11733,
3468,
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/system/classes/CombineAssets.php | CombineAssets.resetCache | public static function resetCache()
{
if (Cache::has('combiner.index')) {
$index = (array) @unserialize(@base64_decode(Cache::get('combiner.index'))) ?: [];
foreach ($index as $cacheKey) {
Cache::forget($cacheKey);
}
Cache::forget('combiner.index');
}
CacheHelper::instance()->clearCombiner();
} | php | public static function resetCache()
{
if (Cache::has('combiner.index')) {
$index = (array) @unserialize(@base64_decode(Cache::get('combiner.index'))) ?: [];
foreach ($index as $cacheKey) {
Cache::forget($cacheKey);
}
Cache::forget('combiner.index');
}
CacheHelper::instance()->clearCombiner();
} | [
"public",
"static",
"function",
"resetCache",
"(",
")",
"{",
"if",
"(",
"Cache",
"::",
"has",
"(",
"'combiner.index'",
")",
")",
"{",
"$",
"index",
"=",
"(",
"array",
")",
"@",
"unserialize",
"(",
"@",
"base64_decode",
"(",
"Cache",
"::",
"get",
"(",
... | Resets the combiner cache
@return void | [
"Resets",
"the",
"combiner",
"cache"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L821-L834 | train | Reset the combiner cache | [
30522,
2270,
10763,
3853,
25141,
3540,
5403,
1006,
1007,
1063,
2065,
1006,
17053,
1024,
1024,
2038,
1006,
1005,
11506,
2099,
1012,
5950,
1005,
1007,
1007,
1063,
1002,
5950,
1027,
1006,
9140,
1007,
1030,
4895,
8043,
4818,
4697,
1006,
1030,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DevicesDetection/API.php | API.getModel | public function getModel($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_models', $idSite, $period, $date, $segment);
$dataTable->filter(function (DataTable $table) {
foreach ($table->getRowsWithoutSummaryRow() as $row) {
$label = $row->getColumn('label');
if (strpos($label, ';') !== false) {
list($brand, $model) = explode(';', $label, 2);
$brand = getDeviceBrandLabel($brand);
} else {
$brand = null;
$model = $label;
}
$segment = sprintf('deviceBrand==%s;deviceModel==%s', urlencode($brand), urlencode($model));
$row->setMetadata('segment', $segment);
}
});
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getModelName'));
return $dataTable;
} | php | public function getModel($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_models', $idSite, $period, $date, $segment);
$dataTable->filter(function (DataTable $table) {
foreach ($table->getRowsWithoutSummaryRow() as $row) {
$label = $row->getColumn('label');
if (strpos($label, ';') !== false) {
list($brand, $model) = explode(';', $label, 2);
$brand = getDeviceBrandLabel($brand);
} else {
$brand = null;
$model = $label;
}
$segment = sprintf('deviceBrand==%s;deviceModel==%s', urlencode($brand), urlencode($model));
$row->setMetadata('segment', $segment);
}
});
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getModelName'));
return $dataTable;
} | [
"public",
"function",
"getModel",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
")",
"{",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getDataTable",
"(",
"'DevicesDetection_models'",
",",
"$",
"idSite",
",",
... | Gets datatable displaying number of visits by device model
@param int $idSite
@param string $period
@param string $date
@param bool|string $segment
@return DataTable | [
"Gets",
"datatable",
"displaying",
"number",
"of",
"visits",
"by",
"device",
"model"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DevicesDetection/API.php#L111-L136 | train | Get the model data table | [
30522,
2270,
3853,
2131,
5302,
9247,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1007,
1063,
1002,
2951,
10880,
1027,
1002,
2023,
1011,
1028,
2131,
2850,
29336,
3085,
1006,
1005,
5733,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SoftDeletingScope.php | SoftDeletingScope.addWithTrashed | protected function addWithTrashed(Builder $builder)
{
$builder->macro('withTrashed', function (Builder $builder, $withTrashed = true) {
if (! $withTrashed) {
return $builder->withoutTrashed();
}
return $builder->withoutGlobalScope($this);
});
} | php | protected function addWithTrashed(Builder $builder)
{
$builder->macro('withTrashed', function (Builder $builder, $withTrashed = true) {
if (! $withTrashed) {
return $builder->withoutTrashed();
}
return $builder->withoutGlobalScope($this);
});
} | [
"protected",
"function",
"addWithTrashed",
"(",
"Builder",
"$",
"builder",
")",
"{",
"$",
"builder",
"->",
"macro",
"(",
"'withTrashed'",
",",
"function",
"(",
"Builder",
"$",
"builder",
",",
"$",
"withTrashed",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$"... | Add the with-trashed extension to the builder.
@param \Illuminate\Database\Eloquent\Builder $builder
@return void | [
"Add",
"the",
"with",
"-",
"trashed",
"extension",
"to",
"the",
"builder",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/SoftDeletingScope.php#L83-L92 | train | Adds the withTrashed macro to the builder | [
30522,
5123,
3853,
5587,
24415,
6494,
14740,
1006,
12508,
1002,
12508,
1007,
1063,
1002,
12508,
1011,
1028,
26632,
1006,
1005,
2007,
6494,
14740,
1005,
1010,
3853,
1006,
12508,
1002,
12508,
1010,
1002,
2007,
6494,
14740,
1027,
2995,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/API.php | API.getAllUsersPreferences | public function getAllUsersPreferences(array $preferenceNames)
{
Piwik::checkUserHasSuperUserAccess();
$userPreferences = array();
foreach($preferenceNames as $preferenceName) {
$optionNameMatchAllUsers = $this->getPreferenceId('%', $preferenceName);
$preferences = Option::getLike($optionNameMatchAllUsers);
foreach($preferences as $optionName => $optionValue) {
$lastUnderscore = strrpos($optionName, self::OPTION_NAME_PREFERENCE_SEPARATOR);
$userName = substr($optionName, 0, $lastUnderscore);
$preference = substr($optionName, $lastUnderscore + 1);
$userPreferences[$userName][$preference] = $optionValue;
}
}
return $userPreferences;
} | php | public function getAllUsersPreferences(array $preferenceNames)
{
Piwik::checkUserHasSuperUserAccess();
$userPreferences = array();
foreach($preferenceNames as $preferenceName) {
$optionNameMatchAllUsers = $this->getPreferenceId('%', $preferenceName);
$preferences = Option::getLike($optionNameMatchAllUsers);
foreach($preferences as $optionName => $optionValue) {
$lastUnderscore = strrpos($optionName, self::OPTION_NAME_PREFERENCE_SEPARATOR);
$userName = substr($optionName, 0, $lastUnderscore);
$preference = substr($optionName, $lastUnderscore + 1);
$userPreferences[$userName][$preference] = $optionValue;
}
}
return $userPreferences;
} | [
"public",
"function",
"getAllUsersPreferences",
"(",
"array",
"$",
"preferenceNames",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"$",
"userPreferences",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"preferenceNames",
"as",
"$",
... | Returns an array of Preferences
@param $preferenceNames array of preference names
@return array
@ignore | [
"Returns",
"an",
"array",
"of",
"Preferences"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/API.php#L239-L256 | train | Get all users preferences | [
30522,
2270,
3853,
2131,
8095,
20330,
13102,
2890,
25523,
2015,
1006,
9140,
1002,
12157,
18442,
2015,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1025,
1002,
5310,
28139,
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... |
z-song/laravel-admin | src/Traits/ModelTree.php | ModelTree.setBranchOrder | protected static function setBranchOrder(array $order)
{
static::$branchOrder = array_flip(Arr::flatten($order));
static::$branchOrder = array_map(function ($item) {
return ++$item;
}, static::$branchOrder);
} | php | protected static function setBranchOrder(array $order)
{
static::$branchOrder = array_flip(Arr::flatten($order));
static::$branchOrder = array_map(function ($item) {
return ++$item;
}, static::$branchOrder);
} | [
"protected",
"static",
"function",
"setBranchOrder",
"(",
"array",
"$",
"order",
")",
"{",
"static",
"::",
"$",
"branchOrder",
"=",
"array_flip",
"(",
"Arr",
"::",
"flatten",
"(",
"$",
"order",
")",
")",
";",
"static",
"::",
"$",
"branchOrder",
"=",
"arr... | Set the order of branches in the tree.
@param array $order
@return void | [
"Set",
"the",
"order",
"of",
"branches",
"in",
"the",
"tree",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Traits/ModelTree.php#L196-L203 | train | Sets the branch order for the language tree. | [
30522,
5123,
10763,
3853,
2275,
10024,
12680,
8551,
2121,
1006,
9140,
1002,
2344,
1007,
1063,
10763,
1024,
1024,
1002,
3589,
8551,
2121,
1027,
9140,
1035,
11238,
1006,
12098,
2099,
1024,
1024,
4257,
6528,
1006,
1002,
2344,
1007,
1007,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter.php | Filter.removeIDFilterIfNeeded | public function removeIDFilterIfNeeded()
{
if (!$this->useIdFilter && !$this->idFilterRemoved) {
$this->removeDefaultIDFilter();
$this->layout->removeDefaultIDFilter();
$this->idFilterRemoved = true;
}
} | php | public function removeIDFilterIfNeeded()
{
if (!$this->useIdFilter && !$this->idFilterRemoved) {
$this->removeDefaultIDFilter();
$this->layout->removeDefaultIDFilter();
$this->idFilterRemoved = true;
}
} | [
"public",
"function",
"removeIDFilterIfNeeded",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"useIdFilter",
"&&",
"!",
"$",
"this",
"->",
"idFilterRemoved",
")",
"{",
"$",
"this",
"->",
"removeDefaultIDFilter",
"(",
")",
";",
"$",
"this",
"->",
"lay... | Remove ID filter if needed. | [
"Remove",
"ID",
"filter",
"if",
"needed",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter.php#L256-L265 | train | Removes ID filters if they are not used by this page. | [
30522,
2270,
3853,
6366,
3593,
8873,
21928,
10128,
24045,
5732,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2224,
3593,
8873,
21928,
1004,
1004,
999,
1002,
2023,
1011,
1028,
24011,
4014,
3334,
28578,
21818,
2094,
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/Database/Eloquent/Builder.php | Builder.scopes | public function scopes(array $scopes)
{
$builder = $this;
foreach ($scopes as $scope => $parameters) {
// If the scope key is an integer, then the scope was passed as the value and
// the parameter list is empty, so we will format the scope name and these
// parameters here. Then, we'll be ready to call the scope on the model.
if (is_int($scope)) {
[$scope, $parameters] = [$parameters, []];
}
// Next we'll pass the scope callback to the callScope method which will take
// care of grouping the "wheres" properly so the logical order doesn't get
// messed up when adding scopes. Then we'll return back out the builder.
$builder = $builder->callScope(
[$this->model, 'scope'.ucfirst($scope)],
(array) $parameters
);
}
return $builder;
} | php | public function scopes(array $scopes)
{
$builder = $this;
foreach ($scopes as $scope => $parameters) {
// If the scope key is an integer, then the scope was passed as the value and
// the parameter list is empty, so we will format the scope name and these
// parameters here. Then, we'll be ready to call the scope on the model.
if (is_int($scope)) {
[$scope, $parameters] = [$parameters, []];
}
// Next we'll pass the scope callback to the callScope method which will take
// care of grouping the "wheres" properly so the logical order doesn't get
// messed up when adding scopes. Then we'll return back out the builder.
$builder = $builder->callScope(
[$this->model, 'scope'.ucfirst($scope)],
(array) $parameters
);
}
return $builder;
} | [
"public",
"function",
"scopes",
"(",
"array",
"$",
"scopes",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
";",
"foreach",
"(",
"$",
"scopes",
"as",
"$",
"scope",
"=>",
"$",
"parameters",
")",
"{",
"// If the scope key is an integer, then the scope was passed as t... | Call the given local model scopes.
@param array $scopes
@return static|mixed | [
"Call",
"the",
"given",
"local",
"model",
"scopes",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Builder.php#L921-L943 | train | This method will return the builder with the scopes passed in the array | [
30522,
2270,
3853,
9531,
2015,
1006,
9140,
1002,
9531,
2015,
1007,
1063,
1002,
12508,
1027,
1002,
2023,
1025,
18921,
6776,
1006,
1002,
9531,
2015,
2004,
1002,
9531,
1027,
1028,
1002,
11709,
1007,
1063,
1013,
1013,
2065,
1996,
9531,
3145,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Uri/UriPartsFilter.php | UriPartsFilter.filterUserInfo | public static function filterUserInfo($info)
{
if (!\is_string($info)) {
throw new \InvalidArgumentException('Uri user info must be a string');
}
return preg_replace_callback(
'/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=]+|%(?![A-Fa-f0-9]{2}))/u',
function ($match) {
return rawurlencode($match[0]);
},
$info
) ?? '';
} | php | public static function filterUserInfo($info)
{
if (!\is_string($info)) {
throw new \InvalidArgumentException('Uri user info must be a string');
}
return preg_replace_callback(
'/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=]+|%(?![A-Fa-f0-9]{2}))/u',
function ($match) {
return rawurlencode($match[0]);
},
$info
) ?? '';
} | [
"public",
"static",
"function",
"filterUserInfo",
"(",
"$",
"info",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"info",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Uri user info must be a string'",
")",
";",
"}",
"retur... | Filters the user info string.
@param string $info The raw user or password.
@return string The percent-encoded user or password string.
@throws \InvalidArgumentException | [
"Filters",
"the",
"user",
"info",
"string",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Uri/UriPartsFilter.php#L41-L54 | train | Filter URI user info | [
30522,
2270,
10763,
3853,
11307,
20330,
2378,
14876,
1006,
1002,
18558,
1007,
1063,
2065,
1006,
999,
1032,
2003,
1035,
5164,
1006,
1002,
18558,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422,
1006,
1005,
24471,
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... |
dompdf/dompdf | src/Adapter/GD.php | GD.image | public function image($img_url, $x, $y, $w, $h, $resolution = "normal")
{
$img_type = Cache::detect_type($img_url, $this->get_dompdf()->getHttpContext());
if (!$img_type) {
return;
}
$func_name = "imagecreatefrom$img_type";
if (!function_exists($func_name)) {
if (!method_exists("Dompdf\Helpers", $func_name)) {
throw new \Exception("Function $func_name() not found. Cannot convert $img_type image: $img_url. Please install the image PHP extension.");
}
$func_name = "\\Dompdf\\Helpers::" . $func_name;
}
$src = @call_user_func($func_name, $img_url);
if (!$src) {
return; // Probably should add to $_dompdf_errors or whatever here
}
// Scale by the AA factor and DPI
$x = $this->_upscale($x);
$y = $this->_upscale($y);
$w = $this->_upscale($w);
$h = $this->_upscale($h);
$img_w = imagesx($src);
$img_h = imagesy($src);
imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
} | php | public function image($img_url, $x, $y, $w, $h, $resolution = "normal")
{
$img_type = Cache::detect_type($img_url, $this->get_dompdf()->getHttpContext());
if (!$img_type) {
return;
}
$func_name = "imagecreatefrom$img_type";
if (!function_exists($func_name)) {
if (!method_exists("Dompdf\Helpers", $func_name)) {
throw new \Exception("Function $func_name() not found. Cannot convert $img_type image: $img_url. Please install the image PHP extension.");
}
$func_name = "\\Dompdf\\Helpers::" . $func_name;
}
$src = @call_user_func($func_name, $img_url);
if (!$src) {
return; // Probably should add to $_dompdf_errors or whatever here
}
// Scale by the AA factor and DPI
$x = $this->_upscale($x);
$y = $this->_upscale($y);
$w = $this->_upscale($w);
$h = $this->_upscale($h);
$img_w = imagesx($src);
$img_h = imagesy($src);
imagecopyresampled($this->get_image(), $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
} | [
"public",
"function",
"image",
"(",
"$",
"img_url",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"resolution",
"=",
"\"normal\"",
")",
"{",
"$",
"img_type",
"=",
"Cache",
"::",
"detect_type",
"(",
"$",
"img_url",
",",
"$"... | Add an image to the pdf.
The image is placed at the specified x and y coordinates with the
given width and height.
@param string $img_url the path to the image
@param float $x x position
@param float $y y position
@param int $w width (in pixels)
@param int $h height (in pixels)
@param string $resolution
@return void
@throws \Exception
@internal param string $img_type the type (e.g. extension) of the image | [
"Add",
"an",
"image",
"to",
"the",
"pdf",
".",
"The",
"image",
"is",
"placed",
"at",
"the",
"specified",
"x",
"and",
"y",
"coordinates",
"with",
"the",
"given",
"width",
"and",
"height",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L721-L753 | train | Copy an image to the pdf | [
30522,
2270,
3853,
3746,
1006,
1002,
10047,
2290,
1035,
24471,
2140,
1010,
1002,
1060,
1010,
1002,
1061,
1010,
1002,
1059,
1010,
1002,
1044,
1010,
1002,
5813,
1027,
1000,
3671,
1000,
1007,
1063,
1002,
10047,
2290,
1035,
2828,
1027,
17053,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/FilesystemAdapter.php | FilesystemAdapter.getVisibility | public function getVisibility($path)
{
if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) {
return FilesystemContract::VISIBILITY_PUBLIC;
}
return FilesystemContract::VISIBILITY_PRIVATE;
} | php | public function getVisibility($path)
{
if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) {
return FilesystemContract::VISIBILITY_PUBLIC;
}
return FilesystemContract::VISIBILITY_PRIVATE;
} | [
"public",
"function",
"getVisibility",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"driver",
"->",
"getVisibility",
"(",
"$",
"path",
")",
"==",
"AdapterInterface",
"::",
"VISIBILITY_PUBLIC",
")",
"{",
"return",
"FilesystemContract",
"::",
"VIS... | Get the visibility for the given path.
@param string $path
@return string | [
"Get",
"the",
"visibility",
"for",
"the",
"given",
"path",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/FilesystemAdapter.php#L244-L251 | train | Return the visibility of a file | [
30522,
2270,
3853,
2131,
11365,
13464,
1006,
1002,
4130,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
4062,
1011,
1028,
2131,
11365,
13464,
1006,
1002,
4130,
1007,
1027,
1027,
15581,
23282,
3334,
12172,
1024,
1024,
16476,
1035,
2270,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Controller.php | Controller.renderReport | protected function renderReport($apiAction, $controllerAction = false)
{
if (empty($controllerAction) && is_string($apiAction)) {
$report = ReportsProvider::factory($this->pluginName, $apiAction);
if (!empty($report)) {
$apiAction = $report;
}
}
if ($apiAction instanceof Report) {
$this->checkSitePermission();
$apiAction->checkIsEnabled();
return $apiAction->render();
}
$pluginName = $this->pluginName;
/** @var Proxy $apiProxy */
$apiProxy = Proxy::getInstance();
if (!$apiProxy->isExistingApiAction($pluginName, $apiAction)) {
throw new \Exception("Invalid action name '$apiAction' for '$pluginName' plugin.");
}
$apiAction = $apiProxy->buildApiActionName($pluginName, $apiAction);
if ($controllerAction !== false) {
$controllerAction = $pluginName . '.' . $controllerAction;
}
$view = ViewDataTableFactory::build(null, $apiAction, $controllerAction);
$rendered = $view->render();
return $rendered;
} | php | protected function renderReport($apiAction, $controllerAction = false)
{
if (empty($controllerAction) && is_string($apiAction)) {
$report = ReportsProvider::factory($this->pluginName, $apiAction);
if (!empty($report)) {
$apiAction = $report;
}
}
if ($apiAction instanceof Report) {
$this->checkSitePermission();
$apiAction->checkIsEnabled();
return $apiAction->render();
}
$pluginName = $this->pluginName;
/** @var Proxy $apiProxy */
$apiProxy = Proxy::getInstance();
if (!$apiProxy->isExistingApiAction($pluginName, $apiAction)) {
throw new \Exception("Invalid action name '$apiAction' for '$pluginName' plugin.");
}
$apiAction = $apiProxy->buildApiActionName($pluginName, $apiAction);
if ($controllerAction !== false) {
$controllerAction = $pluginName . '.' . $controllerAction;
}
$view = ViewDataTableFactory::build(null, $apiAction, $controllerAction);
$rendered = $view->render();
return $rendered;
} | [
"protected",
"function",
"renderReport",
"(",
"$",
"apiAction",
",",
"$",
"controllerAction",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"controllerAction",
")",
"&&",
"is_string",
"(",
"$",
"apiAction",
")",
")",
"{",
"$",
"report",
"=",
"Rep... | Convenience method that creates and renders a ViewDataTable for a API method.
@param string|\Piwik\Plugin\Report $apiAction The name of the API action (eg, `'getResolution'`) or
an instance of an report.
@param bool $controllerAction The name of the Controller action name that is rendering the report. Defaults
to the `$apiAction`.
@param bool $fetch If `true`, the rendered string is returned, if `false` it is `echo`'d.
@throws \Exception if `$pluginName` is not an existing plugin or if `$apiAction` is not an
existing method of the plugin's API.
@return string|void See `$fetch`.
@api | [
"Convenience",
"method",
"that",
"creates",
"and",
"renders",
"a",
"ViewDataTable",
"for",
"a",
"API",
"method",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Controller.php#L315-L351 | train | Render a report | [
30522,
5123,
3853,
17552,
2890,
6442,
1006,
1002,
17928,
18908,
3258,
1010,
1002,
11486,
18908,
3258,
1027,
6270,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
11486,
18908,
3258,
1007,
1004,
1004,
2003,
1035,
5164,
1006,
1002,
17928,
18908,
32... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Scheduler/Job.php | Job.finalize | public function finalize()
{
/** @var Process $process */
$process = $this->process;
if ($process) {
$process->wait();
if ($process->isSuccessful()) {
$this->successful = true;
$this->output = $process->getOutput();
} else {
$this->successful = false;
$this->output = $process->getErrorOutput();
}
$this->postRun();
unset($this->process);
}
} | php | public function finalize()
{
/** @var Process $process */
$process = $this->process;
if ($process) {
$process->wait();
if ($process->isSuccessful()) {
$this->successful = true;
$this->output = $process->getOutput();
} else {
$this->successful = false;
$this->output = $process->getErrorOutput();
}
$this->postRun();
unset($this->process);
}
} | [
"public",
"function",
"finalize",
"(",
")",
"{",
"/** @var Process $process */",
"$",
"process",
"=",
"$",
"this",
"->",
"process",
";",
"if",
"(",
"$",
"process",
")",
"{",
"$",
"process",
"->",
"wait",
"(",
")",
";",
"if",
"(",
"$",
"process",
"->",
... | Finish up processing the job
@return void | [
"Finish",
"up",
"processing",
"the",
"job"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Job.php#L323-L343 | train | Finalize the process | [
30522,
2270,
3853,
2345,
4697,
1006,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
2832,
1002,
2832,
1008,
1013,
1002,
2832,
1027,
1002,
2023,
1011,
1028,
2832,
1025,
2065,
1006,
1002,
2832,
1007,
1063,
1002,
2832,
1011,
1028,
3524,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Http/HttpUtils.php | HttpUtils.createRedirectResponse | public function createRedirectResponse(Request $request, $path, $status = 302)
{
if (null !== $this->secureDomainRegexp && 'https' === $this->urlMatcher->getContext()->getScheme() && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path, $host) && !preg_match(sprintf($this->secureDomainRegexp, preg_quote($request->getHttpHost())), $host[0])) {
$path = '/';
}
if (null !== $this->domainRegexp && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path, $host) && !preg_match(sprintf($this->domainRegexp, preg_quote($request->getHttpHost())), $host[0])) {
$path = '/';
}
return new RedirectResponse($this->generateUri($request, $path), $status);
} | php | public function createRedirectResponse(Request $request, $path, $status = 302)
{
if (null !== $this->secureDomainRegexp && 'https' === $this->urlMatcher->getContext()->getScheme() && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path, $host) && !preg_match(sprintf($this->secureDomainRegexp, preg_quote($request->getHttpHost())), $host[0])) {
$path = '/';
}
if (null !== $this->domainRegexp && preg_match('#^https?:[/\\\\]{2,}+[^/]++#i', $path, $host) && !preg_match(sprintf($this->domainRegexp, preg_quote($request->getHttpHost())), $host[0])) {
$path = '/';
}
return new RedirectResponse($this->generateUri($request, $path), $status);
} | [
"public",
"function",
"createRedirectResponse",
"(",
"Request",
"$",
"request",
",",
"$",
"path",
",",
"$",
"status",
"=",
"302",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"secureDomainRegexp",
"&&",
"'https'",
"===",
"$",
"this",
"->",
"url... | Creates a redirect Response.
@param Request $request A Request instance
@param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
@param int $status The status code
@return RedirectResponse A RedirectResponse instance | [
"Creates",
"a",
"redirect",
"Response",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/HttpUtils.php#L63-L73 | train | Create a redirect response | [
30522,
2270,
3853,
3443,
5596,
7442,
6593,
6072,
26029,
3366,
1006,
5227,
1002,
5227,
1010,
1002,
4130,
1010,
1002,
3570,
1027,
22060,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
7119,
9626,
2378,
2890,
3351,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select._renderDistinct | protected function _renderDistinct($sql)
{
if ($this->_parts[self::DISTINCT]) {
$sql .= ' ' . self::SQL_DISTINCT;
}
return $sql;
} | php | protected function _renderDistinct($sql)
{
if ($this->_parts[self::DISTINCT]) {
$sql .= ' ' . self::SQL_DISTINCT;
}
return $sql;
} | [
"protected",
"function",
"_renderDistinct",
"(",
"$",
"sql",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"DISTINCT",
"]",
")",
"{",
"$",
"sql",
".=",
"' '",
".",
"self",
"::",
"SQL_DISTINCT",
";",
"}",
"return",
"$",
"sql",
... | Render DISTINCT clause
@param string $sql SQL query
@return string | [
"Render",
"DISTINCT",
"clause"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1055-L1062 | train | Render the DISTINCT part of the query | [
30522,
5123,
3853,
1035,
17552,
10521,
7629,
6593,
1006,
1002,
29296,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
2969,
1024,
1024,
5664,
1033,
1007,
1063,
1002,
29296,
1012,
1027,
1005,
1005,
1012,
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... |
octobercms/october | modules/system/classes/SettingsManager.php | SettingsManager.listItems | public function listItems($context = null)
{
if ($this->items === null) {
$this->loadItems();
}
if ($context !== null) {
return $this->filterByContext($this->groupedItems, $context);
}
return $this->groupedItems;
} | php | public function listItems($context = null)
{
if ($this->items === null) {
$this->loadItems();
}
if ($context !== null) {
return $this->filterByContext($this->groupedItems, $context);
}
return $this->groupedItems;
} | [
"public",
"function",
"listItems",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"items",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"loadItems",
"(",
")",
";",
"}",
"if",
"(",
"$",
"context",
"!==",
"null",
")",
"{",... | Returns a collection of all settings by group, filtered by context
@param string $context
@return array | [
"Returns",
"a",
"collection",
"of",
"all",
"settings",
"by",
"group",
"filtered",
"by",
"context"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/SettingsManager.php#L151-L162 | train | Returns the items grouped by a context | [
30522,
2270,
3853,
2862,
30524,
1011,
1028,
5167,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
7170,
4221,
5244,
1006,
1007,
1025,
1065,
2065,
1006,
1002,
6123,
999,
1027,
1027,
19701,
1007,
1063,
2709,
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... |
laravel/framework | src/Illuminate/Cache/TaggedCache.php | TaggedCache.increment | public function increment($key, $value = 1)
{
$this->store->increment($this->itemKey($key), $value);
} | php | public function increment($key, $value = 1)
{
$this->store->increment($this->itemKey($key), $value);
} | [
"public",
"function",
"increment",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"store",
"->",
"increment",
"(",
"$",
"this",
"->",
"itemKey",
"(",
"$",
"key",
")",
",",
"$",
"value",
")",
";",
"}"
] | Increment the value of an item in the cache.
@param string $key
@param mixed $value
@return void | [
"Increment",
"the",
"value",
"of",
"an",
"item",
"in",
"the",
"cache",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/TaggedCache.php#L57-L60 | train | Increment the value of an integer key in the recordset | [
30522,
2270,
3853,
4297,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
3643,
1027,
1015,
1007,
1063,
1002,
2023,
1011,
1028,
3573,
1011,
1028,
4297,
28578,
4765,
1006,
1002,
2023,
1011,
1028,
8875,
14839,
1006,
1002,
3145,
1007,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Translation/Translator.php | Translator.getAllTranslations | public function getAllTranslations()
{
$this->loadTranslations($this->currentLanguage);
if (!isset($this->translations[$this->currentLanguage])) {
return array();
}
return $this->translations[$this->currentLanguage];
} | php | public function getAllTranslations()
{
$this->loadTranslations($this->currentLanguage);
if (!isset($this->translations[$this->currentLanguage])) {
return array();
}
return $this->translations[$this->currentLanguage];
} | [
"public",
"function",
"getAllTranslations",
"(",
")",
"{",
"$",
"this",
"->",
"loadTranslations",
"(",
"$",
"this",
"->",
"currentLanguage",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"translations",
"[",
"$",
"this",
"->",
"currentLanguage... | Returns all the translation messages loaded.
@return array | [
"Returns",
"all",
"the",
"translation",
"messages",
"loaded",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Translation/Translator.php#L222-L231 | train | Returns all translations for the current language | [
30522,
2270,
3853,
2131,
8095,
6494,
3619,
13490,
2015,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
7170,
6494,
3619,
13490,
2015,
1006,
1002,
2023,
1011,
1028,
2783,
25023,
6692,
3351,
1007,
1025,
2065,
1006,
999,
26354,
3388,
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 | plugins/SitesManager/API.php | API.setGlobalExcludedUserAgents | public function setGlobalExcludedUserAgents($excludedUserAgents)
{
Piwik::checkUserHasSuperUserAccess();
// update option
$excludedUserAgents = $this->checkAndReturnCommaSeparatedStringList($excludedUserAgents);
Option::set(self::OPTION_EXCLUDED_USER_AGENTS_GLOBAL, $excludedUserAgents);
// make sure tracker cache will reflect change
Cache::deleteTrackerCache();
} | php | public function setGlobalExcludedUserAgents($excludedUserAgents)
{
Piwik::checkUserHasSuperUserAccess();
// update option
$excludedUserAgents = $this->checkAndReturnCommaSeparatedStringList($excludedUserAgents);
Option::set(self::OPTION_EXCLUDED_USER_AGENTS_GLOBAL, $excludedUserAgents);
// make sure tracker cache will reflect change
Cache::deleteTrackerCache();
} | [
"public",
"function",
"setGlobalExcludedUserAgents",
"(",
"$",
"excludedUserAgents",
")",
"{",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"// update option",
"$",
"excludedUserAgents",
"=",
"$",
"this",
"->",
"checkAndReturnCommaSeparatedStringList",
"("... | Sets list of user agent substrings to look for when excluding visits. For more info,
@see getExcludedUserAgentsGlobal.
@param string $excludedUserAgents Comma separated list of strings. Each element is trimmed,
and empty strings are removed. | [
"Sets",
"list",
"of",
"user",
"agent",
"substrings",
"to",
"look",
"for",
"when",
"excluding",
"visits",
".",
"For",
"more",
"info",
"@see",
"getExcludedUserAgentsGlobal",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L1050-L1060 | train | Sets the list of excluded user agents that should be excluded from the user agent list. | [
30522,
2270,
3853,
2275,
23296,
16429,
9453,
2595,
20464,
13936,
20330,
4270,
7666,
1006,
1002,
12421,
20330,
4270,
7666,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Filter/SafeDecodeLabel.php | SafeDecodeLabel.decodeLabelSafe | public static function decodeLabelSafe($value)
{
if (empty($value)) {
return $value;
}
$raw = urldecode($value);
$value = htmlspecialchars_decode($raw, ENT_QUOTES);
// ENT_IGNORE so that if utf8 string has some errors, we simply discard invalid code unit sequences
$style = ENT_QUOTES | ENT_IGNORE;
// See changes in 5.4: http://nikic.github.com/2012/01/28/htmlspecialchars-improvements-in-PHP-5-4.html
// Note: at some point we should change ENT_IGNORE to ENT_SUBSTITUTE
$value = htmlspecialchars($value, $style, 'UTF-8');
return $value;
} | php | public static function decodeLabelSafe($value)
{
if (empty($value)) {
return $value;
}
$raw = urldecode($value);
$value = htmlspecialchars_decode($raw, ENT_QUOTES);
// ENT_IGNORE so that if utf8 string has some errors, we simply discard invalid code unit sequences
$style = ENT_QUOTES | ENT_IGNORE;
// See changes in 5.4: http://nikic.github.com/2012/01/28/htmlspecialchars-improvements-in-PHP-5-4.html
// Note: at some point we should change ENT_IGNORE to ENT_SUBSTITUTE
$value = htmlspecialchars($value, $style, 'UTF-8');
return $value;
} | [
"public",
"static",
"function",
"decodeLabelSafe",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"raw",
"=",
"urldecode",
"(",
"$",
"value",
")",
";",
"$",
"value",
"=",
... | Decodes the given value
@param string $value
@return mixed|string | [
"Decodes",
"the",
"given",
"value"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/SafeDecodeLabel.php#L37-L53 | train | Decode label safe | [
30522,
2270,
10763,
3853,
21933,
9247,
16336,
4877,
10354,
2063,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
1002,
3643,
1025,
1065,
1002,
6315,
1027,
24471,
17920,
16044,
1006,
1002,
3643,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php | InteractsWithPivotTable.detachUsingCustomClass | protected function detachUsingCustomClass($ids)
{
$results = 0;
foreach ($this->parseIds($ids) as $id) {
$results += $this->newPivot([
$this->foreignPivotKey => $this->parent->{$this->parentKey},
$this->relatedPivotKey => $id,
], true)->delete();
}
return $results;
} | php | protected function detachUsingCustomClass($ids)
{
$results = 0;
foreach ($this->parseIds($ids) as $id) {
$results += $this->newPivot([
$this->foreignPivotKey => $this->parent->{$this->parentKey},
$this->relatedPivotKey => $id,
], true)->delete();
}
return $results;
} | [
"protected",
"function",
"detachUsingCustomClass",
"(",
"$",
"ids",
")",
"{",
"$",
"results",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"parseIds",
"(",
"$",
"ids",
")",
"as",
"$",
"id",
")",
"{",
"$",
"results",
"+=",
"$",
"this",
"->",
"n... | Detach models from the relationship using a custom class.
@param mixed $ids
@return int | [
"Detach",
"models",
"from",
"the",
"relationship",
"using",
"a",
"custom",
"class",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php#L443-L455 | train | Detaches all pivot records from a custom class | [
30522,
5123,
3853,
20010,
6776,
18161,
7874,
20389,
26266,
1006,
1002,
8909,
2015,
1007,
1063,
1002,
3463,
1027,
1014,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
11968,
20240,
5104,
1006,
1002,
8909,
2015,
1007,
2004,
1002,
8909,
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/system/classes/CombineAssets.php | CombineAssets.getBundles | public function getBundles($extension = null)
{
if ($extension === null) {
return $this->bundles;
}
elseif (isset($this->bundles[$extension])) {
return $this->bundles[$extension];
}
else {
return null;
}
} | php | public function getBundles($extension = null)
{
if ($extension === null) {
return $this->bundles;
}
elseif (isset($this->bundles[$extension])) {
return $this->bundles[$extension];
}
else {
return null;
}
} | [
"public",
"function",
"getBundles",
"(",
"$",
"extension",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"extension",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"bundles",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"bundles",
"[",
... | Returns bundles.
@param string $extension Extension name. Eg: css
@return self | [
"Returns",
"bundles",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L675-L686 | train | Get all bundles | [
30522,
2270,
3853,
2131,
27265,
4244,
1006,
1002,
5331,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
5331,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
26825,
1025,
1065,
2842,
10128,
1006,
26354,
3388,
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 | libs/Zend/Db/Table/Abstract.php | Zend_Db_Table_Abstract.info | public function info($key = null)
{
$this->_setupPrimaryKey();
$info = array(
self::SCHEMA => $this->_schema,
self::NAME => $this->_name,
self::COLS => $this->_getCols(),
self::PRIMARY => (array) $this->_primary,
self::METADATA => $this->_metadata,
self::ROW_CLASS => $this->getRowClass(),
self::ROWSET_CLASS => $this->getRowsetClass(),
self::REFERENCE_MAP => $this->_referenceMap,
self::DEPENDENT_TABLES => $this->_dependentTables,
self::SEQUENCE => $this->_sequence
);
if ($key === null) {
return $info;
}
if (!array_key_exists($key, $info)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception('There is no table information for the key "' . $key . '"');
}
return $info[$key];
} | php | public function info($key = null)
{
$this->_setupPrimaryKey();
$info = array(
self::SCHEMA => $this->_schema,
self::NAME => $this->_name,
self::COLS => $this->_getCols(),
self::PRIMARY => (array) $this->_primary,
self::METADATA => $this->_metadata,
self::ROW_CLASS => $this->getRowClass(),
self::ROWSET_CLASS => $this->getRowsetClass(),
self::REFERENCE_MAP => $this->_referenceMap,
self::DEPENDENT_TABLES => $this->_dependentTables,
self::SEQUENCE => $this->_sequence
);
if ($key === null) {
return $info;
}
if (!array_key_exists($key, $info)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception('There is no table information for the key "' . $key . '"');
}
return $info[$key];
} | [
"public",
"function",
"info",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_setupPrimaryKey",
"(",
")",
";",
"$",
"info",
"=",
"array",
"(",
"self",
"::",
"SCHEMA",
"=>",
"$",
"this",
"->",
"_schema",
",",
"self",
"::",
"NAME",
"=>",... | Returns table information.
You can elect to return only a part of this information by supplying its key name,
otherwise all information is returned as an array.
@param string $key The specific info part to return OPTIONAL
@return mixed
@throws Zend_Db_Table_Exception | [
"Returns",
"table",
"information",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Abstract.php#L980-L1007 | train | Return the table information | [
30522,
2270,
3853,
18558,
1006,
1002,
3145,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
16437,
18098,
9581,
2854,
14839,
1006,
1007,
1025,
1002,
18558,
1027,
9140,
1006,
2969,
1024,
1024,
8040,
28433,
1027,
1028,
1002,
2023,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/models/ImportModel.php | ImportModel.decodeArrayValue | protected function decodeArrayValue($value, $delimeter = '|')
{
if (strpos($value, $delimeter) === false) return [$value];
$data = preg_split('~(?<!\\\)' . preg_quote($delimeter, '~') . '~', $value);
$newData = [];
foreach ($data as $_value) {
$newData[] = str_replace('\\'.$delimeter, $delimeter, $_value);
}
return $newData;
} | php | protected function decodeArrayValue($value, $delimeter = '|')
{
if (strpos($value, $delimeter) === false) return [$value];
$data = preg_split('~(?<!\\\)' . preg_quote($delimeter, '~') . '~', $value);
$newData = [];
foreach ($data as $_value) {
$newData[] = str_replace('\\'.$delimeter, $delimeter, $_value);
}
return $newData;
} | [
"protected",
"function",
"decodeArrayValue",
"(",
"$",
"value",
",",
"$",
"delimeter",
"=",
"'|'",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"delimeter",
")",
"===",
"false",
")",
"return",
"[",
"$",
"value",
"]",
";",
"$",
"data",
... | Explodes a string using pipes (|) to a single dimension array
@return array | [
"Explodes",
"a",
"string",
"using",
"pipes",
"(",
"|",
")",
"to",
"a",
"single",
"dimension",
"array"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/models/ImportModel.php#L175-L187 | train | Decode array value | [
30522,
5123,
3853,
21933,
3207,
2906,
9447,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
3972,
19198,
1027,
1005,
1064,
1005,
1007,
1063,
2065,
1006,
2358,
14536,
2891,
1006,
1002,
3643,
1010,
1002,
3972,
19198,
1007,
1027,
1027,
1027,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php | ArrayNodeDefinition.fixXmlConfig | public function fixXmlConfig($singular, $plural = null)
{
$this->normalization()->remap($singular, $plural);
return $this;
} | php | public function fixXmlConfig($singular, $plural = null)
{
$this->normalization()->remap($singular, $plural);
return $this;
} | [
"public",
"function",
"fixXmlConfig",
"(",
"$",
"singular",
",",
"$",
"plural",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"normalization",
"(",
")",
"->",
"remap",
"(",
"$",
"singular",
",",
"$",
"plural",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a normalization rule for XML configurations.
@param string $singular The key to remap
@param string $plural The plural of the key for irregular plurals
@return $this | [
"Sets",
"a",
"normalization",
"rule",
"for",
"XML",
"configurations",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php#L202-L207 | train | Fixes the XML configuration of the current language. | [
30522,
2270,
3853,
8081,
2595,
19968,
8663,
8873,
2290,
1006,
1002,
13048,
1010,
1002,
13994,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
3671,
3989,
1006,
1007,
1011,
1028,
2128,
2863,
2361,
1006,
1002,
13048,
1010,
1002,
13994,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Exceptions/WhoopsHandler.php | WhoopsHandler.forDebug | public function forDebug()
{
return tap(new PrettyPageHandler, function ($handler) {
$handler->handleUnconditionally(true);
$this->registerApplicationPaths($handler)
->registerBlacklist($handler)
->registerEditor($handler);
});
} | php | public function forDebug()
{
return tap(new PrettyPageHandler, function ($handler) {
$handler->handleUnconditionally(true);
$this->registerApplicationPaths($handler)
->registerBlacklist($handler)
->registerEditor($handler);
});
} | [
"public",
"function",
"forDebug",
"(",
")",
"{",
"return",
"tap",
"(",
"new",
"PrettyPageHandler",
",",
"function",
"(",
"$",
"handler",
")",
"{",
"$",
"handler",
"->",
"handleUnconditionally",
"(",
"true",
")",
";",
"$",
"this",
"->",
"registerApplicationPa... | Create a new Whoops handler for debug mode.
@return \Whoops\Handler\PrettyPageHandler | [
"Create",
"a",
"new",
"Whoops",
"handler",
"for",
"debug",
"mode",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Exceptions/WhoopsHandler.php#L16-L25 | train | Returns a pretty page handler that will be used to display debug information. | [
30522,
2270,
3853,
4811,
15878,
15916,
1006,
1007,
1063,
2709,
11112,
1006,
2047,
3492,
13704,
11774,
3917,
1010,
3853,
1006,
1002,
28213,
1007,
1063,
1002,
28213,
1011,
1028,
5047,
4609,
8663,
27064,
2135,
1006,
2995,
1007,
1025,
1002,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/MessageCatalogue.php | MessageCatalogue.addFallbackCatalogue | public function addFallbackCatalogue(MessageCatalogueInterface $catalogue)
{
// detect circular references
$c = $catalogue;
while ($c = $c->getFallbackCatalogue()) {
if ($c->getLocale() === $this->getLocale()) {
throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
}
}
$c = $this;
do {
if ($c->getLocale() === $catalogue->getLocale()) {
throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
}
foreach ($catalogue->getResources() as $resource) {
$c->addResource($resource);
}
} while ($c = $c->parent);
$catalogue->parent = $this;
$this->fallbackCatalogue = $catalogue;
foreach ($catalogue->getResources() as $resource) {
$this->addResource($resource);
}
} | php | public function addFallbackCatalogue(MessageCatalogueInterface $catalogue)
{
// detect circular references
$c = $catalogue;
while ($c = $c->getFallbackCatalogue()) {
if ($c->getLocale() === $this->getLocale()) {
throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
}
}
$c = $this;
do {
if ($c->getLocale() === $catalogue->getLocale()) {
throw new LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
}
foreach ($catalogue->getResources() as $resource) {
$c->addResource($resource);
}
} while ($c = $c->parent);
$catalogue->parent = $this;
$this->fallbackCatalogue = $catalogue;
foreach ($catalogue->getResources() as $resource) {
$this->addResource($resource);
}
} | [
"public",
"function",
"addFallbackCatalogue",
"(",
"MessageCatalogueInterface",
"$",
"catalogue",
")",
"{",
"// detect circular references",
"$",
"c",
"=",
"$",
"catalogue",
";",
"while",
"(",
"$",
"c",
"=",
"$",
"c",
"->",
"getFallbackCatalogue",
"(",
")",
")",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/MessageCatalogue.php#L193-L220 | train | Adds a fallback catalogue for the current locale. | [
30522,
2270,
3853,
5587,
13976,
5963,
11266,
23067,
9077,
1006,
4471,
11266,
23067,
9077,
18447,
2121,
12172,
1002,
10161,
1007,
1063,
1013,
1013,
11487,
8206,
7604,
1002,
1039,
1027,
1002,
10161,
1025,
2096,
1006,
1002,
1039,
1027,
1002,
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/Console/Formatter/OutputFormatterStyleStack.php | OutputFormatterStyleStack.pop | public function pop(OutputFormatterStyleInterface $style = null)
{
if (empty($this->styles)) {
return $this->emptyStyle;
}
if (null === $style) {
return array_pop($this->styles);
}
foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
if ($style->apply('') === $stackedStyle->apply('')) {
$this->styles = \array_slice($this->styles, 0, $index);
return $stackedStyle;
}
}
throw new InvalidArgumentException('Incorrectly nested style tag found.');
} | php | public function pop(OutputFormatterStyleInterface $style = null)
{
if (empty($this->styles)) {
return $this->emptyStyle;
}
if (null === $style) {
return array_pop($this->styles);
}
foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
if ($style->apply('') === $stackedStyle->apply('')) {
$this->styles = \array_slice($this->styles, 0, $index);
return $stackedStyle;
}
}
throw new InvalidArgumentException('Incorrectly nested style tag found.');
} | [
"public",
"function",
"pop",
"(",
"OutputFormatterStyleInterface",
"$",
"style",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"styles",
")",
")",
"{",
"return",
"$",
"this",
"->",
"emptyStyle",
";",
"}",
"if",
"(",
"null",
"===",
... | Pops a style from the stack.
@return OutputFormatterStyleInterface
@throws InvalidArgumentException When style tags incorrectly nested | [
"Pops",
"a",
"style",
"from",
"the",
"stack",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php#L58-L77 | train | Pop the last output formatter style tag | [
30522,
2270,
3853,
3769,
1006,
6434,
14192,
20097,
21756,
19856,
3334,
12172,
1002,
2806,
1027,
19701,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
6782,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4064,
21756,
2571,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php | HasOneOrMany.addEagerConstraints | public function addEagerConstraints(array $models)
{
$whereIn = $this->whereInMethod($this->parent, $this->localKey);
$this->query->{$whereIn}(
$this->foreignKey, $this->getKeys($models, $this->localKey)
);
} | php | public function addEagerConstraints(array $models)
{
$whereIn = $this->whereInMethod($this->parent, $this->localKey);
$this->query->{$whereIn}(
$this->foreignKey, $this->getKeys($models, $this->localKey)
);
} | [
"public",
"function",
"addEagerConstraints",
"(",
"array",
"$",
"models",
")",
"{",
"$",
"whereIn",
"=",
"$",
"this",
"->",
"whereInMethod",
"(",
"$",
"this",
"->",
"parent",
",",
"$",
"this",
"->",
"localKey",
")",
";",
"$",
"this",
"->",
"query",
"->... | Set the constraints for an eager load of the relation.
@param array $models
@return void | [
"Set",
"the",
"constraints",
"for",
"an",
"eager",
"load",
"of",
"the",
"relation",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php#L82-L89 | train | Adds eager constraints to the query object. | [
30522,
2270,
3853,
5587,
5243,
4590,
8663,
20528,
18447,
2015,
1006,
9140,
1002,
4275,
1007,
1063,
1002,
16726,
1027,
1002,
2023,
1011,
1028,
16726,
11368,
6806,
2094,
1006,
1002,
2023,
1011,
1028,
6687,
1010,
1002,
2023,
1011,
1028,
2334,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/View/Concerns/ManagesStacks.php | ManagesStacks.startPrepend | public function startPrepend($section, $content = '')
{
if ($content === '') {
if (ob_start()) {
$this->pushStack[] = $section;
}
} else {
$this->extendPrepend($section, $content);
}
} | php | public function startPrepend($section, $content = '')
{
if ($content === '') {
if (ob_start()) {
$this->pushStack[] = $section;
}
} else {
$this->extendPrepend($section, $content);
}
} | [
"public",
"function",
"startPrepend",
"(",
"$",
"section",
",",
"$",
"content",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"content",
"===",
"''",
")",
"{",
"if",
"(",
"ob_start",
"(",
")",
")",
"{",
"$",
"this",
"->",
"pushStack",
"[",
"]",
"=",
"$",
... | Start prepending content into a push section.
@param string $section
@param string $content
@return void | [
"Start",
"prepending",
"content",
"into",
"a",
"push",
"section",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Concerns/ManagesStacks.php#L93-L102 | train | Start prepending content to a section | [
30522,
2270,
3853,
2707,
28139,
11837,
2094,
1006,
1002,
2930,
1010,
1002,
4180,
1027,
1005,
1005,
1007,
1063,
2065,
1006,
1002,
4180,
1027,
1027,
1027,
1005,
1005,
1007,
1063,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/API.php | API.regenerateTokenAuth | public function regenerateTokenAuth($userLogin)
{
$this->checkUserIsNotAnonymous($userLogin);
Piwik::checkUserHasSuperUserAccessOrIsTheUser($userLogin);
$this->model->updateUserTokenAuth(
$userLogin,
$this->createTokenAuth($userLogin)
);
} | php | public function regenerateTokenAuth($userLogin)
{
$this->checkUserIsNotAnonymous($userLogin);
Piwik::checkUserHasSuperUserAccessOrIsTheUser($userLogin);
$this->model->updateUserTokenAuth(
$userLogin,
$this->createTokenAuth($userLogin)
);
} | [
"public",
"function",
"regenerateTokenAuth",
"(",
"$",
"userLogin",
")",
"{",
"$",
"this",
"->",
"checkUserIsNotAnonymous",
"(",
"$",
"userLogin",
")",
";",
"Piwik",
"::",
"checkUserHasSuperUserAccessOrIsTheUser",
"(",
"$",
"userLogin",
")",
";",
"$",
"this",
"-... | Regenerate the token_auth associated with a user.
If the user currently logged in regenerates his own token, he will be logged out.
His previous token will be rendered invalid.
@param string $userLogin
@throws Exception | [
"Regenerate",
"the",
"token_auth",
"associated",
"with",
"a",
"user",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/API.php#L831-L841 | train | Regenerates the token auth for a user | [
30522,
2270,
3853,
19723,
24454,
3686,
18715,
8189,
14317,
1006,
1002,
5310,
21197,
2378,
1007,
1063,
1002,
2023,
1011,
1028,
4638,
20330,
2483,
17048,
6761,
4890,
27711,
1006,
1002,
5310,
21197,
2378,
1007,
1025,
14255,
9148,
2243,
1024,
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/Markdown/ParsedownGravTrait.php | ParsedownGravTrait.init | protected function init($page, $defaults)
{
$grav = Grav::instance();
$this->page = $page;
$this->BlockTypes['{'] [] = 'TwigTag';
$this->special_chars = ['>' => 'gt', '<' => 'lt', '"' => 'quot'];
if ($defaults === null) {
$defaults = (array)Grav::instance()['config']->get('system.pages.markdown');
}
$this->setBreaksEnabled($defaults['auto_line_breaks']);
$this->setUrlsLinked($defaults['auto_url_links']);
$this->setMarkupEscaped($defaults['escape_markup']);
$this->setSpecialChars($defaults['special_chars']);
$grav->fireEvent('onMarkdownInitialized', new Event(['markdown' => $this, 'page' => $page]));
} | php | protected function init($page, $defaults)
{
$grav = Grav::instance();
$this->page = $page;
$this->BlockTypes['{'] [] = 'TwigTag';
$this->special_chars = ['>' => 'gt', '<' => 'lt', '"' => 'quot'];
if ($defaults === null) {
$defaults = (array)Grav::instance()['config']->get('system.pages.markdown');
}
$this->setBreaksEnabled($defaults['auto_line_breaks']);
$this->setUrlsLinked($defaults['auto_url_links']);
$this->setMarkupEscaped($defaults['escape_markup']);
$this->setSpecialChars($defaults['special_chars']);
$grav->fireEvent('onMarkdownInitialized', new Event(['markdown' => $this, 'page' => $page]));
} | [
"protected",
"function",
"init",
"(",
"$",
"page",
",",
"$",
"defaults",
")",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"$",
"this",
"->",
"page",
"=",
"$",
"page",
";",
"$",
"this",
"->",
"BlockTypes",
"[",
"'{'",
"]",
"[",... | Initialization function to setup key variables needed by the MarkdownGravLinkTrait
@param PageInterface $page
@param array|null $defaults | [
"Initialization",
"function",
"to",
"setup",
"key",
"variables",
"needed",
"by",
"the",
"MarkdownGravLinkTrait"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Markdown/ParsedownGravTrait.php#L34-L53 | train | Initializes the Markdown object | [
30522,
5123,
3853,
1999,
4183,
1006,
1002,
3931,
1010,
1002,
12398,
2015,
1007,
1063,
1002,
24665,
11431,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
3931,
1027,
1002,
3931,
1025,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Mime/Encoder/QpEncoder.php | QpEncoder.standardize | private function standardize(string $string): string
{
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
switch ($end = \ord(substr($string, -1))) {
case 0x09:
case 0x20:
$string = substr_replace($string, self::$qpMap[$end], -1);
}
return $string;
} | php | private function standardize(string $string): string
{
$string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], ["=09\r\n", "=20\r\n", "\r\n"], $string);
switch ($end = \ord(substr($string, -1))) {
case 0x09:
case 0x20:
$string = substr_replace($string, self::$qpMap[$end], -1);
}
return $string;
} | [
"private",
"function",
"standardize",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"[",
"\"\\t=0D=0A\"",
",",
"' =0D=0A'",
",",
"'=0D=0A'",
"]",
",",
"[",
"\"=09\\r\\n\"",
",",
"\"=20\\r\\n\"",
",",
"\"\\r\\n... | Make sure CRLF is correct and HT/SPACE are in valid places. | [
"Make",
"sure",
"CRLF",
"is",
"correct",
"and",
"HT",
"/",
"SPACE",
"are",
"in",
"valid",
"places",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/Encoder/QpEncoder.php#L186-L196 | train | Standardize the string | [
30522,
2797,
3853,
3115,
4697,
1006,
5164,
1002,
5164,
1007,
1024,
5164,
1063,
1002,
5164,
1027,
2358,
2099,
1035,
5672,
1006,
1031,
1000,
1032,
1056,
1027,
1014,
2094,
1027,
1014,
2050,
1000,
1010,
1005,
1027,
1014,
2094,
1027,
1014,
205... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.compileUpdateColumns | protected function compileUpdateColumns($values)
{
return collect($values)->map(function ($value, $key) {
if ($this->isJsonSelector($key)) {
return $this->compileJsonUpdateColumn($key, new JsonExpression($value));
}
return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
} | php | protected function compileUpdateColumns($values)
{
return collect($values)->map(function ($value, $key) {
if ($this->isJsonSelector($key)) {
return $this->compileJsonUpdateColumn($key, new JsonExpression($value));
}
return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', ');
} | [
"protected",
"function",
"compileUpdateColumns",
"(",
"$",
"values",
")",
"{",
"return",
"collect",
"(",
"$",
"values",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isJsonSelector",
"("... | Compile all of the columns for an update statement.
@param array $values
@return string | [
"Compile",
"all",
"of",
"the",
"columns",
"for",
"an",
"update",
"statement",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php#L182-L191 | train | Compiles the update columns into a string | [
30522,
5123,
3853,
4012,
22090,
6279,
13701,
25778,
2819,
3619,
1006,
1002,
5300,
1007,
1063,
2709,
8145,
1006,
1002,
5300,
1007,
1011,
1028,
4949,
1006,
3853,
1006,
1002,
3643,
1010,
1002,
3145,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/ConfigurationUrlParser.php | ConfigurationUrlParser.getPrimaryOptions | protected function getPrimaryOptions($url)
{
return array_filter([
'driver' => $this->getDriver($url),
'database' => $this->getDatabase($url),
'host' => $url['host'] ?? null,
'port' => $url['port'] ?? null,
'username' => $url['user'] ?? null,
'password' => $url['pass'] ?? null,
], function ($value) {
return ! is_null($value);
});
} | php | protected function getPrimaryOptions($url)
{
return array_filter([
'driver' => $this->getDriver($url),
'database' => $this->getDatabase($url),
'host' => $url['host'] ?? null,
'port' => $url['port'] ?? null,
'username' => $url['user'] ?? null,
'password' => $url['pass'] ?? null,
], function ($value) {
return ! is_null($value);
});
} | [
"protected",
"function",
"getPrimaryOptions",
"(",
"$",
"url",
")",
"{",
"return",
"array_filter",
"(",
"[",
"'driver'",
"=>",
"$",
"this",
"->",
"getDriver",
"(",
"$",
"url",
")",
",",
"'database'",
"=>",
"$",
"this",
"->",
"getDatabase",
"(",
"$",
"url... | Get the primary database connection options.
@param array $url
@return array | [
"Get",
"the",
"primary",
"database",
"connection",
"options",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/ConfigurationUrlParser.php#L58-L70 | train | Get Primary Options | [
30522,
5123,
3853,
2131,
18098,
9581,
2854,
7361,
9285,
1006,
1002,
24471,
2140,
1007,
1063,
2709,
9140,
1035,
11307,
1006,
1031,
1005,
4062,
1005,
1027,
1028,
1002,
2023,
1011,
1028,
2131,
23663,
2099,
1006,
1002,
24471,
2140,
1007,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/VersionManager.php | VersionManager.removeDatabaseComment | protected function removeDatabaseComment($code, $version)
{
Db::table('system_plugin_history')
->where('code', $code)
->where('type', self::HISTORY_TYPE_COMMENT)
->where('version', $version)
->delete();
} | php | protected function removeDatabaseComment($code, $version)
{
Db::table('system_plugin_history')
->where('code', $code)
->where('type', self::HISTORY_TYPE_COMMENT)
->where('version', $version)
->delete();
} | [
"protected",
"function",
"removeDatabaseComment",
"(",
"$",
"code",
",",
"$",
"version",
")",
"{",
"Db",
"::",
"table",
"(",
"'system_plugin_history'",
")",
"->",
"where",
"(",
"'code'",
",",
"$",
"code",
")",
"->",
"where",
"(",
"'type'",
",",
"self",
"... | Removes a database update comment in the history table. | [
"Removes",
"a",
"database",
"update",
"comment",
"in",
"the",
"history",
"table",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/VersionManager.php#L375-L382 | train | Remove database comment | [
30522,
5123,
3853,
3718,
6790,
15058,
9006,
3672,
1006,
1002,
3642,
1010,
1002,
2544,
1007,
1063,
16962,
1024,
1024,
2795,
1006,
1005,
2291,
1035,
13354,
2378,
1035,
2381,
1005,
1007,
1011,
1028,
2073,
1006,
1005,
3642,
1005,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SegmentEditor/API.php | API.get | public function get($idSegment)
{
Piwik::checkUserHasSomeViewAccess();
if (!is_numeric($idSegment)) {
throw new Exception("idSegment should be numeric.");
}
$segment = $this->getModel()->getSegment($idSegment);
if (empty($segment)) {
return false;
}
try {
if (!$segment['enable_all_users']) {
Piwik::checkUserHasSuperUserAccessOrIsTheUser($segment['login']);
}
} catch (Exception $e) {
throw new Exception($this->getMessageCannotEditSegmentCreatedBySuperUser());
}
if ($segment['deleted']) {
throw new Exception("This segment is marked as deleted. ");
}
return $segment;
} | php | public function get($idSegment)
{
Piwik::checkUserHasSomeViewAccess();
if (!is_numeric($idSegment)) {
throw new Exception("idSegment should be numeric.");
}
$segment = $this->getModel()->getSegment($idSegment);
if (empty($segment)) {
return false;
}
try {
if (!$segment['enable_all_users']) {
Piwik::checkUserHasSuperUserAccessOrIsTheUser($segment['login']);
}
} catch (Exception $e) {
throw new Exception($this->getMessageCannotEditSegmentCreatedBySuperUser());
}
if ($segment['deleted']) {
throw new Exception("This segment is marked as deleted. ");
}
return $segment;
} | [
"public",
"function",
"get",
"(",
"$",
"idSegment",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeViewAccess",
"(",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"idSegment",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"idSegment should be numeric.\"",
... | Returns a stored segment by ID
@param $idSegment
@throws Exception
@return bool | [
"Returns",
"a",
"stored",
"segment",
"by",
"ID"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SegmentEditor/API.php#L307-L335 | train | Get the segment | [
30522,
2270,
3853,
2131,
1006,
1002,
8909,
3366,
21693,
4765,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
8584,
6305,
9623,
2015,
1006,
1007,
1025,
2065,
1006,
999,
2003,
1035,
16371,
25531,
1006,
1002,
8909,
3366,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.union | public function union($select = array(), $type = self::SQL_UNION)
{
if (!is_array($select)) {
// require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception(
"union() only accepts an array of Zend_Db_Select instances of sql query strings."
);
}
if (!in_array($type, self::$_unionTypes)) {
// require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception("Invalid union type '{$type}'");
}
foreach ($select as $target) {
$this->_parts[self::UNION][] = array($target, $type);
}
return $this;
} | php | public function union($select = array(), $type = self::SQL_UNION)
{
if (!is_array($select)) {
// require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception(
"union() only accepts an array of Zend_Db_Select instances of sql query strings."
);
}
if (!in_array($type, self::$_unionTypes)) {
// require_once 'Zend/Db/Select/Exception.php';
throw new Zend_Db_Select_Exception("Invalid union type '{$type}'");
}
foreach ($select as $target) {
$this->_parts[self::UNION][] = array($target, $type);
}
return $this;
} | [
"public",
"function",
"union",
"(",
"$",
"select",
"=",
"array",
"(",
")",
",",
"$",
"type",
"=",
"self",
"::",
"SQL_UNION",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"select",
")",
")",
"{",
"// require_once 'Zend/Db/Select/Exception.php';",
"throw"... | Adds a UNION clause to the query.
The first parameter has to be an array of Zend_Db_Select or
sql query strings.
<code>
$sql1 = $db->select();
$sql2 = "SELECT ...";
$select = $db->select()
->union(array($sql1, $sql2))
->order("id");
</code>
@param array $select Array of select clauses for the union.
@return Zend_Db_Select This Zend_Db_Select object. | [
"Adds",
"a",
"UNION",
"clause",
"to",
"the",
"query",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L280-L299 | train | union - Select a set of target values | [
30522,
2270,
3853,
2586,
1006,
1002,
7276,
1027,
9140,
1006,
1007,
1010,
1002,
2828,
1027,
2969,
1024,
1024,
29296,
1035,
2586,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
7276,
1007,
1007,
1063,
1013,
1013,
5478,
1035,
232... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Css/Style.php | Style.set_image_resolution | function set_image_resolution($val)
{
$parsed = $this->parse_image_resolution($val);
$this->_prop_cache["image_resolution"] = null;
$this->_props["image_resolution"] = $parsed;
} | php | function set_image_resolution($val)
{
$parsed = $this->parse_image_resolution($val);
$this->_prop_cache["image_resolution"] = null;
$this->_props["image_resolution"] = $parsed;
} | [
"function",
"set_image_resolution",
"(",
"$",
"val",
")",
"{",
"$",
"parsed",
"=",
"$",
"this",
"->",
"parse_image_resolution",
"(",
"$",
"val",
")",
";",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"image_resolution\"",
"]",
"=",
"null",
";",
"$",
"this",
... | auto | normal | dpi
@param $val | [
"auto",
"|",
"normal",
"|",
"dpi"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L2838-L2844 | train | Set the image resolution | [
30522,
3853,
2275,
1035,
3746,
1035,
5813,
1006,
1002,
11748,
1007,
1063,
1002,
11968,
6924,
1027,
1002,
2023,
1011,
1028,
11968,
3366,
1035,
3746,
1035,
5813,
1006,
1002,
11748,
1007,
1025,
1002,
2023,
1011,
1028,
1035,
17678,
1035,
17053,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | BelongsToMany.firstOrCreate | public function firstOrCreate(array $attributes, array $joining = [], $touch = true)
{
if (is_null($instance = $this->where($attributes)->first())) {
$instance = $this->create($attributes, $joining, $touch);
}
return $instance;
} | php | public function firstOrCreate(array $attributes, array $joining = [], $touch = true)
{
if (is_null($instance = $this->where($attributes)->first())) {
$instance = $this->create($attributes, $joining, $touch);
}
return $instance;
} | [
"public",
"function",
"firstOrCreate",
"(",
"array",
"$",
"attributes",
",",
"array",
"$",
"joining",
"=",
"[",
"]",
",",
"$",
"touch",
"=",
"true",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"instance",
"=",
"$",
"this",
"->",
"where",
"(",
"$",
"a... | Get the first related record matching the attributes or create it.
@param array $attributes
@param array $joining
@param bool $touch
@return \Illuminate\Database\Eloquent\Model | [
"Get",
"the",
"first",
"related",
"record",
"matching",
"the",
"attributes",
"or",
"create",
"it",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L467-L474 | train | First or Create a single record | [
30522,
2270,
3853,
2034,
2953,
16748,
3686,
1006,
9140,
1002,
12332,
1010,
9140,
1002,
5241,
1027,
1031,
1033,
1010,
1002,
3543,
1027,
2995,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
6013,
1027,
1002,
2023,
1011,
1028,
2073,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpClient/HttpClient.php | HttpClient.create | public static function create(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50): HttpClientInterface
{
if (\extension_loaded('curl')) {
return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes);
}
return new NativeHttpClient($defaultOptions, $maxHostConnections);
} | php | public static function create(array $defaultOptions = [], int $maxHostConnections = 6, int $maxPendingPushes = 50): HttpClientInterface
{
if (\extension_loaded('curl')) {
return new CurlHttpClient($defaultOptions, $maxHostConnections, $maxPendingPushes);
}
return new NativeHttpClient($defaultOptions, $maxHostConnections);
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"defaultOptions",
"=",
"[",
"]",
",",
"int",
"$",
"maxHostConnections",
"=",
"6",
",",
"int",
"$",
"maxPendingPushes",
"=",
"50",
")",
":",
"HttpClientInterface",
"{",
"if",
"(",
"\\",
"extension... | @param array $defaultOptions Default requests' options
@param int $maxHostConnections The maximum number of connections to a single host
@param int $maxPendingPushes The maximum number of pushed responses to accept in the queue
@see HttpClientInterface::OPTIONS_DEFAULTS for available options | [
"@param",
"array",
"$defaultOptions",
"Default",
"requests",
"options",
"@param",
"int",
"$maxHostConnections",
"The",
"maximum",
"number",
"of",
"connections",
"to",
"a",
"single",
"host",
"@param",
"int",
"$maxPendingPushes",
"The",
"maximum",
"number",
"of",
"pus... | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/HttpClient.php#L32-L39 | train | Create a new HTTP client | [
30522,
2270,
10763,
3853,
3443,
1006,
9140,
1002,
12398,
7361,
9285,
1027,
1031,
1033,
1010,
20014,
1002,
4098,
15006,
13535,
18256,
22014,
1027,
1020,
1010,
20014,
1002,
4098,
11837,
4667,
12207,
15689,
1027,
2753,
1007,
1024,
8299,
20464,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/controllers/Updates.php | Updates.appendRequiredPlugins | protected function appendRequiredPlugins(array $plugins, array $result)
{
foreach ((array) array_get($result, 'require') as $plugin) {
if (
($name = array_get($plugin, 'code')) &&
($hash = array_get($plugin, 'hash')) &&
!PluginManager::instance()->hasPlugin($name)
) {
$plugins[$name] = $hash;
}
}
return $plugins;
} | php | protected function appendRequiredPlugins(array $plugins, array $result)
{
foreach ((array) array_get($result, 'require') as $plugin) {
if (
($name = array_get($plugin, 'code')) &&
($hash = array_get($plugin, 'hash')) &&
!PluginManager::instance()->hasPlugin($name)
) {
$plugins[$name] = $hash;
}
}
return $plugins;
} | [
"protected",
"function",
"appendRequiredPlugins",
"(",
"array",
"$",
"plugins",
",",
"array",
"$",
"result",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"array_get",
"(",
"$",
"result",
",",
"'require'",
")",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
... | Adds require plugin codes to the collection based on a result.
@param array $plugins
@param array $result
@return array | [
"Adds",
"require",
"plugin",
"codes",
"to",
"the",
"collection",
"based",
"on",
"a",
"result",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/controllers/Updates.php#L986-L999 | train | Append required plugins to the list | [
30522,
5123,
3853,
10439,
10497,
2890,
15549,
5596,
24759,
15916,
7076,
1006,
9140,
1002,
13354,
7076,
1010,
9140,
1002,
2765,
1007,
1063,
18921,
6776,
1006,
1006,
9140,
1007,
9140,
1035,
2131,
1006,
1002,
2765,
1010,
1005,
5478,
1005,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php | LoadEnvironmentVariables.bootstrap | public function bootstrap(Application $app)
{
if ($app->configurationIsCached()) {
return;
}
$this->checkForSpecificEnvironmentFile($app);
try {
$this->createDotenv($app)->safeLoad();
} catch (InvalidFileException $e) {
$this->writeErrorAndDie($e);
}
} | php | public function bootstrap(Application $app)
{
if ($app->configurationIsCached()) {
return;
}
$this->checkForSpecificEnvironmentFile($app);
try {
$this->createDotenv($app)->safeLoad();
} catch (InvalidFileException $e) {
$this->writeErrorAndDie($e);
}
} | [
"public",
"function",
"bootstrap",
"(",
"Application",
"$",
"app",
")",
"{",
"if",
"(",
"$",
"app",
"->",
"configurationIsCached",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"checkForSpecificEnvironmentFile",
"(",
"$",
"app",
")",
";",
"t... | Bootstrap the given application.
@param \Illuminate\Contracts\Foundation\Application $app
@return void | [
"Bootstrap",
"the",
"given",
"application",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php#L23-L36 | train | Bootstraps the environment file. | [
30522,
2270,
3853,
6879,
6494,
2361,
1006,
4646,
1002,
10439,
1007,
1063,
2065,
1006,
1002,
10439,
1011,
1028,
9563,
2483,
3540,
7690,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
4638,
29278,
13102,
8586,
23664,
2078,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Translator.php | Translator.transChoice | public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED);
if (!$this->formatter instanceof ChoiceMessageFormatterInterface) {
throw new LogicException(sprintf('The formatter "%s" does not support plural translations.', \get_class($this->formatter)));
}
if (null === $domain) {
$domain = 'messages';
}
$id = (string) $id;
$catalogue = $this->getCatalogue($locale);
$locale = $catalogue->getLocale();
while (!$catalogue->defines($id, $domain)) {
if ($cat = $catalogue->getFallbackCatalogue()) {
$catalogue = $cat;
$locale = $catalogue->getLocale();
} else {
break;
}
}
if ($this->hasIntlFormatter && $catalogue->defines($id, $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
return $this->formatter->formatIntl($catalogue->get($id, $domain), $locale, ['%count%' => $number] + $parameters);
}
return $this->formatter->choiceFormat($catalogue->get($id, $domain), $number, $locale, $parameters);
} | php | public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED);
if (!$this->formatter instanceof ChoiceMessageFormatterInterface) {
throw new LogicException(sprintf('The formatter "%s" does not support plural translations.', \get_class($this->formatter)));
}
if (null === $domain) {
$domain = 'messages';
}
$id = (string) $id;
$catalogue = $this->getCatalogue($locale);
$locale = $catalogue->getLocale();
while (!$catalogue->defines($id, $domain)) {
if ($cat = $catalogue->getFallbackCatalogue()) {
$catalogue = $cat;
$locale = $catalogue->getLocale();
} else {
break;
}
}
if ($this->hasIntlFormatter && $catalogue->defines($id, $domain.MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
return $this->formatter->formatIntl($catalogue->get($id, $domain), $locale, ['%count%' => $number] + $parameters);
}
return $this->formatter->choiceFormat($catalogue->get($id, $domain), $number, $locale, $parameters);
} | [
"public",
"function",
"transChoice",
"(",
"$",
"id",
",",
"$",
"number",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'The \"%s... | {@inheritdoc}
@deprecated since Symfony 4.2, use the trans() method instead with a %count% parameter | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Translator.php#L227-L256 | train | Returns the plural form of the given message. | [
30522,
2270,
3853,
9099,
9905,
6610,
1006,
1002,
8909,
1010,
1002,
2193,
1010,
9140,
1002,
11709,
1027,
1031,
1033,
1010,
1002,
5884,
1027,
19701,
1010,
1002,
2334,
2063,
1027,
19701,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.