repo stringclasses 21 values | path stringlengths 10 105 | func_name stringlengths 6 64 | original_string stringlengths 105 15.6k | language stringclasses 1 value | code stringlengths 105 15.6k | code_tokens listlengths 29 2.15k | docstring stringlengths 11 2.85k | docstring_tokens listlengths 1 290 | sha stringclasses 21 values | url stringlengths 100 194 | partition stringclasses 1 value | summary stringlengths 8 319 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getgrav/grav | system/src/Grav/Console/ConsoleCommand.php | ConsoleCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$this->serve();
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$this->serve();
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"setupConsole",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"this",
"->",
"serve",
"(",
")",
";",
"}"... | @param InputInterface $input
@param OutputInterface $output
@return int|null|void | [
"@param",
"InputInterface",
"$input",
"@param",
"OutputInterface",
"$output"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/ConsoleCommand.php#L27-L31 | train | Execute the command | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
2023,
1011,
1028,
16437,
8663,
19454,
2063,
1006,
1002,
7953,
1010,
1002,
6434,
1007,
1025,
1002,
2023,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/MailManager.php | MailManager.registerMailTemplates | public function registerMailTemplates(array $definitions)
{
if (!$this->registeredTemplates) {
$this->registeredTemplates = [];
}
// Prior sytax where (key) code => (value) description
if (!isset($definitions[0])) {
$definitions = array_keys($definitions);
}
$definitions = array_combine($definitions, $definitions);
$this->registeredTemplates = $definitions + $this->registeredTemplates;
} | php | public function registerMailTemplates(array $definitions)
{
if (!$this->registeredTemplates) {
$this->registeredTemplates = [];
}
// Prior sytax where (key) code => (value) description
if (!isset($definitions[0])) {
$definitions = array_keys($definitions);
}
$definitions = array_combine($definitions, $definitions);
$this->registeredTemplates = $definitions + $this->registeredTemplates;
} | [
"public",
"function",
"registerMailTemplates",
"(",
"array",
"$",
"definitions",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"registeredTemplates",
")",
"{",
"$",
"this",
"->",
"registeredTemplates",
"=",
"[",
"]",
";",
"}",
"// Prior sytax where (key) code => ... | Registers mail views and manageable templates. | [
"Registers",
"mail",
"views",
"and",
"manageable",
"templates",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MailManager.php#L419-L433 | train | Register mail templates | [
30522,
2270,
3853,
4236,
21397,
18532,
15725,
2015,
1006,
9140,
1002,
15182,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
5068,
18532,
15725,
2015,
1007,
1063,
1002,
2023,
1011,
1028,
5068,
18532,
15725,
2015,
1027,
1031,
1033,
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... |
octobercms/october | modules/backend/behaviors/ListController.php | ListController.makeList | public function makeList($definition = null)
{
if (!$definition || !isset($this->listDefinitions[$definition])) {
$definition = $this->primaryDefinition;
}
$listConfig = $this->controller->listGetConfig($definition);
/*
* Create the model
*/
$class = $listConfig->modelClass;
$model = new $class;
$model = $this->controller->listExtendModel($model, $definition);
/*
* Prepare the list widget
*/
$columnConfig = $this->makeConfig($listConfig->list);
$columnConfig->model = $model;
$columnConfig->alias = $definition;
/*
* Prepare the columns configuration
*/
$configFieldsToTransfer = [
'recordUrl',
'recordOnClick',
'recordsPerPage',
'showPageNumbers',
'noRecordsMessage',
'defaultSort',
'showSorting',
'showSetup',
'showCheckboxes',
'showTree',
'treeExpanded',
'customViewPath',
];
foreach ($configFieldsToTransfer as $field) {
if (isset($listConfig->{$field})) {
$columnConfig->{$field} = $listConfig->{$field};
}
}
/*
* List Widget with extensibility
*/
$widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig);
$widget->bindEvent('list.extendColumns', function () use ($widget) {
$this->controller->listExtendColumns($widget);
});
$widget->bindEvent('list.extendQueryBefore', function ($query) use ($definition) {
$this->controller->listExtendQueryBefore($query, $definition);
});
$widget->bindEvent('list.extendQuery', function ($query) use ($definition) {
$this->controller->listExtendQuery($query, $definition);
});
$widget->bindEvent('list.extendRecords', function ($records) use ($definition) {
return $this->controller->listExtendRecords($records, $definition);
});
$widget->bindEvent('list.injectRowClass', function ($record) use ($definition) {
return $this->controller->listInjectRowClass($record, $definition);
});
$widget->bindEvent('list.overrideColumnValue', function ($record, $column, $value) use ($definition) {
return $this->controller->listOverrideColumnValue($record, $column->columnName, $definition);
});
$widget->bindEvent('list.overrideHeaderValue', function ($column, $value) use ($definition) {
return $this->controller->listOverrideHeaderValue($column->columnName, $definition);
});
$widget->bindToController();
/*
* Prepare the toolbar widget (optional)
*/
if (isset($listConfig->toolbar)) {
$toolbarConfig = $this->makeConfig($listConfig->toolbar);
$toolbarConfig->alias = $widget->alias . 'Toolbar';
$toolbarWidget = $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig);
$toolbarWidget->bindToController();
$toolbarWidget->cssClasses[] = 'list-header';
/*
* Link the Search Widget to the List Widget
*/
if ($searchWidget = $toolbarWidget->getSearchWidget()) {
$searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) {
$widget->setSearchTerm($searchWidget->getActiveTerm());
return $widget->onRefresh();
});
$widget->setSearchOptions([
'mode' => $searchWidget->mode,
'scope' => $searchWidget->scope,
]);
// Find predefined search term
$widget->setSearchTerm($searchWidget->getActiveTerm());
}
$this->toolbarWidgets[$definition] = $toolbarWidget;
}
/*
* Prepare the filter widget (optional)
*/
if (isset($listConfig->filter)) {
$widget->cssClasses[] = 'list-flush';
$filterConfig = $this->makeConfig($listConfig->filter);
$filterConfig->alias = $widget->alias . 'Filter';
$filterWidget = $this->makeWidget('Backend\Widgets\Filter', $filterConfig);
$filterWidget->bindToController();
/*
* Filter the list when the scopes are changed
*/
$filterWidget->bindEvent('filter.update', function () use ($widget, $filterWidget) {
return $widget->onFilter();
});
/*
* Filter Widget with extensibility
*/
$filterWidget->bindEvent('filter.extendScopes', function () use ($filterWidget) {
$this->controller->listFilterExtendScopes($filterWidget);
});
/*
* Extend the query of the list of options
*/
$filterWidget->bindEvent('filter.extendQuery', function ($query, $scope) {
$this->controller->listFilterExtendQuery($query, $scope);
});
// Apply predefined filter values
$widget->addFilter([$filterWidget, 'applyAllScopesToQuery']);
$this->filterWidgets[$definition] = $filterWidget;
}
return $widget;
} | php | public function makeList($definition = null)
{
if (!$definition || !isset($this->listDefinitions[$definition])) {
$definition = $this->primaryDefinition;
}
$listConfig = $this->controller->listGetConfig($definition);
/*
* Create the model
*/
$class = $listConfig->modelClass;
$model = new $class;
$model = $this->controller->listExtendModel($model, $definition);
/*
* Prepare the list widget
*/
$columnConfig = $this->makeConfig($listConfig->list);
$columnConfig->model = $model;
$columnConfig->alias = $definition;
/*
* Prepare the columns configuration
*/
$configFieldsToTransfer = [
'recordUrl',
'recordOnClick',
'recordsPerPage',
'showPageNumbers',
'noRecordsMessage',
'defaultSort',
'showSorting',
'showSetup',
'showCheckboxes',
'showTree',
'treeExpanded',
'customViewPath',
];
foreach ($configFieldsToTransfer as $field) {
if (isset($listConfig->{$field})) {
$columnConfig->{$field} = $listConfig->{$field};
}
}
/*
* List Widget with extensibility
*/
$widget = $this->makeWidget('Backend\Widgets\Lists', $columnConfig);
$widget->bindEvent('list.extendColumns', function () use ($widget) {
$this->controller->listExtendColumns($widget);
});
$widget->bindEvent('list.extendQueryBefore', function ($query) use ($definition) {
$this->controller->listExtendQueryBefore($query, $definition);
});
$widget->bindEvent('list.extendQuery', function ($query) use ($definition) {
$this->controller->listExtendQuery($query, $definition);
});
$widget->bindEvent('list.extendRecords', function ($records) use ($definition) {
return $this->controller->listExtendRecords($records, $definition);
});
$widget->bindEvent('list.injectRowClass', function ($record) use ($definition) {
return $this->controller->listInjectRowClass($record, $definition);
});
$widget->bindEvent('list.overrideColumnValue', function ($record, $column, $value) use ($definition) {
return $this->controller->listOverrideColumnValue($record, $column->columnName, $definition);
});
$widget->bindEvent('list.overrideHeaderValue', function ($column, $value) use ($definition) {
return $this->controller->listOverrideHeaderValue($column->columnName, $definition);
});
$widget->bindToController();
/*
* Prepare the toolbar widget (optional)
*/
if (isset($listConfig->toolbar)) {
$toolbarConfig = $this->makeConfig($listConfig->toolbar);
$toolbarConfig->alias = $widget->alias . 'Toolbar';
$toolbarWidget = $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig);
$toolbarWidget->bindToController();
$toolbarWidget->cssClasses[] = 'list-header';
/*
* Link the Search Widget to the List Widget
*/
if ($searchWidget = $toolbarWidget->getSearchWidget()) {
$searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) {
$widget->setSearchTerm($searchWidget->getActiveTerm());
return $widget->onRefresh();
});
$widget->setSearchOptions([
'mode' => $searchWidget->mode,
'scope' => $searchWidget->scope,
]);
// Find predefined search term
$widget->setSearchTerm($searchWidget->getActiveTerm());
}
$this->toolbarWidgets[$definition] = $toolbarWidget;
}
/*
* Prepare the filter widget (optional)
*/
if (isset($listConfig->filter)) {
$widget->cssClasses[] = 'list-flush';
$filterConfig = $this->makeConfig($listConfig->filter);
$filterConfig->alias = $widget->alias . 'Filter';
$filterWidget = $this->makeWidget('Backend\Widgets\Filter', $filterConfig);
$filterWidget->bindToController();
/*
* Filter the list when the scopes are changed
*/
$filterWidget->bindEvent('filter.update', function () use ($widget, $filterWidget) {
return $widget->onFilter();
});
/*
* Filter Widget with extensibility
*/
$filterWidget->bindEvent('filter.extendScopes', function () use ($filterWidget) {
$this->controller->listFilterExtendScopes($filterWidget);
});
/*
* Extend the query of the list of options
*/
$filterWidget->bindEvent('filter.extendQuery', function ($query, $scope) {
$this->controller->listFilterExtendQuery($query, $scope);
});
// Apply predefined filter values
$widget->addFilter([$filterWidget, 'applyAllScopesToQuery']);
$this->filterWidgets[$definition] = $filterWidget;
}
return $widget;
} | [
"public",
"function",
"makeList",
"(",
"$",
"definition",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"definition",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"listDefinitions",
"[",
"$",
"definition",
"]",
")",
")",
"{",
"$",
"definition",
"=",
"$"... | Prepare the widgets used by this action
@return void | [
"Prepare",
"the",
"widgets",
"used",
"by",
"this",
"action"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/ListController.php#L114-L265 | train | Create the list object | [
30522,
2270,
3853,
2191,
9863,
1006,
1002,
6210,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1002,
6210,
1064,
1064,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2862,
3207,
16294,
22753,
2015,
1031,
1002,
6210,
1033,
1007,
1007,
1063,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Builder.php | Builder.options | public function options($options = [])
{
if (empty($options)) {
return $this->options;
}
$this->options = array_merge($this->options, $options);
} | php | public function options($options = [])
{
if (empty($options)) {
return $this->options;
}
$this->options = array_merge($this->options, $options);
} | [
"public",
"function",
"options",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"return",
"$",
"this",
"->",
"options",
";",
"}",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"(",
"$",
"... | Add or get options.
@param array $options
@return array|null | [
"Add",
"or",
"get",
"options",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Builder.php#L387-L394 | train | Options for the current language | [
30522,
2270,
3853,
7047,
1006,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
7047,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7047,
1025,
1065,
1002,
2023,
1011,
1028,
7047,
1027,
9140,
1035,
13590,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('debug');
$rootNode = $treeBuilder->getRootNode();
$rootNode->children()
->integerNode('max_items')
->info('Max number of displayed items past the first level, -1 means no limit')
->min(-1)
->defaultValue(2500)
->end()
->integerNode('min_depth')
->info('Minimum tree depth to clone all the items, 1 is default')
->min(0)
->defaultValue(1)
->end()
->integerNode('max_string_length')
->info('Max length of displayed strings, -1 means no limit')
->min(-1)
->defaultValue(-1)
->end()
->scalarNode('dump_destination')
->info('A stream URL where dumps should be written to')
->example('php://stderr, or tcp://%env(VAR_DUMPER_SERVER)% when using the "server:dump" command')
->defaultNull()
->end()
->end()
;
if (method_exists(HtmlDumper::class, 'setTheme')) {
$rootNode
->children()
->enumNode('theme')
->info('Changes the color of the dump() output when rendered directly on the templating. "dark" (default) or "light"')
->example('dark')
->values(['dark', 'light'])
->defaultValue('dark')
->end()
->end()
;
}
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('debug');
$rootNode = $treeBuilder->getRootNode();
$rootNode->children()
->integerNode('max_items')
->info('Max number of displayed items past the first level, -1 means no limit')
->min(-1)
->defaultValue(2500)
->end()
->integerNode('min_depth')
->info('Minimum tree depth to clone all the items, 1 is default')
->min(0)
->defaultValue(1)
->end()
->integerNode('max_string_length')
->info('Max length of displayed strings, -1 means no limit')
->min(-1)
->defaultValue(-1)
->end()
->scalarNode('dump_destination')
->info('A stream URL where dumps should be written to')
->example('php://stderr, or tcp://%env(VAR_DUMPER_SERVER)% when using the "server:dump" command')
->defaultNull()
->end()
->end()
;
if (method_exists(HtmlDumper::class, 'setTheme')) {
$rootNode
->children()
->enumNode('theme')
->info('Changes the color of the dump() output when rendered directly on the templating. "dark" (default) or "light"')
->example('dark')
->values(['dark', 'light'])
->defaultValue('dark')
->end()
->end()
;
}
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
"'debug'",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"getRootNode",
"(",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/DebugBundle/DependencyInjection/Configuration.php#L28-L71 | train | Returns the tree builder | [
30522,
2270,
3853,
2131,
30524,
1006,
1005,
2139,
8569,
2290,
1005,
1007,
1025,
1002,
7117,
3630,
3207,
1027,
1002,
3392,
8569,
23891,
2099,
1011,
1028,
2131,
3217,
4140,
3630,
3207,
1006,
1007,
1025,
1002,
7117,
3630,
3207,
1011,
1028,
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... |
getgrav/grav | system/src/Grav/Framework/Filesystem/Filesystem.php | Filesystem.dirname | public function dirname(string $path, int $levels = 1): string
{
[$scheme, $path] = $this->getSchemeAndHierarchy($path);
if ($this->normalize || ($scheme && null === $this->normalize)) {
$path = $this->normalizePathPart($path);
}
[$scheme, $path] = $this->dirnameInternal($scheme, $path, $levels);
return $this->toString($scheme, $path);
} | php | public function dirname(string $path, int $levels = 1): string
{
[$scheme, $path] = $this->getSchemeAndHierarchy($path);
if ($this->normalize || ($scheme && null === $this->normalize)) {
$path = $this->normalizePathPart($path);
}
[$scheme, $path] = $this->dirnameInternal($scheme, $path, $levels);
return $this->toString($scheme, $path);
} | [
"public",
"function",
"dirname",
"(",
"string",
"$",
"path",
",",
"int",
"$",
"levels",
"=",
"1",
")",
":",
"string",
"{",
"[",
"$",
"scheme",
",",
"$",
"path",
"]",
"=",
"$",
"this",
"->",
"getSchemeAndHierarchy",
"(",
"$",
"path",
")",
";",
"if",... | {@inheritdoc}
@see FilesystemInterface::dirname() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Filesystem/Filesystem.php#L136-L147 | train | Return the directory path of the given path | [
30522,
2270,
3853,
16101,
18442,
1006,
5164,
1002,
4130,
1010,
20014,
1002,
3798,
1027,
1015,
1007,
1024,
5164,
1063,
1031,
1002,
5679,
1010,
1002,
4130,
1033,
1027,
1002,
2023,
1011,
1028,
4152,
5403,
4168,
5685,
4048,
6906,
29389,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.isValidMetricForReport | public function isValidMetricForReport($metric, $idSite, $apiMethodUniqueId)
{
$translation = $this->translateMetric($metric, $idSite, $apiMethodUniqueId);
return !empty($translation);
} | php | public function isValidMetricForReport($metric, $idSite, $apiMethodUniqueId)
{
$translation = $this->translateMetric($metric, $idSite, $apiMethodUniqueId);
return !empty($translation);
} | [
"public",
"function",
"isValidMetricForReport",
"(",
"$",
"metric",
",",
"$",
"idSite",
",",
"$",
"apiMethodUniqueId",
")",
"{",
"$",
"translation",
"=",
"$",
"this",
"->",
"translateMetric",
"(",
"$",
"metric",
",",
"$",
"idSite",
",",
"$",
"apiMethodUnique... | Verfies whether the given metric belongs to the given report.
@param int $idSite
@param string $metric For example 'nb_visits'
@param string $apiMethodUniqueId For example 'MultiSites_getAll'
@return bool | [
"Verfies",
"whether",
"the",
"given",
"metric",
"belongs",
"to",
"the",
"given",
"report",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/ProcessedReport.php#L118-L123 | train | Checks if a metric is valid for a report | [
30522,
2270,
3853,
2003,
10175,
3593,
12589,
29278,
2890,
6442,
1006,
1002,
12046,
1010,
1002,
8909,
28032,
2063,
1010,
1002,
17928,
11368,
6806,
27584,
7413,
3593,
1007,
1063,
1002,
5449,
1027,
1002,
2023,
1011,
1028,
17637,
12589,
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... |
z-song/laravel-admin | src/Show.php | Show.render | public function render()
{
if (is_callable($this->builder)) {
call_user_func($this->builder, $this);
}
if ($this->fields->isEmpty()) {
$this->all();
}
if (is_array($this->builder)) {
$this->fields($this->builder);
}
$this->fields->each->setValue($this->model);
$this->relations->each->setModel($this->model);
$data = [
'panel' => $this->panel->fill($this->fields),
'relations' => $this->relations,
];
return view('admin::show', $data)->render();
} | php | public function render()
{
if (is_callable($this->builder)) {
call_user_func($this->builder, $this);
}
if ($this->fields->isEmpty()) {
$this->all();
}
if (is_array($this->builder)) {
$this->fields($this->builder);
}
$this->fields->each->setValue($this->model);
$this->relations->each->setModel($this->model);
$data = [
'panel' => $this->panel->fill($this->fields),
'relations' => $this->relations,
];
return view('admin::show', $data)->render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"builder",
")",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"builder",
",",
"$",
"this",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"fields",... | Render the show panels.
@return string | [
"Render",
"the",
"show",
"panels",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Show.php#L504-L527 | train | Render the show action | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
2655,
3085,
1006,
1002,
2023,
1011,
1028,
12508,
1007,
1007,
1063,
2655,
1035,
5310,
1035,
4569,
2278,
1006,
1002,
2023,
1011,
1028,
12508,
1010,
1002,
2023,
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... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.getSearchableColumns | protected function getSearchableColumns()
{
$columns = $this->getColumns();
$searchable = [];
foreach ($columns as $column) {
if (!$column->searchable) {
continue;
}
$searchable[] = $column;
}
return $searchable;
} | php | protected function getSearchableColumns()
{
$columns = $this->getColumns();
$searchable = [];
foreach ($columns as $column) {
if (!$column->searchable) {
continue;
}
$searchable[] = $column;
}
return $searchable;
} | [
"protected",
"function",
"getSearchableColumns",
"(",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
")",
";",
"$",
"searchable",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"!",... | Returns a collection of columns which can be searched.
@return array | [
"Returns",
"a",
"collection",
"of",
"columns",
"which",
"can",
"be",
"searched",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1419-L1433 | train | Get searchable columns | [
30522,
5123,
3853,
4152,
14644,
7507,
3468,
25778,
2819,
3619,
1006,
1007,
1063,
1002,
7753,
1027,
1002,
2023,
1011,
1028,
2131,
25778,
2819,
30524,
1002,
3945,
3085,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.getSessionKey | public function getSessionKey()
{
if ($this->sessionKey) {
return $this->sessionKey;
}
if (post('_session_key')) {
return $this->sessionKey = post('_session_key');
}
return $this->sessionKey = FormHelper::getSessionKey();
} | php | public function getSessionKey()
{
if ($this->sessionKey) {
return $this->sessionKey;
}
if (post('_session_key')) {
return $this->sessionKey = post('_session_key');
}
return $this->sessionKey = FormHelper::getSessionKey();
} | [
"public",
"function",
"getSessionKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sessionKey",
")",
"{",
"return",
"$",
"this",
"->",
"sessionKey",
";",
"}",
"if",
"(",
"post",
"(",
"'_session_key'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"se... | Returns the active session key.
@return \Illuminate\Routing\Route|mixed|string | [
"Returns",
"the",
"active",
"session",
"key",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L1293-L1304 | train | Get Session Key | [
30522,
2270,
3853,
4152,
7971,
3258,
14839,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5219,
14839,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5219,
14839,
1025,
1065,
2065,
1006,
2695,
1006,
1005,
1035,
5219,
1035,
3145,
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... |
octobercms/october | modules/cms/classes/CmsException.php | CmsException.processIni | protected function processIni(Exception $exception)
{
$message = $exception->getMessage();
/*
* Expecting: syntax error, unexpected '!' in Unknown on line 4
*/
if (!starts_with($message, 'syntax error')) {
return false;
}
if (strpos($message, 'Unknown') === false) {
return false;
}
if (strpos($exception->getFile(), 'Ini.php') === false) {
return false;
}
/*
* Line number from parse_ini_string() error.
* The last word should contain the line number.
*/
$parts = explode(' ', $message);
$line = array_pop($parts);
$this->line = (int)$line;
// Find where the ini settings section begins
$offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
$this->line += $offsetArray['settings'];
$this->message = $message;
// Account for line 0
$this->line--;
return true;
} | php | protected function processIni(Exception $exception)
{
$message = $exception->getMessage();
/*
* Expecting: syntax error, unexpected '!' in Unknown on line 4
*/
if (!starts_with($message, 'syntax error')) {
return false;
}
if (strpos($message, 'Unknown') === false) {
return false;
}
if (strpos($exception->getFile(), 'Ini.php') === false) {
return false;
}
/*
* Line number from parse_ini_string() error.
* The last word should contain the line number.
*/
$parts = explode(' ', $message);
$line = array_pop($parts);
$this->line = (int)$line;
// Find where the ini settings section begins
$offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
$this->line += $offsetArray['settings'];
$this->message = $message;
// Account for line 0
$this->line--;
return true;
} | [
"protected",
"function",
"processIni",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"message",
"=",
"$",
"exception",
"->",
"getMessage",
"(",
")",
";",
"/*\n * Expecting: syntax error, unexpected '!' in Unknown on line 4\n */",
"if",
"(",
"!",
"st... | Override properties of an exception specific to the INI section
of a CMS object.
@param \Exception $exception The exception to modify.
@return bool | [
"Override",
"properties",
"of",
"an",
"exception",
"specific",
"to",
"the",
"INI",
"section",
"of",
"a",
"CMS",
"object",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/CmsException.php#L100-L135 | train | Process the ini error | [
30522,
5123,
3853,
2832,
5498,
1006,
6453,
1002,
6453,
1007,
1063,
1002,
4471,
1027,
1002,
6453,
1011,
1028,
2131,
7834,
3736,
3351,
1006,
1007,
1025,
1013,
1008,
1008,
8074,
1024,
20231,
7561,
1010,
9223,
1005,
999,
1005,
1999,
4242,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/FilesystemAdapter.php | FilesystemAdapter.directories | public function directories($directory = null, $recursive = false)
{
$contents = $this->driver->listContents($directory, $recursive);
return $this->filterContentsByType($contents, 'dir');
} | php | public function directories($directory = null, $recursive = false)
{
$contents = $this->driver->listContents($directory, $recursive);
return $this->filterContentsByType($contents, 'dir');
} | [
"public",
"function",
"directories",
"(",
"$",
"directory",
"=",
"null",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"$",
"contents",
"=",
"$",
"this",
"->",
"driver",
"->",
"listContents",
"(",
"$",
"directory",
",",
"$",
"recursive",
")",
";",
"re... | Get all of the directories within a given directory.
@param string|null $directory
@param bool $recursive
@return array | [
"Get",
"all",
"of",
"the",
"directories",
"within",
"a",
"given",
"directory",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/FilesystemAdapter.php#L614-L619 | train | Get directories in the current directory | [
30522,
2270,
3853,
2472,
3111,
1006,
1002,
14176,
1027,
19701,
1010,
1002,
28667,
9236,
3512,
1027,
6270,
1007,
1063,
1002,
8417,
1027,
1002,
2023,
1011,
1028,
4062,
1011,
1028,
2862,
8663,
6528,
3215,
1006,
1002,
14176,
1010,
1002,
28667,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Updates/2.11.1-b4.php | Updates_2_11_1_b4.doUpdate | public function doUpdate(Updater $updater)
{
if (!Development::isEnabled()) {
return;
}
$config = Config::getInstance();
$dbTests = $config->database_tests;
if ($dbTests['username'] === '@USERNAME@') {
$dbTests['username'] = 'root';
}
$config->database_tests = $dbTests;
$config->forceSave();
} | php | public function doUpdate(Updater $updater)
{
if (!Development::isEnabled()) {
return;
}
$config = Config::getInstance();
$dbTests = $config->database_tests;
if ($dbTests['username'] === '@USERNAME@') {
$dbTests['username'] = 'root';
}
$config->database_tests = $dbTests;
$config->forceSave();
} | [
"public",
"function",
"doUpdate",
"(",
"Updater",
"$",
"updater",
")",
"{",
"if",
"(",
"!",
"Development",
"::",
"isEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"config",
"=",
"Config",
"::",
"getInstance",
"(",
")",
";",
"$",
"dbTests",
"=... | Here you can define any action that should be performed during the update. For instance executing SQL statements,
renaming config entries, updating files, etc. | [
"Here",
"you",
"can",
"define",
"any",
"action",
"that",
"should",
"be",
"performed",
"during",
"the",
"update",
".",
"For",
"instance",
"executing",
"SQL",
"statements",
"renaming",
"config",
"entries",
"updating",
"files",
"etc",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updates/2.11.1-b4.php#L23-L39 | train | Update database tests | [
30522,
2270,
3853,
2079,
6279,
13701,
1006,
10651,
2099,
1002,
10651,
2099,
1007,
1063,
2065,
1006,
999,
2458,
1024,
1024,
2003,
8189,
23242,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php | AbstractNormalizer.instantiateObject | protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
{
if (null !== $object = $this->extractObjectToPopulate($class, $context, self::OBJECT_TO_POPULATE)) {
unset($context[self::OBJECT_TO_POPULATE]);
return $object;
}
// clean up even if no match
unset($context[static::OBJECT_TO_POPULATE]);
$constructor = $this->getConstructor($data, $class, $context, $reflectionClass, $allowedAttributes);
if ($constructor) {
if (true !== $constructor->isPublic()) {
return $reflectionClass->newInstanceWithoutConstructor();
}
$constructorParameters = $constructor->getParameters();
$params = [];
foreach ($constructorParameters as $constructorParameter) {
$paramName = $constructorParameter->name;
$key = $this->nameConverter ? $this->nameConverter->normalize($paramName, $class, $format, $context) : $paramName;
$allowed = false === $allowedAttributes || \in_array($paramName, $allowedAttributes);
$ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
if ($constructorParameter->isVariadic()) {
if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
if (!\is_array($data[$paramName])) {
throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name));
}
$params = array_merge($params, $data[$paramName]);
}
} elseif ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
$parameterData = $data[$key];
if (null === $parameterData && $constructorParameter->allowsNull()) {
$params[] = null;
// Don't run set for a parameter passed to the constructor
unset($data[$key]);
continue;
}
// Don't run set for a parameter passed to the constructor
$params[] = $this->denormalizeParameter($reflectionClass, $constructorParameter, $paramName, $parameterData, $context, $format);
unset($data[$key]);
} elseif (\array_key_exists($key, $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class] ?? [])) {
$params[] = $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class][$key];
} elseif (\array_key_exists($key, $this->defaultContext[self::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class] ?? [])) {
$params[] = $this->defaultContext[self::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class][$key];
} elseif ($constructorParameter->isDefaultValueAvailable()) {
$params[] = $constructorParameter->getDefaultValue();
} else {
throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name));
}
}
if ($constructor->isConstructor()) {
return $reflectionClass->newInstanceArgs($params);
} else {
return $constructor->invokeArgs(null, $params);
}
}
return new $class();
} | php | protected function instantiateObject(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes, string $format = null)
{
if (null !== $object = $this->extractObjectToPopulate($class, $context, self::OBJECT_TO_POPULATE)) {
unset($context[self::OBJECT_TO_POPULATE]);
return $object;
}
// clean up even if no match
unset($context[static::OBJECT_TO_POPULATE]);
$constructor = $this->getConstructor($data, $class, $context, $reflectionClass, $allowedAttributes);
if ($constructor) {
if (true !== $constructor->isPublic()) {
return $reflectionClass->newInstanceWithoutConstructor();
}
$constructorParameters = $constructor->getParameters();
$params = [];
foreach ($constructorParameters as $constructorParameter) {
$paramName = $constructorParameter->name;
$key = $this->nameConverter ? $this->nameConverter->normalize($paramName, $class, $format, $context) : $paramName;
$allowed = false === $allowedAttributes || \in_array($paramName, $allowedAttributes);
$ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
if ($constructorParameter->isVariadic()) {
if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
if (!\is_array($data[$paramName])) {
throw new RuntimeException(sprintf('Cannot create an instance of %s from serialized data because the variadic parameter %s can only accept an array.', $class, $constructorParameter->name));
}
$params = array_merge($params, $data[$paramName]);
}
} elseif ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
$parameterData = $data[$key];
if (null === $parameterData && $constructorParameter->allowsNull()) {
$params[] = null;
// Don't run set for a parameter passed to the constructor
unset($data[$key]);
continue;
}
// Don't run set for a parameter passed to the constructor
$params[] = $this->denormalizeParameter($reflectionClass, $constructorParameter, $paramName, $parameterData, $context, $format);
unset($data[$key]);
} elseif (\array_key_exists($key, $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class] ?? [])) {
$params[] = $context[static::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class][$key];
} elseif (\array_key_exists($key, $this->defaultContext[self::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class] ?? [])) {
$params[] = $this->defaultContext[self::DEFAULT_CONSTRUCTOR_ARGUMENTS][$class][$key];
} elseif ($constructorParameter->isDefaultValueAvailable()) {
$params[] = $constructorParameter->getDefaultValue();
} else {
throw new MissingConstructorArgumentsException(sprintf('Cannot create an instance of %s from serialized data because its constructor requires parameter "%s" to be present.', $class, $constructorParameter->name));
}
}
if ($constructor->isConstructor()) {
return $reflectionClass->newInstanceArgs($params);
} else {
return $constructor->invokeArgs(null, $params);
}
}
return new $class();
} | [
"protected",
"function",
"instantiateObject",
"(",
"array",
"&",
"$",
"data",
",",
"$",
"class",
",",
"array",
"&",
"$",
"context",
",",
"\\",
"ReflectionClass",
"$",
"reflectionClass",
",",
"$",
"allowedAttributes",
",",
"string",
"$",
"format",
"=",
"null"... | Instantiates an object using constructor parameters when needed.
This method also allows to denormalize data into an existing object if
it is present in the context with the object_to_populate. This object
is removed from the context before being returned to avoid side effects
when recursively normalizing an object graph.
@param array $data
@param string $class
@param array $context
@param \ReflectionClass $reflectionClass
@param array|bool $allowedAttributes
@param string|null $format
@return object
@throws RuntimeException
@throws MissingConstructorArgumentsException | [
"Instantiates",
"an",
"object",
"using",
"constructor",
"parameters",
"when",
"needed",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L458-L522 | train | Instantiate an object from the data | [
30522,
5123,
3853,
7107,
13143,
16429,
20614,
1006,
9140,
1004,
1002,
2951,
1010,
1002,
2465,
1010,
9140,
1004,
1002,
6123,
1010,
1032,
9185,
26266,
1002,
9185,
26266,
1010,
1002,
3039,
19321,
3089,
8569,
4570,
1010,
5164,
1002,
4289,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Filter.php | Filter.getScopeValue | public function getScopeValue($scope, $default = null)
{
if (is_string($scope)) {
$scope = $this->getScope($scope);
}
$cacheKey = 'scope-'.$scope->scopeName;
return $this->getSession($cacheKey, $default);
} | php | public function getScopeValue($scope, $default = null)
{
if (is_string($scope)) {
$scope = $this->getScope($scope);
}
$cacheKey = 'scope-'.$scope->scopeName;
return $this->getSession($cacheKey, $default);
} | [
"public",
"function",
"getScopeValue",
"(",
"$",
"scope",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"scope",
"=",
"$",
"this",
"->",
"getScope",
"(",
"$",
"scope",
")",
";",
"}",
"$... | Returns a scope value for this widget instance. | [
"Returns",
"a",
"scope",
"value",
"for",
"this",
"widget",
"instance",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L853-L861 | train | Get the value of a scope | [
30522,
2270,
3853,
4152,
16186,
10175,
5657,
1006,
1002,
9531,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
9531,
1007,
1007,
1063,
1002,
9531,
1027,
1002,
2023,
1011,
1028,
4152,
16186,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php | PropertyPathBuilder.replaceByIndex | public function replaceByIndex($offset, $name = null)
{
if (!isset($this->elements[$offset])) {
throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset));
}
if (null !== $name) {
$this->elements[$offset] = $name;
}
$this->isIndex[$offset] = true;
} | php | public function replaceByIndex($offset, $name = null)
{
if (!isset($this->elements[$offset])) {
throw new OutOfBoundsException(sprintf('The offset %s is not within the property path', $offset));
}
if (null !== $name) {
$this->elements[$offset] = $name;
}
$this->isIndex[$offset] = true;
} | [
"public",
"function",
"replaceByIndex",
"(",
"$",
"offset",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sp... | Replaces a property element by an index element.
@param int $offset The offset at which to replace
@param string $name The new name of the element. Optional
@throws OutOfBoundsException If the offset is invalid | [
"Replaces",
"a",
"property",
"element",
"by",
"an",
"index",
"element",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/PropertyAccess/PropertyPathBuilder.php#L149-L160 | train | Replace the element at the given offset with the name | [
30522,
2270,
3853,
5672,
3762,
22254,
10288,
1006,
1002,
16396,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
3787,
1031,
1002,
16396,
1033,
1007,
1007,
1063,
5466,
2047,
2041,
11253,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.back | public function back()
{
do {
$request = $this->history->back();
} while (\array_key_exists(serialize($request), $this->redirects));
return $this->requestFromRequest($request, false);
} | php | public function back()
{
do {
$request = $this->history->back();
} while (\array_key_exists(serialize($request), $this->redirects));
return $this->requestFromRequest($request, false);
} | [
"public",
"function",
"back",
"(",
")",
"{",
"do",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"history",
"->",
"back",
"(",
")",
";",
"}",
"while",
"(",
"\\",
"array_key_exists",
"(",
"serialize",
"(",
"$",
"request",
")",
",",
"$",
"this",
"->",... | Goes back in the browser history.
@return Crawler | [
"Goes",
"back",
"in",
"the",
"browser",
"history",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/Client.php#L549-L556 | train | Back to the next redirect | [
30522,
2270,
3853,
2067,
1006,
1007,
1063,
2079,
1063,
1002,
5227,
1027,
1002,
2023,
1011,
1028,
2381,
1011,
1028,
2067,
1006,
1007,
1025,
1065,
2096,
1006,
1032,
9140,
1035,
3145,
1035,
6526,
1006,
7642,
4697,
1006,
1002,
5227,
1007,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Mime/FileBinaryMimeTypeGuesser.php | FileBinaryMimeTypeGuesser.isGuesserSupported | public function isGuesserSupported(): bool
{
static $supported = null;
if (null !== $supported) {
return $supported;
}
if ('\\' === \DIRECTORY_SEPARATOR || !\function_exists('passthru') || !\function_exists('escapeshellarg')) {
return $supported = false;
}
ob_start();
passthru('command -v file', $exitStatus);
$binPath = trim(ob_get_clean());
return $supported = 0 === $exitStatus && '' !== $binPath;
} | php | public function isGuesserSupported(): bool
{
static $supported = null;
if (null !== $supported) {
return $supported;
}
if ('\\' === \DIRECTORY_SEPARATOR || !\function_exists('passthru') || !\function_exists('escapeshellarg')) {
return $supported = false;
}
ob_start();
passthru('command -v file', $exitStatus);
$binPath = trim(ob_get_clean());
return $supported = 0 === $exitStatus && '' !== $binPath;
} | [
"public",
"function",
"isGuesserSupported",
"(",
")",
":",
"bool",
"{",
"static",
"$",
"supported",
"=",
"null",
";",
"if",
"(",
"null",
"!==",
"$",
"supported",
")",
"{",
"return",
"$",
"supported",
";",
"}",
"if",
"(",
"'\\\\'",
"===",
"\\",
"DIRECTO... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/FileBinaryMimeTypeGuesser.php#L44-L61 | train | Returns true if the guesser is supported by the current platform. | [
30522,
2270,
3853,
2003,
22967,
8043,
6342,
9397,
15613,
1006,
1007,
1024,
22017,
2140,
1063,
10763,
1002,
3569,
1027,
19701,
1025,
2065,
1006,
19701,
999,
1027,
1027,
1002,
3569,
1007,
1063,
2709,
1002,
3569,
1025,
1065,
2065,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/Middleware/CheckResponseForModifications.php | CheckResponseForModifications.handle | public function handle($request, Closure $next)
{
$response = $next($request);
if ($response instanceof Response) {
$response->isNotModified($request);
}
return $response;
} | php | public function handle($request, Closure $next)
{
$response = $next($request);
if ($response instanceof Response) {
$response->isNotModified($request);
}
return $response;
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"$",
"response",
"=",
"$",
"next",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"response",
"instanceof",
"Response",
")",
"{",
"$",
"response",
"->",
"isNo... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Middleware/CheckResponseForModifications.php#L17-L26 | train | Handle the request and return the response | [
30522,
2270,
3853,
5047,
1006,
1002,
5227,
1010,
8503,
1002,
2279,
1007,
1063,
1002,
3433,
1027,
1002,
2279,
1006,
1002,
5227,
1007,
1025,
2065,
1006,
1002,
3433,
6013,
11253,
3433,
1007,
1063,
1002,
3433,
1011,
1028,
3475,
4140,
5302,
43... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AbstractCloner.php | AbstractCloner.addCasters | public function addCasters(array $casters)
{
foreach ($casters as $type => $callback) {
$closure = &$this->casters[$type][];
$closure = $callback instanceof \Closure ? $callback : static function (...$args) use ($callback, &$closure) {
return ($closure = \Closure::fromCallable($callback))(...$args);
};
}
} | php | public function addCasters(array $casters)
{
foreach ($casters as $type => $callback) {
$closure = &$this->casters[$type][];
$closure = $callback instanceof \Closure ? $callback : static function (...$args) use ($callback, &$closure) {
return ($closure = \Closure::fromCallable($callback))(...$args);
};
}
} | [
"public",
"function",
"addCasters",
"(",
"array",
"$",
"casters",
")",
"{",
"foreach",
"(",
"$",
"casters",
"as",
"$",
"type",
"=>",
"$",
"callback",
")",
"{",
"$",
"closure",
"=",
"&",
"$",
"this",
"->",
"casters",
"[",
"$",
"type",
"]",
"[",
"]",... | Adds casters for resources and objects.
Maps resources or objects types to a callback.
Types are in the key, with a callable caster for value.
Resource types are to be prefixed with a `:`,
see e.g. static::$defaultCasters.
@param callable[] $casters A map of casters | [
"Adds",
"casters",
"for",
"resources",
"and",
"objects",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php#L188-L196 | train | Adds the casters to the array of casters | [
30522,
2270,
3853,
5587,
25490,
2015,
1006,
9140,
1002,
14542,
2869,
1007,
1063,
18921,
6776,
1006,
1002,
14542,
2869,
2004,
1002,
2828,
1027,
1028,
1002,
2655,
5963,
1007,
1063,
1002,
8503,
1027,
1004,
1002,
2023,
1011,
1028,
14542,
2869,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Protocol/Imap.php | Zend_Mail_Protocol_Imap.append | public function append($folder, $message, $flags = null, $date = null)
{
$tokens = array();
$tokens[] = $this->escapeString($folder);
if ($flags !== null) {
$tokens[] = $this->escapeList($flags);
}
if ($date !== null) {
$tokens[] = $this->escapeString($date);
}
$tokens[] = $this->escapeString($message);
return $this->requestAndResponse('APPEND', $tokens, true);
} | php | public function append($folder, $message, $flags = null, $date = null)
{
$tokens = array();
$tokens[] = $this->escapeString($folder);
if ($flags !== null) {
$tokens[] = $this->escapeList($flags);
}
if ($date !== null) {
$tokens[] = $this->escapeString($date);
}
$tokens[] = $this->escapeString($message);
return $this->requestAndResponse('APPEND', $tokens, true);
} | [
"public",
"function",
"append",
"(",
"$",
"folder",
",",
"$",
"message",
",",
"$",
"flags",
"=",
"null",
",",
"$",
"date",
"=",
"null",
")",
"{",
"$",
"tokens",
"=",
"array",
"(",
")",
";",
"$",
"tokens",
"[",
"]",
"=",
"$",
"this",
"->",
"esca... | append a new message to given folder
@param string $folder name of target folder
@param string $message full message content
@param array $flags flags for new message
@param string $date date for new message
@return bool success
@throws Zend_Mail_Protocol_Exception | [
"append",
"a",
"new",
"message",
"to",
"given",
"folder"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Imap.php#L723-L736 | train | Append a message to a folder | [
30522,
2270,
3853,
10439,
10497,
1006,
1002,
19622,
1010,
1002,
4471,
1010,
1002,
9245,
1027,
19701,
1010,
1002,
3058,
1027,
19701,
1007,
1063,
1002,
19204,
2015,
1027,
9140,
1006,
1007,
1025,
1002,
19204,
2015,
1031,
1033,
1027,
1002,
2023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Plugin.php | Plugin.isPluginActiveAdmin | protected function isPluginActiveAdmin($plugin_route)
{
$should_run = false;
$uri = $this->grav['uri'];
if (strpos($uri->path(), $this->config->get('plugins.admin.route') . '/' . $plugin_route) === false) {
$should_run = false;
} elseif (isset($uri->paths()[1]) && $uri->paths()[1] === $plugin_route) {
$should_run = true;
}
return $should_run;
} | php | protected function isPluginActiveAdmin($plugin_route)
{
$should_run = false;
$uri = $this->grav['uri'];
if (strpos($uri->path(), $this->config->get('plugins.admin.route') . '/' . $plugin_route) === false) {
$should_run = false;
} elseif (isset($uri->paths()[1]) && $uri->paths()[1] === $plugin_route) {
$should_run = true;
}
return $should_run;
} | [
"protected",
"function",
"isPluginActiveAdmin",
"(",
"$",
"plugin_route",
")",
"{",
"$",
"should_run",
"=",
"false",
";",
"$",
"uri",
"=",
"$",
"this",
"->",
"grav",
"[",
"'uri'",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"uri",
"->",
"path",
"(",
")"... | Determine if this route is in Admin and active for the plugin
@param string $plugin_route
@return bool | [
"Determine",
"if",
"this",
"route",
"is",
"in",
"Admin",
"and",
"active",
"for",
"the",
"plugin"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Plugin.php#L127-L140 | train | Check if the plugin is active in the administration section | [
30522,
5123,
3853,
2003,
24759,
15916,
3981,
15277,
4215,
10020,
1006,
1002,
13354,
2378,
1035,
2799,
1007,
1063,
1002,
2323,
1035,
2448,
1027,
6270,
1025,
1002,
24471,
2072,
1027,
1002,
2023,
1011,
1028,
24665,
11431,
1031,
1005,
24471,
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... |
getgrav/grav | system/src/Grav/Common/Filesystem/Folder.php | Folder.rcopy | public static function rcopy($src, $dest)
{
// If the src is not a directory do a simple file copy
if (!is_dir($src)) {
copy($src, $dest);
return true;
}
// If the destination directory does not exist create it
if (!is_dir($dest)) {
static::create($dest);
}
// Open the source directory to read in files
$i = new \DirectoryIterator($src);
/** @var \DirectoryIterator $f */
foreach ($i as $f) {
if ($f->isFile()) {
copy($f->getRealPath(), "{$dest}/" . $f->getFilename());
} else {
if (!$f->isDot() && $f->isDir()) {
static::rcopy($f->getRealPath(), "{$dest}/{$f}");
}
}
}
return true;
} | php | public static function rcopy($src, $dest)
{
// If the src is not a directory do a simple file copy
if (!is_dir($src)) {
copy($src, $dest);
return true;
}
// If the destination directory does not exist create it
if (!is_dir($dest)) {
static::create($dest);
}
// Open the source directory to read in files
$i = new \DirectoryIterator($src);
/** @var \DirectoryIterator $f */
foreach ($i as $f) {
if ($f->isFile()) {
copy($f->getRealPath(), "{$dest}/" . $f->getFilename());
} else {
if (!$f->isDot() && $f->isDir()) {
static::rcopy($f->getRealPath(), "{$dest}/{$f}");
}
}
}
return true;
} | [
"public",
"static",
"function",
"rcopy",
"(",
"$",
"src",
",",
"$",
"dest",
")",
"{",
"// If the src is not a directory do a simple file copy",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"src",
")",
")",
"{",
"copy",
"(",
"$",
"src",
",",
"$",
"dest",
")",
";",... | Recursive copy of one directory to another
@param string $src
@param string $dest
@return bool
@throws \RuntimeException | [
"Recursive",
"copy",
"of",
"one",
"directory",
"to",
"another"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Filesystem/Folder.php#L446-L473 | train | Copy a file or directory to a new location | [
30522,
2270,
10763,
3853,
22110,
7361,
2100,
1006,
1002,
5034,
2278,
1010,
1002,
4078,
2102,
1007,
1063,
1013,
1013,
2065,
1996,
5034,
2278,
2003,
2025,
1037,
14176,
2079,
1037,
3722,
5371,
6100,
2065,
1006,
999,
2003,
1035,
16101,
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/Support/Collection.php | Collection.mapToDictionary | public function mapToDictionary(callable $callback)
{
$dictionary = [];
foreach ($this->items as $key => $item) {
$pair = $callback($item, $key);
$key = key($pair);
$value = reset($pair);
if (! isset($dictionary[$key])) {
$dictionary[$key] = [];
}
$dictionary[$key][] = $value;
}
return new static($dictionary);
} | php | public function mapToDictionary(callable $callback)
{
$dictionary = [];
foreach ($this->items as $key => $item) {
$pair = $callback($item, $key);
$key = key($pair);
$value = reset($pair);
if (! isset($dictionary[$key])) {
$dictionary[$key] = [];
}
$dictionary[$key][] = $value;
}
return new static($dictionary);
} | [
"public",
"function",
"mapToDictionary",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"dictionary",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"$",
"pair",
"=",
"$",
"callback",
... | Run a dictionary map over the items.
The callback should return an associative array with a single key/value pair.
@param callable $callback
@return static | [
"Run",
"a",
"dictionary",
"map",
"over",
"the",
"items",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Collection.php#L1148-L1167 | train | Maps the items to a dictionary. | [
30522,
2270,
3853,
4949,
3406,
29201,
3258,
5649,
1006,
2655,
3085,
1002,
2655,
5963,
1007,
1063,
1002,
9206,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
5167,
2004,
1002,
3145,
1027,
1028,
1002,
8875,
1007,
1063,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php | SqlServerGrammar.compileAdd | public function compileAdd(Blueprint $blueprint, Fluent $command)
{
return sprintf('alter table %s add %s',
$this->wrapTable($blueprint),
implode(', ', $this->getColumns($blueprint))
);
} | php | public function compileAdd(Blueprint $blueprint, Fluent $command)
{
return sprintf('alter table %s add %s',
$this->wrapTable($blueprint),
implode(', ', $this->getColumns($blueprint))
);
} | [
"public",
"function",
"compileAdd",
"(",
"Blueprint",
"$",
"blueprint",
",",
"Fluent",
"$",
"command",
")",
"{",
"return",
"sprintf",
"(",
"'alter table %s add %s'",
",",
"$",
"this",
"->",
"wrapTable",
"(",
"$",
"blueprint",
")",
",",
"implode",
"(",
"', '"... | Compile a column addition table command.
@param \Illuminate\Database\Schema\Blueprint $blueprint
@param \Illuminate\Support\Fluent $command
@return string | [
"Compile",
"a",
"column",
"addition",
"table",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php#L75-L81 | train | Compiles add statement | [
30522,
2270,
3853,
4012,
22090,
4215,
2094,
1006,
2630,
16550,
1002,
2630,
16550,
1010,
19376,
1002,
3094,
1007,
1063,
2709,
9043,
2546,
1006,
1005,
11477,
2795,
1003,
1055,
5587,
1003,
1055,
1005,
1010,
1002,
2023,
1011,
1028,
10236,
10880... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Model.php | Model.addConditions | public function addConditions(array $conditions)
{
foreach ($conditions as $condition) {
call_user_func_array([$this, key($condition)], current($condition));
}
return $this;
} | php | public function addConditions(array $conditions)
{
foreach ($conditions as $condition) {
call_user_func_array([$this, key($condition)], current($condition));
}
return $this;
} | [
"public",
"function",
"addConditions",
"(",
"array",
"$",
"conditions",
")",
"{",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"condition",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"key",
"(",
"$",
"condition",
")",
"]",
",",
"curre... | Add conditions to grid model.
@param array $conditions
@return $this | [
"Add",
"conditions",
"to",
"grid",
"model",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Model.php#L340-L347 | train | Add conditions to the current object | [
30522,
2270,
3853,
5587,
8663,
20562,
2015,
1006,
9140,
1002,
3785,
1007,
1063,
18921,
6776,
1006,
1002,
3785,
2004,
1002,
4650,
1007,
1063,
2655,
1035,
5310,
1035,
4569,
2278,
1035,
9140,
1006,
1031,
1002,
2023,
1010,
3145,
1006,
1002,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form.php | Form.destroy | public function destroy($id)
{
try {
if (($ret = $this->callDeleting()) instanceof Response) {
return $ret;
}
collect(explode(',', $id))->filter()->each(function ($id) {
$builder = $this->model()->newQuery();
if ($this->isSoftDeletes) {
$builder = $builder->withTrashed();
}
$model = $builder->with($this->getRelations())->findOrFail($id);
if ($this->isSoftDeletes && $model->trashed()) {
$this->deleteFiles($model, true);
$model->forceDelete();
return;
}
$this->deleteFiles($model);
$model->delete();
});
if (($ret = $this->callDeleted()) instanceof Response) {
return $ret;
}
$response = [
'status' => true,
'message' => trans('admin.delete_succeeded'),
];
} catch (\Exception $exception) {
$response = [
'status' => false,
'message' => $exception->getMessage() ?: trans('admin.delete_failed'),
];
}
return response()->json($response);
} | php | public function destroy($id)
{
try {
if (($ret = $this->callDeleting()) instanceof Response) {
return $ret;
}
collect(explode(',', $id))->filter()->each(function ($id) {
$builder = $this->model()->newQuery();
if ($this->isSoftDeletes) {
$builder = $builder->withTrashed();
}
$model = $builder->with($this->getRelations())->findOrFail($id);
if ($this->isSoftDeletes && $model->trashed()) {
$this->deleteFiles($model, true);
$model->forceDelete();
return;
}
$this->deleteFiles($model);
$model->delete();
});
if (($ret = $this->callDeleted()) instanceof Response) {
return $ret;
}
$response = [
'status' => true,
'message' => trans('admin.delete_succeeded'),
];
} catch (\Exception $exception) {
$response = [
'status' => false,
'message' => $exception->getMessage() ?: trans('admin.delete_failed'),
];
}
return response()->json($response);
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"$",
"ret",
"=",
"$",
"this",
"->",
"callDeleting",
"(",
")",
")",
"instanceof",
"Response",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"collect",
"(",
"explode",... | Destroy data entity and remove files.
@param $id
@return mixed | [
"Destroy",
"data",
"entity",
"and",
"remove",
"files",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form.php#L300-L343 | train | Destroy all records with the given ID | [
30522,
2270,
3853,
6033,
1006,
1002,
8909,
1007,
1063,
3046,
1063,
2065,
1006,
1006,
1002,
2128,
2102,
1027,
1002,
2023,
1011,
1028,
2655,
9247,
20624,
3070,
1006,
1007,
1007,
6013,
11253,
30524,
2023,
1011,
1028,
2944,
1006,
1007,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Manager.php | Manager.deleteTable | public function deleteTable($id)
{
if (isset($this[$id])) {
Common::destroy($this[$id]);
$this->setTableDeleted($id);
}
} | php | public function deleteTable($id)
{
if (isset($this[$id])) {
Common::destroy($this[$id]);
$this->setTableDeleted($id);
}
} | [
"public",
"function",
"deleteTable",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"id",
"]",
")",
")",
"{",
"Common",
"::",
"destroy",
"(",
"$",
"this",
"[",
"$",
"id",
"]",
")",
";",
"$",
"this",
"->",
"setTableDel... | Deletes (unsets) the datatable given its id and removes it from the manager
Subsequent get for this table will fail
@param int $id | [
"Deletes",
"(",
"unsets",
")",
"the",
"datatable",
"given",
"its",
"id",
"and",
"removes",
"it",
"from",
"the",
"manager",
"Subsequent",
"get",
"for",
"this",
"table",
"will",
"fail"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Manager.php#L104-L110 | train | Delete a table by ID | [
30522,
2270,
3853,
3972,
12870,
10880,
1006,
1002,
8909,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1031,
1002,
8909,
1033,
1007,
1007,
1063,
2691,
1024,
1024,
6033,
1006,
1002,
2023,
1031,
1002,
8909,
1033,
1007,
1025,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid.php | Grid.appendActionsColumn | protected function appendActionsColumn()
{
if (!$this->option('show_actions')) {
return;
}
$this->addColumn('__actions__', trans('admin.action'))
->displayUsing($this->actionsClass, [$this->actionsCallback]);
} | php | protected function appendActionsColumn()
{
if (!$this->option('show_actions')) {
return;
}
$this->addColumn('__actions__', trans('admin.action'))
->displayUsing($this->actionsClass, [$this->actionsCallback]);
} | [
"protected",
"function",
"appendActionsColumn",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"option",
"(",
"'show_actions'",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"addColumn",
"(",
"'__actions__'",
",",
"trans",
"(",
"'admin.action'",... | Add `actions` column for grid.
@return void | [
"Add",
"actions",
"column",
"for",
"grid",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L527-L535 | train | Append actions column | [
30522,
5123,
3853,
10439,
10497,
18908,
8496,
25778,
2819,
2078,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
2265,
1035,
4506,
1005,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
5587,
25778,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Event.php | Event.skip | public function skip($callback)
{
$this->rejects[] = is_callable($callback) ? $callback : function () use ($callback) {
return $callback;
};
return $this;
} | php | public function skip($callback)
{
$this->rejects[] = is_callable($callback) ? $callback : function () use ($callback) {
return $callback;
};
return $this;
} | [
"public",
"function",
"skip",
"(",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"rejects",
"[",
"]",
"=",
"is_callable",
"(",
"$",
"callback",
")",
"?",
"$",
"callback",
":",
"function",
"(",
")",
"use",
"(",
"$",
"callback",
")",
"{",
"return",
"... | Register a callback to further filter the schedule.
@param \Closure|bool $callback
@return $this | [
"Register",
"a",
"callback",
"to",
"further",
"filter",
"the",
"schedule",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/Event.php#L662-L669 | train | Skips the given callback | [
30522,
2270,
3853,
13558,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
2023,
1011,
1028,
19164,
1031,
1033,
1027,
2003,
1035,
2655,
3085,
1006,
1002,
2655,
5963,
1007,
1029,
1002,
2655,
5963,
1024,
3853,
1006,
1007,
2224,
1006,
1002,
2655,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Cellmap.php | Cellmap.frame_exists_in_cellmap | public function frame_exists_in_cellmap(Frame $frame)
{
$key = $frame->get_id();
return isset($this->_frames[$key]);
} | php | public function frame_exists_in_cellmap(Frame $frame)
{
$key = $frame->get_id();
return isset($this->_frames[$key]);
} | [
"public",
"function",
"frame_exists_in_cellmap",
"(",
"Frame",
"$",
"frame",
")",
"{",
"$",
"key",
"=",
"$",
"frame",
"->",
"get_id",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"_frames",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | @param Frame $frame
@return bool | [
"@param",
"Frame",
"$frame"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Cellmap.php#L330-L335 | train | Check if a Frame exists in the cellmap | [
30522,
2270,
3853,
4853,
1035,
6526,
1035,
1999,
1035,
3526,
2863,
2361,
1006,
4853,
1002,
4853,
1007,
1063,
1002,
3145,
1027,
1002,
4853,
1011,
1028,
2131,
1035,
8909,
1006,
1007,
1025,
2709,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Filter.php | Filter.applyAllScopesToQuery | public function applyAllScopesToQuery($query)
{
$this->defineFilterScopes();
foreach ($this->allScopes as $scope) {
$this->applyScopeToQuery($scope, $query);
}
return $query;
} | php | public function applyAllScopesToQuery($query)
{
$this->defineFilterScopes();
foreach ($this->allScopes as $scope) {
$this->applyScopeToQuery($scope, $query);
}
return $query;
} | [
"public",
"function",
"applyAllScopesToQuery",
"(",
"$",
"query",
")",
"{",
"$",
"this",
"->",
"defineFilterScopes",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"allScopes",
"as",
"$",
"scope",
")",
"{",
"$",
"this",
"->",
"applyScopeToQuery",
"(",
... | Applies all scopes to a DB query.
@param Builder $query
@return Builder | [
"Applies",
"all",
"scopes",
"to",
"a",
"DB",
"query",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L660-L669 | train | Apply all scopes to the query | [
30522,
2270,
3853,
6611,
8095,
26127,
16033,
4226,
2854,
1006,
1002,
23032,
1007,
1063,
1002,
2023,
1011,
1028,
9375,
8873,
21928,
26127,
2015,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2035,
26127,
2015,
2004,
1002,
9531... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Simple/TraceableCache.php | TraceableCache.prune | public function prune()
{
if (!$this->pool instanceof PruneableInterface) {
return false;
}
$event = $this->start(__FUNCTION__);
try {
return $event->result = $this->pool->prune();
} finally {
$event->end = microtime(true);
}
} | php | public function prune()
{
if (!$this->pool instanceof PruneableInterface) {
return false;
}
$event = $this->start(__FUNCTION__);
try {
return $event->result = $this->pool->prune();
} finally {
$event->end = microtime(true);
}
} | [
"public",
"function",
"prune",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pool",
"instanceof",
"PruneableInterface",
")",
"{",
"return",
"false",
";",
"}",
"$",
"event",
"=",
"$",
"this",
"->",
"start",
"(",
"__FUNCTION__",
")",
";",
"try",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Simple/TraceableCache.php#L187-L198 | train | Prune the cache | [
30522,
2270,
3853,
10975,
9816,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
4770,
6013,
11253,
10975,
9816,
3085,
18447,
2121,
12172,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
2724,
1027,
1002,
2023,
1011,
1028,
2707,
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... |
walkor/Workerman | Protocols/Ws.php | Ws.dealHandshake | public static function dealHandshake($buffer, $connection)
{
$pos = strpos($buffer, "\r\n\r\n");
if ($pos) {
//checking Sec-WebSocket-Accept
if (preg_match("/Sec-WebSocket-Accept: *(.*?)\r\n/i", $buffer, $match)) {
if ($match[1] !== base64_encode(sha1($connection->websocketSecKey . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", true))) {
Worker::safeEcho("Sec-WebSocket-Accept not match. Header:\n" . substr($buffer, 0, $pos) . "\n");
$connection->close();
return 0;
}
} else {
Worker::safeEcho("Sec-WebSocket-Accept not found. Header:\n" . substr($buffer, 0, $pos) . "\n");
$connection->close();
return 0;
}
// handshake complete
// Get WebSocket subprotocol (if specified by server)
if (preg_match("/Sec-WebSocket-Protocol: *(.*?)\r\n/i", $buffer, $match)) {
$connection->WSServerProtocol = trim($match[1]);
}
$connection->handshakeStep = 2;
$handshake_response_length = $pos + 4;
// Try to emit onWebSocketConnect callback.
if (isset($connection->onWebSocketConnect)) {
try {
call_user_func($connection->onWebSocketConnect, $connection, substr($buffer, 0, $handshake_response_length));
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
// Headbeat.
if (!empty($connection->websocketPingInterval)) {
$connection->websocketPingTimer = Timer::add($connection->websocketPingInterval, function() use ($connection){
if (false === $connection->send(pack('H*', '898000000000'), true)) {
Timer::del($connection->websocketPingTimer);
$connection->websocketPingTimer = null;
}
});
}
$connection->consumeRecvBuffer($handshake_response_length);
if (!empty($connection->tmpWebsocketData)) {
$connection->send($connection->tmpWebsocketData, true);
$connection->tmpWebsocketData = '';
}
if (strlen($buffer) > $handshake_response_length) {
return self::input(substr($buffer, $handshake_response_length), $connection);
}
}
return 0;
} | php | public static function dealHandshake($buffer, $connection)
{
$pos = strpos($buffer, "\r\n\r\n");
if ($pos) {
//checking Sec-WebSocket-Accept
if (preg_match("/Sec-WebSocket-Accept: *(.*?)\r\n/i", $buffer, $match)) {
if ($match[1] !== base64_encode(sha1($connection->websocketSecKey . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", true))) {
Worker::safeEcho("Sec-WebSocket-Accept not match. Header:\n" . substr($buffer, 0, $pos) . "\n");
$connection->close();
return 0;
}
} else {
Worker::safeEcho("Sec-WebSocket-Accept not found. Header:\n" . substr($buffer, 0, $pos) . "\n");
$connection->close();
return 0;
}
// handshake complete
// Get WebSocket subprotocol (if specified by server)
if (preg_match("/Sec-WebSocket-Protocol: *(.*?)\r\n/i", $buffer, $match)) {
$connection->WSServerProtocol = trim($match[1]);
}
$connection->handshakeStep = 2;
$handshake_response_length = $pos + 4;
// Try to emit onWebSocketConnect callback.
if (isset($connection->onWebSocketConnect)) {
try {
call_user_func($connection->onWebSocketConnect, $connection, substr($buffer, 0, $handshake_response_length));
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
// Headbeat.
if (!empty($connection->websocketPingInterval)) {
$connection->websocketPingTimer = Timer::add($connection->websocketPingInterval, function() use ($connection){
if (false === $connection->send(pack('H*', '898000000000'), true)) {
Timer::del($connection->websocketPingTimer);
$connection->websocketPingTimer = null;
}
});
}
$connection->consumeRecvBuffer($handshake_response_length);
if (!empty($connection->tmpWebsocketData)) {
$connection->send($connection->tmpWebsocketData, true);
$connection->tmpWebsocketData = '';
}
if (strlen($buffer) > $handshake_response_length) {
return self::input(substr($buffer, $handshake_response_length), $connection);
}
}
return 0;
} | [
"public",
"static",
"function",
"dealHandshake",
"(",
"$",
"buffer",
",",
"$",
"connection",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"buffer",
",",
"\"\\r\\n\\r\\n\"",
")",
";",
"if",
"(",
"$",
"pos",
")",
"{",
"//checking Sec-WebSocket-Accept",
"if... | Websocket handshake.
@param string $buffer
@param \Workerman\Connection\TcpConnection $connection
@return int | [
"Websocket",
"handshake",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Ws.php#L404-L462 | train | Decides the WebSocket handshake | [
30522,
2270,
10763,
3853,
3066,
11774,
7377,
3489,
1006,
1002,
17698,
1010,
1002,
4434,
1007,
1063,
1002,
13433,
2015,
1027,
2358,
14536,
2891,
1006,
1002,
17698,
1010,
1000,
1032,
1054,
1032,
1050,
1032,
1054,
1032,
1050,
1000,
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... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.md5_16 | function md5_16($string)
{
$tmp = md5($string);
$out = '';
for ($i = 0; $i <= 30; $i = $i + 2) {
$out .= chr(hexdec(substr($tmp, $i, 2)));
}
return $out;
} | php | function md5_16($string)
{
$tmp = md5($string);
$out = '';
for ($i = 0; $i <= 30; $i = $i + 2) {
$out .= chr(hexdec(substr($tmp, $i, 2)));
}
return $out;
} | [
"function",
"md5_16",
"(",
"$",
"string",
")",
"{",
"$",
"tmp",
"=",
"md5",
"(",
"$",
"string",
")",
";",
"$",
"out",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"30",
";",
"$",
"i",
"=",
"$",
"i",
"+",
"2",
")"... | calculate the 16 byte version of the 128 bit md5 digest of the string
@param $string
@return string | [
"calculate",
"the",
"16",
"byte",
"version",
"of",
"the",
"128",
"bit",
"md5",
"digest",
"of",
"the",
"string"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2115-L2124 | train | 16 - bit md5 - 16 | [
30522,
3853,
9108,
2629,
1035,
2385,
1006,
1002,
5164,
1007,
1063,
1002,
1056,
8737,
1027,
9108,
2629,
1006,
1002,
5164,
1007,
1025,
1002,
2041,
1027,
1005,
1005,
1025,
2005,
1006,
1002,
1045,
1027,
1014,
1025,
1002,
1045,
1026,
1027,
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... |
symfony/symfony | src/Symfony/Component/Debug/ErrorHandler.php | ErrorHandler.screamAt | public function screamAt($levels, $replace = false)
{
$prev = $this->screamedErrors;
$this->screamedErrors = (int) $levels;
if (!$replace) {
$this->screamedErrors |= $prev;
}
return $prev;
} | php | public function screamAt($levels, $replace = false)
{
$prev = $this->screamedErrors;
$this->screamedErrors = (int) $levels;
if (!$replace) {
$this->screamedErrors |= $prev;
}
return $prev;
} | [
"public",
"function",
"screamAt",
"(",
"$",
"levels",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"$",
"prev",
"=",
"$",
"this",
"->",
"screamedErrors",
";",
"$",
"this",
"->",
"screamedErrors",
"=",
"(",
"int",
")",
"$",
"levels",
";",
"if",
"(",
... | Sets the error levels where the @-operator is ignored.
@param int $levels A bit field of E_* constants for screamed errors
@param bool $replace Replace or amend the previous value
@return int The previous value | [
"Sets",
"the",
"error",
"levels",
"where",
"the",
"@",
"-",
"operator",
"is",
"ignored",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Debug/ErrorHandler.php#L338-L347 | train | Set the level of errors that the current language should be reported at. | [
30522,
2270,
3853,
6978,
4017,
1006,
1002,
3798,
1010,
1002,
5672,
1027,
6270,
1007,
1063,
1002,
3653,
2615,
1027,
1002,
2023,
1011,
1028,
7210,
2121,
29165,
2015,
1025,
1002,
2023,
1011,
1028,
7210,
2121,
29165,
2015,
1027,
1006,
20014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Locale.php | Locale.getFallback | public static function getFallback($locale): ?string
{
if (\function_exists('locale_parse')) {
$localeSubTags = locale_parse($locale);
if (1 === \count($localeSubTags)) {
if (self::$defaultFallback === $localeSubTags['language']) {
return 'root';
}
// Don't return default fallback for "root", "meta" or others
// Normal locales have two or three letters
if (\strlen($locale) < 4) {
return self::$defaultFallback;
}
return null;
}
array_pop($localeSubTags);
$fallback = locale_compose($localeSubTags);
return false !== $fallback ? $fallback : null;
}
if (false !== $pos = strrpos($locale, '_')) {
return substr($locale, 0, $pos);
}
if (false !== $pos = strrpos($locale, '-')) {
return substr($locale, 0, $pos);
}
if (self::$defaultFallback === $locale) {
return 'root';
}
// Don't return default fallback for "root", "meta" or others
// Normal locales have two or three letters
if (\strlen($locale) < 4) {
return self::$defaultFallback;
}
return null;
} | php | public static function getFallback($locale): ?string
{
if (\function_exists('locale_parse')) {
$localeSubTags = locale_parse($locale);
if (1 === \count($localeSubTags)) {
if (self::$defaultFallback === $localeSubTags['language']) {
return 'root';
}
// Don't return default fallback for "root", "meta" or others
// Normal locales have two or three letters
if (\strlen($locale) < 4) {
return self::$defaultFallback;
}
return null;
}
array_pop($localeSubTags);
$fallback = locale_compose($localeSubTags);
return false !== $fallback ? $fallback : null;
}
if (false !== $pos = strrpos($locale, '_')) {
return substr($locale, 0, $pos);
}
if (false !== $pos = strrpos($locale, '-')) {
return substr($locale, 0, $pos);
}
if (self::$defaultFallback === $locale) {
return 'root';
}
// Don't return default fallback for "root", "meta" or others
// Normal locales have two or three letters
if (\strlen($locale) < 4) {
return self::$defaultFallback;
}
return null;
} | [
"public",
"static",
"function",
"getFallback",
"(",
"$",
"locale",
")",
":",
"?",
"string",
"{",
"if",
"(",
"\\",
"function_exists",
"(",
"'locale_parse'",
")",
")",
"{",
"$",
"localeSubTags",
"=",
"locale_parse",
"(",
"$",
"locale",
")",
";",
"if",
"(",... | Returns the fallback locale for a given locale.
For example, the fallback of "fr_FR" is "fr". The fallback of "fr" is
the default fallback locale configured with {@link setDefaultFallback()}.
The default fallback locale has no fallback.
@param string $locale The ICU locale code to find the fallback for
@return string|null The ICU locale code of the fallback locale, or null
if no fallback exists | [
"Returns",
"the",
"fallback",
"locale",
"for",
"a",
"given",
"locale",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Locale.php#L68-L112 | train | Returns the fallback for the given locale | [
30522,
2270,
10763,
3853,
2131,
13976,
5963,
1006,
1002,
2334,
2063,
1007,
1024,
1029,
5164,
1063,
2065,
1006,
1032,
3853,
1035,
6526,
1006,
1005,
2334,
2063,
1035,
11968,
3366,
1005,
1007,
1007,
1063,
1002,
2334,
2229,
12083,
15900,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php | TemplateFinder.findTemplatesInBundle | private function findTemplatesInBundle(BundleInterface $bundle)
{
$name = $bundle->getName();
$templates = array_unique(array_merge(
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
));
foreach ($templates as $i => $template) {
$templates[$i] = $template->set('bundle', $name);
}
return $templates;
} | php | private function findTemplatesInBundle(BundleInterface $bundle)
{
$name = $bundle->getName();
$templates = array_unique(array_merge(
$this->findTemplatesInFolder($bundle->getPath().'/Resources/views'),
$this->findTemplatesInFolder($this->rootDir.'/'.$name.'/views')
));
foreach ($templates as $i => $template) {
$templates[$i] = $template->set('bundle', $name);
}
return $templates;
} | [
"private",
"function",
"findTemplatesInBundle",
"(",
"BundleInterface",
"$",
"bundle",
")",
"{",
"$",
"name",
"=",
"$",
"bundle",
"->",
"getName",
"(",
")",
";",
"$",
"templates",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"findTemplate... | Find templates in the given bundle.
@param BundleInterface $bundle The bundle where to look for templates
@return TemplateReferenceInterface[] | [
"Find",
"templates",
"in",
"the",
"given",
"bundle",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php#L101-L114 | train | finds all templates in the bundle | [
30522,
2797,
3853,
2424,
18532,
15725,
11493,
27265,
2571,
1006,
14012,
18447,
2121,
12172,
1002,
14012,
1007,
1063,
1002,
2171,
1027,
1002,
14012,
1011,
1028,
2131,
18442,
1006,
1007,
1025,
1002,
23561,
2015,
1027,
9140,
1035,
4310,
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/Session/CookieSessionHandler.php | CookieSessionHandler.write | public function write($sessionId, $data)
{
$this->cookie->queue($sessionId, json_encode([
'data' => $data,
'expires' => $this->availableAt($this->minutes * 60),
]), $this->minutes);
return true;
} | php | public function write($sessionId, $data)
{
$this->cookie->queue($sessionId, json_encode([
'data' => $data,
'expires' => $this->availableAt($this->minutes * 60),
]), $this->minutes);
return true;
} | [
"public",
"function",
"write",
"(",
"$",
"sessionId",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"cookie",
"->",
"queue",
"(",
"$",
"sessionId",
",",
"json_encode",
"(",
"[",
"'data'",
"=>",
"$",
"data",
",",
"'expires'",
"=>",
"$",
"this",
"->",... | {@inheritdoc} | [
"{"
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Session/CookieSessionHandler.php#L83-L91 | train | Write session data to cookie | [
30522,
2270,
3853,
4339,
1006,
1002,
5219,
3593,
1010,
1002,
2951,
1007,
1063,
1002,
2023,
1011,
1028,
17387,
1011,
1028,
24240,
1006,
1002,
5219,
3593,
1010,
1046,
3385,
1035,
4372,
16044,
1006,
1031,
1005,
2951,
1005,
1027,
1028,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Routing/Router.php | Router.resolve | private function resolve($value)
{
if (\is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $this->resolve($val);
}
return $value;
}
if (!\is_string($value)) {
return $value;
}
$escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function ($match) use ($value) {
// skip %%
if (!isset($match[1])) {
return '%%';
}
if (preg_match('/^env\(\w+\)$/', $match[1])) {
throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1]));
}
$resolved = ($this->paramFetcher)($match[1]);
if (\is_bool($resolved)) {
$resolved = (string) (int) $resolved;
}
if (\is_string($resolved) || is_numeric($resolved)) {
$this->collectedParameters[$match[1]] = $resolved;
return (string) $resolved;
}
throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type %s.', $match[1], $value, \gettype($resolved)));
}, $value);
return str_replace('%%', '%', $escapedValue);
} | php | private function resolve($value)
{
if (\is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $this->resolve($val);
}
return $value;
}
if (!\is_string($value)) {
return $value;
}
$escapedValue = preg_replace_callback('/%%|%([^%\s]++)%/', function ($match) use ($value) {
// skip %%
if (!isset($match[1])) {
return '%%';
}
if (preg_match('/^env\(\w+\)$/', $match[1])) {
throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1]));
}
$resolved = ($this->paramFetcher)($match[1]);
if (\is_bool($resolved)) {
$resolved = (string) (int) $resolved;
}
if (\is_string($resolved) || is_numeric($resolved)) {
$this->collectedParameters[$match[1]] = $resolved;
return (string) $resolved;
}
throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type %s.', $match[1], $value, \gettype($resolved)));
}, $value);
return str_replace('%%', '%', $escapedValue);
} | [
"private",
"function",
"resolve",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"value",
"[",
"$",
"key",
"]",
"=",
... | Recursively replaces placeholders with the service container parameters.
@param mixed $value The source which might contain "%placeholders%"
@return mixed The source with the placeholders replaced by the container
parameters. Arrays are resolved recursively.
@throws ParameterNotFoundException When a placeholder does not exist as a container parameter
@throws RuntimeException When a container value is not a string or a numeric value | [
"Recursively",
"replaces",
"placeholders",
"with",
"the",
"service",
"container",
"parameters",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php#L143-L183 | train | Resolves the container parameter value | [
30522,
2797,
3853,
10663,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
9140,
1006,
1002,
3643,
1007,
1007,
1063,
18921,
6776,
1006,
1002,
3643,
2004,
1002,
3145,
1027,
1028,
1002,
11748,
1007,
1063,
1002,
3643,
1031,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Maildir.php | Zend_Mail_Storage_Maildir.getMessage | public function getMessage($id)
{
// TODO that's ugly, would be better to let the message class decide
if (strtolower($this->_messageClass) == 'zend_mail_message_file' || is_subclass_of($this->_messageClass, 'zend_mail_message_file')) {
return new $this->_messageClass(array('file' => $this->_getFileData($id, 'filename'),
'flags' => $this->_getFileData($id, 'flags')));
}
return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $this->getRawHeader($id),
'flags' => $this->_getFileData($id, 'flags')));
} | php | public function getMessage($id)
{
// TODO that's ugly, would be better to let the message class decide
if (strtolower($this->_messageClass) == 'zend_mail_message_file' || is_subclass_of($this->_messageClass, 'zend_mail_message_file')) {
return new $this->_messageClass(array('file' => $this->_getFileData($id, 'filename'),
'flags' => $this->_getFileData($id, 'flags')));
}
return new $this->_messageClass(array('handler' => $this, 'id' => $id, 'headers' => $this->getRawHeader($id),
'flags' => $this->_getFileData($id, 'flags')));
} | [
"public",
"function",
"getMessage",
"(",
"$",
"id",
")",
"{",
"// TODO that's ugly, would be better to let the message class decide",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"_messageClass",
")",
"==",
"'zend_mail_message_file'",
"||",
"is_subclass_of",
"(",
"$... | Fetch a message
@param int $id number of message
@return Zend_Mail_Message_File
@throws Zend_Mail_Storage_Exception | [
"Fetch",
"a",
"message"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Maildir.php#L175-L185 | train | Returns the message object for the given message id | [
30522,
2270,
3853,
2131,
7834,
3736,
3351,
1006,
1002,
8909,
1007,
1063,
1013,
1013,
28681,
2080,
2008,
1005,
1055,
9200,
1010,
2052,
2022,
2488,
2000,
2292,
1996,
4471,
2465,
5630,
2065,
1006,
2358,
5339,
12898,
13777,
1006,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php | WorkflowExtension.hasMarkedPlace | public function hasMarkedPlace($subject, $placeName, $name = null)
{
return $this->workflowRegistry->get($subject, $name)->getMarking($subject)->has($placeName);
} | php | public function hasMarkedPlace($subject, $placeName, $name = null)
{
return $this->workflowRegistry->get($subject, $name)->getMarking($subject)->has($placeName);
} | [
"public",
"function",
"hasMarkedPlace",
"(",
"$",
"subject",
",",
"$",
"placeName",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"workflowRegistry",
"->",
"get",
"(",
"$",
"subject",
",",
"$",
"name",
")",
"->",
"getMarking",
"... | Returns true if the place is marked.
@param object $subject A subject
@param string $placeName A place name
@param string $name A workflow name
@return bool true if the transition is enabled | [
"Returns",
"true",
"if",
"the",
"place",
"is",
"marked",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php#L82-L85 | train | Has a place marked? | [
30522,
2270,
3853,
2038,
10665,
2098,
24759,
10732,
1006,
1002,
3395,
1010,
1002,
2173,
18442,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2147,
12314,
2890,
24063,
2854,
1011,
1028,
2131,
1006,
1002,
3395,
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/Translation/Extractor/PhpStringTokenParser.php | PhpStringTokenParser.parseEscapeSequences | public static function parseEscapeSequences($str, $quote)
{
if (null !== $quote) {
$str = str_replace('\\'.$quote, $quote, $str);
}
return preg_replace_callback(
'~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~',
[__CLASS__, 'parseCallback'],
$str
);
} | php | public static function parseEscapeSequences($str, $quote)
{
if (null !== $quote) {
$str = str_replace('\\'.$quote, $quote, $str);
}
return preg_replace_callback(
'~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~',
[__CLASS__, 'parseCallback'],
$str
);
} | [
"public",
"static",
"function",
"parseEscapeSequences",
"(",
"$",
"str",
",",
"$",
"quote",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"quote",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"'\\\\'",
".",
"$",
"quote",
",",
"$",
"quote",
",",
"$",
"... | Parses escape sequences in strings (all string types apart from single quoted).
@param string $str String without quotes
@param string|null $quote Quote type
@return string String with escape sequences parsed | [
"Parses",
"escape",
"sequences",
"in",
"strings",
"(",
"all",
"string",
"types",
"apart",
"from",
"single",
"quoted",
")",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Extractor/PhpStringTokenParser.php#L96-L107 | train | Parse escape sequences | [
30522,
2270,
10763,
3853,
11968,
19763,
15782,
10374,
2063,
4226,
5897,
2015,
1006,
1002,
2358,
2099,
1010,
1002,
14686,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
14686,
30524,
2709,
3653,
2290,
1035,
5672,
1035,
2655,
5963,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataAccess/LogAggregator.php | LogAggregator.queryConversionsByDimension | public function queryConversionsByDimension($dimensions = array(), $where = false, $additionalSelects = array(), $extraFrom = [])
{
$dimensions = array_merge(array(self::IDGOAL_FIELD), $dimensions);
$tableName = self::LOG_CONVERSION_TABLE;
$availableMetrics = $this->getConversionsMetricFields();
$select = $this->getSelectStatement($dimensions, $tableName, $additionalSelects, $availableMetrics);
$from = array_merge([$tableName], $extraFrom);
$where = $this->getWhereStatement($tableName, self::CONVERSION_DATETIME_FIELD, $where);
$groupBy = $this->getGroupByStatement($dimensions, $tableName);
$orderBy = false;
$query = $this->generateQuery($select, $from, $where, $groupBy, $orderBy);
return $this->getDb()->query($query['sql'], $query['bind']);
} | php | public function queryConversionsByDimension($dimensions = array(), $where = false, $additionalSelects = array(), $extraFrom = [])
{
$dimensions = array_merge(array(self::IDGOAL_FIELD), $dimensions);
$tableName = self::LOG_CONVERSION_TABLE;
$availableMetrics = $this->getConversionsMetricFields();
$select = $this->getSelectStatement($dimensions, $tableName, $additionalSelects, $availableMetrics);
$from = array_merge([$tableName], $extraFrom);
$where = $this->getWhereStatement($tableName, self::CONVERSION_DATETIME_FIELD, $where);
$groupBy = $this->getGroupByStatement($dimensions, $tableName);
$orderBy = false;
$query = $this->generateQuery($select, $from, $where, $groupBy, $orderBy);
return $this->getDb()->query($query['sql'], $query['bind']);
} | [
"public",
"function",
"queryConversionsByDimension",
"(",
"$",
"dimensions",
"=",
"array",
"(",
")",
",",
"$",
"where",
"=",
"false",
",",
"$",
"additionalSelects",
"=",
"array",
"(",
")",
",",
"$",
"extraFrom",
"=",
"[",
"]",
")",
"{",
"$",
"dimensions"... | Executes a query aggregating conversion data (everything in the **log_conversion** table) and returns
a DB statement that can be used to iterate over the result.
<a name="queryConversionsByDimension-result-set"></a>
**Result Set**
Each row of the result set represents an aggregated group of conversions. The
following columns are in each aggregate row:
- **{@link Piwik\Metrics::INDEX_GOAL_NB_CONVERSIONS}**: The total number of conversions in this aggregate
group.
- **{@link Piwik\Metrics::INDEX_GOAL_NB_VISITS_CONVERTED}**: The total number of visits during which these
conversions were converted.
- **{@link Piwik\Metrics::INDEX_GOAL_REVENUE}**: The total revenue generated by these conversions. This value
includes the revenue from individual ecommerce items.
- **{@link Piwik\Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_SUBTOTAL}**: The total cost of all ecommerce items sold
within these conversions. This value does not
include tax, shipping or any applied discount.
_This metric is only applicable to the special
**ecommerce** goal (where `idGoal == 'ecommerceOrder'`)._
- **{@link Piwik\Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_TAX}**: The total tax applied to every transaction in these
conversions.
_This metric is only applicable to the special
**ecommerce** goal (where `idGoal == 'ecommerceOrder'`)._
- **{@link Piwik\Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_SHIPPING}**: The total shipping cost for every transaction
in these conversions.
_This metric is only applicable to the special
**ecommerce** goal (where `idGoal == 'ecommerceOrder'`)._
- **{@link Piwik\Metrics::INDEX_GOAL_ECOMMERCE_REVENUE_DISCOUNT}**: The total discount applied to every transaction
in these conversions.
_This metric is only applicable to the special
**ecommerce** goal (where `idGoal == 'ecommerceOrder'`)._
- **{@link Piwik\Metrics::INDEX_GOAL_ECOMMERCE_ITEMS}**: The total number of ecommerce items sold in each transaction
in these conversions.
_This metric is only applicable to the special
**ecommerce** goal (where `idGoal == 'ecommerceOrder'`)._
Additional data can be selected through the `$additionalSelects` parameter.
_Note: This method will only query the **log_conversion** table. Other tables cannot be joined
using this method._
@param array|string $dimensions One or more **SELECT** fields that will be used to group the log_conversion
rows by. This parameter determines which **log_conversion** rows will be
aggregated together.
@param bool|string $where An optional SQL expression used in the SQL's **WHERE** clause.
@param array $additionalSelects Additional SELECT fields that are not included in the group by
clause. These can be aggregate expressions, eg, `SUM(somecol)`.
@return \Zend_Db_Statement | [
"Executes",
"a",
"query",
"aggregating",
"conversion",
"data",
"(",
"everything",
"in",
"the",
"**",
"log_conversion",
"**",
"table",
")",
"and",
"returns",
"a",
"DB",
"statement",
"that",
"can",
"be",
"used",
"to",
"iterate",
"over",
"the",
"result",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/LogAggregator.php#L808-L823 | train | QueryConversionsByDimension - Selects theConversions table and returns the result as an array of objects | [
30522,
2270,
3853,
23032,
8663,
27774,
14478,
22172,
6132,
3258,
1006,
1002,
9646,
1027,
9140,
1006,
1007,
1010,
1002,
2073,
1027,
6270,
1010,
1002,
3176,
11246,
22471,
2015,
1027,
9140,
1006,
1007,
1010,
1002,
4469,
19699,
5358,
1027,
1031... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Blueprint.php | Blueprint.double | public function double($column, $total = null, $places = null)
{
return $this->addColumn('double', $column, compact('total', 'places'));
} | php | public function double($column, $total = null, $places = null)
{
return $this->addColumn('double', $column, compact('total', 'places'));
} | [
"public",
"function",
"double",
"(",
"$",
"column",
",",
"$",
"total",
"=",
"null",
",",
"$",
"places",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addColumn",
"(",
"'double'",
",",
"$",
"column",
",",
"compact",
"(",
"'total'",
",",
"'place... | Create a new double column on the table.
@param string $column
@param int|null $total
@param int|null $places
@return \Illuminate\Database\Schema\ColumnDefinition | [
"Create",
"a",
"new",
"double",
"column",
"on",
"the",
"table",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Blueprint.php#L803-L806 | train | Add a double column to the table | [
30522,
2270,
3853,
3313,
1006,
1002,
5930,
1010,
1002,
2561,
1027,
19701,
1010,
1002,
3182,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5587,
25778,
2819,
2078,
1006,
1005,
3313,
1005,
1010,
1002,
5930,
1010,
9233,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Annotations/Controller.php | Controller.deleteAnnotation | public function deleteAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// delete annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.delete");
return $this->getAnnotationManager($fetch = true);
}
} | php | public function deleteAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// delete annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.delete");
return $this->getAnnotationManager($fetch = true);
}
} | [
"public",
"function",
"deleteAnnotation",
"(",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"POST\"",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"// delete annotation. NOTE: permissions checked in API method",
"Req... | Controller action that deletes an annotation and returns new annotation
manager HTML for the site & date range.
Query Param Input:
- idSite: The ID of the site this annotation belongs to.
- idNote: The ID of the annotation to delete.
- date: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
- period: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
- lastN: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
Output:
- @see self::getAnnotationManager | [
"Controller",
"action",
"that",
"deletes",
"an",
"annotation",
"and",
"returns",
"new",
"annotation",
"manager",
"HTML",
"for",
"the",
"site",
"&",
"date",
"range",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L179-L189 | train | Delete annotation. | [
30522,
2270,
3853,
3972,
12870,
11639,
17287,
3508,
1006,
1007,
1063,
2065,
1006,
1002,
1035,
8241,
1031,
1000,
5227,
1035,
4118,
1000,
1033,
1027,
1027,
1000,
2695,
1000,
1007,
1063,
1002,
2023,
1011,
1028,
4638,
18715,
18595,
11231,
12190... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CallQueuedHandler.php | CallQueuedHandler.handleModelNotFound | protected function handleModelNotFound(Job $job, $e)
{
$class = $job->resolveName();
try {
$shouldDelete = (new ReflectionClass($class))
->getDefaultProperties()['deleteWhenMissingModels'] ?? false;
} catch (Exception $e) {
$shouldDelete = false;
}
if ($shouldDelete) {
return $job->delete();
}
return $job->fail($e);
} | php | protected function handleModelNotFound(Job $job, $e)
{
$class = $job->resolveName();
try {
$shouldDelete = (new ReflectionClass($class))
->getDefaultProperties()['deleteWhenMissingModels'] ?? false;
} catch (Exception $e) {
$shouldDelete = false;
}
if ($shouldDelete) {
return $job->delete();
}
return $job->fail($e);
} | [
"protected",
"function",
"handleModelNotFound",
"(",
"Job",
"$",
"job",
",",
"$",
"e",
")",
"{",
"$",
"class",
"=",
"$",
"job",
"->",
"resolveName",
"(",
")",
";",
"try",
"{",
"$",
"shouldDelete",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"class",
... | Handle a model not found exception.
@param \Illuminate\Contracts\Queue\Job $job
@param \Exception $e
@return void | [
"Handle",
"a",
"model",
"not",
"found",
"exception",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/CallQueuedHandler.php#L115-L131 | train | Handle ModelNotFound for ModelNotFoundJob | [
30522,
5123,
3853,
30524,
1027,
1006,
2047,
9185,
26266,
1006,
1002,
2465,
1007,
1007,
1011,
1028,
2131,
3207,
7011,
11314,
21572,
4842,
7368,
1006,
1007,
1031,
1005,
3972,
12870,
2860,
10222,
15630,
7741,
5302,
9247,
2015,
1005,
1033,
1029... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php | MarkdownFormatter.encode | public function encode($data): string
{
$headerVar = $this->getHeaderField();
$bodyVar = $this->getBodyField();
$header = isset($data[$headerVar]) ? (array) $data[$headerVar] : [];
$body = isset($data[$bodyVar]) ? (string) $data[$bodyVar] : '';
// Create Markdown file with YAML header.
$encoded = '';
if ($header) {
$encoded = "---\n" . trim($this->getHeaderFormatter()->encode($data['header'])) . "\n---\n\n";
}
$encoded .= $body;
// Normalize line endings to Unix style.
$encoded = preg_replace("/(\r\n|\r)/", "\n", $encoded);
return $encoded;
} | php | public function encode($data): string
{
$headerVar = $this->getHeaderField();
$bodyVar = $this->getBodyField();
$header = isset($data[$headerVar]) ? (array) $data[$headerVar] : [];
$body = isset($data[$bodyVar]) ? (string) $data[$bodyVar] : '';
// Create Markdown file with YAML header.
$encoded = '';
if ($header) {
$encoded = "---\n" . trim($this->getHeaderFormatter()->encode($data['header'])) . "\n---\n\n";
}
$encoded .= $body;
// Normalize line endings to Unix style.
$encoded = preg_replace("/(\r\n|\r)/", "\n", $encoded);
return $encoded;
} | [
"public",
"function",
"encode",
"(",
"$",
"data",
")",
":",
"string",
"{",
"$",
"headerVar",
"=",
"$",
"this",
"->",
"getHeaderField",
"(",
")",
";",
"$",
"bodyVar",
"=",
"$",
"this",
"->",
"getBodyField",
"(",
")",
";",
"$",
"header",
"=",
"isset",
... | {@inheritdoc}
@see FileFormatterInterface::encode() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/File/Formatter/MarkdownFormatter.php#L80-L99 | train | Encode the data to a Markdown string | [
30522,
2270,
3853,
4372,
16044,
1006,
1002,
2951,
1007,
1024,
5164,
1063,
1002,
20346,
10755,
1027,
1002,
2023,
1011,
1028,
2131,
4974,
2121,
3790,
1006,
1007,
1025,
1002,
2303,
10755,
1027,
1002,
2023,
1011,
1028,
2131,
23684,
3790,
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/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php | AddExpressionLanguageProvidersPass.process | public function process(ContainerBuilder $container)
{
// routing
if ($container->has('router')) {
$definition = $container->findDefinition('router');
foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) {
$definition->addMethodCall('addExpressionLanguageProvider', [new Reference($id)]);
}
}
// security
if ($this->handleSecurityLanguageProviders && $container->has('security.expression_language')) {
$definition = $container->findDefinition('security.expression_language');
foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) {
$definition->addMethodCall('registerProvider', [new Reference($id)]);
}
}
} | php | public function process(ContainerBuilder $container)
{
// routing
if ($container->has('router')) {
$definition = $container->findDefinition('router');
foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) {
$definition->addMethodCall('addExpressionLanguageProvider', [new Reference($id)]);
}
}
// security
if ($this->handleSecurityLanguageProviders && $container->has('security.expression_language')) {
$definition = $container->findDefinition('security.expression_language');
foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) {
$definition->addMethodCall('registerProvider', [new Reference($id)]);
}
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"// routing",
"if",
"(",
"$",
"container",
"->",
"has",
"(",
"'router'",
")",
")",
"{",
"$",
"definition",
"=",
"$",
"container",
"->",
"findDefinition",
"(",
"'router'",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php#L40-L57 | train | Adds expression language providers to routing and security providers | [
30522,
2270,
3853,
2832,
1006,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
1013,
1013,
16972,
2065,
1006,
1002,
11661,
1011,
1028,
2038,
1006,
1005,
2799,
2099,
1005,
1007,
1007,
1063,
1002,
6210,
1027,
1002,
11661,
1011,
1028,
2424,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field.php | Field.options | public function options($options = [])
{
if ($options instanceof Arrayable) {
$options = $options->toArray();
}
$this->options = array_merge($this->options, $options);
return $this;
} | php | public function options($options = [])
{
if ($options instanceof Arrayable) {
$options = $options->toArray();
}
$this->options = array_merge($this->options, $options);
return $this;
} | [
"public",
"function",
"options",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"options",
"instanceof",
"Arrayable",
")",
"{",
"$",
"options",
"=",
"$",
"options",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"this",
"->",
"options",
"... | Set the field options.
@param array $options
@return $this | [
"Set",
"the",
"field",
"options",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field.php#L435-L444 | train | Set options for this class | [
30522,
2270,
3853,
7047,
1006,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
7047,
6013,
11253,
9140,
3085,
1007,
1063,
1002,
7047,
1027,
1002,
7047,
1011,
1028,
2000,
2906,
9447,
1006,
1007,
1025,
1065,
1002,
2023,
1011,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Blueprint.php | Blueprint.build | public function build(Connection $connection, Grammar $grammar)
{
foreach ($this->toSql($connection, $grammar) as $statement) {
$connection->statement($statement);
}
} | php | public function build(Connection $connection, Grammar $grammar)
{
foreach ($this->toSql($connection, $grammar) as $statement) {
$connection->statement($statement);
}
} | [
"public",
"function",
"build",
"(",
"Connection",
"$",
"connection",
",",
"Grammar",
"$",
"grammar",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"toSql",
"(",
"$",
"connection",
",",
"$",
"grammar",
")",
"as",
"$",
"statement",
")",
"{",
"$",
"connect... | Execute the blueprint against the database.
@param \Illuminate\Database\Connection $connection
@param \Illuminate\Database\Schema\Grammars\Grammar $grammar
@return void | [
"Execute",
"the",
"blueprint",
"against",
"the",
"database",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Blueprint.php#L94-L99 | train | Build the table and execute it. | [
30522,
2270,
3853,
3857,
1006,
4434,
1002,
4434,
1010,
8035,
1002,
8035,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2000,
2015,
4160,
2140,
1006,
1002,
4434,
1010,
1002,
8035,
1007,
2004,
1002,
4861,
1007,
1063,
1002,
4434,
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/CoreVisualizations/Visualizations/Cloud.php | Cloud.getClassFromPercent | protected function getClassFromPercent($percent)
{
$mapping = array(95, 70, 50, 30, 15, 5, 0);
foreach ($mapping as $key => $value) {
if ($percent >= $value) {
return $key;
}
}
return 0;
} | php | protected function getClassFromPercent($percent)
{
$mapping = array(95, 70, 50, 30, 15, 5, 0);
foreach ($mapping as $key => $value) {
if ($percent >= $value) {
return $key;
}
}
return 0;
} | [
"protected",
"function",
"getClassFromPercent",
"(",
"$",
"percent",
")",
"{",
"$",
"mapping",
"=",
"array",
"(",
"95",
",",
"70",
",",
"50",
",",
"30",
",",
"15",
",",
"5",
",",
"0",
")",
";",
"foreach",
"(",
"$",
"mapping",
"as",
"$",
"key",
"=... | Get the class range using a percentage
@param $percent
@return int class | [
"Get",
"the",
"class",
"range",
"using",
"a",
"percentage"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/Visualizations/Cloud.php#L161-L170 | train | Get the class from the percentage | [
30522,
5123,
3853,
2131,
26266,
19699,
25377,
2121,
13013,
1006,
1002,
3867,
1007,
1063,
1002,
12375,
1027,
9140,
1006,
5345,
1010,
3963,
1010,
2753,
1010,
2382,
1010,
2321,
1010,
1019,
1010,
1014,
1007,
1025,
18921,
6776,
1006,
1002,
12375... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Url.php | Url.isValidHost | public static function isValidHost($host = false)
{
// only do trusted host check if it's enabled
if (isset(Config::getInstance()->General['enable_trusted_host_check'])
&& Config::getInstance()->General['enable_trusted_host_check'] == 0
) {
return true;
}
if ($host === false) {
$host = @$_SERVER['HTTP_HOST'];
if (empty($host)) {
// if no current host, assume valid
return true;
}
}
// if host is in hardcoded whitelist, assume it's valid
if (in_array($host, self::getAlwaysTrustedHosts())) {
return true;
}
$trustedHosts = self::getTrustedHosts();
// Only punctuation we allow is '[', ']', ':', '.', '_' and '-'
$hostLength = strlen($host);
if ($hostLength !== strcspn($host, '`~!@#$%^&*()+={}\\|;"\'<>,?/ ')) {
return false;
}
// if no trusted hosts, just assume it's valid
if (empty($trustedHosts)) {
self::saveTrustedHostnameInConfig($host);
return true;
}
// Escape trusted hosts for preg_match call below
foreach ($trustedHosts as &$trustedHost) {
$trustedHost = preg_quote($trustedHost);
}
$trustedHosts = str_replace("/", "\\/", $trustedHosts);
$untrustedHost = Common::mb_strtolower($host);
$untrustedHost = rtrim($untrustedHost, '.');
$hostRegex = Common::mb_strtolower('/(^|.)' . implode('|', $trustedHosts) . '$/');
$result = preg_match($hostRegex, $untrustedHost);
return 0 !== $result;
} | php | public static function isValidHost($host = false)
{
// only do trusted host check if it's enabled
if (isset(Config::getInstance()->General['enable_trusted_host_check'])
&& Config::getInstance()->General['enable_trusted_host_check'] == 0
) {
return true;
}
if ($host === false) {
$host = @$_SERVER['HTTP_HOST'];
if (empty($host)) {
// if no current host, assume valid
return true;
}
}
// if host is in hardcoded whitelist, assume it's valid
if (in_array($host, self::getAlwaysTrustedHosts())) {
return true;
}
$trustedHosts = self::getTrustedHosts();
// Only punctuation we allow is '[', ']', ':', '.', '_' and '-'
$hostLength = strlen($host);
if ($hostLength !== strcspn($host, '`~!@#$%^&*()+={}\\|;"\'<>,?/ ')) {
return false;
}
// if no trusted hosts, just assume it's valid
if (empty($trustedHosts)) {
self::saveTrustedHostnameInConfig($host);
return true;
}
// Escape trusted hosts for preg_match call below
foreach ($trustedHosts as &$trustedHost) {
$trustedHost = preg_quote($trustedHost);
}
$trustedHosts = str_replace("/", "\\/", $trustedHosts);
$untrustedHost = Common::mb_strtolower($host);
$untrustedHost = rtrim($untrustedHost, '.');
$hostRegex = Common::mb_strtolower('/(^|.)' . implode('|', $trustedHosts) . '$/');
$result = preg_match($hostRegex, $untrustedHost);
return 0 !== $result;
} | [
"public",
"static",
"function",
"isValidHost",
"(",
"$",
"host",
"=",
"false",
")",
"{",
"// only do trusted host check if it's enabled",
"if",
"(",
"isset",
"(",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"General",
"[",
"'enable_trusted_host_check'",
"]",
")... | Validates the **Host** HTTP header (untrusted user input). Used to prevent Host header
attacks.
@param string|bool $host Contents of Host: header from the HTTP request. If `false`, gets the
value from the request.
@return bool `true` if valid; `false` otherwise. | [
"Validates",
"the",
"**",
"Host",
"**",
"HTTP",
"header",
"(",
"untrusted",
"user",
"input",
")",
".",
"Used",
"to",
"prevent",
"Host",
"header",
"attacks",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Url.php#L201-L251 | train | Returns true if the host is valid | [
30522,
2270,
10763,
3853,
2003,
10175,
3593,
15006,
2102,
1006,
1002,
3677,
1027,
6270,
1007,
1063,
1013,
1013,
2069,
2079,
9480,
3677,
4638,
2065,
2009,
1005,
1055,
9124,
2065,
1006,
26354,
3388,
1006,
9530,
8873,
2290,
1024,
1024,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/Table.php | Table.setColumnMaxWidth | public function setColumnMaxWidth(int $columnIndex, int $width): self
{
if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, \get_class($this->output->getFormatter())));
}
$this->columnMaxWidths[$columnIndex] = $width;
return $this;
} | php | public function setColumnMaxWidth(int $columnIndex, int $width): self
{
if (!$this->output->getFormatter() instanceof WrappableOutputFormatterInterface) {
throw new \LogicException(sprintf('Setting a maximum column width is only supported when using a "%s" formatter, got "%s".', WrappableOutputFormatterInterface::class, \get_class($this->output->getFormatter())));
}
$this->columnMaxWidths[$columnIndex] = $width;
return $this;
} | [
"public",
"function",
"setColumnMaxWidth",
"(",
"int",
"$",
"columnIndex",
",",
"int",
"$",
"width",
")",
":",
"self",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
"instanceof",
"WrappableOutputFormatterInterface",
")",
"... | Sets the maximum width of a column.
Any cell within this column which contents exceeds the specified width will be wrapped into multiple lines, while
formatted strings are preserved.
@return $this | [
"Sets",
"the",
"maximum",
"width",
"of",
"a",
"column",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/Table.php#L232-L241 | train | Set maximum width of a column | [
30522,
2270,
3853,
2275,
25778,
2819,
2078,
17848,
9148,
11927,
2232,
1006,
20014,
1002,
5930,
22254,
10288,
1010,
20014,
1002,
9381,
1007,
1024,
2969,
1063,
30524,
1006,
1007,
6013,
11253,
10236,
4502,
3468,
5833,
18780,
14192,
20097,
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/FrameworkBundle/Templating/Helper/CodeHelper.php | CodeHelper.formatArgs | public function formatArgs(array $args)
{
$result = [];
foreach ($args as $key => $item) {
if ('object' === $item[0]) {
$parts = explode('\\', $item[1]);
$short = array_pop($parts);
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
} elseif ('array' === $item[0]) {
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
} elseif ('null' === $item[0]) {
$formattedValue = '<em>null</em>';
} elseif ('boolean' === $item[0]) {
$formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
} elseif ('resource' === $item[0]) {
$formattedValue = '<em>resource</em>';
} else {
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
}
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
}
return implode(', ', $result);
} | php | public function formatArgs(array $args)
{
$result = [];
foreach ($args as $key => $item) {
if ('object' === $item[0]) {
$parts = explode('\\', $item[1]);
$short = array_pop($parts);
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
} elseif ('array' === $item[0]) {
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
} elseif ('string' === $item[0]) {
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->getCharset()));
} elseif ('null' === $item[0]) {
$formattedValue = '<em>null</em>';
} elseif ('boolean' === $item[0]) {
$formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
} elseif ('resource' === $item[0]) {
$formattedValue = '<em>resource</em>';
} else {
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->getCharset()), true));
}
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
}
return implode(', ', $result);
} | [
"public",
"function",
"formatArgs",
"(",
"array",
"$",
"args",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"'object'",
"===",
"$",
"item",
"[",
"0",
"]",
")... | Formats an array as a string.
@param array $args The argument array
@return string | [
"Formats",
"an",
"array",
"as",
"a",
"string",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php#L85-L111 | train | Formats the arguments for the debug function | [
30522,
2270,
3853,
4289,
2906,
5620,
1006,
9140,
1002,
12098,
5620,
1007,
1063,
1002,
2765,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
12098,
5620,
2004,
1002,
3145,
1027,
1028,
1002,
8875,
1007,
1063,
2065,
1006,
1005,
4874,
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/Period/Day.php | Day.getLocalizedLongString | public function getLocalizedLongString()
{
//"Mon 15 Aug"
$date = $this->getDateStart();
$out = $date->getLocalized(Date::DATE_FORMAT_LONG);
return $out;
} | php | public function getLocalizedLongString()
{
//"Mon 15 Aug"
$date = $this->getDateStart();
$out = $date->getLocalized(Date::DATE_FORMAT_LONG);
return $out;
} | [
"public",
"function",
"getLocalizedLongString",
"(",
")",
"{",
"//\"Mon 15 Aug\"",
"$",
"date",
"=",
"$",
"this",
"->",
"getDateStart",
"(",
")",
";",
"$",
"out",
"=",
"$",
"date",
"->",
"getLocalized",
"(",
"Date",
"::",
"DATE_FORMAT_LONG",
")",
";",
"ret... | Returns the day of the period as a localized long string
@return string | [
"Returns",
"the",
"day",
"of",
"the",
"period",
"as",
"a",
"localized",
"long",
"string"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Period/Day.php#L52-L58 | train | Get localized long string | [
30522,
2270,
3853,
2131,
4135,
9289,
3550,
10052,
3367,
4892,
1006,
1007,
1063,
1013,
1013,
1000,
12256,
2321,
15476,
1000,
1002,
3058,
1027,
1002,
2023,
1011,
1028,
2131,
27122,
7559,
2102,
1006,
1007,
1025,
1002,
2041,
1027,
1002,
3058,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php | XmlFileLoader.parseValues | protected function parseValues(\SimpleXMLElement $nodes)
{
$values = [];
foreach ($nodes as $node) {
if (\count($node) > 0) {
if (\count($node->value) > 0) {
$value = $this->parseValues($node->value);
} elseif (\count($node->constraint) > 0) {
$value = $this->parseConstraints($node->constraint);
} else {
$value = [];
}
} else {
$value = trim($node);
}
if (isset($node['key'])) {
$values[(string) $node['key']] = $value;
} else {
$values[] = $value;
}
}
return $values;
} | php | protected function parseValues(\SimpleXMLElement $nodes)
{
$values = [];
foreach ($nodes as $node) {
if (\count($node) > 0) {
if (\count($node->value) > 0) {
$value = $this->parseValues($node->value);
} elseif (\count($node->constraint) > 0) {
$value = $this->parseConstraints($node->constraint);
} else {
$value = [];
}
} else {
$value = trim($node);
}
if (isset($node['key'])) {
$values[(string) $node['key']] = $value;
} else {
$values[] = $value;
}
}
return $values;
} | [
"protected",
"function",
"parseValues",
"(",
"\\",
"SimpleXMLElement",
"$",
"nodes",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"node",
")",
">",
"0",
... | Parses a collection of "value" XML nodes.
@param \SimpleXMLElement $nodes The XML nodes
@return array The values | [
"Parses",
"a",
"collection",
"of",
"value",
"XML",
"nodes",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php#L107-L132 | train | Parse Values from XML nodes | [
30522,
5123,
3853,
11968,
3366,
10175,
15808,
1006,
1032,
3722,
2595,
19968,
12260,
3672,
1002,
14164,
1007,
1063,
1002,
5300,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
14164,
2004,
1002,
13045,
1007,
1063,
2065,
1006,
1032,
4175,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Abstract.php | Zend_Db_Adapter_Pdo_Abstract._quote | protected function _quote($value)
{
if (is_int($value) || is_float($value)) {
return $value;
}
$this->_connect();
return $this->_connection->quote($value);
} | php | protected function _quote($value)
{
if (is_int($value) || is_float($value)) {
return $value;
}
$this->_connect();
return $this->_connection->quote($value);
} | [
"protected",
"function",
"_quote",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
"||",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"retu... | Quote a raw string.
@param string $value Raw string
@return string Quoted string | [
"Quote",
"a",
"raw",
"string",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Abstract.php#L290-L297 | train | Quote value to a string | [
30522,
5123,
3853,
30524,
2023,
1011,
1028,
1035,
4434,
1011,
1028,
14686,
1006,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.isPiwikInstalled | public static function isPiwikInstalled()
{
$config = Config::getInstance()->getLocalPath();
$exists = file_exists($config);
// Piwik is not installed if the config file is not found
if (!$exists) {
return false;
}
$general = Config::getInstance()->General;
$isInstallationInProgress = false;
if (array_key_exists('installation_in_progress', $general)) {
$isInstallationInProgress = (bool) $general['installation_in_progress'];
}
if ($isInstallationInProgress) {
return false;
}
// Check that the database section is really set, ie. file is not empty
if (empty(Config::getInstance()->database['username'])) {
return false;
}
return true;
} | php | public static function isPiwikInstalled()
{
$config = Config::getInstance()->getLocalPath();
$exists = file_exists($config);
// Piwik is not installed if the config file is not found
if (!$exists) {
return false;
}
$general = Config::getInstance()->General;
$isInstallationInProgress = false;
if (array_key_exists('installation_in_progress', $general)) {
$isInstallationInProgress = (bool) $general['installation_in_progress'];
}
if ($isInstallationInProgress) {
return false;
}
// Check that the database section is really set, ie. file is not empty
if (empty(Config::getInstance()->database['username'])) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"isPiwikInstalled",
"(",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"getLocalPath",
"(",
")",
";",
"$",
"exists",
"=",
"file_exists",
"(",
"$",
"config",
")",
";",
"// Piwik is not installed i... | Return true if Piwik is installed (installation is done).
@deprecated since Matomo 3.8.0, please use {@link isMatomoInstalled()} instead.
@return bool | [
"Return",
"true",
"if",
"Piwik",
"is",
"installed",
"(",
"installation",
"is",
"done",
")",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/SettingsPiwik.php#L230-L255 | train | Check if Piwik is installed | [
30522,
2270,
10763,
3853,
2003,
8197,
9148,
14322,
9080,
3709,
1006,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2131,
4135,
9289,
15069,
1006,
1007,
1025,
1002,
6526,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MiniProgram/UniformMessage/Client.php | Client.formatMessage | protected function formatMessage(array $data = [])
{
$params = array_merge($this->message, $data);
if (empty($params['touser'])) {
throw new InvalidArgumentException(sprintf('Attribute "touser" can not be empty!'));
}
if (!empty($params['weapp_template_msg'])) {
$params['weapp_template_msg'] = $this->formatWeappMessage($params['weapp_template_msg']);
}
if (!empty($params['mp_template_msg'])) {
$params['mp_template_msg'] = $this->formatMpMessage($params['mp_template_msg']);
}
return $params;
} | php | protected function formatMessage(array $data = [])
{
$params = array_merge($this->message, $data);
if (empty($params['touser'])) {
throw new InvalidArgumentException(sprintf('Attribute "touser" can not be empty!'));
}
if (!empty($params['weapp_template_msg'])) {
$params['weapp_template_msg'] = $this->formatWeappMessage($params['weapp_template_msg']);
}
if (!empty($params['mp_template_msg'])) {
$params['mp_template_msg'] = $this->formatMpMessage($params['mp_template_msg']);
}
return $params;
} | [
"protected",
"function",
"formatMessage",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"message",
",",
"$",
"data",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'touser'",
... | @param array $data
@return array
@throws InvalidArgumentException | [
"@param",
"array",
"$data"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/MiniProgram/UniformMessage/Client.php#L70-L87 | train | Format message by adding touser and weapp_template_msg | [
30522,
5123,
3853,
4289,
7834,
3736,
3351,
1006,
9140,
1002,
2951,
1027,
1031,
1033,
1007,
1063,
1002,
11498,
5244,
1027,
9140,
1035,
13590,
1006,
1002,
2023,
1011,
1028,
4471,
1010,
1002,
2951,
1007,
1025,
2065,
1006,
4064,
1006,
1002,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/Connections/PhpRedisConnection.php | PhpRedisConnection.zrevrangebyscore | public function zrevrangebyscore($key, $min, $max, $options = [])
{
if (isset($options['limit'])) {
$options['limit'] = [
$options['limit']['offset'],
$options['limit']['count'],
];
}
return $this->command('zRevRangeByScore', [$key, $min, $max, $options]);
} | php | public function zrevrangebyscore($key, $min, $max, $options = [])
{
if (isset($options['limit'])) {
$options['limit'] = [
$options['limit']['offset'],
$options['limit']['count'],
];
}
return $this->command('zRevRangeByScore', [$key, $min, $max, $options]);
} | [
"public",
"function",
"zrevrangebyscore",
"(",
"$",
"key",
",",
"$",
"min",
",",
"$",
"max",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'limit'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'limit'"... | Return elements with score between $min and $max.
@param string $key
@param mixed $min
@param mixed $max
@param array $options
@return int | [
"Return",
"elements",
"with",
"score",
"between",
"$min",
"and",
"$max",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Connections/PhpRedisConnection.php#L248-L258 | train | Returns array of term IDs sorted by score | [
30522,
2270,
3853,
1062,
2890,
19716,
22043,
3762,
9363,
2890,
1006,
1002,
3145,
1010,
1002,
8117,
1010,
1002,
4098,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
7047,
1031,
1005,
5787,
1005,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/VersionManager.php | VersionManager.purgePlugin | public function purgePlugin($pluginCode)
{
$versions = Db::table('system_plugin_versions')->where('code', $pluginCode);
if ($countVersions = $versions->count()) {
$versions->delete();
}
$history = Db::table('system_plugin_history')->where('code', $pluginCode);
if ($countHistory = $history->count()) {
$history->delete();
}
return ($countHistory + $countVersions) > 0;
} | php | public function purgePlugin($pluginCode)
{
$versions = Db::table('system_plugin_versions')->where('code', $pluginCode);
if ($countVersions = $versions->count()) {
$versions->delete();
}
$history = Db::table('system_plugin_history')->where('code', $pluginCode);
if ($countHistory = $history->count()) {
$history->delete();
}
return ($countHistory + $countVersions) > 0;
} | [
"public",
"function",
"purgePlugin",
"(",
"$",
"pluginCode",
")",
"{",
"$",
"versions",
"=",
"Db",
"::",
"table",
"(",
"'system_plugin_versions'",
")",
"->",
"where",
"(",
"'code'",
",",
"$",
"pluginCode",
")",
";",
"if",
"(",
"$",
"countVersions",
"=",
... | Deletes all records from the version and history tables for a plugin.
@param string $pluginCode Plugin code
@return void | [
"Deletes",
"all",
"records",
"from",
"the",
"version",
"and",
"history",
"tables",
"for",
"a",
"plugin",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/VersionManager.php#L219-L232 | train | Purges the plugin versions and history for a given plugin code | [
30522,
2270,
3853,
24694,
24759,
15916,
2378,
1006,
1002,
13354,
2378,
16044,
1007,
1063,
1002,
4617,
1027,
16962,
1024,
1024,
2795,
1006,
1005,
2291,
1035,
13354,
2378,
1035,
4617,
1005,
1007,
1011,
1028,
2073,
1006,
1005,
3642,
1005,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Work/Invoice/Client.php | Client.batchUpdate | public function batchUpdate(array $invoices, string $openid, string $status)
{
$params = [
'openid' => $openid,
'reimburse_status' => $status,
'invoice_list' => $invoices,
];
return $this->httpPostJson('cgi-bin/card/invoice/reimburse/updatestatusbatch', $params);
} | php | public function batchUpdate(array $invoices, string $openid, string $status)
{
$params = [
'openid' => $openid,
'reimburse_status' => $status,
'invoice_list' => $invoices,
];
return $this->httpPostJson('cgi-bin/card/invoice/reimburse/updatestatusbatch', $params);
} | [
"public",
"function",
"batchUpdate",
"(",
"array",
"$",
"invoices",
",",
"string",
"$",
"openid",
",",
"string",
"$",
"status",
")",
"{",
"$",
"params",
"=",
"[",
"'openid'",
"=>",
"$",
"openid",
",",
"'reimburse_status'",
"=>",
"$",
"status",
",",
"'inv... | @param array $invoices
@param string $openid
@param string $status
@return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"@param",
"array",
"$invoices",
"@param",
"string",
"$openid",
"@param",
"string",
"$status"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Work/Invoice/Client.php#L86-L95 | train | Batch Update invoice status | [
30522,
2270,
3853,
14108,
6279,
13701,
1006,
9140,
1002,
1999,
6767,
23522,
1010,
5164,
1002,
2330,
3593,
1010,
5164,
1002,
3570,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
2330,
3593,
1005,
1027,
1028,
1002,
2330,
3593,
1010,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Plugin.php | Plugin.offsetGet | public function offsetGet($offset)
{
$this->loadBlueprint();
if ($offset === 'title') {
$offset = 'name';
}
return $this->blueprint[$offset] ?? null;
} | php | public function offsetGet($offset)
{
$this->loadBlueprint();
if ($offset === 'title') {
$offset = 'name';
}
return $this->blueprint[$offset] ?? null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"$",
"this",
"->",
"loadBlueprint",
"(",
")",
";",
"if",
"(",
"$",
"offset",
"===",
"'title'",
")",
"{",
"$",
"offset",
"=",
"'name'",
";",
"}",
"return",
"$",
"this",
"->",
"blueprint"... | Returns the value at specified offset.
@param string $offset The offset to retrieve.
@return mixed Can return all value types. | [
"Returns",
"the",
"value",
"at",
"specified",
"offset",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Plugin.php#L206-L214 | train | Get the value of the blueprint at the specified offset. | [
30522,
2270,
3853,
16396,
18150,
1006,
30524,
1027,
1027,
1027,
1005,
2516,
1005,
1007,
1063,
1002,
16396,
1027,
1005,
2171,
1005,
1025,
1065,
2709,
1002,
2023,
1011,
1028,
2630,
16550,
1031,
1002,
16396,
1033,
1029,
1029,
19701,
1025,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Http/HttpUtils.php | HttpUtils.createRequest | public function createRequest(Request $request, $path)
{
$newRequest = Request::create($this->generateUri($request, $path), 'get', [], $request->cookies->all(), [], $request->server->all());
static $setSession;
if (null === $setSession) {
$setSession = \Closure::bind(function ($newRequest, $request) { $newRequest->session = $request->session; }, null, Request::class);
}
$setSession($newRequest, $request);
if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
$newRequest->attributes->set(Security::AUTHENTICATION_ERROR, $request->attributes->get(Security::AUTHENTICATION_ERROR));
}
if ($request->attributes->has(Security::ACCESS_DENIED_ERROR)) {
$newRequest->attributes->set(Security::ACCESS_DENIED_ERROR, $request->attributes->get(Security::ACCESS_DENIED_ERROR));
}
if ($request->attributes->has(Security::LAST_USERNAME)) {
$newRequest->attributes->set(Security::LAST_USERNAME, $request->attributes->get(Security::LAST_USERNAME));
}
if ($request->get('_format')) {
$newRequest->attributes->set('_format', $request->get('_format'));
}
if ($request->getDefaultLocale() !== $request->getLocale()) {
$newRequest->setLocale($request->getLocale());
}
return $newRequest;
} | php | public function createRequest(Request $request, $path)
{
$newRequest = Request::create($this->generateUri($request, $path), 'get', [], $request->cookies->all(), [], $request->server->all());
static $setSession;
if (null === $setSession) {
$setSession = \Closure::bind(function ($newRequest, $request) { $newRequest->session = $request->session; }, null, Request::class);
}
$setSession($newRequest, $request);
if ($request->attributes->has(Security::AUTHENTICATION_ERROR)) {
$newRequest->attributes->set(Security::AUTHENTICATION_ERROR, $request->attributes->get(Security::AUTHENTICATION_ERROR));
}
if ($request->attributes->has(Security::ACCESS_DENIED_ERROR)) {
$newRequest->attributes->set(Security::ACCESS_DENIED_ERROR, $request->attributes->get(Security::ACCESS_DENIED_ERROR));
}
if ($request->attributes->has(Security::LAST_USERNAME)) {
$newRequest->attributes->set(Security::LAST_USERNAME, $request->attributes->get(Security::LAST_USERNAME));
}
if ($request->get('_format')) {
$newRequest->attributes->set('_format', $request->get('_format'));
}
if ($request->getDefaultLocale() !== $request->getLocale()) {
$newRequest->setLocale($request->getLocale());
}
return $newRequest;
} | [
"public",
"function",
"createRequest",
"(",
"Request",
"$",
"request",
",",
"$",
"path",
")",
"{",
"$",
"newRequest",
"=",
"Request",
"::",
"create",
"(",
"$",
"this",
"->",
"generateUri",
"(",
"$",
"request",
",",
"$",
"path",
")",
",",
"'get'",
",",
... | Creates a Request.
@param Request $request The current Request instance
@param string $path A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo))
@return Request A Request instance | [
"Creates",
"a",
"Request",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/HttpUtils.php#L83-L112 | train | Create a new request | [
30522,
2270,
3853,
3443,
2890,
15500,
1006,
5227,
1002,
5227,
1010,
1002,
4130,
1007,
1063,
1002,
2047,
2890,
15500,
1027,
5227,
1024,
1024,
3443,
1006,
1002,
2023,
1011,
1028,
9699,
9496,
1006,
1002,
5227,
1010,
1002,
4130,
1007,
1010,
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/CssSelector/Parser/TokenStream.php | TokenStream.getPeek | public function getPeek()
{
if (!$this->peeking) {
$this->peeked = $this->getNext();
$this->peeking = true;
}
return $this->peeked;
} | php | public function getPeek()
{
if (!$this->peeking) {
$this->peeked = $this->getNext();
$this->peeking = true;
}
return $this->peeked;
} | [
"public",
"function",
"getPeek",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"peeking",
")",
"{",
"$",
"this",
"->",
"peeked",
"=",
"$",
"this",
"->",
"getNext",
"(",
")",
";",
"$",
"this",
"->",
"peeking",
"=",
"true",
";",
"}",
"return",
... | Returns peeked token.
@return Token | [
"Returns",
"peeked",
"token",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/CssSelector/Parser/TokenStream.php#L104-L112 | train | Get the next position in the iterator | [
30522,
2270,
3853,
2131,
28084,
2243,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
28222,
1007,
1063,
1002,
2023,
1011,
1028,
18652,
1027,
1002,
2023,
1011,
1028,
2131,
2638,
18413,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Container/Container.php | Container.getClosure | protected function getClosure($abstract, $concrete)
{
return function ($container, $parameters = []) use ($abstract, $concrete) {
if ($abstract == $concrete) {
return $container->build($concrete);
}
return $container->resolve(
$concrete, $parameters, $raiseEvents = false
);
};
} | php | protected function getClosure($abstract, $concrete)
{
return function ($container, $parameters = []) use ($abstract, $concrete) {
if ($abstract == $concrete) {
return $container->build($concrete);
}
return $container->resolve(
$concrete, $parameters, $raiseEvents = false
);
};
} | [
"protected",
"function",
"getClosure",
"(",
"$",
"abstract",
",",
"$",
"concrete",
")",
"{",
"return",
"function",
"(",
"$",
"container",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"use",
"(",
"$",
"abstract",
",",
"$",
"concrete",
")",
"{",
"if",
"... | Get the Closure to be used when building a type.
@param string $abstract
@param string $concrete
@return \Closure | [
"Get",
"the",
"Closure",
"to",
"be",
"used",
"when",
"building",
"a",
"type",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L257-L268 | train | Returns closure that will be used to create the concrete class. | [
30522,
5123,
3853,
2131,
20464,
2891,
5397,
1006,
1002,
10061,
1010,
1002,
5509,
1007,
1063,
2709,
3853,
1006,
1002,
11661,
1010,
1002,
11709,
1027,
1031,
1033,
1007,
2224,
1006,
1002,
10061,
1010,
1002,
5509,
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... |
php-ai/php-ml | src/Association/Apriori.php | Apriori.frequency | private function frequency(array $sample): int
{
return count(array_filter($this->samples, function ($entry) use ($sample) {
return $this->subset($entry, $sample);
}));
} | php | private function frequency(array $sample): int
{
return count(array_filter($this->samples, function ($entry) use ($sample) {
return $this->subset($entry, $sample);
}));
} | [
"private",
"function",
"frequency",
"(",
"array",
"$",
"sample",
")",
":",
"int",
"{",
"return",
"count",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"samples",
",",
"function",
"(",
"$",
"entry",
")",
"use",
"(",
"$",
"sample",
")",
"{",
"return",
... | Counts occurrences of $sample as subset in data pool.
@see \Phpml\Association\Apriori::samples
@param mixed[] $sample | [
"Counts",
"occurrences",
"of",
"$sample",
"as",
"subset",
"in",
"data",
"pool",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L289-L294 | train | Returns the frequency of the sample in the result | [
30522,
2797,
3853,
6075,
1006,
9140,
1002,
7099,
1007,
1024,
20014,
1063,
2709,
4175,
1006,
9140,
1035,
11307,
1006,
1002,
2023,
1011,
1028,
8168,
1010,
3853,
1006,
1002,
4443,
1007,
2224,
1006,
1002,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.getSetupListColumns | protected function getSetupListColumns()
{
/*
* Force all columns invisible
*/
$columns = $this->defineListColumns();
foreach ($columns as $column) {
$column->invisible = true;
}
return array_merge($columns, $this->getVisibleColumns());
} | php | protected function getSetupListColumns()
{
/*
* Force all columns invisible
*/
$columns = $this->defineListColumns();
foreach ($columns as $column) {
$column->invisible = true;
}
return array_merge($columns, $this->getVisibleColumns());
} | [
"protected",
"function",
"getSetupListColumns",
"(",
")",
"{",
"/*\n * Force all columns invisible\n */",
"$",
"columns",
"=",
"$",
"this",
"->",
"defineListColumns",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"$"... | Returns all the list columns used for list set up. | [
"Returns",
"all",
"the",
"list",
"columns",
"used",
"for",
"list",
"set",
"up",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1615-L1626 | train | Get list columns | [
30522,
5123,
3853,
4152,
3388,
6279,
9863,
25778,
2819,
3619,
1006,
1007,
1063,
1013,
1008,
1008,
2486,
2035,
7753,
8841,
1008,
1013,
1002,
7753,
1027,
1002,
2023,
1011,
1028,
9375,
9863,
25778,
2819,
3619,
1006,
1007,
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/Database/Eloquent/FactoryBuilder.php | FactoryBuilder.stateHasAfterCallback | protected function stateHasAfterCallback($state)
{
return isset($this->afterMaking[$this->class][$state]) ||
isset($this->afterCreating[$this->class][$state]);
} | php | protected function stateHasAfterCallback($state)
{
return isset($this->afterMaking[$this->class][$state]) ||
isset($this->afterCreating[$this->class][$state]);
} | [
"protected",
"function",
"stateHasAfterCallback",
"(",
"$",
"state",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"afterMaking",
"[",
"$",
"this",
"->",
"class",
"]",
"[",
"$",
"state",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"afterCre... | Determine if the given state has an "after" callback.
@param string $state
@return bool | [
"Determine",
"if",
"the",
"given",
"state",
"has",
"an",
"after",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/FactoryBuilder.php#L443-L447 | train | Checks if the state has an after callback | [
30522,
5123,
3853,
2110,
14949,
10354,
3334,
9289,
20850,
8684,
1006,
1002,
2110,
1007,
1063,
2709,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2044,
12614,
1031,
1002,
2023,
1011,
1028,
2465,
1033,
1031,
1002,
2110,
1033,
1007,
1064,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php | AbstractServiceConfigurator.get | final public function get(string $id): ServiceConfigurator
{
$this->__destruct();
return $this->parent->get($id);
} | php | final public function get(string $id): ServiceConfigurator
{
$this->__destruct();
return $this->parent->get($id);
} | [
"final",
"public",
"function",
"get",
"(",
"string",
"$",
"id",
")",
":",
"ServiceConfigurator",
"{",
"$",
"this",
"->",
"__destruct",
"(",
")",
";",
"return",
"$",
"this",
"->",
"parent",
"->",
"get",
"(",
"$",
"id",
")",
";",
"}"
] | Gets an already defined service definition.
@throws ServiceNotFoundException if the service definition does not exist | [
"Gets",
"an",
"already",
"defined",
"service",
"definition",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php#L77-L82 | train | Get a record from the pool | [
30522,
2345,
2270,
3853,
2131,
1006,
5164,
1002,
8909,
30524,
1025,
2709,
1002,
2023,
1011,
1028,
6687,
1011,
1028,
2131,
1006,
1002,
8909,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/PropertyNormalizer.php | PropertyNormalizer.setAttributeValue | protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = [])
{
try {
$reflectionProperty = $this->getReflectionProperty($object, $attribute);
} catch (\ReflectionException $reflectionException) {
return;
}
if ($reflectionProperty->isStatic()) {
return;
}
// Override visibility
if (!$reflectionProperty->isPublic()) {
$reflectionProperty->setAccessible(true);
}
$reflectionProperty->setValue($object, $value);
} | php | protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = [])
{
try {
$reflectionProperty = $this->getReflectionProperty($object, $attribute);
} catch (\ReflectionException $reflectionException) {
return;
}
if ($reflectionProperty->isStatic()) {
return;
}
// Override visibility
if (!$reflectionProperty->isPublic()) {
$reflectionProperty->setAccessible(true);
}
$reflectionProperty->setValue($object, $value);
} | [
"protected",
"function",
"setAttributeValue",
"(",
"$",
"object",
",",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"reflectionProperty",
"=",
"$",
"this",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php#L140-L158 | train | Set the value of an attribute on the object | [
30522,
5123,
3853,
2275,
19321,
3089,
8569,
2618,
10175,
5657,
1006,
1002,
4874,
1010,
1002,
17961,
1010,
1002,
3643,
1010,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
3046,
1063,
1002,
9185,
21572,
4842,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DataAccess/Model.php | Model.getArchiveIdsForDeletedSegments | public function getArchiveIdsForDeletedSegments($archiveTableName, array $segmentHashesById, $oldestToKeep)
{
$validSegmentClauses = [];
foreach ($segmentHashesById as $idSite => $segments) {
// segments are md5 hashes and such not a problem re sql injection. for performance etc we don't want to use
// bound parameters for the query
foreach ($segments as $segment) {
if (!ctype_xdigit($segment)) {
throw new Exception($segment . ' expected to be an md5 hash');
}
}
// Special case as idsite=0 means the segments are not site-specific
if ($idSite === 0) {
foreach ($segments as $segmentHash) {
$validSegmentClauses[] = '(name LIKE "done' . $segmentHash . '%")';
}
continue;
}
$idSite = (int)$idSite;
// Vanilla case - segments that are valid for a single site only
$sql = '(idsite = ' . $idSite . ' AND (';
$sql .= 'name LIKE "done' . implode('%" OR name LIKE "done', $segments) . '%"';
$sql .= '))';
$validSegmentClauses[] = $sql;
}
$isValidSegmentSql = implode(' OR ', $validSegmentClauses);
$sql = 'SELECT idarchive FROM ' . $archiveTableName
. ' WHERE name LIKE "done%" AND name != "done"'
. ' AND ts_archived < ?'
. ' AND NOT (' . $isValidSegmentSql . ')';
$rows = Db::fetchAll($sql, array($oldestToKeep));
return array_map(function($row) { return $row['idarchive']; }, $rows);
} | php | public function getArchiveIdsForDeletedSegments($archiveTableName, array $segmentHashesById, $oldestToKeep)
{
$validSegmentClauses = [];
foreach ($segmentHashesById as $idSite => $segments) {
// segments are md5 hashes and such not a problem re sql injection. for performance etc we don't want to use
// bound parameters for the query
foreach ($segments as $segment) {
if (!ctype_xdigit($segment)) {
throw new Exception($segment . ' expected to be an md5 hash');
}
}
// Special case as idsite=0 means the segments are not site-specific
if ($idSite === 0) {
foreach ($segments as $segmentHash) {
$validSegmentClauses[] = '(name LIKE "done' . $segmentHash . '%")';
}
continue;
}
$idSite = (int)$idSite;
// Vanilla case - segments that are valid for a single site only
$sql = '(idsite = ' . $idSite . ' AND (';
$sql .= 'name LIKE "done' . implode('%" OR name LIKE "done', $segments) . '%"';
$sql .= '))';
$validSegmentClauses[] = $sql;
}
$isValidSegmentSql = implode(' OR ', $validSegmentClauses);
$sql = 'SELECT idarchive FROM ' . $archiveTableName
. ' WHERE name LIKE "done%" AND name != "done"'
. ' AND ts_archived < ?'
. ' AND NOT (' . $isValidSegmentSql . ')';
$rows = Db::fetchAll($sql, array($oldestToKeep));
return array_map(function($row) { return $row['idarchive']; }, $rows);
} | [
"public",
"function",
"getArchiveIdsForDeletedSegments",
"(",
"$",
"archiveTableName",
",",
"array",
"$",
"segmentHashesById",
",",
"$",
"oldestToKeep",
")",
"{",
"$",
"validSegmentClauses",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"segmentHashesById",
"as",
"$",
... | Get a list of IDs of archives with segments that no longer exist in the DB. Excludes temporary archives that
may still be in use, as specified by the $oldestToKeep passed in.
@param string $archiveTableName
@param array $segmentHashesById Whitelist of existing segments, indexed by site ID
@param string $oldestToKeep Datetime string
@return array With keys idarchive, name, idsite | [
"Get",
"a",
"list",
"of",
"IDs",
"of",
"archives",
"with",
"segments",
"that",
"no",
"longer",
"exist",
"in",
"the",
"DB",
".",
"Excludes",
"temporary",
"archives",
"that",
"may",
"still",
"be",
"in",
"use",
"as",
"specified",
"by",
"the",
"$oldestToKeep",... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/Model.php#L363-L403 | train | Returns archive ids for deleted segments | [
30522,
2270,
3853,
2131,
2906,
5428,
3726,
9821,
3877,
12260,
3064,
3366,
21693,
11187,
1006,
1002,
8756,
10880,
18442,
1010,
9140,
1002,
6903,
14949,
15689,
3762,
3593,
1010,
1002,
4587,
18715,
4402,
2361,
1007,
1063,
1002,
9398,
3366,
216... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Actions/ArchivingHelper.php | ArchivingHelper.getUnknownActionName | public static function getUnknownActionName($type)
{
if (empty(self::$defaultActionNameWhenNotDefined)) {
self::$defaultActionNameWhenNotDefined = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageName'));
self::$defaultActionUrlWhenNotDefined = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageURL'));
}
if ($type == Action::TYPE_PAGE_TITLE) {
return self::$defaultActionNameWhenNotDefined;
}
return self::$defaultActionUrlWhenNotDefined;
} | php | public static function getUnknownActionName($type)
{
if (empty(self::$defaultActionNameWhenNotDefined)) {
self::$defaultActionNameWhenNotDefined = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageName'));
self::$defaultActionUrlWhenNotDefined = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageURL'));
}
if ($type == Action::TYPE_PAGE_TITLE) {
return self::$defaultActionNameWhenNotDefined;
}
return self::$defaultActionUrlWhenNotDefined;
} | [
"public",
"static",
"function",
"getUnknownActionName",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"defaultActionNameWhenNotDefined",
")",
")",
"{",
"self",
"::",
"$",
"defaultActionNameWhenNotDefined",
"=",
"Piwik",
"::",
"translate... | Returns default label for the action type
@param $type
@return string | [
"Returns",
"default",
"label",
"for",
"the",
"action",
"type"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/ArchivingHelper.php#L416-L426 | train | Get unknown action name | [
30522,
2270,
10763,
3853,
2131,
16814,
19779,
18357,
3508,
18442,
1006,
1002,
2828,
1007,
1063,
2065,
1006,
4064,
1006,
2969,
1024,
1024,
1002,
12398,
18908,
3258,
18442,
2860,
10222,
17048,
3207,
23460,
2094,
1007,
1007,
1063,
2969,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/NavigationManager.php | NavigationManager.loadItems | protected function loadItems()
{
/*
* Load module items
*/
foreach ($this->callbacks as $callback) {
$callback($this);
}
/*
* Load plugin items
*/
$plugins = $this->pluginManager->getPlugins();
foreach ($plugins as $id => $plugin) {
$items = $plugin->registerNavigation();
if (!is_array($items)) {
continue;
}
$this->registerMenuItems($id, $items);
}
/*
* Extensibility
*/
Event::fire('backend.menu.extendItems', [$this]);
/*
* Sort menu items
*/
uasort($this->items, function ($a, $b) {
return $a->order - $b->order;
});
/*
* Filter items user lacks permission for
*/
$user = BackendAuth::getUser();
$this->items = $this->filterItemPermissions($user, $this->items);
foreach ($this->items as $item) {
if (!$item->sideMenu || !count($item->sideMenu)) {
continue;
}
/*
* Apply incremental default orders
*/
$orderCount = 0;
foreach ($item->sideMenu as $sideMenuItem) {
if ($sideMenuItem->order !== -1) continue;
$sideMenuItem->order = ($orderCount += 100);
}
/*
* Sort side menu items
*/
uasort($item->sideMenu, function ($a, $b) {
return $a->order - $b->order;
});
/*
* Filter items user lacks permission for
*/
$item->sideMenu = $this->filterItemPermissions($user, $item->sideMenu);
}
} | php | protected function loadItems()
{
/*
* Load module items
*/
foreach ($this->callbacks as $callback) {
$callback($this);
}
/*
* Load plugin items
*/
$plugins = $this->pluginManager->getPlugins();
foreach ($plugins as $id => $plugin) {
$items = $plugin->registerNavigation();
if (!is_array($items)) {
continue;
}
$this->registerMenuItems($id, $items);
}
/*
* Extensibility
*/
Event::fire('backend.menu.extendItems', [$this]);
/*
* Sort menu items
*/
uasort($this->items, function ($a, $b) {
return $a->order - $b->order;
});
/*
* Filter items user lacks permission for
*/
$user = BackendAuth::getUser();
$this->items = $this->filterItemPermissions($user, $this->items);
foreach ($this->items as $item) {
if (!$item->sideMenu || !count($item->sideMenu)) {
continue;
}
/*
* Apply incremental default orders
*/
$orderCount = 0;
foreach ($item->sideMenu as $sideMenuItem) {
if ($sideMenuItem->order !== -1) continue;
$sideMenuItem->order = ($orderCount += 100);
}
/*
* Sort side menu items
*/
uasort($item->sideMenu, function ($a, $b) {
return $a->order - $b->order;
});
/*
* Filter items user lacks permission for
*/
$item->sideMenu = $this->filterItemPermissions($user, $item->sideMenu);
}
} | [
"protected",
"function",
"loadItems",
"(",
")",
"{",
"/*\n * Load module items\n */",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"as",
"$",
"callback",
")",
"{",
"$",
"callback",
"(",
"$",
"this",
")",
";",
"}",
"/*\n * Load plugin ite... | Loads the menu items from modules and plugins
@return void | [
"Loads",
"the",
"menu",
"items",
"from",
"modules",
"and",
"plugins"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/NavigationManager.php#L74-L141 | train | Load menu items | [
30522,
5123,
3853,
7170,
4221,
5244,
1006,
1007,
1063,
1013,
1008,
1008,
7170,
11336,
5167,
1008,
1013,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2655,
12221,
2004,
1002,
2655,
5963,
1007,
1063,
1002,
2655,
5963,
1006,
1002,
2023,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php | ReflectionExtractor.isWritable | public function isWritable($class, $property, array $context = [])
{
if ($this->isAllowedProperty($class, $property)) {
return true;
}
list($reflectionMethod) = $this->getMutatorMethod($class, $property);
return null !== $reflectionMethod;
} | php | public function isWritable($class, $property, array $context = [])
{
if ($this->isAllowedProperty($class, $property)) {
return true;
}
list($reflectionMethod) = $this->getMutatorMethod($class, $property);
return null !== $reflectionMethod;
} | [
"public",
"function",
"isWritable",
"(",
"$",
"class",
",",
"$",
"property",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAllowedProperty",
"(",
"$",
"class",
",",
"$",
"property",
")",
")",
"{",
"return",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php#L173-L182 | train | Returns true if the property is writable | [
30522,
2270,
3853,
2003,
13088,
6590,
3468,
1006,
1002,
2465,
1010,
1002,
3200,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
18061,
7174,
15557,
21572,
4842,
3723,
1006,
1002,
2465,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.detectGoalMatch | public function detectGoalMatch($goal, Action $action)
{
$actionType = $action->getActionType();
$attribute = $goal['match_attribute'];
// if the attribute to match is not the type of the current action
if ((($attribute == 'url' || $attribute == 'title') && $actionType != Action::TYPE_PAGE_URL)
|| ($attribute == 'file' && $actionType != Action::TYPE_DOWNLOAD)
|| ($attribute == 'external_website' && $actionType != Action::TYPE_OUTLINK)
|| ($attribute == 'manually')
|| self::isEventMatchingGoal($goal) && $actionType != Action::TYPE_EVENT
) {
return null;
}
switch ($attribute) {
case 'title':
// Matching on Page Title
$actionToMatch = $action->getActionName();
break;
case 'event_action':
$actionToMatch = $action->getEventAction();
break;
case 'event_name':
$actionToMatch = $action->getEventName();
break;
case 'event_category':
$actionToMatch = $action->getEventCategory();
break;
// url, external_website, file, manually...
default:
$actionToMatch = $action->getActionUrlRaw();
break;
}
$pattern_type = $goal['pattern_type'];
$match = $this->isUrlMatchingGoal($goal, $pattern_type, $actionToMatch);
if (!$match) {
return null;
}
return $action->getActionUrl();
} | php | public function detectGoalMatch($goal, Action $action)
{
$actionType = $action->getActionType();
$attribute = $goal['match_attribute'];
// if the attribute to match is not the type of the current action
if ((($attribute == 'url' || $attribute == 'title') && $actionType != Action::TYPE_PAGE_URL)
|| ($attribute == 'file' && $actionType != Action::TYPE_DOWNLOAD)
|| ($attribute == 'external_website' && $actionType != Action::TYPE_OUTLINK)
|| ($attribute == 'manually')
|| self::isEventMatchingGoal($goal) && $actionType != Action::TYPE_EVENT
) {
return null;
}
switch ($attribute) {
case 'title':
// Matching on Page Title
$actionToMatch = $action->getActionName();
break;
case 'event_action':
$actionToMatch = $action->getEventAction();
break;
case 'event_name':
$actionToMatch = $action->getEventName();
break;
case 'event_category':
$actionToMatch = $action->getEventCategory();
break;
// url, external_website, file, manually...
default:
$actionToMatch = $action->getActionUrlRaw();
break;
}
$pattern_type = $goal['pattern_type'];
$match = $this->isUrlMatchingGoal($goal, $pattern_type, $actionToMatch);
if (!$match) {
return null;
}
return $action->getActionUrl();
} | [
"public",
"function",
"detectGoalMatch",
"(",
"$",
"goal",
",",
"Action",
"$",
"action",
")",
"{",
"$",
"actionType",
"=",
"$",
"action",
"->",
"getActionType",
"(",
")",
";",
"$",
"attribute",
"=",
"$",
"goal",
"[",
"'match_attribute'",
"]",
";",
"// if... | Detects if an Action matches a given goal. If it does, the URL that triggered the goal
is returned. Otherwise null is returned.
@param array $goal
@param Action $action
@return if a goal is matched, a string of the Action URL is returned, or if no goal was matched it returns null | [
"Detects",
"if",
"an",
"Action",
"matches",
"a",
"given",
"goal",
".",
"If",
"it",
"does",
"the",
"URL",
"that",
"triggered",
"the",
"goal",
"is",
"returned",
".",
"Otherwise",
"null",
"is",
"returned",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L151-L196 | train | Detects if the goal matches the current action | [
30522,
2270,
3853,
11487,
3995,
2389,
18900,
2818,
1006,
1002,
3125,
1010,
2895,
1002,
2895,
1007,
1063,
1002,
2895,
13874,
1027,
1002,
2895,
1011,
1028,
2131,
18908,
3258,
13874,
1006,
1007,
1025,
1002,
17961,
1027,
1002,
3125,
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... |
symfony/symfony | src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php | Collection.toArray | public function toArray()
{
if (null === $this->entries) {
$this->entries = iterator_to_array($this->getIterator(), false);
}
return $this->entries;
} | php | public function toArray()
{
if (null === $this->entries) {
$this->entries = iterator_to_array($this->getIterator(), false);
}
return $this->entries;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"entries",
")",
"{",
"$",
"this",
"->",
"entries",
"=",
"iterator_to_array",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"false",
")",
";",
"}",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Ldap/Adapter/ExtLdap/Collection.php#L36-L43 | train | Returns the entries as an array | [
30522,
2270,
3853,
2000,
2906,
9447,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
10445,
1007,
1063,
1002,
2023,
1011,
1028,
10445,
1027,
2009,
6906,
4263,
1035,
2000,
1035,
9140,
1006,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable.php | DataTable.rebuildIndex | public function rebuildIndex()
{
$this->rowsIndexByLabel = array();
$this->rebuildIndexContinuously = true;
foreach ($this->rows as $id => $row) {
$label = $row->getColumn('label');
if ($label !== false) {
$this->rowsIndexByLabel[$label] = $id;
}
}
if ($this->summaryRow) {
$label = $this->summaryRow->getColumn('label');
if ($label !== false) {
$this->rowsIndexByLabel[$label] = DataTable::ID_SUMMARY_ROW;
}
}
$this->indexNotUpToDate = false;
} | php | public function rebuildIndex()
{
$this->rowsIndexByLabel = array();
$this->rebuildIndexContinuously = true;
foreach ($this->rows as $id => $row) {
$label = $row->getColumn('label');
if ($label !== false) {
$this->rowsIndexByLabel[$label] = $id;
}
}
if ($this->summaryRow) {
$label = $this->summaryRow->getColumn('label');
if ($label !== false) {
$this->rowsIndexByLabel[$label] = DataTable::ID_SUMMARY_ROW;
}
}
$this->indexNotUpToDate = false;
} | [
"public",
"function",
"rebuildIndex",
"(",
")",
"{",
"$",
"this",
"->",
"rowsIndexByLabel",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"rebuildIndexContinuously",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"id",
"=>",
... | Rebuilds the index used to lookup a row by label
@internal | [
"Rebuilds",
"the",
"index",
"used",
"to",
"lookup",
"a",
"row",
"by",
"label"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L722-L742 | train | Rebuild index by label | [
30522,
2270,
3853,
14591,
22254,
10288,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
10281,
22254,
10288,
3762,
20470,
2884,
1027,
9140,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
14591,
22254,
10288,
8663,
7629,
28078,
1027,
2995,
1025,
18921,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/User/FlexUser/User.php | User.joinDefaults | public function joinDefaults($name, $value, $separator = null)
{
if (\is_object($value)) {
$value = (array) $value;
}
$old = $this->get($name, null, $separator);
if ($old !== null) {
$value = $this->getBlueprint()->mergeData($value, $old, $name, $separator);
}
$this->setNestedProperty($name, $value, $separator);
return $this;
} | php | public function joinDefaults($name, $value, $separator = null)
{
if (\is_object($value)) {
$value = (array) $value;
}
$old = $this->get($name, null, $separator);
if ($old !== null) {
$value = $this->getBlueprint()->mergeData($value, $old, $name, $separator);
}
$this->setNestedProperty($name, $value, $separator);
return $this;
} | [
"public",
"function",
"joinDefaults",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"separator",
"=",
"null",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"value",
";",
"}",... | Set default values by using blueprints.
@param string $name Dot separated path to the requested value.
@param mixed $value Value to be joined.
@param string $separator Separator, defaults to '.'
@return $this | [
"Set",
"default",
"values",
"by",
"using",
"blueprints",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/FlexUser/User.php#L289-L303 | train | Join default values with the new values | [
30522,
2270,
3853,
3693,
3207,
7011,
11314,
2015,
1006,
1002,
2171,
1010,
1002,
3643,
1010,
1002,
19802,
25879,
2953,
1027,
19701,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
4874,
1006,
1002,
3643,
1007,
1007,
1063,
1002,
3643,
1027,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/Loader.php | Loader.getSourceContext | public function getSourceContext($name)
{
if (!$this->validateCmsObject($name)) {
return parent::getSourceContext($name);
}
$content = $this->obj->getTwigContent();
/**
* @event cms.template.processTwigContent
* Provides an oportunity to modify Twig content before being processed by Twig. `$dataHolder` = {content: $twigContent}
*
* Example usage:
*
* Event::listen('cms.template.processTwigContent', function ((\Cms\Classes\CmsObject) $thisObject, (object) $dataHolder) {
* $dataHolder->content = "NO CONTENT FOR YOU!";
* });
*
*/
$dataHolder = (object) ['content' => $content];
Event::fire('cms.template.processTwigContent', [$this->obj, $dataHolder]);
return new Twig_Source($dataHolder->content, $name);
} | php | public function getSourceContext($name)
{
if (!$this->validateCmsObject($name)) {
return parent::getSourceContext($name);
}
$content = $this->obj->getTwigContent();
/**
* @event cms.template.processTwigContent
* Provides an oportunity to modify Twig content before being processed by Twig. `$dataHolder` = {content: $twigContent}
*
* Example usage:
*
* Event::listen('cms.template.processTwigContent', function ((\Cms\Classes\CmsObject) $thisObject, (object) $dataHolder) {
* $dataHolder->content = "NO CONTENT FOR YOU!";
* });
*
*/
$dataHolder = (object) ['content' => $content];
Event::fire('cms.template.processTwigContent', [$this->obj, $dataHolder]);
return new Twig_Source($dataHolder->content, $name);
} | [
"public",
"function",
"getSourceContext",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateCmsObject",
"(",
"$",
"name",
")",
")",
"{",
"return",
"parent",
"::",
"getSourceContext",
"(",
"$",
"name",
")",
";",
"}",
"$",
"content"... | Returns the Twig content string.
This step is cached internally by Twig. | [
"Returns",
"the",
"Twig",
"content",
"string",
".",
"This",
"step",
"is",
"cached",
"internally",
"by",
"Twig",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/Loader.php#L41-L64 | train | Returns the Twig source context for the given Twig object. | [
30522,
2270,
3853,
4152,
8162,
3401,
8663,
18209,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
9398,
3686,
27487,
6499,
2497,
20614,
1006,
1002,
2171,
1007,
1007,
1063,
2709,
6687,
1024,
1024,
4152,
8162,
3401,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Migrations/Migrator.php | Migrator.getSchemaGrammar | protected function getSchemaGrammar($connection)
{
if (is_null($grammar = $connection->getSchemaGrammar())) {
$connection->useDefaultSchemaGrammar();
$grammar = $connection->getSchemaGrammar();
}
return $grammar;
} | php | protected function getSchemaGrammar($connection)
{
if (is_null($grammar = $connection->getSchemaGrammar())) {
$connection->useDefaultSchemaGrammar();
$grammar = $connection->getSchemaGrammar();
}
return $grammar;
} | [
"protected",
"function",
"getSchemaGrammar",
"(",
"$",
"connection",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"grammar",
"=",
"$",
"connection",
"->",
"getSchemaGrammar",
"(",
")",
")",
")",
"{",
"$",
"connection",
"->",
"useDefaultSchemaGrammar",
"(",
")",... | Get the schema grammar out of a migration connection.
@param \Illuminate\Database\Connection $connection
@return \Illuminate\Database\Schema\Grammars\Grammar | [
"Get",
"the",
"schema",
"grammar",
"out",
"of",
"a",
"migration",
"connection",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Migrations/Migrator.php#L555-L564 | train | Get the schema grammar | [
30522,
5123,
3853,
4152,
5403,
2863,
13113,
7849,
1006,
1002,
4434,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
8035,
1027,
1002,
4434,
1011,
1028,
4152,
5403,
2863,
13113,
7849,
1006,
1007,
1007,
1007,
1063,
1002,
4434,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/RedirectResponse.php | RedirectResponse.setTargetUrl | public function setTargetUrl($url)
{
if (empty($url)) {
throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
}
$this->targetUrl = $url;
$this->setContent(
sprintf('<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0;url=%1$s" />
<title>Redirecting to %1$s</title>
</head>
<body>
Redirecting to <a href="%1$s">%1$s</a>.
</body>
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')));
$this->headers->set('Location', $url);
return $this;
} | php | public function setTargetUrl($url)
{
if (empty($url)) {
throw new \InvalidArgumentException('Cannot redirect to an empty URL.');
}
$this->targetUrl = $url;
$this->setContent(
sprintf('<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="0;url=%1$s" />
<title>Redirecting to %1$s</title>
</head>
<body>
Redirecting to <a href="%1$s">%1$s</a>.
</body>
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')));
$this->headers->set('Location', $url);
return $this;
} | [
"public",
"function",
"setTargetUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Cannot redirect to an empty URL.'",
")",
";",
"}",
"$",
"this",
"->",
"targetUrl",
... | Sets the redirect target of this response.
@param string $url The URL to redirect to
@return $this
@throws \InvalidArgumentException | [
"Sets",
"the",
"redirect",
"target",
"of",
"this",
"response",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/RedirectResponse.php#L83-L108 | train | Set the target URL | [
30522,
2270,
3853,
2275,
7559,
18150,
3126,
2140,
1006,
1002,
24471,
2140,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
24471,
2140,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422,
1006,
1005,
3685,
2417,
7442,
6593... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DatabaseQueue.php | DatabaseQueue.pop | public function pop($queue = null)
{
$queue = $this->getQueue($queue);
return $this->database->transaction(function () use ($queue) {
if ($job = $this->getNextAvailableJob($queue)) {
return $this->marshalJob($queue, $job);
}
});
} | php | public function pop($queue = null)
{
$queue = $this->getQueue($queue);
return $this->database->transaction(function () use ($queue) {
if ($job = $this->getNextAvailableJob($queue)) {
return $this->marshalJob($queue, $job);
}
});
} | [
"public",
"function",
"pop",
"(",
"$",
"queue",
"=",
"null",
")",
"{",
"$",
"queue",
"=",
"$",
"this",
"->",
"getQueue",
"(",
"$",
"queue",
")",
";",
"return",
"$",
"this",
"->",
"database",
"->",
"transaction",
"(",
"function",
"(",
")",
"use",
"(... | Pop the next job off of the queue.
@param string $queue
@return \Illuminate\Contracts\Queue\Job|null
@throws \Exception|\Throwable | [
"Pop",
"the",
"next",
"job",
"off",
"of",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/DatabaseQueue.php#L194-L203 | train | Pop a job from the queue | [
30522,
2270,
3853,
3769,
1006,
1002,
24240,
1027,
19701,
1007,
1063,
1002,
24240,
1027,
1002,
2023,
1011,
1028,
2131,
4226,
5657,
1006,
1002,
24240,
1007,
1025,
2709,
1002,
2023,
1011,
1028,
7809,
1011,
1028,
12598,
1006,
3853,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/DescriptorHelper.php | DescriptorHelper.describe | public function describe(OutputInterface $output, $object, array $options = [])
{
$options = array_merge([
'raw_text' => false,
'format' => 'txt',
], $options);
if (!isset($this->descriptors[$options['format']])) {
throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
}
$descriptor = $this->descriptors[$options['format']];
$descriptor->describe($output, $object, $options);
} | php | public function describe(OutputInterface $output, $object, array $options = [])
{
$options = array_merge([
'raw_text' => false,
'format' => 'txt',
], $options);
if (!isset($this->descriptors[$options['format']])) {
throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
}
$descriptor = $this->descriptors[$options['format']];
$descriptor->describe($output, $object, $options);
} | [
"public",
"function",
"describe",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"object",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"[",
"'raw_text'",
"=>",
"false",
",",
"'format'",
"=>",
"'txt'",... | Describes an object if supported.
Available options are:
* format: string, the output format name
* raw_text: boolean, sets output type as raw
@param OutputInterface $output
@param object $object
@param array $options
@throws InvalidArgumentException when the given format is not supported | [
"Describes",
"an",
"object",
"if",
"supported",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/DescriptorHelper.php#L57-L70 | train | Describes the language | [
30522,
2270,
3853,
6235,
1006,
6434,
18447,
2121,
12172,
1002,
6434,
1010,
1002,
4874,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
7047,
1027,
9140,
1035,
13590,
1006,
1031,
1005,
6315,
1035,
3793,
1005,
1027,
1028,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Envelope.php | Envelope.wrap | public static function wrap($message, array $stamps = []): self
{
$envelope = $message instanceof self ? $message : new self($message);
return $envelope->with(...$stamps);
} | php | public static function wrap($message, array $stamps = []): self
{
$envelope = $message instanceof self ? $message : new self($message);
return $envelope->with(...$stamps);
} | [
"public",
"static",
"function",
"wrap",
"(",
"$",
"message",
",",
"array",
"$",
"stamps",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"envelope",
"=",
"$",
"message",
"instanceof",
"self",
"?",
"$",
"message",
":",
"new",
"self",
"(",
"$",
"message",
... | Makes sure the message is in an Envelope and adds the given stamps.
@param object|Envelope $message
@param StampInterface[] $stamps | [
"Makes",
"sure",
"the",
"message",
"is",
"in",
"an",
"Envelope",
"and",
"adds",
"the",
"given",
"stamps",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Envelope.php#L50-L55 | train | Wrap the message in a self object with stamps | [
30522,
2270,
10763,
3853,
10236,
1006,
1002,
4471,
1010,
9140,
1002,
12133,
1027,
1031,
1033,
1007,
1024,
2969,
1063,
1002,
11255,
1027,
1002,
4471,
6013,
11253,
2969,
1029,
1002,
4471,
1024,
2047,
2969,
1006,
1002,
4471,
1007,
1025,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataAccess/LogAggregator.php | LogAggregator.makeArrayOneColumn | public static function makeArrayOneColumn($row, $columnName, $lookForThisPrefix = false)
{
$cleanRow = array();
foreach ($row as $label => $count) {
if (empty($lookForThisPrefix)
|| strpos($label, $lookForThisPrefix) === 0
) {
$cleanLabel = substr($label, strlen($lookForThisPrefix));
$cleanRow[$cleanLabel] = array($columnName => $count);
}
}
return $cleanRow;
} | php | public static function makeArrayOneColumn($row, $columnName, $lookForThisPrefix = false)
{
$cleanRow = array();
foreach ($row as $label => $count) {
if (empty($lookForThisPrefix)
|| strpos($label, $lookForThisPrefix) === 0
) {
$cleanLabel = substr($label, strlen($lookForThisPrefix));
$cleanRow[$cleanLabel] = array($columnName => $count);
}
}
return $cleanRow;
} | [
"public",
"static",
"function",
"makeArrayOneColumn",
"(",
"$",
"row",
",",
"$",
"columnName",
",",
"$",
"lookForThisPrefix",
"=",
"false",
")",
"{",
"$",
"cleanRow",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"label",
"=>",
"$... | Clean up the row data and return values.
$lookForThisPrefix can be used to make sure only SOME of the data in $row is used.
The array will have one column $columnName
@param $row
@param $columnName
@param bool $lookForThisPrefix A string that identifies which elements of $row to use
in the result. Every key of $row that starts with this
value is used.
@return array | [
"Clean",
"up",
"the",
"row",
"data",
"and",
"return",
"values",
".",
"$lookForThisPrefix",
"can",
"be",
"used",
"to",
"make",
"sure",
"only",
"SOME",
"of",
"the",
"data",
"in",
"$row",
"is",
"used",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/LogAggregator.php#L941-L955 | train | This method is used to make an array of columns | [
30522,
2270,
10763,
3853,
2191,
2906,
9447,
5643,
25778,
2819,
2078,
1006,
1002,
5216,
1010,
1002,
5930,
18442,
1010,
1002,
2298,
15628,
2483,
28139,
8873,
2595,
1027,
6270,
1007,
1063,
1002,
4550,
10524,
1027,
9140,
1006,
1007,
1025,
18921... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/GPM/Installer.php | Installer.isGravInstance | public static function isGravInstance($target)
{
self::$error = 0;
self::$target = $target;
if (
!file_exists($target . DS . 'index.php') ||
!file_exists($target . DS . 'bin') ||
!file_exists($target . DS . 'user') ||
!file_exists($target . DS . 'system' . DS . 'config' . DS . 'system.yaml')
) {
self::$error = self::NOT_GRAV_ROOT;
}
return !self::$error;
} | php | public static function isGravInstance($target)
{
self::$error = 0;
self::$target = $target;
if (
!file_exists($target . DS . 'index.php') ||
!file_exists($target . DS . 'bin') ||
!file_exists($target . DS . 'user') ||
!file_exists($target . DS . 'system' . DS . 'config' . DS . 'system.yaml')
) {
self::$error = self::NOT_GRAV_ROOT;
}
return !self::$error;
} | [
"public",
"static",
"function",
"isGravInstance",
"(",
"$",
"target",
")",
"{",
"self",
"::",
"$",
"error",
"=",
"0",
";",
"self",
"::",
"$",
"target",
"=",
"$",
"target",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"target",
".",
"DS",
".",
"'in... | Validates if the given path is a Grav Instance
@param string $target The local path to the Grav Instance
@return bool True if is a Grav Instance. False otherwise | [
"Validates",
"if",
"the",
"given",
"path",
"is",
"a",
"Grav",
"Instance"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/Installer.php#L408-L423 | train | Return TRUE if the target directory is a Grav instance | [
30522,
2270,
10763,
3853,
2003,
17643,
6371,
12693,
3401,
1006,
1002,
4539,
1007,
1063,
2969,
1024,
1024,
1002,
7561,
1027,
1014,
1025,
2969,
1024,
1024,
1002,
4539,
1027,
1002,
4539,
1025,
2065,
1006,
999,
5371,
1035,
6526,
1006,
1002,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/traits/AssetMaker.php | AssetMaker.getAssetEntryBuildPath | protected function getAssetEntryBuildPath($asset)
{
$path = $asset['path'];
if (isset($asset['attributes']['build'])) {
$build = $asset['attributes']['build'];
if ($build == 'core') {
$build = 'v' . Parameter::get('system::core.build', 1);
}
elseif ($pluginVersion = PluginVersion::getVersion($build)) {
$build = 'v' . $pluginVersion;
}
$path .= '?' . $build;
}
return $path;
} | php | protected function getAssetEntryBuildPath($asset)
{
$path = $asset['path'];
if (isset($asset['attributes']['build'])) {
$build = $asset['attributes']['build'];
if ($build == 'core') {
$build = 'v' . Parameter::get('system::core.build', 1);
}
elseif ($pluginVersion = PluginVersion::getVersion($build)) {
$build = 'v' . $pluginVersion;
}
$path .= '?' . $build;
}
return $path;
} | [
"protected",
"function",
"getAssetEntryBuildPath",
"(",
"$",
"asset",
")",
"{",
"$",
"path",
"=",
"$",
"asset",
"[",
"'path'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"asset",
"[",
"'attributes'",
"]",
"[",
"'build'",
"]",
")",
")",
"{",
"$",
"build"... | Internal helper, attaches a build code to an asset path
@param array $asset Stored asset array
@return string | [
"Internal",
"helper",
"attaches",
"a",
"build",
"code",
"to",
"an",
"asset",
"path"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/AssetMaker.php#L266-L283 | train | Get Asset Entry Build Path | [
30522,
5123,
3853,
2131,
27241,
6528,
11129,
8569,
4014,
18927,
8988,
1006,
1002,
11412,
1007,
1063,
1002,
4130,
1027,
1002,
11412,
1031,
1005,
4130,
1005,
1033,
1025,
2065,
1006,
26354,
3388,
1006,
1002,
11412,
1031,
1005,
12332,
1005,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Table/Abstract.php | Zend_Db_Table_Abstract._setupPrimaryKey | protected function _setupPrimaryKey()
{
if (!$this->_primary) {
$this->_setupMetadata();
$this->_primary = array();
foreach ($this->_metadata as $col) {
if ($col['PRIMARY']) {
$this->_primary[ $col['PRIMARY_POSITION'] ] = $col['COLUMN_NAME'];
if ($col['IDENTITY']) {
$this->_identity = $col['PRIMARY_POSITION'];
}
}
}
// if no primary key was specified and none was found in the metadata
// then throw an exception.
if (empty($this->_primary)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception('A table must have a primary key, but none was found');
}
} else if (!is_array($this->_primary)) {
$this->_primary = array(1 => $this->_primary);
} else if (isset($this->_primary[0])) {
array_unshift($this->_primary, null);
unset($this->_primary[0]);
}
$cols = $this->_getCols();
if (! array_intersect((array) $this->_primary, $cols) == (array) $this->_primary) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Primary key column(s) ("
. implode(',', (array) $this->_primary)
. ") are not columns in this table ("
. implode(',', $cols)
. ")");
}
$primary = (array) $this->_primary;
$pkIdentity = $primary[(int) $this->_identity];
/**
* Special case for PostgreSQL: a SERIAL key implicitly uses a sequence
* object whose name is "<table>_<column>_seq".
*/
if ($this->_sequence === true && $this->_db instanceof Zend_Db_Adapter_Pdo_Pgsql) {
$this->_sequence = $this->_db->quoteIdentifier("{$this->_name}_{$pkIdentity}_seq");
if ($this->_schema) {
$this->_sequence = $this->_db->quoteIdentifier($this->_schema) . '.' . $this->_sequence;
}
}
} | php | protected function _setupPrimaryKey()
{
if (!$this->_primary) {
$this->_setupMetadata();
$this->_primary = array();
foreach ($this->_metadata as $col) {
if ($col['PRIMARY']) {
$this->_primary[ $col['PRIMARY_POSITION'] ] = $col['COLUMN_NAME'];
if ($col['IDENTITY']) {
$this->_identity = $col['PRIMARY_POSITION'];
}
}
}
// if no primary key was specified and none was found in the metadata
// then throw an exception.
if (empty($this->_primary)) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception('A table must have a primary key, but none was found');
}
} else if (!is_array($this->_primary)) {
$this->_primary = array(1 => $this->_primary);
} else if (isset($this->_primary[0])) {
array_unshift($this->_primary, null);
unset($this->_primary[0]);
}
$cols = $this->_getCols();
if (! array_intersect((array) $this->_primary, $cols) == (array) $this->_primary) {
// require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Primary key column(s) ("
. implode(',', (array) $this->_primary)
. ") are not columns in this table ("
. implode(',', $cols)
. ")");
}
$primary = (array) $this->_primary;
$pkIdentity = $primary[(int) $this->_identity];
/**
* Special case for PostgreSQL: a SERIAL key implicitly uses a sequence
* object whose name is "<table>_<column>_seq".
*/
if ($this->_sequence === true && $this->_db instanceof Zend_Db_Adapter_Pdo_Pgsql) {
$this->_sequence = $this->_db->quoteIdentifier("{$this->_name}_{$pkIdentity}_seq");
if ($this->_schema) {
$this->_sequence = $this->_db->quoteIdentifier($this->_schema) . '.' . $this->_sequence;
}
}
} | [
"protected",
"function",
"_setupPrimaryKey",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_primary",
")",
"{",
"$",
"this",
"->",
"_setupMetadata",
"(",
")",
";",
"$",
"this",
"->",
"_primary",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
... | Initialize primary key from metadata.
If $_primary is not defined, discover primary keys
from the information returned by describeTable().
@return void
@throws Zend_Db_Table_Exception | [
"Initialize",
"primary",
"key",
"from",
"metadata",
".",
"If",
"$_primary",
"is",
"not",
"defined",
"discover",
"primary",
"keys",
"from",
"the",
"information",
"returned",
"by",
"describeTable",
"()",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Abstract.php#L871-L920 | train | Setup the primary key | [
30522,
5123,
3853,
1035,
16437,
18098,
9581,
2854,
14839,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
3078,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
16437,
11368,
8447,
2696,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php | FullTransformer.getReverseMatchingRegExp | public function getReverseMatchingRegExp($pattern)
{
$escapedPattern = preg_quote($pattern, '/');
// ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa
// when parsing a date/time value
$escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
$reverseMatchingRegExp = preg_replace_callback($this->regExp, function ($matches) {
$length = \strlen($matches[0]);
$transformerIndex = $matches[0][0];
$dateChars = $matches[0];
if ($this->isQuoteMatch($dateChars)) {
return $this->replaceQuoteMatch($dateChars);
}
$transformers = $this->getTransformers();
if (isset($transformers[$transformerIndex])) {
$transformer = $transformers[$transformerIndex];
$captureName = str_repeat($transformerIndex, $length);
return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
}
}, $escapedPattern);
return $reverseMatchingRegExp;
} | php | public function getReverseMatchingRegExp($pattern)
{
$escapedPattern = preg_quote($pattern, '/');
// ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa
// when parsing a date/time value
$escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
$reverseMatchingRegExp = preg_replace_callback($this->regExp, function ($matches) {
$length = \strlen($matches[0]);
$transformerIndex = $matches[0][0];
$dateChars = $matches[0];
if ($this->isQuoteMatch($dateChars)) {
return $this->replaceQuoteMatch($dateChars);
}
$transformers = $this->getTransformers();
if (isset($transformers[$transformerIndex])) {
$transformer = $transformers[$transformerIndex];
$captureName = str_repeat($transformerIndex, $length);
return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
}
}, $escapedPattern);
return $reverseMatchingRegExp;
} | [
"public",
"function",
"getReverseMatchingRegExp",
"(",
"$",
"pattern",
")",
"{",
"$",
"escapedPattern",
"=",
"preg_quote",
"(",
"$",
"pattern",
",",
"'/'",
")",
";",
"// ICU 4.8 recognizes slash (\"/\") in a value to be parsed as a dash (\"-\") and vice-versa",
"// when parsi... | Retrieve a regular expression to match with a formatted value.
@param string $pattern The pattern to create the reverse matching regular expression
@return string The reverse matching regular expression with named captures being formed by the
transformer index in the $transformer array | [
"Retrieve",
"a",
"regular",
"expression",
"to",
"match",
"with",
"a",
"formatted",
"value",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php#L175-L202 | train | Returns a regular expression that matches the reverse matching pattern. | [
30522,
2270,
3853,
2131,
2890,
16070,
18900,
8450,
2890,
3351,
2595,
2361,
1006,
1002,
5418,
1007,
1063,
1002,
6376,
4502,
12079,
2078,
1027,
3653,
2290,
1035,
14686,
1006,
1002,
5418,
1010,
1005,
1013,
1005,
1007,
1025,
1013,
1013,
24582,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.followRedirect | public function followRedirect()
{
if (empty($this->redirect)) {
throw new \LogicException('The request was not redirected.');
}
if (-1 !== $this->maxRedirects) {
if ($this->redirectCount > $this->maxRedirects) {
$this->redirectCount = 0;
throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects));
}
}
$request = $this->internalRequest;
if (\in_array($this->internalResponse->getStatusCode(), [301, 302, 303])) {
$method = 'GET';
$files = [];
$content = null;
} else {
$method = $request->getMethod();
$files = $request->getFiles();
$content = $request->getContent();
}
if ('GET' === strtoupper($method)) {
// Don't forward parameters for GET request as it should reach the redirection URI
$parameters = [];
} else {
$parameters = $request->getParameters();
}
$server = $request->getServer();
$server = $this->updateServerFromUri($server, $this->redirect);
$this->isMainRequest = false;
$response = $this->request($method, $this->redirect, $parameters, $files, $server, $content);
$this->isMainRequest = true;
return $response;
} | php | public function followRedirect()
{
if (empty($this->redirect)) {
throw new \LogicException('The request was not redirected.');
}
if (-1 !== $this->maxRedirects) {
if ($this->redirectCount > $this->maxRedirects) {
$this->redirectCount = 0;
throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects));
}
}
$request = $this->internalRequest;
if (\in_array($this->internalResponse->getStatusCode(), [301, 302, 303])) {
$method = 'GET';
$files = [];
$content = null;
} else {
$method = $request->getMethod();
$files = $request->getFiles();
$content = $request->getContent();
}
if ('GET' === strtoupper($method)) {
// Don't forward parameters for GET request as it should reach the redirection URI
$parameters = [];
} else {
$parameters = $request->getParameters();
}
$server = $request->getServer();
$server = $this->updateServerFromUri($server, $this->redirect);
$this->isMainRequest = false;
$response = $this->request($method, $this->redirect, $parameters, $files, $server, $content);
$this->isMainRequest = true;
return $response;
} | [
"public",
"function",
"followRedirect",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"redirect",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'The request was not redirected.'",
")",
";",
"}",
"if",
"(",
"-",
"1",
"!==",
"$"... | Follow redirects?
@return Crawler
@throws \LogicException If request was not a redirect | [
"Follow",
"redirects?"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/Client.php#L589-L631 | train | Follows the redirection | [
30522,
2270,
3853,
3582,
5596,
7442,
6593,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
2417,
7442,
6593,
1007,
1007,
1063,
5466,
2047,
1032,
7961,
10288,
24422,
1006,
1005,
1996,
5227,
2001,
2025,
2417,
7442,
10985,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Generator/UrlGenerator.php | UrlGenerator.getRelativePath | public static function getRelativePath($basePath, $targetPath)
{
if ($basePath === $targetPath) {
return '';
}
$sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath);
$targetDirs = explode('/', isset($targetPath[0]) && '/' === $targetPath[0] ? substr($targetPath, 1) : $targetPath);
array_pop($sourceDirs);
$targetFile = array_pop($targetDirs);
foreach ($sourceDirs as $i => $dir) {
if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) {
unset($sourceDirs[$i], $targetDirs[$i]);
} else {
break;
}
}
$targetDirs[] = $targetFile;
$path = str_repeat('../', \count($sourceDirs)).implode('/', $targetDirs);
// A reference to the same base directory or an empty subdirectory must be prefixed with "./".
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
// as the first segment of a relative-path reference, as it would be mistaken for a scheme name
// (see http://tools.ietf.org/html/rfc3986#section-4.2).
return '' === $path || '/' === $path[0]
|| false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos)
? "./$path" : $path;
} | php | public static function getRelativePath($basePath, $targetPath)
{
if ($basePath === $targetPath) {
return '';
}
$sourceDirs = explode('/', isset($basePath[0]) && '/' === $basePath[0] ? substr($basePath, 1) : $basePath);
$targetDirs = explode('/', isset($targetPath[0]) && '/' === $targetPath[0] ? substr($targetPath, 1) : $targetPath);
array_pop($sourceDirs);
$targetFile = array_pop($targetDirs);
foreach ($sourceDirs as $i => $dir) {
if (isset($targetDirs[$i]) && $dir === $targetDirs[$i]) {
unset($sourceDirs[$i], $targetDirs[$i]);
} else {
break;
}
}
$targetDirs[] = $targetFile;
$path = str_repeat('../', \count($sourceDirs)).implode('/', $targetDirs);
// A reference to the same base directory or an empty subdirectory must be prefixed with "./".
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
// as the first segment of a relative-path reference, as it would be mistaken for a scheme name
// (see http://tools.ietf.org/html/rfc3986#section-4.2).
return '' === $path || '/' === $path[0]
|| false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos)
? "./$path" : $path;
} | [
"public",
"static",
"function",
"getRelativePath",
"(",
"$",
"basePath",
",",
"$",
"targetPath",
")",
"{",
"if",
"(",
"$",
"basePath",
"===",
"$",
"targetPath",
")",
"{",
"return",
"''",
";",
"}",
"$",
"sourceDirs",
"=",
"explode",
"(",
"'/'",
",",
"is... | Returns the target path as relative reference from the base path.
Only the URIs path component (no schema, host etc.) is relevant and must be given, starting with a slash.
Both paths must be absolute and not contain relative parts.
Relative URLs from one resource to another are useful when generating self-contained downloadable document archives.
Furthermore, they can be used to reduce the link size in documents.
Example target paths, given a base path of "/a/b/c/d":
- "/a/b/c/d" -> ""
- "/a/b/c/" -> "./"
- "/a/b/" -> "../"
- "/a/b/c/other" -> "other"
- "/a/x/y" -> "../../x/y"
@param string $basePath The base path
@param string $targetPath The target path
@return string The relative target path | [
"Returns",
"the",
"target",
"path",
"as",
"relative",
"reference",
"from",
"the",
"base",
"path",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Generator/UrlGenerator.php#L322-L351 | train | Returns the relative path of the file | [
30522,
2270,
10763,
3853,
2131,
16570,
8082,
15069,
1006,
1002,
2918,
15069,
1010,
1002,
4539,
15069,
1007,
1063,
2065,
1006,
1002,
2918,
15069,
1027,
1027,
1027,
1002,
4539,
15069,
1007,
1063,
2709,
1005,
1005,
1025,
1065,
1002,
23184,
188... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ImageMedium.php | ImageMedium.path | public function path($reset = true)
{
$output = $this->saveImage();
if ($reset) {
$this->reset();
}
return $output;
} | php | public function path($reset = true)
{
$output = $this->saveImage();
if ($reset) {
$this->reset();
}
return $output;
} | [
"public",
"function",
"path",
"(",
"$",
"reset",
"=",
"true",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"saveImage",
"(",
")",
";",
"if",
"(",
"$",
"reset",
")",
"{",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"}",
"return",
"$",
"output... | Return PATH to image.
@param bool $reset
@return string path to image | [
"Return",
"PATH",
"to",
"image",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ImageMedium.php#L152-L161 | train | Returns the path of the image | [
30522,
2270,
3853,
4130,
1006,
1002,
25141,
1027,
2995,
1007,
1063,
1002,
6434,
1027,
1002,
2023,
1011,
1028,
3828,
9581,
3351,
1006,
1007,
1025,
2065,
1006,
1002,
25141,
1007,
1063,
1002,
2023,
1011,
1028,
25141,
1006,
1007,
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... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.setFrom | public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
// Don't validate now addresses with IDN. Will be done in send().
$pos = strrpos($address, '@');
if (false === $pos or
(!$this->has8bitChars(substr($address, ++$pos)) or !static::idnSupported()) and
!static::validateAddress($address)) {
$error_message = sprintf('%s (From): %s',
$this->lang('invalid_address'),
$address);
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new Exception($error_message);
}
return false;
}
$this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
return true;
} | php | public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
// Don't validate now addresses with IDN. Will be done in send().
$pos = strrpos($address, '@');
if (false === $pos or
(!$this->has8bitChars(substr($address, ++$pos)) or !static::idnSupported()) and
!static::validateAddress($address)) {
$error_message = sprintf('%s (From): %s',
$this->lang('invalid_address'),
$address);
$this->setError($error_message);
$this->edebug($error_message);
if ($this->exceptions) {
throw new Exception($error_message);
}
return false;
}
$this->From = $address;
$this->FromName = $name;
if ($auto) {
if (empty($this->Sender)) {
$this->Sender = $address;
}
}
return true;
} | [
"public",
"function",
"setFrom",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"''",
",",
"$",
"auto",
"=",
"true",
")",
"{",
"$",
"address",
"=",
"trim",
"(",
"$",
"address",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"preg_replace",
"(",
"'/[\\r\\n]+... | Set the From and FromName properties.
@param string $address
@param string $name
@param bool $auto Whether to also set the Sender address, defaults to true
@throws Exception
@return bool | [
"Set",
"the",
"From",
"and",
"FromName",
"properties",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L1183-L1212 | train | Set From Name From Address | [
30522,
2270,
3853,
2275,
19699,
5358,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
1005,
1005,
1010,
1002,
8285,
1027,
2995,
1007,
1063,
1002,
4769,
1027,
12241,
1006,
1002,
4769,
1007,
1025,
1002,
2171,
1027,
12241,
1006,
3653,
2290,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | HasAttributes.relationsToArray | public function relationsToArray()
{
$attributes = [];
foreach ($this->getArrayableRelations() as $key => $value) {
// If the values implements the Arrayable interface we can just call this
// toArray method on the instances which will convert both models and
// collections to their proper array form and we'll set the values.
if ($value instanceof Arrayable) {
$relation = $value->toArray();
}
// If the value is null, we'll still go ahead and set it in this list of
// attributes since null is used to represent empty relationships if
// if it a has one or belongs to type relationships on the models.
elseif (is_null($value)) {
$relation = $value;
}
// If the relationships snake-casing is enabled, we will snake case this
// key so that the relation attribute is snake cased in this returned
// array to the developers, making this consistent with attributes.
if (static::$snakeAttributes) {
$key = Str::snake($key);
}
// If the relation value has been set, we will set it on this attributes
// list for returning. If it was not arrayable or null, we'll not set
// the value on the array because it is some type of invalid value.
if (isset($relation) || is_null($value)) {
$attributes[$key] = $relation;
}
unset($relation);
}
return $attributes;
} | php | public function relationsToArray()
{
$attributes = [];
foreach ($this->getArrayableRelations() as $key => $value) {
// If the values implements the Arrayable interface we can just call this
// toArray method on the instances which will convert both models and
// collections to their proper array form and we'll set the values.
if ($value instanceof Arrayable) {
$relation = $value->toArray();
}
// If the value is null, we'll still go ahead and set it in this list of
// attributes since null is used to represent empty relationships if
// if it a has one or belongs to type relationships on the models.
elseif (is_null($value)) {
$relation = $value;
}
// If the relationships snake-casing is enabled, we will snake case this
// key so that the relation attribute is snake cased in this returned
// array to the developers, making this consistent with attributes.
if (static::$snakeAttributes) {
$key = Str::snake($key);
}
// If the relation value has been set, we will set it on this attributes
// list for returning. If it was not arrayable or null, we'll not set
// the value on the array because it is some type of invalid value.
if (isset($relation) || is_null($value)) {
$attributes[$key] = $relation;
}
unset($relation);
}
return $attributes;
} | [
"public",
"function",
"relationsToArray",
"(",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getArrayableRelations",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// If the values implements the Arrayable int... | Get the model's relationships in array form.
@return array | [
"Get",
"the",
"model",
"s",
"relationships",
"in",
"array",
"form",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L234-L271 | train | Returns the relations as an array | [
30522,
2270,
3853,
4262,
3406,
2906,
9447,
1006,
1007,
1063,
1002,
12332,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
2906,
29539,
16213,
10581,
9285,
1006,
1007,
2004,
1002,
3145,
1027,
1028,
1002,
3643,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php | AbstractSurrogate.removeFromControl | protected function removeFromControl(Response $response)
{
if (!$response->headers->has('Surrogate-Control')) {
return;
}
$value = $response->headers->get('Surrogate-Control');
$upperName = strtoupper($this->getName());
if (sprintf('content="%s/1.0"', $upperName) == $value) {
$response->headers->remove('Surrogate-Control');
} elseif (preg_match(sprintf('#,\s*content="%s/1.0"#', $upperName), $value)) {
$response->headers->set('Surrogate-Control', preg_replace(sprintf('#,\s*content="%s/1.0"#', $upperName), '', $value));
} elseif (preg_match(sprintf('#content="%s/1.0",\s*#', $upperName), $value)) {
$response->headers->set('Surrogate-Control', preg_replace(sprintf('#content="%s/1.0",\s*#', $upperName), '', $value));
}
} | php | protected function removeFromControl(Response $response)
{
if (!$response->headers->has('Surrogate-Control')) {
return;
}
$value = $response->headers->get('Surrogate-Control');
$upperName = strtoupper($this->getName());
if (sprintf('content="%s/1.0"', $upperName) == $value) {
$response->headers->remove('Surrogate-Control');
} elseif (preg_match(sprintf('#,\s*content="%s/1.0"#', $upperName), $value)) {
$response->headers->set('Surrogate-Control', preg_replace(sprintf('#,\s*content="%s/1.0"#', $upperName), '', $value));
} elseif (preg_match(sprintf('#content="%s/1.0",\s*#', $upperName), $value)) {
$response->headers->set('Surrogate-Control', preg_replace(sprintf('#content="%s/1.0",\s*#', $upperName), '', $value));
}
} | [
"protected",
"function",
"removeFromControl",
"(",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"$",
"response",
"->",
"headers",
"->",
"has",
"(",
"'Surrogate-Control'",
")",
")",
"{",
"return",
";",
"}",
"$",
"value",
"=",
"$",
"response",
"-... | Remove the Surrogate from the Surrogate-Control header. | [
"Remove",
"the",
"Surrogate",
"from",
"the",
"Surrogate",
"-",
"Control",
"header",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php#L117-L133 | train | Remove the Surrogate from the Surrogate header | [
30522,
5123,
3853,
6366,
19699,
5358,
8663,
13181,
2140,
1006,
3433,
1002,
3433,
1007,
1063,
2065,
1006,
999,
1002,
3433,
1011,
1028,
20346,
2015,
1011,
1028,
2038,
1006,
1005,
7505,
21799,
1011,
2491,
1005,
1007,
1007,
1063,
2709,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php | MessengerDataCollector.lateCollect | public function lateCollect()
{
$this->data = ['messages' => [], 'buses' => array_keys($this->traceableBuses)];
$messages = [];
foreach ($this->traceableBuses as $busName => $bus) {
foreach ($bus->getDispatchedMessages() as $message) {
$debugRepresentation = $this->cloneVar($this->collectMessage($busName, $message));
$messages[] = [$debugRepresentation, $message['callTime']];
}
}
// Order by call time
usort($messages, function ($a, $b) { return $a[1] <=> $b[1]; });
// Keep the messages clones only
$this->data['messages'] = array_column($messages, 0);
} | php | public function lateCollect()
{
$this->data = ['messages' => [], 'buses' => array_keys($this->traceableBuses)];
$messages = [];
foreach ($this->traceableBuses as $busName => $bus) {
foreach ($bus->getDispatchedMessages() as $message) {
$debugRepresentation = $this->cloneVar($this->collectMessage($busName, $message));
$messages[] = [$debugRepresentation, $message['callTime']];
}
}
// Order by call time
usort($messages, function ($a, $b) { return $a[1] <=> $b[1]; });
// Keep the messages clones only
$this->data['messages'] = array_column($messages, 0);
} | [
"public",
"function",
"lateCollect",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"[",
"'messages'",
"=>",
"[",
"]",
",",
"'buses'",
"=>",
"array_keys",
"(",
"$",
"this",
"->",
"traceableBuses",
")",
"]",
";",
"$",
"messages",
"=",
"[",
"]",
";",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/DataCollector/MessengerDataCollector.php#L46-L63 | train | Late collect the messages from all registered buses | [
30522,
2270,
3853,
2397,
26895,
22471,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2951,
1027,
1031,
1005,
7696,
1005,
1027,
1028,
1031,
1033,
1010,
1005,
7793,
1005,
1027,
1028,
9140,
1035,
6309,
1006,
1002,
2023,
1011,
1028,
7637,
3085,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/View/Middleware/ShareErrorsFromSession.php | ShareErrorsFromSession.handle | public function handle($request, Closure $next)
{
// If the current session has an "errors" variable bound to it, we will share
// its value with all view instances so the views can easily access errors
// without having to bind. An empty bag is set when there aren't errors.
$this->view->share(
'errors', $request->session()->get('errors') ?: new ViewErrorBag
);
// Putting the errors in the view for every view allows the developer to just
// assume that some errors are always available, which is convenient since
// they don't have to continually run checks for the presence of errors.
return $next($request);
} | php | public function handle($request, Closure $next)
{
// If the current session has an "errors" variable bound to it, we will share
// its value with all view instances so the views can easily access errors
// without having to bind. An empty bag is set when there aren't errors.
$this->view->share(
'errors', $request->session()->get('errors') ?: new ViewErrorBag
);
// Putting the errors in the view for every view allows the developer to just
// assume that some errors are always available, which is convenient since
// they don't have to continually run checks for the presence of errors.
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"// If the current session has an \"errors\" variable bound to it, we will share",
"// its value with all view instances so the views can easily access errors",
"// without having to bind. An empt... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | [
"Handle",
"an",
"incoming",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Middleware/ShareErrorsFromSession.php#L36-L50 | train | Handle the request | [
30522,
2270,
3853,
5047,
1006,
1002,
5227,
1010,
8503,
1002,
2279,
1007,
1063,
1013,
1013,
2065,
1996,
2783,
5219,
2038,
2019,
1000,
10697,
1000,
8023,
5391,
2000,
2009,
1010,
2057,
2097,
3745,
1013,
1013,
2049,
3643,
2007,
2035,
3193,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getUninitializedPrecision | private function getUninitializedPrecision($value, $precision)
{
if (self::CURRENCY == $this->style) {
return $precision;
}
if (!$this->isInitializedAttribute(self::FRACTION_DIGITS)) {
preg_match('/.*\.(.*)/', (string) $value, $digits);
if (isset($digits[1])) {
$precision = \strlen($digits[1]);
}
}
return $precision;
} | php | private function getUninitializedPrecision($value, $precision)
{
if (self::CURRENCY == $this->style) {
return $precision;
}
if (!$this->isInitializedAttribute(self::FRACTION_DIGITS)) {
preg_match('/.*\.(.*)/', (string) $value, $digits);
if (isset($digits[1])) {
$precision = \strlen($digits[1]);
}
}
return $precision;
} | [
"private",
"function",
"getUninitializedPrecision",
"(",
"$",
"value",
",",
"$",
"precision",
")",
"{",
"if",
"(",
"self",
"::",
"CURRENCY",
"==",
"$",
"this",
"->",
"style",
")",
"{",
"return",
"$",
"precision",
";",
"}",
"if",
"(",
"!",
"$",
"this",
... | Returns the precision value if the DECIMAL style is being used and the FRACTION_DIGITS attribute is uninitialized.
@param int|float $value The value to get the precision from if the FRACTION_DIGITS attribute is uninitialized
@param int $precision The precision value to returns if the FRACTION_DIGITS attribute is initialized
@return int The precision value | [
"Returns",
"the",
"precision",
"value",
"if",
"the",
"DECIMAL",
"style",
"is",
"being",
"used",
"and",
"the",
"FRACTION_DIGITS",
"attribute",
"is",
"uninitialized",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php#L764-L778 | train | Returns the uninitialized precision value | [
30522,
2797,
3853,
2131,
19496,
3490,
20925,
3550,
28139,
28472,
1006,
1002,
3643,
1010,
1002,
11718,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
9598,
1027,
1027,
1002,
2023,
1011,
1028,
2806,
1007,
1063,
2709,
1002,
11718,
1025,
1065,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.