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/Serializer/Normalizer/CustomNormalizer.php | CustomNormalizer.denormalize | public function denormalize($data, $class, $format = null, array $context = [])
{
$object = $this->extractObjectToPopulate($class, $context) ?: new $class();
$object->denormalize($this->serializer, $data, $format, $context);
return $object;
} | php | public function denormalize($data, $class, $format = null, array $context = [])
{
$object = $this->extractObjectToPopulate($class, $context) ?: new $class();
$object->denormalize($this->serializer, $data, $format, $context);
return $object;
} | [
"public",
"function",
"denormalize",
"(",
"$",
"data",
",",
"$",
"class",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"extractObjectToPopulate",
"(",
"$",
"class",
","... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/CustomNormalizer.php#L36-L42 | train | Denormalizes the given data into a new object | [
30522,
2270,
3853,
7939,
2953,
9067,
4697,
1006,
1002,
2951,
1010,
1002,
2465,
1010,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
1002,
4874,
1027,
1002,
2023,
1011,
1028,
14817,
16429,
20614,
14399,
7361,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.without | public function without($relations)
{
$this->eagerLoad = array_diff_key($this->eagerLoad, array_flip(
is_string($relations) ? func_get_args() : $relations
));
return $this;
} | php | public function without($relations)
{
$this->eagerLoad = array_diff_key($this->eagerLoad, array_flip(
is_string($relations) ? func_get_args() : $relations
));
return $this;
} | [
"public",
"function",
"without",
"(",
"$",
"relations",
")",
"{",
"$",
"this",
"->",
"eagerLoad",
"=",
"array_diff_key",
"(",
"$",
"this",
"->",
"eagerLoad",
",",
"array_flip",
"(",
"is_string",
"(",
"$",
"relations",
")",
"?",
"func_get_args",
"(",
")",
... | Prevent the specified relations from being eager loaded.
@param mixed $relations
@return $this | [
"Prevent",
"the",
"specified",
"relations",
"from",
"being",
"eager",
"loaded",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Builder.php#L1096-L1103 | train | Remove items from eagerLoad | [
30522,
2270,
3853,
2302,
1006,
1002,
4262,
1007,
1063,
1002,
2023,
1011,
1028,
9461,
11066,
1027,
9140,
1035,
4487,
4246,
1035,
3145,
1006,
1002,
2023,
1011,
1028,
9461,
11066,
1010,
9140,
1035,
11238,
1006,
2003,
1035,
5164,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/helpers/Backend.php | Backend.redirectIntended | public function redirectIntended($path, $status = 302, $headers = [], $secure = null)
{
return Redirect::intended($this->uri() . '/' . $path, $status, $headers, $secure);
} | php | public function redirectIntended($path, $status = 302, $headers = [], $secure = null)
{
return Redirect::intended($this->uri() . '/' . $path, $status, $headers, $secure);
} | [
"public",
"function",
"redirectIntended",
"(",
"$",
"path",
",",
"$",
"status",
"=",
"302",
",",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"return",
"Redirect",
"::",
"intended",
"(",
"$",
"this",
"->",
"uri",
"(",
"... | Create a new redirect response to the previously intended backend location. | [
"Create",
"a",
"new",
"redirect",
"response",
"to",
"the",
"previously",
"intended",
"backend",
"location",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/helpers/Backend.php#L81-L84 | train | Redirect intended to the current request | [
30522,
2270,
3853,
2417,
7442,
6593,
18447,
21945,
1006,
1002,
4130,
1010,
1002,
3570,
1027,
22060,
1010,
1002,
20346,
2015,
1027,
1031,
1033,
1010,
1002,
5851,
1027,
19701,
1007,
1063,
2709,
2417,
7442,
6593,
1024,
1024,
3832,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/DevicePlugins/Archiver.php | Archiver.aggregateByPlugin | protected function aggregateByPlugin()
{
$selects = array();
$columns = DevicePlugins::getAllPluginColumns();
foreach ($columns as $column) {
$selects[] = sprintf(
"sum(case log_visit.%s when 1 then 1 else 0 end) as %s",
$column->getColumnName(),
substr($column->getColumnName(), 7) // remove leading `config_`
);
}
$query = $this->getLogAggregator()->queryVisitsByDimension(array(), false, $selects, $metrics = array());
$data = $query->fetch();
$cleanRow = LogAggregator::makeArrayOneColumn($data, Metrics::INDEX_NB_VISITS);
$table = DataTable::makeFromIndexedArray($cleanRow);
$this->insertTable(self::PLUGIN_RECORD_NAME, $table);
} | php | protected function aggregateByPlugin()
{
$selects = array();
$columns = DevicePlugins::getAllPluginColumns();
foreach ($columns as $column) {
$selects[] = sprintf(
"sum(case log_visit.%s when 1 then 1 else 0 end) as %s",
$column->getColumnName(),
substr($column->getColumnName(), 7) // remove leading `config_`
);
}
$query = $this->getLogAggregator()->queryVisitsByDimension(array(), false, $selects, $metrics = array());
$data = $query->fetch();
$cleanRow = LogAggregator::makeArrayOneColumn($data, Metrics::INDEX_NB_VISITS);
$table = DataTable::makeFromIndexedArray($cleanRow);
$this->insertTable(self::PLUGIN_RECORD_NAME, $table);
} | [
"protected",
"function",
"aggregateByPlugin",
"(",
")",
"{",
"$",
"selects",
"=",
"array",
"(",
")",
";",
"$",
"columns",
"=",
"DevicePlugins",
"::",
"getAllPluginColumns",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"$"... | Archives reports for all available plugin columns
@see DevicePluginColumn | [
"Archives",
"reports",
"for",
"all",
"available",
"plugin",
"columns"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DevicePlugins/Archiver.php#L60-L78 | train | Aggregate by plugin | [
30522,
5123,
3853,
9572,
3762,
24759,
15916,
2378,
1006,
1007,
1063,
1002,
27034,
1027,
9140,
1006,
1007,
1025,
1002,
7753,
1027,
5080,
24759,
15916,
7076,
1024,
1024,
2131,
8095,
24759,
15916,
2378,
25778,
2819,
3619,
1006,
1007,
1025,
189... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Collection.php | Collection.contains | public function contains($key, $operator = null, $value = null)
{
if (func_num_args() > 1 || $this->useAsCallable($key)) {
return parent::contains(...func_get_args());
}
if ($key instanceof Model) {
return parent::contains(function ($model) use ($key) {
return $model->is($key);
});
}
return parent::contains(function ($model) use ($key) {
return $model->getKey() == $key;
});
} | php | public function contains($key, $operator = null, $value = null)
{
if (func_num_args() > 1 || $this->useAsCallable($key)) {
return parent::contains(...func_get_args());
}
if ($key instanceof Model) {
return parent::contains(function ($model) use ($key) {
return $model->is($key);
});
}
return parent::contains(function ($model) use ($key) {
return $model->getKey() == $key;
});
} | [
"public",
"function",
"contains",
"(",
"$",
"key",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
">",
"1",
"||",
"$",
"this",
"->",
"useAsCallable",
"(",
"$",
"key",
")",
")",
"... | Determine if a key exists in the collection.
@param mixed $key
@param mixed $operator
@param mixed $value
@return bool | [
"Determine",
"if",
"a",
"key",
"exists",
"in",
"the",
"collection",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Collection.php#L200-L215 | train | Return true if the collection contains the given key | [
30522,
2270,
3853,
3397,
1006,
1002,
3145,
1010,
1002,
6872,
30524,
1035,
16371,
2213,
1035,
12098,
5620,
1006,
1007,
1028,
1015,
1064,
1064,
1002,
2023,
1011,
1028,
2224,
3022,
9289,
20470,
2571,
1006,
1002,
3145,
1007,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.onCreateFolder | public function onCreateFolder()
{
$this->abortIfReadOnly();
$name = trim(Input::get('name'));
if (!strlen($name)) {
throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));
}
if (!$this->validateFileName($name)) {
throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
}
$path = Input::get('path');
$path = MediaLibrary::validatePath($path);
$newFolderPath = $path.'/'.$name;
$library = MediaLibrary::instance();
if ($library->folderExists($newFolderPath)) {
throw new ApplicationException(Lang::get('backend::lang.media.folder_or_file_exist'));
}
/*
* Create the new folder
*/
if (!$library->makeFolder($newFolderPath)) {
throw new ApplicationException(Lang::get('backend::lang.media.error_creating_folder'));
}
/**
* @event media.folder.create
* Called after a folder is created
*
* Example usage:
*
* Event::listen('media.folder.create', function((\Backend\Widgets\MediaManager) $mediaWidget, (string) $newFolderPath) {
* \Log::info($newFolderPath . " was created");
* });
*
* Or
*
* $mediaWidget->bindEvent('folder.create', function ((string) $newFolderPath) {
* \Log::info($newFolderPath . " was created");
* });
*
*/
$this->fireSystemEvent('media.folder.create', [$newFolderPath]);
$library->resetCache();
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list')
];
} | php | public function onCreateFolder()
{
$this->abortIfReadOnly();
$name = trim(Input::get('name'));
if (!strlen($name)) {
throw new ApplicationException(Lang::get('cms::lang.asset.name_cant_be_empty'));
}
if (!$this->validateFileName($name)) {
throw new ApplicationException(Lang::get('cms::lang.asset.invalid_name'));
}
$path = Input::get('path');
$path = MediaLibrary::validatePath($path);
$newFolderPath = $path.'/'.$name;
$library = MediaLibrary::instance();
if ($library->folderExists($newFolderPath)) {
throw new ApplicationException(Lang::get('backend::lang.media.folder_or_file_exist'));
}
/*
* Create the new folder
*/
if (!$library->makeFolder($newFolderPath)) {
throw new ApplicationException(Lang::get('backend::lang.media.error_creating_folder'));
}
/**
* @event media.folder.create
* Called after a folder is created
*
* Example usage:
*
* Event::listen('media.folder.create', function((\Backend\Widgets\MediaManager) $mediaWidget, (string) $newFolderPath) {
* \Log::info($newFolderPath . " was created");
* });
*
* Or
*
* $mediaWidget->bindEvent('folder.create', function ((string) $newFolderPath) {
* \Log::info($newFolderPath . " was created");
* });
*
*/
$this->fireSystemEvent('media.folder.create', [$newFolderPath]);
$library->resetCache();
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list')
];
} | [
"public",
"function",
"onCreateFolder",
"(",
")",
"{",
"$",
"this",
"->",
"abortIfReadOnly",
"(",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"Input",
"::",
"get",
"(",
"'name'",
")",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"name",
")",
")",
"... | Create library folder AJAX handler
@return array | [
"Create",
"library",
"folder",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L482-L539 | train | Create a new folder | [
30522,
2270,
3853,
2006,
16748,
3686,
10371,
2121,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
11113,
11589,
10128,
16416,
5280,
2135,
1006,
1007,
1025,
1002,
2171,
1027,
12241,
1006,
7953,
1024,
1024,
2131,
1006,
1005,
2171,
1005,
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... |
matomo-org/matomo | libs/Zend/Cache/Frontend/Function.php | Zend_Cache_Frontend_Function.call | public function call($callback, array $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8)
{
if (!is_callable($callback, true, $name)) {
Zend_Cache::throwException('Invalid callback');
}
$cacheBool1 = $this->_specificOptions['cache_by_default'];
$cacheBool2 = in_array($name, $this->_specificOptions['cached_functions']);
$cacheBool3 = in_array($name, $this->_specificOptions['non_cached_functions']);
$cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
if (!$cache) {
// Caching of this callback is disabled
return call_user_func_array($callback, $parameters);
}
$id = $this->_makeId($callback, $parameters);
if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1])) {
// A cache is available
$output = $rs[0];
$return = $rs[1];
} else {
// A cache is not available (or not valid for this frontend)
ob_start();
ob_implicit_flush(false);
$return = call_user_func_array($callback, $parameters);
$output = ob_get_clean();
$data = array($output, $return);
$this->save($data, $id, $tags, $specificLifetime, $priority);
}
echo $output;
return $return;
} | php | public function call($callback, array $parameters = array(), $tags = array(), $specificLifetime = false, $priority = 8)
{
if (!is_callable($callback, true, $name)) {
Zend_Cache::throwException('Invalid callback');
}
$cacheBool1 = $this->_specificOptions['cache_by_default'];
$cacheBool2 = in_array($name, $this->_specificOptions['cached_functions']);
$cacheBool3 = in_array($name, $this->_specificOptions['non_cached_functions']);
$cache = (($cacheBool1 || $cacheBool2) && (!$cacheBool3));
if (!$cache) {
// Caching of this callback is disabled
return call_user_func_array($callback, $parameters);
}
$id = $this->_makeId($callback, $parameters);
if ( ($rs = $this->load($id)) && isset($rs[0], $rs[1])) {
// A cache is available
$output = $rs[0];
$return = $rs[1];
} else {
// A cache is not available (or not valid for this frontend)
ob_start();
ob_implicit_flush(false);
$return = call_user_func_array($callback, $parameters);
$output = ob_get_clean();
$data = array($output, $return);
$this->save($data, $id, $tags, $specificLifetime, $priority);
}
echo $output;
return $return;
} | [
"public",
"function",
"call",
"(",
"$",
"callback",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
",",
"$",
"tags",
"=",
"array",
"(",
")",
",",
"$",
"specificLifetime",
"=",
"false",
",",
"$",
"priority",
"=",
"8",
")",
"{",
"if",
"(",
... | Main method : call the specified function or get the result from cache
@param callback $callback A valid callback
@param array $parameters Function parameters
@param array $tags Cache tags
@param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
@param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by some particular backends
@return mixed Result | [
"Main",
"method",
":",
"call",
"the",
"specified",
"function",
"or",
"get",
"the",
"result",
"from",
"cache"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Function.php#L82-L114 | train | Call a callback | [
30522,
2270,
3853,
2655,
1006,
1002,
2655,
5963,
1010,
9140,
1002,
11709,
1027,
9140,
1006,
1007,
1010,
1002,
22073,
1027,
9140,
1006,
1007,
1010,
1002,
3563,
15509,
7292,
1027,
6270,
1010,
1002,
9470,
1027,
1022,
1007,
1063,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php | BroadcastNotificationCreated.broadcastType | public function broadcastType()
{
return method_exists($this->notification, 'broadcastType')
? $this->notification->broadcastType()
: get_class($this->notification);
} | php | public function broadcastType()
{
return method_exists($this->notification, 'broadcastType')
? $this->notification->broadcastType()
: get_class($this->notification);
} | [
"public",
"function",
"broadcastType",
"(",
")",
"{",
"return",
"method_exists",
"(",
"$",
"this",
"->",
"notification",
",",
"'broadcastType'",
")",
"?",
"$",
"this",
"->",
"notification",
"->",
"broadcastType",
"(",
")",
":",
"get_class",
"(",
"$",
"this",... | Get the type of the notification being broadcast.
@return string | [
"Get",
"the",
"type",
"of",
"the",
"notification",
"being",
"broadcast",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php#L100-L105 | train | Returns the type of the notification | [
30522,
2270,
3853,
3743,
13874,
1006,
1007,
1063,
2709,
4118,
1035,
6526,
1006,
1002,
2023,
1011,
1028,
26828,
1010,
1005,
3743,
13874,
1005,
1007,
1029,
1002,
2023,
1011,
1028,
26828,
1011,
1028,
3743,
13874,
1006,
1007,
1024,
2131,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/API/ProcessedReport.php | ProcessedReport.getPrettyValue | public static function getPrettyValue(Formatter $formatter, $idSite, $columnName, $value)
{
if (!is_numeric($value)) {
return $value;
}
// Display time in human readable
if (strpos($columnName, 'time_generation') !== false) {
return $formatter->getPrettyTimeFromSeconds($value, true);
}
if (strpos($columnName, 'time') !== false) {
return $formatter->getPrettyTimeFromSeconds($value);
}
// Add revenue symbol to revenues
$isMoneyMetric = strpos($columnName, 'revenue') !== false || strpos($columnName, 'price') !== false;
if ($isMoneyMetric && strpos($columnName, 'evolution') === false) {
return $formatter->getPrettyMoney($value, $idSite);
}
// Add % symbol to rates
if (strpos($columnName, '_rate') !== false) {
if (strpos($value, "%") === false) {
return (100 * $value) . "%";
}
}
return $value;
} | php | public static function getPrettyValue(Formatter $formatter, $idSite, $columnName, $value)
{
if (!is_numeric($value)) {
return $value;
}
// Display time in human readable
if (strpos($columnName, 'time_generation') !== false) {
return $formatter->getPrettyTimeFromSeconds($value, true);
}
if (strpos($columnName, 'time') !== false) {
return $formatter->getPrettyTimeFromSeconds($value);
}
// Add revenue symbol to revenues
$isMoneyMetric = strpos($columnName, 'revenue') !== false || strpos($columnName, 'price') !== false;
if ($isMoneyMetric && strpos($columnName, 'evolution') === false) {
return $formatter->getPrettyMoney($value, $idSite);
}
// Add % symbol to rates
if (strpos($columnName, '_rate') !== false) {
if (strpos($value, "%") === false) {
return (100 * $value) . "%";
}
}
return $value;
} | [
"public",
"static",
"function",
"getPrettyValue",
"(",
"Formatter",
"$",
"formatter",
",",
"$",
"idSite",
",",
"$",
"columnName",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
... | Prettifies a metric value based on the column name.
@param int $idSite The ID of the site the metric is for (used if the column value is an amount of money).
@param string $columnName The metric name.
@param mixed $value The metric value.
@param bool $isHtml If true, replaces all spaces with `' '`.
@return string | [
"Prettifies",
"a",
"metric",
"value",
"based",
"on",
"the",
"column",
"name",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/ProcessedReport.php#L827-L855 | train | Returns the value of a column in a human readable format | [
30522,
2270,
10763,
3853,
2131,
28139,
15353,
10175,
5657,
1006,
4289,
3334,
1002,
4289,
3334,
1010,
1002,
8909,
28032,
2063,
1010,
1002,
5930,
18442,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16371,
25531,
1006,
1002,
3643... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CombinedStore.php | CombinedStore.exists | public function exists(Key $key)
{
$successCount = 0;
$failureCount = 0;
$storesCount = \count($this->stores);
foreach ($this->stores as $store) {
if ($store->exists($key)) {
++$successCount;
} else {
++$failureCount;
}
if ($this->strategy->isMet($successCount, $storesCount)) {
return true;
}
if (!$this->strategy->canBeMet($failureCount, $storesCount)) {
return false;
}
}
return false;
} | php | public function exists(Key $key)
{
$successCount = 0;
$failureCount = 0;
$storesCount = \count($this->stores);
foreach ($this->stores as $store) {
if ($store->exists($key)) {
++$successCount;
} else {
++$failureCount;
}
if ($this->strategy->isMet($successCount, $storesCount)) {
return true;
}
if (!$this->strategy->canBeMet($failureCount, $storesCount)) {
return false;
}
}
return false;
} | [
"public",
"function",
"exists",
"(",
"Key",
"$",
"key",
")",
"{",
"$",
"successCount",
"=",
"0",
";",
"$",
"failureCount",
"=",
"0",
";",
"$",
"storesCount",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"stores",
")",
";",
"foreach",
"(",
"$",
"this... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Store/CombinedStore.php#L161-L183 | train | Checks if a key exists in all stores | [
30522,
2270,
3853,
6526,
1006,
3145,
1002,
3145,
1007,
1063,
1002,
3112,
3597,
16671,
1027,
1014,
1025,
1002,
4945,
3597,
16671,
1027,
1014,
1025,
1002,
5324,
3597,
16671,
1027,
1032,
4175,
1006,
1002,
2023,
1011,
1028,
5324,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/Controller.php | Controller.downloadFreeGeoIP2DB | public function downloadFreeGeoIP2DB()
{
$this->dieIfGeolocationAdminIsDisabled();
Piwik::checkUserHasSuperUserAccess();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
Json::sendHeaderJSON();
$outputPath = GeoIp2::getPathForGeoIpDatabase('GeoLite2-City.tar') . '.gz';
try {
$result = Http::downloadChunk(
$url = GeoIp2::GEO_LITE_URL,
$outputPath,
$continue = Common::getRequestVar('continue', true, 'int')
);
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
try {
GeoIP2AutoUpdater::unzipDownloadedFile($outputPath, 'loc', $unlink = true);
} catch (\Exception $e) {
// remove downloaded file on error
unlink($outputPath);
throw $e;
}
// setup the auto updater
GeoIP2AutoUpdater::setUpdaterOptions(array(
'loc' => GeoIp2::GEO_LITE_URL,
'period' => GeoIP2AutoUpdater::SCHEDULE_PERIOD_MONTHLY,
));
$result['settings'] = GeoIP2AutoUpdater::getConfiguredUrls();
}
return json_encode($result);
} catch (Exception $ex) {
return json_encode(array('error' => $ex->getMessage()));
}
}
} | php | public function downloadFreeGeoIP2DB()
{
$this->dieIfGeolocationAdminIsDisabled();
Piwik::checkUserHasSuperUserAccess();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
Json::sendHeaderJSON();
$outputPath = GeoIp2::getPathForGeoIpDatabase('GeoLite2-City.tar') . '.gz';
try {
$result = Http::downloadChunk(
$url = GeoIp2::GEO_LITE_URL,
$outputPath,
$continue = Common::getRequestVar('continue', true, 'int')
);
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
try {
GeoIP2AutoUpdater::unzipDownloadedFile($outputPath, 'loc', $unlink = true);
} catch (\Exception $e) {
// remove downloaded file on error
unlink($outputPath);
throw $e;
}
// setup the auto updater
GeoIP2AutoUpdater::setUpdaterOptions(array(
'loc' => GeoIp2::GEO_LITE_URL,
'period' => GeoIP2AutoUpdater::SCHEDULE_PERIOD_MONTHLY,
));
$result['settings'] = GeoIP2AutoUpdater::getConfiguredUrls();
}
return json_encode($result);
} catch (Exception $ex) {
return json_encode(array('error' => $ex->getMessage()));
}
}
} | [
"public",
"function",
"downloadFreeGeoIP2DB",
"(",
")",
"{",
"$",
"this",
"->",
"dieIfGeolocationAdminIsDisabled",
"(",
")",
";",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"POS... | Starts or continues download of GeoLite2-City.mmdb.
To avoid a server/PHP timeout & to show progress of the download to the user, we
use the HTTP Range header to download one chunk of the file at a time. After each
chunk, it is the browser's responsibility to call the method again to continue the download.
Input:
'continue' query param - if set to 1, will assume we are currently downloading & use
Range: HTTP header to get another chunk of the file.
Output (in JSON):
'current_size' - Current size of the partially downloaded file on disk.
'expected_file_size' - The expected finished file size as returned by the HTTP server.
'next_screen' - When the download finishes, this is the next screen that should be shown.
'error' - When an error occurs, the message is returned in this property. | [
"Starts",
"or",
"continues",
"download",
"of",
"GeoLite2",
"-",
"City",
".",
"mmdb",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/Controller.php#L167-L206 | train | Download Free GeoLite2DB | [
30522,
2270,
3853,
8816,
23301,
3351,
10448,
2361,
2475,
18939,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
3280,
10128,
3351,
12898,
10719,
4215,
25300,
16150,
14268,
23242,
1006,
1007,
1025,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | Protocols/Http.php | Http.parseUploadFiles | protected static function parseUploadFiles($http_body, $http_post_boundary)
{
$http_body = substr($http_body, 0, strlen($http_body) - (strlen($http_post_boundary) + 4));
$boundary_data_array = explode($http_post_boundary . "\r\n", $http_body);
if ($boundary_data_array[0] === '') {
unset($boundary_data_array[0]);
}
$key = -1;
foreach ($boundary_data_array as $boundary_data_buffer) {
list($boundary_header_buffer, $boundary_value) = explode("\r\n\r\n", $boundary_data_buffer, 2);
// Remove \r\n from the end of buffer.
$boundary_value = substr($boundary_value, 0, -2);
$key ++;
foreach (explode("\r\n", $boundary_header_buffer) as $item) {
list($header_key, $header_value) = explode(": ", $item);
$header_key = strtolower($header_key);
switch ($header_key) {
case "content-disposition":
// Is file data.
if (preg_match('/name="(.*?)"; filename="(.*?)"$/', $header_value, $match)) {
// Parse $_FILES.
$_FILES[$key] = array(
'name' => $match[1],
'file_name' => $match[2],
'file_data' => $boundary_value,
'file_size' => strlen($boundary_value),
);
break;
} // Is post field.
else {
// Parse $_POST.
if (preg_match('/name="(.*?)"$/', $header_value, $match)) {
$_POST[$match[1]] = $boundary_value;
}
}
break;
case "content-type":
// add file_type
$_FILES[$key]['file_type'] = trim($header_value);
break;
}
}
}
} | php | protected static function parseUploadFiles($http_body, $http_post_boundary)
{
$http_body = substr($http_body, 0, strlen($http_body) - (strlen($http_post_boundary) + 4));
$boundary_data_array = explode($http_post_boundary . "\r\n", $http_body);
if ($boundary_data_array[0] === '') {
unset($boundary_data_array[0]);
}
$key = -1;
foreach ($boundary_data_array as $boundary_data_buffer) {
list($boundary_header_buffer, $boundary_value) = explode("\r\n\r\n", $boundary_data_buffer, 2);
// Remove \r\n from the end of buffer.
$boundary_value = substr($boundary_value, 0, -2);
$key ++;
foreach (explode("\r\n", $boundary_header_buffer) as $item) {
list($header_key, $header_value) = explode(": ", $item);
$header_key = strtolower($header_key);
switch ($header_key) {
case "content-disposition":
// Is file data.
if (preg_match('/name="(.*?)"; filename="(.*?)"$/', $header_value, $match)) {
// Parse $_FILES.
$_FILES[$key] = array(
'name' => $match[1],
'file_name' => $match[2],
'file_data' => $boundary_value,
'file_size' => strlen($boundary_value),
);
break;
} // Is post field.
else {
// Parse $_POST.
if (preg_match('/name="(.*?)"$/', $header_value, $match)) {
$_POST[$match[1]] = $boundary_value;
}
}
break;
case "content-type":
// add file_type
$_FILES[$key]['file_type'] = trim($header_value);
break;
}
}
}
} | [
"protected",
"static",
"function",
"parseUploadFiles",
"(",
"$",
"http_body",
",",
"$",
"http_post_boundary",
")",
"{",
"$",
"http_body",
"=",
"substr",
"(",
"$",
"http_body",
",",
"0",
",",
"strlen",
"(",
"$",
"http_body",
")",
"-",
"(",
"strlen",
"(",
... | Parse $_FILES.
@param string $http_body
@param string $http_post_boundary
@return void | [
"Parse",
"$_FILES",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Http.php#L541-L584 | train | Parse upload files | [
30522,
5123,
10763,
3853,
11968,
3366,
6279,
11066,
8873,
4244,
1006,
1002,
8299,
1035,
2303,
1010,
1002,
8299,
1035,
2695,
1035,
6192,
1007,
1063,
1002,
8299,
1035,
2303,
1027,
4942,
3367,
2099,
1006,
1002,
8299,
1035,
2303,
1010,
1014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Authentication/Token/Storage/TokenStorage.php | TokenStorage.setToken | public function setToken(TokenInterface $token = null)
{
if (null !== $token && !method_exists($token, 'getRoleNames')) {
@trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED);
}
$this->token = $token;
} | php | public function setToken(TokenInterface $token = null)
{
if (null !== $token && !method_exists($token, 'getRoleNames')) {
@trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED);
}
$this->token = $token;
} | [
"public",
"function",
"setToken",
"(",
"TokenInterface",
"$",
"token",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"token",
"&&",
"!",
"method_exists",
"(",
"$",
"token",
",",
"'getRoleNames'",
")",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Authentication/Token/Storage/TokenStorage.php#L40-L47 | train | Sets the token | [
30522,
2270,
3853,
2275,
18715,
2368,
1006,
19204,
18447,
2121,
12172,
1002,
19204,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
19204,
1004,
1004,
999,
4118,
1035,
6526,
1006,
1002,
19204,
1010,
1005,
2131,
13153,
818... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php | ExprBuilder.thenInvalid | public function thenInvalid($message)
{
$this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
return $this;
} | php | public function thenInvalid($message)
{
$this->thenPart = function ($v) use ($message) { throw new \InvalidArgumentException(sprintf($message, json_encode($v))); };
return $this;
} | [
"public",
"function",
"thenInvalid",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"thenPart",
"=",
"function",
"(",
"$",
"v",
")",
"use",
"(",
"$",
"message",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"$",
"m... | Sets a closure marking the value as invalid at processing time.
if you want to add the value of the node in your message just use a %s placeholder.
@param string $message
@return $this
@throws \InvalidArgumentException | [
"Sets",
"a",
"closure",
"marking",
"the",
"value",
"as",
"invalid",
"at",
"processing",
"time",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php#L187-L192 | train | Set the exception handler to be thrown if the value is not an instance of \ InvalidArgumentException | [
30522,
2270,
3853,
2059,
2378,
10175,
3593,
1006,
1002,
4471,
1007,
1063,
1002,
2023,
1011,
1028,
2059,
19362,
2102,
1027,
3853,
1006,
1002,
1058,
1007,
2224,
1006,
1002,
4471,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.getDateTime | protected function getDateTime($value)
{
try {
if ($this->isTestingRelativeDateTime($value)) {
return Date::parse($value);
}
return new DateTime($value);
} catch (Exception $e) {
//
}
} | php | protected function getDateTime($value)
{
try {
if ($this->isTestingRelativeDateTime($value)) {
return Date::parse($value);
}
return new DateTime($value);
} catch (Exception $e) {
//
}
} | [
"protected",
"function",
"getDateTime",
"(",
"$",
"value",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"isTestingRelativeDateTime",
"(",
"$",
"value",
")",
")",
"{",
"return",
"Date",
"::",
"parse",
"(",
"$",
"value",
")",
";",
"}",
"return",
... | Get a DateTime instance from a string with no format.
@param string $value
@return \DateTime|null | [
"Get",
"a",
"DateTime",
"instance",
"from",
"a",
"string",
"with",
"no",
"format",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L242-L253 | train | Get DateTime from value | [
30522,
5123,
3853,
2131,
13701,
7292,
1006,
1002,
3643,
1007,
1063,
3046,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
21541,
4355,
2075,
16570,
8082,
13701,
7292,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
3058,
1024,
1024,
11968,
3366,
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/Statement/Db2.php | Zend_Db_Statement_Db2.fetch | public function fetch($style = null, $cursor = null, $offset = null)
{
if (!$this->_stmt) {
return false;
}
if ($style === null) {
$style = $this->_fetchMode;
}
switch ($style) {
case Zend_Db::FETCH_NUM :
$row = db2_fetch_array($this->_stmt);
break;
case Zend_Db::FETCH_ASSOC :
$row = db2_fetch_assoc($this->_stmt);
break;
case Zend_Db::FETCH_BOTH :
$row = db2_fetch_both($this->_stmt);
break;
case Zend_Db::FETCH_OBJ :
$row = db2_fetch_object($this->_stmt);
break;
case Zend_Db::FETCH_BOUND:
$row = db2_fetch_both($this->_stmt);
if ($row !== false) {
return $this->_fetchBound($row);
}
break;
default:
/**
* @see Zend_Db_Statement_Db2_Exception
*/
// require_once 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception("Invalid fetch mode '$style' specified");
break;
}
return $row;
} | php | public function fetch($style = null, $cursor = null, $offset = null)
{
if (!$this->_stmt) {
return false;
}
if ($style === null) {
$style = $this->_fetchMode;
}
switch ($style) {
case Zend_Db::FETCH_NUM :
$row = db2_fetch_array($this->_stmt);
break;
case Zend_Db::FETCH_ASSOC :
$row = db2_fetch_assoc($this->_stmt);
break;
case Zend_Db::FETCH_BOTH :
$row = db2_fetch_both($this->_stmt);
break;
case Zend_Db::FETCH_OBJ :
$row = db2_fetch_object($this->_stmt);
break;
case Zend_Db::FETCH_BOUND:
$row = db2_fetch_both($this->_stmt);
if ($row !== false) {
return $this->_fetchBound($row);
}
break;
default:
/**
* @see Zend_Db_Statement_Db2_Exception
*/
// require_once 'Zend/Db/Statement/Db2/Exception.php';
throw new Zend_Db_Statement_Db2_Exception("Invalid fetch mode '$style' specified");
break;
}
return $row;
} | [
"public",
"function",
"fetch",
"(",
"$",
"style",
"=",
"null",
",",
"$",
"cursor",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_stmt",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"style... | Fetches a row from the result set.
@param int $style OPTIONAL Fetch mode for this fetch operation.
@param int $cursor OPTIONAL Absolute, relative, or other.
@param int $offset OPTIONAL Number for absolute or relative cursors.
@return mixed Array, object, or scalar depending on fetch mode.
@throws Zend_Db_Statement_Db2_Exception | [
"Fetches",
"a",
"row",
"from",
"the",
"result",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Db2.php#L242-L281 | train | Fetch a row from the result set | [
30522,
2270,
3853,
18584,
1006,
1002,
2806,
1027,
19701,
1010,
1002,
12731,
25301,
2099,
1027,
19701,
1010,
1002,
16396,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1007,
1063,
2709,
6270,
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... |
matomo-org/matomo | libs/Zend/Mime/Part.php | Zend_Mime_Part.getContent | public function getContent($EOL = Zend_Mime::LINEEND)
{
if ($this->_isStream) {
return stream_get_contents($this->getEncodedStream());
} else {
return Zend_Mime::encode($this->_content, $this->encoding, $EOL);
}
} | php | public function getContent($EOL = Zend_Mime::LINEEND)
{
if ($this->_isStream) {
return stream_get_contents($this->getEncodedStream());
} else {
return Zend_Mime::encode($this->_content, $this->encoding, $EOL);
}
} | [
"public",
"function",
"getContent",
"(",
"$",
"EOL",
"=",
"Zend_Mime",
"::",
"LINEEND",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_isStream",
")",
"{",
"return",
"stream_get_contents",
"(",
"$",
"this",
"->",
"getEncodedStream",
"(",
")",
")",
";",
"}",
... | Get the Content of the current Mime Part in the given encoding.
@return String | [
"Get",
"the",
"Content",
"of",
"the",
"current",
"Mime",
"Part",
"in",
"the",
"given",
"encoding",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Part.php#L141-L148 | train | Get content of the part | [
30522,
2270,
3853,
2131,
8663,
6528,
2102,
1006,
1002,
1041,
4747,
1027,
16729,
2094,
1035,
2771,
4168,
1024,
1024,
2240,
10497,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
26354,
25379,
1007,
1063,
2709,
5460,
1035,
2131,
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... |
barryvdh/laravel-debugbar | src/DataCollector/RequestCollector.php | RequestCollector.collect | public function collect()
{
$request = $this->request;
$response = $this->response;
$responseHeaders = $response->headers->all();
$cookies = [];
foreach ($response->headers->getCookies() as $cookie) {
$cookies[] = $this->getCookieHeader(
$cookie->getName(),
$cookie->getValue(),
$cookie->getExpiresTime(),
$cookie->getPath(),
$cookie->getDomain(),
$cookie->isSecure(),
$cookie->isHttpOnly()
);
}
if (count($cookies) > 0) {
$responseHeaders['Set-Cookie'] = $cookies;
}
$statusCode = $response->getStatusCode();
$data = [
'path_info' => $request->getPathInfo(),
'status_code' => $statusCode,
'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '',
'format' => $request->getRequestFormat(),
'content_type' => $response->headers->get('Content-Type') ? $response->headers->get(
'Content-Type'
) : 'text/html',
'request_query' => $request->query->all(),
'request_request' => $request->request->all(),
'request_headers' => $request->headers->all(),
'request_server' => $request->server->all(),
'request_cookies' => $request->cookies->all(),
'response_headers' => $responseHeaders,
];
if ($this->session) {
$sessionAttributes = [];
foreach ($this->session->all() as $key => $value) {
$sessionAttributes[$key] = $value;
}
$data['session_attributes'] = $sessionAttributes;
}
foreach ($data['request_server'] as $key => $value) {
if (str_is('*_KEY', $key) || str_is('*_PASSWORD', $key)
|| str_is('*_SECRET', $key) || str_is('*_PW', $key)) {
$data['request_server'][$key] = '******';
}
}
if (isset($data['request_headers']['php-auth-pw'])) {
$data['request_headers']['php-auth-pw'] = '******';
}
if (isset($data['request_server']['PHP_AUTH_PW'])) {
$data['request_server']['PHP_AUTH_PW'] = '******';
}
;
foreach ($data as $key => $var) {
if (!is_string($data[$key])) {
$data[$key] = DataCollector::getDefaultVarDumper()->renderVar($var);
} else {
$data[$key] = e($data[$key]);
}
}
$htmlData = [];
if (class_exists(Telescope::class)) {
$entry = IncomingEntry::make([
'requestId' => $this->currentRequestId,
])->type('debugbar');
Telescope::$entriesQueue[] = $entry;
$url = route('debugbar.telescope', [$entry->uuid]);
$htmlData['telescope'] = '<a href="'.$url.'" target="_blank">View in Telescope</a>';
}
return $htmlData + $data;
} | php | public function collect()
{
$request = $this->request;
$response = $this->response;
$responseHeaders = $response->headers->all();
$cookies = [];
foreach ($response->headers->getCookies() as $cookie) {
$cookies[] = $this->getCookieHeader(
$cookie->getName(),
$cookie->getValue(),
$cookie->getExpiresTime(),
$cookie->getPath(),
$cookie->getDomain(),
$cookie->isSecure(),
$cookie->isHttpOnly()
);
}
if (count($cookies) > 0) {
$responseHeaders['Set-Cookie'] = $cookies;
}
$statusCode = $response->getStatusCode();
$data = [
'path_info' => $request->getPathInfo(),
'status_code' => $statusCode,
'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '',
'format' => $request->getRequestFormat(),
'content_type' => $response->headers->get('Content-Type') ? $response->headers->get(
'Content-Type'
) : 'text/html',
'request_query' => $request->query->all(),
'request_request' => $request->request->all(),
'request_headers' => $request->headers->all(),
'request_server' => $request->server->all(),
'request_cookies' => $request->cookies->all(),
'response_headers' => $responseHeaders,
];
if ($this->session) {
$sessionAttributes = [];
foreach ($this->session->all() as $key => $value) {
$sessionAttributes[$key] = $value;
}
$data['session_attributes'] = $sessionAttributes;
}
foreach ($data['request_server'] as $key => $value) {
if (str_is('*_KEY', $key) || str_is('*_PASSWORD', $key)
|| str_is('*_SECRET', $key) || str_is('*_PW', $key)) {
$data['request_server'][$key] = '******';
}
}
if (isset($data['request_headers']['php-auth-pw'])) {
$data['request_headers']['php-auth-pw'] = '******';
}
if (isset($data['request_server']['PHP_AUTH_PW'])) {
$data['request_server']['PHP_AUTH_PW'] = '******';
}
;
foreach ($data as $key => $var) {
if (!is_string($data[$key])) {
$data[$key] = DataCollector::getDefaultVarDumper()->renderVar($var);
} else {
$data[$key] = e($data[$key]);
}
}
$htmlData = [];
if (class_exists(Telescope::class)) {
$entry = IncomingEntry::make([
'requestId' => $this->currentRequestId,
])->type('debugbar');
Telescope::$entriesQueue[] = $entry;
$url = route('debugbar.telescope', [$entry->uuid]);
$htmlData['telescope'] = '<a href="'.$url.'" target="_blank">View in Telescope</a>';
}
return $htmlData + $data;
} | [
"public",
"function",
"collect",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"response",
";",
"$",
"responseHeaders",
"=",
"$",
"response",
"->",
"headers",
"->",
"all",
"(",
")",
";... | {@inheritdoc} | [
"{"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/RequestCollector.php#L69-L153 | train | Collect all the information from the response | [
30522,
2270,
3853,
8145,
1006,
1007,
1063,
1002,
5227,
1027,
1002,
2023,
1011,
1028,
5227,
1025,
1002,
3433,
1027,
1002,
2023,
1011,
1028,
3433,
1025,
1002,
3433,
4974,
2545,
1027,
1002,
3433,
1011,
1028,
20346,
2015,
1011,
1028,
2035,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/EventListCommand.php | EventListCommand.filterEvents | protected function filterEvents(array $events)
{
if (! $eventName = $this->option('event')) {
return $events;
}
return collect($events)->filter(function ($listeners, $event) use ($eventName) {
return Str::contains($event, $eventName);
})->toArray();
} | php | protected function filterEvents(array $events)
{
if (! $eventName = $this->option('event')) {
return $events;
}
return collect($events)->filter(function ($listeners, $event) use ($eventName) {
return Str::contains($event, $eventName);
})->toArray();
} | [
"protected",
"function",
"filterEvents",
"(",
"array",
"$",
"events",
")",
"{",
"if",
"(",
"!",
"$",
"eventName",
"=",
"$",
"this",
"->",
"option",
"(",
"'event'",
")",
")",
"{",
"return",
"$",
"events",
";",
"}",
"return",
"collect",
"(",
"$",
"even... | Filter the given events using the provided event name filter.
@param array $events
@return array | [
"Filter",
"the",
"given",
"events",
"using",
"the",
"provided",
"event",
"name",
"filter",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/EventListCommand.php#L71-L80 | train | Filter events by event name | [
30522,
5123,
3853,
11307,
18697,
7666,
1006,
9140,
1002,
2824,
1007,
1063,
2065,
1006,
999,
1002,
2724,
18442,
1027,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
2724,
1005,
1007,
1007,
1063,
2709,
1002,
2824,
1025,
1065,
2709,
8145,
1006,
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/Intl/NumberFormatter/NumberFormatter.php | NumberFormatter.convertValueDataType | private function convertValueDataType($value, $type)
{
if (self::TYPE_DOUBLE == $type) {
$value = (float) $value;
} elseif (self::TYPE_INT32 == $type) {
$value = $this->getInt32Value($value);
} elseif (self::TYPE_INT64 == $type) {
$value = $this->getInt64Value($value);
}
return $value;
} | php | private function convertValueDataType($value, $type)
{
if (self::TYPE_DOUBLE == $type) {
$value = (float) $value;
} elseif (self::TYPE_INT32 == $type) {
$value = $this->getInt32Value($value);
} elseif (self::TYPE_INT64 == $type) {
$value = $this->getInt64Value($value);
}
return $value;
} | [
"private",
"function",
"convertValueDataType",
"(",
"$",
"value",
",",
"$",
"type",
")",
"{",
"if",
"(",
"self",
"::",
"TYPE_DOUBLE",
"==",
"$",
"type",
")",
"{",
"$",
"value",
"=",
"(",
"float",
")",
"$",
"value",
";",
"}",
"elseif",
"(",
"self",
... | Returns the numeric value using the $type to convert to the right data type.
@param mixed $value The value to be converted
@param int $type The type to convert. Can be TYPE_DOUBLE (float) or TYPE_INT32 (int)
@return int|float|false The converted value | [
"Returns",
"the",
"numeric",
"value",
"using",
"the",
"$type",
"to",
"convert",
"to",
"the",
"right",
"data",
"type",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php#L800-L811 | train | Convert value data type | [
30522,
2797,
3853,
10463,
10175,
5657,
2850,
29336,
18863,
1006,
1002,
3643,
1010,
1002,
2828,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
2828,
1035,
3313,
1027,
1027,
1002,
2828,
1007,
1063,
1002,
3643,
1027,
1006,
14257,
1007,
1002,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/models/ThemeLog.php | ThemeLog.add | public static function add(HalcyonModel $template, $type = null)
{
if (!App::hasDatabase()) {
return;
}
if (!LogSetting::get('log_theme')) {
return;
}
if (!$type) {
$type = self::TYPE_UPDATE;
}
$isDelete = $type === self::TYPE_DELETE;
$dirName = $template->getObjectTypeDirName();
$templateName = $template->fileName;
$oldTemplateName = $template->getOriginal('fileName');
$newContent = $template->toCompiled();
$oldContent = $template->getOriginal('content');
if ($newContent === $oldContent && $templateName === $oldTemplateName && !$isDelete) {
traceLog($newContent, $oldContent);
traceLog('Content not dirty for: '. $template->getObjectTypeDirName().'/'.$template->fileName);
return;
}
$record = new self;
$record->type = $type;
$record->theme = Theme::getEditThemeCode();
$record->template = $isDelete ? '' : $dirName.'/'.$templateName;
$record->old_template = $oldTemplateName ? $dirName.'/'.$oldTemplateName : '';
$record->content = $isDelete ? '' : $newContent;
$record->old_content = $oldContent;
if ($user = BackendAuth::getUser()) {
$record->user_id = $user->id;
}
try {
$record->save();
}
catch (Exception $ex) {}
return $record;
} | php | public static function add(HalcyonModel $template, $type = null)
{
if (!App::hasDatabase()) {
return;
}
if (!LogSetting::get('log_theme')) {
return;
}
if (!$type) {
$type = self::TYPE_UPDATE;
}
$isDelete = $type === self::TYPE_DELETE;
$dirName = $template->getObjectTypeDirName();
$templateName = $template->fileName;
$oldTemplateName = $template->getOriginal('fileName');
$newContent = $template->toCompiled();
$oldContent = $template->getOriginal('content');
if ($newContent === $oldContent && $templateName === $oldTemplateName && !$isDelete) {
traceLog($newContent, $oldContent);
traceLog('Content not dirty for: '. $template->getObjectTypeDirName().'/'.$template->fileName);
return;
}
$record = new self;
$record->type = $type;
$record->theme = Theme::getEditThemeCode();
$record->template = $isDelete ? '' : $dirName.'/'.$templateName;
$record->old_template = $oldTemplateName ? $dirName.'/'.$oldTemplateName : '';
$record->content = $isDelete ? '' : $newContent;
$record->old_content = $oldContent;
if ($user = BackendAuth::getUser()) {
$record->user_id = $user->id;
}
try {
$record->save();
}
catch (Exception $ex) {}
return $record;
} | [
"public",
"static",
"function",
"add",
"(",
"HalcyonModel",
"$",
"template",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"App",
"::",
"hasDatabase",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"LogSetting",
"::",
"get",
"("... | Creates a log record
@return self | [
"Creates",
"a",
"log",
"record"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/models/ThemeLog.php#L55-L100 | train | Add new record | [
30522,
2270,
10763,
3853,
5587,
1006,
11085,
5666,
2239,
5302,
9247,
1002,
23561,
1010,
1002,
2828,
1027,
19701,
1007,
1063,
2065,
1006,
999,
10439,
1024,
1024,
2038,
2850,
2696,
15058,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Live/Model.php | Model.queryAdjacentVisitorId | public function queryAdjacentVisitorId($idSite, $visitorId, $visitLastActionTime, $segment, $getNext)
{
if ($getNext) {
$visitLastActionTimeCondition = "sub.visit_last_action_time <= ?";
$orderByDir = "DESC";
} else {
$visitLastActionTimeCondition = "sub.visit_last_action_time >= ?";
$orderByDir = "ASC";
}
$visitLastActionDate = Date::factory($visitLastActionTime);
$dateOneDayAgo = $visitLastActionDate->subDay(1);
$dateOneDayInFuture = $visitLastActionDate->addDay(1);
$select = "log_visit.idvisitor, MAX(log_visit.visit_last_action_time) as visit_last_action_time";
$from = "log_visit";
$where = "log_visit.idsite = ? AND log_visit.idvisitor <> ? AND visit_last_action_time >= ? and visit_last_action_time <= ?";
$whereBind = array($idSite, @Common::hex2bin($visitorId), $dateOneDayAgo->toString('Y-m-d H:i:s'), $dateOneDayInFuture->toString('Y-m-d H:i:s'));
$orderBy = "MAX(log_visit.visit_last_action_time) $orderByDir";
$groupBy = "log_visit.idvisitor";
$segment = new Segment($segment, $idSite);
$queryInfo = $segment->getSelectQuery($select, $from, $where, $whereBind, $orderBy, $groupBy);
$sql = "SELECT sub.idvisitor, sub.visit_last_action_time FROM ({$queryInfo['sql']}) as sub
WHERE $visitLastActionTimeCondition
LIMIT 1";
$bind = array_merge($queryInfo['bind'], array($visitLastActionTime));
$visitorId = Db::fetchOne($sql, $bind);
if (!empty($visitorId)) {
$visitorId = bin2hex($visitorId);
}
return $visitorId;
} | php | public function queryAdjacentVisitorId($idSite, $visitorId, $visitLastActionTime, $segment, $getNext)
{
if ($getNext) {
$visitLastActionTimeCondition = "sub.visit_last_action_time <= ?";
$orderByDir = "DESC";
} else {
$visitLastActionTimeCondition = "sub.visit_last_action_time >= ?";
$orderByDir = "ASC";
}
$visitLastActionDate = Date::factory($visitLastActionTime);
$dateOneDayAgo = $visitLastActionDate->subDay(1);
$dateOneDayInFuture = $visitLastActionDate->addDay(1);
$select = "log_visit.idvisitor, MAX(log_visit.visit_last_action_time) as visit_last_action_time";
$from = "log_visit";
$where = "log_visit.idsite = ? AND log_visit.idvisitor <> ? AND visit_last_action_time >= ? and visit_last_action_time <= ?";
$whereBind = array($idSite, @Common::hex2bin($visitorId), $dateOneDayAgo->toString('Y-m-d H:i:s'), $dateOneDayInFuture->toString('Y-m-d H:i:s'));
$orderBy = "MAX(log_visit.visit_last_action_time) $orderByDir";
$groupBy = "log_visit.idvisitor";
$segment = new Segment($segment, $idSite);
$queryInfo = $segment->getSelectQuery($select, $from, $where, $whereBind, $orderBy, $groupBy);
$sql = "SELECT sub.idvisitor, sub.visit_last_action_time FROM ({$queryInfo['sql']}) as sub
WHERE $visitLastActionTimeCondition
LIMIT 1";
$bind = array_merge($queryInfo['bind'], array($visitLastActionTime));
$visitorId = Db::fetchOne($sql, $bind);
if (!empty($visitorId)) {
$visitorId = bin2hex($visitorId);
}
return $visitorId;
} | [
"public",
"function",
"queryAdjacentVisitorId",
"(",
"$",
"idSite",
",",
"$",
"visitorId",
",",
"$",
"visitLastActionTime",
",",
"$",
"segment",
",",
"$",
"getNext",
")",
"{",
"if",
"(",
"$",
"getNext",
")",
"{",
"$",
"visitLastActionTimeCondition",
"=",
"\"... | Returns the ID of a visitor that is adjacent to another visitor (by time of last action)
in the log_visit table.
@param int $idSite The ID of the site whose visits should be looked at.
@param string $visitorId The ID of the visitor to get an adjacent visitor for.
@param string $visitLastActionTime The last action time of the latest visit for $visitorId.
@param string $segment
@param bool $getNext Whether to retrieve the next visitor or the previous visitor. The next
visitor will be the visitor that appears chronologically later in the
log_visit table. The previous visitor will be the visitor that appears
earlier.
@return string The hex visitor ID.
@throws Exception | [
"Returns",
"the",
"ID",
"of",
"a",
"visitor",
"that",
"is",
"adjacent",
"to",
"another",
"visitor",
"(",
"by",
"time",
"of",
"last",
"action",
")",
"in",
"the",
"log_visit",
"table",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Live/Model.php#L205-L239 | train | Query the visit ID for an adjacent visitor | [
30522,
2270,
3853,
23032,
4215,
3900,
13013,
11365,
15660,
3593,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
10367,
3593,
1010,
1002,
3942,
8523,
2696,
7542,
7292,
1010,
1002,
6903,
1010,
1002,
2131,
2638,
18413,
1007,
1063,
2065,
1006,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Annotations/API.php | API.getAll | public function getAll($idSite, $date = false, $period = 'day', $lastN = false)
{
Piwik::checkUserHasViewAccess($idSite);
$annotations = new AnnotationList($idSite);
// if date/period are supplied, determine start/end date for search
list($startDate, $endDate) = self::getDateRangeForPeriod($date, $period, $lastN);
return $annotations->search($startDate, $endDate);
} | php | public function getAll($idSite, $date = false, $period = 'day', $lastN = false)
{
Piwik::checkUserHasViewAccess($idSite);
$annotations = new AnnotationList($idSite);
// if date/period are supplied, determine start/end date for search
list($startDate, $endDate) = self::getDateRangeForPeriod($date, $period, $lastN);
return $annotations->search($startDate, $endDate);
} | [
"public",
"function",
"getAll",
"(",
"$",
"idSite",
",",
"$",
"date",
"=",
"false",
",",
"$",
"period",
"=",
"'day'",
",",
"$",
"lastN",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"$",
"annotations",
... | Returns every annotation for a specific site within a specific date range.
The date range is specified by a date, the period type (day/week/month/year)
and an optional number of N periods in the past to include.
@param string $idSite The site ID to add the annotation to. Can be one ID or
a list of site IDs.
@param bool|string $date The date of the period.
@param string $period The period type.
@param bool|int $lastN Whether to include the last N number of periods in the
date range or not.
@return array An array that indexes arrays of annotations by site ID. ie,
array(
5 => array(
array(...), // annotation #1
array(...), // annotation #2
),
8 => array(...)
) | [
"Returns",
"every",
"annotation",
"for",
"a",
"specific",
"site",
"within",
"a",
"specific",
"date",
"range",
".",
"The",
"date",
"range",
"is",
"specified",
"by",
"a",
"date",
"the",
"period",
"type",
"(",
"day",
"/",
"week",
"/",
"month",
"/",
"year",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/API.php#L185-L195 | train | Get all annotations for a site | [
30522,
2270,
3853,
2131,
8095,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
3058,
1027,
6270,
1010,
1002,
2558,
1027,
1005,
2154,
1005,
1010,
1002,
2197,
2078,
1027,
6270,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
8584,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/CallQueuedClosure.php | CallQueuedClosure.displayName | public function displayName()
{
$reflection = new ReflectionFunction($this->closure->getClosure());
return 'Closure ('.basename($reflection->getFileName()).':'.$reflection->getStartLine().')';
} | php | public function displayName()
{
$reflection = new ReflectionFunction($this->closure->getClosure());
return 'Closure ('.basename($reflection->getFileName()).':'.$reflection->getStartLine().')';
} | [
"public",
"function",
"displayName",
"(",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"this",
"->",
"closure",
"->",
"getClosure",
"(",
")",
")",
";",
"return",
"'Closure ('",
".",
"basename",
"(",
"$",
"reflection",
"->",
"get... | Get the display name for the queued job.
@return string | [
"Get",
"the",
"display",
"name",
"for",
"the",
"queued",
"job",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/CallQueuedClosure.php#L56-L61 | train | Get the display name of the closure | [
30522,
2270,
3853,
4653,
18442,
1006,
1007,
1063,
1002,
9185,
1027,
2047,
9185,
11263,
27989,
1006,
1002,
2023,
1011,
1028,
8503,
1011,
1028,
2131,
20464,
2891,
5397,
1006,
1007,
1007,
1025,
2709,
1005,
8503,
1006,
1005,
1012,
2918,
18442,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Mailable.php | Mailable.hasRecipient | protected function hasRecipient($address, $name = null, $property = 'to')
{
$expected = $this->normalizeRecipient(
$this->addressesToArray($address, $name)[0]
);
$expected = [
'name' => $expected->name ?? null,
'address' => $expected->email,
];
return collect($this->{$property})->contains(function ($actual) use ($expected) {
if (! isset($expected['name'])) {
return $actual['address'] == $expected['address'];
}
return $actual == $expected;
});
} | php | protected function hasRecipient($address, $name = null, $property = 'to')
{
$expected = $this->normalizeRecipient(
$this->addressesToArray($address, $name)[0]
);
$expected = [
'name' => $expected->name ?? null,
'address' => $expected->email,
];
return collect($this->{$property})->contains(function ($actual) use ($expected) {
if (! isset($expected['name'])) {
return $actual['address'] == $expected['address'];
}
return $actual == $expected;
});
} | [
"protected",
"function",
"hasRecipient",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
",",
"$",
"property",
"=",
"'to'",
")",
"{",
"$",
"expected",
"=",
"$",
"this",
"->",
"normalizeRecipient",
"(",
"$",
"this",
"->",
"addressesToArray",
"(",
"$",... | Determine if the given recipient is set on the mailable.
@param object|array|string $address
@param string|null $name
@param string $property
@return bool | [
"Determine",
"if",
"the",
"given",
"recipient",
"is",
"set",
"on",
"the",
"mailable",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailable.php#L632-L650 | train | Checks if a recipient has been sent | [
30522,
5123,
3853,
2038,
2890,
6895,
14756,
3372,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
19701,
1010,
1002,
3200,
1027,
1005,
2000,
1005,
1007,
1063,
1002,
3517,
1027,
1002,
2023,
1011,
1028,
3671,
17629,
8586,
11514,
11638,
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/Bundle/FrameworkBundle/Templating/PhpEngine.php | PhpEngine.get | public function get($name)
{
if (!isset($this->helpers[$name])) {
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
}
if (\is_string($this->helpers[$name])) {
$this->helpers[$name] = $this->container->get($this->helpers[$name]);
$this->helpers[$name]->setCharset($this->charset);
}
return $this->helpers[$name];
} | php | public function get($name)
{
if (!isset($this->helpers[$name])) {
throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
}
if (\is_string($this->helpers[$name])) {
$this->helpers[$name] = $this->container->get($this->helpers[$name]);
$this->helpers[$name]->setCharset($this->charset);
}
return $this->helpers[$name];
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"helpers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The helper \"%s\" is not d... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php#L47-L59 | train | Get the helper by name | [
30522,
2270,
3853,
2131,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2393,
2545,
1031,
1002,
2171,
1033,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422,
1006,
9043,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.getSelectionParams | protected function getSelectionParams()
{
$result = $this->getSession('media_crop_selection_params');
if ($result) {
if (!isset($result['mode'])) {
$result['mode'] = self::SELECTION_MODE_NORMAL;
}
if (!isset($result['width'])) {
$result['width'] = null;
}
if (!isset($result['height'])) {
$result['height'] = null;
}
return $result;
}
return [
'mode' => self::SELECTION_MODE_NORMAL,
'width' => null,
'height' => null
];
} | php | protected function getSelectionParams()
{
$result = $this->getSession('media_crop_selection_params');
if ($result) {
if (!isset($result['mode'])) {
$result['mode'] = self::SELECTION_MODE_NORMAL;
}
if (!isset($result['width'])) {
$result['width'] = null;
}
if (!isset($result['height'])) {
$result['height'] = null;
}
return $result;
}
return [
'mode' => self::SELECTION_MODE_NORMAL,
'width' => null,
'height' => null
];
} | [
"protected",
"function",
"getSelectionParams",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getSession",
"(",
"'media_crop_selection_params'",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"'mod... | Gets the user selection parameters from the session state
@return array | [
"Gets",
"the",
"user",
"selection",
"parameters",
"from",
"the",
"session",
"state"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L1003-L1028 | train | Return the selection parameters from the session | [
30522,
5123,
3853,
4152,
12260,
7542,
28689,
5244,
1006,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
4152,
7971,
3258,
1006,
1005,
2865,
1035,
10416,
1035,
4989,
1035,
11498,
5244,
1005,
1007,
1025,
2065,
1006,
1002,
2765,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Message.php | Message.to | public function to($address, $name = null, $override = false)
{
if ($override) {
$this->swift->setTo($address, $name);
return $this;
}
return $this->addAddresses($address, $name, 'To');
} | php | public function to($address, $name = null, $override = false)
{
if ($override) {
$this->swift->setTo($address, $name);
return $this;
}
return $this->addAddresses($address, $name, 'To');
} | [
"public",
"function",
"to",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
",",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"override",
")",
"{",
"$",
"this",
"->",
"swift",
"->",
"setTo",
"(",
"$",
"address",
",",
"$",
"name",
... | Add a recipient to the message.
@param string|array $address
@param string|null $name
@param bool $override
@return $this | [
"Add",
"a",
"recipient",
"to",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Message.php#L90-L99 | train | Set To address | [
30522,
2270,
3853,
2000,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
19701,
1010,
1002,
2058,
15637,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2058,
15637,
1007,
1063,
1002,
2023,
1011,
1028,
9170,
1011,
1028,
2275,
3406,
1006,
1002,
4769,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Contracts/Translation/TranslatorTrait.php | TranslatorTrait.getPluralizationRule | private function getPluralizationRule(int $number, string $locale): int
{
switch ('pt_BR' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
case 'af':
case 'bn':
case 'bg':
case 'ca':
case 'da':
case 'de':
case 'el':
case 'en':
case 'eo':
case 'es':
case 'et':
case 'eu':
case 'fa':
case 'fi':
case 'fo':
case 'fur':
case 'fy':
case 'gl':
case 'gu':
case 'ha':
case 'he':
case 'hu':
case 'is':
case 'it':
case 'ku':
case 'lb':
case 'ml':
case 'mn':
case 'mr':
case 'nah':
case 'nb':
case 'ne':
case 'nl':
case 'nn':
case 'no':
case 'oc':
case 'om':
case 'or':
case 'pa':
case 'pap':
case 'ps':
case 'pt':
case 'so':
case 'sq':
case 'sv':
case 'sw':
case 'ta':
case 'te':
case 'tk':
case 'ur':
case 'zu':
return (1 == $number) ? 0 : 1;
case 'am':
case 'bh':
case 'fil':
case 'fr':
case 'gun':
case 'hi':
case 'hy':
case 'ln':
case 'mg':
case 'nso':
case 'pt_BR':
case 'ti':
case 'wa':
return ((0 == $number) || (1 == $number)) ? 0 : 1;
case 'be':
case 'bs':
case 'hr':
case 'ru':
case 'sh':
case 'sr':
case 'uk':
return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
case 'cs':
case 'sk':
return (1 == $number) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
case 'ga':
return (1 == $number) ? 0 : ((2 == $number) ? 1 : 2);
case 'lt':
return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
case 'sl':
return (1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : (((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3));
case 'mk':
return (1 == $number % 10) ? 0 : 1;
case 'mt':
return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
case 'lv':
return (0 == $number) ? 0 : (((1 == $number % 10) && (11 != $number % 100)) ? 1 : 2);
case 'pl':
return (1 == $number) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
case 'cy':
return (1 == $number) ? 0 : ((2 == $number) ? 1 : (((8 == $number) || (11 == $number)) ? 2 : 3));
case 'ro':
return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
case 'ar':
return (0 == $number) ? 0 : ((1 == $number) ? 1 : ((2 == $number) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
default:
return 0;
}
} | php | private function getPluralizationRule(int $number, string $locale): int
{
switch ('pt_BR' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
case 'af':
case 'bn':
case 'bg':
case 'ca':
case 'da':
case 'de':
case 'el':
case 'en':
case 'eo':
case 'es':
case 'et':
case 'eu':
case 'fa':
case 'fi':
case 'fo':
case 'fur':
case 'fy':
case 'gl':
case 'gu':
case 'ha':
case 'he':
case 'hu':
case 'is':
case 'it':
case 'ku':
case 'lb':
case 'ml':
case 'mn':
case 'mr':
case 'nah':
case 'nb':
case 'ne':
case 'nl':
case 'nn':
case 'no':
case 'oc':
case 'om':
case 'or':
case 'pa':
case 'pap':
case 'ps':
case 'pt':
case 'so':
case 'sq':
case 'sv':
case 'sw':
case 'ta':
case 'te':
case 'tk':
case 'ur':
case 'zu':
return (1 == $number) ? 0 : 1;
case 'am':
case 'bh':
case 'fil':
case 'fr':
case 'gun':
case 'hi':
case 'hy':
case 'ln':
case 'mg':
case 'nso':
case 'pt_BR':
case 'ti':
case 'wa':
return ((0 == $number) || (1 == $number)) ? 0 : 1;
case 'be':
case 'bs':
case 'hr':
case 'ru':
case 'sh':
case 'sr':
case 'uk':
return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
case 'cs':
case 'sk':
return (1 == $number) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
case 'ga':
return (1 == $number) ? 0 : ((2 == $number) ? 1 : 2);
case 'lt':
return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
case 'sl':
return (1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : (((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3));
case 'mk':
return (1 == $number % 10) ? 0 : 1;
case 'mt':
return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));
case 'lv':
return (0 == $number) ? 0 : (((1 == $number % 10) && (11 != $number % 100)) ? 1 : 2);
case 'pl':
return (1 == $number) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
case 'cy':
return (1 == $number) ? 0 : ((2 == $number) ? 1 : (((8 == $number) || (11 == $number)) ? 2 : 3));
case 'ro':
return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
case 'ar':
return (0 == $number) ? 0 : ((1 == $number) ? 1 : ((2 == $number) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));
default:
return 0;
}
} | [
"private",
"function",
"getPluralizationRule",
"(",
"int",
"$",
"number",
",",
"string",
"$",
"locale",
")",
":",
"int",
"{",
"switch",
"(",
"'pt_BR'",
"!==",
"$",
"locale",
"&&",
"\\",
"strlen",
"(",
"$",
"locale",
")",
">",
"3",
"?",
"substr",
"(",
... | Returns the plural position to use for the given locale and number.
The plural rules are derived from code of the Zend Framework (2010-09-25),
which is subject to the new BSD license (http://framework.zend.com/license/new-bsd).
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) | [
"Returns",
"the",
"plural",
"position",
"to",
"use",
"for",
"the",
"given",
"locale",
"and",
"number",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Contracts/Translation/TranslatorTrait.php#L137-L254 | train | Returns the pluralization rule for the given number and locale | [
30522,
2797,
3853,
2131,
24759,
11137,
3989,
6820,
2571,
1006,
20014,
1002,
2193,
1010,
5164,
1002,
2334,
2063,
1007,
1024,
20014,
1063,
6942,
1006,
1005,
13866,
1035,
7987,
1005,
999,
1027,
1027,
1002,
2334,
2063,
1004,
1004,
1032,
2358,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Uri.php | Uri.route | public function route($absolute = false, $domain = false)
{
return ($absolute ? $this->rootUrl($domain) : '') . '/' . implode('/', $this->paths);
} | php | public function route($absolute = false, $domain = false)
{
return ($absolute ? $this->rootUrl($domain) : '') . '/' . implode('/', $this->paths);
} | [
"public",
"function",
"route",
"(",
"$",
"absolute",
"=",
"false",
",",
"$",
"domain",
"=",
"false",
")",
"{",
"return",
"(",
"$",
"absolute",
"?",
"$",
"this",
"->",
"rootUrl",
"(",
"$",
"domain",
")",
":",
"''",
")",
".",
"'/'",
".",
"implode",
... | Return route to the current URI. By default route doesn't include base path.
@param bool $absolute True to include full path.
@param bool $domain True to include domain. Works only if first parameter is also true.
@return string | [
"Return",
"route",
"to",
"the",
"current",
"URI",
".",
"By",
"default",
"route",
"doesn",
"t",
"include",
"base",
"path",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L236-L239 | train | Returns the route to the root of the page | [
30522,
2270,
3853,
2799,
1006,
1002,
7619,
1027,
6270,
1010,
1002,
5884,
1027,
6270,
1007,
1063,
2709,
1006,
1002,
7619,
1029,
1002,
2023,
1011,
1028,
7117,
3126,
2140,
1006,
1002,
5884,
1007,
1024,
1005,
1005,
1007,
1012,
1005,
1013,
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/Auth/Passwords/PasswordBroker.php | PasswordBroker.validatePasswordWithDefaults | protected function validatePasswordWithDefaults(array $credentials)
{
[$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];
return $password === $confirm && mb_strlen($password) >= 8;
} | php | protected function validatePasswordWithDefaults(array $credentials)
{
[$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];
return $password === $confirm && mb_strlen($password) >= 8;
} | [
"protected",
"function",
"validatePasswordWithDefaults",
"(",
"array",
"$",
"credentials",
")",
"{",
"[",
"$",
"password",
",",
"$",
"confirm",
"]",
"=",
"[",
"$",
"credentials",
"[",
"'password'",
"]",
",",
"$",
"credentials",
"[",
"'password_confirmation'",
... | Determine if the passwords are valid for the request.
@param array $credentials
@return bool | [
"Determine",
"if",
"the",
"passwords",
"are",
"valid",
"for",
"the",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Passwords/PasswordBroker.php#L168-L176 | train | Validate password with default values | [
30522,
5123,
3853,
9398,
3686,
15194,
18351,
24415,
3207,
7011,
11314,
2015,
1006,
30524,
1005,
20786,
1005,
1033,
1010,
1002,
22496,
1031,
1005,
20786,
1035,
13964,
1005,
1033,
1010,
1033,
1025,
2709,
1002,
20786,
1027,
1027,
1027,
1002,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/API.php | API.updateSiteCreatedTime | public function updateSiteCreatedTime($idSites, Date $minDate)
{
$idSites = Site::getIdSitesFromIdSitesString($idSites);
Piwik::checkUserHasAdminAccess($idSites);
$minDateSql = $minDate->subDay(1)->getDatetime();
$this->getModel()->updateSiteCreatedTime($idSites, $minDateSql);
} | php | public function updateSiteCreatedTime($idSites, Date $minDate)
{
$idSites = Site::getIdSitesFromIdSitesString($idSites);
Piwik::checkUserHasAdminAccess($idSites);
$minDateSql = $minDate->subDay(1)->getDatetime();
$this->getModel()->updateSiteCreatedTime($idSites, $minDateSql);
} | [
"public",
"function",
"updateSiteCreatedTime",
"(",
"$",
"idSites",
",",
"Date",
"$",
"minDate",
")",
"{",
"$",
"idSites",
"=",
"Site",
"::",
"getIdSitesFromIdSitesString",
"(",
"$",
"idSites",
")",
";",
"Piwik",
"::",
"checkUserHasAdminAccess",
"(",
"$",
"idS... | Updates the field ts_created for the specified websites.
@param $idSites int Id Site to update ts_created
@param $minDate Date to set as creation date. To play it safe it will subtract one more day.
@ignore | [
"Updates",
"the",
"field",
"ts_created",
"for",
"the",
"specified",
"websites",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L1347-L1355 | train | Update the created time of the sites in the database. | [
30522,
2270,
3853,
14409,
4221,
16748,
4383,
7292,
1006,
1002,
8909,
28032,
2229,
1010,
3058,
1002,
2568,
3686,
1007,
1063,
1002,
8909,
28032,
2229,
1027,
2609,
1024,
1024,
2131,
9821,
7616,
19699,
20936,
5104,
7616,
3367,
4892,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Live/API.php | API.getCounters | public function getCounters($idSite, $lastMinutes, $segment = false, $showColumns = array(), $hideColumns = array())
{
Piwik::checkUserHasViewAccess($idSite);
$model = new Model();
if (is_string($showColumns)) {
$showColumns = explode(',', $showColumns);
}
if (is_string($hideColumns)) {
$hideColumns = explode(',', $hideColumns);
}
$counters = array();
$hasVisits = true;
if ($this->shouldColumnBePresentInResponse('visits', $showColumns, $hideColumns)) {
$counters['visits'] = $model->getNumVisits($idSite, $lastMinutes, $segment);
$hasVisits = !empty($counters['visits']);
}
if ($this->shouldColumnBePresentInResponse('actions', $showColumns, $hideColumns)) {
if ($hasVisits) {
$counters['actions'] = $model->getNumActions($idSite, $lastMinutes, $segment);
} else {
$counters['actions'] = 0;
}
}
if ($this->shouldColumnBePresentInResponse('visitors', $showColumns, $hideColumns)) {
if ($hasVisits) {
$counters['visitors'] = $model->getNumVisitors($idSite, $lastMinutes, $segment);
} else {
$counters['visitors'] = 0;
}
}
if ($this->shouldColumnBePresentInResponse('visitsConverted', $showColumns, $hideColumns)) {
if ($hasVisits) {
$counters['visitsConverted'] = $model->getNumVisitsConverted($idSite, $lastMinutes, $segment);
} else {
$counters['visitsConverted'] = 0;
}
}
return array($counters);
} | php | public function getCounters($idSite, $lastMinutes, $segment = false, $showColumns = array(), $hideColumns = array())
{
Piwik::checkUserHasViewAccess($idSite);
$model = new Model();
if (is_string($showColumns)) {
$showColumns = explode(',', $showColumns);
}
if (is_string($hideColumns)) {
$hideColumns = explode(',', $hideColumns);
}
$counters = array();
$hasVisits = true;
if ($this->shouldColumnBePresentInResponse('visits', $showColumns, $hideColumns)) {
$counters['visits'] = $model->getNumVisits($idSite, $lastMinutes, $segment);
$hasVisits = !empty($counters['visits']);
}
if ($this->shouldColumnBePresentInResponse('actions', $showColumns, $hideColumns)) {
if ($hasVisits) {
$counters['actions'] = $model->getNumActions($idSite, $lastMinutes, $segment);
} else {
$counters['actions'] = 0;
}
}
if ($this->shouldColumnBePresentInResponse('visitors', $showColumns, $hideColumns)) {
if ($hasVisits) {
$counters['visitors'] = $model->getNumVisitors($idSite, $lastMinutes, $segment);
} else {
$counters['visitors'] = 0;
}
}
if ($this->shouldColumnBePresentInResponse('visitsConverted', $showColumns, $hideColumns)) {
if ($hasVisits) {
$counters['visitsConverted'] = $model->getNumVisitsConverted($idSite, $lastMinutes, $segment);
} else {
$counters['visitsConverted'] = 0;
}
}
return array($counters);
} | [
"public",
"function",
"getCounters",
"(",
"$",
"idSite",
",",
"$",
"lastMinutes",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"showColumns",
"=",
"array",
"(",
")",
",",
"$",
"hideColumns",
"=",
"array",
"(",
")",
")",
"{",
"Piwik",
"::",
"checkUserHa... | This will return simple counters, for a given website ID, for visits over the last N minutes
@param int $idSite Id Site
@param int $lastMinutes Number of minutes to look back at
@param bool|string $segment
@param array $showColumns The columns to show / not to request. Eg 'visits', 'actions', ...
@param array $hideColumns The columns to hide / not to request. Eg 'visits', 'actions', ...
@return array( visits => N, actions => M, visitsConverted => P ) | [
"This",
"will",
"return",
"simple",
"counters",
"for",
"a",
"given",
"website",
"ID",
"for",
"visits",
"over",
"the",
"last",
"N",
"minutes"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Live/API.php#L70-L116 | train | Returns the counters for the given site | [
30522,
2270,
3853,
2131,
3597,
16671,
2545,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2197,
10020,
10421,
2015,
1010,
1002,
6903,
1027,
6270,
1010,
1002,
2265,
25778,
2819,
3619,
1027,
9140,
1006,
1007,
1010,
1002,
5342,
25778,
2819,
3619,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/Handler/MockHandler.php | MockHandler.append | public function append()
{
foreach (func_get_args() as $value) {
if ($value instanceof ResponseInterface
|| $value instanceof \Exception
|| $value instanceof PromiseInterface
|| is_callable($value)
) {
$this->queue[] = $value;
} else {
throw new \InvalidArgumentException('Expected a response or '
. 'exception. Found ' . \GuzzleHttp\describe_type($value));
}
}
} | php | public function append()
{
foreach (func_get_args() as $value) {
if ($value instanceof ResponseInterface
|| $value instanceof \Exception
|| $value instanceof PromiseInterface
|| is_callable($value)
) {
$this->queue[] = $value;
} else {
throw new \InvalidArgumentException('Expected a response or '
. 'exception. Found ' . \GuzzleHttp\describe_type($value));
}
}
} | [
"public",
"function",
"append",
"(",
")",
"{",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"ResponseInterface",
"||",
"$",
"value",
"instanceof",
"\\",
"Exception",
"||",
"$",
"value",
"... | Adds one or more variadic requests, exceptions, callables, or promises
to the queue. | [
"Adds",
"one",
"or",
"more",
"variadic",
"requests",
"exceptions",
"callables",
"or",
"promises",
"to",
"the",
"queue",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Handler/MockHandler.php#L132-L146 | train | Append to the queue | [
30522,
2270,
3853,
10439,
10497,
1006,
1007,
1063,
18921,
6776,
1006,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
2004,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
3643,
6013,
11253,
3433,
18447,
2121,
12172,
1064,
1064,
1002,
3643... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/BrowserKit/Client.php | Client.insulate | public function insulate($insulated = true)
{
if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) {
throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.');
}
$this->insulated = (bool) $insulated;
} | php | public function insulate($insulated = true)
{
if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) {
throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.');
}
$this->insulated = (bool) $insulated;
} | [
"public",
"function",
"insulate",
"(",
"$",
"insulated",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"insulated",
"&&",
"!",
"class_exists",
"(",
"'Symfony\\\\Component\\\\Process\\\\Process'",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Unable to i... | Sets the insulated flag.
@param bool $insulated Whether to insulate the requests or not
@throws \RuntimeException When Symfony Process Component is not installed | [
"Sets",
"the",
"insulated",
"flag",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/Client.php#L120-L127 | train | Instructs the request handler to isolate requests. | [
30522,
2270,
3853,
16021,
9869,
1006,
1002,
16021,
8898,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
16021,
8898,
1004,
1004,
999,
2465,
1035,
6526,
1006,
1005,
25353,
2213,
14876,
4890,
1032,
1032,
6922,
1032,
1032,
2832,
1032,
1032,
2832,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php | MappingRule.getTarget | public function getTarget()
{
$childNames = explode('.', $this->targetPath);
$target = $this->origin;
foreach ($childNames as $childName) {
if (!$target->has($childName)) {
throw new ErrorMappingException(sprintf('The child "%s" of "%s" mapped by the rule "%s" in "%s" does not exist.', $childName, $target->getName(), $this->targetPath, $this->origin->getName()));
}
$target = $target->get($childName);
}
return $target;
} | php | public function getTarget()
{
$childNames = explode('.', $this->targetPath);
$target = $this->origin;
foreach ($childNames as $childName) {
if (!$target->has($childName)) {
throw new ErrorMappingException(sprintf('The child "%s" of "%s" mapped by the rule "%s" in "%s" does not exist.', $childName, $target->getName(), $this->targetPath, $this->origin->getName()));
}
$target = $target->get($childName);
}
return $target;
} | [
"public",
"function",
"getTarget",
"(",
")",
"{",
"$",
"childNames",
"=",
"explode",
"(",
"'.'",
",",
"$",
"this",
"->",
"targetPath",
")",
";",
"$",
"target",
"=",
"$",
"this",
"->",
"origin",
";",
"foreach",
"(",
"$",
"childNames",
"as",
"$",
"chil... | @return FormInterface
@throws ErrorMappingException | [
"@return",
"FormInterface"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php#L79-L92 | train | Get the target of the mapping | [
30522,
2270,
3853,
2131,
7559,
18150,
1006,
1007,
1063,
1002,
2775,
18442,
2015,
1027,
15044,
1006,
1005,
1012,
1005,
1010,
1002,
2023,
1011,
1028,
4539,
15069,
1007,
1025,
1002,
4539,
1027,
1002,
2023,
1011,
1028,
4761,
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... |
laravel/framework | src/Illuminate/Routing/Router.php | Router.addWhereClausesToRoute | protected function addWhereClausesToRoute($route)
{
$route->where(array_merge(
$this->patterns, $route->getAction()['where'] ?? []
));
return $route;
} | php | protected function addWhereClausesToRoute($route)
{
$route->where(array_merge(
$this->patterns, $route->getAction()['where'] ?? []
));
return $route;
} | [
"protected",
"function",
"addWhereClausesToRoute",
"(",
"$",
"route",
")",
"{",
"$",
"route",
"->",
"where",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"patterns",
",",
"$",
"route",
"->",
"getAction",
"(",
")",
"[",
"'where'",
"]",
"??",
"[",
"]",
")... | Add the necessary where clauses to the route based on its initial registration.
@param \Illuminate\Routing\Route $route
@return \Illuminate\Routing\Route | [
"Add",
"the",
"necessary",
"where",
"clauses",
"to",
"the",
"route",
"based",
"on",
"its",
"initial",
"registration",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Router.php#L569-L576 | train | Add where clauses to route | [
30522,
5123,
3853,
5587,
2860,
5886,
8586,
28128,
4355,
14604,
10421,
1006,
1002,
2799,
1007,
1063,
1002,
2799,
1011,
1028,
2073,
1006,
9140,
1035,
13590,
1006,
1002,
2023,
1011,
1028,
7060,
1010,
1002,
2799,
1011,
1028,
2131,
18908,
3258,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MemcachedStore.php | MemcachedStore.putOffExpiration | public function putOffExpiration(Key $key, $ttl)
{
if ($ttl < 1) {
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
}
// Interface defines a float value but Store required an integer.
$ttl = (int) ceil($ttl);
$token = $this->getUniqueToken($key);
list($value, $cas) = $this->getValueAndCas($key);
$key->reduceLifetime($ttl);
// Could happens when we ask a putOff after a timeout but in luck nobody steal the lock
if (\Memcached::RES_NOTFOUND === $this->memcached->getResultCode()) {
if ($this->memcached->add((string) $key, $token, $ttl)) {
return;
}
// no luck, with concurrency, someone else acquire the lock
throw new LockConflictedException();
}
// Someone else steal the lock
if ($value !== $token) {
throw new LockConflictedException();
}
if (!$this->memcached->cas($cas, (string) $key, $token, $ttl)) {
throw new LockConflictedException();
}
if ($key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
}
} | php | public function putOffExpiration(Key $key, $ttl)
{
if ($ttl < 1) {
throw new InvalidArgumentException(sprintf('%s() expects a TTL greater or equals to 1 second. Got %s.', __METHOD__, $ttl));
}
// Interface defines a float value but Store required an integer.
$ttl = (int) ceil($ttl);
$token = $this->getUniqueToken($key);
list($value, $cas) = $this->getValueAndCas($key);
$key->reduceLifetime($ttl);
// Could happens when we ask a putOff after a timeout but in luck nobody steal the lock
if (\Memcached::RES_NOTFOUND === $this->memcached->getResultCode()) {
if ($this->memcached->add((string) $key, $token, $ttl)) {
return;
}
// no luck, with concurrency, someone else acquire the lock
throw new LockConflictedException();
}
// Someone else steal the lock
if ($value !== $token) {
throw new LockConflictedException();
}
if (!$this->memcached->cas($cas, (string) $key, $token, $ttl)) {
throw new LockConflictedException();
}
if ($key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
}
} | [
"public",
"function",
"putOffExpiration",
"(",
"Key",
"$",
"key",
",",
"$",
"ttl",
")",
"{",
"if",
"(",
"$",
"ttl",
"<",
"1",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'%s() expects a TTL greater or equals to 1 second. Got %s.'",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Store/MemcachedStore.php#L80-L116 | train | Puts off the expiration of a key | [
30522,
2270,
3853,
2404,
7245,
10288,
16781,
1006,
3145,
1002,
3145,
1010,
1002,
23746,
2140,
1007,
1063,
2065,
1006,
1002,
23746,
2140,
1026,
1015,
1007,
1063,
5466,
2047,
19528,
2906,
22850,
15781,
2595,
24422,
1006,
9043,
2546,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/RedisQueue.php | RedisQueue.pop | public function pop($queue = null)
{
$this->migrate($prefixed = $this->getQueue($queue));
if (empty($nextJob = $this->retrieveNextJob($prefixed))) {
return;
}
[$job, $reserved] = $nextJob;
if ($reserved) {
return new RedisJob(
$this->container, $this, $job,
$reserved, $this->connectionName, $queue ?: $this->default
);
}
} | php | public function pop($queue = null)
{
$this->migrate($prefixed = $this->getQueue($queue));
if (empty($nextJob = $this->retrieveNextJob($prefixed))) {
return;
}
[$job, $reserved] = $nextJob;
if ($reserved) {
return new RedisJob(
$this->container, $this, $job,
$reserved, $this->connectionName, $queue ?: $this->default
);
}
} | [
"public",
"function",
"pop",
"(",
"$",
"queue",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"migrate",
"(",
"$",
"prefixed",
"=",
"$",
"this",
"->",
"getQueue",
"(",
"$",
"queue",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"nextJob",
"=",
"$",
... | Pop the next job off of the queue.
@param string $queue
@return \Illuminate\Contracts\Queue\Job|null | [
"Pop",
"the",
"next",
"job",
"off",
"of",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/RedisQueue.php#L165-L181 | train | Pop a job from the queue | [
30522,
2270,
3853,
3769,
1006,
1002,
24240,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
22806,
1006,
1002,
17576,
2098,
1027,
1002,
2023,
1011,
1028,
2131,
4226,
5657,
1006,
1002,
24240,
1007,
1007,
1025,
2065,
1006,
4064,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Table/Row/Abstract.php | Zend_Db_Table_Row_Abstract.findDependentRowset | public function findDependentRowset($dependentTable, $ruleKey = null, Zend_Db_Table_Select $select = null)
{
$db = $this->_getTable()->getAdapter();
if (is_string($dependentTable)) {
$dependentTable = $this->_getTableFromString($dependentTable);
}
if (!$dependentTable instanceof Zend_Db_Table_Abstract) {
$type = gettype($dependentTable);
if ($type == 'object') {
$type = get_class($dependentTable);
}
// require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("Dependent table must be a Zend_Db_Table_Abstract, but it is $type");
}
// even if we are interacting between a table defined in a class and a
// table via extension, ensure to persist the definition
if (($tableDefinition = $this->_table->getDefinition()) !== null
&& ($dependentTable->getDefinition() == null)) {
$dependentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
}
if ($select === null) {
$select = $dependentTable->select();
} else {
$select->setTable($dependentTable);
}
$map = $this->_prepareReference($dependentTable, $this->_getTable(), $ruleKey);
for ($i = 0; $i < count($map[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
$parentColumnName = $db->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
$value = $this->_data[$parentColumnName];
// Use adapter from dependent table to ensure correct query construction
$dependentDb = $dependentTable->getAdapter();
$dependentColumnName = $dependentDb->foldCase($map[Zend_Db_Table_Abstract::COLUMNS][$i]);
$dependentColumn = $dependentDb->quoteIdentifier($dependentColumnName, true);
$dependentInfo = $dependentTable->info();
$type = $dependentInfo[Zend_Db_Table_Abstract::METADATA][$dependentColumnName]['DATA_TYPE'];
$select->where("$dependentColumn = ?", $value, $type);
}
return $dependentTable->fetchAll($select);
} | php | public function findDependentRowset($dependentTable, $ruleKey = null, Zend_Db_Table_Select $select = null)
{
$db = $this->_getTable()->getAdapter();
if (is_string($dependentTable)) {
$dependentTable = $this->_getTableFromString($dependentTable);
}
if (!$dependentTable instanceof Zend_Db_Table_Abstract) {
$type = gettype($dependentTable);
if ($type == 'object') {
$type = get_class($dependentTable);
}
// require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("Dependent table must be a Zend_Db_Table_Abstract, but it is $type");
}
// even if we are interacting between a table defined in a class and a
// table via extension, ensure to persist the definition
if (($tableDefinition = $this->_table->getDefinition()) !== null
&& ($dependentTable->getDefinition() == null)) {
$dependentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
}
if ($select === null) {
$select = $dependentTable->select();
} else {
$select->setTable($dependentTable);
}
$map = $this->_prepareReference($dependentTable, $this->_getTable(), $ruleKey);
for ($i = 0; $i < count($map[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
$parentColumnName = $db->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
$value = $this->_data[$parentColumnName];
// Use adapter from dependent table to ensure correct query construction
$dependentDb = $dependentTable->getAdapter();
$dependentColumnName = $dependentDb->foldCase($map[Zend_Db_Table_Abstract::COLUMNS][$i]);
$dependentColumn = $dependentDb->quoteIdentifier($dependentColumnName, true);
$dependentInfo = $dependentTable->info();
$type = $dependentInfo[Zend_Db_Table_Abstract::METADATA][$dependentColumnName]['DATA_TYPE'];
$select->where("$dependentColumn = ?", $value, $type);
}
return $dependentTable->fetchAll($select);
} | [
"public",
"function",
"findDependentRowset",
"(",
"$",
"dependentTable",
",",
"$",
"ruleKey",
"=",
"null",
",",
"Zend_Db_Table_Select",
"$",
"select",
"=",
"null",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"_getTable",
"(",
")",
"->",
"getAdapter",
"(",... | Query a dependent table to retrieve rows matching the current row.
@param string|Zend_Db_Table_Abstract $dependentTable
@param string OPTIONAL $ruleKey
@param Zend_Db_Table_Select OPTIONAL $select
@return Zend_Db_Table_Rowset_Abstract Query result from $dependentTable
@throws Zend_Db_Table_Row_Exception If $dependentTable is not a table or is not loadable. | [
"Query",
"a",
"dependent",
"table",
"to",
"retrieve",
"rows",
"matching",
"the",
"current",
"row",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Row/Abstract.php#L867-L912 | train | find dependent rowset | [
30522,
2270,
3853,
2424,
3207,
11837,
16454,
10524,
13462,
1006,
1002,
7790,
10880,
1010,
1002,
3627,
14839,
1027,
19701,
1010,
16729,
2094,
1035,
16962,
1035,
2795,
1035,
7276,
1002,
7276,
1027,
19701,
1007,
1063,
1002,
16962,
1027,
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/ShakeAround/ServiceProvider.php | ServiceProvider.register | public function register(Container $app)
{
$app['shake_around'] = function ($app) {
return new ShakeAround($app);
};
$app['shake_around.device'] = function ($app) {
return new DeviceClient($app);
};
$app['shake_around.page'] = function ($app) {
return new PageClient($app);
};
$app['shake_around.material'] = function ($app) {
return new MaterialClient($app);
};
$app['shake_around.group'] = function ($app) {
return new GroupClient($app);
};
$app['shake_around.relation'] = function ($app) {
return new RelationClient($app);
};
$app['shake_around.stats'] = function ($app) {
return new StatsClient($app);
};
} | php | public function register(Container $app)
{
$app['shake_around'] = function ($app) {
return new ShakeAround($app);
};
$app['shake_around.device'] = function ($app) {
return new DeviceClient($app);
};
$app['shake_around.page'] = function ($app) {
return new PageClient($app);
};
$app['shake_around.material'] = function ($app) {
return new MaterialClient($app);
};
$app['shake_around.group'] = function ($app) {
return new GroupClient($app);
};
$app['shake_around.relation'] = function ($app) {
return new RelationClient($app);
};
$app['shake_around.stats'] = function ($app) {
return new StatsClient($app);
};
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'shake_around'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"ShakeAround",
"(",
"$",
"app",
")",
";",
"}",
";",
"$",
"app",
"[",
"'sh... | {@inheritdoc}. | [
"{"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/ShakeAround/ServiceProvider.php#L27-L56 | train | Register the shake around and page clients | [
30522,
2270,
3853,
4236,
1006,
11661,
1002,
10439,
1007,
1063,
1002,
10439,
1031,
1005,
6073,
1035,
2105,
1005,
1033,
1027,
3853,
1006,
1002,
10439,
1007,
1063,
2709,
2047,
6073,
24490,
1006,
1002,
10439,
1007,
1025,
1065,
1025,
1002,
10439... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/html5lib/Parser.php | HTML5_Parser.parse | static public function parse($text, $builder = null) {
$tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parse();
return $tokenizer->save();
} | php | static public function parse($text, $builder = null) {
$tokenizer = new HTML5_Tokenizer($text, $builder);
$tokenizer->parse();
return $tokenizer->save();
} | [
"static",
"public",
"function",
"parse",
"(",
"$",
"text",
",",
"$",
"builder",
"=",
"null",
")",
"{",
"$",
"tokenizer",
"=",
"new",
"HTML5_Tokenizer",
"(",
"$",
"text",
",",
"$",
"builder",
")",
";",
"$",
"tokenizer",
"->",
"parse",
"(",
")",
";",
... | Parses a full HTML document.
@param $text | HTML text to parse
@param $builder | Custom builder implementation
@return DOMDocument|DOMNodeList Parsed HTML as DOMDocument | [
"Parses",
"a",
"full",
"HTML",
"document",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/Parser.php#L19-L23 | train | Parse HTML5 string | [
30522,
10763,
2270,
3853,
11968,
3366,
1006,
1002,
3793,
1010,
1002,
12508,
1027,
19701,
1007,
1063,
1002,
19204,
17629,
1027,
2047,
16129,
2629,
1035,
19204,
17629,
1006,
1002,
3793,
1010,
1002,
12508,
1007,
1025,
1002,
19204,
17629,
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 | plugins/API/ProcessedReport.php | ProcessedReport.sortReports | public function sortReports($a, $b)
{
return $this->reportsProvider->compareCategories($a['category'], $a['subcategory'], $a['order'], $b['category'], $b['subcategory'], $b['order']);
} | php | public function sortReports($a, $b)
{
return $this->reportsProvider->compareCategories($a['category'], $a['subcategory'], $a['order'], $b['category'], $b['subcategory'], $b['order']);
} | [
"public",
"function",
"sortReports",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"$",
"this",
"->",
"reportsProvider",
"->",
"compareCategories",
"(",
"$",
"a",
"[",
"'category'",
"]",
",",
"$",
"a",
"[",
"'subcategory'",
"]",
",",
"$",
"a",
"[... | API metadata are sorted by category/name,
with a little tweak to replicate the standard Piwik category ordering
@param array $a
@param array $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/plugins/API/ProcessedReport.php#L313-L316 | train | Sort reports by categories and subcategories | [
30522,
2270,
3853,
4066,
2890,
25378,
1006,
1002,
1037,
1010,
1002,
1038,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4311,
21572,
17258,
2121,
1011,
1028,
12826,
16280,
20255,
3111,
1006,
1002,
1037,
1031,
1005,
4696,
1005,
1033,
1010,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Router.php | Router.view | public function view($uri, $view, $data = [])
{
return $this->match(['GET', 'HEAD'], $uri, '\Illuminate\Routing\ViewController')
->defaults('view', $view)
->defaults('data', $data);
} | php | public function view($uri, $view, $data = [])
{
return $this->match(['GET', 'HEAD'], $uri, '\Illuminate\Routing\ViewController')
->defaults('view', $view)
->defaults('data', $data);
} | [
"public",
"function",
"view",
"(",
"$",
"uri",
",",
"$",
"view",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"match",
"(",
"[",
"'GET'",
",",
"'HEAD'",
"]",
",",
"$",
"uri",
",",
"'\\Illuminate\\Routing\\ViewController'",
... | Register a new route that returns a view.
@param string $uri
@param string $view
@param array $data
@return \Illuminate\Routing\Route | [
"Register",
"a",
"new",
"route",
"that",
"returns",
"a",
"view",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Router.php#L269-L274 | train | View a controller | [
30522,
2270,
3853,
3193,
1006,
1002,
24471,
2072,
1010,
1002,
3193,
1010,
1002,
2951,
1027,
1031,
1033,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
30524,
12717,
12556,
1032,
16972,
1032,
3193,
8663,
13181,
10820,
1005,
1007,
1011,
1028,
1239... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/DynamoDbStore.php | DynamoDbStore.many | public function many(array $keys)
{
$prefixedKeys = array_map(function ($key) {
return $this->prefix.$key;
}, $keys);
$response = $this->dynamo->batchGetItem([
'RequestItems' => [
$this->table => [
'ConsistentRead' => false,
'Keys' => collect($prefixedKeys)->map(function ($key) {
return [
$this->keyAttribute => [
'S' => $key,
],
];
})->all(),
],
],
]);
$now = Carbon::now();
return array_merge(collect(array_flip($keys))->map(function () {
})->all(), collect($response['Responses'][$this->table])->mapWithKeys(function ($response) use ($now) {
if ($this->isExpired($response, $now)) {
$value = null;
} else {
$value = $this->unserialize(
$response[$this->valueAttribute]['S'] ??
$response[$this->valueAttribute]['N'] ??
null
);
}
return [Str::replaceFirst($this->prefix, '', $response[$this->keyAttribute]['S']) => $value];
})->all());
} | php | public function many(array $keys)
{
$prefixedKeys = array_map(function ($key) {
return $this->prefix.$key;
}, $keys);
$response = $this->dynamo->batchGetItem([
'RequestItems' => [
$this->table => [
'ConsistentRead' => false,
'Keys' => collect($prefixedKeys)->map(function ($key) {
return [
$this->keyAttribute => [
'S' => $key,
],
];
})->all(),
],
],
]);
$now = Carbon::now();
return array_merge(collect(array_flip($keys))->map(function () {
})->all(), collect($response['Responses'][$this->table])->mapWithKeys(function ($response) use ($now) {
if ($this->isExpired($response, $now)) {
$value = null;
} else {
$value = $this->unserialize(
$response[$this->valueAttribute]['S'] ??
$response[$this->valueAttribute]['N'] ??
null
);
}
return [Str::replaceFirst($this->prefix, '', $response[$this->keyAttribute]['S']) => $value];
})->all());
} | [
"public",
"function",
"many",
"(",
"array",
"$",
"keys",
")",
"{",
"$",
"prefixedKeys",
"=",
"array_map",
"(",
"function",
"(",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"prefix",
".",
"$",
"key",
";",
"}",
",",
"$",
"keys",
")",
";",
"$... | Retrieve multiple items from the cache by key.
Items not found in the cache will have a null value.
@param array $keys
@return array | [
"Retrieve",
"multiple",
"items",
"from",
"the",
"cache",
"by",
"key",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/DynamoDbStore.php#L130-L167 | train | Returns an array of all keys in the cache | [
30522,
2270,
3853,
2116,
1006,
9140,
1002,
6309,
1007,
1063,
1002,
17576,
2098,
14839,
2015,
1027,
9140,
1035,
4949,
1006,
3853,
1006,
1002,
3145,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
3145,
1025,
1065,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/MultiSites/API.php | API.setPastTotalVisitsMetadata | private function setPastTotalVisitsMetadata($dataTable, $pastTable)
{
if ($pastTable instanceof DataTable) {
$total = 0;
$metric = 'nb_visits';
$rows = $pastTable->getRows();
$rows = $this->filterRowsForTotalsCalculation($rows);
foreach ($rows as $row) {
$total += $row->getColumn($metric);
}
$dataTable->setMetadata(self::getTotalMetadataName($metric . '_lastdate'), $total);
}
} | php | private function setPastTotalVisitsMetadata($dataTable, $pastTable)
{
if ($pastTable instanceof DataTable) {
$total = 0;
$metric = 'nb_visits';
$rows = $pastTable->getRows();
$rows = $this->filterRowsForTotalsCalculation($rows);
foreach ($rows as $row) {
$total += $row->getColumn($metric);
}
$dataTable->setMetadata(self::getTotalMetadataName($metric . '_lastdate'), $total);
}
} | [
"private",
"function",
"setPastTotalVisitsMetadata",
"(",
"$",
"dataTable",
",",
"$",
"pastTable",
")",
"{",
"if",
"(",
"$",
"pastTable",
"instanceof",
"DataTable",
")",
"{",
"$",
"total",
"=",
"0",
";",
"$",
"metric",
"=",
"'nb_visits'",
";",
"$",
"rows",... | Sets the number of total visits in tha pastTable on the dataTable as metadata.
@param DataTable $dataTable
@param DataTable $pastTable | [
"Sets",
"the",
"number",
"of",
"total",
"visits",
"in",
"tha",
"pastTable",
"on",
"the",
"dataTable",
"as",
"metadata",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MultiSites/API.php#L463-L478 | train | Set total visits metadata | [
30522,
2797,
3853,
2275,
19707,
9284,
9080,
11365,
12762,
11368,
8447,
2696,
1006,
1002,
2951,
10880,
1010,
1002,
2627,
10880,
1007,
1063,
2065,
1006,
1002,
2627,
10880,
6013,
11253,
2951,
10880,
1007,
1063,
1002,
2561,
1027,
1014,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php | AbstractObjectNormalizer.getCacheKey | private function getCacheKey(?string $format, array $context)
{
foreach ($context[self::EXCLUDE_FROM_CACHE_KEY] ?? $this->defaultContext[self::EXCLUDE_FROM_CACHE_KEY] as $key) {
unset($context[$key]);
}
unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
unset($context['cache_key']); // avoid artificially different keys
try {
return md5($format.serialize([
'context' => $context,
'ignored' => $this->ignoredAttributes,
'camelized' => $this->camelizedAttributes,
]));
} catch (\Exception $exception) {
// The context cannot be serialized, skip the cache
return false;
}
} | php | private function getCacheKey(?string $format, array $context)
{
foreach ($context[self::EXCLUDE_FROM_CACHE_KEY] ?? $this->defaultContext[self::EXCLUDE_FROM_CACHE_KEY] as $key) {
unset($context[$key]);
}
unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
unset($context['cache_key']); // avoid artificially different keys
try {
return md5($format.serialize([
'context' => $context,
'ignored' => $this->ignoredAttributes,
'camelized' => $this->camelizedAttributes,
]));
} catch (\Exception $exception) {
// The context cannot be serialized, skip the cache
return false;
}
} | [
"private",
"function",
"getCacheKey",
"(",
"?",
"string",
"$",
"format",
",",
"array",
"$",
"context",
")",
"{",
"foreach",
"(",
"$",
"context",
"[",
"self",
"::",
"EXCLUDE_FROM_CACHE_KEY",
"]",
"??",
"$",
"this",
"->",
"defaultContext",
"[",
"self",
"::",... | Builds the cache key for the attributes cache.
The key must be different for every option in the context that could change which attributes should be handled.
@return bool|string | [
"Builds",
"the",
"cache",
"key",
"for",
"the",
"attributes",
"cache",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php#L586-L604 | train | Get the cache key | [
30522,
2797,
3853,
2131,
3540,
5403,
14839,
1006,
1029,
5164,
1002,
4289,
1010,
9140,
1002,
6123,
1007,
1063,
18921,
6776,
1006,
1002,
6123,
1031,
2969,
1024,
1024,
23329,
1035,
2013,
1035,
17053,
1035,
3145,
1033,
1029,
1029,
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/Imap.php | Zend_Mail_Storage_Imap.selectFolder | public function selectFolder($globalName)
{
$this->_currentFolder = $globalName;
if (!$this->_protocol->select($this->_currentFolder)) {
$this->_currentFolder = '';
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot change folder, maybe it does not exist');
}
} | php | public function selectFolder($globalName)
{
$this->_currentFolder = $globalName;
if (!$this->_protocol->select($this->_currentFolder)) {
$this->_currentFolder = '';
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot change folder, maybe it does not exist');
}
} | [
"public",
"function",
"selectFolder",
"(",
"$",
"globalName",
")",
"{",
"$",
"this",
"->",
"_currentFolder",
"=",
"$",
"globalName",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_protocol",
"->",
"select",
"(",
"$",
"this",
"->",
"_currentFolder",
")",
")",
... | select given folder
folder must be selectable!
@param Zend_Mail_Storage_Folder|string $globalName global name of folder or instance for subfolder
@return null
@throws Zend_Mail_Storage_Exception
@throws Zend_Mail_Protocol_Exception | [
"select",
"given",
"folder"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Imap.php#L458-L469 | train | select a folder | [
30522,
2270,
3853,
7276,
10371,
2121,
1006,
1002,
3795,
18442,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
2783,
10371,
2121,
1027,
1002,
3795,
18442,
1025,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
8778,
1011,
1028,
7276,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/VisitorInterest/API.php | API.getNumberOfVisitsByVisitCount | public function getNumberOfVisitsByVisitCount($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable(
Archiver::VISITS_COUNT_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
$dataTable->queueFilter('AddSegmentByRangeLabel', array('visitCount'));
$dataTable->queueFilter('BeautifyRangeLabels', array(
Piwik::translate('General_OneVisit'), Piwik::translate('General_NVisits')));
return $dataTable;
} | php | public function getNumberOfVisitsByVisitCount($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable(
Archiver::VISITS_COUNT_RECORD_NAME, $idSite, $period, $date, $segment, Metrics::INDEX_NB_VISITS);
$dataTable->queueFilter('AddSegmentByRangeLabel', array('visitCount'));
$dataTable->queueFilter('BeautifyRangeLabels', array(
Piwik::translate('General_OneVisit'), Piwik::translate('General_NVisits')));
return $dataTable;
} | [
"public",
"function",
"getNumberOfVisitsByVisitCount",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
")",
"{",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getDataTable",
"(",
"Archiver",
"::",
"VISITS_COUNT_RECOR... | Returns a DataTable that associates ranges of visit numbers with the count of visits
whose visit number falls within those ranges.
@param int $idSite The site to select data from.
@param string $period The period type.
@param string $date The date type.
@param string|bool $segment The segment.
@return DataTable the archived report data. | [
"Returns",
"a",
"DataTable",
"that",
"associates",
"ranges",
"of",
"visit",
"numbers",
"with",
"the",
"count",
"of",
"visits",
"whose",
"visit",
"number",
"falls",
"within",
"those",
"ranges",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/VisitorInterest/API.php#L85-L95 | train | Get number of visits by range | [
30522,
2270,
3853,
2131,
19172,
5677,
11253,
11365,
12762,
3762,
11365,
4183,
3597,
16671,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1007,
1063,
1002,
2951,
10880,
1027,
1002,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Sqlite.php | Zend_Cache_Backend_Sqlite._automaticVacuum | private function _automaticVacuum()
{
if ($this->_options['automatic_vacuum_factor'] > 0) {
$rand = rand(1, $this->_options['automatic_vacuum_factor']);
if ($rand == 1) {
$this->_query('VACUUM');
}
}
} | php | private function _automaticVacuum()
{
if ($this->_options['automatic_vacuum_factor'] > 0) {
$rand = rand(1, $this->_options['automatic_vacuum_factor']);
if ($rand == 1) {
$this->_query('VACUUM');
}
}
} | [
"private",
"function",
"_automaticVacuum",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_options",
"[",
"'automatic_vacuum_factor'",
"]",
">",
"0",
")",
"{",
"$",
"rand",
"=",
"rand",
"(",
"1",
",",
"$",
"this",
"->",
"_options",
"[",
"'automatic_vacuum... | Deal with the automatic vacuum process
@return void | [
"Deal",
"with",
"the",
"automatic",
"vacuum",
"process"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Sqlite.php#L527-L535 | train | Automatic Vacuum function | [
30522,
2797,
3853,
1035,
6882,
24887,
2226,
2819,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
7047,
1031,
1005,
6882,
1035,
11641,
1035,
5387,
1005,
1033,
1028,
1014,
1007,
1063,
1002,
14566,
1027,
14566,
1006,
1015,
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... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php | NativeSessionStorage.registerBag | public function registerBag(SessionBagInterface $bag)
{
if ($this->started) {
throw new \LogicException('Cannot register a bag when the session is already started.');
}
$this->bags[$bag->getName()] = $bag;
} | php | public function registerBag(SessionBagInterface $bag)
{
if ($this->started) {
throw new \LogicException('Cannot register a bag when the session is already started.');
}
$this->bags[$bag->getName()] = $bag;
} | [
"public",
"function",
"registerBag",
"(",
"SessionBagInterface",
"$",
"bag",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Cannot register a bag when the session is already started.'",
")",
";",
"}",
"$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L292-L299 | train | Registers a bag | [
30522,
2270,
3853,
4236,
16078,
1006,
5219,
16078,
18447,
2121,
12172,
1002,
4524,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2318,
1007,
1063,
5466,
2047,
1032,
7961,
10288,
24422,
1006,
1005,
3685,
4236,
1037,
4524,
2043,
1996,
5219,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.onEndCroppingSession | public function onEndCroppingSession()
{
$this->abortIfReadOnly();
$cropSessionKey = Input::get('cropSessionKey');
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey)) {
throw new ApplicationException('Invalid input data');
}
$this->removeCropEditDir($cropSessionKey);
} | php | public function onEndCroppingSession()
{
$this->abortIfReadOnly();
$cropSessionKey = Input::get('cropSessionKey');
if (!preg_match('/^[0-9a-z]+$/', $cropSessionKey)) {
throw new ApplicationException('Invalid input data');
}
$this->removeCropEditDir($cropSessionKey);
} | [
"public",
"function",
"onEndCroppingSession",
"(",
")",
"{",
"$",
"this",
"->",
"abortIfReadOnly",
"(",
")",
";",
"$",
"cropSessionKey",
"=",
"Input",
"::",
"get",
"(",
"'cropSessionKey'",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[0-9a-z]+$/'",
",",
... | End crop session AJAX handler
@return array | [
"End",
"crop",
"session",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L725-L735 | train | End cropping session | [
30522,
2270,
3853,
2028,
4859,
26775,
7361,
4691,
8583,
10992,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
11113,
11589,
10128,
16416,
5280,
2135,
1006,
1007,
1025,
1002,
8765,
7971,
3258,
14839,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
8765... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/thrift | lib/php/lib/Transport/TBufferedTransport.php | TBufferedTransport.readAll | public function readAll($len)
{
$have = TStringFuncFactory::create()->strlen($this->rBuf_);
if ($have == 0) {
$data = $this->transport_->readAll($len);
} elseif ($have < $len) {
$data = $this->rBuf_;
$this->rBuf_ = '';
$data .= $this->transport_->readAll($len - $have);
} elseif ($have == $len) {
$data = $this->rBuf_;
$this->rBuf_ = '';
} elseif ($have > $len) {
$data = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len);
$this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len);
}
return $data;
} | php | public function readAll($len)
{
$have = TStringFuncFactory::create()->strlen($this->rBuf_);
if ($have == 0) {
$data = $this->transport_->readAll($len);
} elseif ($have < $len) {
$data = $this->rBuf_;
$this->rBuf_ = '';
$data .= $this->transport_->readAll($len - $have);
} elseif ($have == $len) {
$data = $this->rBuf_;
$this->rBuf_ = '';
} elseif ($have > $len) {
$data = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len);
$this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len);
}
return $data;
} | [
"public",
"function",
"readAll",
"(",
"$",
"len",
")",
"{",
"$",
"have",
"=",
"TStringFuncFactory",
"::",
"create",
"(",
")",
"->",
"strlen",
"(",
"$",
"this",
"->",
"rBuf_",
")",
";",
"if",
"(",
"$",
"have",
"==",
"0",
")",
"{",
"$",
"data",
"="... | The reason that we customize readAll here is that the majority of PHP
streams are already internally buffered by PHP. The socket stream, for
example, buffers internally and blocks if you call read with $len greater
than the amount of data available, unlike recv() in C.
Therefore, use the readAll method of the wrapped transport inside
the buffered readAll.
@throws TTransportException | [
"The",
"reason",
"that",
"we",
"customize",
"readAll",
"here",
"is",
"that",
"the",
"majority",
"of",
"PHP",
"streams",
"are",
"already",
"internally",
"buffered",
"by",
"PHP",
".",
"The",
"socket",
"stream",
"for",
"example",
"buffers",
"internally",
"and",
... | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Transport/TBufferedTransport.php#L122-L140 | train | read all data from the socket | [
30522,
2270,
3853,
3191,
8095,
1006,
1002,
18798,
1007,
1063,
1002,
2031,
1027,
24529,
18886,
3070,
11263,
12273,
21450,
1024,
1024,
3443,
1006,
1007,
1011,
1028,
2358,
20927,
2078,
1006,
1002,
2023,
1011,
1028,
21144,
16093,
1035,
1007,
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/Uri.php | Uri.convertUrlOld | public static function convertUrlOld(PageInterface $page, $markdown_url, $type = 'link', $relative = null)
{
$grav = Grav::instance();
$language = $grav['language'];
// Link processing should prepend language
$language_append = '';
if ($type === 'link' && $language->enabled()) {
$language_append = $language->getLanguageURLPrefix();
}
$pages_dir = $grav['locator']->findResource('page://');
if ($relative === null) {
$base = $grav['base_url'];
} else {
$base = $relative ? $grav['base_url_relative'] : $grav['base_url_absolute'];
}
$base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
// if absolute and starts with a base_url move on
if (pathinfo($markdown_url, PATHINFO_DIRNAME) === '.' && $page->url() === '/') {
return '/' . $markdown_url;
}
// no path to convert
if ($base_url !== '' && Utils::startsWith($markdown_url, $base_url)) {
return $markdown_url;
}
// if contains only a fragment
if (Utils::startsWith($markdown_url, '#')) {
return $markdown_url;
}
$target = null;
// see if page is relative to this or absolute
if (Utils::startsWith($markdown_url, '/')) {
$normalized_url = Utils::normalizePath($base_url . $markdown_url);
$normalized_path = Utils::normalizePath($pages_dir . $markdown_url);
} else {
$normalized_url = $base_url . Utils::normalizePath($page->route() . '/' . $markdown_url);
$normalized_path = Utils::normalizePath($page->path() . '/' . $markdown_url);
}
// special check to see if path checking is required.
$just_path = str_replace($normalized_url, '', $normalized_path);
if ($just_path === $page->path()) {
return $normalized_url;
}
$url_bits = parse_url($normalized_path);
$full_path = $url_bits['path'];
if (file_exists($full_path)) {
// do nothing
} elseif (file_exists(rawurldecode($full_path))) {
$full_path = rawurldecode($full_path);
} else {
return $normalized_url;
}
$path_info = pathinfo($full_path);
$page_path = $path_info['dirname'];
$filename = '';
if ($markdown_url === '..') {
$page_path = $full_path;
} else {
// save the filename if a file is part of the path
if (is_file($full_path)) {
if ($path_info['extension'] !== 'md') {
$filename = '/' . $path_info['basename'];
}
} else {
$page_path = $full_path;
}
}
// get page instances and try to find one that fits
$instances = $grav['pages']->instances();
if (isset($instances[$page_path])) {
/** @var PageInterface $target */
$target = $instances[$page_path];
$url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
return static::buildUrl($url_bits);
}
return $normalized_url;
} | php | public static function convertUrlOld(PageInterface $page, $markdown_url, $type = 'link', $relative = null)
{
$grav = Grav::instance();
$language = $grav['language'];
// Link processing should prepend language
$language_append = '';
if ($type === 'link' && $language->enabled()) {
$language_append = $language->getLanguageURLPrefix();
}
$pages_dir = $grav['locator']->findResource('page://');
if ($relative === null) {
$base = $grav['base_url'];
} else {
$base = $relative ? $grav['base_url_relative'] : $grav['base_url_absolute'];
}
$base_url = rtrim($base . $grav['pages']->base(), '/') . $language_append;
// if absolute and starts with a base_url move on
if (pathinfo($markdown_url, PATHINFO_DIRNAME) === '.' && $page->url() === '/') {
return '/' . $markdown_url;
}
// no path to convert
if ($base_url !== '' && Utils::startsWith($markdown_url, $base_url)) {
return $markdown_url;
}
// if contains only a fragment
if (Utils::startsWith($markdown_url, '#')) {
return $markdown_url;
}
$target = null;
// see if page is relative to this or absolute
if (Utils::startsWith($markdown_url, '/')) {
$normalized_url = Utils::normalizePath($base_url . $markdown_url);
$normalized_path = Utils::normalizePath($pages_dir . $markdown_url);
} else {
$normalized_url = $base_url . Utils::normalizePath($page->route() . '/' . $markdown_url);
$normalized_path = Utils::normalizePath($page->path() . '/' . $markdown_url);
}
// special check to see if path checking is required.
$just_path = str_replace($normalized_url, '', $normalized_path);
if ($just_path === $page->path()) {
return $normalized_url;
}
$url_bits = parse_url($normalized_path);
$full_path = $url_bits['path'];
if (file_exists($full_path)) {
// do nothing
} elseif (file_exists(rawurldecode($full_path))) {
$full_path = rawurldecode($full_path);
} else {
return $normalized_url;
}
$path_info = pathinfo($full_path);
$page_path = $path_info['dirname'];
$filename = '';
if ($markdown_url === '..') {
$page_path = $full_path;
} else {
// save the filename if a file is part of the path
if (is_file($full_path)) {
if ($path_info['extension'] !== 'md') {
$filename = '/' . $path_info['basename'];
}
} else {
$page_path = $full_path;
}
}
// get page instances and try to find one that fits
$instances = $grav['pages']->instances();
if (isset($instances[$page_path])) {
/** @var PageInterface $target */
$target = $instances[$page_path];
$url_bits['path'] = $base_url . rtrim($target->route(), '/') . $filename;
return static::buildUrl($url_bits);
}
return $normalized_url;
} | [
"public",
"static",
"function",
"convertUrlOld",
"(",
"PageInterface",
"$",
"page",
",",
"$",
"markdown_url",
",",
"$",
"type",
"=",
"'link'",
",",
"$",
"relative",
"=",
"null",
")",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"$",
... | Converts links from absolute '/' or relative (../..) to a Grav friendly format
@param PageInterface $page the current page to use as reference
@param string $markdown_url the URL as it was written in the markdown
@param string $type the type of URL, image | link
@param null $relative if null, will use system default, if true will use relative links internally
@return string the more friendly formatted url | [
"Converts",
"links",
"from",
"absolute",
"/",
"or",
"relative",
"(",
"..",
"/",
"..",
")",
"to",
"a",
"Grav",
"friendly",
"format"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L957-L1045 | train | Convert a page from the old version of the convertUrlOld | [
30522,
2270,
10763,
3853,
10463,
3126,
4135,
6392,
1006,
3931,
18447,
2121,
12172,
1002,
3931,
1010,
1002,
2928,
7698,
1035,
24471,
2140,
1010,
1002,
2828,
1027,
1005,
4957,
1005,
1010,
1002,
5816,
1027,
19701,
1007,
1063,
1002,
24665,
1143... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Chunk/ErrorChunk.php | ErrorChunk.isFirst | public function isFirst(): bool
{
$this->didThrow = true;
throw new TransportException($this->errorMessage, 0, $this->error);
} | php | public function isFirst(): bool
{
$this->didThrow = true;
throw new TransportException($this->errorMessage, 0, $this->error);
} | [
"public",
"function",
"isFirst",
"(",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"didThrow",
"=",
"true",
";",
"throw",
"new",
"TransportException",
"(",
"$",
"this",
"->",
"errorMessage",
",",
"0",
",",
"$",
"this",
"->",
"error",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php#L53-L57 | train | Is this the first time? | [
30522,
2270,
3853,
2003,
8873,
12096,
1006,
1007,
1024,
22017,
2140,
1063,
1002,
2023,
1011,
1028,
2106,
2705,
10524,
1027,
2995,
1025,
5466,
2047,
30524,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Dompdf.php | Dompdf.render | public function render()
{
$this->saveLocale();
$options = $this->options;
$logOutputFile = $options->getLogOutputFile();
if ($logOutputFile) {
if (!file_exists($logOutputFile) && is_writable(dirname($logOutputFile))) {
touch($logOutputFile);
}
$this->startTime = microtime(true);
if (is_writable($logOutputFile)) {
ob_start();
}
}
$this->processHtml();
$this->css->apply_styles($this->tree);
// @page style rules : size, margins
$pageStyles = $this->css->get_page_styles();
$basePageStyle = $pageStyles["base"];
unset($pageStyles["base"]);
foreach ($pageStyles as $pageStyle) {
$pageStyle->inherit($basePageStyle);
}
$defaultOptionPaperSize = $this->getPaperSize($options->getDefaultPaperSize());
// If there is a CSS defined paper size compare to the paper size used to create the canvas to determine a
// recreation need
if (is_array($basePageStyle->size)) {
$basePageStyleSize = $basePageStyle->size;
$this->setPaper(array(0, 0, $basePageStyleSize[0], $basePageStyleSize[1]));
}
$paperSize = $this->getPaperSize();
if (
$defaultOptionPaperSize[2] !== $paperSize[2] ||
$defaultOptionPaperSize[3] !== $paperSize[3] ||
$options->getDefaultPaperOrientation() !== $this->paperOrientation
) {
$this->setCanvas(CanvasFactory::get_instance($this, $this->paperSize, $this->paperOrientation));
$this->fontMetrics->setCanvas($this->getCanvas());
}
$canvas = $this->getCanvas();
if ($options->isFontSubsettingEnabled() && $canvas instanceof CPDF) {
foreach ($this->tree->get_frames() as $frame) {
$style = $frame->get_style();
$node = $frame->get_node();
// Handle text nodes
if ($node->nodeName === "#text") {
$chars = mb_strtoupper($node->nodeValue) . mb_strtolower($node->nodeValue);
$canvas->register_string_subset($style->font_family, $chars);
continue;
}
// Handle generated content (list items)
if ($style->display === "list-item") {
$chars = ListBullet::get_counter_chars($style->list_style_type);
$canvas->register_string_subset($style->font_family, $chars);
$canvas->register_string_subset($style->font_family, '.');
continue;
}
// Handle other generated content (pseudo elements)
// FIXME: This only captures the text of the stylesheet declaration,
// not the actual generated content, and forces all possible counter
// values. See notes in issue #750.
if ($frame->get_node()->nodeName == "dompdf_generated") {
// all possible counter values, just in case
$chars = ListBullet::get_counter_chars('decimal');
$canvas->register_string_subset($style->font_family, $chars);
$chars = ListBullet::get_counter_chars('upper-alpha');
$canvas->register_string_subset($style->font_family, $chars);
$chars = ListBullet::get_counter_chars('lower-alpha');
$canvas->register_string_subset($style->font_family, $chars);
$chars = ListBullet::get_counter_chars('lower-greek');
$canvas->register_string_subset($style->font_family, $chars);
// the hex-decoded text of the content property, duplicated from AbstrctFrameReflower::_parse_string
$decoded_string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})/",
function ($matches) { return \Dompdf\Helpers::unichr(hexdec($matches[1])); },
$style->content);
$chars = mb_strtoupper($style->content) . mb_strtolower($style->content) . mb_strtoupper($decoded_string) . mb_strtolower($decoded_string);
$canvas->register_string_subset($style->font_family, $chars);
continue;
}
}
}
$root = null;
foreach ($this->tree->get_frames() as $frame) {
// Set up the root frame
if (is_null($root)) {
$root = Factory::decorate_root($this->tree->get_root(), $this);
continue;
}
// Create the appropriate decorators, reflowers & positioners.
Factory::decorate_frame($frame, $this, $root);
}
// Add meta information
$title = $this->dom->getElementsByTagName("title");
if ($title->length) {
$canvas->add_info("Title", trim($title->item(0)->nodeValue));
}
$metas = $this->dom->getElementsByTagName("meta");
$labels = array(
"author" => "Author",
"keywords" => "Keywords",
"description" => "Subject",
);
/** @var \DOMElement $meta */
foreach ($metas as $meta) {
$name = mb_strtolower($meta->getAttribute("name"));
$value = trim($meta->getAttribute("content"));
if (isset($labels[$name])) {
$canvas->add_info($labels[$name], $value);
continue;
}
if ($name === "dompdf.view" && $this->parseDefaultView($value)) {
$canvas->set_default_view($this->defaultView, $this->defaultViewOptions);
}
}
$root->set_containing_block(0, 0,$canvas->get_width(), $canvas->get_height());
$root->set_renderer(new Renderer($this));
// This is where the magic happens:
$root->reflow();
// Clean up cached images
Cache::clear();
global $_dompdf_warnings, $_dompdf_show_warnings;
if ($_dompdf_show_warnings && isset($_dompdf_warnings)) {
echo '<b>Dompdf Warnings</b><br><pre>';
foreach ($_dompdf_warnings as $msg) {
echo $msg . "\n";
}
if ($canvas instanceof CPDF) {
echo $canvas->get_cpdf()->messages;
}
echo '</pre>';
flush();
}
if ($logOutputFile && is_writable($logOutputFile)) {
$this->write_log();
ob_end_clean();
}
$this->restoreLocale();
} | php | public function render()
{
$this->saveLocale();
$options = $this->options;
$logOutputFile = $options->getLogOutputFile();
if ($logOutputFile) {
if (!file_exists($logOutputFile) && is_writable(dirname($logOutputFile))) {
touch($logOutputFile);
}
$this->startTime = microtime(true);
if (is_writable($logOutputFile)) {
ob_start();
}
}
$this->processHtml();
$this->css->apply_styles($this->tree);
// @page style rules : size, margins
$pageStyles = $this->css->get_page_styles();
$basePageStyle = $pageStyles["base"];
unset($pageStyles["base"]);
foreach ($pageStyles as $pageStyle) {
$pageStyle->inherit($basePageStyle);
}
$defaultOptionPaperSize = $this->getPaperSize($options->getDefaultPaperSize());
// If there is a CSS defined paper size compare to the paper size used to create the canvas to determine a
// recreation need
if (is_array($basePageStyle->size)) {
$basePageStyleSize = $basePageStyle->size;
$this->setPaper(array(0, 0, $basePageStyleSize[0], $basePageStyleSize[1]));
}
$paperSize = $this->getPaperSize();
if (
$defaultOptionPaperSize[2] !== $paperSize[2] ||
$defaultOptionPaperSize[3] !== $paperSize[3] ||
$options->getDefaultPaperOrientation() !== $this->paperOrientation
) {
$this->setCanvas(CanvasFactory::get_instance($this, $this->paperSize, $this->paperOrientation));
$this->fontMetrics->setCanvas($this->getCanvas());
}
$canvas = $this->getCanvas();
if ($options->isFontSubsettingEnabled() && $canvas instanceof CPDF) {
foreach ($this->tree->get_frames() as $frame) {
$style = $frame->get_style();
$node = $frame->get_node();
// Handle text nodes
if ($node->nodeName === "#text") {
$chars = mb_strtoupper($node->nodeValue) . mb_strtolower($node->nodeValue);
$canvas->register_string_subset($style->font_family, $chars);
continue;
}
// Handle generated content (list items)
if ($style->display === "list-item") {
$chars = ListBullet::get_counter_chars($style->list_style_type);
$canvas->register_string_subset($style->font_family, $chars);
$canvas->register_string_subset($style->font_family, '.');
continue;
}
// Handle other generated content (pseudo elements)
// FIXME: This only captures the text of the stylesheet declaration,
// not the actual generated content, and forces all possible counter
// values. See notes in issue #750.
if ($frame->get_node()->nodeName == "dompdf_generated") {
// all possible counter values, just in case
$chars = ListBullet::get_counter_chars('decimal');
$canvas->register_string_subset($style->font_family, $chars);
$chars = ListBullet::get_counter_chars('upper-alpha');
$canvas->register_string_subset($style->font_family, $chars);
$chars = ListBullet::get_counter_chars('lower-alpha');
$canvas->register_string_subset($style->font_family, $chars);
$chars = ListBullet::get_counter_chars('lower-greek');
$canvas->register_string_subset($style->font_family, $chars);
// the hex-decoded text of the content property, duplicated from AbstrctFrameReflower::_parse_string
$decoded_string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})/",
function ($matches) { return \Dompdf\Helpers::unichr(hexdec($matches[1])); },
$style->content);
$chars = mb_strtoupper($style->content) . mb_strtolower($style->content) . mb_strtoupper($decoded_string) . mb_strtolower($decoded_string);
$canvas->register_string_subset($style->font_family, $chars);
continue;
}
}
}
$root = null;
foreach ($this->tree->get_frames() as $frame) {
// Set up the root frame
if (is_null($root)) {
$root = Factory::decorate_root($this->tree->get_root(), $this);
continue;
}
// Create the appropriate decorators, reflowers & positioners.
Factory::decorate_frame($frame, $this, $root);
}
// Add meta information
$title = $this->dom->getElementsByTagName("title");
if ($title->length) {
$canvas->add_info("Title", trim($title->item(0)->nodeValue));
}
$metas = $this->dom->getElementsByTagName("meta");
$labels = array(
"author" => "Author",
"keywords" => "Keywords",
"description" => "Subject",
);
/** @var \DOMElement $meta */
foreach ($metas as $meta) {
$name = mb_strtolower($meta->getAttribute("name"));
$value = trim($meta->getAttribute("content"));
if (isset($labels[$name])) {
$canvas->add_info($labels[$name], $value);
continue;
}
if ($name === "dompdf.view" && $this->parseDefaultView($value)) {
$canvas->set_default_view($this->defaultView, $this->defaultViewOptions);
}
}
$root->set_containing_block(0, 0,$canvas->get_width(), $canvas->get_height());
$root->set_renderer(new Renderer($this));
// This is where the magic happens:
$root->reflow();
// Clean up cached images
Cache::clear();
global $_dompdf_warnings, $_dompdf_show_warnings;
if ($_dompdf_show_warnings && isset($_dompdf_warnings)) {
echo '<b>Dompdf Warnings</b><br><pre>';
foreach ($_dompdf_warnings as $msg) {
echo $msg . "\n";
}
if ($canvas instanceof CPDF) {
echo $canvas->get_cpdf()->messages;
}
echo '</pre>';
flush();
}
if ($logOutputFile && is_writable($logOutputFile)) {
$this->write_log();
ob_end_clean();
}
$this->restoreLocale();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"saveLocale",
"(",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"options",
";",
"$",
"logOutputFile",
"=",
"$",
"options",
"->",
"getLogOutputFile",
"(",
")",
";",
"if",
"(",
"$",... | Renders the HTML to PDF | [
"Renders",
"the",
"HTML",
"to",
"PDF"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L707-L872 | train | Render the page | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
3828,
4135,
9289,
2063,
1006,
1007,
1025,
1002,
7047,
1027,
1002,
2023,
1011,
1028,
7047,
1025,
1002,
8154,
4904,
18780,
8873,
2571,
1027,
1002,
7047,
1011,
1028,
2131,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Session/Namespace.php | Zend_Session_Namespace.apply | public function apply($callback)
{
$arg_list = func_get_args();
$arg_list[0] = $_SESSION[$this->_namespace];
return call_user_func_array($callback, $arg_list);
} | php | public function apply($callback)
{
$arg_list = func_get_args();
$arg_list[0] = $_SESSION[$this->_namespace];
return call_user_func_array($callback, $arg_list);
} | [
"public",
"function",
"apply",
"(",
"$",
"callback",
")",
"{",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"$",
"arg_list",
"[",
"0",
"]",
"=",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_namespace",
"]",
";",
"return",
"call_user_func_array",
... | apply() - enables applying user-selected function, such as array_merge() to the namespace
Parameters following the $callback argument are passed to the callback function.
Caveat: ignores members expiring now.
Example:
$namespace->apply('array_merge', array('tree' => 'apple', 'fruit' => 'peach'), array('flower' => 'rose'));
$namespace->apply('count');
@param string|array $callback - callback function | [
"apply",
"()",
"-",
"enables",
"applying",
"user",
"-",
"selected",
"function",
"such",
"as",
"array_merge",
"()",
"to",
"the",
"namespace",
"Parameters",
"following",
"the",
"$callback",
"argument",
"are",
"passed",
"to",
"the",
"callback",
"function",
".",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session/Namespace.php#L342-L347 | train | Apply a callback to the current namespace | [
30522,
2270,
3853,
6611,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
12098,
2290,
1035,
2862,
1027,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
1025,
1002,
12098,
2290,
1035,
2862,
1031,
1014,
1033,
1027,
1002,
1035,
5219,
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... |
octobercms/october | modules/cms/models/ThemeData.php | ThemeData.getAssetVariables | public function getAssetVariables()
{
$result = [];
foreach ($this->getFormFields() as $attribute => $field) {
if (!$varName = array_get($field, 'assetVar')) {
continue;
}
$result[$varName] = $this->{$attribute};
}
return $result;
} | php | public function getAssetVariables()
{
$result = [];
foreach ($this->getFormFields() as $attribute => $field) {
if (!$varName = array_get($field, 'assetVar')) {
continue;
}
$result[$varName] = $this->{$attribute};
}
return $result;
} | [
"public",
"function",
"getAssetVariables",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFormFields",
"(",
")",
"as",
"$",
"attribute",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"$",
"varName",
"=",
"a... | Returns variables that should be passed to the asset combiner.
@return array | [
"Returns",
"variables",
"that",
"should",
"be",
"passed",
"to",
"the",
"asset",
"combiner",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/models/ThemeData.php#L207-L220 | train | Get asset variables | [
30522,
2270,
3853,
2131,
27241,
9189,
10980,
13510,
1006,
1007,
1063,
1002,
2765,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
14192,
15155,
1006,
1007,
2004,
1002,
17961,
1027,
1028,
1002,
2492,
1007,
1063,
2065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/TaggedCache.php | TaggedCache.decrement | public function decrement($key, $value = 1)
{
$this->store->decrement($this->itemKey($key), $value);
} | php | public function decrement($key, $value = 1)
{
$this->store->decrement($this->itemKey($key), $value);
} | [
"public",
"function",
"decrement",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"store",
"->",
"decrement",
"(",
"$",
"this",
"->",
"itemKey",
"(",
"$",
"key",
")",
",",
"$",
"value",
")",
";",
"}"
] | Decrement the value of an item in the cache.
@param string $key
@param mixed $value
@return void | [
"Decrement",
"the",
"value",
"of",
"an",
"item",
"in",
"the",
"cache",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/TaggedCache.php#L69-L72 | train | Decrement the value of an integer key in the recordset | [
30522,
2270,
3853,
11703,
30524,
11703,
28578,
4765,
1006,
1002,
2023,
1011,
1028,
8875,
14839,
1006,
1002,
3145,
1007,
1010,
1002,
3643,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Classification/Ensemble/RandomForest.php | RandomForest.setClassifer | public function setClassifer(string $classifier, array $classifierOptions = [])
{
if ($classifier !== DecisionTree::class) {
throw new InvalidArgumentException('RandomForest can only use DecisionTree as base classifier');
}
parent::setClassifer($classifier, $classifierOptions);
return $this;
} | php | public function setClassifer(string $classifier, array $classifierOptions = [])
{
if ($classifier !== DecisionTree::class) {
throw new InvalidArgumentException('RandomForest can only use DecisionTree as base classifier');
}
parent::setClassifer($classifier, $classifierOptions);
return $this;
} | [
"public",
"function",
"setClassifer",
"(",
"string",
"$",
"classifier",
",",
"array",
"$",
"classifierOptions",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"classifier",
"!==",
"DecisionTree",
"::",
"class",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
... | RandomForest algorithm is usable *only* with DecisionTree
@return $this | [
"RandomForest",
"algorithm",
"is",
"usable",
"*",
"only",
"*",
"with",
"DecisionTree"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Ensemble/RandomForest.php#L70-L79 | train | Set the classifier for RandomForest | [
30522,
2270,
3853,
2275,
26266,
23780,
1006,
5164,
1002,
2465,
18095,
1010,
9140,
1002,
2465,
18095,
7361,
9285,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
2465,
18095,
999,
1027,
1027,
3247,
13334,
1024,
1024,
2465,
1007,
1063,
5466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Support/Arr.php | Arr.pluck | public static function pluck($array, $value, $key = null)
{
$results = [];
[$value, $key] = static::explodePluckParameters($value, $key);
foreach ($array as $item) {
$itemValue = data_get($item, $value);
// If the key is "null", we will just append the value to the array and keep
// looping. Otherwise we will key the array using the value of the key we
// received from the developer. Then we'll return the final array form.
if (is_null($key)) {
$results[] = $itemValue;
} else {
$itemKey = data_get($item, $key);
if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
$itemKey = (string) $itemKey;
}
$results[$itemKey] = $itemValue;
}
}
return $results;
} | php | public static function pluck($array, $value, $key = null)
{
$results = [];
[$value, $key] = static::explodePluckParameters($value, $key);
foreach ($array as $item) {
$itemValue = data_get($item, $value);
// If the key is "null", we will just append the value to the array and keep
// looping. Otherwise we will key the array using the value of the key we
// received from the developer. Then we'll return the final array form.
if (is_null($key)) {
$results[] = $itemValue;
} else {
$itemKey = data_get($item, $key);
if (is_object($itemKey) && method_exists($itemKey, '__toString')) {
$itemKey = (string) $itemKey;
}
$results[$itemKey] = $itemValue;
}
}
return $results;
} | [
"public",
"static",
"function",
"pluck",
"(",
"$",
"array",
",",
"$",
"value",
",",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"[",
"$",
"value",
",",
"$",
"key",
"]",
"=",
"static",
"::",
"explodePluckParameters",
"(",
... | Pluck an array of values from an array.
@param array $array
@param string|array $value
@param string|array|null $key
@return array | [
"Pluck",
"an",
"array",
"of",
"values",
"from",
"an",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Arr.php#L376-L402 | train | Plucks the values from the array | [
30522,
2270,
10763,
3853,
20228,
12722,
1006,
1002,
9140,
1010,
1002,
3643,
1010,
1002,
3145,
1027,
19701,
1007,
1063,
1002,
3463,
1027,
1031,
1033,
1025,
1031,
1002,
3643,
1010,
1002,
3145,
1033,
1027,
10763,
1024,
1024,
15044,
24759,
1272... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/ContainerBuilder.php | ContainerBuilder.prependExtensionConfig | public function prependExtensionConfig($name, array $config)
{
if (!isset($this->extensionConfigs[$name])) {
$this->extensionConfigs[$name] = [];
}
array_unshift($this->extensionConfigs[$name], $config);
} | php | public function prependExtensionConfig($name, array $config)
{
if (!isset($this->extensionConfigs[$name])) {
$this->extensionConfigs[$name] = [];
}
array_unshift($this->extensionConfigs[$name], $config);
} | [
"public",
"function",
"prependExtensionConfig",
"(",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"extensionConfigs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"extensionConfigs",
"... | Prepends a config array to the configs of the given extension.
@param string $name The name of the extension
@param array $config The config to set | [
"Prepends",
"a",
"config",
"array",
"to",
"the",
"configs",
"of",
"the",
"given",
"extension",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/ContainerBuilder.php#L713-L720 | train | Prepend extension config | [
30522,
2270,
3853,
17463,
10497,
10288,
29048,
8663,
8873,
2290,
1006,
1002,
2171,
1010,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
5331,
8663,
8873,
5620,
1031,
1002,
2171,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php | TemplateManager.getNames | public function getNames(Profile $profile)
{
$templates = [];
foreach ($this->templates as $arguments) {
if (null === $arguments) {
continue;
}
list($name, $template) = $arguments;
if (!$this->profiler->has($name) || !$profile->hasCollector($name)) {
continue;
}
if ('.html.twig' === substr($template, -10)) {
$template = substr($template, 0, -10);
}
if (!$this->templateExists($template.'.html.twig')) {
throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
}
$templates[$name] = $template.'.html.twig';
}
return $templates;
} | php | public function getNames(Profile $profile)
{
$templates = [];
foreach ($this->templates as $arguments) {
if (null === $arguments) {
continue;
}
list($name, $template) = $arguments;
if (!$this->profiler->has($name) || !$profile->hasCollector($name)) {
continue;
}
if ('.html.twig' === substr($template, -10)) {
$template = substr($template, 0, -10);
}
if (!$this->templateExists($template.'.html.twig')) {
throw new \UnexpectedValueException(sprintf('The profiler template "%s.html.twig" for data collector "%s" does not exist.', $template, $name));
}
$templates[$name] = $template.'.html.twig';
}
return $templates;
} | [
"public",
"function",
"getNames",
"(",
"Profile",
"$",
"profile",
")",
"{",
"$",
"templates",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"templates",
"as",
"$",
"arguments",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"arguments",
")",
"{",
... | Gets template names of templates that are present in the viewed profile.
@return array
@throws \UnexpectedValueException | [
"Gets",
"template",
"names",
"of",
"templates",
"that",
"are",
"present",
"in",
"the",
"viewed",
"profile",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php#L70-L97 | train | Get all the profiler templates for a given profile | [
30522,
2270,
3853,
2131,
18442,
2015,
1006,
6337,
1002,
6337,
1007,
1063,
1002,
23561,
2015,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
23561,
2015,
2004,
1002,
9918,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
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/Foundation/Console/EventGenerateCommand.php | EventGenerateCommand.makeListeners | protected function makeListeners($event, $listeners)
{
foreach ($listeners as $listener) {
$listener = preg_replace('/@.+$/', '', $listener);
$this->callSilent('make:listener', array_filter(
['name' => $listener, '--event' => $event]
));
}
} | php | protected function makeListeners($event, $listeners)
{
foreach ($listeners as $listener) {
$listener = preg_replace('/@.+$/', '', $listener);
$this->callSilent('make:listener', array_filter(
['name' => $listener, '--event' => $event]
));
}
} | [
"protected",
"function",
"makeListeners",
"(",
"$",
"event",
",",
"$",
"listeners",
")",
"{",
"foreach",
"(",
"$",
"listeners",
"as",
"$",
"listener",
")",
"{",
"$",
"listener",
"=",
"preg_replace",
"(",
"'/@.+$/'",
",",
"''",
",",
"$",
"listener",
")",
... | Make the listeners for the given event.
@param string $event
@param array $listeners
@return void | [
"Make",
"the",
"listeners",
"for",
"the",
"given",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/EventGenerateCommand.php#L68-L77 | train | Make all listeners for the given event | [
30522,
5123,
3853,
2191,
9863,
24454,
2015,
1006,
1002,
2724,
1010,
1002,
13810,
1007,
1063,
18921,
6776,
1006,
1002,
13810,
2004,
1002,
19373,
1007,
1063,
1002,
19373,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
1013,
1030,
1012,
1009,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php | TemplateController.templateAction | public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null): Response
{
if ($this->templating) {
$response = new Response($this->templating->render($template));
} elseif ($this->twig) {
$response = new Response($this->twig->render($template));
} else {
throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
}
if ($maxAge) {
$response->setMaxAge($maxAge);
}
if ($sharedAge) {
$response->setSharedMaxAge($sharedAge);
}
if ($private) {
$response->setPrivate();
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
$response->setPublic();
}
return $response;
} | php | public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null): Response
{
if ($this->templating) {
$response = new Response($this->templating->render($template));
} elseif ($this->twig) {
$response = new Response($this->twig->render($template));
} else {
throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.');
}
if ($maxAge) {
$response->setMaxAge($maxAge);
}
if ($sharedAge) {
$response->setSharedMaxAge($sharedAge);
}
if ($private) {
$response->setPrivate();
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
$response->setPublic();
}
return $response;
} | [
"public",
"function",
"templateAction",
"(",
"string",
"$",
"template",
",",
"int",
"$",
"maxAge",
"=",
"null",
",",
"int",
"$",
"sharedAge",
"=",
"null",
",",
"bool",
"$",
"private",
"=",
"null",
")",
":",
"Response",
"{",
"if",
"(",
"$",
"this",
"-... | Renders a template.
@param string $template The template name
@param int|null $maxAge Max age for client caching
@param int|null $sharedAge Max age for shared (proxy) caching
@param bool|null $private Whether or not caching should apply for client caches only | [
"Renders",
"a",
"template",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php#L44-L69 | train | Renders a template | [
30522,
2270,
3853,
23561,
18908,
3258,
1006,
5164,
1002,
23561,
1010,
20014,
1002,
4098,
4270,
1027,
19701,
1010,
20014,
1002,
4207,
4270,
1027,
19701,
1010,
22017,
2140,
1002,
2797,
1027,
19701,
1007,
1024,
3433,
1063,
2065,
1006,
1002,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Support/ServiceProvider.php | ServiceProvider.loadViewsFrom | protected function loadViewsFrom($path, $namespace)
{
if (is_array($this->app->config['view']['paths'])) {
foreach ($this->app->config['view']['paths'] as $viewPath) {
if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
$this->app['view']->addNamespace($namespace, $appPath);
}
}
}
$this->app['view']->addNamespace($namespace, $path);
} | php | protected function loadViewsFrom($path, $namespace)
{
if (is_array($this->app->config['view']['paths'])) {
foreach ($this->app->config['view']['paths'] as $viewPath) {
if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
$this->app['view']->addNamespace($namespace, $appPath);
}
}
}
$this->app['view']->addNamespace($namespace, $path);
} | [
"protected",
"function",
"loadViewsFrom",
"(",
"$",
"path",
",",
"$",
"namespace",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"app",
"->",
"config",
"[",
"'view'",
"]",
"[",
"'paths'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
... | Register a view file namespace.
@param string|array $path
@param string $namespace
@return void | [
"Register",
"a",
"view",
"file",
"namespace",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/ServiceProvider.php#L95-L106 | train | Load views from the given path and namespace | [
30522,
5123,
3853,
7170,
8584,
22747,
21716,
1006,
1002,
4130,
1010,
1002,
3415,
15327,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2023,
1011,
1028,
10439,
1011,
1028,
9530,
8873,
2290,
1031,
1005,
3193,
1005,
1033,
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... |
matomo-org/matomo | core/Tracker/Model.php | Model.getAllItemsCurrentlyInTheCart | public function getAllItemsCurrentlyInTheCart($goal, $defaultIdOrder)
{
$sql = "SELECT idaction_sku, idaction_name, idaction_category, idaction_category2, idaction_category3, idaction_category4, idaction_category5, price, quantity, deleted, idorder as idorder_original_value
FROM " . Common::prefixTable('log_conversion_item') . "
WHERE idvisit = ? AND (idorder = ? OR idorder = ?)";
$bind = array(
$goal['idvisit'],
isset($goal['idorder']) ? $goal['idorder'] : $defaultIdOrder,
$defaultIdOrder
);
$itemsInDb = $this->getDb()->fetchAll($sql, $bind);
Common::printDebug("Items found in current cart, for conversion_item (visit,idorder)=" . var_export($bind, true));
Common::printDebug($itemsInDb);
return $itemsInDb;
} | php | public function getAllItemsCurrentlyInTheCart($goal, $defaultIdOrder)
{
$sql = "SELECT idaction_sku, idaction_name, idaction_category, idaction_category2, idaction_category3, idaction_category4, idaction_category5, price, quantity, deleted, idorder as idorder_original_value
FROM " . Common::prefixTable('log_conversion_item') . "
WHERE idvisit = ? AND (idorder = ? OR idorder = ?)";
$bind = array(
$goal['idvisit'],
isset($goal['idorder']) ? $goal['idorder'] : $defaultIdOrder,
$defaultIdOrder
);
$itemsInDb = $this->getDb()->fetchAll($sql, $bind);
Common::printDebug("Items found in current cart, for conversion_item (visit,idorder)=" . var_export($bind, true));
Common::printDebug($itemsInDb);
return $itemsInDb;
} | [
"public",
"function",
"getAllItemsCurrentlyInTheCart",
"(",
"$",
"goal",
",",
"$",
"defaultIdOrder",
")",
"{",
"$",
"sql",
"=",
"\"SELECT idaction_sku, idaction_name, idaction_category, idaction_category2, idaction_category3, idaction_category4, idaction_category5, price, quantity, delet... | Loads the Ecommerce items from the request and records them in the DB
@param array $goal
@param int $defaultIdOrder
@throws Exception
@return array | [
"Loads",
"the",
"Ecommerce",
"items",
"from",
"the",
"request",
"and",
"records",
"them",
"in",
"the",
"DB"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Model.php#L96-L114 | train | Get all items currently in the cart | [
30522,
2270,
3853,
2131,
8095,
4221,
5244,
10841,
14343,
20630,
18447,
5369,
10010,
2102,
1006,
1002,
3125,
1010,
1002,
12398,
13820,
26764,
1007,
1063,
1002,
29296,
1027,
1000,
7276,
16096,
7542,
1035,
15315,
2226,
1010,
16096,
7542,
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/system/classes/CombineAssets.php | CombineAssets.getCache | protected function getCache($cacheKey)
{
$cacheKey = 'combiner.'.$cacheKey;
if (!Cache::has($cacheKey)) {
return false;
}
return @unserialize(@base64_decode(Cache::get($cacheKey)));
} | php | protected function getCache($cacheKey)
{
$cacheKey = 'combiner.'.$cacheKey;
if (!Cache::has($cacheKey)) {
return false;
}
return @unserialize(@base64_decode(Cache::get($cacheKey)));
} | [
"protected",
"function",
"getCache",
"(",
"$",
"cacheKey",
")",
"{",
"$",
"cacheKey",
"=",
"'combiner.'",
".",
"$",
"cacheKey",
";",
"if",
"(",
"!",
"Cache",
"::",
"has",
"(",
"$",
"cacheKey",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"@"... | Look up information about a cache identifier.
@param string $cacheKey Cache identifier
@return array Cache information | [
"Look",
"up",
"information",
"about",
"a",
"cache",
"identifier",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L780-L789 | train | Get the cached value of a key | [
30522,
5123,
3853,
2131,
3540,
5403,
1006,
1002,
17053,
14839,
1007,
1063,
1002,
17053,
14839,
1027,
1005,
11506,
2099,
1012,
1005,
1012,
1002,
17053,
14839,
1025,
2065,
1006,
999,
17053,
1024,
1024,
2038,
1006,
1002,
17053,
14839,
1007,
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.filenameToType | public static function filenameToType($filename)
{
// In case the path is a URL, strip any query string before getting extension
$qpos = strpos($filename, '?');
if (false !== $qpos) {
$filename = substr($filename, 0, $qpos);
}
$ext = static::mb_pathinfo($filename, PATHINFO_EXTENSION);
return static::_mime_types($ext);
} | php | public static function filenameToType($filename)
{
// In case the path is a URL, strip any query string before getting extension
$qpos = strpos($filename, '?');
if (false !== $qpos) {
$filename = substr($filename, 0, $qpos);
}
$ext = static::mb_pathinfo($filename, PATHINFO_EXTENSION);
return static::_mime_types($ext);
} | [
"public",
"static",
"function",
"filenameToType",
"(",
"$",
"filename",
")",
"{",
"// In case the path is a URL, strip any query string before getting extension",
"$",
"qpos",
"=",
"strpos",
"(",
"$",
"filename",
",",
"'?'",
")",
";",
"if",
"(",
"false",
"!==",
"$",... | Map a file name to a MIME type.
Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
@param string $filename A file name or full path, does not need to exist as a file
@return string | [
"Map",
"a",
"file",
"name",
"to",
"a",
"MIME",
"type",
".",
"Defaults",
"to",
"application",
"/",
"octet",
"-",
"stream",
"i",
".",
"e",
"..",
"arbitrary",
"binary",
"data",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L4029-L4039 | train | Returns the mime types of a file | [
30522,
2270,
10763,
3853,
5371,
18442,
3406,
13874,
1006,
1002,
5371,
18442,
1007,
1063,
1013,
1013,
1999,
2553,
1996,
4130,
2003,
1037,
24471,
2140,
1010,
6167,
2151,
23032,
5164,
2077,
2893,
5331,
1002,
1053,
6873,
2015,
1027,
2358,
14536... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/thrift | lib/php/lib/Transport/TSSLSocket.php | TSSLSocket.open | public function open()
{
if ($this->isOpen()) {
throw new TTransportException('Socket already connected', TTransportException::ALREADY_OPEN);
}
if (empty($this->host_)) {
throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN);
}
if ($this->port_ <= 0) {
throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN);
}
$this->handle_ = @stream_socket_client(
$this->host_ . ':' . $this->port_,
$errno,
$errstr,
$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000),
STREAM_CLIENT_CONNECT,
$this->context_
);
// Connect failed?
if ($this->handle_ === false) {
$error = 'TSocket: Could not connect to ' .
$this->host_ . ':' . $this->port_ . ' (' . $errstr . ' [' . $errno . '])';
if ($this->debug_) {
call_user_func($this->debugHandler_, $error);
}
throw new TException($error);
}
} | php | public function open()
{
if ($this->isOpen()) {
throw new TTransportException('Socket already connected', TTransportException::ALREADY_OPEN);
}
if (empty($this->host_)) {
throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN);
}
if ($this->port_ <= 0) {
throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN);
}
$this->handle_ = @stream_socket_client(
$this->host_ . ':' . $this->port_,
$errno,
$errstr,
$this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000),
STREAM_CLIENT_CONNECT,
$this->context_
);
// Connect failed?
if ($this->handle_ === false) {
$error = 'TSocket: Could not connect to ' .
$this->host_ . ':' . $this->port_ . ' (' . $errstr . ' [' . $errno . '])';
if ($this->debug_) {
call_user_func($this->debugHandler_, $error);
}
throw new TException($error);
}
} | [
"public",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOpen",
"(",
")",
")",
"{",
"throw",
"new",
"TTransportException",
"(",
"'Socket already connected'",
",",
"TTransportException",
"::",
"ALREADY_OPEN",
")",
";",
"}",
"if",
"(",
"... | Connects the socket. | [
"Connects",
"the",
"socket",
"."
] | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Transport/TSSLSocket.php#L84-L116 | train | Open the socket | [
30522,
2270,
3853,
2330,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11163,
11837,
1006,
1007,
1007,
1063,
5466,
2047,
23746,
5521,
20205,
10288,
24422,
1006,
1005,
22278,
2525,
4198,
1005,
30524,
1005,
3685,
2330,
19701,
3677,
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... |
barryvdh/laravel-debugbar | src/DataCollector/FilesCollector.php | FilesCollector.getCompiledFiles | protected function getCompiledFiles()
{
if ($this->app && class_exists('Illuminate\Foundation\Console\OptimizeCommand')) {
$reflector = new \ReflectionClass('Illuminate\Foundation\Console\OptimizeCommand');
$path = dirname($reflector->getFileName()) . '/Optimize/config.php';
if (file_exists($path)) {
$app = $this->app;
$core = require $path;
return array_merge($core, $app['config']['compile']);
}
}
return [];
} | php | protected function getCompiledFiles()
{
if ($this->app && class_exists('Illuminate\Foundation\Console\OptimizeCommand')) {
$reflector = new \ReflectionClass('Illuminate\Foundation\Console\OptimizeCommand');
$path = dirname($reflector->getFileName()) . '/Optimize/config.php';
if (file_exists($path)) {
$app = $this->app;
$core = require $path;
return array_merge($core, $app['config']['compile']);
}
}
return [];
} | [
"protected",
"function",
"getCompiledFiles",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"&&",
"class_exists",
"(",
"'Illuminate\\Foundation\\Console\\OptimizeCommand'",
")",
")",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"'Illuminat... | Get the files that are going to be compiled, so they aren't as important.
@return array | [
"Get",
"the",
"files",
"that",
"are",
"going",
"to",
"be",
"compiled",
"so",
"they",
"aren",
"t",
"as",
"important",
"."
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/FilesCollector.php#L82-L95 | train | Get all compiled files | [
30522,
5123,
3853,
2131,
9006,
22090,
20952,
9463,
2015,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
10439,
1004,
1004,
2465,
1035,
6526,
1006,
1005,
5665,
12717,
12556,
1032,
3192,
1032,
10122,
1032,
23569,
27605,
4371,
9006,
238... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/ArchiveProcessor.php | ArchiveProcessor.renameColumnsAfterAggregation | public function renameColumnsAfterAggregation(DataTable $table, $columnsToRenameAfterAggregation = null)
{
// Rename columns after aggregation
if (is_null($columnsToRenameAfterAggregation)) {
$columnsToRenameAfterAggregation = self::$columnsToRenameAfterAggregation;
}
if (empty($columnsToRenameAfterAggregation)) {
return;
}
foreach ($table->getRows() as $row) {
foreach ($columnsToRenameAfterAggregation as $oldName => $newName) {
$row->renameColumn($oldName, $newName);
}
$subTable = $row->getSubtable();
if ($subTable) {
$this->renameColumnsAfterAggregation($subTable, $columnsToRenameAfterAggregation);
}
}
} | php | public function renameColumnsAfterAggregation(DataTable $table, $columnsToRenameAfterAggregation = null)
{
// Rename columns after aggregation
if (is_null($columnsToRenameAfterAggregation)) {
$columnsToRenameAfterAggregation = self::$columnsToRenameAfterAggregation;
}
if (empty($columnsToRenameAfterAggregation)) {
return;
}
foreach ($table->getRows() as $row) {
foreach ($columnsToRenameAfterAggregation as $oldName => $newName) {
$row->renameColumn($oldName, $newName);
}
$subTable = $row->getSubtable();
if ($subTable) {
$this->renameColumnsAfterAggregation($subTable, $columnsToRenameAfterAggregation);
}
}
} | [
"public",
"function",
"renameColumnsAfterAggregation",
"(",
"DataTable",
"$",
"table",
",",
"$",
"columnsToRenameAfterAggregation",
"=",
"null",
")",
"{",
"// Rename columns after aggregation",
"if",
"(",
"is_null",
"(",
"$",
"columnsToRenameAfterAggregation",
")",
")",
... | Note: public only for use in closure in PHP 5.3. | [
"Note",
":",
"public",
"only",
"for",
"use",
"in",
"closure",
"in",
"PHP",
"5",
".",
"3",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor.php#L540-L561 | train | Rename columns after aggregation | [
30522,
2270,
3853,
14916,
14074,
25778,
2819,
3619,
10354,
14621,
13871,
2890,
12540,
1006,
2951,
10880,
1002,
2795,
1010,
1002,
7753,
19277,
18442,
10354,
14621,
13871,
2890,
12540,
1027,
19701,
1007,
1063,
1013,
1013,
14916,
14074,
7753,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreHome/Tracker/VisitRequestProcessor.php | VisitRequestProcessor.isVisitNew | public function isVisitNew(VisitProperties $visitProperties, Request $request)
{
$isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown');
if (!$isKnown) {
return true;
}
$isLastActionInTheSameVisit = $this->isLastActionInTheSameVisit($visitProperties, $request);
if (!$isLastActionInTheSameVisit) {
Common::printDebug("Visitor detected, but last action was more than 30 minutes ago...");
return true;
}
$wasLastActionYesterday = $this->wasLastActionNotToday($visitProperties, $request);
$forceNewVisitAtMidnight = (bool) Config::getInstance()->Tracker['create_new_visit_after_midnight'];
if ($wasLastActionYesterday && $forceNewVisitAtMidnight) {
Common::printDebug("Visitor detected, but last action was yesterday...");
return true;
}
return false;
} | php | public function isVisitNew(VisitProperties $visitProperties, Request $request)
{
$isKnown = $request->getMetadata('CoreHome', 'isVisitorKnown');
if (!$isKnown) {
return true;
}
$isLastActionInTheSameVisit = $this->isLastActionInTheSameVisit($visitProperties, $request);
if (!$isLastActionInTheSameVisit) {
Common::printDebug("Visitor detected, but last action was more than 30 minutes ago...");
return true;
}
$wasLastActionYesterday = $this->wasLastActionNotToday($visitProperties, $request);
$forceNewVisitAtMidnight = (bool) Config::getInstance()->Tracker['create_new_visit_after_midnight'];
if ($wasLastActionYesterday && $forceNewVisitAtMidnight) {
Common::printDebug("Visitor detected, but last action was yesterday...");
return true;
}
return false;
} | [
"public",
"function",
"isVisitNew",
"(",
"VisitProperties",
"$",
"visitProperties",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"isKnown",
"=",
"$",
"request",
"->",
"getMetadata",
"(",
"'CoreHome'",
",",
"'isVisitorKnown'",
")",
";",
"if",
"(",
"!",
"$",... | Determines if the tracker if the current action should be treated as the start of a new visit or
an action in an existing visit.
Note: public only for tests.
@param VisitProperties $visitProperties The current visit/visitor information.
@param Request $request
@return bool | [
"Determines",
"if",
"the",
"tracker",
"if",
"the",
"current",
"action",
"should",
"be",
"treated",
"as",
"the",
"start",
"of",
"a",
"new",
"visit",
"or",
"an",
"action",
"in",
"an",
"existing",
"visit",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreHome/Tracker/VisitRequestProcessor.php#L149-L173 | train | Check if a new visit should be made | [
30522,
2270,
3853,
2003,
11365,
4183,
2638,
2860,
1006,
3942,
21572,
4842,
7368,
1002,
3942,
21572,
4842,
7368,
1010,
5227,
1002,
5227,
1007,
1063,
1002,
2003,
2243,
19779,
2078,
1027,
1002,
5227,
1011,
1028,
2131,
11368,
8447,
2696,
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/RequestHandler/RequestHandler.php | RequestHandler.addMiddleware | public function addMiddleware(string $name, MiddlewareInterface $middleware): self
{
$this->container[$name] = $middleware;
array_unshift($this->middleware, $name);
return $this;
} | php | public function addMiddleware(string $name, MiddlewareInterface $middleware): self
{
$this->container[$name] = $middleware;
array_unshift($this->middleware, $name);
return $this;
} | [
"public",
"function",
"addMiddleware",
"(",
"string",
"$",
"name",
",",
"MiddlewareInterface",
"$",
"middleware",
")",
":",
"self",
"{",
"$",
"this",
"->",
"container",
"[",
"$",
"name",
"]",
"=",
"$",
"middleware",
";",
"array_unshift",
"(",
"$",
"this",
... | Add Middleware that will be executed as soon as possible.
@param string $name
@param MiddlewareInterface $middleware
@return $this | [
"Add",
"Middleware",
"that",
"will",
"be",
"executed",
"as",
"soon",
"as",
"possible",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/RequestHandler/RequestHandler.php#L59-L65 | train | Add a middleware to the beginning of the stack | [
30522,
2270,
3853,
5587,
4328,
20338,
8059,
1006,
5164,
1002,
2171,
1010,
2690,
8059,
18447,
2121,
12172,
1002,
2690,
8059,
1007,
1024,
2969,
1063,
1002,
2023,
1011,
1028,
11661,
1031,
1002,
2171,
1033,
1027,
1002,
2690,
8059,
1025,
9140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.fields | public function fields(array $fields = [])
{
if (!Arr::isAssoc($fields)) {
$fields = array_combine($fields, $fields);
}
foreach ($fields as $field => $label) {
$this->field($field, $label);
}
return $this;
} | php | public function fields(array $fields = [])
{
if (!Arr::isAssoc($fields)) {
$fields = array_combine($fields, $fields);
}
foreach ($fields as $field => $label) {
$this->field($field, $label);
}
return $this;
} | [
"public",
"function",
"fields",
"(",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"isAssoc",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"array_combine",
"(",
"$",
"fields",
",",
"$",
"fields",
")",
";"... | Add multiple fields.
@param array $fields
@return $this | [
"Add",
"multiple",
"fields",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show.php#L166-L177 | train | Set the fields to be used in the query | [
30522,
2270,
3853,
4249,
1006,
9140,
1002,
4249,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
999,
12098,
2099,
1024,
1024,
18061,
24137,
2278,
1006,
1002,
4249,
1007,
1007,
1063,
1002,
4249,
1027,
9140,
1035,
11506,
1006,
1002,
4249,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/AuthManager.php | AuthManager.validateUserModel | protected function validateUserModel($user)
{
if ( ! $user instanceof $this->userModel) {
return false;
}
// Perform the deleted_at check manually since the relevant migrations
// might not have been run yet during the update to build 444.
// @see https://github.com/octobercms/october/issues/3999
if (array_key_exists('deleted_at', $user->getAttributes()) && $user->deleted_at !== null) {
return false;
}
return $user;
} | php | protected function validateUserModel($user)
{
if ( ! $user instanceof $this->userModel) {
return false;
}
// Perform the deleted_at check manually since the relevant migrations
// might not have been run yet during the update to build 444.
// @see https://github.com/octobercms/october/issues/3999
if (array_key_exists('deleted_at', $user->getAttributes()) && $user->deleted_at !== null) {
return false;
}
return $user;
} | [
"protected",
"function",
"validateUserModel",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"$",
"user",
"instanceof",
"$",
"this",
"->",
"userModel",
")",
"{",
"return",
"false",
";",
"}",
"// Perform the deleted_at check manually since the relevant migrations",
"// ... | {@inheritdoc} | [
"{"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/AuthManager.php#L177-L191 | train | Validate user model | [
30522,
5123,
3853,
9398,
3686,
20330,
5302,
9247,
1006,
1002,
5310,
1007,
1063,
2065,
1006,
999,
1002,
5310,
6013,
11253,
1002,
2023,
1011,
1028,
5310,
5302,
9247,
1007,
1063,
2709,
6270,
1025,
1065,
1013,
1013,
4685,
1996,
17159,
1035,
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/SettingsPiwik.php | SettingsPiwik.getSalt | public static function getSalt()
{
static $salt = null;
if (is_null($salt)) {
$salt = @Config::getInstance()->General['salt'];
}
return $salt;
} | php | public static function getSalt()
{
static $salt = null;
if (is_null($salt)) {
$salt = @Config::getInstance()->General['salt'];
}
return $salt;
} | [
"public",
"static",
"function",
"getSalt",
"(",
")",
"{",
"static",
"$",
"salt",
"=",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"salt",
")",
")",
"{",
"$",
"salt",
"=",
"@",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"General",
"[",
"'salt'"... | Get salt from [General] section. Should ONLY be used as a seed to create hashes
NOTE: Keep this salt secret! Never output anywhere or share it etc.
@return string | [
"Get",
"salt",
"from",
"[",
"General",
"]",
"section",
".",
"Should",
"ONLY",
"be",
"used",
"as",
"a",
"seed",
"to",
"create",
"hashes"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/SettingsPiwik.php#L29-L36 | train | Get the salt | [
30522,
2270,
10763,
3853,
4152,
2389,
2102,
1006,
1007,
1063,
10763,
1002,
5474,
1027,
19701,
1025,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
5474,
1007,
1007,
1063,
1002,
5474,
1027,
1030,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/VarDumper/Cloner/Data.php | Data.dumpItem | private function dumpItem($dumper, $cursor, &$refs, $item)
{
$cursor->refIndex = 0;
$cursor->softRefTo = $cursor->softRefHandle = $cursor->softRefCount = 0;
$cursor->hardRefTo = $cursor->hardRefHandle = $cursor->hardRefCount = 0;
$firstSeen = true;
if (!$item instanceof Stub) {
$cursor->attr = [];
$type = \gettype($item);
if ($item && 'array' === $type) {
$item = $this->getStub($item);
}
} elseif (Stub::TYPE_REF === $item->type) {
if ($item->handle) {
if (!isset($refs[$r = $item->handle - (PHP_INT_MAX >> 1)])) {
$cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0];
} else {
$firstSeen = false;
}
$cursor->hardRefTo = $refs[$r];
$cursor->hardRefHandle = $this->useRefHandles & $item->handle;
$cursor->hardRefCount = $item->refCount;
}
$cursor->attr = $item->attr;
$type = $item->class ?: \gettype($item->value);
$item = $this->getStub($item->value);
}
if ($item instanceof Stub) {
if ($item->refCount) {
if (!isset($refs[$r = $item->handle])) {
$cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0];
} else {
$firstSeen = false;
}
$cursor->softRefTo = $refs[$r];
}
$cursor->softRefHandle = $this->useRefHandles & $item->handle;
$cursor->softRefCount = $item->refCount;
$cursor->attr = $item->attr;
$cut = $item->cut;
if ($item->position && $firstSeen) {
$children = $this->data[$item->position];
if ($cursor->stop) {
if ($cut >= 0) {
$cut += \count($children);
}
$children = [];
}
} else {
$children = [];
}
switch ($item->type) {
case Stub::TYPE_STRING:
$dumper->dumpString($cursor, $item->value, Stub::STRING_BINARY === $item->class, $cut);
break;
case Stub::TYPE_ARRAY:
$item = clone $item;
$item->type = $item->class;
$item->class = $item->value;
// no break
case Stub::TYPE_OBJECT:
case Stub::TYPE_RESOURCE:
$withChildren = $children && $cursor->depth !== $this->maxDepth && $this->maxItemsPerDepth;
$dumper->enterHash($cursor, $item->type, $item->class, $withChildren);
if ($withChildren) {
if ($cursor->skipChildren) {
$withChildren = false;
$cut = -1;
} else {
$cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->type, null !== $item->class);
}
} elseif ($children && 0 <= $cut) {
$cut += \count($children);
}
$cursor->skipChildren = false;
$dumper->leaveHash($cursor, $item->type, $item->class, $withChildren, $cut);
break;
default:
throw new \RuntimeException(sprintf('Unexpected Stub type: %s', $item->type));
}
} elseif ('array' === $type) {
$dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false);
$dumper->leaveHash($cursor, Cursor::HASH_INDEXED, 0, false, 0);
} elseif ('string' === $type) {
$dumper->dumpString($cursor, $item, false, 0);
} else {
$dumper->dumpScalar($cursor, $type, $item);
}
} | php | private function dumpItem($dumper, $cursor, &$refs, $item)
{
$cursor->refIndex = 0;
$cursor->softRefTo = $cursor->softRefHandle = $cursor->softRefCount = 0;
$cursor->hardRefTo = $cursor->hardRefHandle = $cursor->hardRefCount = 0;
$firstSeen = true;
if (!$item instanceof Stub) {
$cursor->attr = [];
$type = \gettype($item);
if ($item && 'array' === $type) {
$item = $this->getStub($item);
}
} elseif (Stub::TYPE_REF === $item->type) {
if ($item->handle) {
if (!isset($refs[$r = $item->handle - (PHP_INT_MAX >> 1)])) {
$cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0];
} else {
$firstSeen = false;
}
$cursor->hardRefTo = $refs[$r];
$cursor->hardRefHandle = $this->useRefHandles & $item->handle;
$cursor->hardRefCount = $item->refCount;
}
$cursor->attr = $item->attr;
$type = $item->class ?: \gettype($item->value);
$item = $this->getStub($item->value);
}
if ($item instanceof Stub) {
if ($item->refCount) {
if (!isset($refs[$r = $item->handle])) {
$cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0];
} else {
$firstSeen = false;
}
$cursor->softRefTo = $refs[$r];
}
$cursor->softRefHandle = $this->useRefHandles & $item->handle;
$cursor->softRefCount = $item->refCount;
$cursor->attr = $item->attr;
$cut = $item->cut;
if ($item->position && $firstSeen) {
$children = $this->data[$item->position];
if ($cursor->stop) {
if ($cut >= 0) {
$cut += \count($children);
}
$children = [];
}
} else {
$children = [];
}
switch ($item->type) {
case Stub::TYPE_STRING:
$dumper->dumpString($cursor, $item->value, Stub::STRING_BINARY === $item->class, $cut);
break;
case Stub::TYPE_ARRAY:
$item = clone $item;
$item->type = $item->class;
$item->class = $item->value;
// no break
case Stub::TYPE_OBJECT:
case Stub::TYPE_RESOURCE:
$withChildren = $children && $cursor->depth !== $this->maxDepth && $this->maxItemsPerDepth;
$dumper->enterHash($cursor, $item->type, $item->class, $withChildren);
if ($withChildren) {
if ($cursor->skipChildren) {
$withChildren = false;
$cut = -1;
} else {
$cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->type, null !== $item->class);
}
} elseif ($children && 0 <= $cut) {
$cut += \count($children);
}
$cursor->skipChildren = false;
$dumper->leaveHash($cursor, $item->type, $item->class, $withChildren, $cut);
break;
default:
throw new \RuntimeException(sprintf('Unexpected Stub type: %s', $item->type));
}
} elseif ('array' === $type) {
$dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false);
$dumper->leaveHash($cursor, Cursor::HASH_INDEXED, 0, false, 0);
} elseif ('string' === $type) {
$dumper->dumpString($cursor, $item, false, 0);
} else {
$dumper->dumpScalar($cursor, $type, $item);
}
} | [
"private",
"function",
"dumpItem",
"(",
"$",
"dumper",
",",
"$",
"cursor",
",",
"&",
"$",
"refs",
",",
"$",
"item",
")",
"{",
"$",
"cursor",
"->",
"refIndex",
"=",
"0",
";",
"$",
"cursor",
"->",
"softRefTo",
"=",
"$",
"cursor",
"->",
"softRefHandle",... | Depth-first dumping of items.
@param DumperInterface $dumper The dumper being used for dumping
@param Cursor $cursor A cursor used for tracking dumper state position
@param array &$refs A map of all references discovered while dumping
@param mixed $item A Stub object or the original value being dumped | [
"Depth",
"-",
"first",
"dumping",
"of",
"items",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Cloner/Data.php#L276-L369 | train | Dumps an item | [
30522,
2797,
3853,
15653,
4221,
2213,
1006,
1002,
15653,
2121,
1010,
1002,
12731,
25301,
2099,
1010,
1004,
1002,
25416,
2015,
1010,
1002,
8875,
1007,
1063,
1002,
12731,
25301,
2099,
1011,
1028,
25416,
22254,
10288,
1027,
1014,
1025,
1002,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/behaviors/FormController.php | FormController.prepareVars | protected function prepareVars($model)
{
$this->controller->vars['formModel'] = $model;
$this->controller->vars['formContext'] = $this->formGetContext();
$this->controller->vars['formRecordName'] = Lang::get($this->getConfig('name', 'backend::lang.model.name'));
} | php | protected function prepareVars($model)
{
$this->controller->vars['formModel'] = $model;
$this->controller->vars['formContext'] = $this->formGetContext();
$this->controller->vars['formRecordName'] = Lang::get($this->getConfig('name', 'backend::lang.model.name'));
} | [
"protected",
"function",
"prepareVars",
"(",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"controller",
"->",
"vars",
"[",
"'formModel'",
"]",
"=",
"$",
"model",
";",
"$",
"this",
"->",
"controller",
"->",
"vars",
"[",
"'formContext'",
"]",
"=",
"$",
"th... | Prepares commonly used view data.
@param October\Rain\Database\Model $model | [
"Prepares",
"commonly",
"used",
"view",
"data",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/FormController.php#L185-L190 | train | Prepare form model context and record name | [
30522,
5123,
3853,
7374,
10755,
2015,
1006,
1002,
2944,
1007,
1063,
1002,
2023,
1011,
1028,
11486,
1011,
1028,
13075,
2015,
1031,
1005,
2433,
5302,
9247,
1005,
1033,
1027,
1002,
2944,
1025,
1002,
2023,
1011,
1028,
11486,
1011,
1028,
13075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.whereIntegerInRaw | public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false)
{
$type = $not ? 'NotInRaw' : 'InRaw';
if ($values instanceof Arrayable) {
$values = $values->toArray();
}
foreach ($values as &$value) {
$value = (int) $value;
}
$this->wheres[] = compact('type', 'column', 'values', 'boolean');
return $this;
} | php | public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false)
{
$type = $not ? 'NotInRaw' : 'InRaw';
if ($values instanceof Arrayable) {
$values = $values->toArray();
}
foreach ($values as &$value) {
$value = (int) $value;
}
$this->wheres[] = compact('type', 'column', 'values', 'boolean');
return $this;
} | [
"public",
"function",
"whereIntegerInRaw",
"(",
"$",
"column",
",",
"$",
"values",
",",
"$",
"boolean",
"=",
"'and'",
",",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"type",
"=",
"$",
"not",
"?",
"'NotInRaw'",
":",
"'InRaw'",
";",
"if",
"(",
"$",
"va... | Add a "where in raw" clause for integer values to the query.
@param string $column
@param \Illuminate\Contracts\Support\Arrayable|array $values
@param string $boolean
@param bool $not
@return $this | [
"Add",
"a",
"where",
"in",
"raw",
"clause",
"for",
"integer",
"values",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L966-L981 | train | Add where integer in raw | [
30522,
2270,
3853,
16726,
2618,
4590,
2378,
2527,
2860,
1006,
1002,
5930,
1010,
1002,
5300,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1010,
1002,
2025,
1027,
6270,
1007,
1063,
1002,
2828,
1027,
1002,
2025,
1029,
1005,
2025,
2378,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/LanguagesManager.php | LanguagesManager.setLanguageForSession | public static function setLanguageForSession($languageCode)
{
if (!API::getInstance()->isLanguageAvailable($languageCode)) {
return false;
}
$cookieName = Config::getInstance()->General['language_cookie_name'];
$cookie = new Cookie($cookieName, 0);
$cookie->set('language', $languageCode);
$cookie->setSecure(ProxyHttp::isHttps());
$cookie->save();
return true;
} | php | public static function setLanguageForSession($languageCode)
{
if (!API::getInstance()->isLanguageAvailable($languageCode)) {
return false;
}
$cookieName = Config::getInstance()->General['language_cookie_name'];
$cookie = new Cookie($cookieName, 0);
$cookie->set('language', $languageCode);
$cookie->setSecure(ProxyHttp::isHttps());
$cookie->save();
return true;
} | [
"public",
"static",
"function",
"setLanguageForSession",
"(",
"$",
"languageCode",
")",
"{",
"if",
"(",
"!",
"API",
"::",
"getInstance",
"(",
")",
"->",
"isLanguageAvailable",
"(",
"$",
"languageCode",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cook... | Set the language for the session
@param string $languageCode ISO language code
@return bool | [
"Set",
"the",
"language",
"for",
"the",
"session"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/LanguagesManager.php#L217-L229 | train | Set language for session | [
30522,
2270,
10763,
3853,
2275,
25023,
6692,
3351,
29278,
8583,
10992,
1006,
1002,
2653,
16044,
1007,
1063,
2065,
1006,
999,
17928,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
25340,
3070,
6692,
3351,
12462,
11733,
3468,
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 | plugins/UserCountry/LocationProvider/GeoIp/Php.php | Php.getLocation | public function getLocation($info)
{
$ip = $this->getIpFromInfo($info);
$isIPv6 = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
$result = array();
$locationGeoIp = $this->getGeoIpInstance($key = 'loc');
if ($locationGeoIp) {
switch ($locationGeoIp->databaseType) {
case GEOIP_CITY_EDITION_REV0: // city database type
case GEOIP_CITY_EDITION_REV1:
case GEOIP_CITYCOMBINED_EDITION:
if ($isIPv6) {
$location = geoip_record_by_addr_v6($locationGeoIp, $ip);
} else {
$location = geoip_record_by_addr($locationGeoIp, $ip);
}
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location->country_code;
$result[self::REGION_CODE_KEY] = $location->region;
$result[self::CITY_NAME_KEY] = utf8_encode($location->city);
$result[self::AREA_CODE_KEY] = $location->area_code;
$result[self::LATITUDE_KEY] = $location->latitude;
$result[self::LONGITUDE_KEY] = $location->longitude;
$result[self::POSTAL_CODE_KEY] = $location->postal_code;
}
break;
case GEOIP_REGION_EDITION_REV0: // region database type
case GEOIP_REGION_EDITION_REV1:
if ($isIPv6) {
// NOTE: geoip_region_by_addr_v6 does not exist (yet?), so we
// return the country code and an empty region code
$location = array(geoip_country_code_by_addr_v6($locationGeoIp, $ip), '');
} else {
$location = geoip_region_by_addr($locationGeoIp, $ip);
}
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location[0];
$result[self::REGION_CODE_KEY] = $location[1];
}
break;
case GEOIP_COUNTRY_EDITION: // country database type
if ($isIPv6) {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr_v6($locationGeoIp, $ip);
} else {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
}
break;
default: // unknown database type, log warning and fallback to country edition
Log::warning("Found unrecognized database type: %s", $locationGeoIp->databaseType);
if ($isIPv6) {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr_v6($locationGeoIp, $ip);
} else {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
}
break;
}
}
// NOTE: ISP & ORG require commercial dbs to test. The code has been tested manually,
// but not by system tests.
$ispGeoIp = $this->getGeoIpInstance($key = 'isp');
if ($ispGeoIp) {
if ($isIPv6) {
$isp = geoip_name_by_addr_v6($ispGeoIp, $ip);
} else {
$isp = geoip_org_by_addr($ispGeoIp, $ip);
}
if (!empty($isp)) {
$result[self::ISP_KEY] = utf8_encode($isp);
}
}
$orgGeoIp = $this->getGeoIpInstance($key = 'org');
if ($orgGeoIp) {
if ($isIPv6) {
$org = geoip_name_by_addr_v6($orgGeoIp, $ip);
} else {
$org = geoip_org_by_addr($orgGeoIp, $ip);
}
if (!empty($org)) {
$result[self::ORG_KEY] = utf8_encode($org);
}
}
if (empty($result)) {
return false;
}
$this->completeLocationResult($result);
return $result;
} | php | public function getLocation($info)
{
$ip = $this->getIpFromInfo($info);
$isIPv6 = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
$result = array();
$locationGeoIp = $this->getGeoIpInstance($key = 'loc');
if ($locationGeoIp) {
switch ($locationGeoIp->databaseType) {
case GEOIP_CITY_EDITION_REV0: // city database type
case GEOIP_CITY_EDITION_REV1:
case GEOIP_CITYCOMBINED_EDITION:
if ($isIPv6) {
$location = geoip_record_by_addr_v6($locationGeoIp, $ip);
} else {
$location = geoip_record_by_addr($locationGeoIp, $ip);
}
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location->country_code;
$result[self::REGION_CODE_KEY] = $location->region;
$result[self::CITY_NAME_KEY] = utf8_encode($location->city);
$result[self::AREA_CODE_KEY] = $location->area_code;
$result[self::LATITUDE_KEY] = $location->latitude;
$result[self::LONGITUDE_KEY] = $location->longitude;
$result[self::POSTAL_CODE_KEY] = $location->postal_code;
}
break;
case GEOIP_REGION_EDITION_REV0: // region database type
case GEOIP_REGION_EDITION_REV1:
if ($isIPv6) {
// NOTE: geoip_region_by_addr_v6 does not exist (yet?), so we
// return the country code and an empty region code
$location = array(geoip_country_code_by_addr_v6($locationGeoIp, $ip), '');
} else {
$location = geoip_region_by_addr($locationGeoIp, $ip);
}
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location[0];
$result[self::REGION_CODE_KEY] = $location[1];
}
break;
case GEOIP_COUNTRY_EDITION: // country database type
if ($isIPv6) {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr_v6($locationGeoIp, $ip);
} else {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
}
break;
default: // unknown database type, log warning and fallback to country edition
Log::warning("Found unrecognized database type: %s", $locationGeoIp->databaseType);
if ($isIPv6) {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr_v6($locationGeoIp, $ip);
} else {
$result[self::COUNTRY_CODE_KEY] = geoip_country_code_by_addr($locationGeoIp, $ip);
}
break;
}
}
// NOTE: ISP & ORG require commercial dbs to test. The code has been tested manually,
// but not by system tests.
$ispGeoIp = $this->getGeoIpInstance($key = 'isp');
if ($ispGeoIp) {
if ($isIPv6) {
$isp = geoip_name_by_addr_v6($ispGeoIp, $ip);
} else {
$isp = geoip_org_by_addr($ispGeoIp, $ip);
}
if (!empty($isp)) {
$result[self::ISP_KEY] = utf8_encode($isp);
}
}
$orgGeoIp = $this->getGeoIpInstance($key = 'org');
if ($orgGeoIp) {
if ($isIPv6) {
$org = geoip_name_by_addr_v6($orgGeoIp, $ip);
} else {
$org = geoip_org_by_addr($orgGeoIp, $ip);
}
if (!empty($org)) {
$result[self::ORG_KEY] = utf8_encode($org);
}
}
if (empty($result)) {
return false;
}
$this->completeLocationResult($result);
return $result;
} | [
"public",
"function",
"getLocation",
"(",
"$",
"info",
")",
"{",
"$",
"ip",
"=",
"$",
"this",
"->",
"getIpFromInfo",
"(",
"$",
"info",
")",
";",
"$",
"isIPv6",
"=",
"filter_var",
"(",
"$",
"ip",
",",
"FILTER_VALIDATE_IP",
",",
"FILTER_FLAG_IPV6",
")",
... | Uses a GeoIP database to get a visitor's location based on their IP address.
This function will return different results based on the data used. If a city
database is used, it may return the country code, region code, city name, area
code, latitude, longitude and postal code of the visitor.
Alternatively, if used with a country database, only the country code will be
returned.
@param array $info Must have an 'ip' field.
@return array | [
"Uses",
"a",
"GeoIP",
"database",
"to",
"get",
"a",
"visitor",
"s",
"location",
"based",
"on",
"their",
"IP",
"address",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/LocationProvider/GeoIp/Php.php#L95-L188 | train | Returns the location from the info | [
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,
30524,
2003,
11514,
2615,
2575,
1027,
11307,
1035,
13075,
1006,
1002,
12997,
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... |
symfony/symfony | src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php | FormDataExtractor.extractSubmittedData | public function extractSubmittedData(FormInterface $form)
{
$data = [
'submitted_data' => [
'norm' => $form->getNormData(),
],
'errors' => [],
];
if ($form->getViewData() !== $form->getNormData()) {
$data['submitted_data']['view'] = $form->getViewData();
}
if ($form->getData() !== $form->getNormData()) {
$data['submitted_data']['model'] = $form->getData();
}
foreach ($form->getErrors() as $error) {
$errorData = [
'message' => $error->getMessage(),
'origin' => \is_object($error->getOrigin())
? spl_object_hash($error->getOrigin())
: null,
'trace' => [],
];
$cause = $error->getCause();
while (null !== $cause) {
if ($cause instanceof ConstraintViolationInterface) {
$errorData['trace'][] = $cause;
$cause = method_exists($cause, 'getCause') ? $cause->getCause() : null;
continue;
}
if ($cause instanceof \Exception) {
$errorData['trace'][] = $cause;
$cause = $cause->getPrevious();
continue;
}
$errorData['trace'][] = $cause;
break;
}
$data['errors'][] = $errorData;
}
$data['synchronized'] = $form->isSynchronized();
return $data;
} | php | public function extractSubmittedData(FormInterface $form)
{
$data = [
'submitted_data' => [
'norm' => $form->getNormData(),
],
'errors' => [],
];
if ($form->getViewData() !== $form->getNormData()) {
$data['submitted_data']['view'] = $form->getViewData();
}
if ($form->getData() !== $form->getNormData()) {
$data['submitted_data']['model'] = $form->getData();
}
foreach ($form->getErrors() as $error) {
$errorData = [
'message' => $error->getMessage(),
'origin' => \is_object($error->getOrigin())
? spl_object_hash($error->getOrigin())
: null,
'trace' => [],
];
$cause = $error->getCause();
while (null !== $cause) {
if ($cause instanceof ConstraintViolationInterface) {
$errorData['trace'][] = $cause;
$cause = method_exists($cause, 'getCause') ? $cause->getCause() : null;
continue;
}
if ($cause instanceof \Exception) {
$errorData['trace'][] = $cause;
$cause = $cause->getPrevious();
continue;
}
$errorData['trace'][] = $cause;
break;
}
$data['errors'][] = $errorData;
}
$data['synchronized'] = $form->isSynchronized();
return $data;
} | [
"public",
"function",
"extractSubmittedData",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"data",
"=",
"[",
"'submitted_data'",
"=>",
"[",
"'norm'",
"=>",
"$",
"form",
"->",
"getNormData",
"(",
")",
",",
"]",
",",
"'errors'",
"=>",
"[",
"]",
",",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php#L79-L133 | train | Extract submitted data from form | [
30522,
2270,
3853,
27059,
12083,
22930,
3064,
2850,
2696,
1006,
2433,
18447,
2121,
12172,
1002,
2433,
1007,
1063,
1002,
2951,
1027,
1031,
1005,
7864,
1035,
2951,
1005,
1027,
1028,
1031,
1005,
13373,
1005,
1027,
1028,
1002,
2433,
1011,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Referrers/Referrers.php | Referrers.setGetAllHtmlPrefix | public function setGetAllHtmlPrefix($referrerType)
{
// get singular label for referrer type
$indexTranslation = '';
switch ($referrerType) {
case Common::REFERRER_TYPE_DIRECT_ENTRY:
$indexTranslation = 'Referrers_DirectEntry';
break;
case Common::REFERRER_TYPE_SEARCH_ENGINE:
$indexTranslation = 'General_ColumnKeyword';
break;
case Common::REFERRER_TYPE_SOCIAL_NETWORK:
$indexTranslation = 'Referrers_ColumnSocial';
break;
case Common::REFERRER_TYPE_WEBSITE:
$indexTranslation = 'Referrers_ColumnWebsite';
break;
case Common::REFERRER_TYPE_CAMPAIGN:
$indexTranslation = 'Referrers_ColumnCampaign';
break;
default:
// case of newsletter, partners, before Piwik 0.2.25
$indexTranslation = 'General_Others';
break;
}
$label = strtolower(Piwik::translate($indexTranslation));
// return html that displays it as grey & italic
return '<span class="datatable-label-category">(' . $label . ')</span>';
} | php | public function setGetAllHtmlPrefix($referrerType)
{
// get singular label for referrer type
$indexTranslation = '';
switch ($referrerType) {
case Common::REFERRER_TYPE_DIRECT_ENTRY:
$indexTranslation = 'Referrers_DirectEntry';
break;
case Common::REFERRER_TYPE_SEARCH_ENGINE:
$indexTranslation = 'General_ColumnKeyword';
break;
case Common::REFERRER_TYPE_SOCIAL_NETWORK:
$indexTranslation = 'Referrers_ColumnSocial';
break;
case Common::REFERRER_TYPE_WEBSITE:
$indexTranslation = 'Referrers_ColumnWebsite';
break;
case Common::REFERRER_TYPE_CAMPAIGN:
$indexTranslation = 'Referrers_ColumnCampaign';
break;
default:
// case of newsletter, partners, before Piwik 0.2.25
$indexTranslation = 'General_Others';
break;
}
$label = strtolower(Piwik::translate($indexTranslation));
// return html that displays it as grey & italic
return '<span class="datatable-label-category">(' . $label . ')</span>';
} | [
"public",
"function",
"setGetAllHtmlPrefix",
"(",
"$",
"referrerType",
")",
"{",
"// get singular label for referrer type",
"$",
"indexTranslation",
"=",
"''",
";",
"switch",
"(",
"$",
"referrerType",
")",
"{",
"case",
"Common",
"::",
"REFERRER_TYPE_DIRECT_ENTRY",
":"... | DataTable filter callback that returns the HTML prefix for a label in the
'getAll' report based on the row's referrer type.
@param int $referrerType The referrer type.
@return string | [
"DataTable",
"filter",
"callback",
"that",
"returns",
"the",
"HTML",
"prefix",
"for",
"a",
"label",
"in",
"the",
"getAll",
"report",
"based",
"on",
"the",
"row",
"s",
"referrer",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Referrers/Referrers.php#L101-L131 | train | Returns the html for the all columns of the referrer type | [
30522,
2270,
3853,
2275,
18150,
8095,
11039,
19968,
28139,
8873,
2595,
1006,
1002,
6523,
14544,
13874,
1007,
1063,
1013,
1013,
2131,
13048,
3830,
2005,
6523,
14544,
2828,
1002,
5950,
6494,
3619,
13490,
1027,
1005,
1005,
1025,
6942,
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... |
overtrue/wechat | src/OfficialAccount/DataCube/Client.php | Client.memberCardSummaryById | public function memberCardSummaryById(string $from, string $to, string $cardId)
{
$ext = [
'card_id' => $cardId,
];
return $this->query('datacube/getcardmembercarddetail', $from, $to, $ext);
} | php | public function memberCardSummaryById(string $from, string $to, string $cardId)
{
$ext = [
'card_id' => $cardId,
];
return $this->query('datacube/getcardmembercarddetail', $from, $to, $ext);
} | [
"public",
"function",
"memberCardSummaryById",
"(",
"string",
"$",
"from",
",",
"string",
"$",
"to",
",",
"string",
"$",
"cardId",
")",
"{",
"$",
"ext",
"=",
"[",
"'card_id'",
"=>",
"$",
"cardId",
",",
"]",
";",
"return",
"$",
"this",
"->",
"query",
... | 拉取单张会员卡数据接口.
@param string $from
@param string $to
@param string $cardId
@return mixed | [
"拉取单张会员卡数据接口",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/DataCube/Client.php#L309-L316 | train | Get member card summary by card id | [
30522,
2270,
3853,
2266,
17965,
2819,
7849,
2100,
3762,
3593,
1006,
5164,
1002,
2013,
1010,
5164,
1002,
2000,
1010,
5164,
1002,
4003,
3593,
1007,
1063,
1002,
4654,
2102,
1027,
1031,
1005,
4003,
1035,
8909,
1005,
1027,
1028,
1002,
4003,
35... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ComponentPartial.php | ComponentPartial.getFilePath | public function getFilePath($fileName = null)
{
if ($fileName === null) {
$fileName = $this->fileName;
}
$component = $this->component;
$path = $component->getPath().'/'.$fileName;
/*
* Check the shared "/partials" directory for the partial
*/
if (!File::isFile($path)) {
$sharedDir = dirname($component->getPath()).'/partials';
$sharedPath = $sharedDir.'/'.$fileName;
if (File::isFile($sharedPath)) {
return $sharedPath;
}
}
return $path;
} | php | public function getFilePath($fileName = null)
{
if ($fileName === null) {
$fileName = $this->fileName;
}
$component = $this->component;
$path = $component->getPath().'/'.$fileName;
/*
* Check the shared "/partials" directory for the partial
*/
if (!File::isFile($path)) {
$sharedDir = dirname($component->getPath()).'/partials';
$sharedPath = $sharedDir.'/'.$fileName;
if (File::isFile($sharedPath)) {
return $sharedPath;
}
}
return $path;
} | [
"public",
"function",
"getFilePath",
"(",
"$",
"fileName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"fileName",
"===",
"null",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"fileName",
";",
"}",
"$",
"component",
"=",
"$",
"this",
"->",
"component... | Returns the absolute file path.
@param string $fileName Specifies the file name to return the path to.
@return string | [
"Returns",
"the",
"absolute",
"file",
"path",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/ComponentPartial.php#L240-L261 | train | Get the full path to the partial file | [
30522,
2270,
3853,
2131,
8873,
2571,
15069,
1006,
1002,
5371,
18442,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
5371,
18442,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
5371,
18442,
1027,
1002,
2023,
1011,
1028,
5371,
18442,
1025,
1065,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Mailable.php | Mailable.buildViewData | public function buildViewData()
{
$data = $this->viewData;
if (static::$viewDataCallback) {
$data = array_merge($data, call_user_func(static::$viewDataCallback, $this));
}
foreach ((new ReflectionClass($this))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
if ($property->getDeclaringClass()->getName() !== self::class) {
$data[$property->getName()] = $property->getValue($this);
}
}
return $data;
} | php | public function buildViewData()
{
$data = $this->viewData;
if (static::$viewDataCallback) {
$data = array_merge($data, call_user_func(static::$viewDataCallback, $this));
}
foreach ((new ReflectionClass($this))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
if ($property->getDeclaringClass()->getName() !== self::class) {
$data[$property->getName()] = $property->getValue($this);
}
}
return $data;
} | [
"public",
"function",
"buildViewData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"viewData",
";",
"if",
"(",
"static",
"::",
"$",
"viewDataCallback",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"data",
",",
"call_user_func",
"(",
"st... | Build the view data for the message.
@return array
@throws \ReflectionException | [
"Build",
"the",
"view",
"data",
"for",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailable.php#L279-L294 | train | Build the viewData array | [
30522,
2270,
3853,
3857,
8584,
2850,
2696,
1006,
1007,
1063,
1002,
2951,
1027,
1002,
2023,
1011,
1028,
3193,
2850,
2696,
1025,
2065,
1006,
10763,
1024,
1024,
1002,
3193,
2850,
2696,
9289,
20850,
8684,
1007,
1063,
1002,
2951,
1027,
9140,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Data/Validation.php | Validation.typeMonth | public static function typeMonth($value, array $params, array $field)
{
if (!isset($params['format'])) {
$params['format'] = 'Y-m';
}
return self::typeDatetime($value, $params, $field);
} | php | public static function typeMonth($value, array $params, array $field)
{
if (!isset($params['format'])) {
$params['format'] = 'Y-m';
}
return self::typeDatetime($value, $params, $field);
} | [
"public",
"static",
"function",
"typeMonth",
"(",
"$",
"value",
",",
"array",
"$",
"params",
",",
"array",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'format'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'format'",
"]"... | HTML5 input: month
@param mixed $value Value to be validated.
@param array $params Validation parameters.
@param array $field Blueprint for the field.
@return bool True if validation succeeded. | [
"HTML5",
"input",
":",
"month"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Validation.php#L519-L526 | train | Type Month = > datetime | [
30522,
2270,
10763,
3853,
2828,
9629,
2232,
1006,
1002,
3643,
1010,
9140,
1002,
11498,
5244,
1010,
9140,
1002,
2492,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
11498,
5244,
1031,
1005,
4289,
1005,
1033,
1007,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpReceiver.php | AmqpReceiver.get | public function get(): iterable
{
foreach ($this->connection->getQueueNames() as $queueName) {
yield from $this->getEnvelope($queueName);
}
} | php | public function get(): iterable
{
foreach ($this->connection->getQueueNames() as $queueName) {
yield from $this->getEnvelope($queueName);
}
} | [
"public",
"function",
"get",
"(",
")",
":",
"iterable",
"{",
"foreach",
"(",
"$",
"this",
"->",
"connection",
"->",
"getQueueNames",
"(",
")",
"as",
"$",
"queueName",
")",
"{",
"yield",
"from",
"$",
"this",
"->",
"getEnvelope",
"(",
"$",
"queueName",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/AmqpExt/AmqpReceiver.php#L44-L49 | train | Get all messages in the queue | [
30522,
2270,
3853,
2131,
1006,
1007,
1024,
2009,
6906,
3468,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
4434,
1011,
1028,
2131,
4226,
24997,
14074,
2015,
1006,
1007,
2004,
1002,
24240,
18442,
1007,
1063,
10750,
2013,
1002,
2023,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Console/Scheduling/ManagesFrequencies.php | ManagesFrequencies.twiceDaily | public function twiceDaily($first = 1, $second = 13)
{
$hours = $first.','.$second;
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, $hours);
} | php | public function twiceDaily($first = 1, $second = 13)
{
$hours = $first.','.$second;
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, $hours);
} | [
"public",
"function",
"twiceDaily",
"(",
"$",
"first",
"=",
"1",
",",
"$",
"second",
"=",
"13",
")",
"{",
"$",
"hours",
"=",
"$",
"first",
".",
"','",
".",
"$",
"second",
";",
"return",
"$",
"this",
"->",
"spliceIntoPosition",
"(",
"1",
",",
"0",
... | Schedule the event to run twice daily.
@param int $first
@param int $second
@return $this | [
"Schedule",
"the",
"event",
"to",
"run",
"twice",
"daily",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/ManagesFrequencies.php#L178-L184 | train | This method is used to add the two times the same year. | [
30522,
2270,
3853,
3807,
21351,
2135,
1006,
1002,
2034,
1027,
1015,
1010,
1002,
2117,
1027,
2410,
1007,
1063,
1002,
2847,
1027,
1002,
2034,
1012,
1005,
1010,
1005,
1012,
1002,
2117,
1025,
2709,
1002,
2023,
1011,
1028,
11867,
13231,
18447,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php | ContentSecurityPolicyHandler.updateResponseHeaders | public function updateResponseHeaders(Request $request, Response $response)
{
if ($this->cspDisabled) {
$this->removeCspHeaders($response);
return [];
}
$nonces = $this->getNonces($request, $response);
$this->cleanHeaders($response);
$this->updateCspHeaders($response, $nonces);
return $nonces;
} | php | public function updateResponseHeaders(Request $request, Response $response)
{
if ($this->cspDisabled) {
$this->removeCspHeaders($response);
return [];
}
$nonces = $this->getNonces($request, $response);
$this->cleanHeaders($response);
$this->updateCspHeaders($response, $nonces);
return $nonces;
} | [
"public",
"function",
"updateResponseHeaders",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cspDisabled",
")",
"{",
"$",
"this",
"->",
"removeCspHeaders",
"(",
"$",
"response",
")",
";",
"return... | Cleanup temporary headers and updates Content-Security-Policy headers.
@return array Nonces used by the bundle in Content-Security-Policy header | [
"Cleanup",
"temporary",
"headers",
"and",
"updates",
"Content",
"-",
"Security",
"-",
"Policy",
"headers",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php#L86-L99 | train | Update response headers | [
30522,
2270,
3853,
10651,
6072,
26029,
3366,
4974,
2545,
1006,
5227,
1002,
5227,
1010,
3433,
1002,
3433,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
20116,
17299,
14268,
23242,
1007,
1063,
1002,
2023,
1011,
1028,
6366,
6169,
8458,
13775... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.setStrokeColor | function setStrokeColor($color, $force = false)
{
$new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
if (!$force && $this->currentStrokeColor == $new_color) {
return;
}
if (isset($new_color[3])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F K", $this->currentStrokeColor));
} else {
if (isset($new_color[2])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F RG", $this->currentStrokeColor));
}
}
} | php | function setStrokeColor($color, $force = false)
{
$new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
if (!$force && $this->currentStrokeColor == $new_color) {
return;
}
if (isset($new_color[3])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F K", $this->currentStrokeColor));
} else {
if (isset($new_color[2])) {
$this->currentStrokeColor = $new_color;
$this->addContent(vsprintf("\n%.3F %.3F %.3F RG", $this->currentStrokeColor));
}
}
} | [
"function",
"setStrokeColor",
"(",
"$",
"color",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"new_color",
"=",
"array",
"(",
"$",
"color",
"[",
"0",
"]",
",",
"$",
"color",
"[",
"1",
"]",
",",
"$",
"color",
"[",
"2",
"]",
",",
"isset",
"(",... | sets the color for stroke operations
@param $color
@param bool $force | [
"sets",
"the",
"color",
"for",
"stroke",
"operations"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3102-L3119 | train | Set the stroke color for the current page | [
30522,
3853,
4520,
13181,
3489,
18717,
1006,
1002,
3609,
1010,
1002,
2486,
1027,
6270,
1007,
1063,
1002,
2047,
1035,
3609,
1027,
9140,
1006,
1002,
3609,
1031,
1014,
1033,
1010,
1002,
3609,
1031,
1015,
1033,
1010,
1002,
3609,
1031,
1016,
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/Adapter/Mysqli.php | Zend_Db_Adapter_Mysqli._rollBack | protected function _rollBack()
{
$this->_connect();
$this->_connection->rollback();
$this->_connection->autocommit(true);
} | php | protected function _rollBack()
{
$this->_connect();
$this->_connection->rollback();
$this->_connection->autocommit(true);
} | [
"protected",
"function",
"_rollBack",
"(",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"$",
"this",
"->",
"_connection",
"->",
"rollback",
"(",
")",
";",
"$",
"this",
"->",
"_connection",
"->",
"autocommit",
"(",
"true",
")",
";",
"}"
] | Roll-back a transaction.
@return void | [
"Roll",
"-",
"back",
"a",
"transaction",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L477-L482 | train | rollBack - Rollback all transactions | [
30522,
5123,
3853,
1035,
4897,
5963,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
1035,
4434,
1011,
1028,
4897,
5963,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
1035,
4434,
1011,
1028,
828... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid.php | Grid.getExportUrl | public function getExportUrl($scope = 1, $args = null)
{
$input = array_merge(Input::all(), Exporter::formatExportQuery($scope, $args));
if ($constraints = $this->model()->getConstraints()) {
$input = array_merge($input, $constraints);
}
return $this->resource().'?'.http_build_query($input);
} | php | public function getExportUrl($scope = 1, $args = null)
{
$input = array_merge(Input::all(), Exporter::formatExportQuery($scope, $args));
if ($constraints = $this->model()->getConstraints()) {
$input = array_merge($input, $constraints);
}
return $this->resource().'?'.http_build_query($input);
} | [
"public",
"function",
"getExportUrl",
"(",
"$",
"scope",
"=",
"1",
",",
"$",
"args",
"=",
"null",
")",
"{",
"$",
"input",
"=",
"array_merge",
"(",
"Input",
"::",
"all",
"(",
")",
",",
"Exporter",
"::",
"formatExportQuery",
"(",
"$",
"scope",
",",
"$"... | Get the export url.
@param int $scope
@param null $args
@return string | [
"Get",
"the",
"export",
"url",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L651-L660 | train | Get Export URL | [
30522,
2270,
3853,
2131,
10288,
6442,
3126,
2140,
1006,
1002,
9531,
1027,
1015,
1010,
1002,
12098,
5620,
1027,
19701,
1007,
1063,
1002,
7953,
1027,
9140,
1035,
13590,
1006,
7953,
1024,
1024,
2035,
1006,
1007,
1010,
9167,
2121,
1024,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Twig/TwigExtension.php | TwigExtension.exifFunc | public function exifFunc($image, $raw = false)
{
if (isset($this->grav['exif'])) {
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
if ($locator->isStream($image)) {
$image = $locator->findResource($image);
}
$exif_reader = $this->grav['exif']->getReader();
if ($image & file_exists($image) && $this->config->get('system.media.auto_metadata_exif') && $exif_reader) {
$exif_data = $exif_reader->read($image);
if ($exif_data) {
if ($raw) {
return $exif_data->getRawData();
}
return $exif_data->getData();
}
}
}
return null;
} | php | public function exifFunc($image, $raw = false)
{
if (isset($this->grav['exif'])) {
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
if ($locator->isStream($image)) {
$image = $locator->findResource($image);
}
$exif_reader = $this->grav['exif']->getReader();
if ($image & file_exists($image) && $this->config->get('system.media.auto_metadata_exif') && $exif_reader) {
$exif_data = $exif_reader->read($image);
if ($exif_data) {
if ($raw) {
return $exif_data->getRawData();
}
return $exif_data->getData();
}
}
}
return null;
} | [
"public",
"function",
"exifFunc",
"(",
"$",
"image",
",",
"$",
"raw",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"grav",
"[",
"'exif'",
"]",
")",
")",
"{",
"/** @var UniformResourceLocator $locator */",
"$",
"locator",
"=",
"$",
... | Get's the Exif data for a file
@param string $image
@param bool $raw
@return mixed | [
"Get",
"s",
"the",
"Exif",
"data",
"for",
"a",
"file"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TwigExtension.php#L1145-L1172 | train | Return the Exif data of an image | [
30522,
2270,
3853,
4654,
13355,
4609,
2278,
1006,
1002,
3746,
1010,
1002,
6315,
1027,
6270,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
24665,
11431,
1031,
1005,
4654,
10128,
1005,
1033,
1007,
1007,
1063,
1013,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/PdoStore.php | PdoStore.save | public function save(Key $key)
{
$key->reduceLifetime($this->initialTtl);
$sql = "INSERT INTO $this->table ($this->idCol, $this->tokenCol, $this->expirationCol) VALUES (:id, :token, {$this->getCurrentTimestampStatement()} + $this->initialTtl)";
$stmt = $this->getConnection()->prepare($sql);
$stmt->bindValue(':id', $this->getHashedKey($key));
$stmt->bindValue(':token', $this->getUniqueToken($key));
try {
$stmt->execute();
if ($key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
}
return;
} catch (DBALException $e) {
// the lock is already acquired. It could be us. Let's try to put off.
$this->putOffExpiration($key, $this->initialTtl);
} catch (\PDOException $e) {
// the lock is already acquired. It could be us. Let's try to put off.
$this->putOffExpiration($key, $this->initialTtl);
}
if ($key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
}
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
$this->prune();
}
} | php | public function save(Key $key)
{
$key->reduceLifetime($this->initialTtl);
$sql = "INSERT INTO $this->table ($this->idCol, $this->tokenCol, $this->expirationCol) VALUES (:id, :token, {$this->getCurrentTimestampStatement()} + $this->initialTtl)";
$stmt = $this->getConnection()->prepare($sql);
$stmt->bindValue(':id', $this->getHashedKey($key));
$stmt->bindValue(':token', $this->getUniqueToken($key));
try {
$stmt->execute();
if ($key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to put off the expiration of the "%s" lock within the specified time.', $key));
}
return;
} catch (DBALException $e) {
// the lock is already acquired. It could be us. Let's try to put off.
$this->putOffExpiration($key, $this->initialTtl);
} catch (\PDOException $e) {
// the lock is already acquired. It could be us. Let's try to put off.
$this->putOffExpiration($key, $this->initialTtl);
}
if ($key->isExpired()) {
throw new LockExpiredException(sprintf('Failed to store the "%s" lock.', $key));
}
if ($this->gcProbability > 0 && (1.0 === $this->gcProbability || (random_int(0, PHP_INT_MAX) / PHP_INT_MAX) <= $this->gcProbability)) {
$this->prune();
}
} | [
"public",
"function",
"save",
"(",
"Key",
"$",
"key",
")",
"{",
"$",
"key",
"->",
"reduceLifetime",
"(",
"$",
"this",
"->",
"initialTtl",
")",
";",
"$",
"sql",
"=",
"\"INSERT INTO $this->table ($this->idCol, $this->tokenCol, $this->expirationCol) VALUES (:id, :token, {$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Store/PdoStore.php#L114-L146 | train | Save a lock | [
30522,
2270,
3853,
3828,
1006,
3145,
1002,
3145,
1007,
1063,
1002,
3145,
1011,
1028,
5547,
15509,
7292,
1006,
1002,
2023,
1011,
1028,
3988,
4779,
2140,
1007,
1025,
1002,
29296,
1027,
1000,
19274,
2046,
1002,
2023,
1011,
1028,
2795,
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/Serializer/Encoder/ChainEncoder.php | ChainEncoder.getEncoder | private function getEncoder(string $format, array $context): EncoderInterface
{
if (isset($this->encoderByFormat[$format])
&& isset($this->encoders[$this->encoderByFormat[$format]])
) {
return $this->encoders[$this->encoderByFormat[$format]];
}
foreach ($this->encoders as $i => $encoder) {
if ($encoder->supportsEncoding($format, $context)) {
$this->encoderByFormat[$format] = $i;
return $encoder;
}
}
throw new RuntimeException(sprintf('No encoder found for format "%s".', $format));
} | php | private function getEncoder(string $format, array $context): EncoderInterface
{
if (isset($this->encoderByFormat[$format])
&& isset($this->encoders[$this->encoderByFormat[$format]])
) {
return $this->encoders[$this->encoderByFormat[$format]];
}
foreach ($this->encoders as $i => $encoder) {
if ($encoder->supportsEncoding($format, $context)) {
$this->encoderByFormat[$format] = $i;
return $encoder;
}
}
throw new RuntimeException(sprintf('No encoder found for format "%s".', $format));
} | [
"private",
"function",
"getEncoder",
"(",
"string",
"$",
"format",
",",
"array",
"$",
"context",
")",
":",
"EncoderInterface",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"encoderByFormat",
"[",
"$",
"format",
"]",
")",
"&&",
"isset",
"(",
"$",
"t... | Gets the encoder supporting the format.
@throws RuntimeException if no encoder is found | [
"Gets",
"the",
"encoder",
"supporting",
"the",
"format",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Encoder/ChainEncoder.php#L85-L102 | train | Get encoder for given format and context. | [
30522,
2797,
3853,
2131,
2368,
16044,
2099,
1006,
5164,
1002,
4289,
1010,
9140,
1002,
6123,
1007,
1024,
4372,
16044,
6657,
3334,
12172,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
4372,
16044,
15185,
2100,
14192,
4017,
1031... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/TraceableMessageBus.php | TraceableMessageBus.dispatch | public function dispatch($message, array $stamps = []): Envelope
{
$envelope = Envelope::wrap($message, $stamps);
$context = [
'stamps' => array_values($envelope->all()),
'message' => $envelope->getMessage(),
'caller' => $this->getCaller(),
'callTime' => microtime(true),
];
try {
return $this->decoratedBus->dispatch($message, $stamps);
} catch (\Throwable $e) {
$context['exception'] = $e;
throw $e;
} finally {
$this->dispatchedMessages[] = $context;
}
} | php | public function dispatch($message, array $stamps = []): Envelope
{
$envelope = Envelope::wrap($message, $stamps);
$context = [
'stamps' => array_values($envelope->all()),
'message' => $envelope->getMessage(),
'caller' => $this->getCaller(),
'callTime' => microtime(true),
];
try {
return $this->decoratedBus->dispatch($message, $stamps);
} catch (\Throwable $e) {
$context['exception'] = $e;
throw $e;
} finally {
$this->dispatchedMessages[] = $context;
}
} | [
"public",
"function",
"dispatch",
"(",
"$",
"message",
",",
"array",
"$",
"stamps",
"=",
"[",
"]",
")",
":",
"Envelope",
"{",
"$",
"envelope",
"=",
"Envelope",
"::",
"wrap",
"(",
"$",
"message",
",",
"$",
"stamps",
")",
";",
"$",
"context",
"=",
"[... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/TraceableMessageBus.php#L32-L51 | train | Dispatches a message to the registered bus | [
30522,
2270,
3853,
18365,
1006,
1002,
4471,
1010,
9140,
1002,
12133,
1027,
1031,
1033,
1007,
1024,
11255,
1063,
1002,
11255,
1027,
11255,
1024,
1024,
10236,
1006,
1002,
4471,
1010,
1002,
12133,
1007,
1025,
1002,
6123,
1027,
1031,
1005,
1213... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/DatabaseUserProvider.php | DatabaseUserProvider.retrieveById | public function retrieveById($identifier)
{
$user = $this->conn->table($this->table)->find($identifier);
return $this->getGenericUser($user);
} | php | public function retrieveById($identifier)
{
$user = $this->conn->table($this->table)->find($identifier);
return $this->getGenericUser($user);
} | [
"public",
"function",
"retrieveById",
"(",
"$",
"identifier",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"conn",
"->",
"table",
"(",
"$",
"this",
"->",
"table",
")",
"->",
"find",
"(",
"$",
"identifier",
")",
";",
"return",
"$",
"this",
"->",
"... | Retrieve a user by their unique identifier.
@param mixed $identifier
@return \Illuminate\Contracts\Auth\Authenticatable|null | [
"Retrieve",
"a",
"user",
"by",
"their",
"unique",
"identifier",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/DatabaseUserProvider.php#L56-L61 | train | Retrieve a user by its identifier | [
30522,
2270,
3853,
12850,
3762,
3593,
1006,
1002,
8909,
4765,
18095,
1007,
1063,
1002,
5310,
1027,
1002,
2023,
1011,
1028,
9530,
2078,
1011,
1028,
2795,
1006,
1002,
2023,
1011,
1028,
2795,
1007,
1011,
1028,
2424,
1006,
1002,
8909,
4765,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/CmsObject.php | CmsObject.listInTheme | public static function listInTheme($theme, $skipCache = false)
{
$result = [];
$instance = static::inTheme($theme);
if ($skipCache) {
$result = $instance->get();
} else {
$items = $instance->newQuery()->lists('fileName');
$loadedItems = [];
foreach ($items as $item) {
$loadedItems[] = static::loadCached($theme, $item);
}
$result = $instance->newCollection($loadedItems);
}
/**
* @event cms.object.listInTheme
* Provides opportunity to filter the items returned by a call to CmsObject::listInTheme()
*
* Parameters provided are `$cmsObject` (the object being listed) and `$objectList` (a collection of the CmsObjects being returned).
* > Note: The `$objectList` provided is an object reference to a CmsObjectCollection, to make changes you must use object modifying methods.
*
* Example usage (filters all pages except for the 404 page on the CMS Maintenance mode settings page):
*
* // Extend only the Settings Controller
* \System\Controllers\Settings::extend(function($controller) {
* // Listen for the cms.object.listInTheme event
* \Event::listen('cms.object.listInTheme', function ($cmsObject, $objectList) {
* // Get the current context of the Settings Manager to ensure we only affect what we need to affect
* $context = \System\Classes\SettingsManager::instance()->getContext();
* if ($context->owner === 'october.cms' && $context->itemCode === 'maintenance_settings') {
* // Double check that this is a Page List that we're modifying
* if ($cmsObject instanceof \Cms\Classes\Page) {
* // Perform filtering with an original-object modifying method as $objectList is passed by reference (being that it's an object)
* foreach ($objectList as $index => $page) {
* if ($page->url !== '/404') {
* $objectList->forget($index);
* }
* }
* }
* }
* });
* });
*/
Event::fire('cms.object.listInTheme', [$instance, $result]);
return $result;
} | php | public static function listInTheme($theme, $skipCache = false)
{
$result = [];
$instance = static::inTheme($theme);
if ($skipCache) {
$result = $instance->get();
} else {
$items = $instance->newQuery()->lists('fileName');
$loadedItems = [];
foreach ($items as $item) {
$loadedItems[] = static::loadCached($theme, $item);
}
$result = $instance->newCollection($loadedItems);
}
/**
* @event cms.object.listInTheme
* Provides opportunity to filter the items returned by a call to CmsObject::listInTheme()
*
* Parameters provided are `$cmsObject` (the object being listed) and `$objectList` (a collection of the CmsObjects being returned).
* > Note: The `$objectList` provided is an object reference to a CmsObjectCollection, to make changes you must use object modifying methods.
*
* Example usage (filters all pages except for the 404 page on the CMS Maintenance mode settings page):
*
* // Extend only the Settings Controller
* \System\Controllers\Settings::extend(function($controller) {
* // Listen for the cms.object.listInTheme event
* \Event::listen('cms.object.listInTheme', function ($cmsObject, $objectList) {
* // Get the current context of the Settings Manager to ensure we only affect what we need to affect
* $context = \System\Classes\SettingsManager::instance()->getContext();
* if ($context->owner === 'october.cms' && $context->itemCode === 'maintenance_settings') {
* // Double check that this is a Page List that we're modifying
* if ($cmsObject instanceof \Cms\Classes\Page) {
* // Perform filtering with an original-object modifying method as $objectList is passed by reference (being that it's an object)
* foreach ($objectList as $index => $page) {
* if ($page->url !== '/404') {
* $objectList->forget($index);
* }
* }
* }
* }
* });
* });
*/
Event::fire('cms.object.listInTheme', [$instance, $result]);
return $result;
} | [
"public",
"static",
"function",
"listInTheme",
"(",
"$",
"theme",
",",
"$",
"skipCache",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"instance",
"=",
"static",
"::",
"inTheme",
"(",
"$",
"theme",
")",
";",
"if",
"(",
"$",
"skipC... | Returns the list of objects in the specified theme.
This method is used internally by the system.
@param \Cms\Classes\Theme $theme Specifies a parent theme.
@param boolean $skipCache Indicates if objects should be reloaded from the disk bypassing the cache.
@return Collection Returns a collection of CMS objects. | [
"Returns",
"the",
"list",
"of",
"objects",
"in",
"the",
"specified",
"theme",
".",
"This",
"method",
"is",
"used",
"internally",
"by",
"the",
"system",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/CmsObject.php#L121-L171 | train | Returns all the CMS objects in a given theme. | [
30522,
2270,
10763,
3853,
2862,
18447,
29122,
2063,
1006,
1002,
4323,
1010,
1002,
13558,
3540,
5403,
1027,
6270,
1007,
1063,
1002,
2765,
1027,
1031,
1033,
1025,
1002,
6013,
1027,
10763,
1024,
1024,
20014,
29122,
2063,
1006,
1002,
4323,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.