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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
symfony/symfony | src/Symfony/Component/HttpFoundation/HeaderUtils.php | HeaderUtils.toString | public static function toString(array $assoc, string $separator): string
{
$parts = [];
foreach ($assoc as $name => $value) {
if (true === $value) {
$parts[] = $name;
} else {
$parts[] = $name.'='.self::quote($value);
}
}
return implode($separator.' ', $parts);
} | php | public static function toString(array $assoc, string $separator): string
{
$parts = [];
foreach ($assoc as $name => $value) {
if (true === $value) {
$parts[] = $name;
} else {
$parts[] = $name.'='.self::quote($value);
}
}
return implode($separator.' ', $parts);
} | [
"public",
"static",
"function",
"toString",
"(",
"array",
"$",
"assoc",
",",
"string",
"$",
"separator",
")",
":",
"string",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"assoc",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",... | Joins an associative array into a string for use in an HTTP header.
The key and value of each entry are joined with "=", and all entries
are joined with the specified separator and an additional space (for
readability). Values are quoted if necessary.
Example:
HeaderUtils::toString(["foo" => "abc", "bar" => true, "baz" => "a b c"], ",")
// => 'foo=abc, bar, baz="a b c"' | [
"Joins",
"an",
"associative",
"array",
"into",
"a",
"string",
"for",
"use",
"in",
"an",
"HTTP",
"header",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/HeaderUtils.php#L108-L120 | train | Returns the string representation of the array | [
30522,
2270,
10763,
3853,
2000,
3367,
4892,
1006,
9140,
1002,
4632,
10085,
1010,
5164,
1002,
19802,
25879,
2953,
1007,
1024,
5164,
1063,
1002,
3033,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
4632,
10085,
2004,
1002,
2171,
1027,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/behaviors/ListController.php | ListController.index_onDelete | public function index_onDelete()
{
if (method_exists($this->controller, 'onDelete')) {
return call_user_func_array([$this->controller, 'onDelete'], func_get_args());
}
/*
* Validate checked identifiers
*/
$checkedIds = post('checked');
if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) {
Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
return $this->controller->listRefresh();
}
/*
* Establish the list definition
*/
$definition = post('definition', $this->primaryDefinition);
if (!isset($this->listDefinitions[$definition])) {
throw new ApplicationException(Lang::get('backend::lang.list.missing_parent_definition', compact('definition')));
}
$listConfig = $this->controller->listGetConfig($definition);
/*
* Create the model
*/
$class = $listConfig->modelClass;
$model = new $class;
$model = $this->controller->listExtendModel($model, $definition);
/*
* Create the query
*/
$query = $model->newQuery();
$this->controller->listExtendQueryBefore($query, $definition);
$query->whereIn($model->getKeyName(), $checkedIds);
$this->controller->listExtendQuery($query, $definition);
/*
* Delete records
*/
$records = $query->get();
if ($records->count()) {
foreach ($records as $record) {
$record->delete();
}
Flash::success(Lang::get('backend::lang.list.delete_selected_success'));
}
else {
Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
}
return $this->controller->listRefresh($definition);
} | php | public function index_onDelete()
{
if (method_exists($this->controller, 'onDelete')) {
return call_user_func_array([$this->controller, 'onDelete'], func_get_args());
}
/*
* Validate checked identifiers
*/
$checkedIds = post('checked');
if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) {
Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
return $this->controller->listRefresh();
}
/*
* Establish the list definition
*/
$definition = post('definition', $this->primaryDefinition);
if (!isset($this->listDefinitions[$definition])) {
throw new ApplicationException(Lang::get('backend::lang.list.missing_parent_definition', compact('definition')));
}
$listConfig = $this->controller->listGetConfig($definition);
/*
* Create the model
*/
$class = $listConfig->modelClass;
$model = new $class;
$model = $this->controller->listExtendModel($model, $definition);
/*
* Create the query
*/
$query = $model->newQuery();
$this->controller->listExtendQueryBefore($query, $definition);
$query->whereIn($model->getKeyName(), $checkedIds);
$this->controller->listExtendQuery($query, $definition);
/*
* Delete records
*/
$records = $query->get();
if ($records->count()) {
foreach ($records as $record) {
$record->delete();
}
Flash::success(Lang::get('backend::lang.list.delete_selected_success'));
}
else {
Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
}
return $this->controller->listRefresh($definition);
} | [
"public",
"function",
"index_onDelete",
"(",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"controller",
",",
"'onDelete'",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"controller",
",",
"'onDelete'",
"]",
... | Bulk delete records.
@return void | [
"Bulk",
"delete",
"records",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/ListController.php#L285-L345 | train | Delete selected records | [
30522,
2270,
3853,
5950,
1035,
2006,
9247,
12870,
1006,
1007,
1063,
2065,
1006,
4118,
1035,
6526,
1006,
1002,
2023,
1011,
1028,
11486,
1010,
1005,
2006,
9247,
12870,
1005,
1007,
1007,
1063,
2709,
2655,
1035,
5310,
1035,
4569,
2278,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.union | public function union($query, $all = false)
{
if ($query instanceof Closure) {
call_user_func($query, $query = $this->newQuery());
}
$this->unions[] = compact('query', 'all');
$this->addBinding($query->getBindings(), 'union');
return $this;
} | php | public function union($query, $all = false)
{
if ($query instanceof Closure) {
call_user_func($query, $query = $this->newQuery());
}
$this->unions[] = compact('query', 'all');
$this->addBinding($query->getBindings(), 'union');
return $this;
} | [
"public",
"function",
"union",
"(",
"$",
"query",
",",
"$",
"all",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"query",
"instanceof",
"Closure",
")",
"{",
"call_user_func",
"(",
"$",
"query",
",",
"$",
"query",
"=",
"$",
"this",
"->",
"newQuery",
"(",
... | Add a union statement to the query.
@param \Illuminate\Database\Query\Builder|\Closure $query
@param bool $all
@return \Illuminate\Database\Query\Builder|static | [
"Add",
"a",
"union",
"statement",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L2007-L2018 | train | union with another query | [
30522,
2270,
3853,
2586,
1006,
1002,
23032,
1010,
1002,
2035,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
23032,
6013,
11253,
8503,
1007,
1063,
2655,
1035,
5310,
1035,
4569,
2278,
1006,
1002,
23032,
1010,
1002,
23032,
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... |
symfony/symfony | src/Symfony/Component/Cache/Psr16Cache.php | Psr16Cache.deleteMultiple | public function deleteMultiple($keys)
{
if ($keys instanceof \Traversable) {
$keys = iterator_to_array($keys, false);
} elseif (!\is_array($keys)) {
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
}
try {
return $this->pool->deleteItems($keys);
} catch (SimpleCacheException $e) {
throw $e;
} catch (Psr6CacheException $e) {
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
} | php | public function deleteMultiple($keys)
{
if ($keys instanceof \Traversable) {
$keys = iterator_to_array($keys, false);
} elseif (!\is_array($keys)) {
throw new InvalidArgumentException(sprintf('Cache keys must be array or Traversable, "%s" given', \is_object($keys) ? \get_class($keys) : \gettype($keys)));
}
try {
return $this->pool->deleteItems($keys);
} catch (SimpleCacheException $e) {
throw $e;
} catch (Psr6CacheException $e) {
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"deleteMultiple",
"(",
"$",
"keys",
")",
"{",
"if",
"(",
"$",
"keys",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"keys",
"=",
"iterator_to_array",
"(",
"$",
"keys",
",",
"false",
")",
";",
"}",
"elseif",
"(",
"!",
"\\",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Psr16Cache.php#L233-L248 | train | Delete multiple cache items | [
30522,
2270,
3853,
3972,
12870,
12274,
7096,
11514,
2571,
1006,
1002,
6309,
1007,
1063,
2065,
1006,
1002,
6309,
6013,
11253,
1032,
29053,
3085,
1007,
1063,
1002,
6309,
1027,
2009,
6906,
4263,
1035,
2000,
1035,
9140,
1006,
1002,
6309,
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... |
matomo-org/matomo | core/Db/Schema/Mysql.php | Mysql.getTableColumns | public function getTableColumns($tableName)
{
$db = $this->getDb();
$allColumns = $db->fetchAll("SHOW COLUMNS FROM " . $tableName);
$fields = array();
foreach ($allColumns as $column) {
$fields[trim($column['Field'])] = $column;
}
return $fields;
} | php | public function getTableColumns($tableName)
{
$db = $this->getDb();
$allColumns = $db->fetchAll("SHOW COLUMNS FROM " . $tableName);
$fields = array();
foreach ($allColumns as $column) {
$fields[trim($column['Field'])] = $column;
}
return $fields;
} | [
"public",
"function",
"getTableColumns",
"(",
"$",
"tableName",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
";",
"$",
"allColumns",
"=",
"$",
"db",
"->",
"fetchAll",
"(",
"\"SHOW COLUMNS FROM \"",
".",
"$",
"tableName",
")",
";",
"$... | Get list of installed columns in a table
@param string $tableName The name of a table.
@return array Installed columns indexed by the column name. | [
"Get",
"list",
"of",
"installed",
"columns",
"in",
"a",
"table"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Schema/Mysql.php#L362-L374 | train | Get Table Columns | [
30522,
2270,
3853,
2131,
10880,
25778,
2819,
3619,
1006,
1002,
2795,
18442,
1007,
1063,
1002,
16962,
1027,
1002,
2023,
1011,
1028,
2131,
18939,
1006,
1007,
1025,
1002,
2035,
25778,
2819,
3619,
1027,
1002,
16962,
1011,
1028,
18584,
8095,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php | InteractsWithPivotTable.updateExistingPivotUsingCustomClass | protected function updateExistingPivotUsingCustomClass($id, array $attributes, $touch)
{
$updated = $this->newPivot([
$this->foreignPivotKey => $this->parent->{$this->parentKey},
$this->relatedPivotKey => $this->parseId($id),
], true)->fill($attributes)->save();
if ($touch) {
$this->touchIfTouching();
}
return (int) $updated;
} | php | protected function updateExistingPivotUsingCustomClass($id, array $attributes, $touch)
{
$updated = $this->newPivot([
$this->foreignPivotKey => $this->parent->{$this->parentKey},
$this->relatedPivotKey => $this->parseId($id),
], true)->fill($attributes)->save();
if ($touch) {
$this->touchIfTouching();
}
return (int) $updated;
} | [
"protected",
"function",
"updateExistingPivotUsingCustomClass",
"(",
"$",
"id",
",",
"array",
"$",
"attributes",
",",
"$",
"touch",
")",
"{",
"$",
"updated",
"=",
"$",
"this",
"->",
"newPivot",
"(",
"[",
"$",
"this",
"->",
"foreignPivotKey",
"=>",
"$",
"th... | Update an existing pivot record on the table via a custom class.
@param mixed $id
@param array $attributes
@param bool $touch
@return int | [
"Update",
"an",
"existing",
"pivot",
"record",
"on",
"the",
"table",
"via",
"a",
"custom",
"class",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php#L214-L226 | train | Update existing pivot using custom class | [
30522,
5123,
3853,
10651,
10288,
2923,
2075,
8197,
22994,
18161,
7874,
20389,
26266,
1006,
1002,
8909,
1010,
9140,
1002,
12332,
1010,
1002,
3543,
1007,
1063,
1002,
7172,
1027,
1002,
2023,
1011,
1028,
2047,
8197,
22994,
1006,
1031,
1002,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Tasks.php | Tasks.hourly | protected function hourly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY)
{
return $this->custom($this, $methodName, $methodParameter, 'hourly', $priority);
} | php | protected function hourly($methodName, $methodParameter = null, $priority = self::NORMAL_PRIORITY)
{
return $this->custom($this, $methodName, $methodParameter, 'hourly', $priority);
} | [
"protected",
"function",
"hourly",
"(",
"$",
"methodName",
",",
"$",
"methodParameter",
"=",
"null",
",",
"$",
"priority",
"=",
"self",
"::",
"NORMAL_PRIORITY",
")",
"{",
"return",
"$",
"this",
"->",
"custom",
"(",
"$",
"this",
",",
"$",
"methodName",
",... | Schedule the given tasks/method to run once every hour.
@param string $methodName The name of the method that will be called when the task is being
exectuted. To make it work you need to create a public method having the
given method name in your Tasks class.
@param null|string $methodParameter Can be null if the task does not need any parameter or a string. It is not
possible to specify multiple parameters as an array etc. If you need to
pass multiple parameters separate them via any characters such as '###'.
For instance '$param1###$param2###$param3'
@param int $priority Can be any constant such as self::LOW_PRIORITY
@return Schedule
@api | [
"Schedule",
"the",
"given",
"tasks",
"/",
"method",
"to",
"run",
"once",
"every",
"hour",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Tasks.php#L66-L69 | train | Protected hourly method | [
30522,
5123,
3853,
21462,
1006,
1002,
4118,
18442,
1010,
1002,
4118,
28689,
22828,
1027,
19701,
1010,
1002,
9470,
1027,
2969,
1024,
1024,
3671,
1035,
9470,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7661,
1006,
1002,
2023,
1010,
1002,
4118,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | BelongsToMany.chunkById | public function chunkById($count, callable $callback, $column = null, $alias = null)
{
$this->query->addSelect($this->shouldSelect());
$column = $column ?? $this->getRelated()->qualifyColumn(
$this->getRelatedKeyName()
);
$alias = $alias ?? $this->getRelatedKeyName();
return $this->query->chunkById($count, function ($results) use ($callback) {
$this->hydratePivotRelation($results->all());
return $callback($results);
}, $column, $alias);
} | php | public function chunkById($count, callable $callback, $column = null, $alias = null)
{
$this->query->addSelect($this->shouldSelect());
$column = $column ?? $this->getRelated()->qualifyColumn(
$this->getRelatedKeyName()
);
$alias = $alias ?? $this->getRelatedKeyName();
return $this->query->chunkById($count, function ($results) use ($callback) {
$this->hydratePivotRelation($results->all());
return $callback($results);
}, $column, $alias);
} | [
"public",
"function",
"chunkById",
"(",
"$",
"count",
",",
"callable",
"$",
"callback",
",",
"$",
"column",
"=",
"null",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"addSelect",
"(",
"$",
"this",
"->",
"shouldSelect",
... | Chunk the results of a query by comparing numeric IDs.
@param int $count
@param callable $callback
@param string|null $column
@param string|null $alias
@return bool | [
"Chunk",
"the",
"results",
"of",
"a",
"query",
"by",
"comparing",
"numeric",
"IDs",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L717-L732 | train | Returns a chunk of results from the query by ID. | [
30522,
2270,
3853,
20000,
3762,
3593,
1006,
1002,
4175,
1010,
2655,
3085,
1002,
2655,
5963,
1010,
1002,
5930,
1027,
19701,
1010,
1002,
14593,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
23032,
1011,
1028,
9909,
12260,
6593,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/Store/Client.php | Client.list | public function list(int $offset = 0, int $limit = 10)
{
$params = [
'offset' => $offset,
'limit' => $limit,
];
return $this->httpPostJson('wxa/get_store_list', $params);
} | php | public function list(int $offset = 0, int $limit = 10)
{
$params = [
'offset' => $offset,
'limit' => $limit,
];
return $this->httpPostJson('wxa/get_store_list', $params);
} | [
"public",
"function",
"list",
"(",
"int",
"$",
"offset",
"=",
"0",
",",
"int",
"$",
"limit",
"=",
"10",
")",
"{",
"$",
"params",
"=",
"[",
"'offset'",
"=>",
"$",
"offset",
",",
"'limit'",
"=>",
"$",
"limit",
",",
"]",
";",
"return",
"$",
"this",
... | List store.
@param int $offset
@param int $limit
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string | [
"List",
"store",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Store/Client.php#L154-L162 | train | Get store list | [
30522,
2270,
3853,
2862,
1006,
20014,
1002,
16396,
1027,
1014,
1010,
20014,
1002,
5787,
1027,
2184,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
16396,
1005,
1027,
1028,
1002,
16396,
1010,
1005,
5787,
1005,
1027,
1028,
1002,
5787,
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... |
matomo-org/matomo | core/Columns/Dimension.php | Dimension.uninstall | public function uninstall()
{
if (empty($this->columnName) || empty($this->columnType) || empty($this->dbTableName)) {
return;
}
try {
$sql = "ALTER TABLE `" . Common::prefixTable($this->dbTableName) . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
} | php | public function uninstall()
{
if (empty($this->columnName) || empty($this->columnType) || empty($this->dbTableName)) {
return;
}
try {
$sql = "ALTER TABLE `" . Common::prefixTable($this->dbTableName) . "` DROP COLUMN `$this->columnName`";
Db::exec($sql);
} catch (Exception $e) {
if (!Db::get()->isErrNo($e, '1091')) {
throw $e;
}
}
} | [
"public",
"function",
"uninstall",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"columnName",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"columnType",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"dbTableName",
")",
")",
"{",
"return",
... | Uninstalls the dimension if a {@link $columnName} and {@link columnType} is set. In case you perform any custom
actions during {@link install()} - for instance adding an index - you should make sure to undo those actions by
overwriting this method. Make sure to call this parent method to make sure the uninstallation of the column
will be done.
@throws Exception
@api | [
"Uninstalls",
"the",
"dimension",
"if",
"a",
"{"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L314-L328 | train | Uninstalls the column | [
30522,
2270,
3853,
4895,
7076,
9080,
2140,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
5930,
18442,
1007,
1064,
1064,
4064,
1006,
1002,
2023,
1011,
1028,
5930,
13874,
1007,
1064,
1064,
4064,
1006,
1002,
2023,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
spatie/laravel-permission | src/Models/Role.php | Role.hasPermissionTo | public function hasPermissionTo($permission): bool
{
$permissionClass = $this->getPermissionClass();
if (is_string($permission)) {
$permission = $permissionClass->findByName($permission, $this->getDefaultGuardName());
}
if (is_int($permission)) {
$permission = $permissionClass->findById($permission, $this->getDefaultGuardName());
}
if (! $this->getGuardNames()->contains($permission->guard_name)) {
throw GuardDoesNotMatch::create($permission->guard_name, $this->getGuardNames());
}
return $this->permissions->contains('id', $permission->id);
} | php | public function hasPermissionTo($permission): bool
{
$permissionClass = $this->getPermissionClass();
if (is_string($permission)) {
$permission = $permissionClass->findByName($permission, $this->getDefaultGuardName());
}
if (is_int($permission)) {
$permission = $permissionClass->findById($permission, $this->getDefaultGuardName());
}
if (! $this->getGuardNames()->contains($permission->guard_name)) {
throw GuardDoesNotMatch::create($permission->guard_name, $this->getGuardNames());
}
return $this->permissions->contains('id', $permission->id);
} | [
"public",
"function",
"hasPermissionTo",
"(",
"$",
"permission",
")",
":",
"bool",
"{",
"$",
"permissionClass",
"=",
"$",
"this",
"->",
"getPermissionClass",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"permission",
")",
")",
"{",
"$",
"permission",
... | Determine if the user may perform the given permission.
@param string|Permission $permission
@return bool
@throws \Spatie\Permission\Exceptions\GuardDoesNotMatch | [
"Determine",
"if",
"the",
"user",
"may",
"perform",
"the",
"given",
"permission",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Models/Role.php#L140-L157 | train | Check if the user has the given permission | [
30522,
2270,
3853,
2038,
4842,
25481,
3406,
1006,
1002,
6656,
1007,
1024,
22017,
2140,
1063,
1002,
6656,
26266,
1027,
1002,
2023,
1011,
1028,
2131,
4842,
25481,
26266,
1006,
1007,
1025,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
6656,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Kernel/Traits/ResponseCastable.php | ResponseCastable.detectAndCastResponseToType | protected function detectAndCastResponseToType($response, $type = null)
{
switch (true) {
case $response instanceof ResponseInterface:
$response = Response::buildFromPsrResponse($response);
break;
case $response instanceof Arrayable:
$response = new Response(200, [], json_encode($response->toArray()));
break;
case ($response instanceof Collection) || is_array($response) || is_object($response):
$response = new Response(200, [], json_encode($response));
break;
case is_scalar($response):
$response = new Response(200, [], $response);
break;
default:
throw new InvalidArgumentException(sprintf('Unsupported response type "%s"', gettype($response)));
}
return $this->castResponseToType($response, $type);
} | php | protected function detectAndCastResponseToType($response, $type = null)
{
switch (true) {
case $response instanceof ResponseInterface:
$response = Response::buildFromPsrResponse($response);
break;
case $response instanceof Arrayable:
$response = new Response(200, [], json_encode($response->toArray()));
break;
case ($response instanceof Collection) || is_array($response) || is_object($response):
$response = new Response(200, [], json_encode($response));
break;
case is_scalar($response):
$response = new Response(200, [], $response);
break;
default:
throw new InvalidArgumentException(sprintf('Unsupported response type "%s"', gettype($response)));
}
return $this->castResponseToType($response, $type);
} | [
"protected",
"function",
"detectAndCastResponseToType",
"(",
"$",
"response",
",",
"$",
"type",
"=",
"null",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"response",
"instanceof",
"ResponseInterface",
":",
"$",
"response",
"=",
"Response",
"::",
"... | @param mixed $response
@param string|null $type
@return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"@param",
"mixed",
"$response",
"@param",
"string|null",
"$type"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/Traits/ResponseCastable.php#L71-L95 | train | Detects and casts the response to the specified type | [
30522,
5123,
3853,
11487,
5685,
10526,
6072,
26029,
13462,
26305,
1006,
1002,
3433,
1010,
1002,
2828,
1027,
19701,
1007,
1063,
6942,
1006,
2995,
1007,
1063,
2553,
1002,
3433,
6013,
11253,
3433,
18447,
2121,
12172,
1024,
1002,
3433,
1027,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HasMany.php | HasMany.setupScript | protected function setupScript($script)
{
$method = 'setupScriptFor'.ucfirst($this->viewMode).'View';
call_user_func([$this, $method], $script);
} | php | protected function setupScript($script)
{
$method = 'setupScriptFor'.ucfirst($this->viewMode).'View';
call_user_func([$this, $method], $script);
} | [
"protected",
"function",
"setupScript",
"(",
"$",
"script",
")",
"{",
"$",
"method",
"=",
"'setupScriptFor'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"viewMode",
")",
".",
"'View'",
";",
"call_user_func",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
... | Setup script for this field in different view mode.
@param string $script
@return void | [
"Setup",
"script",
"for",
"this",
"field",
"in",
"different",
"view",
"mode",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/HasMany.php#L414-L419 | train | Setup script for current view mode | [
30522,
5123,
3853,
16437,
22483,
1006,
1002,
5896,
1007,
1063,
1002,
4118,
1027,
1005,
16437,
22483,
29278,
1005,
1012,
15384,
8873,
12096,
1006,
1002,
2023,
1011,
1028,
3193,
5302,
3207,
1007,
1012,
1005,
3193,
1005,
1025,
2655,
1035,
5310... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Console/Gpm/IndexCommand.php | IndexCommand.version | private function version($package)
{
$list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}();
$package = $list[$package->slug] ?? $package;
$type = ucfirst(preg_replace('/s$/', '', $package->package_type));
$updatable = $this->gpm->{'is' . $type . 'Updatable'}($package->slug);
$installed = $this->gpm->{'is' . $type . 'Installed'}($package->slug);
$local = $this->gpm->{'getInstalled' . $type}($package->slug);
if (!$installed || !$updatable) {
$version = $installed ? $local->version : $package->version;
return "v<green>{$version}</green>";
}
if ($updatable) {
return "v<red>{$package->version}</red> <cyan>-></cyan> v<green>{$package->available}</green>";
}
return '';
} | php | private function version($package)
{
$list = $this->gpm->{'getUpdatable' . ucfirst($package->package_type)}();
$package = $list[$package->slug] ?? $package;
$type = ucfirst(preg_replace('/s$/', '', $package->package_type));
$updatable = $this->gpm->{'is' . $type . 'Updatable'}($package->slug);
$installed = $this->gpm->{'is' . $type . 'Installed'}($package->slug);
$local = $this->gpm->{'getInstalled' . $type}($package->slug);
if (!$installed || !$updatable) {
$version = $installed ? $local->version : $package->version;
return "v<green>{$version}</green>";
}
if ($updatable) {
return "v<red>{$package->version}</red> <cyan>-></cyan> v<green>{$package->available}</green>";
}
return '';
} | [
"private",
"function",
"version",
"(",
"$",
"package",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"gpm",
"->",
"{",
"'getUpdatable'",
".",
"ucfirst",
"(",
"$",
"package",
"->",
"package_type",
")",
"}",
"(",
")",
";",
"$",
"package",
"=",
"$",
... | @param Package $package
@return string | [
"@param",
"Package",
"$package"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/Gpm/IndexCommand.php#L154-L173 | train | Return version of package | [
30522,
2797,
3853,
2544,
1006,
1002,
7427,
1007,
1063,
1002,
2862,
1027,
1002,
2023,
1011,
1028,
14246,
2213,
1011,
1028,
1063,
1005,
2131,
6279,
2850,
10880,
1005,
1012,
15384,
8873,
12096,
1006,
1002,
7427,
1011,
1028,
7427,
1035,
2828,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Filesystem/Filesystem.php | Filesystem.parent | public function parent(string $path, int $levels = 1): string
{
[$scheme, $path] = $this->getSchemeAndHierarchy($path);
if ($this->normalize !== false) {
$path = $this->normalizePathPart($path);
}
if ($path === '' || $path === '.') {
return '';
}
[$scheme, $parent] = $this->dirnameInternal($scheme, $path, $levels);
return $parent !== $path ? $this->toString($scheme, $parent) : '';
} | php | public function parent(string $path, int $levels = 1): string
{
[$scheme, $path] = $this->getSchemeAndHierarchy($path);
if ($this->normalize !== false) {
$path = $this->normalizePathPart($path);
}
if ($path === '' || $path === '.') {
return '';
}
[$scheme, $parent] = $this->dirnameInternal($scheme, $path, $levels);
return $parent !== $path ? $this->toString($scheme, $parent) : '';
} | [
"public",
"function",
"parent",
"(",
"string",
"$",
"path",
",",
"int",
"$",
"levels",
"=",
"1",
")",
":",
"string",
"{",
"[",
"$",
"scheme",
",",
"$",
"path",
"]",
"=",
"$",
"this",
"->",
"getSchemeAndHierarchy",
"(",
"$",
"path",
")",
";",
"if",
... | {@inheritdoc}
@see FilesystemInterface::parent() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Filesystem/Filesystem.php#L102-L117 | train | Get parent of path | [
30522,
2270,
3853,
6687,
1006,
5164,
1002,
4130,
1010,
20014,
1002,
3798,
1027,
1015,
1007,
1024,
5164,
1063,
1031,
1002,
5679,
1010,
1002,
4130,
1033,
1027,
1002,
2023,
1011,
1028,
4152,
5403,
4168,
5685,
4048,
6906,
29389,
1006,
1002,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/twig/Extension.php | Extension.getFilters | public function getFilters()
{
$filters = [
new Twig_SimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]),
];
/*
* Include extensions provided by plugins
*/
$filters = $this->markupManager->makeTwigFilters($filters);
return $filters;
} | php | public function getFilters()
{
$filters = [
new Twig_SimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('media', [$this, 'mediaFilter'], ['is_safe' => ['html']]),
];
/*
* Include extensions provided by plugins
*/
$filters = $this->markupManager->makeTwigFilters($filters);
return $filters;
} | [
"public",
"function",
"getFilters",
"(",
")",
"{",
"$",
"filters",
"=",
"[",
"new",
"Twig_SimpleFilter",
"(",
"'app'",
",",
"[",
"$",
"this",
",",
"'appFilter'",
"]",
",",
"[",
"'is_safe'",
"=>",
"[",
"'html'",
"]",
"]",
")",
",",
"new",
"Twig_SimpleFi... | Returns a list of filters this extensions provides.
@return array An array of filters | [
"Returns",
"a",
"list",
"of",
"filters",
"this",
"extensions",
"provides",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/twig/Extension.php#L53-L66 | train | Get filters for this page | [
30522,
2270,
3853,
2131,
8873,
21928,
2015,
1006,
1007,
1063,
1002,
17736,
1027,
1031,
2047,
1056,
16279,
1035,
3722,
8873,
21928,
1006,
1005,
10439,
1005,
1010,
1031,
1002,
2023,
1010,
1005,
10439,
8873,
21928,
1005,
1033,
1010,
1031,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Twig/TwigExtension.php | TwigExtension.arrayKeyValueFunc | public function arrayKeyValueFunc($key, $val, $current_array = null)
{
if (empty($current_array)) {
return array($key => $val);
}
$current_array[$key] = $val;
return $current_array;
} | php | public function arrayKeyValueFunc($key, $val, $current_array = null)
{
if (empty($current_array)) {
return array($key => $val);
}
$current_array[$key] = $val;
return $current_array;
} | [
"public",
"function",
"arrayKeyValueFunc",
"(",
"$",
"key",
",",
"$",
"val",
",",
"$",
"current_array",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"current_array",
")",
")",
"{",
"return",
"array",
"(",
"$",
"key",
"=>",
"$",
"val",
")",
... | Workaround for twig associative array initialization
Returns a key => val array
@param string $key key of item
@param string $val value of item
@param array $current_array optional array to add to
@return array | [
"Workaround",
"for",
"twig",
"associative",
"array",
"initialization",
"Returns",
"a",
"key",
"=",
">",
"val",
"array"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TwigExtension.php#L941-L950 | train | ArrayKeyValueFunc - arrayKeyValueFunc - arrayKeyValue = > array | [
30522,
2270,
3853,
9140,
14839,
10175,
5657,
11263,
12273,
1006,
1002,
3145,
1010,
1002,
11748,
1010,
1002,
2783,
1035,
9140,
30524,
1027,
1002,
11748,
1025,
2709,
1002,
2783,
1035,
9140,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Lock/Store/RetryTillSaveStore.php | RetryTillSaveStore.waitAndSave | public function waitAndSave(Key $key)
{
$retry = 0;
$sleepRandomness = (int) ($this->retrySleep / 10);
do {
try {
$this->decorated->save($key);
return;
} catch (LockConflictedException $e) {
usleep(($this->retrySleep + random_int(-$sleepRandomness, $sleepRandomness)) * 1000);
}
} while (++$retry < $this->retryCount);
$this->logger->warning('Failed to store the "{resource}" lock. Abort after {retry} retry.', ['resource' => $key, 'retry' => $retry]);
throw new LockConflictedException();
} | php | public function waitAndSave(Key $key)
{
$retry = 0;
$sleepRandomness = (int) ($this->retrySleep / 10);
do {
try {
$this->decorated->save($key);
return;
} catch (LockConflictedException $e) {
usleep(($this->retrySleep + random_int(-$sleepRandomness, $sleepRandomness)) * 1000);
}
} while (++$retry < $this->retryCount);
$this->logger->warning('Failed to store the "{resource}" lock. Abort after {retry} retry.', ['resource' => $key, 'retry' => $retry]);
throw new LockConflictedException();
} | [
"public",
"function",
"waitAndSave",
"(",
"Key",
"$",
"key",
")",
"{",
"$",
"retry",
"=",
"0",
";",
"$",
"sleepRandomness",
"=",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"retrySleep",
"/",
"10",
")",
";",
"do",
"{",
"try",
"{",
"$",
"this",
"->",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Store/RetryTillSaveStore.php#L60-L77 | train | Wait for the key to be held. | [
30522,
2270,
3853,
3524,
29560,
10696,
1006,
3145,
1002,
3145,
1007,
1063,
1002,
2128,
11129,
1027,
1014,
1025,
1002,
3637,
13033,
5358,
2791,
1027,
1006,
20014,
1007,
1006,
1002,
2023,
1011,
1028,
2128,
11129,
25016,
13699,
1013,
2184,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php | ConfigDebugCommand.getConfigForPath | private function getConfigForPath(array $config, string $path, string $alias)
{
$steps = explode('.', $path);
foreach ($steps as $step) {
if (!\array_key_exists($step, $config)) {
throw new LogicException(sprintf('Unable to find configuration for "%s.%s"', $alias, $path));
}
$config = $config[$step];
}
return $config;
} | php | private function getConfigForPath(array $config, string $path, string $alias)
{
$steps = explode('.', $path);
foreach ($steps as $step) {
if (!\array_key_exists($step, $config)) {
throw new LogicException(sprintf('Unable to find configuration for "%s.%s"', $alias, $path));
}
$config = $config[$step];
}
return $config;
} | [
"private",
"function",
"getConfigForPath",
"(",
"array",
"$",
"config",
",",
"string",
"$",
"path",
",",
"string",
"$",
"alias",
")",
"{",
"$",
"steps",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"steps",
"as",
"$",
... | Iterate over configuration until the last step of the given path.
@throws LogicException If the configuration does not exist
@return mixed | [
"Iterate",
"over",
"configuration",
"until",
"the",
"last",
"step",
"of",
"the",
"given",
"path",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php#L140-L153 | train | Get the config for a path | [
30522,
2797,
3853,
2131,
8663,
8873,
25708,
2953,
15069,
1006,
9140,
1002,
9530,
8873,
2290,
1010,
5164,
1002,
4130,
1010,
5164,
1002,
14593,
1007,
1063,
1002,
4084,
1027,
15044,
1006,
1005,
1012,
1005,
1010,
1002,
4130,
1007,
1025,
18921,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Show.php | Show.relation | public function relation($name, $label, $builder = null)
{
if (is_null($builder)) {
$builder = $label;
$label = '';
}
return $this->addRelation($name, $builder, $label);
} | php | public function relation($name, $label, $builder = null)
{
if (is_null($builder)) {
$builder = $label;
$label = '';
}
return $this->addRelation($name, $builder, $label);
} | [
"public",
"function",
"relation",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"builder",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"builder",
")",
")",
"{",
"$",
"builder",
"=",
"$",
"label",
";",
"$",
"label",
"=",
"''",
";",
"... | Add a relation to show.
@param string $name
@param string|\Closure $label
@param null|\Closure $builder
@return Relation | [
"Add",
"a",
"relation",
"to",
"show",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show.php#L200-L208 | train | Add a new relation to the grammar | [
30522,
2270,
3853,
7189,
1006,
1002,
2171,
1010,
1002,
3830,
1010,
1002,
12508,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
12508,
1007,
1007,
1063,
1002,
12508,
1027,
1002,
3830,
1025,
1002,
3830,
1027,
1005,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserId/Archiver.php | Archiver.insertDayReports | protected function insertDayReports()
{
/** @var DataTable $dataTable */
$dataTable = $this->arrays->asDataTable();
$this->setVisitorIds($dataTable);
$report = $dataTable->getSerialized($this->maximumRowsInDataTableLevelZero, null, Metrics::INDEX_NB_VISITS);
$this->getProcessor()->insertBlobRecord(self::USERID_ARCHIVE_RECORD, $report);
} | php | protected function insertDayReports()
{
/** @var DataTable $dataTable */
$dataTable = $this->arrays->asDataTable();
$this->setVisitorIds($dataTable);
$report = $dataTable->getSerialized($this->maximumRowsInDataTableLevelZero, null, Metrics::INDEX_NB_VISITS);
$this->getProcessor()->insertBlobRecord(self::USERID_ARCHIVE_RECORD, $report);
} | [
"protected",
"function",
"insertDayReports",
"(",
")",
"{",
"/** @var DataTable $dataTable */",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"arrays",
"->",
"asDataTable",
"(",
")",
";",
"$",
"this",
"->",
"setVisitorIds",
"(",
"$",
"dataTable",
")",
";",
"$",
... | Insert aggregated daily data serialized
@throws \Exception | [
"Insert",
"aggregated",
"daily",
"data",
"serialized"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserId/Archiver.php#L104-L111 | train | Insert day reports | [
30522,
5123,
3853,
19274,
10259,
2890,
25378,
1006,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
2951,
10880,
1002,
2951,
10880,
1008,
1013,
1002,
2951,
10880,
1027,
1002,
2023,
1011,
1028,
27448,
1011,
1028,
2004,
2850,
29336,
3085,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select._renderWhere | protected function _renderWhere($sql)
{
if ($this->_parts[self::FROM] && $this->_parts[self::WHERE]) {
$sql .= ' ' . self::SQL_WHERE . ' ' . implode(' ', $this->_parts[self::WHERE]);
}
return $sql;
} | php | protected function _renderWhere($sql)
{
if ($this->_parts[self::FROM] && $this->_parts[self::WHERE]) {
$sql .= ' ' . self::SQL_WHERE . ' ' . implode(' ', $this->_parts[self::WHERE]);
}
return $sql;
} | [
"protected",
"function",
"_renderWhere",
"(",
"$",
"sql",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"FROM",
"]",
"&&",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"WHERE",
"]",
")",
"{",
"$",
"sql",
".=",
"' '",
"."... | Render WHERE clause
@param string $sql SQL query
@return string | [
"Render",
"WHERE",
"clause"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1176-L1183 | train | Render where clause | [
30522,
5123,
3853,
1035,
17552,
2860,
5886,
2063,
1006,
1002,
29296,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
2969,
1024,
1024,
2013,
1033,
1004,
1004,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
2969,
1024,
1024,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Session.php | Session.start | public static function start($options = false)
{
if (headers_sent()
|| self::$sessionStarted
|| (defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START)
) {
return;
}
self::$sessionStarted = true;
if (defined('PIWIK_SESSION_NAME')) {
self::$sessionName = PIWIK_SESSION_NAME;
}
$config = Config::getInstance();
// use cookies to store session id on the client side
@ini_set('session.use_cookies', '1');
// prevent attacks involving session ids passed in URLs
@ini_set('session.use_only_cookies', '1');
// advise browser that session cookie should only be sent over secure connection
if (ProxyHttp::isHttps()) {
@ini_set('session.cookie_secure', '1');
}
// advise browser that session cookie should only be accessible through the HTTP protocol (i.e., not JavaScript)
@ini_set('session.cookie_httponly', '1');
// don't use the default: PHPSESSID
@ini_set('session.name', self::$sessionName);
// proxies may cause the referer check to fail and
// incorrectly invalidate the session
@ini_set('session.referer_check', '');
// to preserve previous behavior piwik_auth provided when it contained a token_auth, we ensure
// the session data won't be deleted until the cookie expires.
@ini_set('session.gc_maxlifetime', $config->General['login_cookie_expire']);
@ini_set('session.cookie_path', empty($config->General['login_cookie_path']) ? '/' : $config->General['login_cookie_path']);
$currentSaveHandler = ini_get('session.save_handler');
if (!SettingsPiwik::isPiwikInstalled()) {
// Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files
// for "files", use our own folder to prevent local session file hijacking
$sessionPath = self::getSessionsDirectory();
// We always call mkdir since it also chmods the directory which might help when permissions were reverted for some reasons
Filesystem::mkdir($sessionPath);
@ini_set('session.save_handler', 'files');
@ini_set('session.save_path', $sessionPath);
} elseif (self::isSessionHandler('dbtable')
|| self::isSessionHandler('files')
|| in_array($currentSaveHandler, array('user', 'mm'))
) {
// as of Matomo 3.7.0 we only support files session handler during installation
// We consider these to be misconfigurations, in that:
// - user - we can't verify that user-defined session handler functions have already been set via session_set_save_handler()
// - mm - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue
if (@ini_get('session.serialize_handler') !== 'php_serialize') {
@ini_set('session.serialize_handler', 'php_serialize');
}
$config = array(
'name' => Common::prefixTable(DbTable::TABLE_NAME),
'primary' => 'id',
'modifiedColumn' => 'modified',
'dataColumn' => 'data',
'lifetimeColumn' => 'lifetime',
);
$saveHandler = new DbTable($config);
if ($saveHandler) {
self::setSaveHandler($saveHandler);
}
}
// garbage collection may disabled by default (e.g., Debian)
if (ini_get('session.gc_probability') == 0) {
@ini_set('session.gc_probability', 1);
}
try {
parent::start();
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
} catch (Exception $e) {
StaticContainer::get(LoggerInterface::class)->error('Unable to start session: {exception}', [
'exception' => $e,
'ignoreInScreenWriter' => true,
]);
if (SettingsPiwik::isPiwikInstalled()) {
$pathToSessions = '';
} else {
$pathToSessions = Filechecks::getErrorMessageMissingPermissions(self::getSessionsDirectory());
}
$message = sprintf("Error: %s %s\n<pre>Debug: the original error was \n%s</pre>",
Piwik::translate('General_ExceptionUnableToStartSession'),
$pathToSessions,
$e->getMessage()
);
$ex = new MissingFilePermissionException($message, $e->getCode(), $e);
$ex->setIsHtmlMessage();
throw $ex;
}
} | php | public static function start($options = false)
{
if (headers_sent()
|| self::$sessionStarted
|| (defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START)
) {
return;
}
self::$sessionStarted = true;
if (defined('PIWIK_SESSION_NAME')) {
self::$sessionName = PIWIK_SESSION_NAME;
}
$config = Config::getInstance();
// use cookies to store session id on the client side
@ini_set('session.use_cookies', '1');
// prevent attacks involving session ids passed in URLs
@ini_set('session.use_only_cookies', '1');
// advise browser that session cookie should only be sent over secure connection
if (ProxyHttp::isHttps()) {
@ini_set('session.cookie_secure', '1');
}
// advise browser that session cookie should only be accessible through the HTTP protocol (i.e., not JavaScript)
@ini_set('session.cookie_httponly', '1');
// don't use the default: PHPSESSID
@ini_set('session.name', self::$sessionName);
// proxies may cause the referer check to fail and
// incorrectly invalidate the session
@ini_set('session.referer_check', '');
// to preserve previous behavior piwik_auth provided when it contained a token_auth, we ensure
// the session data won't be deleted until the cookie expires.
@ini_set('session.gc_maxlifetime', $config->General['login_cookie_expire']);
@ini_set('session.cookie_path', empty($config->General['login_cookie_path']) ? '/' : $config->General['login_cookie_path']);
$currentSaveHandler = ini_get('session.save_handler');
if (!SettingsPiwik::isPiwikInstalled()) {
// Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files
// for "files", use our own folder to prevent local session file hijacking
$sessionPath = self::getSessionsDirectory();
// We always call mkdir since it also chmods the directory which might help when permissions were reverted for some reasons
Filesystem::mkdir($sessionPath);
@ini_set('session.save_handler', 'files');
@ini_set('session.save_path', $sessionPath);
} elseif (self::isSessionHandler('dbtable')
|| self::isSessionHandler('files')
|| in_array($currentSaveHandler, array('user', 'mm'))
) {
// as of Matomo 3.7.0 we only support files session handler during installation
// We consider these to be misconfigurations, in that:
// - user - we can't verify that user-defined session handler functions have already been set via session_set_save_handler()
// - mm - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue
if (@ini_get('session.serialize_handler') !== 'php_serialize') {
@ini_set('session.serialize_handler', 'php_serialize');
}
$config = array(
'name' => Common::prefixTable(DbTable::TABLE_NAME),
'primary' => 'id',
'modifiedColumn' => 'modified',
'dataColumn' => 'data',
'lifetimeColumn' => 'lifetime',
);
$saveHandler = new DbTable($config);
if ($saveHandler) {
self::setSaveHandler($saveHandler);
}
}
// garbage collection may disabled by default (e.g., Debian)
if (ini_get('session.gc_probability') == 0) {
@ini_set('session.gc_probability', 1);
}
try {
parent::start();
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
} catch (Exception $e) {
StaticContainer::get(LoggerInterface::class)->error('Unable to start session: {exception}', [
'exception' => $e,
'ignoreInScreenWriter' => true,
]);
if (SettingsPiwik::isPiwikInstalled()) {
$pathToSessions = '';
} else {
$pathToSessions = Filechecks::getErrorMessageMissingPermissions(self::getSessionsDirectory());
}
$message = sprintf("Error: %s %s\n<pre>Debug: the original error was \n%s</pre>",
Piwik::translate('General_ExceptionUnableToStartSession'),
$pathToSessions,
$e->getMessage()
);
$ex = new MissingFilePermissionException($message, $e->getCode(), $e);
$ex->setIsHtmlMessage();
throw $ex;
}
} | [
"public",
"static",
"function",
"start",
"(",
"$",
"options",
"=",
"false",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
"||",
"self",
"::",
"$",
"sessionStarted",
"||",
"(",
"defined",
"(",
"'PIWIK_ENABLE_SESSION_START'",
")",
"&&",
"!",
"PIWIK_ENABLE_SES... | Start the session
@param array|bool $options An array of configuration options; the auto-start (bool) setting is ignored
@return void
@throws Exception if starting a session fails | [
"Start",
"the",
"session"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Session.php#L48-L162 | train | Starts the session | [
30522,
2270,
10763,
3853,
2707,
1006,
1002,
7047,
1027,
6270,
1007,
1063,
2065,
1006,
20346,
2015,
1035,
2741,
1006,
1007,
1064,
1064,
2969,
1024,
1024,
1002,
6521,
7559,
3064,
1064,
1064,
1006,
4225,
1006,
1005,
14255,
9148,
2243,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Tree.php | Tree.initBranchCallback | protected function initBranchCallback()
{
if (is_null($this->branchCallback)) {
$this->branchCallback = function ($branch) {
$key = $branch[$this->model->getKeyName()];
$title = $branch[$this->model->getTitleColumn()];
return "$key - $title";
};
}
} | php | protected function initBranchCallback()
{
if (is_null($this->branchCallback)) {
$this->branchCallback = function ($branch) {
$key = $branch[$this->model->getKeyName()];
$title = $branch[$this->model->getTitleColumn()];
return "$key - $title";
};
}
} | [
"protected",
"function",
"initBranchCallback",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"branchCallback",
")",
")",
"{",
"$",
"this",
"->",
"branchCallback",
"=",
"function",
"(",
"$",
"branch",
")",
"{",
"$",
"key",
"=",
"$",
"bran... | Initialize branch callback.
@return void | [
"Initialize",
"branch",
"callback",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Tree.php#L113-L123 | train | Initializes branch callback | [
30522,
5123,
3853,
1999,
4183,
10024,
12680,
9289,
20850,
8684,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
3589,
9289,
20850,
8684,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
3589,
9289,
20850,
8684,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Extension.php | Extension.routes | public static function routes($callback)
{
$attributes = array_merge(
[
'prefix' => config('admin.route.prefix'),
'middleware' => config('admin.route.middleware'),
],
static::config('route', [])
);
Route::group($attributes, $callback);
} | php | public static function routes($callback)
{
$attributes = array_merge(
[
'prefix' => config('admin.route.prefix'),
'middleware' => config('admin.route.middleware'),
],
static::config('route', [])
);
Route::group($attributes, $callback);
} | [
"public",
"static",
"function",
"routes",
"(",
"$",
"callback",
")",
"{",
"$",
"attributes",
"=",
"array_merge",
"(",
"[",
"'prefix'",
"=>",
"config",
"(",
"'admin.route.prefix'",
")",
",",
"'middleware'",
"=>",
"config",
"(",
"'admin.route.middleware'",
")",
... | Set routes for this extension.
@param $callback | [
"Set",
"routes",
"for",
"this",
"extension",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Extension.php#L341-L352 | train | Route routes. | [
30522,
2270,
10763,
3853,
5847,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
12332,
1027,
9140,
1035,
13590,
1006,
1031,
1005,
17576,
1005,
1027,
1028,
9530,
8873,
2290,
1006,
1005,
4748,
10020,
1012,
2799,
1012,
17576,
1005,
1007,
1010,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php | CacheWarmerAggregate.warmUp | public function warmUp($cacheDir)
{
if ($this->debug) {
$collectedLogs = [];
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
}
if (isset($collectedLogs[$message])) {
++$collectedLogs[$message]['count'];
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
// Clean the trace by removing first frames added by the error handler itself.
for ($i = 0; isset($backtrace[$i]); ++$i) {
if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
$backtrace = \array_slice($backtrace, 1 + $i);
break;
}
}
$collectedLogs[$message] = [
'type' => $type,
'message' => $message,
'file' => $file,
'line' => $line,
'trace' => $backtrace,
'count' => 1,
];
});
}
try {
foreach ($this->warmers as $warmer) {
if (!$this->optionalsEnabled && $warmer->isOptional()) {
continue;
}
if ($this->onlyOptionalsEnabled && !$warmer->isOptional()) {
continue;
}
$warmer->warmUp($cacheDir);
}
} finally {
if ($this->debug && true !== $previousHandler) {
restore_error_handler();
if (file_exists($this->deprecationLogsFilepath)) {
$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath));
$collectedLogs = array_merge($previousLogs, $collectedLogs);
}
file_put_contents($this->deprecationLogsFilepath, serialize(array_values($collectedLogs)));
}
}
} | php | public function warmUp($cacheDir)
{
if ($this->debug) {
$collectedLogs = [];
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
}
if (isset($collectedLogs[$message])) {
++$collectedLogs[$message]['count'];
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
// Clean the trace by removing first frames added by the error handler itself.
for ($i = 0; isset($backtrace[$i]); ++$i) {
if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
$backtrace = \array_slice($backtrace, 1 + $i);
break;
}
}
$collectedLogs[$message] = [
'type' => $type,
'message' => $message,
'file' => $file,
'line' => $line,
'trace' => $backtrace,
'count' => 1,
];
});
}
try {
foreach ($this->warmers as $warmer) {
if (!$this->optionalsEnabled && $warmer->isOptional()) {
continue;
}
if ($this->onlyOptionalsEnabled && !$warmer->isOptional()) {
continue;
}
$warmer->warmUp($cacheDir);
}
} finally {
if ($this->debug && true !== $previousHandler) {
restore_error_handler();
if (file_exists($this->deprecationLogsFilepath)) {
$previousLogs = unserialize(file_get_contents($this->deprecationLogsFilepath));
$collectedLogs = array_merge($previousLogs, $collectedLogs);
}
file_put_contents($this->deprecationLogsFilepath, serialize(array_values($collectedLogs)));
}
}
} | [
"public",
"function",
"warmUp",
"(",
"$",
"cacheDir",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"$",
"collectedLogs",
"=",
"[",
"]",
";",
"$",
"previousHandler",
"=",
"\\",
"defined",
"(",
"'PHPUNIT_COMPOSER_INSTALL'",
")",
";",
"$",
"... | Warms up the cache.
@param string $cacheDir The cache directory | [
"Warms",
"up",
"the",
"cache",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php#L51-L110 | train | Warms up the cache. | [
30522,
2270,
3853,
4010,
6279,
1006,
1002,
17053,
4305,
2099,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2139,
8569,
2290,
1007,
1063,
1002,
5067,
21197,
2015,
1027,
1031,
1033,
1025,
1002,
3025,
11774,
3917,
1027,
1032,
4225,
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 | libs/Zend/Db/Adapter/Pdo/Ibm.php | Zend_Db_Adapter_Pdo_Ibm._checkRequiredOptions | protected function _checkRequiredOptions(array $config)
{
parent::_checkRequiredOptions($config);
if (array_key_exists('host', $this->_config) &&
!array_key_exists('port', $config)) {
/** @see Zend_Db_Adapter_Exception */
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified");
}
} | php | protected function _checkRequiredOptions(array $config)
{
parent::_checkRequiredOptions($config);
if (array_key_exists('host', $this->_config) &&
!array_key_exists('port', $config)) {
/** @see Zend_Db_Adapter_Exception */
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("Configuration must have a key for 'port' when 'host' is specified");
}
} | [
"protected",
"function",
"_checkRequiredOptions",
"(",
"array",
"$",
"config",
")",
"{",
"parent",
"::",
"_checkRequiredOptions",
"(",
"$",
"config",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'host'",
",",
"$",
"this",
"->",
"_config",
")",
"&&",
"!",
... | Checks required options
@param array $config
@throws Zend_Db_Adapter_Exception
@return void | [
"Checks",
"required",
"options"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm.php#L174-L184 | train | Check required options | [
30522,
5123,
3853,
1035,
4638,
2890,
15549,
23417,
16790,
2015,
1006,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
6687,
1024,
1024,
1035,
4638,
2890,
15549,
23417,
16790,
2015,
1006,
1002,
9530,
8873,
2290,
30524,
1006,
1005,
3417,
1005,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/TrackerConfig.php | TrackerConfig.setConfigValue | public static function setConfigValue($name, $value)
{
$section = self::getConfig();
$section[$name] = $value;
Config::getInstance()->Tracker = $section;
} | php | public static function setConfigValue($name, $value)
{
$section = self::getConfig();
$section[$name] = $value;
Config::getInstance()->Tracker = $section;
} | [
"public",
"static",
"function",
"setConfigValue",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"section",
"=",
"self",
"::",
"getConfig",
"(",
")",
";",
"$",
"section",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"Config",
"::",
"getInstanc... | Update Tracker config
@param string $name Setting name
@param mixed $value Value | [
"Update",
"Tracker",
"config"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/TrackerConfig.php#L22-L27 | train | Set a value in the config | [
30522,
2270,
10763,
3853,
2275,
8663,
8873,
2290,
10175,
5657,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
1002,
2930,
1027,
2969,
1024,
1024,
2131,
8663,
8873,
2290,
1006,
1007,
1025,
1002,
2930,
1031,
1002,
2171,
1033,
1027,
1002,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/MultiSites/API.php | API.getSitesIdFromPattern | private function getSitesIdFromPattern($pattern, $_restrictSitesToLogin)
{
// First clear cache
Site::clearCache();
if (empty($pattern)) {
/** @var Scheduler $scheduler */
$scheduler = StaticContainer::getContainer()->get('Piwik\Scheduler\Scheduler');
// Then, warm the cache with only the data we should have access to
if (Piwik::hasUserSuperUserAccess()
// Hack: when this API function is called as a Scheduled Task, Super User status is enforced.
// This means this function would return ALL websites in all cases.
// Instead, we make sure that only the right set of data is returned
&& !$scheduler->isRunningTask()
) {
APISitesManager::getInstance()->getAllSites();
} else {
APISitesManager::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin);
}
} else {
$sites = Request::processRequest('SitesManager.getPatternMatchSites',
array('pattern' => $pattern,
// added because caller could overwrite these
'limit' => SettingsPiwik::getWebsitesCountToDisplay(),
'showColumns' => '',
'hideColumns' => '',
'format' => 'original'));
if (!empty($sites)) {
Site::setSitesFromArray($sites);
}
}
// Both calls above have called Site::setSitesFromArray. We now get these sites:
$sitesToProblablyAdd = Site::getSites();
return $sitesToProblablyAdd;
} | php | private function getSitesIdFromPattern($pattern, $_restrictSitesToLogin)
{
// First clear cache
Site::clearCache();
if (empty($pattern)) {
/** @var Scheduler $scheduler */
$scheduler = StaticContainer::getContainer()->get('Piwik\Scheduler\Scheduler');
// Then, warm the cache with only the data we should have access to
if (Piwik::hasUserSuperUserAccess()
// Hack: when this API function is called as a Scheduled Task, Super User status is enforced.
// This means this function would return ALL websites in all cases.
// Instead, we make sure that only the right set of data is returned
&& !$scheduler->isRunningTask()
) {
APISitesManager::getInstance()->getAllSites();
} else {
APISitesManager::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin);
}
} else {
$sites = Request::processRequest('SitesManager.getPatternMatchSites',
array('pattern' => $pattern,
// added because caller could overwrite these
'limit' => SettingsPiwik::getWebsitesCountToDisplay(),
'showColumns' => '',
'hideColumns' => '',
'format' => 'original'));
if (!empty($sites)) {
Site::setSitesFromArray($sites);
}
}
// Both calls above have called Site::setSitesFromArray. We now get these sites:
$sitesToProblablyAdd = Site::getSites();
return $sitesToProblablyAdd;
} | [
"private",
"function",
"getSitesIdFromPattern",
"(",
"$",
"pattern",
",",
"$",
"_restrictSitesToLogin",
")",
"{",
"// First clear cache",
"Site",
"::",
"clearCache",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"pattern",
")",
")",
"{",
"/** @var Scheduler $sche... | Fetches the list of sites which names match the string pattern
@param string $pattern
@param bool $_restrictSitesToLogin
@return array|string | [
"Fetches",
"the",
"list",
"of",
"sites",
"which",
"names",
"match",
"the",
"string",
"pattern"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MultiSites/API.php#L121-L160 | train | Returns the list of websites that match the given pattern | [
30522,
2797,
3853,
4152,
7616,
3593,
19699,
25377,
20097,
2078,
1006,
1002,
5418,
1010,
1002,
1035,
21573,
28032,
4355,
12898,
11528,
1007,
1063,
1013,
1013,
2034,
3154,
17053,
2609,
1024,
1024,
3154,
3540,
5403,
1006,
1007,
1025,
2065,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/EventDispatcher.php | EventDispatcher.postEvent | public function postEvent($eventName, $params, $pending = false, $plugins = null)
{
if ($pending) {
$this->pendingEvents[] = array($eventName, $params);
}
$manager = $this->pluginManager;
if (empty($plugins)) {
$plugins = $manager->getPluginsLoadedAndActivated();
}
$callbacks = array();
// collect all callbacks to execute
foreach ($plugins as $pluginName) {
if (!is_string($pluginName)) {
$pluginName = $pluginName->getPluginName();
}
if (!isset($this->pluginHooks[$pluginName])) {
$plugin = $manager->getLoadedPlugin($pluginName);
$this->pluginHooks[$pluginName] = $plugin->getListHooksRegistered();
}
$hooks = $this->pluginHooks[$pluginName];
if (isset($hooks[$eventName])) {
list($pluginFunction, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($hooks[$eventName]);
if (is_string($pluginFunction)) {
$plugin = $manager->getLoadedPlugin($pluginName);
$callbacks[$callbackGroup][] = array($plugin, $pluginFunction) ;
} else {
$callbacks[$callbackGroup][] = $pluginFunction;
}
}
}
if (isset($this->extraObservers[$eventName])) {
foreach ($this->extraObservers[$eventName] as $callbackInfo) {
list($callback, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($callbackInfo);
$callbacks[$callbackGroup][] = $callback;
}
}
// sort callbacks by their importance
ksort($callbacks);
// execute callbacks in order
foreach ($callbacks as $callbackGroup) {
foreach ($callbackGroup as $callback) {
call_user_func_array($callback, $params);
}
}
} | php | public function postEvent($eventName, $params, $pending = false, $plugins = null)
{
if ($pending) {
$this->pendingEvents[] = array($eventName, $params);
}
$manager = $this->pluginManager;
if (empty($plugins)) {
$plugins = $manager->getPluginsLoadedAndActivated();
}
$callbacks = array();
// collect all callbacks to execute
foreach ($plugins as $pluginName) {
if (!is_string($pluginName)) {
$pluginName = $pluginName->getPluginName();
}
if (!isset($this->pluginHooks[$pluginName])) {
$plugin = $manager->getLoadedPlugin($pluginName);
$this->pluginHooks[$pluginName] = $plugin->getListHooksRegistered();
}
$hooks = $this->pluginHooks[$pluginName];
if (isset($hooks[$eventName])) {
list($pluginFunction, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($hooks[$eventName]);
if (is_string($pluginFunction)) {
$plugin = $manager->getLoadedPlugin($pluginName);
$callbacks[$callbackGroup][] = array($plugin, $pluginFunction) ;
} else {
$callbacks[$callbackGroup][] = $pluginFunction;
}
}
}
if (isset($this->extraObservers[$eventName])) {
foreach ($this->extraObservers[$eventName] as $callbackInfo) {
list($callback, $callbackGroup) = $this->getCallbackFunctionAndGroupNumber($callbackInfo);
$callbacks[$callbackGroup][] = $callback;
}
}
// sort callbacks by their importance
ksort($callbacks);
// execute callbacks in order
foreach ($callbacks as $callbackGroup) {
foreach ($callbackGroup as $callback) {
call_user_func_array($callback, $params);
}
}
} | [
"public",
"function",
"postEvent",
"(",
"$",
"eventName",
",",
"$",
"params",
",",
"$",
"pending",
"=",
"false",
",",
"$",
"plugins",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"pending",
")",
"{",
"$",
"this",
"->",
"pendingEvents",
"[",
"]",
"=",
"ar... | Triggers an event, executing all callbacks associated with it.
@param string $eventName The name of the event, ie, API.getReportMetadata.
@param array $params The parameters to pass to each callback when executing.
@param bool $pending Whether this event should be posted again for plugins
loaded after the event is fired.
@param array|null $plugins The plugins to post events to. If null, the event
is posted to all plugins. The elements of this array
can be either the Plugin objects themselves
or their string names. | [
"Triggers",
"an",
"event",
"executing",
"all",
"callbacks",
"associated",
"with",
"it",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/EventDispatcher.php#L88-L144 | train | Post event callback | [
30522,
2270,
3853,
2695,
18697,
3372,
1006,
1002,
2724,
18442,
1010,
1002,
11498,
5244,
1010,
1002,
14223,
1027,
6270,
1010,
1002,
13354,
7076,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
14223,
1007,
1063,
1002,
2023,
1011,
1028,
14223,
186... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Comment/Client.php | Client.reply | public function reply(string $msgId, int $index, int $commentId, string $content)
{
$params = [
'msg_data_id' => $msgId,
'index' => $index,
'user_comment_id' => $commentId,
'content' => $content,
];
return $this->httpPostJson('cgi-bin/comment/reply/add', $params);
} | php | public function reply(string $msgId, int $index, int $commentId, string $content)
{
$params = [
'msg_data_id' => $msgId,
'index' => $index,
'user_comment_id' => $commentId,
'content' => $content,
];
return $this->httpPostJson('cgi-bin/comment/reply/add', $params);
} | [
"public",
"function",
"reply",
"(",
"string",
"$",
"msgId",
",",
"int",
"$",
"index",
",",
"int",
"$",
"commentId",
",",
"string",
"$",
"content",
")",
"{",
"$",
"params",
"=",
"[",
"'msg_data_id'",
"=>",
"$",
"msgId",
",",
"'index'",
"=>",
"$",
"ind... | Reply to a comment.
@param string $msgId
@param int $index
@param int $commentId
@param string $content
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string | [
"Reply",
"to",
"a",
"comment",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Comment/Client.php#L153-L163 | train | Reply to a comment | [
30522,
2270,
3853,
7514,
1006,
5164,
1002,
5796,
5856,
2094,
1010,
20014,
1002,
5950,
1010,
20014,
1002,
7615,
3593,
1010,
5164,
1002,
4180,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
5796,
2290,
1035,
2951,
1035,
8909,
1005,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Route.php | Route.gatherMiddleware | public function gatherMiddleware()
{
if (! is_null($this->computedMiddleware)) {
return $this->computedMiddleware;
}
$this->computedMiddleware = [];
return $this->computedMiddleware = array_unique(array_merge(
$this->middleware(), $this->controllerMiddleware()
), SORT_REGULAR);
} | php | public function gatherMiddleware()
{
if (! is_null($this->computedMiddleware)) {
return $this->computedMiddleware;
}
$this->computedMiddleware = [];
return $this->computedMiddleware = array_unique(array_merge(
$this->middleware(), $this->controllerMiddleware()
), SORT_REGULAR);
} | [
"public",
"function",
"gatherMiddleware",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"computedMiddleware",
")",
")",
"{",
"return",
"$",
"this",
"->",
"computedMiddleware",
";",
"}",
"$",
"this",
"->",
"computedMiddleware",
"=",
"[",... | Get all middleware, including the ones from the controller.
@return array | [
"Get",
"all",
"middleware",
"including",
"the",
"ones",
"from",
"the",
"controller",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Route.php#L785-L796 | train | Gather all middleware from the controller and the controller middleware. | [
30522,
2270,
3853,
8587,
4328,
20338,
8059,
1006,
1007,
1063,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
24806,
4328,
20338,
8059,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
24806,
4328,
20338,
8059,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/ControllerBehavior.php | ControllerBehavior.makeFileContents | public function makeFileContents($filePath, $extraParams = [])
{
$this->controller->vars = array_merge($this->controller->vars, $this->vars);
return $this->controller->makeFileContents($filePath, $extraParams);
} | php | public function makeFileContents($filePath, $extraParams = [])
{
$this->controller->vars = array_merge($this->controller->vars, $this->vars);
return $this->controller->makeFileContents($filePath, $extraParams);
} | [
"public",
"function",
"makeFileContents",
"(",
"$",
"filePath",
",",
"$",
"extraParams",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"controller",
"->",
"vars",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"controller",
"->",
"vars",
",",
"$",
"this",
"... | Makes all views in context of the controller, not the behavior.
@param string $filePath Absolute path to the view file.
@param array $extraParams Parameters that should be available to the view.
@return string | [
"Makes",
"all",
"views",
"in",
"context",
"of",
"the",
"controller",
"not",
"the",
"behavior",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/ControllerBehavior.php#L140-L144 | train | This method is used to make the file contents of the current page. | [
30522,
2270,
3853,
2191,
8873,
2571,
8663,
6528,
3215,
1006,
1002,
5371,
15069,
1010,
1002,
4469,
28689,
5244,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
11486,
1011,
1028,
13075,
2015,
1027,
9140,
1035,
13590,
1006,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Middleware/ThrottleRequests.php | ThrottleRequests.resolveMaxAttempts | protected function resolveMaxAttempts($request, $maxAttempts)
{
if (Str::contains($maxAttempts, '|')) {
$maxAttempts = explode('|', $maxAttempts, 2)[$request->user() ? 1 : 0];
}
if (! is_numeric($maxAttempts) && $request->user()) {
$maxAttempts = $request->user()->{$maxAttempts};
}
return (int) $maxAttempts;
} | php | protected function resolveMaxAttempts($request, $maxAttempts)
{
if (Str::contains($maxAttempts, '|')) {
$maxAttempts = explode('|', $maxAttempts, 2)[$request->user() ? 1 : 0];
}
if (! is_numeric($maxAttempts) && $request->user()) {
$maxAttempts = $request->user()->{$maxAttempts};
}
return (int) $maxAttempts;
} | [
"protected",
"function",
"resolveMaxAttempts",
"(",
"$",
"request",
",",
"$",
"maxAttempts",
")",
"{",
"if",
"(",
"Str",
"::",
"contains",
"(",
"$",
"maxAttempts",
",",
"'|'",
")",
")",
"{",
"$",
"maxAttempts",
"=",
"explode",
"(",
"'|'",
",",
"$",
"ma... | Resolve the number of attempts if the user is authenticated or not.
@param \Illuminate\Http\Request $request
@param int|string $maxAttempts
@return int | [
"Resolve",
"the",
"number",
"of",
"attempts",
"if",
"the",
"user",
"is",
"authenticated",
"or",
"not",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Middleware/ThrottleRequests.php#L73-L84 | train | Resolves the maximum number of attempts for the current user | [
30522,
5123,
3853,
10663,
17848,
19321,
6633,
22798,
1006,
1002,
5227,
1010,
1002,
4098,
19321,
6633,
22798,
1007,
1063,
2065,
1006,
2358,
2099,
1024,
1024,
3397,
1006,
1002,
4098,
19321,
6633,
22798,
1010,
1005,
1064,
1005,
1007,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/behaviors/SettingsModel.php | SettingsModel.set | public function set($key, $value = null)
{
$data = is_array($key) ? $key : [$key => $value];
$obj = self::instance();
$obj->fill($data);
return $obj->save();
} | php | public function set($key, $value = null)
{
$data = is_array($key) ? $key : [$key => $value];
$obj = self::instance();
$obj->fill($data);
return $obj->save();
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"[",
"$",
"key",
"=>",
"$",
"value",
"]",
";",
"$",
"obj",
"=",
"self",
"::",
... | Set a single or array key pair of values, intended as a static method | [
"Set",
"a",
"single",
"or",
"array",
"key",
"pair",
"of",
"values",
"intended",
"as",
"a",
"static",
"method"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/behaviors/SettingsModel.php#L122-L128 | train | Set a value to the language | [
30522,
2270,
3853,
2275,
1006,
1002,
3145,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
1002,
2951,
1027,
2003,
1035,
9140,
1006,
1002,
3145,
1007,
1029,
1002,
3145,
1024,
1031,
1002,
3145,
1027,
1028,
1002,
3643,
1033,
1025,
1002,
27885,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.url | public static function url($input, $domain = false)
{
if (!trim((string)$input)) {
$input = '/';
}
if (Grav::instance()['config']->get('system.absolute_urls', false)) {
$domain = true;
}
if (Grav::instance()['uri']->isExternal($input)) {
return $input;
}
/** @var Uri $uri */
$uri = Grav::instance()['uri'];
$root = $uri->rootUrl();
$input = Utils::replaceFirstOccurrence($root, '', $input);
$input = ltrim((string)$input, '/');
if (Utils::contains((string)$input, '://')) {
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
$parts = Uri::parseUrl($input);
if ($parts) {
$resource = $locator->findResource("{$parts['scheme']}://{$parts['host']}{$parts['path']}", false);
if (isset($parts['query'])) {
$resource = $resource . '?' . $parts['query'];
}
} else {
// Not a valid URL (can still be a stream).
$resource = $locator->findResource($input, false);
}
} else {
$resource = $input;
}
return rtrim($uri->rootUrl($domain), '/') . '/' . ($resource ?? '');
} | php | public static function url($input, $domain = false)
{
if (!trim((string)$input)) {
$input = '/';
}
if (Grav::instance()['config']->get('system.absolute_urls', false)) {
$domain = true;
}
if (Grav::instance()['uri']->isExternal($input)) {
return $input;
}
/** @var Uri $uri */
$uri = Grav::instance()['uri'];
$root = $uri->rootUrl();
$input = Utils::replaceFirstOccurrence($root, '', $input);
$input = ltrim((string)$input, '/');
if (Utils::contains((string)$input, '://')) {
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
$parts = Uri::parseUrl($input);
if ($parts) {
$resource = $locator->findResource("{$parts['scheme']}://{$parts['host']}{$parts['path']}", false);
if (isset($parts['query'])) {
$resource = $resource . '?' . $parts['query'];
}
} else {
// Not a valid URL (can still be a stream).
$resource = $locator->findResource($input, false);
}
} else {
$resource = $input;
}
return rtrim($uri->rootUrl($domain), '/') . '/' . ($resource ?? '');
} | [
"public",
"static",
"function",
"url",
"(",
"$",
"input",
",",
"$",
"domain",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"trim",
"(",
"(",
"string",
")",
"$",
"input",
")",
")",
"{",
"$",
"input",
"=",
"'/'",
";",
"}",
"if",
"(",
"Grav",
"::",
"... | Simple helper method to make getting a Grav URL easier
@param string $input
@param bool $domain
@return bool|null|string | [
"Simple",
"helper",
"method",
"to",
"make",
"getting",
"a",
"Grav",
"URL",
"easier"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L34-L81 | train | Returns a URL from a URL | [
30522,
2270,
10763,
3853,
24471,
2140,
1006,
1002,
7953,
1010,
1002,
5884,
1027,
6270,
1007,
1063,
2065,
1006,
999,
12241,
1006,
1006,
5164,
1007,
1002,
7953,
1007,
1007,
1063,
1002,
7953,
1027,
1005,
1013,
1005,
1025,
1065,
2065,
1006,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/RouteAction.php | RouteAction.parse | public static function parse($uri, $action)
{
// If no action is passed in right away, we assume the user will make use of
// fluent routing. In that case, we set a default closure, to be executed
// if the user never explicitly sets an action to handle the given uri.
if (is_null($action)) {
return static::missingAction($uri);
}
// If the action is already a Closure instance, we will just set that instance
// as the "uses" property, because there is nothing else we need to do when
// it is available. Otherwise we will need to find it in the action list.
if (is_callable($action, true)) {
return ! is_array($action) ? ['uses' => $action] : [
'uses' => $action[0].'@'.$action[1],
'controller' => $action[0].'@'.$action[1],
];
}
// If no "uses" property has been set, we will dig through the array to find a
// Closure instance within this list. We will set the first Closure we come
// across into the "uses" property that will get fired off by this route.
elseif (! isset($action['uses'])) {
$action['uses'] = static::findCallable($action);
}
if (is_string($action['uses']) && ! Str::contains($action['uses'], '@')) {
$action['uses'] = static::makeInvokable($action['uses']);
}
return $action;
} | php | public static function parse($uri, $action)
{
// If no action is passed in right away, we assume the user will make use of
// fluent routing. In that case, we set a default closure, to be executed
// if the user never explicitly sets an action to handle the given uri.
if (is_null($action)) {
return static::missingAction($uri);
}
// If the action is already a Closure instance, we will just set that instance
// as the "uses" property, because there is nothing else we need to do when
// it is available. Otherwise we will need to find it in the action list.
if (is_callable($action, true)) {
return ! is_array($action) ? ['uses' => $action] : [
'uses' => $action[0].'@'.$action[1],
'controller' => $action[0].'@'.$action[1],
];
}
// If no "uses" property has been set, we will dig through the array to find a
// Closure instance within this list. We will set the first Closure we come
// across into the "uses" property that will get fired off by this route.
elseif (! isset($action['uses'])) {
$action['uses'] = static::findCallable($action);
}
if (is_string($action['uses']) && ! Str::contains($action['uses'], '@')) {
$action['uses'] = static::makeInvokable($action['uses']);
}
return $action;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"uri",
",",
"$",
"action",
")",
"{",
"// If no action is passed in right away, we assume the user will make use of",
"// fluent routing. In that case, we set a default closure, to be executed",
"// if the user never explicitly sets an ac... | Parse the given action into an array.
@param string $uri
@param mixed $action
@return array | [
"Parse",
"the",
"given",
"action",
"into",
"an",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/RouteAction.php#L19-L50 | train | Parse the action and return the result | [
30522,
2270,
10763,
3853,
11968,
3366,
1006,
1002,
24471,
2072,
1010,
1002,
2895,
1007,
1063,
1013,
1013,
2065,
2053,
2895,
2003,
2979,
1999,
2157,
2185,
1010,
2057,
7868,
1996,
5310,
2097,
2191,
2224,
1997,
1013,
1013,
19376,
16972,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Row.php | Row.renameColumn | public function renameColumn($oldName, $newName)
{
if (isset($this[$oldName])) {
$this[$newName] = $this[$oldName];
}
// outside the if () since we want to delete nulled columns
if ($this->offsetExists($oldName)) {
unset($this[$oldName]);
}
} | php | public function renameColumn($oldName, $newName)
{
if (isset($this[$oldName])) {
$this[$newName] = $this[$oldName];
}
// outside the if () since we want to delete nulled columns
if ($this->offsetExists($oldName)) {
unset($this[$oldName]);
}
} | [
"public",
"function",
"renameColumn",
"(",
"$",
"oldName",
",",
"$",
"newName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"oldName",
"]",
")",
")",
"{",
"$",
"this",
"[",
"$",
"newName",
"]",
"=",
"$",
"this",
"[",
"$",
"oldName",... | Renames a column.
@param string $oldName The current name of the column.
@param string $newName The new name of the column. | [
"Renames",
"a",
"column",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L164-L174 | train | Renames a column | [
30522,
2270,
3853,
14916,
14074,
25778,
2819,
2078,
1006,
1002,
2214,
18442,
1010,
1002,
2047,
18442,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1031,
1002,
2214,
18442,
1033,
1007,
1007,
1063,
1002,
2023,
1031,
1002,
2047,
1844... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
google/flatbuffers | php/ByteBuffer.php | ByteBuffer.writeLittleEndian | public function writeLittleEndian($offset, $count, $data)
{
if (ByteBuffer::isLittleEndian()) {
for ($i = 0; $i < $count; $i++) {
$this->_buffer[$offset + $i] = chr($data >> $i * 8);
}
} else {
for ($i = 0; $i < $count; $i++) {
$this->_buffer[$offset + $count - 1 - $i] = chr($data >> $i * 8);
}
}
} | php | public function writeLittleEndian($offset, $count, $data)
{
if (ByteBuffer::isLittleEndian()) {
for ($i = 0; $i < $count; $i++) {
$this->_buffer[$offset + $i] = chr($data >> $i * 8);
}
} else {
for ($i = 0; $i < $count; $i++) {
$this->_buffer[$offset + $count - 1 - $i] = chr($data >> $i * 8);
}
}
} | [
"public",
"function",
"writeLittleEndian",
"(",
"$",
"offset",
",",
"$",
"count",
",",
"$",
"data",
")",
"{",
"if",
"(",
"ByteBuffer",
"::",
"isLittleEndian",
"(",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
"... | write little endian value to the buffer.
@param $offset
@param $count byte length
@param $data actual values | [
"write",
"little",
"endian",
"value",
"to",
"the",
"buffer",
"."
] | af74f87ccd6ea9bcf9e325427dca7c7faf1d79c1 | https://github.com/google/flatbuffers/blob/af74f87ccd6ea9bcf9e325427dca7c7faf1d79c1/php/ByteBuffer.php#L120-L131 | train | Write little endian data | [
30522,
2270,
3853,
4339,
15909,
9286,
10497,
2937,
1006,
1002,
16396,
1010,
1002,
4175,
1010,
1002,
2951,
1007,
1063,
2065,
1006,
24880,
30524,
2099,
1006,
1002,
2951,
1028,
1028,
1002,
1045,
1008,
1022,
1007,
1025,
1065,
1065,
2842,
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/Messenger/Transport/AmqpExt/AmqpSender.php | AmqpSender.send | public function send(Envelope $envelope): Envelope
{
$encodedMessage = $this->serializer->encode($envelope);
/** @var DelayStamp|null $delayStamp */
$delayStamp = $envelope->last(DelayStamp::class);
$delay = 0;
if (null !== $delayStamp) {
$delay = $delayStamp->getDelay();
}
try {
$this->connection->publish(
$encodedMessage['body'],
$encodedMessage['headers'] ?? [],
$delay,
$envelope->last(AmqpStamp::class)
);
} catch (\AMQPException $e) {
throw new TransportException($e->getMessage(), 0, $e);
}
return $envelope;
} | php | public function send(Envelope $envelope): Envelope
{
$encodedMessage = $this->serializer->encode($envelope);
/** @var DelayStamp|null $delayStamp */
$delayStamp = $envelope->last(DelayStamp::class);
$delay = 0;
if (null !== $delayStamp) {
$delay = $delayStamp->getDelay();
}
try {
$this->connection->publish(
$encodedMessage['body'],
$encodedMessage['headers'] ?? [],
$delay,
$envelope->last(AmqpStamp::class)
);
} catch (\AMQPException $e) {
throw new TransportException($e->getMessage(), 0, $e);
}
return $envelope;
} | [
"public",
"function",
"send",
"(",
"Envelope",
"$",
"envelope",
")",
":",
"Envelope",
"{",
"$",
"encodedMessage",
"=",
"$",
"this",
"->",
"serializer",
"->",
"encode",
"(",
"$",
"envelope",
")",
";",
"/** @var DelayStamp|null $delayStamp */",
"$",
"delayStamp",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpSender.php#L42-L65 | train | Send an AMQP message. | [
30522,
2270,
3853,
4604,
1006,
11255,
1002,
11255,
1007,
1024,
11255,
1063,
1002,
12359,
7834,
3736,
3351,
1027,
1002,
2023,
1011,
1028,
7642,
17629,
1011,
1028,
4372,
16044,
1006,
1002,
11255,
1007,
1025,
1013,
1008,
1008,
1030,
13075,
143... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Console/ExportSeedCommand.php | ExportSeedCommand.getTableDataArrayAsString | protected function getTableDataArrayAsString($table, $exceptFields = [])
{
$fields = \DB::getSchemaBuilder()->getColumnListing($table);
$fields = array_diff($fields, $exceptFields);
$array = \DB::table($table)->get($fields)->map(function ($item) {
return (array) $item;
})->all();
return $this->varExport($array, str_repeat(' ', 12));
} | php | protected function getTableDataArrayAsString($table, $exceptFields = [])
{
$fields = \DB::getSchemaBuilder()->getColumnListing($table);
$fields = array_diff($fields, $exceptFields);
$array = \DB::table($table)->get($fields)->map(function ($item) {
return (array) $item;
})->all();
return $this->varExport($array, str_repeat(' ', 12));
} | [
"protected",
"function",
"getTableDataArrayAsString",
"(",
"$",
"table",
",",
"$",
"exceptFields",
"=",
"[",
"]",
")",
"{",
"$",
"fields",
"=",
"\\",
"DB",
"::",
"getSchemaBuilder",
"(",
")",
"->",
"getColumnListing",
"(",
"$",
"table",
")",
";",
"$",
"f... | Get data array from table as string result var_export.
@param string $table
@param array $exceptFields
@return string | [
"Get",
"data",
"array",
"from",
"table",
"as",
"string",
"result",
"var_export",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/ExportSeedCommand.php#L87-L97 | train | Get table data array as string | [
30522,
5123,
3853,
2131,
10880,
2850,
2696,
2906,
29539,
4757,
18886,
3070,
1006,
1002,
2795,
1010,
1002,
3272,
15155,
1027,
1031,
1033,
1007,
1063,
1002,
4249,
1027,
1032,
16962,
1024,
1024,
4152,
5403,
2863,
8569,
23891,
2099,
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... |
symfony/symfony | src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php | InMemoryUserProvider.getUser | private function getUser($username)
{
if (!isset($this->users[strtolower($username)])) {
$ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
$ex->setUsername($username);
throw $ex;
}
return $this->users[strtolower($username)];
} | php | private function getUser($username)
{
if (!isset($this->users[strtolower($username)])) {
$ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
$ex->setUsername($username);
throw $ex;
}
return $this->users[strtolower($username)];
} | [
"private",
"function",
"getUser",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"users",
"[",
"strtolower",
"(",
"$",
"username",
")",
"]",
")",
")",
"{",
"$",
"ex",
"=",
"new",
"UsernameNotFoundException",
"(",
"sp... | Returns the user by given username.
@param string $username The username
@return User
@throws UsernameNotFoundException if user whose given username does not exist | [
"Returns",
"the",
"user",
"by",
"given",
"username",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/User/InMemoryUserProvider.php#L102-L112 | train | Get user by username | [
30522,
2797,
3853,
2131,
20330,
1006,
1002,
5310,
18442,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
5198,
1031,
2358,
5339,
12898,
13777,
1006,
1002,
5310,
18442,
1007,
1033,
1007,
1007,
1063,
1002,
4654,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php | DoctrineTokenProvider.updateToken | public function updateToken($series, $tokenValue, \DateTime $lastUsed)
{
$sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed'
.' WHERE series=:series';
$paramValues = [
'value' => $tokenValue,
'lastUsed' => $lastUsed,
'series' => $series,
];
$paramTypes = [
'value' => \PDO::PARAM_STR,
'lastUsed' => DoctrineType::DATETIME,
'series' => \PDO::PARAM_STR,
];
$updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes);
if ($updated < 1) {
throw new TokenNotFoundException('No token found.');
}
} | php | public function updateToken($series, $tokenValue, \DateTime $lastUsed)
{
$sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed'
.' WHERE series=:series';
$paramValues = [
'value' => $tokenValue,
'lastUsed' => $lastUsed,
'series' => $series,
];
$paramTypes = [
'value' => \PDO::PARAM_STR,
'lastUsed' => DoctrineType::DATETIME,
'series' => \PDO::PARAM_STR,
];
$updated = $this->conn->executeUpdate($sql, $paramValues, $paramTypes);
if ($updated < 1) {
throw new TokenNotFoundException('No token found.');
}
} | [
"public",
"function",
"updateToken",
"(",
"$",
"series",
",",
"$",
"tokenValue",
",",
"\\",
"DateTime",
"$",
"lastUsed",
")",
"{",
"$",
"sql",
"=",
"'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed'",
".",
"' WHERE series=:series'",
";",
"$",
"paramValues... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php#L82-L100 | train | Update token value | [
30522,
2270,
3853,
10651,
18715,
2368,
1006,
1002,
2186,
1010,
1002,
19204,
10175,
5657,
1010,
1032,
3058,
7292,
1002,
2197,
13901,
1007,
1063,
1002,
29296,
1027,
1005,
10651,
3342,
4168,
1035,
19204,
2275,
3643,
1027,
1024,
3643,
1010,
219... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/LanguagesManager/TranslationWriter/Validate/NoScripts.php | NoScripts.isValid | public function isValid($translations)
{
$this->message = null;
// check if any translation contains restricted script tags
$serializedStrings = serialize($translations);
$invalids = array("<script", 'document.', 'javascript:', 'src=', 'background=', 'onload=');
foreach ($invalids as $invalid) {
if (stripos($serializedStrings, $invalid) !== false) {
$this->message = 'script tags restricted for language files';
return false;
}
}
return true;
} | php | public function isValid($translations)
{
$this->message = null;
// check if any translation contains restricted script tags
$serializedStrings = serialize($translations);
$invalids = array("<script", 'document.', 'javascript:', 'src=', 'background=', 'onload=');
foreach ($invalids as $invalid) {
if (stripos($serializedStrings, $invalid) !== false) {
$this->message = 'script tags restricted for language files';
return false;
}
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"translations",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"null",
";",
"// check if any translation contains restricted script tags",
"$",
"serializedStrings",
"=",
"serialize",
"(",
"$",
"translations",
")",
";",
"$",
... | Validates the given translations
* No script like parts should be present in any part of the translations
@param array $translations
@return boolean | [
"Validates",
"the",
"given",
"translations",
"*",
"No",
"script",
"like",
"parts",
"should",
"be",
"present",
"in",
"any",
"part",
"of",
"the",
"translations"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/TranslationWriter/Validate/NoScripts.php#L22-L38 | train | Checks if any translation string contains script tags | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
11913,
1007,
1063,
1002,
2023,
1011,
1028,
4471,
1027,
19701,
1025,
1013,
1013,
4638,
2065,
2151,
5449,
3397,
7775,
5896,
22073,
1002,
27289,
3367,
4892,
2015,
1027,
7642,
4697,
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... |
laravel/framework | src/Illuminate/Cookie/Middleware/EncryptCookies.php | EncryptCookies.handle | public function handle($request, Closure $next)
{
return $this->encrypt($next($this->decrypt($request)));
} | php | public function handle($request, Closure $next)
{
return $this->encrypt($next($this->decrypt($request)));
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"return",
"$",
"this",
"->",
"encrypt",
"(",
"$",
"next",
"(",
"$",
"this",
"->",
"decrypt",
"(",
"$",
"request",
")",
")",
")",
";",
"}"
] | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return \Symfony\Component\HttpFoundation\Response | [
"Handle",
"an",
"incoming",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cookie/Middleware/EncryptCookies.php#L64-L67 | train | Encrypts and decrypts the request and returns the result | [
30522,
2270,
3853,
5047,
1006,
1002,
5227,
1010,
8503,
1002,
2279,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4372,
26775,
22571,
2102,
1006,
1002,
2279,
1006,
1002,
2023,
1011,
1028,
11703,
2854,
13876,
1006,
1002,
5227,
1007,
1007,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ImageMedium.php | ImageMedium.derivatives | public function derivatives($min_width, $max_width = 2500, $step = 200)
{
if (!empty($this->alternatives)) {
$max = max(array_keys($this->alternatives));
$base = $this->alternatives[$max];
} else {
$base = $this;
}
$widths = [];
if (func_num_args() === 1) {
foreach ((array) func_get_arg(0) as $width) {
if ($width < $base->get('width')) {
$widths[] = $width;
}
}
} else {
$max_width = min($max_width, $base->get('width'));
for ($width = $min_width; $width < $max_width; $width = $width + $step) {
$widths[] = $width;
}
}
foreach ($widths as $width) {
// Only generate image alternatives that don't already exist
if (array_key_exists((int) $width, $this->alternatives)) {
continue;
}
$derivative = MediumFactory::fromFile($base->get('filepath'));
// It's possible that MediumFactory::fromFile returns null if the
// original image file no longer exists and this class instance was
// retrieved from the page cache
if (null !== $derivative) {
$index = 2;
$alt_widths = array_keys($this->alternatives);
sort($alt_widths);
foreach ($alt_widths as $i => $key) {
if ($width > $key) {
$index += max($i, 1);
}
}
$basename = preg_replace('/(@\d+x){0,1}$/', "@{$width}w", $base->get('basename'), 1);
$derivative->setImagePrettyName($basename);
$ratio = $base->get('width') / $width;
$height = $derivative->get('height') / $ratio;
$derivative->resize($width, $height);
$derivative->set('width', $width);
$derivative->set('height', $height);
$this->addAlternative($ratio, $derivative);
}
}
return $this;
} | php | public function derivatives($min_width, $max_width = 2500, $step = 200)
{
if (!empty($this->alternatives)) {
$max = max(array_keys($this->alternatives));
$base = $this->alternatives[$max];
} else {
$base = $this;
}
$widths = [];
if (func_num_args() === 1) {
foreach ((array) func_get_arg(0) as $width) {
if ($width < $base->get('width')) {
$widths[] = $width;
}
}
} else {
$max_width = min($max_width, $base->get('width'));
for ($width = $min_width; $width < $max_width; $width = $width + $step) {
$widths[] = $width;
}
}
foreach ($widths as $width) {
// Only generate image alternatives that don't already exist
if (array_key_exists((int) $width, $this->alternatives)) {
continue;
}
$derivative = MediumFactory::fromFile($base->get('filepath'));
// It's possible that MediumFactory::fromFile returns null if the
// original image file no longer exists and this class instance was
// retrieved from the page cache
if (null !== $derivative) {
$index = 2;
$alt_widths = array_keys($this->alternatives);
sort($alt_widths);
foreach ($alt_widths as $i => $key) {
if ($width > $key) {
$index += max($i, 1);
}
}
$basename = preg_replace('/(@\d+x){0,1}$/', "@{$width}w", $base->get('basename'), 1);
$derivative->setImagePrettyName($basename);
$ratio = $base->get('width') / $width;
$height = $derivative->get('height') / $ratio;
$derivative->resize($width, $height);
$derivative->set('width', $width);
$derivative->set('height', $height);
$this->addAlternative($ratio, $derivative);
}
}
return $this;
} | [
"public",
"function",
"derivatives",
"(",
"$",
"min_width",
",",
"$",
"max_width",
"=",
"2500",
",",
"$",
"step",
"=",
"200",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"alternatives",
")",
")",
"{",
"$",
"max",
"=",
"max",
"(",
"... | Generate alternative image widths, using either an array of integers, or
a min width, a max width, and a step parameter to fill out the necessary
widths. Existing image alternatives won't be overwritten.
@param int|int[] $min_width
@param int $max_width
@param int $step
@return $this | [
"Generate",
"alternative",
"image",
"widths",
"using",
"either",
"an",
"array",
"of",
"integers",
"or",
"a",
"min",
"width",
"a",
"max",
"width",
"and",
"a",
"step",
"parameter",
"to",
"fill",
"out",
"the",
"necessary",
"widths",
".",
"Existing",
"image",
... | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ImageMedium.php#L270-L332 | train | Generate derivatives of image | [
30522,
2270,
3853,
16942,
1006,
1002,
8117,
1035,
9381,
1010,
1002,
4098,
1035,
9381,
1027,
25108,
1010,
1002,
3357,
1027,
3263,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
2023,
1011,
1028,
15955,
1007,
1007,
1063,
1002,
4098,
1027,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Menu/MenuAbstract.php | MenuAbstract.applyEdits | private function applyEdits()
{
foreach ($this->edits as $edit) {
$mainMenuToEdit = $edit[0];
$subMenuToEdit = $edit[1];
$newUrl = $edit[2];
if ($subMenuToEdit === null) {
if (isset($this->menu[$mainMenuToEdit])) {
$menuDataToEdit = &$this->menu[$mainMenuToEdit];
} else {
$menuDataToEdit = null;
}
} else {
if (isset($this->menu[$mainMenuToEdit][$subMenuToEdit])) {
$menuDataToEdit = &$this->menu[$mainMenuToEdit][$subMenuToEdit];
} else {
$menuDataToEdit = null;
}
}
if (empty($menuDataToEdit)) {
$this->buildMenuItem($mainMenuToEdit, $subMenuToEdit, $newUrl);
} else {
$menuDataToEdit['_url'] = $newUrl;
}
}
} | php | private function applyEdits()
{
foreach ($this->edits as $edit) {
$mainMenuToEdit = $edit[0];
$subMenuToEdit = $edit[1];
$newUrl = $edit[2];
if ($subMenuToEdit === null) {
if (isset($this->menu[$mainMenuToEdit])) {
$menuDataToEdit = &$this->menu[$mainMenuToEdit];
} else {
$menuDataToEdit = null;
}
} else {
if (isset($this->menu[$mainMenuToEdit][$subMenuToEdit])) {
$menuDataToEdit = &$this->menu[$mainMenuToEdit][$subMenuToEdit];
} else {
$menuDataToEdit = null;
}
}
if (empty($menuDataToEdit)) {
$this->buildMenuItem($mainMenuToEdit, $subMenuToEdit, $newUrl);
} else {
$menuDataToEdit['_url'] = $newUrl;
}
}
} | [
"private",
"function",
"applyEdits",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"edits",
"as",
"$",
"edit",
")",
"{",
"$",
"mainMenuToEdit",
"=",
"$",
"edit",
"[",
"0",
"]",
";",
"$",
"subMenuToEdit",
"=",
"$",
"edit",
"[",
"1",
"]",
";",
... | Applies all edits to the menu. | [
"Applies",
"all",
"edits",
"to",
"the",
"menu",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Menu/MenuAbstract.php#L228-L255 | train | Apply edits to menu | [
30522,
2797,
3853,
6611,
2098,
12762,
1006,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
10086,
2015,
2004,
1002,
10086,
1007,
1063,
1002,
2364,
3549,
16161,
2098,
4183,
1027,
1002,
10086,
1031,
1014,
1033,
1025,
1002,
4942,
3549,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
opencart/opencart | upload/catalog/controller/event/activity.php | ControllerEventActivity.editPassword | public function editPassword(&$route, &$args, &$output) {
if ($this->config->get('config_customer_activity')) {
$this->load->model('account/activity');
if ($this->customer->isLogged()) {
$activity_data = array(
'customer_id' => $this->customer->getId(),
'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
);
$this->model_account_activity->addActivity('password', $activity_data);
} else {
$customer_info = $this->model_account_customer->getCustomerByEmail($args[0]);
if ($customer_info) {
$activity_data = array(
'customer_id' => $customer_info['customer_id'],
'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']
);
$this->model_account_activity->addActivity('reset', $activity_data);
}
}
}
} | php | public function editPassword(&$route, &$args, &$output) {
if ($this->config->get('config_customer_activity')) {
$this->load->model('account/activity');
if ($this->customer->isLogged()) {
$activity_data = array(
'customer_id' => $this->customer->getId(),
'name' => $this->customer->getFirstName() . ' ' . $this->customer->getLastName()
);
$this->model_account_activity->addActivity('password', $activity_data);
} else {
$customer_info = $this->model_account_customer->getCustomerByEmail($args[0]);
if ($customer_info) {
$activity_data = array(
'customer_id' => $customer_info['customer_id'],
'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']
);
$this->model_account_activity->addActivity('reset', $activity_data);
}
}
}
} | [
"public",
"function",
"editPassword",
"(",
"&",
"$",
"route",
",",
"&",
"$",
"args",
",",
"&",
"$",
"output",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'config_customer_activity'",
")",
")",
"{",
"$",
"this",
"->",
"load",
... | catalog/model/account/customer/editPassword/after | [
"catalog",
"/",
"model",
"/",
"account",
"/",
"customer",
"/",
"editPassword",
"/",
"after"
] | e7933b56ba05aafb3655c6b490c9733cd18b5c69 | https://github.com/opencart/opencart/blob/e7933b56ba05aafb3655c6b490c9733cd18b5c69/upload/catalog/controller/event/activity.php#L32-L56 | train | Edit password for customer | [
30522,
2270,
3853,
10086,
15194,
18351,
1006,
1004,
1002,
2799,
1010,
1004,
1002,
12098,
5620,
1010,
1004,
1002,
6434,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1011,
1028,
2131,
1006,
1005,
9530,
8873,
2290,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.onLoadRenamePopup | public function onLoadRenamePopup()
{
$this->abortIfReadOnly();
$path = Input::get('path');
$path = MediaLibrary::validatePath($path);
$this->vars['originalPath'] = $path;
$this->vars['name'] = basename($path);
$this->vars['listId'] = Input::get('listId');
$this->vars['type'] = Input::get('type');
return $this->makePartial('rename-form');
} | php | public function onLoadRenamePopup()
{
$this->abortIfReadOnly();
$path = Input::get('path');
$path = MediaLibrary::validatePath($path);
$this->vars['originalPath'] = $path;
$this->vars['name'] = basename($path);
$this->vars['listId'] = Input::get('listId');
$this->vars['type'] = Input::get('type');
return $this->makePartial('rename-form');
} | [
"public",
"function",
"onLoadRenamePopup",
"(",
")",
"{",
"$",
"this",
"->",
"abortIfReadOnly",
"(",
")",
";",
"$",
"path",
"=",
"Input",
"::",
"get",
"(",
"'path'",
")",
";",
"$",
"path",
"=",
"MediaLibrary",
"::",
"validatePath",
"(",
"$",
"path",
")... | Show rename item popup AJAX handler
@return array | [
"Show",
"rename",
"item",
"popup",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L380-L393 | train | onLoadRenamePopup callback. | [
30522,
2270,
3853,
2006,
11066,
7389,
14074,
16340,
6279,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
11113,
11589,
10128,
16416,
5280,
2135,
1006,
1007,
1025,
1002,
4130,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
4130,
1005,
1007,
1025,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/OptionsResolver/OptionsResolver.php | OptionsResolver.addNormalizer | public function addNormalizer(string $option, \Closure $normalizer, bool $forcePrepend = false): self
{
if ($this->locked) {
throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.');
}
if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
}
if ($forcePrepend) {
array_unshift($this->normalizers[$option], $normalizer);
} else {
$this->normalizers[$option][] = $normalizer;
}
// Make sure the option is processed
unset($this->resolved[$option]);
return $this;
} | php | public function addNormalizer(string $option, \Closure $normalizer, bool $forcePrepend = false): self
{
if ($this->locked) {
throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.');
}
if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
}
if ($forcePrepend) {
array_unshift($this->normalizers[$option], $normalizer);
} else {
$this->normalizers[$option][] = $normalizer;
}
// Make sure the option is processed
unset($this->resolved[$option]);
return $this;
} | [
"public",
"function",
"addNormalizer",
"(",
"string",
"$",
"option",
",",
"\\",
"Closure",
"$",
"normalizer",
",",
"bool",
"$",
"forcePrepend",
"=",
"false",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"Acce... | Adds a normalizer for an option.
The normalizer should be a closure with the following signature:
function (Options $options, $value): mixed {
// ...
}
The closure is invoked when {@link resolve()} is called. The closure
has access to the resolved values of other options through the passed
{@link Options} instance.
The second parameter passed to the closure is the value of
the option.
The resolved option value is set to the return value of the closure.
@param string $option The option name
@param \Closure $normalizer The normalizer
@param bool $forcePrepend If set to true, prepend instead of appending
@return $this
@throws UndefinedOptionsException If the option is undefined
@throws AccessException If called from a lazy option or normalizer | [
"Adds",
"a",
"normalizer",
"for",
"an",
"option",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/OptionsResolver/OptionsResolver.php#L522-L542 | train | Adds a normalizer to the list of normalizers defined for the option | [
30522,
2270,
3853,
5587,
12131,
9067,
17629,
1006,
5164,
1002,
5724,
1010,
1032,
8503,
1002,
3671,
17629,
1010,
22017,
2140,
1002,
2486,
28139,
11837,
2094,
1027,
6270,
1007,
1024,
2969,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5299,
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... |
php-ai/php-ml | src/Helper/Optimizer/ConjugateGradient.php | MP.adds | public static function adds(array $m1, float $m2, int $mag = 1): array
{
$res = [];
foreach ($m1 as $val) {
$res[] = $val + $mag * $m2;
}
return $res;
} | php | public static function adds(array $m1, float $m2, int $mag = 1): array
{
$res = [];
foreach ($m1 as $val) {
$res[] = $val + $mag * $m2;
}
return $res;
} | [
"public",
"static",
"function",
"adds",
"(",
"array",
"$",
"m1",
",",
"float",
"$",
"m2",
",",
"int",
"$",
"mag",
"=",
"1",
")",
":",
"array",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"m1",
"as",
"$",
"val",
")",
"{",
"$",
... | Element-wise <b>addition</b> of a vector with a scalar | [
"Element",
"-",
"wise",
"<b",
">",
"addition<",
"/",
"b",
">",
"of",
"a",
"vector",
"with",
"a",
"scalar"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/Optimizer/ConjugateGradient.php#L287-L295 | train | Adds two values to the array | [
30522,
2270,
10763,
3853,
9909,
1006,
9140,
1002,
23290,
1010,
14257,
1002,
25525,
1010,
20014,
1002,
23848,
1027,
1015,
1007,
1024,
9140,
1063,
1002,
24501,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
23290,
2004,
1002,
11748,
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... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php | Descriptor.formatValue | protected function formatValue($value)
{
if (\is_object($value)) {
return sprintf('object(%s)', \get_class($value));
}
if (\is_string($value)) {
return $value;
}
return preg_replace("/\n\s*/s", '', var_export($value, true));
} | php | protected function formatValue($value)
{
if (\is_object($value)) {
return sprintf('object(%s)', \get_class($value));
}
if (\is_string($value)) {
return $value;
}
return preg_replace("/\n\s*/s", '', var_export($value, true));
} | [
"protected",
"function",
"formatValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"return",
"sprintf",
"(",
"'object(%s)'",
",",
"\\",
"get_class",
"(",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
... | Formats a value as string.
@param mixed $value
@return string | [
"Formats",
"a",
"value",
"as",
"string",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php#L191-L202 | train | Format value to string | [
30522,
5123,
3853,
4289,
10175,
5657,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
4874,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
9043,
2546,
1006,
1005,
4874,
1006,
1003,
1055,
1007,
1005,
1010,
1032,
2131,
1035,
2465,
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/HttpClient/HttpClientTrait.php | HttpClientTrait.parseUrl | private static function parseUrl(string $url, array $query = [], array $allowedSchemes = ['http' => 80, 'https' => 443]): array
{
if (false === $parts = parse_url($url)) {
throw new InvalidArgumentException(sprintf('Malformed URL "%s".', $url));
}
if ($query) {
$parts['query'] = self::mergeQueryString($parts['query'] ?? null, $query, true);
}
$port = $parts['port'] ?? 0;
if (null !== $scheme = $parts['scheme'] ?? null) {
if (!isset($allowedSchemes[$scheme = strtolower($scheme)])) {
throw new InvalidArgumentException(sprintf('Unsupported scheme in "%s".', $url));
}
$port = $allowedSchemes[$scheme] === $port ? 0 : $port;
$scheme .= ':';
}
if (null !== $host = $parts['host'] ?? null) {
if (!\defined('INTL_IDNA_VARIANT_UTS46') && preg_match('/[\x80-\xFF]/', $host)) {
throw new InvalidArgumentException(sprintf('Unsupported IDN "%s", try enabling the "intl" PHP extension or running "composer require symfony/polyfill-intl-idn".', $host));
}
if (false === $host = \defined('INTL_IDNA_VARIANT_UTS46') ? idn_to_ascii($host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) : strtolower($host)) {
throw new InvalidArgumentException(sprintf('Unsupported host in "%s".', $url));
}
$host .= $port ? ':'.$port : '';
}
foreach (['user', 'pass', 'path', 'query', 'fragment'] as $part) {
if (!isset($parts[$part])) {
continue;
}
if (false !== strpos($parts[$part], '%')) {
// https://tools.ietf.org/html/rfc3986#section-2.3
$parts[$part] = preg_replace_callback('/%(?:2[DE]|3[0-9]|[46][1-9A-F]|5F|[57][0-9A]|7E)++/i', function ($m) { return rawurldecode($m[0]); }, $parts[$part]);
}
// https://tools.ietf.org/html/rfc3986#section-3.3
$parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()*+,;=:@%]++#", function ($m) { return rawurlencode($m[0]); }, $parts[$part]);
}
return [
'scheme' => $scheme,
'authority' => null !== $host ? '//'.(isset($parts['user']) ? $parts['user'].(isset($parts['pass']) ? ':'.$parts['pass'] : '').'@' : '').$host : null,
'path' => isset($parts['path'][0]) ? $parts['path'] : null,
'query' => isset($parts['query']) ? '?'.$parts['query'] : null,
'fragment' => isset($parts['fragment']) ? '#'.$parts['fragment'] : null,
];
} | php | private static function parseUrl(string $url, array $query = [], array $allowedSchemes = ['http' => 80, 'https' => 443]): array
{
if (false === $parts = parse_url($url)) {
throw new InvalidArgumentException(sprintf('Malformed URL "%s".', $url));
}
if ($query) {
$parts['query'] = self::mergeQueryString($parts['query'] ?? null, $query, true);
}
$port = $parts['port'] ?? 0;
if (null !== $scheme = $parts['scheme'] ?? null) {
if (!isset($allowedSchemes[$scheme = strtolower($scheme)])) {
throw new InvalidArgumentException(sprintf('Unsupported scheme in "%s".', $url));
}
$port = $allowedSchemes[$scheme] === $port ? 0 : $port;
$scheme .= ':';
}
if (null !== $host = $parts['host'] ?? null) {
if (!\defined('INTL_IDNA_VARIANT_UTS46') && preg_match('/[\x80-\xFF]/', $host)) {
throw new InvalidArgumentException(sprintf('Unsupported IDN "%s", try enabling the "intl" PHP extension or running "composer require symfony/polyfill-intl-idn".', $host));
}
if (false === $host = \defined('INTL_IDNA_VARIANT_UTS46') ? idn_to_ascii($host, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) : strtolower($host)) {
throw new InvalidArgumentException(sprintf('Unsupported host in "%s".', $url));
}
$host .= $port ? ':'.$port : '';
}
foreach (['user', 'pass', 'path', 'query', 'fragment'] as $part) {
if (!isset($parts[$part])) {
continue;
}
if (false !== strpos($parts[$part], '%')) {
// https://tools.ietf.org/html/rfc3986#section-2.3
$parts[$part] = preg_replace_callback('/%(?:2[DE]|3[0-9]|[46][1-9A-F]|5F|[57][0-9A]|7E)++/i', function ($m) { return rawurldecode($m[0]); }, $parts[$part]);
}
// https://tools.ietf.org/html/rfc3986#section-3.3
$parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()*+,;=:@%]++#", function ($m) { return rawurlencode($m[0]); }, $parts[$part]);
}
return [
'scheme' => $scheme,
'authority' => null !== $host ? '//'.(isset($parts['user']) ? $parts['user'].(isset($parts['pass']) ? ':'.$parts['pass'] : '').'@' : '').$host : null,
'path' => isset($parts['path'][0]) ? $parts['path'] : null,
'query' => isset($parts['query']) ? '?'.$parts['query'] : null,
'fragment' => isset($parts['fragment']) ? '#'.$parts['fragment'] : null,
];
} | [
"private",
"static",
"function",
"parseUrl",
"(",
"string",
"$",
"url",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"array",
"$",
"allowedSchemes",
"=",
"[",
"'http'",
"=>",
"80",
",",
"'https'",
"=>",
"443",
"]",
")",
":",
"array",
"{",
"if",
... | Parses a URL and fixes its encoding if needed.
@throws InvalidArgumentException When an invalid URL is passed | [
"Parses",
"a",
"URL",
"and",
"fixes",
"its",
"encoding",
"if",
"needed",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/HttpClientTrait.php#L378-L432 | train | Parse URL and return array of parts | [
30522,
2797,
10763,
3853,
11968,
3366,
3126,
2140,
1006,
5164,
1002,
24471,
2140,
1010,
9140,
1002,
23032,
1027,
1031,
1033,
1010,
9140,
1002,
3039,
22842,
7834,
1027,
1031,
1005,
8299,
1005,
1027,
1028,
3770,
1010,
1005,
16770,
1005,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Filesystem/Filesystem.php | Filesystem.normalizePathPart | protected function normalizePathPart(string $path): string
{
// Quick check for empty path.
if ($path === '' || $path === '.') {
return '';
}
// Quick check for root.
if ($path === '/') {
return '/';
}
// If the last character is not '/' or any of '\', './', '//' and '..' are not found, path is clean and we're done.
if ($path[-1] !== '/' && !preg_match('`(\\\\|\./|//|\.\.)`', $path)) {
return $path;
}
// Convert backslashes
$path = strtr($path, ['\\' => '/']);
$parts = explode('/', $path);
// Keep absolute paths.
$root = '';
if ($parts[0] === '') {
$root = '/';
array_shift($parts);
}
$list = [];
foreach ($parts as $i => $part) {
// Remove empty parts: // and /./
if ($part === '' || $part === '.') {
continue;
}
// Resolve /../ by removing path part.
if ($part === '..') {
$test = array_shift($list);
if ($test === null) {
// Oops, user tried to access something outside of our root folder.
throw new \RuntimeException("Bad path {$path}");
}
}
$list[] = $part;
}
// Build path back together.
return $root . implode('/', $list);
} | php | protected function normalizePathPart(string $path): string
{
// Quick check for empty path.
if ($path === '' || $path === '.') {
return '';
}
// Quick check for root.
if ($path === '/') {
return '/';
}
// If the last character is not '/' or any of '\', './', '//' and '..' are not found, path is clean and we're done.
if ($path[-1] !== '/' && !preg_match('`(\\\\|\./|//|\.\.)`', $path)) {
return $path;
}
// Convert backslashes
$path = strtr($path, ['\\' => '/']);
$parts = explode('/', $path);
// Keep absolute paths.
$root = '';
if ($parts[0] === '') {
$root = '/';
array_shift($parts);
}
$list = [];
foreach ($parts as $i => $part) {
// Remove empty parts: // and /./
if ($part === '' || $part === '.') {
continue;
}
// Resolve /../ by removing path part.
if ($part === '..') {
$test = array_shift($list);
if ($test === null) {
// Oops, user tried to access something outside of our root folder.
throw new \RuntimeException("Bad path {$path}");
}
}
$list[] = $part;
}
// Build path back together.
return $root . implode('/', $list);
} | [
"protected",
"function",
"normalizePathPart",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"// Quick check for empty path.",
"if",
"(",
"$",
"path",
"===",
"''",
"||",
"$",
"path",
"===",
"'.'",
")",
"{",
"return",
"''",
";",
"}",
"// Quick check for... | @param string $path
@return string
@throws \RuntimeException | [
"@param",
"string",
"$path"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Filesystem/Filesystem.php#L242-L292 | train | Normalize path part | [
30522,
5123,
3853,
3671,
4697,
15069,
19362,
2102,
1006,
5164,
1002,
4130,
1007,
1024,
5164,
1063,
1013,
1013,
4248,
4638,
2005,
4064,
4130,
1012,
2065,
1006,
1002,
4130,
1027,
1027,
1027,
1005,
1005,
1064,
1064,
1002,
4130,
1027,
1027,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Writer/TranslationWriter.php | TranslationWriter.write | public function write(MessageCatalogue $catalogue, $format, $options = [])
{
if (!isset($this->dumpers[$format])) {
throw new InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format));
}
// get the right dumper
$dumper = $this->dumpers[$format];
if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) {
throw new RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
}
// save
$dumper->dump($catalogue, $options);
} | php | public function write(MessageCatalogue $catalogue, $format, $options = [])
{
if (!isset($this->dumpers[$format])) {
throw new InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format));
}
// get the right dumper
$dumper = $this->dumpers[$format];
if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) {
throw new RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
}
// save
$dumper->dump($catalogue, $options);
} | [
"public",
"function",
"write",
"(",
"MessageCatalogue",
"$",
"catalogue",
",",
"$",
"format",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dumpers",
"[",
"$",
"format",
"]",
")",
")",
"{",
"throw",... | Writes translation from the catalogue according to the selected format.
@param MessageCatalogue $catalogue The message catalogue to write
@param string $format The format to use to dump the messages
@param array $options Options that are passed to the dumper
@throws InvalidArgumentException | [
"Writes",
"translation",
"from",
"the",
"catalogue",
"according",
"to",
"the",
"selected",
"format",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Writer/TranslationWriter.php#L74-L89 | train | Write a message catalogue to the specified format | [
30522,
2270,
3853,
4339,
1006,
4471,
11266,
23067,
9077,
1002,
10161,
1010,
1002,
4289,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
15653,
2545,
1031,
1002,
4289,
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... |
matomo-org/matomo | core/Option.php | Option.autoload | protected function autoload()
{
if ($this->loaded) {
return;
}
$table = Common::prefixTable('option');
$sql = 'SELECT option_value, option_name FROM `' . $table . '` WHERE autoload = 1';
$all = Db::fetchAll($sql);
foreach ($all as $option) {
$this->all[$option['option_name']] = $option['option_value'];
}
$this->loaded = true;
} | php | protected function autoload()
{
if ($this->loaded) {
return;
}
$table = Common::prefixTable('option');
$sql = 'SELECT option_value, option_name FROM `' . $table . '` WHERE autoload = 1';
$all = Db::fetchAll($sql);
foreach ($all as $option) {
$this->all[$option['option_name']] = $option['option_value'];
}
$this->loaded = true;
} | [
"protected",
"function",
"autoload",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loaded",
")",
"{",
"return",
";",
"}",
"$",
"table",
"=",
"Common",
"::",
"prefixTable",
"(",
"'option'",
")",
";",
"$",
"sql",
"=",
"'SELECT option_value, option_name FROM ... | Initialize cache with autoload settings.
@return void | [
"Initialize",
"cache",
"with",
"autoload",
"settings",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Option.php#L263-L278 | train | Load all options from the database | [
30522,
5123,
3853,
8285,
11066,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
8209,
1007,
1063,
2709,
1025,
1065,
1002,
2795,
1027,
2691,
1024,
1024,
17576,
10880,
1006,
1005,
5724,
1005,
1007,
1025,
1002,
29296,
1027,
1005,
7276,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TokenBasedRememberMeServices.php | TokenBasedRememberMeServices.processAutoLoginCookie | protected function processAutoLoginCookie(array $cookieParts, Request $request)
{
if (4 !== \count($cookieParts)) {
throw new AuthenticationException('The cookie is invalid.');
}
list($class, $username, $expires, $hash) = $cookieParts;
if (false === $username = base64_decode($username, true)) {
throw new AuthenticationException('$username contains a character from outside the base64 alphabet.');
}
try {
$user = $this->getUserProvider($class)->loadUserByUsername($username);
} catch (\Exception $e) {
if (!$e instanceof AuthenticationException) {
$e = new AuthenticationException($e->getMessage(), $e->getCode(), $e);
}
throw $e;
}
if (!$user instanceof UserInterface) {
throw new \RuntimeException(sprintf('The UserProviderInterface implementation must return an instance of UserInterface, but returned "%s".', \get_class($user)));
}
if (true !== hash_equals($this->generateCookieHash($class, $username, $expires, $user->getPassword()), $hash)) {
throw new AuthenticationException('The cookie\'s hash is invalid.');
}
if ($expires < time()) {
throw new AuthenticationException('The cookie has expired.');
}
return $user;
} | php | protected function processAutoLoginCookie(array $cookieParts, Request $request)
{
if (4 !== \count($cookieParts)) {
throw new AuthenticationException('The cookie is invalid.');
}
list($class, $username, $expires, $hash) = $cookieParts;
if (false === $username = base64_decode($username, true)) {
throw new AuthenticationException('$username contains a character from outside the base64 alphabet.');
}
try {
$user = $this->getUserProvider($class)->loadUserByUsername($username);
} catch (\Exception $e) {
if (!$e instanceof AuthenticationException) {
$e = new AuthenticationException($e->getMessage(), $e->getCode(), $e);
}
throw $e;
}
if (!$user instanceof UserInterface) {
throw new \RuntimeException(sprintf('The UserProviderInterface implementation must return an instance of UserInterface, but returned "%s".', \get_class($user)));
}
if (true !== hash_equals($this->generateCookieHash($class, $username, $expires, $user->getPassword()), $hash)) {
throw new AuthenticationException('The cookie\'s hash is invalid.');
}
if ($expires < time()) {
throw new AuthenticationException('The cookie has expired.');
}
return $user;
} | [
"protected",
"function",
"processAutoLoginCookie",
"(",
"array",
"$",
"cookieParts",
",",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"4",
"!==",
"\\",
"count",
"(",
"$",
"cookieParts",
")",
")",
"{",
"throw",
"new",
"AuthenticationException",
"(",
"'The... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/RememberMe/TokenBasedRememberMeServices.php#L32-L65 | train | Process the auto login cookie | [
30522,
5123,
3853,
2832,
4887,
3406,
21197,
2378,
3597,
23212,
2063,
1006,
9140,
1002,
17387,
26950,
1010,
5227,
1002,
5227,
1007,
1063,
2065,
1006,
1018,
999,
1027,
1027,
1032,
4175,
1006,
1002,
17387,
26950,
1007,
1007,
1063,
5466,
2047,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/PluginManager.php | PluginManager.getPluginNamespaces | public function getPluginNamespaces()
{
$classNames = [];
foreach ($this->getVendorAndPluginNames() as $vendorName => $vendorList) {
foreach ($vendorList as $pluginName => $pluginPath) {
$namespace = '\\'.$vendorName.'\\'.$pluginName;
$namespace = Str::normalizeClassName($namespace);
$classNames[$namespace] = $pluginPath;
}
}
return $classNames;
} | php | public function getPluginNamespaces()
{
$classNames = [];
foreach ($this->getVendorAndPluginNames() as $vendorName => $vendorList) {
foreach ($vendorList as $pluginName => $pluginPath) {
$namespace = '\\'.$vendorName.'\\'.$pluginName;
$namespace = Str::normalizeClassName($namespace);
$classNames[$namespace] = $pluginPath;
}
}
return $classNames;
} | [
"public",
"function",
"getPluginNamespaces",
"(",
")",
"{",
"$",
"classNames",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getVendorAndPluginNames",
"(",
")",
"as",
"$",
"vendorName",
"=>",
"$",
"vendorList",
")",
"{",
"foreach",
"(",
"$",
"v... | Returns a flat array of vendor plugin namespaces and their paths | [
"Returns",
"a",
"flat",
"array",
"of",
"vendor",
"plugin",
"namespaces",
"and",
"their",
"paths"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/PluginManager.php#L372-L385 | train | Get all plugin namespaces | [
30522,
2270,
3853,
2131,
24759,
15916,
23111,
14074,
23058,
2015,
1006,
1007,
1063,
1002,
2465,
18442,
2015,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
8159,
24562,
4859,
24759,
15916,
23111,
14074,
2015,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Config/ConfigFileFinder.php | ConfigFileFinder.locateFiles | public function locateFiles(array $paths, $pattern = '|\.yaml$|', $levels = -1)
{
$list = [];
foreach ($paths as $folder) {
$list += $this->detectRecursive($folder, $pattern, $levels);
}
return $list;
} | php | public function locateFiles(array $paths, $pattern = '|\.yaml$|', $levels = -1)
{
$list = [];
foreach ($paths as $folder) {
$list += $this->detectRecursive($folder, $pattern, $levels);
}
return $list;
} | [
"public",
"function",
"locateFiles",
"(",
"array",
"$",
"paths",
",",
"$",
"pattern",
"=",
"'|\\.yaml$|'",
",",
"$",
"levels",
"=",
"-",
"1",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"folder",
")",
"{",
... | Return all locations for all the files with a timestamp.
@param array $paths List of folders to look from.
@param string $pattern Pattern to match the file. Pattern will also be removed from the key.
@param int $levels Maximum number of recursive directories.
@return array | [
"Return",
"all",
"locations",
"for",
"all",
"the",
"files",
"with",
"a",
"timestamp",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Config/ConfigFileFinder.php#L37-L44 | train | Locates all files in a list of directories matching a pattern. | [
30522,
2270,
3853,
12453,
8873,
4244,
1006,
9140,
1002,
10425,
1010,
1002,
5418,
1027,
1005,
1064,
1032,
1012,
8038,
19968,
1002,
1064,
1005,
1010,
1002,
3798,
1027,
1011,
1015,
1007,
1063,
1002,
2862,
1027,
1031,
1033,
1025,
18921,
6776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/LocationProvider.php | LocationProvider.getLocationProviders | protected static function getLocationProviders(Plugin $plugin)
{
$locationProviders = $plugin->findMultipleComponents('LocationProvider', 'Piwik\\Plugins\\UserCountry\\LocationProvider');
$instances = [];
foreach ($locationProviders as $locationProvider) {
$instances[] = new $locationProvider();
}
return $instances;
} | php | protected static function getLocationProviders(Plugin $plugin)
{
$locationProviders = $plugin->findMultipleComponents('LocationProvider', 'Piwik\\Plugins\\UserCountry\\LocationProvider');
$instances = [];
foreach ($locationProviders as $locationProvider) {
$instances[] = new $locationProvider();
}
return $instances;
} | [
"protected",
"static",
"function",
"getLocationProviders",
"(",
"Plugin",
"$",
"plugin",
")",
"{",
"$",
"locationProviders",
"=",
"$",
"plugin",
"->",
"findMultipleComponents",
"(",
"'LocationProvider'",
",",
"'Piwik\\\\Plugins\\\\UserCountry\\\\LocationProvider'",
")",
"... | Get all lo that are defined by the given plugin.
@param Plugin $plugin
@return LocationProvider[] | [
"Get",
"all",
"lo",
"that",
"are",
"defined",
"by",
"the",
"given",
"plugin",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/LocationProvider.php#L187-L197 | train | Get all LocationProvider objects from a plugin. | [
30522,
5123,
10763,
3853,
2131,
4135,
10719,
21572,
17258,
2545,
1006,
13354,
2378,
1002,
13354,
2378,
1007,
1063,
1002,
3295,
21572,
17258,
2545,
1027,
1002,
13354,
2378,
1011,
1028,
2424,
12274,
7096,
11514,
2571,
9006,
29513,
7666,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Form/Traits/FormTrait.php | FormTrait.parseRequest | protected function parseRequest(ServerRequestInterface $request): array
{
$method = $request->getMethod();
if (!\in_array($method, ['PUT', 'POST', 'PATCH'])) {
throw new \RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
}
$body = $request->getParsedBody();
$data = isset($body['data']) ? $this->decodeData($body['data']) : null;
$flash = $this->getFlash();
/*
if (null !== $data) {
$flash->setData($data);
$flash->save();
}
*/
$blueprint = $this->getBlueprint();
$includeOriginal = (bool)($blueprint->form()['images']['original'] ?? null);
$files = $flash->getFilesByFields($includeOriginal);
$data = $blueprint->processForm($data ?? [], $body['toggleable_data'] ?? []);
return [
$data,
$files ?? []
];
} | php | protected function parseRequest(ServerRequestInterface $request): array
{
$method = $request->getMethod();
if (!\in_array($method, ['PUT', 'POST', 'PATCH'])) {
throw new \RuntimeException(sprintf('FlexForm: Bad HTTP method %s', $method));
}
$body = $request->getParsedBody();
$data = isset($body['data']) ? $this->decodeData($body['data']) : null;
$flash = $this->getFlash();
/*
if (null !== $data) {
$flash->setData($data);
$flash->save();
}
*/
$blueprint = $this->getBlueprint();
$includeOriginal = (bool)($blueprint->form()['images']['original'] ?? null);
$files = $flash->getFilesByFields($includeOriginal);
$data = $blueprint->processForm($data ?? [], $body['toggleable_data'] ?? []);
return [
$data,
$files ?? []
];
} | [
"protected",
"function",
"parseRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"array",
"{",
"$",
"method",
"=",
"$",
"request",
"->",
"getMethod",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"method",
",",
"[",
"'PUT'",... | Parse PSR-7 ServerRequest into data and files.
@param ServerRequestInterface $request
@return array | [
"Parse",
"PSR",
"-",
"7",
"ServerRequest",
"into",
"data",
"and",
"files",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/Traits/FormTrait.php#L446-L474 | train | Parse the request and return the data and files | [
30522,
5123,
3853,
11968,
8043,
2063,
15500,
1006,
8241,
2890,
15500,
18447,
2121,
12172,
1002,
5227,
1007,
1024,
9140,
1063,
1002,
4118,
1027,
1002,
5227,
1011,
1028,
2131,
11368,
6806,
2094,
1006,
1007,
1025,
2065,
1006,
999,
1032,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Layout/Content.php | Content.validateBreadcrumb | protected function validateBreadcrumb(array $breadcrumb)
{
foreach ($breadcrumb as $item) {
if (!is_array($item) || !Arr::has($item, 'text')) {
throw new \Exception('Breadcrumb format error!');
}
}
return true;
} | php | protected function validateBreadcrumb(array $breadcrumb)
{
foreach ($breadcrumb as $item) {
if (!is_array($item) || !Arr::has($item, 'text')) {
throw new \Exception('Breadcrumb format error!');
}
}
return true;
} | [
"protected",
"function",
"validateBreadcrumb",
"(",
"array",
"$",
"breadcrumb",
")",
"{",
"foreach",
"(",
"$",
"breadcrumb",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"item",
")",
"||",
"!",
"Arr",
"::",
"has",
"(",
"$",
"ite... | Validate content breadcrumb.
@param array $breadcrumb
@throws \Exception
@return bool | [
"Validate",
"content",
"breadcrumb",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Layout/Content.php#L102-L111 | train | Validate breadcrumb array | [
30522,
5123,
3853,
9398,
3686,
27035,
26775,
25438,
1006,
9140,
1002,
7852,
26775,
25438,
1007,
1063,
18921,
6776,
1006,
1002,
7852,
26775,
25438,
2004,
1002,
8875,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
8875,
1007,
1064... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Filter/AddSummaryRow.php | AddSummaryRow.filter | public function filter($table)
{
$row = new DataTableSummaryRow($table);
$row->setColumn('label', $this->labelSummaryRow);
$table->addSummaryRow($row);
} | php | public function filter($table)
{
$row = new DataTableSummaryRow($table);
$row->setColumn('label', $this->labelSummaryRow);
$table->addSummaryRow($row);
} | [
"public",
"function",
"filter",
"(",
"$",
"table",
")",
"{",
"$",
"row",
"=",
"new",
"DataTableSummaryRow",
"(",
"$",
"table",
")",
";",
"$",
"row",
"->",
"setColumn",
"(",
"'label'",
",",
"$",
"this",
"->",
"labelSummaryRow",
")",
";",
"$",
"table",
... | Executes the filter. See {@link AddSummaryRow}.
@param DataTable $table | [
"Executes",
"the",
"filter",
".",
"See",
"{",
"@link",
"AddSummaryRow",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/AddSummaryRow.php#L46-L51 | train | Filter the table to only include the summary row | [
30522,
2270,
3853,
11307,
1006,
1002,
2795,
1007,
1063,
1002,
5216,
1027,
2047,
2951,
10880,
17421,
7849,
12541,
5004,
1006,
1002,
2795,
1007,
1025,
1002,
5216,
1011,
1028,
2275,
25778,
2819,
2078,
1006,
1005,
3830,
1005,
1010,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php | ObjectCollectionTrait.copy | public function copy()
{
$list = [];
foreach ($this->getIterator() as $key => $value) {
$list[$key] = \is_object($value) ? clone $value : $value;
}
return $this->createFrom($list);
} | php | public function copy()
{
$list = [];
foreach ($this->getIterator() as $key => $value) {
$list[$key] = \is_object($value) ? clone $value : $value;
}
return $this->createFrom($list);
} | [
"public",
"function",
"copy",
"(",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"list",
"[",
"$",
"key",
"]",
"=",
"\\",
"is_object",... | Create a copy from this collection by cloning all objects in the collection.
@return static | [
"Create",
"a",
"copy",
"from",
"this",
"collection",
"by",
"cloning",
"all",
"objects",
"in",
"the",
"collection",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Object/Base/ObjectCollectionTrait.php#L29-L37 | train | Clone the array of objects and return a new array | [
30522,
2270,
3853,
6100,
1006,
1007,
1063,
1002,
2862,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
21646,
30524,
19699,
5358,
1006,
1002,
2862,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Updates/3.6.0-b2.php | Updates_3_6_0_b2.getMigrations | public function getMigrations(Updater $updater)
{
$migrations = [];
// in the previous 2.14.0-b2 idsite was added w/ AUTO_INCREMENT, but it should not have been. (note: this
// should have been undone in the 3.0.0-b1 update, but at least one instance out there still has the
// AUTO_INCREMENT modifier).
$migrations[] = $this->migration->db->changeColumn($this->siteSettingsTable, 'idsite', 'idsite', 'INTEGER(10) UNSIGNED NOT NULL');
$migrations = $this->getPluginSettingsMigrations($migrations);
$migrations = $this->getSiteSettingsMigrations($migrations);
$migrations = $this->getLogProfilingMigrations($migrations);
$accessColumns = DbHelper::getTableColumns(Common::prefixTable('access'));
// changes for ACL
$migrations[] = $this->migration->db->changeColumnType('access', 'access', 'VARCHAR(50) NULL');
if (!isset($accessColumns['idaccess'])) {
// the test UpdaterTest::testUpdateWorksAfterPiwikIsAlreadyUpToDate() runs this update on the new DB schema which
// already includes the idaccess column including auto_increment statement. It then fails cause it cannot drop
// the primary key from idaccess as it also has an auto_increment. But in normal case when not executed in that test
// it would remove the primary key (login,idsite). So we ensure to execute this only if the idaccess column not already
// exists
$migrations[] = $this->migration->db->dropPrimaryKey('access');
$migrations[] = $this->migration->db->addColumn('access', 'idaccess', 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT');
$migrations[] = $this->migration->db->addIndex('access', array('login', 'idsite'), 'index_loginidsite');
}
// changes for session auth
$migrations[] = $this->migration->db->addColumn('user', 'ts_password_modified',
'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP');
return $migrations;
} | php | public function getMigrations(Updater $updater)
{
$migrations = [];
// in the previous 2.14.0-b2 idsite was added w/ AUTO_INCREMENT, but it should not have been. (note: this
// should have been undone in the 3.0.0-b1 update, but at least one instance out there still has the
// AUTO_INCREMENT modifier).
$migrations[] = $this->migration->db->changeColumn($this->siteSettingsTable, 'idsite', 'idsite', 'INTEGER(10) UNSIGNED NOT NULL');
$migrations = $this->getPluginSettingsMigrations($migrations);
$migrations = $this->getSiteSettingsMigrations($migrations);
$migrations = $this->getLogProfilingMigrations($migrations);
$accessColumns = DbHelper::getTableColumns(Common::prefixTable('access'));
// changes for ACL
$migrations[] = $this->migration->db->changeColumnType('access', 'access', 'VARCHAR(50) NULL');
if (!isset($accessColumns['idaccess'])) {
// the test UpdaterTest::testUpdateWorksAfterPiwikIsAlreadyUpToDate() runs this update on the new DB schema which
// already includes the idaccess column including auto_increment statement. It then fails cause it cannot drop
// the primary key from idaccess as it also has an auto_increment. But in normal case when not executed in that test
// it would remove the primary key (login,idsite). So we ensure to execute this only if the idaccess column not already
// exists
$migrations[] = $this->migration->db->dropPrimaryKey('access');
$migrations[] = $this->migration->db->addColumn('access', 'idaccess', 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT');
$migrations[] = $this->migration->db->addIndex('access', array('login', 'idsite'), 'index_loginidsite');
}
// changes for session auth
$migrations[] = $this->migration->db->addColumn('user', 'ts_password_modified',
'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP');
return $migrations;
} | [
"public",
"function",
"getMigrations",
"(",
"Updater",
"$",
"updater",
")",
"{",
"$",
"migrations",
"=",
"[",
"]",
";",
"// in the previous 2.14.0-b2 idsite was added w/ AUTO_INCREMENT, but it should not have been. (note: this",
"// should have been undone in the 3.0.0-b1 update, but... | Here you can define one or multiple SQL statements that should be executed during the update.
@param Updater $updater
@return Migration[] | [
"Here",
"you",
"can",
"define",
"one",
"or",
"multiple",
"SQL",
"statements",
"that",
"should",
"be",
"executed",
"during",
"the",
"update",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updates/3.6.0-b2.php#L43-L76 | train | Returns the migrations for the plugin settings table | [
30522,
2270,
3853,
2131,
4328,
29397,
2015,
1006,
10651,
2099,
1002,
10651,
2099,
1007,
1063,
1002,
9230,
2015,
1027,
1031,
1033,
1025,
1013,
1013,
1999,
1996,
3025,
1016,
1012,
2403,
1012,
1014,
1011,
1038,
2475,
8909,
28032,
2063,
2001,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/GeoIp2/LocationProvider/GeoIp2/ServerModule.php | ServerModule.getLocation | public function getLocation($info)
{
$ip = $this->getIpFromInfo($info);
// geoip modules that are built into servers can't use a forced IP. in this case we try
// to fallback to another version.
$myIP = IP::getIpFromHeader();
if (!self::isSameOrAnonymizedIp($ip, $myIP)
&& (!isset($info['disable_fallbacks'])
|| !$info['disable_fallbacks'])
) {
Common::printDebug("The request is for IP address: " . $info['ip'] . " but your IP is: $myIP. GeoIP 2 (Server Module) does not support this use case... ");
$fallbacks = array(
Php::ID
);
foreach ($fallbacks as $fallbackProviderId) {
$otherProvider = LocationProvider::getProviderById($fallbackProviderId);
if ($otherProvider) {
Common::printDebug("Used $fallbackProviderId to detect this visitor IP");
return $otherProvider->getLocation($info);
}
}
Common::printDebug("FAILED to lookup the geo location of this IP address, as no fallback location providers is configured.");
return false;
}
$result = array();
foreach (self::getGeoIpServerVars() as $resultKey => $geoipVarName) {
if (!empty($_SERVER[$geoipVarName])) {
$result[$resultKey] = $_SERVER[$geoipVarName];
}
}
$this->completeLocationResult($result);
return $result;
} | php | public function getLocation($info)
{
$ip = $this->getIpFromInfo($info);
// geoip modules that are built into servers can't use a forced IP. in this case we try
// to fallback to another version.
$myIP = IP::getIpFromHeader();
if (!self::isSameOrAnonymizedIp($ip, $myIP)
&& (!isset($info['disable_fallbacks'])
|| !$info['disable_fallbacks'])
) {
Common::printDebug("The request is for IP address: " . $info['ip'] . " but your IP is: $myIP. GeoIP 2 (Server Module) does not support this use case... ");
$fallbacks = array(
Php::ID
);
foreach ($fallbacks as $fallbackProviderId) {
$otherProvider = LocationProvider::getProviderById($fallbackProviderId);
if ($otherProvider) {
Common::printDebug("Used $fallbackProviderId to detect this visitor IP");
return $otherProvider->getLocation($info);
}
}
Common::printDebug("FAILED to lookup the geo location of this IP address, as no fallback location providers is configured.");
return false;
}
$result = array();
foreach (self::getGeoIpServerVars() as $resultKey => $geoipVarName) {
if (!empty($_SERVER[$geoipVarName])) {
$result[$resultKey] = $_SERVER[$geoipVarName];
}
}
$this->completeLocationResult($result);
return $result;
} | [
"public",
"function",
"getLocation",
"(",
"$",
"info",
")",
"{",
"$",
"ip",
"=",
"$",
"this",
"->",
"getIpFromInfo",
"(",
"$",
"info",
")",
";",
"// geoip modules that are built into servers can't use a forced IP. in this case we try",
"// to fallback to another version.",
... | Uses a GeoIP 2 database to get a visitor's location based on their IP address.
This function will return different results based on the data used and based
on how the GeoIP 2 module is configured.
If a region database is used, it may return the country code, region code,
city name, area code, latitude, longitude and postal code of the visitor.
Alternatively, only the country code may be returned for another database.
If your HTTP server is not configured to include all GeoIP information, some
information will not be available to Piwik.
@param array $info Must have an 'ip' field.
@return array | [
"Uses",
"a",
"GeoIP",
"2",
"database",
"to",
"get",
"a",
"visitor",
"s",
"location",
"based",
"on",
"their",
"IP",
"address",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/LocationProvider/GeoIp2/ServerModule.php#L63-L97 | train | Returns the geo location of the IP address | [
30522,
2270,
3853,
2131,
4135,
10719,
1006,
1002,
18558,
1007,
1063,
1002,
12997,
1027,
1002,
2023,
1011,
1028,
2131,
11514,
19699,
20936,
2078,
14876,
1006,
1002,
18558,
1007,
1025,
1013,
1013,
20248,
11514,
14184,
2008,
2024,
2328,
2046,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Dumper/FileDumper.php | FileDumper.getRelativePath | private function getRelativePath(string $domain, string $locale): string
{
return strtr($this->relativePathTemplate, [
'%domain%' => $domain,
'%locale%' => $locale,
'%extension%' => $this->getExtension(),
]);
} | php | private function getRelativePath(string $domain, string $locale): string
{
return strtr($this->relativePathTemplate, [
'%domain%' => $domain,
'%locale%' => $locale,
'%extension%' => $this->getExtension(),
]);
} | [
"private",
"function",
"getRelativePath",
"(",
"string",
"$",
"domain",
",",
"string",
"$",
"locale",
")",
":",
"string",
"{",
"return",
"strtr",
"(",
"$",
"this",
"->",
"relativePathTemplate",
",",
"[",
"'%domain%'",
"=>",
"$",
"domain",
",",
"'%locale%'",
... | Gets the relative file path using the template. | [
"Gets",
"the",
"relative",
"file",
"path",
"using",
"the",
"template",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Dumper/FileDumper.php#L124-L131 | train | Returns relative path | [
30522,
2797,
3853,
2131,
16570,
8082,
15069,
1006,
5164,
1002,
5884,
1010,
5164,
1002,
2334,
2063,
1007,
1024,
5164,
1063,
2709,
2358,
5339,
2099,
1006,
1002,
2023,
1011,
1028,
5816,
15069,
18532,
15725,
1010,
1031,
1005,
1003,
5884,
1003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/CmsException.php | CmsException.processCompoundObject | public function processCompoundObject(Exception $exception)
{
switch ($this->code) {
case 200:
$result = $this->processIni($exception);
break;
case 300:
$result = $this->processPhp($exception);
break;
case 400:
$result = $this->processTwig($exception);
break;
}
if ($result !== false) {
$this->file = $this->compoundObject->getFilePath();
if (File::isFile($this->file) && is_readable($this->file)) {
$this->fileContent = @file($this->file);
}
}
return $result;
} | php | public function processCompoundObject(Exception $exception)
{
switch ($this->code) {
case 200:
$result = $this->processIni($exception);
break;
case 300:
$result = $this->processPhp($exception);
break;
case 400:
$result = $this->processTwig($exception);
break;
}
if ($result !== false) {
$this->file = $this->compoundObject->getFilePath();
if (File::isFile($this->file) && is_readable($this->file)) {
$this->fileContent = @file($this->file);
}
}
return $result;
} | [
"public",
"function",
"processCompoundObject",
"(",
"Exception",
"$",
"exception",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"code",
")",
"{",
"case",
"200",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"processIni",
"(",
"$",
"exception",
")",
";",
"... | Checks some conditions to confirm error has actually occurred
due to the CMS template code, not some external code. If the error
has occurred in external code, the function will return false. Otherwise return
true and modify the exception by overriding it's content, line and message values
to be accurate against a CMS object properties.
@param \Exception $exception The exception to modify.
@return bool | [
"Checks",
"some",
"conditions",
"to",
"confirm",
"error",
"has",
"actually",
"occurred",
"due",
"to",
"the",
"CMS",
"template",
"code",
"not",
"some",
"external",
"code",
".",
"If",
"the",
"error",
"has",
"occurred",
"in",
"external",
"code",
"the",
"functio... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/CmsException.php#L68-L92 | train | Process compound object exception | [
30522,
2270,
3853,
2832,
9006,
6873,
8630,
16429,
20614,
1006,
6453,
1002,
6453,
1007,
1063,
6942,
1006,
1002,
2023,
1011,
1028,
3642,
1007,
1063,
2553,
3263,
1024,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
2832,
5498,
1006,
1002,
6453,
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/Monolog/Handler/ServerLogHandler.php | ServerLogHandler.handle | public function handle(array $record)
{
if (!$this->isHandling($record)) {
return false;
}
set_error_handler(self::class.'::nullErrorHandler');
try {
if (!$this->socket = $this->socket ?: $this->createSocket()) {
return false === $this->bubble;
}
} finally {
restore_error_handler();
}
$recordFormatted = $this->formatRecord($record);
set_error_handler(self::class.'::nullErrorHandler');
try {
if (-1 === stream_socket_sendto($this->socket, $recordFormatted)) {
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
// Let's retry: the persistent connection might just be stale
if ($this->socket = $this->createSocket()) {
stream_socket_sendto($this->socket, $recordFormatted);
}
}
} finally {
restore_error_handler();
}
return false === $this->bubble;
} | php | public function handle(array $record)
{
if (!$this->isHandling($record)) {
return false;
}
set_error_handler(self::class.'::nullErrorHandler');
try {
if (!$this->socket = $this->socket ?: $this->createSocket()) {
return false === $this->bubble;
}
} finally {
restore_error_handler();
}
$recordFormatted = $this->formatRecord($record);
set_error_handler(self::class.'::nullErrorHandler');
try {
if (-1 === stream_socket_sendto($this->socket, $recordFormatted)) {
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
// Let's retry: the persistent connection might just be stale
if ($this->socket = $this->createSocket()) {
stream_socket_sendto($this->socket, $recordFormatted);
}
}
} finally {
restore_error_handler();
}
return false === $this->bubble;
} | [
"public",
"function",
"handle",
"(",
"array",
"$",
"record",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isHandling",
"(",
"$",
"record",
")",
")",
"{",
"return",
"false",
";",
"}",
"set_error_handler",
"(",
"self",
"::",
"class",
".",
"'::nullErrorH... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php#L42-L76 | train | Handles a record. | [
30522,
2270,
3853,
5047,
1006,
9140,
1002,
2501,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2003,
11774,
2989,
1006,
1002,
2501,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
2275,
1035,
7561,
1035,
28213,
1006,
2969,
1024,
1024,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Events/Dispatcher.php | Dispatcher.propagateListenerOptions | protected function propagateListenerOptions($listener, $job)
{
return tap($job, function ($job) use ($listener) {
$job->tries = $listener->tries ?? null;
$job->timeout = $listener->timeout ?? null;
$job->timeoutAt = method_exists($listener, 'retryUntil')
? $listener->retryUntil() : null;
});
} | php | protected function propagateListenerOptions($listener, $job)
{
return tap($job, function ($job) use ($listener) {
$job->tries = $listener->tries ?? null;
$job->timeout = $listener->timeout ?? null;
$job->timeoutAt = method_exists($listener, 'retryUntil')
? $listener->retryUntil() : null;
});
} | [
"protected",
"function",
"propagateListenerOptions",
"(",
"$",
"listener",
",",
"$",
"job",
")",
"{",
"return",
"tap",
"(",
"$",
"job",
",",
"function",
"(",
"$",
"job",
")",
"use",
"(",
"$",
"listener",
")",
"{",
"$",
"job",
"->",
"tries",
"=",
"$",... | Propagate listener options to the job.
@param mixed $listener
@param mixed $job
@return mixed | [
"Propagate",
"listener",
"options",
"to",
"the",
"job",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Events/Dispatcher.php#L499-L507 | train | Propagates listener options to the job. | [
30522,
5123,
3853,
17678,
16098,
9834,
27870,
3678,
7361,
9285,
1006,
1002,
19373,
1010,
1002,
3105,
1007,
1063,
2709,
11112,
1006,
1002,
3105,
1010,
3853,
1006,
1002,
3105,
1007,
2224,
1006,
1002,
19373,
1007,
1063,
1002,
3105,
1011,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/WinCache.php | Zend_Cache_Backend_WinCache.clean | public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
switch ($mode) {
case Zend_Cache::CLEANING_MODE_ALL:
return wincache_ucache_clear();
break;
case Zend_Cache::CLEANING_MODE_OLD:
$this->_log("Zend_Cache_Backend_WinCache::clean() : CLEANING_MODE_OLD is unsupported by the WinCache backend");
break;
case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
$this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND);
break;
default:
Zend_Cache::throwException('Invalid mode for clean() method');
break;
}
} | php | public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
switch ($mode) {
case Zend_Cache::CLEANING_MODE_ALL:
return wincache_ucache_clear();
break;
case Zend_Cache::CLEANING_MODE_OLD:
$this->_log("Zend_Cache_Backend_WinCache::clean() : CLEANING_MODE_OLD is unsupported by the WinCache backend");
break;
case Zend_Cache::CLEANING_MODE_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG:
case Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG:
$this->_log(self::TAGS_UNSUPPORTED_BY_CLEAN_OF_WINCACHE_BACKEND);
break;
default:
Zend_Cache::throwException('Invalid mode for clean() method');
break;
}
} | [
"public",
"function",
"clean",
"(",
"$",
"mode",
"=",
"Zend_Cache",
"::",
"CLEANING_MODE_ALL",
",",
"$",
"tags",
"=",
"array",
"(",
")",
")",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"Zend_Cache",
"::",
"CLEANING_MODE_ALL",
":",
"return",
"winc... | Clean some cache records
Available modes are :
'all' (default) => remove all cache entries ($tags is not used)
'old' => unsupported
'matchingTag' => unsupported
'notMatchingTag' => unsupported
'matchingAnyTag' => unsupported
@param string $mode clean mode
@param array $tags array of tags
@throws Zend_Cache_Exception
@return boolean true if no problem | [
"Clean",
"some",
"cache",
"records"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/WinCache.php#L145-L163 | train | Clean the WinCache | [
30522,
2270,
3853,
4550,
1006,
1002,
5549,
1027,
16729,
2094,
1035,
17053,
1024,
1024,
9344,
1035,
5549,
1035,
2035,
1010,
1002,
22073,
1027,
9140,
1006,
1007,
1007,
1063,
6942,
1006,
1002,
30524,
1024,
1024,
9344,
1035,
5549,
1035,
2214,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HeaderUtils.php | HeaderUtils.combine | public static function combine(array $parts): array
{
$assoc = [];
foreach ($parts as $part) {
$name = strtolower($part[0]);
$value = $part[1] ?? true;
$assoc[$name] = $value;
}
return $assoc;
} | php | public static function combine(array $parts): array
{
$assoc = [];
foreach ($parts as $part) {
$name = strtolower($part[0]);
$value = $part[1] ?? true;
$assoc[$name] = $value;
}
return $assoc;
} | [
"public",
"static",
"function",
"combine",
"(",
"array",
"$",
"parts",
")",
":",
"array",
"{",
"$",
"assoc",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"part",
"[",
"0"... | Combines an array of arrays into one associative array.
Each of the nested arrays should have one or two elements. The first
value will be used as the keys in the associative array, and the second
will be used as the values, or true if the nested array only contains one
element. Array keys are lowercased.
Example:
HeaderUtils::combine([["foo", "abc"], ["bar"]])
// => ["foo" => "abc", "bar" => true] | [
"Combines",
"an",
"array",
"of",
"arrays",
"into",
"one",
"associative",
"array",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/HeaderUtils.php#L84-L94 | train | Combine array of key = > value pairs into one array | [
30522,
2270,
10763,
3853,
11506,
1006,
9140,
1002,
3033,
1007,
1024,
9140,
1063,
1002,
4632,
10085,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
3033,
2004,
1002,
2112,
1007,
1063,
1002,
2171,
1027,
2358,
5339,
12898,
13777,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail.php | Zend_Mail.setMessageId | public function setMessageId($id = true)
{
if ($id === null || $id === false) {
return $this;
} elseif ($id === true) {
$id = $this->createMessageId();
}
if ($this->_messageId === null) {
$id = $this->_filterOther($id);
$this->_messageId = $id;
$this->_storeHeader('Message-Id', '<' . $this->_messageId . '>');
} else {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Message-ID set twice');
}
return $this;
} | php | public function setMessageId($id = true)
{
if ($id === null || $id === false) {
return $this;
} elseif ($id === true) {
$id = $this->createMessageId();
}
if ($this->_messageId === null) {
$id = $this->_filterOther($id);
$this->_messageId = $id;
$this->_storeHeader('Message-Id', '<' . $this->_messageId . '>');
} else {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Message-ID set twice');
}
return $this;
} | [
"public",
"function",
"setMessageId",
"(",
"$",
"id",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
"||",
"$",
"id",
"===",
"false",
")",
"{",
"return",
"$",
"this",
";",
"}",
"elseif",
"(",
"$",
"id",
"===",
"true",
")",
"{",
"$"... | Sets the Message-ID of the message
@param boolean|string $id
true :Auto
false :No set
null :No set
string:Sets given string (Angle brackets is not necessary)
@return Zend_Mail Provides fluent interface
@throws Zend_Mail_Exception | [
"Sets",
"the",
"Message",
"-",
"ID",
"of",
"the",
"message"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L1042-L1063 | train | Set message - id | [
30522,
2270,
3853,
2275,
7834,
3736,
3351,
3593,
1006,
1002,
8909,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
8909,
1027,
1027,
1027,
19701,
1064,
1064,
1002,
8909,
1027,
1027,
1027,
6270,
1007,
1063,
2709,
1002,
2023,
1025,
1065,
2842,
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... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.isShellSafe | protected static function isShellSafe($string)
{
// Future-proof
if (escapeshellcmd($string) !== $string
or !in_array(escapeshellarg($string), ["'$string'", "\"$string\""])
) {
return false;
}
$length = strlen($string);
for ($i = 0; $i < $length; ++$i) {
$c = $string[$i];
// All other characters have a special meaning in at least one common shell, including = and +.
// Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here.
// Note that this does permit non-Latin alphanumeric characters based on the current locale.
if (!ctype_alnum($c) && strpos('@_-.', $c) === false) {
return false;
}
}
return true;
} | php | protected static function isShellSafe($string)
{
// Future-proof
if (escapeshellcmd($string) !== $string
or !in_array(escapeshellarg($string), ["'$string'", "\"$string\""])
) {
return false;
}
$length = strlen($string);
for ($i = 0; $i < $length; ++$i) {
$c = $string[$i];
// All other characters have a special meaning in at least one common shell, including = and +.
// Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here.
// Note that this does permit non-Latin alphanumeric characters based on the current locale.
if (!ctype_alnum($c) && strpos('@_-.', $c) === false) {
return false;
}
}
return true;
} | [
"protected",
"static",
"function",
"isShellSafe",
"(",
"$",
"string",
")",
"{",
"// Future-proof",
"if",
"(",
"escapeshellcmd",
"(",
"$",
"string",
")",
"!==",
"$",
"string",
"or",
"!",
"in_array",
"(",
"escapeshellarg",
"(",
"$",
"string",
")",
",",
"[",
... | Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows.
@see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report
@param string $string The string to be validated
@return bool | [
"Fix",
"CVE",
"-",
"2016",
"-",
"10033",
"and",
"CVE",
"-",
"2016",
"-",
"10045",
"by",
"disallowing",
"potentially",
"unsafe",
"shell",
"characters",
".",
"Note",
"that",
"escapeshellarg",
"and",
"escapeshellcmd",
"are",
"inadequate",
"for",
"our",
"purposes"... | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L1652-L1675 | train | Checks if a string is safe to be used in a shell | [
30522,
5123,
10763,
3853,
26354,
18223,
3736,
7959,
1006,
1002,
5164,
1007,
1063,
1013,
1013,
2925,
1011,
6947,
2065,
1006,
12976,
18223,
27487,
2094,
1006,
1002,
5164,
1007,
999,
1027,
1027,
1002,
5164,
2030,
999,
1999,
1035,
9140,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php | TimeDataCollector.setEvents | public function setEvents(array $events)
{
foreach ($events as $event) {
$event->ensureStopped();
}
$this->data['events'] = $events;
} | php | public function setEvents(array $events)
{
foreach ($events as $event) {
$event->ensureStopped();
}
$this->data['events'] = $events;
} | [
"public",
"function",
"setEvents",
"(",
"array",
"$",
"events",
")",
"{",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"$",
"event",
"->",
"ensureStopped",
"(",
")",
";",
"}",
"$",
"this",
"->",
"data",
"[",
"'events'",
"]",
"=",
"$... | Sets the request events.
@param array $events The request events | [
"Sets",
"the",
"request",
"events",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php#L82-L89 | train | Set the events | [
30522,
2270,
3853,
2275,
18697,
7666,
1006,
9140,
1002,
2824,
1007,
1063,
18921,
6776,
1006,
1002,
2824,
2004,
1002,
2724,
1007,
1063,
1002,
2724,
1011,
1028,
21312,
14399,
5669,
1006,
1007,
1025,
1065,
1002,
2023,
1011,
1028,
2951,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Console/Scheduling/CacheSchedulingMutex.php | CacheSchedulingMutex.exists | public function exists(Event $event, DateTimeInterface $time)
{
return $this->cache->store($this->store)->has(
$event->mutexName().$time->format('Hi')
);
} | php | public function exists(Event $event, DateTimeInterface $time)
{
return $this->cache->store($this->store)->has(
$event->mutexName().$time->format('Hi')
);
} | [
"public",
"function",
"exists",
"(",
"Event",
"$",
"event",
",",
"DateTimeInterface",
"$",
"time",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"->",
"store",
"(",
"$",
"this",
"->",
"store",
")",
"->",
"has",
"(",
"$",
"event",
"->",
"mutexName",
... | Determine if a scheduling mutex exists for the given event.
@param \Illuminate\Console\Scheduling\Event $event
@param \DateTimeInterface $time
@return bool | [
"Determine",
"if",
"a",
"scheduling",
"mutex",
"exists",
"for",
"the",
"given",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/CacheSchedulingMutex.php#L56-L61 | train | Checks if an event exists in the cache | [
30522,
2270,
3853,
6526,
1006,
2724,
1002,
2724,
1010,
3058,
7292,
18447,
2121,
12172,
1002,
2051,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
17053,
1011,
1028,
3573,
1006,
1002,
2023,
1011,
1028,
3573,
1007,
1011,
1028,
2038,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpTransport.php | AmqpTransport.send | public function send(Envelope $envelope): Envelope
{
return ($this->sender ?? $this->getSender())->send($envelope);
} | php | public function send(Envelope $envelope): Envelope
{
return ($this->sender ?? $this->getSender())->send($envelope);
} | [
"public",
"function",
"send",
"(",
"Envelope",
"$",
"envelope",
")",
":",
"Envelope",
"{",
"return",
"(",
"$",
"this",
"->",
"sender",
"??",
"$",
"this",
"->",
"getSender",
"(",
")",
")",
"->",
"send",
"(",
"$",
"envelope",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpTransport.php#L66-L69 | train | Send an Envelope to the sender | [
30522,
2270,
3853,
4604,
1006,
11255,
1002,
11255,
1007,
1024,
11255,
1063,
2709,
1006,
1002,
2023,
1011,
1028,
4604,
2121,
1029,
1029,
1002,
2023,
1011,
1028,
4152,
10497,
2121,
1006,
1007,
1007,
1011,
1028,
4604,
1006,
1002,
11255,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Show.php | Show.addRelation | protected function addRelation($name, $builder, $label = '')
{
$relation = new Relation($name, $builder, $label);
$relation->setParent($this);
$this->overwriteExistingRelation($name);
return tap($relation, function ($relation) {
$this->relations->push($relation);
});
} | php | protected function addRelation($name, $builder, $label = '')
{
$relation = new Relation($name, $builder, $label);
$relation->setParent($this);
$this->overwriteExistingRelation($name);
return tap($relation, function ($relation) {
$this->relations->push($relation);
});
} | [
"protected",
"function",
"addRelation",
"(",
"$",
"name",
",",
"$",
"builder",
",",
"$",
"label",
"=",
"''",
")",
"{",
"$",
"relation",
"=",
"new",
"Relation",
"(",
"$",
"name",
",",
"$",
"builder",
",",
"$",
"label",
")",
";",
"$",
"relation",
"->... | Add a relation panel to show.
@param string $name
@param \Closure $builder
@param string $label
@return Relation | [
"Add",
"a",
"relation",
"panel",
"to",
"show",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show.php#L240-L251 | train | Add a new relation to the list of relations. | [
30522,
5123,
3853,
5587,
16570,
3370,
1006,
1002,
2171,
1010,
1002,
12508,
1010,
1002,
3830,
1027,
1005,
1005,
1007,
1063,
1002,
7189,
1027,
2047,
7189,
1006,
1002,
2171,
1010,
1002,
12508,
1010,
1002,
3830,
1007,
1025,
1002,
7189,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Row/DataTableSummaryRow.php | DataTableSummaryRow.sumTable | private function sumTable($table)
{
$metadata = $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$enableCopyMetadata = false;
foreach ($table->getRowsWithoutSummaryRow() as $row) {
$this->sumRow($row, $enableCopyMetadata, $metadata);
}
$summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($summaryRow) {
$this->sumRow($summaryRow, $enableCopyMetadata, $metadata);
}
} | php | private function sumTable($table)
{
$metadata = $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$enableCopyMetadata = false;
foreach ($table->getRowsWithoutSummaryRow() as $row) {
$this->sumRow($row, $enableCopyMetadata, $metadata);
}
$summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($summaryRow) {
$this->sumRow($summaryRow, $enableCopyMetadata, $metadata);
}
} | [
"private",
"function",
"sumTable",
"(",
"$",
"table",
")",
"{",
"$",
"metadata",
"=",
"$",
"table",
"->",
"getMetadata",
"(",
"DataTable",
"::",
"COLUMN_AGGREGATION_OPS_METADATA_NAME",
")",
";",
"$",
"enableCopyMetadata",
"=",
"false",
";",
"foreach",
"(",
"$"... | Sums a tables row with this one.
@param DataTable $table | [
"Sums",
"a",
"tables",
"row",
"with",
"this",
"one",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row/DataTableSummaryRow.php#L58-L72 | train | Sums the rows of a table and all its rows without the summary row | [
30522,
2797,
3853,
7680,
10880,
1006,
1002,
2795,
1007,
1063,
1002,
27425,
1027,
1002,
2795,
1011,
1028,
2131,
11368,
8447,
2696,
1006,
2951,
10880,
1024,
1024,
5930,
1035,
28041,
1035,
23092,
1035,
27425,
1035,
2171,
1007,
1025,
1002,
9585... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Marshaller/DefaultMarshaller.php | DefaultMarshaller.marshall | public function marshall(array $values, ?array &$failed): array
{
$serialized = $failed = [];
foreach ($values as $id => $value) {
try {
if ($this->useIgbinarySerialize) {
$serialized[$id] = igbinary_serialize($value);
} else {
$serialized[$id] = serialize($value);
}
} catch (\Exception $e) {
$failed[] = $id;
}
}
return $serialized;
} | php | public function marshall(array $values, ?array &$failed): array
{
$serialized = $failed = [];
foreach ($values as $id => $value) {
try {
if ($this->useIgbinarySerialize) {
$serialized[$id] = igbinary_serialize($value);
} else {
$serialized[$id] = serialize($value);
}
} catch (\Exception $e) {
$failed[] = $id;
}
}
return $serialized;
} | [
"public",
"function",
"marshall",
"(",
"array",
"$",
"values",
",",
"?",
"array",
"&",
"$",
"failed",
")",
":",
"array",
"{",
"$",
"serialized",
"=",
"$",
"failed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"id",
"=>",
"$",
"v... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php#L38-L55 | train | Marshall an array of language objects into a array of language objects. | [
30522,
2270,
3853,
5832,
1006,
9140,
1002,
5300,
1010,
1029,
9140,
1004,
1002,
3478,
1007,
1024,
9140,
1063,
1002,
27289,
1027,
1002,
3478,
1027,
1031,
1033,
30524,
8909,
1027,
1028,
1002,
3643,
1007,
1063,
3046,
1063,
2065,
1006,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php | ControllerTrait.denyAccessUnlessGranted | protected function denyAccessUnlessGranted($attributes, $subject = null, string $message = 'Access Denied.')
{
if (!$this->isGranted($attributes, $subject)) {
$exception = $this->createAccessDeniedException($message);
$exception->setAttributes($attributes);
$exception->setSubject($subject);
throw $exception;
}
} | php | protected function denyAccessUnlessGranted($attributes, $subject = null, string $message = 'Access Denied.')
{
if (!$this->isGranted($attributes, $subject)) {
$exception = $this->createAccessDeniedException($message);
$exception->setAttributes($attributes);
$exception->setSubject($subject);
throw $exception;
}
} | [
"protected",
"function",
"denyAccessUnlessGranted",
"(",
"$",
"attributes",
",",
"$",
"subject",
"=",
"null",
",",
"string",
"$",
"message",
"=",
"'Access Denied.'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isGranted",
"(",
"$",
"attributes",
",",
"$"... | Throws an exception unless the attributes are granted against the current authentication token and optionally
supplied subject.
@throws AccessDeniedException
@final | [
"Throws",
"an",
"exception",
"unless",
"the",
"attributes",
"are",
"granted",
"against",
"the",
"current",
"authentication",
"token",
"and",
"optionally",
"supplied",
"subject",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php#L190-L199 | train | Throws an exception if the attributes are not granted | [
30522,
5123,
3853,
9772,
6305,
9623,
19729,
3238,
18980,
2098,
1006,
1002,
12332,
1010,
1002,
3395,
1027,
19701,
1010,
5164,
1002,
4471,
1027,
1005,
3229,
6380,
1012,
1005,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2003,
18980,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.oldest | public function oldest($column = null)
{
if (is_null($column)) {
$column = $this->model->getCreatedAtColumn() ?? 'created_at';
}
$this->query->oldest($column);
return $this;
} | php | public function oldest($column = null)
{
if (is_null($column)) {
$column = $this->model->getCreatedAtColumn() ?? 'created_at';
}
$this->query->oldest($column);
return $this;
} | [
"public",
"function",
"oldest",
"(",
"$",
"column",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"column",
")",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"model",
"->",
"getCreatedAtColumn",
"(",
")",
"??",
"'created_at'",
";",
"}",
... | Add an "order by" clause for a timestamp to the query.
@param string $column
@return $this | [
"Add",
"an",
"order",
"by",
"clause",
"for",
"a",
"timestamp",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Builder.php#L276-L285 | train | Add a clause to the query to get the oldest created at | [
30522,
2270,
3853,
4587,
1006,
1002,
5930,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
5930,
1007,
1007,
1063,
1002,
5930,
1027,
1002,
2023,
1011,
1028,
2944,
1011,
1028,
2131,
16748,
4383,
4017,
25778,
2819,
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... |
getgrav/grav | system/src/Grav/Common/Uri.php | Uri.rootUrl | public function rootUrl($include_host = false)
{
if ($include_host) {
return $this->root;
}
return str_replace($this->base, '', $this->root);
} | php | public function rootUrl($include_host = false)
{
if ($include_host) {
return $this->root;
}
return str_replace($this->base, '', $this->root);
} | [
"public",
"function",
"rootUrl",
"(",
"$",
"include_host",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"include_host",
")",
"{",
"return",
"$",
"this",
"->",
"root",
";",
"}",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"base",
",",
"''",
",",
"$",
... | Return root URL to the site.
@param bool $include_host Include hostname.
@return mixed | [
"Return",
"root",
"URL",
"to",
"the",
"site",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L528-L535 | train | Return the root URL | [
30522,
2270,
3853,
7117,
3126,
2140,
1006,
1002,
2421,
1035,
3677,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2421,
1035,
3677,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7117,
1025,
1065,
2709,
2358,
2099,
1035,
5672,
1006,
1002,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Twig/Extension/FormExtension.php | FormExtension.getFunctions | public function getFunctions()
{
return [
new TwigFunction('form_widget', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_errors', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_label', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_help', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_row', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_rest', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_start', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_end', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('csrf_token', ['Symfony\Component\Form\FormRenderer', 'renderCsrfToken']),
new TwigFunction('form_parent', 'Symfony\Bridge\Twig\Extension\twig_get_form_parent'),
];
} | php | public function getFunctions()
{
return [
new TwigFunction('form_widget', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_errors', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_label', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_help', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_row', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_rest', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_start', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('form_end', null, ['node_class' => 'Symfony\Bridge\Twig\Node\RenderBlockNode', 'is_safe' => ['html']]),
new TwigFunction('csrf_token', ['Symfony\Component\Form\FormRenderer', 'renderCsrfToken']),
new TwigFunction('form_parent', 'Symfony\Bridge\Twig\Extension\twig_get_form_parent'),
];
} | [
"public",
"function",
"getFunctions",
"(",
")",
"{",
"return",
"[",
"new",
"TwigFunction",
"(",
"'form_widget'",
",",
"null",
",",
"[",
"'node_class'",
"=>",
"'Symfony\\Bridge\\Twig\\Node\\SearchAndRenderBlockNode'",
",",
"'is_safe'",
"=>",
"[",
"'html'",
"]",
"]",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/Extension/FormExtension.php#L44-L59 | train | Get the functions that will be used by the Twig framework | [
30522,
2270,
3853,
2131,
11263,
27989,
2015,
1006,
1007,
1063,
2709,
1031,
2047,
1056,
16279,
11263,
27989,
1006,
1005,
2433,
1035,
15536,
24291,
1005,
1010,
19701,
1010,
1031,
1005,
13045,
1035,
2465,
1005,
1027,
1028,
1005,
25353,
2213,
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/Rowset/Abstract.php | Zend_Db_Table_Rowset_Abstract.offsetGet | public function offsetGet($offset)
{
$offset = (int) $offset;
if ($offset < 0 || $offset >= $this->_count) {
// require_once 'Zend/Db/Table/Rowset/Exception.php';
throw new Zend_Db_Table_Rowset_Exception("Illegal index $offset");
}
$this->_pointer = $offset;
return $this->current();
} | php | public function offsetGet($offset)
{
$offset = (int) $offset;
if ($offset < 0 || $offset >= $this->_count) {
// require_once 'Zend/Db/Table/Rowset/Exception.php';
throw new Zend_Db_Table_Rowset_Exception("Illegal index $offset");
}
$this->_pointer = $offset;
return $this->current();
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"$",
"offset",
"=",
"(",
"int",
")",
"$",
"offset",
";",
"if",
"(",
"$",
"offset",
"<",
"0",
"||",
"$",
"offset",
">=",
"$",
"this",
"->",
"_count",
")",
"{",
"// require_once 'Zend/Db/... | Get the row for the given offset
Required by the ArrayAccess implementation
@param string $offset
@return Zend_Db_Table_Row_Abstract | [
"Get",
"the",
"row",
"for",
"the",
"given",
"offset",
"Required",
"by",
"the",
"ArrayAccess",
"implementation"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Rowset/Abstract.php#L338-L348 | train | Array access. | [
30522,
2270,
3853,
16396,
18150,
1006,
1002,
16396,
1007,
1063,
1002,
16396,
1027,
1006,
20014,
1007,
1002,
16396,
1025,
2065,
1006,
1002,
16396,
1026,
1014,
1064,
1064,
1002,
16396,
1028,
1027,
1002,
2023,
1011,
1028,
1035,
4175,
1007,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Console/Command.php | Command.askWithCompletion | public function askWithCompletion($question, array $choices, $default = null)
{
$question = new Question($question, $default);
$question->setAutocompleterValues($choices);
return $this->output->askQuestion($question);
} | php | public function askWithCompletion($question, array $choices, $default = null)
{
$question = new Question($question, $default);
$question->setAutocompleterValues($choices);
return $this->output->askQuestion($question);
} | [
"public",
"function",
"askWithCompletion",
"(",
"$",
"question",
",",
"array",
"$",
"choices",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"question",
"=",
"new",
"Question",
"(",
"$",
"question",
",",
"$",
"default",
")",
";",
"$",
"question",
"-... | Prompt the user for input with auto completion.
@param string $question
@param array $choices
@param string|null $default
@return mixed | [
"Prompt",
"the",
"user",
"for",
"input",
"with",
"auto",
"completion",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Command.php#L368-L375 | train | Asks the user for a question with automatic completion. | [
30522,
2270,
3853,
3198,
24415,
9006,
10814,
3508,
1006,
1002,
3160,
1010,
9140,
1002,
9804,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
1002,
3160,
1027,
2047,
3160,
1006,
1002,
3160,
1010,
1002,
12398,
1007,
1025,
1002,
3160,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Maildir.php | Zend_Mail_Storage_Maildir._getMaildirFiles | protected function _getMaildirFiles($dh, $dirname, $default_flags = array())
{
while (($entry = readdir($dh)) !== false) {
if ($entry[0] == '.' || !is_file($dirname . $entry)) {
continue;
}
@list($uniq, $info) = explode(':', $entry, 2);
@list(,$size) = explode(',', $uniq, 2);
if ($size && $size[0] == 'S' && $size[1] == '=') {
$size = substr($size, 2);
}
if (!ctype_digit($size)) {
$size = null;
}
@list($version, $flags) = explode(',', $info, 2);
if ($version != 2) {
$flags = '';
}
$named_flags = $default_flags;
$length = strlen($flags);
for ($i = 0; $i < $length; ++$i) {
$flag = $flags[$i];
$named_flags[$flag] = isset(self::$_knownFlags[$flag]) ? self::$_knownFlags[$flag] : $flag;
}
$data = array('uniq' => $uniq,
'flags' => $named_flags,
'flaglookup' => array_flip($named_flags),
'filename' => $dirname . $entry);
if ($size !== null) {
$data['size'] = (int)$size;
}
$this->_files[] = $data;
}
} | php | protected function _getMaildirFiles($dh, $dirname, $default_flags = array())
{
while (($entry = readdir($dh)) !== false) {
if ($entry[0] == '.' || !is_file($dirname . $entry)) {
continue;
}
@list($uniq, $info) = explode(':', $entry, 2);
@list(,$size) = explode(',', $uniq, 2);
if ($size && $size[0] == 'S' && $size[1] == '=') {
$size = substr($size, 2);
}
if (!ctype_digit($size)) {
$size = null;
}
@list($version, $flags) = explode(',', $info, 2);
if ($version != 2) {
$flags = '';
}
$named_flags = $default_flags;
$length = strlen($flags);
for ($i = 0; $i < $length; ++$i) {
$flag = $flags[$i];
$named_flags[$flag] = isset(self::$_knownFlags[$flag]) ? self::$_knownFlags[$flag] : $flag;
}
$data = array('uniq' => $uniq,
'flags' => $named_flags,
'flaglookup' => array_flip($named_flags),
'filename' => $dirname . $entry);
if ($size !== null) {
$data['size'] = (int)$size;
}
$this->_files[] = $data;
}
} | [
"protected",
"function",
"_getMaildirFiles",
"(",
"$",
"dh",
",",
"$",
"dirname",
",",
"$",
"default_flags",
"=",
"array",
"(",
")",
")",
"{",
"while",
"(",
"(",
"$",
"entry",
"=",
"readdir",
"(",
"$",
"dh",
")",
")",
"!==",
"false",
")",
"{",
"if"... | find all files in opened dir handle and add to maildir files
@param resource $dh dir handle used for search
@param string $dirname dirname of dir in $dh
@param array $default_flags default flags for given dir
@return null | [
"find",
"all",
"files",
"in",
"opened",
"dir",
"handle",
"and",
"add",
"to",
"maildir",
"files"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Maildir.php#L352-L388 | train | Get all files in a directory | [
30522,
5123,
3853,
1035,
2131,
21397,
4305,
12881,
9463,
2015,
1006,
1002,
28144,
1010,
1002,
16101,
18442,
1010,
1002,
12398,
1035,
9245,
1027,
9140,
1006,
1007,
1007,
1063,
2096,
1006,
1006,
1002,
4443,
1027,
3191,
4305,
2099,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/Material/Client.php | Client.upload | public function upload(string $type, string $path, array $form = [])
{
if (!file_exists($path) || !is_readable($path)) {
throw new InvalidArgumentException(sprintf('File does not exist, or the file is unreadable: "%s"', $path));
}
$form['type'] = $type;
return $this->httpUpload($this->getApiByType($type), ['media' => $path], $form);
} | php | public function upload(string $type, string $path, array $form = [])
{
if (!file_exists($path) || !is_readable($path)) {
throw new InvalidArgumentException(sprintf('File does not exist, or the file is unreadable: "%s"', $path));
}
$form['type'] = $type;
return $this->httpUpload($this->getApiByType($type), ['media' => $path], $form);
} | [
"public",
"function",
"upload",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"path",
",",
"array",
"$",
"form",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
"||",
"!",
"is_readable",
"(",
"$",
"path",
")",
")"... | Upload material.
@param string $type
@param string $path
@param array $form
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Upload",
"material",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Material/Client.php#L260-L269 | train | Upload a file to the api | [
30522,
2270,
3853,
2039,
11066,
1006,
5164,
1002,
2828,
1010,
5164,
1002,
4130,
1010,
9140,
1002,
2433,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
999,
5371,
1035,
6526,
1006,
1002,
4130,
1007,
1064,
1064,
999,
2003,
1035,
3191,
3085,
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/Mime/Header/AbstractHeader.php | AbstractHeader.toTokens | protected function toTokens(string $string = null): array
{
if (null === $string) {
$string = $this->getBodyAsString();
}
$tokens = [];
// Generate atoms; split at all invisible boundaries followed by WSP
foreach (preg_split('~(?=[ \t])~', $string) as $token) {
$newTokens = $this->generateTokenLines($token);
foreach ($newTokens as $newToken) {
$tokens[] = $newToken;
}
}
return $tokens;
} | php | protected function toTokens(string $string = null): array
{
if (null === $string) {
$string = $this->getBodyAsString();
}
$tokens = [];
// Generate atoms; split at all invisible boundaries followed by WSP
foreach (preg_split('~(?=[ \t])~', $string) as $token) {
$newTokens = $this->generateTokenLines($token);
foreach ($newTokens as $newToken) {
$tokens[] = $newToken;
}
}
return $tokens;
} | [
"protected",
"function",
"toTokens",
"(",
"string",
"$",
"string",
"=",
"null",
")",
":",
"array",
"{",
"if",
"(",
"null",
"===",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"getBodyAsString",
"(",
")",
";",
"}",
"$",
"tokens",
... | Generate a list of all tokens in the final header. | [
"Generate",
"a",
"list",
"of",
"all",
"tokens",
"in",
"the",
"final",
"header",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/Header/AbstractHeader.php#L231-L247 | train | Converts a string containing all tokens into an array of tokens | [
30522,
5123,
3853,
2000,
18715,
6132,
1006,
5164,
1002,
5164,
1027,
19701,
1007,
1024,
9140,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
5164,
1007,
1063,
1002,
5164,
1027,
1002,
2023,
1011,
1028,
2131,
23684,
12054,
18886,
3070,
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 | libs/Zend/Mail.php | Zend_Mail.send | public function send($transport = null)
{
if ($transport === null) {
if (! self::$_defaultTransport instanceof Zend_Mail_Transport_Abstract) {
// require_once 'Zend/Mail/Transport/Sendmail.php';
$transport = new Zend_Mail_Transport_Sendmail();
} else {
$transport = self::$_defaultTransport;
}
}
if ($this->_date === null) {
$this->setDate();
}
if(null === $this->_from && null !== self::getDefaultFrom()) {
$this->setFromToDefaultFrom();
}
if(null === $this->_replyTo && null !== self::getDefaultReplyTo()) {
$this->setReplyToFromDefault();
}
$transport->send($this);
return $this;
} | php | public function send($transport = null)
{
if ($transport === null) {
if (! self::$_defaultTransport instanceof Zend_Mail_Transport_Abstract) {
// require_once 'Zend/Mail/Transport/Sendmail.php';
$transport = new Zend_Mail_Transport_Sendmail();
} else {
$transport = self::$_defaultTransport;
}
}
if ($this->_date === null) {
$this->setDate();
}
if(null === $this->_from && null !== self::getDefaultFrom()) {
$this->setFromToDefaultFrom();
}
if(null === $this->_replyTo && null !== self::getDefaultReplyTo()) {
$this->setReplyToFromDefault();
}
$transport->send($this);
return $this;
} | [
"public",
"function",
"send",
"(",
"$",
"transport",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"transport",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_defaultTransport",
"instanceof",
"Zend_Mail_Transport_Abstract",
")",
"{",
"// require_once... | Sends this email using the given transport or a previously
set DefaultTransport or the internal mail function if no
default transport had been set.
@param Zend_Mail_Transport_Abstract $transport
@return Zend_Mail Provides fluent interface | [
"Sends",
"this",
"email",
"using",
"the",
"given",
"transport",
"or",
"a",
"previously",
"set",
"DefaultTransport",
"or",
"the",
"internal",
"mail",
"function",
"if",
"no",
"default",
"transport",
"had",
"been",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L1171-L1197 | train | Send the message using the transport | [
30522,
2270,
3853,
4604,
1006,
1002,
3665,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
3665,
1027,
1027,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2969,
1024,
1024,
1002,
1035,
12398,
6494,
3619,
6442,
6013,
11253,
16729,
2094,
1035,
5653,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Middleware/LogOperation.php | LogOperation.inAllowedMethods | protected function inAllowedMethods($method)
{
$allowedMethods = collect(config('admin.operation_log.allowed_methods'))->filter();
if ($allowedMethods->isEmpty()) {
return true;
}
return $allowedMethods->map(function ($method) {
return strtoupper($method);
})->contains($method);
} | php | protected function inAllowedMethods($method)
{
$allowedMethods = collect(config('admin.operation_log.allowed_methods'))->filter();
if ($allowedMethods->isEmpty()) {
return true;
}
return $allowedMethods->map(function ($method) {
return strtoupper($method);
})->contains($method);
} | [
"protected",
"function",
"inAllowedMethods",
"(",
"$",
"method",
")",
"{",
"$",
"allowedMethods",
"=",
"collect",
"(",
"config",
"(",
"'admin.operation_log.allowed_methods'",
")",
")",
"->",
"filter",
"(",
")",
";",
"if",
"(",
"$",
"allowedMethods",
"->",
"isE... | Whether requests using this method are allowed to be logged.
@param string $method
@return bool | [
"Whether",
"requests",
"using",
"this",
"method",
"are",
"allowed",
"to",
"be",
"logged",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Middleware/LogOperation.php#L61-L72 | train | Check if the method is in the allowed methods list | [
30522,
5123,
3853,
27118,
7174,
15557,
11368,
6806,
5104,
1006,
1002,
4118,
1007,
1063,
1002,
3039,
11368,
6806,
5104,
1027,
8145,
1006,
9530,
8873,
2290,
1006,
1005,
4748,
10020,
1012,
3169,
1035,
8833,
1012,
3039,
1035,
4725,
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... |
symfony/symfony | src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php | RoundRobinTransport.getNextTransport | protected function getNextTransport(): ?TransportInterface
{
$cursor = $this->cursor;
while (true) {
$transport = $this->transports[$cursor];
if (!$this->isTransportDead($transport)) {
break;
}
if ((microtime(true) - $this->deadTransports[$transport]) > $this->retryPeriod) {
$this->deadTransports->detach($transport);
break;
}
if ($this->cursor === $cursor = $this->moveCursor($cursor)) {
return null;
}
}
$this->cursor = $this->moveCursor($cursor);
return $transport;
} | php | protected function getNextTransport(): ?TransportInterface
{
$cursor = $this->cursor;
while (true) {
$transport = $this->transports[$cursor];
if (!$this->isTransportDead($transport)) {
break;
}
if ((microtime(true) - $this->deadTransports[$transport]) > $this->retryPeriod) {
$this->deadTransports->detach($transport);
break;
}
if ($this->cursor === $cursor = $this->moveCursor($cursor)) {
return null;
}
}
$this->cursor = $this->moveCursor($cursor);
return $transport;
} | [
"protected",
"function",
"getNextTransport",
"(",
")",
":",
"?",
"TransportInterface",
"{",
"$",
"cursor",
"=",
"$",
"this",
"->",
"cursor",
";",
"while",
"(",
"true",
")",
"{",
"$",
"transport",
"=",
"$",
"this",
"->",
"transports",
"[",
"$",
"cursor",
... | Rotates the transport list around and returns the first instance. | [
"Rotates",
"the",
"transport",
"list",
"around",
"and",
"returns",
"the",
"first",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mailer/Transport/RoundRobinTransport.php#L64-L88 | train | Get next transport in the chain | [
30522,
5123,
3853,
2131,
2638,
18413,
6494,
3619,
6442,
1006,
1007,
1024,
1029,
3665,
18447,
2121,
12172,
1063,
1002,
12731,
25301,
2099,
1027,
1002,
2023,
1011,
1028,
12731,
25301,
2099,
1025,
2096,
1006,
2995,
1007,
1063,
1002,
3665,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Ldap/Ldap.php | Ldap.bind | public function bind($dn = null, $password = null)
{
$this->adapter->getConnection()->bind($dn, $password);
} | php | public function bind($dn = null, $password = null)
{
$this->adapter->getConnection()->bind($dn, $password);
} | [
"public",
"function",
"bind",
"(",
"$",
"dn",
"=",
"null",
",",
"$",
"password",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"adapter",
"->",
"getConnection",
"(",
")",
"->",
"bind",
"(",
"$",
"dn",
",",
"$",
"password",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Ldap/Ldap.php#L36-L39 | train | Bind to the connection | [
30522,
2270,
3853,
14187,
1006,
1002,
1040,
2078,
1027,
19701,
1010,
1002,
20786,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
15581,
2121,
1011,
1028,
2131,
8663,
2638,
7542,
1006,
1007,
1011,
1028,
14187,
1006,
1002,
1040,
2078,
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... |
walkor/Workerman | Worker.php | Worker.listen | public function listen()
{
if (!$this->_socketName) {
return;
}
// Autoload.
Autoloader::setRootPath($this->_autoloadRootPath);
if (!$this->_mainSocket) {
// Get the application layer communication protocol and listening address.
list($scheme, $address) = explode(':', $this->_socketName, 2);
// Check application layer protocol class.
if (!isset(static::$_builtinTransports[$scheme])) {
$scheme = ucfirst($scheme);
$this->protocol = substr($scheme,0,1)==='\\' ? $scheme : '\\Protocols\\' . $scheme;
if (!class_exists($this->protocol)) {
$this->protocol = "\\Workerman\\Protocols\\$scheme";
if (!class_exists($this->protocol)) {
throw new Exception("class \\Protocols\\$scheme not exist");
}
}
if (!isset(static::$_builtinTransports[$this->transport])) {
throw new \Exception('Bad worker->transport ' . var_export($this->transport, true));
}
} else {
$this->transport = $scheme;
}
$local_socket = static::$_builtinTransports[$this->transport] . ":" . $address;
// Flag.
$flags = $this->transport === 'udp' ? STREAM_SERVER_BIND : STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
$errno = 0;
$errmsg = '';
// SO_REUSEPORT.
if ($this->reusePort) {
stream_context_set_option($this->_context, 'socket', 'so_reuseport', 1);
}
// Create an Internet or Unix domain server socket.
$this->_mainSocket = stream_socket_server($local_socket, $errno, $errmsg, $flags, $this->_context);
if (!$this->_mainSocket) {
throw new Exception($errmsg);
}
if ($this->transport === 'ssl') {
stream_socket_enable_crypto($this->_mainSocket, false);
} elseif ($this->transport === 'unix') {
$socketFile = substr($address, 2);
if ($this->user) {
chown($socketFile, $this->user);
}
if ($this->group) {
chgrp($socketFile, $this->group);
}
}
// Try to open keepalive for tcp and disable Nagle algorithm.
if (function_exists('socket_import_stream') && static::$_builtinTransports[$this->transport] === 'tcp') {
set_error_handler(function(){});
$socket = socket_import_stream($this->_mainSocket);
socket_set_option($socket, SOL_SOCKET, SO_KEEPALIVE, 1);
socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1);
restore_error_handler();
}
// Non blocking.
stream_set_blocking($this->_mainSocket, 0);
}
$this->resumeAccept();
} | php | public function listen()
{
if (!$this->_socketName) {
return;
}
// Autoload.
Autoloader::setRootPath($this->_autoloadRootPath);
if (!$this->_mainSocket) {
// Get the application layer communication protocol and listening address.
list($scheme, $address) = explode(':', $this->_socketName, 2);
// Check application layer protocol class.
if (!isset(static::$_builtinTransports[$scheme])) {
$scheme = ucfirst($scheme);
$this->protocol = substr($scheme,0,1)==='\\' ? $scheme : '\\Protocols\\' . $scheme;
if (!class_exists($this->protocol)) {
$this->protocol = "\\Workerman\\Protocols\\$scheme";
if (!class_exists($this->protocol)) {
throw new Exception("class \\Protocols\\$scheme not exist");
}
}
if (!isset(static::$_builtinTransports[$this->transport])) {
throw new \Exception('Bad worker->transport ' . var_export($this->transport, true));
}
} else {
$this->transport = $scheme;
}
$local_socket = static::$_builtinTransports[$this->transport] . ":" . $address;
// Flag.
$flags = $this->transport === 'udp' ? STREAM_SERVER_BIND : STREAM_SERVER_BIND | STREAM_SERVER_LISTEN;
$errno = 0;
$errmsg = '';
// SO_REUSEPORT.
if ($this->reusePort) {
stream_context_set_option($this->_context, 'socket', 'so_reuseport', 1);
}
// Create an Internet or Unix domain server socket.
$this->_mainSocket = stream_socket_server($local_socket, $errno, $errmsg, $flags, $this->_context);
if (!$this->_mainSocket) {
throw new Exception($errmsg);
}
if ($this->transport === 'ssl') {
stream_socket_enable_crypto($this->_mainSocket, false);
} elseif ($this->transport === 'unix') {
$socketFile = substr($address, 2);
if ($this->user) {
chown($socketFile, $this->user);
}
if ($this->group) {
chgrp($socketFile, $this->group);
}
}
// Try to open keepalive for tcp and disable Nagle algorithm.
if (function_exists('socket_import_stream') && static::$_builtinTransports[$this->transport] === 'tcp') {
set_error_handler(function(){});
$socket = socket_import_stream($this->_mainSocket);
socket_set_option($socket, SOL_SOCKET, SO_KEEPALIVE, 1);
socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1);
restore_error_handler();
}
// Non blocking.
stream_set_blocking($this->_mainSocket, 0);
}
$this->resumeAccept();
} | [
"public",
"function",
"listen",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_socketName",
")",
"{",
"return",
";",
"}",
"// Autoload.",
"Autoloader",
"::",
"setRootPath",
"(",
"$",
"this",
"->",
"_autoloadRootPath",
")",
";",
"if",
"(",
"!",
"$"... | Listen.
@throws Exception | [
"Listen",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L2172-L2245 | train | Listen to the worker socket | [
30522,
2270,
3853,
4952,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
22278,
18442,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
8285,
11066,
1012,
8285,
11066,
2121,
1024,
1024,
2275,
3217,
4140,
15069,
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/Mail/Storage/Pop3.php | Zend_Mail_Storage_Pop3.getSize | public function getSize($id = 0)
{
$id = $id ? $id : null;
return $this->_protocol->getList($id);
} | php | public function getSize($id = 0)
{
$id = $id ? $id : null;
return $this->_protocol->getList($id);
} | [
"public",
"function",
"getSize",
"(",
"$",
"id",
"=",
"0",
")",
"{",
"$",
"id",
"=",
"$",
"id",
"?",
"$",
"id",
":",
"null",
";",
"return",
"$",
"this",
"->",
"_protocol",
"->",
"getList",
"(",
"$",
"id",
")",
";",
"}"
] | get a list of messages with number and size
@param int $id number of message
@return int|array size of given message of list with all messages as array(num => size)
@throws Zend_Mail_Protocol_Exception | [
"get",
"a",
"list",
"of",
"messages",
"with",
"number",
"and",
"size"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Pop3.php#L76-L80 | train | Get size of all types | [
30522,
2270,
3853,
4152,
4697,
1006,
1002,
8909,
1027,
1014,
1007,
1063,
1002,
8909,
1027,
1002,
8909,
1029,
1002,
8909,
1024,
19701,
1025,
2709,
1002,
2023,
1011,
1028,
1035,
8778,
1011,
1028,
2131,
9863,
1006,
1002,
8909,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php | ThumbnailImageMedium.parsedownElement | public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
{
return $this->bubble('parsedownElement', [$title, $alt, $class, $id, $reset]);
} | php | public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
{
return $this->bubble('parsedownElement', [$title, $alt, $class, $id, $reset]);
} | [
"public",
"function",
"parsedownElement",
"(",
"$",
"title",
"=",
"null",
",",
"$",
"alt",
"=",
"null",
",",
"$",
"class",
"=",
"null",
",",
"$",
"id",
"=",
"null",
",",
"$",
"reset",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"bubble",
... | Get an element (is array) that can be rendered by the Parsedown engine
@param string $title
@param string $alt
@param string $class
@param string $id
@param bool $reset
@return array | [
"Get",
"an",
"element",
"(",
"is",
"array",
")",
"that",
"can",
"be",
"rendered",
"by",
"the",
"Parsedown",
"engine"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php#L45-L48 | train | Display a parsedown element | [
30522,
2270,
3853,
11968,
6924,
12384,
12260,
3672,
1006,
1002,
2516,
1027,
19701,
1010,
1002,
12456,
1027,
19701,
1010,
1002,
2465,
1027,
19701,
1010,
1002,
8909,
1027,
19701,
1010,
1002,
25141,
1027,
2995,
1007,
1063,
2709,
1002,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Ibm.php | Zend_Db_Adapter_Pdo_Ibm.prepare | public function prepare($sql)
{
$this->_connect();
$stmtClass = $this->_defaultStmtClass;
$stmt = new $stmtClass($this, $sql);
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
} | php | public function prepare($sql)
{
$this->_connect();
$stmtClass = $this->_defaultStmtClass;
$stmt = new $stmtClass($this, $sql);
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
} | [
"public",
"function",
"prepare",
"(",
"$",
"sql",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"$",
"stmtClass",
"=",
"$",
"this",
"->",
"_defaultStmtClass",
";",
"$",
"stmt",
"=",
"new",
"$",
"stmtClass",
"(",
"$",
"this",
",",
"$",
"sq... | Prepares an SQL statement.
@param string $sql The SQL statement with placeholders.
@param array $bind An array of data to bind to the placeholders.
@return PDOStatement | [
"Prepares",
"an",
"SQL",
"statement",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm.php#L193-L200 | train | Prepares a statement for execution. | [
30522,
2270,
3853,
7374,
1006,
1002,
29296,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1002,
2358,
20492,
26266,
1027,
1002,
2023,
1011,
1028,
1035,
12398,
3367,
20492,
26266,
1025,
1002,
2358,
20492,
1027,
2047,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Protocol/Imap.php | Zend_Mail_Protocol_Imap.fetch | public function fetch($items, $from, $to = null)
{
if (is_array($from)) {
$set = implode(',', $from);
} else if ($to === null) {
$set = (int)$from;
} else if ($to === INF) {
$set = (int)$from . ':*';
} else {
$set = (int)$from . ':' . (int)$to;
}
$items = (array)$items;
$itemList = $this->escapeList($items);
$this->sendRequest('FETCH', array($set, $itemList), $tag);
$result = array();
while (!$this->readLine($tokens, $tag)) {
// ignore other responses
if ($tokens[1] != 'FETCH') {
continue;
}
// ignore other messages
if ($to === null && !is_array($from) && $tokens[0] != $from) {
continue;
}
// if we only want one item we return that one directly
if (count($items) == 1) {
if ($tokens[2][0] == $items[0]) {
$data = $tokens[2][1];
} else {
// maybe the server send an other field we didn't wanted
$count = count($tokens[2]);
// we start with 2, because 0 was already checked
for ($i = 2; $i < $count; $i += 2) {
if ($tokens[2][$i] != $items[0]) {
continue;
}
$data = $tokens[2][$i + 1];
break;
}
}
} else {
$data = array();
while (key($tokens[2]) !== null) {
$data[current($tokens[2])] = next($tokens[2]);
next($tokens[2]);
}
}
// if we want only one message we can ignore everything else and just return
if ($to === null && !is_array($from) && $tokens[0] == $from) {
// we still need to read all lines
while (!$this->readLine($tokens, $tag));
return $data;
}
$result[$tokens[0]] = $data;
}
if ($to === null && !is_array($from)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('the single id was not found in response');
}
return $result;
} | php | public function fetch($items, $from, $to = null)
{
if (is_array($from)) {
$set = implode(',', $from);
} else if ($to === null) {
$set = (int)$from;
} else if ($to === INF) {
$set = (int)$from . ':*';
} else {
$set = (int)$from . ':' . (int)$to;
}
$items = (array)$items;
$itemList = $this->escapeList($items);
$this->sendRequest('FETCH', array($set, $itemList), $tag);
$result = array();
while (!$this->readLine($tokens, $tag)) {
// ignore other responses
if ($tokens[1] != 'FETCH') {
continue;
}
// ignore other messages
if ($to === null && !is_array($from) && $tokens[0] != $from) {
continue;
}
// if we only want one item we return that one directly
if (count($items) == 1) {
if ($tokens[2][0] == $items[0]) {
$data = $tokens[2][1];
} else {
// maybe the server send an other field we didn't wanted
$count = count($tokens[2]);
// we start with 2, because 0 was already checked
for ($i = 2; $i < $count; $i += 2) {
if ($tokens[2][$i] != $items[0]) {
continue;
}
$data = $tokens[2][$i + 1];
break;
}
}
} else {
$data = array();
while (key($tokens[2]) !== null) {
$data[current($tokens[2])] = next($tokens[2]);
next($tokens[2]);
}
}
// if we want only one message we can ignore everything else and just return
if ($to === null && !is_array($from) && $tokens[0] == $from) {
// we still need to read all lines
while (!$this->readLine($tokens, $tag));
return $data;
}
$result[$tokens[0]] = $data;
}
if ($to === null && !is_array($from)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('the single id was not found in response');
}
return $result;
} | [
"public",
"function",
"fetch",
"(",
"$",
"items",
",",
"$",
"from",
",",
"$",
"to",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"from",
")",
")",
"{",
"$",
"set",
"=",
"implode",
"(",
"','",
",",
"$",
"from",
")",
";",
"}",
"else"... | fetch one or more items of one or more messages
@param string|array $items items to fetch from message(s) as string (if only one item)
or array of strings
@param int $from message for items or start message if $to !== null
@param int|null $to if null only one message ($from) is fetched, else it's the
last message, INF means last message avaible
@return string|array if only one item of one message is fetched it's returned as string
if items of one message are fetched it's returned as (name => value)
if one items of messages are fetched it's returned as (msgno => value)
if items of messages are fetchted it's returned as (msgno => (name => value))
@throws Zend_Mail_Protocol_Exception | [
"fetch",
"one",
"or",
"more",
"items",
"of",
"one",
"or",
"more",
"messages"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L569-L637 | train | Fetch a list of items from a node | [
30522,
2270,
3853,
18584,
1006,
1002,
5167,
1010,
1002,
2013,
1010,
1002,
2000,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2013,
1007,
1007,
1063,
1002,
2275,
1027,
17727,
4135,
3207,
1006,
1005,
1010,
1005,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/ReportsProvider.php | ReportsProvider.sort | private function sort($a, $b)
{
$result = $this->compareCategories($a->getCategoryId(), $a->getSubcategoryId(), $a->getOrder(), $b->getCategoryId(), $b->getSubcategoryId(), $b->getOrder());
// if categories are equal, sort by ID
if (!$result) {
$aId = $a->getId();
$bId = $b->getId();
if ($aId == $bId) {
return 0;
}
return $aId < $bId ? -1 : 1;
}
return $result;
} | php | private function sort($a, $b)
{
$result = $this->compareCategories($a->getCategoryId(), $a->getSubcategoryId(), $a->getOrder(), $b->getCategoryId(), $b->getSubcategoryId(), $b->getOrder());
// if categories are equal, sort by ID
if (!$result) {
$aId = $a->getId();
$bId = $b->getId();
if ($aId == $bId) {
return 0;
}
return $aId < $bId ? -1 : 1;
}
return $result;
} | [
"private",
"function",
"sort",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"compareCategories",
"(",
"$",
"a",
"->",
"getCategoryId",
"(",
")",
",",
"$",
"a",
"->",
"getSubcategoryId",
"(",
")",
",",
"$",
"a",
"... | API metadata are sorted by category/name,
with a little tweak to replicate the standard Piwik category ordering
@param Report $a
@param Report $b
@return int | [
"API",
"metadata",
"are",
"sorted",
"by",
"category",
"/",
"name",
"with",
"a",
"little",
"tweak",
"to",
"replicate",
"the",
"standard",
"Piwik",
"category",
"ordering"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ReportsProvider.php#L182-L199 | train | Sort categories by category id and order | [
30522,
2797,
3853,
4066,
1006,
1002,
1037,
1010,
1002,
1038,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
12826,
16280,
20255,
3111,
1006,
1002,
1037,
1011,
1028,
2131,
16280,
20255,
10139,
2094,
1006,
1007,
1010,
1002,
1037,
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/cms/classes/PartialStack.php | PartialStack.getComponent | public function getComponent($name)
{
if (!$this->activePartial) {
return null;
}
$component = $this->findComponentFromStack($name, $this->activePartial);
if ($component !== null) {
return $component;
}
foreach ($this->partialStack as $stack) {
$component = $this->findComponentFromStack($name, $stack);
if ($component !== null) {
return $component;
}
}
return null;
} | php | public function getComponent($name)
{
if (!$this->activePartial) {
return null;
}
$component = $this->findComponentFromStack($name, $this->activePartial);
if ($component !== null) {
return $component;
}
foreach ($this->partialStack as $stack) {
$component = $this->findComponentFromStack($name, $stack);
if ($component !== null) {
return $component;
}
}
return null;
} | [
"public",
"function",
"getComponent",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"activePartial",
")",
"{",
"return",
"null",
";",
"}",
"$",
"component",
"=",
"$",
"this",
"->",
"findComponentFromStack",
"(",
"$",
"name",
",",
"$",
... | Returns a component by its alias from the partial stack. | [
"Returns",
"a",
"component",
"by",
"its",
"alias",
"from",
"the",
"partial",
"stack",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/PartialStack.php#L59-L78 | train | Get the component from the partial stack | [
30522,
2270,
3853,
2131,
9006,
29513,
3372,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
3161,
19362,
20925,
1007,
1063,
2709,
19701,
1025,
1065,
1002,
6922,
1027,
1002,
2023,
1011,
1028,
2424,
9006,
29513,
3372,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.