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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
laravel/framework | src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php | ConditionallyLoadsAttributes.filter | protected function filter($data)
{
$index = -1;
foreach ($data as $key => $value) {
$index++;
if (is_array($value)) {
$data[$key] = $this->filter($value);
continue;
}
if (is_numeric($key) && $value instanceof MergeValue) {
return $this->mergeData(
$data, $index, $this->filter($value->data),
array_values($value->data) === $value->data
);
}
if ($value instanceof self && is_null($value->resource)) {
$data[$key] = null;
}
}
return $this->removeMissingValues($data);
} | php | protected function filter($data)
{
$index = -1;
foreach ($data as $key => $value) {
$index++;
if (is_array($value)) {
$data[$key] = $this->filter($value);
continue;
}
if (is_numeric($key) && $value instanceof MergeValue) {
return $this->mergeData(
$data, $index, $this->filter($value->data),
array_values($value->data) === $value->data
);
}
if ($value instanceof self && is_null($value->resource)) {
$data[$key] = null;
}
}
return $this->removeMissingValues($data);
} | [
"protected",
"function",
"filter",
"(",
"$",
"data",
")",
"{",
"$",
"index",
"=",
"-",
"1",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"index",
"++",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")"... | Filter the given data, removing any optional values.
@param array $data
@return array | [
"Filter",
"the",
"given",
"data",
"removing",
"any",
"optional",
"values",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php#L15-L41 | train | Filter the data and return the result | [
30522,
5123,
3853,
11307,
1006,
1002,
2951,
1007,
1063,
1002,
5950,
1027,
1011,
1015,
1025,
18921,
6776,
1006,
1002,
2951,
2004,
1002,
3145,
1027,
1028,
1002,
3643,
1007,
1063,
1002,
5950,
1009,
1009,
1025,
2065,
1006,
2003,
1035,
9140,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Archive.php | Archive.getDataTable | public function getDataTable($name, $idSubtable = null)
{
$data = $this->get($name, 'blob', $idSubtable);
return $data->getDataTable($this->getResultIndices());
} | php | public function getDataTable($name, $idSubtable = null)
{
$data = $this->get($name, 'blob', $idSubtable);
return $data->getDataTable($this->getResultIndices());
} | [
"public",
"function",
"getDataTable",
"(",
"$",
"name",
",",
"$",
"idSubtable",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
",",
"'blob'",
",",
"$",
"idSubtable",
")",
";",
"return",
"$",
"data",
"->",
"getD... | Queries and returns one or more reports as DataTable instances.
This method will query blob data that is a serialized array of of {@link DataTable\Row}'s and
unserialize it.
If multiple sites were requested in {@link build()} or {@link factory()} the result will
be a {@link DataTable\Map} that is indexed by site ID.
If multiple periods were requested in {@link build()} or {@link factory()} the result will
be a DataTable\Map that is indexed by period.
The site ID index is always first, so if multiple sites & periods were requested, the result
will be a {@link DataTable\Map} indexed by site ID which contains {@link DataTable\Map} instances that are
indexed by period.
@param string $name The name of the record to get. This method can only query one record at a time.
@param int|string|null $idSubtable The ID of the subtable to get (if any).
@return DataTable|DataTable\Map A DataTable if multiple sites and periods were not requested.
An appropriately indexed {@link DataTable\Map} if otherwise. | [
"Queries",
"and",
"returns",
"one",
"or",
"more",
"reports",
"as",
"DataTable",
"instances",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive.php#L346-L350 | train | Get Data Table | [
30522,
2270,
3853,
2131,
2850,
29336,
3085,
1006,
1002,
2171,
1010,
1002,
8909,
6342,
19279,
3085,
1027,
19701,
1007,
1063,
1002,
2951,
30524,
2497,
1005,
1010,
1002,
8909,
6342,
19279,
3085,
1007,
1025,
2709,
1002,
2951,
1011,
1028,
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... |
octobercms/october | modules/cms/twig/Loader.php | Loader.exists | public function exists($name)
{
if (!$this->validateCmsObject($name)) {
return parent::exists($name);
}
return $this->obj->exists;
} | php | public function exists($name)
{
if (!$this->validateCmsObject($name)) {
return parent::exists($name);
}
return $this->obj->exists;
} | [
"public",
"function",
"exists",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateCmsObject",
"(",
"$",
"name",
")",
")",
"{",
"return",
"parent",
"::",
"exists",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
... | Checks that the template exists. | [
"Checks",
"that",
"the",
"template",
"exists",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/Loader.php#L105-L112 | train | Protected exists method | [
30522,
2270,
3853,
6526,
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,
6526,
1006,
1002,
2171,
1007,
1025,
1065,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Definition.php | Definition.setPublic | public function setPublic($boolean)
{
$this->changes['public'] = true;
$this->public = (bool) $boolean;
$this->private = false;
return $this;
} | php | public function setPublic($boolean)
{
$this->changes['public'] = true;
$this->public = (bool) $boolean;
$this->private = false;
return $this;
} | [
"public",
"function",
"setPublic",
"(",
"$",
"boolean",
")",
"{",
"$",
"this",
"->",
"changes",
"[",
"'public'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"public",
"=",
"(",
"bool",
")",
"$",
"boolean",
";",
"$",
"this",
"->",
"private",
"=",
"fal... | Sets the visibility of this service.
@param bool $boolean
@return $this | [
"Sets",
"the",
"visibility",
"of",
"this",
"service",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Definition.php#L603-L611 | train | Set the public flag | [
30522,
2270,
3853,
2275,
14289,
16558,
2594,
1006,
1002,
22017,
20898,
1007,
1063,
1002,
2023,
1011,
1028,
3431,
1031,
1005,
2270,
1005,
1033,
1027,
2995,
1025,
1002,
2023,
1011,
1028,
2270,
1027,
1006,
22017,
2140,
1007,
1002,
22017,
20898... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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._dsn | protected function _dsn()
{
// baseline of DSN parts
$dsn = $this->_config;
// don't pass the username, password, charset, persistent and driver_options in the DSN
unset($dsn['username']);
unset($dsn['password']);
unset($dsn['options']);
unset($dsn['charset']);
unset($dsn['persistent']);
unset($dsn['driver_options']);
// use all remaining parts in the DSN
foreach ($dsn as $key => $val) {
$dsn[$key] = "$key=$val";
}
return $this->_pdoType . ':' . implode(';', $dsn);
} | php | protected function _dsn()
{
// baseline of DSN parts
$dsn = $this->_config;
// don't pass the username, password, charset, persistent and driver_options in the DSN
unset($dsn['username']);
unset($dsn['password']);
unset($dsn['options']);
unset($dsn['charset']);
unset($dsn['persistent']);
unset($dsn['driver_options']);
// use all remaining parts in the DSN
foreach ($dsn as $key => $val) {
$dsn[$key] = "$key=$val";
}
return $this->_pdoType . ':' . implode(';', $dsn);
} | [
"protected",
"function",
"_dsn",
"(",
")",
"{",
"// baseline of DSN parts",
"$",
"dsn",
"=",
"$",
"this",
"->",
"_config",
";",
"// don't pass the username, password, charset, persistent and driver_options in the DSN",
"unset",
"(",
"$",
"dsn",
"[",
"'username'",
"]",
"... | Creates a PDO DSN for the adapter from $this->_config settings.
@return string | [
"Creates",
"a",
"PDO",
"DSN",
"for",
"the",
"adapter",
"from",
"$this",
"-",
">",
"_config",
"settings",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Abstract.php#L60-L79 | train | Return the DSN string | [
30522,
5123,
3853,
1035,
16233,
2078,
1006,
1007,
1063,
1013,
1013,
26163,
1997,
16233,
2078,
3033,
1002,
16233,
2078,
1027,
1002,
2023,
1011,
1028,
1035,
9530,
8873,
2290,
1025,
1013,
1013,
2123,
1005,
1056,
3413,
1996,
5310,
18442,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/HasOne.php | HasOne.newRelatedInstanceFor | public function newRelatedInstanceFor(Model $parent)
{
return $this->related->newInstance()->setAttribute(
$this->getForeignKeyName(), $parent->{$this->localKey}
);
} | php | public function newRelatedInstanceFor(Model $parent)
{
return $this->related->newInstance()->setAttribute(
$this->getForeignKeyName(), $parent->{$this->localKey}
);
} | [
"public",
"function",
"newRelatedInstanceFor",
"(",
"Model",
"$",
"parent",
")",
"{",
"return",
"$",
"this",
"->",
"related",
"->",
"newInstance",
"(",
")",
"->",
"setAttribute",
"(",
"$",
"this",
"->",
"getForeignKeyName",
"(",
")",
",",
"$",
"parent",
"-... | Make a new related instance for the given model.
@param \Illuminate\Database\Eloquent\Model $parent
@return \Illuminate\Database\Eloquent\Model | [
"Make",
"a",
"new",
"related",
"instance",
"for",
"the",
"given",
"model",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasOne.php#L62-L67 | train | Create a new related instance for the given parent model. | [
30522,
2270,
3853,
2047,
16570,
4383,
7076,
26897,
29278,
1006,
2944,
1002,
6687,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
3141,
1011,
1028,
2047,
7076,
30524,
29278,
7416,
16206,
14839,
18442,
1006,
1007,
1010,
1002,
6687,
1011,
1028,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Container/Container.php | Container.flush | public function flush()
{
$this->aliases = [];
$this->resolved = [];
$this->bindings = [];
$this->instances = [];
$this->abstractAliases = [];
} | php | public function flush()
{
$this->aliases = [];
$this->resolved = [];
$this->bindings = [];
$this->instances = [];
$this->abstractAliases = [];
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"$",
"this",
"->",
"aliases",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"resolved",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"bindings",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"instances",
"=",
"[",
"]",... | Flush the container of all bindings and resolved instances.
@return void | [
"Flush",
"the",
"container",
"of",
"all",
"bindings",
"and",
"resolved",
"instances",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L1172-L1179 | train | Flushes all the caches | [
30522,
2270,
3853,
13862,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
14593,
2229,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
10395,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
8031,
2015,
1027,
1031,
1033,
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... |
php-ai/php-ml | src/Classification/Ensemble/AdaBoost.php | AdaBoost.getBestClassifier | protected function getBestClassifier(): Classifier
{
$ref = new ReflectionClass($this->baseClassifier);
/** @var Classifier $classifier */
$classifier = count($this->classifierOptions) === 0 ? $ref->newInstance() : $ref->newInstanceArgs($this->classifierOptions);
if ($classifier instanceof WeightedClassifier) {
$classifier->setSampleWeights($this->weights);
$classifier->train($this->samples, $this->targets);
} else {
[$samples, $targets] = $this->resample();
$classifier->train($samples, $targets);
}
return $classifier;
} | php | protected function getBestClassifier(): Classifier
{
$ref = new ReflectionClass($this->baseClassifier);
/** @var Classifier $classifier */
$classifier = count($this->classifierOptions) === 0 ? $ref->newInstance() : $ref->newInstanceArgs($this->classifierOptions);
if ($classifier instanceof WeightedClassifier) {
$classifier->setSampleWeights($this->weights);
$classifier->train($this->samples, $this->targets);
} else {
[$samples, $targets] = $this->resample();
$classifier->train($samples, $targets);
}
return $classifier;
} | [
"protected",
"function",
"getBestClassifier",
"(",
")",
":",
"Classifier",
"{",
"$",
"ref",
"=",
"new",
"ReflectionClass",
"(",
"$",
"this",
"->",
"baseClassifier",
")",
";",
"/** @var Classifier $classifier */",
"$",
"classifier",
"=",
"count",
"(",
"$",
"this"... | Returns the classifier with the lowest error rate with the
consideration of current sample weights | [
"Returns",
"the",
"classifier",
"with",
"the",
"lowest",
"error",
"rate",
"with",
"the",
"consideration",
"of",
"current",
"sample",
"weights"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/Ensemble/AdaBoost.php#L159-L174 | train | Returns the best classifier for the current sample and target weights | [
30522,
5123,
3853,
2131,
12681,
13535,
27102,
18095,
1006,
1007,
1024,
2465,
18095,
1063,
1002,
25416,
1027,
2047,
9185,
26266,
1006,
1002,
2023,
1011,
1028,
2918,
26266,
18095,
1007,
1025,
1013,
1008,
1008,
1030,
13075,
2465,
18095,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Validator.php | Validator.invalid | public function invalid()
{
if (! $this->messages) {
$this->passes();
}
return array_intersect_key(
$this->data, $this->attributesThatHaveMessages()
);
} | php | public function invalid()
{
if (! $this->messages) {
$this->passes();
}
return array_intersect_key(
$this->data, $this->attributesThatHaveMessages()
);
} | [
"public",
"function",
"invalid",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"messages",
")",
"{",
"$",
"this",
"->",
"passes",
"(",
")",
";",
"}",
"return",
"array_intersect_key",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"attr... | Returns the data which was invalid.
@return array | [
"Returns",
"the",
"data",
"which",
"was",
"invalid",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Validator.php#L652-L661 | train | Return array of invalid attributes | [
30522,
2270,
3853,
19528,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
7696,
1007,
1063,
1002,
2023,
1011,
1028,
5235,
1006,
1007,
1025,
1065,
2709,
9140,
1035,
29261,
1035,
3145,
1006,
1002,
2023,
1011,
1028,
2951,
1010,
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/Session/SaveHandler/DbTable.php | Zend_Session_SaveHandler_DbTable.gc | public function gc($maxlifetime)
{
$this->delete($this->getAdapter()->quoteIdentifier($this->_modifiedColumn, true) . ' + '
. $this->getAdapter()->quoteIdentifier($this->_lifetimeColumn, true) . ' < '
. $this->getAdapter()->quote(time()));
return true;
} | php | public function gc($maxlifetime)
{
$this->delete($this->getAdapter()->quoteIdentifier($this->_modifiedColumn, true) . ' + '
. $this->getAdapter()->quoteIdentifier($this->_lifetimeColumn, true) . ' < '
. $this->getAdapter()->quote(time()));
return true;
} | [
"public",
"function",
"gc",
"(",
"$",
"maxlifetime",
")",
"{",
"$",
"this",
"->",
"delete",
"(",
"$",
"this",
"->",
"getAdapter",
"(",
")",
"->",
"quoteIdentifier",
"(",
"$",
"this",
"->",
"_modifiedColumn",
",",
"true",
")",
".",
"' + '",
".",
"$",
... | Garbage Collection
@param int $maxlifetime
@return true | [
"Garbage",
"Collection"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session/SaveHandler/DbTable.php#L387-L394 | train | Delete all records older than maxlifetime | [
30522,
2270,
3853,
1043,
2278,
1006,
1002,
4098,
15509,
7292,
1007,
1063,
1002,
2023,
1011,
1028,
3972,
12870,
1006,
1002,
2023,
1011,
1028,
2131,
8447,
13876,
2121,
1006,
1007,
1011,
1028,
14686,
5178,
16778,
8873,
2121,
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/Component/HttpFoundation/FileBag.php | FileBag.set | public function set($key, $value)
{
if (!\is_array($value) && !$value instanceof UploadedFile) {
throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
}
parent::set($key, $this->convertFileInformation($value));
} | php | public function set($key, $value)
{
if (!\is_array($value) && !$value instanceof UploadedFile) {
throw new \InvalidArgumentException('An uploaded file must be an array or an instance of UploadedFile.');
}
parent::set($key, $this->convertFileInformation($value));
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"$",
"value",
"instanceof",
"UploadedFile",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/FileBag.php#L46-L53 | train | Set an uploaded file | [
30522,
2270,
3853,
2275,
1006,
1002,
3145,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
999,
1032,
2003,
1035,
9140,
1006,
1002,
3643,
1007,
1004,
1004,
999,
1002,
3643,
6013,
11253,
21345,
8873,
2571,
1007,
1063,
5466,
2047,
1032,
19528,
29... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.filterItemPermissions | protected function filterItemPermissions($user, array $items)
{
if (!$user) {
return $items;
}
$items = array_filter($items, function ($item) use ($user) {
if (!$item->permissions || !count($item->permissions)) {
return true;
}
return $user->hasAnyAccess($item->permissions);
});
return $items;
} | php | protected function filterItemPermissions($user, array $items)
{
if (!$user) {
return $items;
}
$items = array_filter($items, function ($item) use ($user) {
if (!$item->permissions || !count($item->permissions)) {
return true;
}
return $user->hasAnyAccess($item->permissions);
});
return $items;
} | [
"protected",
"function",
"filterItemPermissions",
"(",
"$",
"user",
",",
"array",
"$",
"items",
")",
"{",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"$",
"items",
";",
"}",
"$",
"items",
"=",
"array_filter",
"(",
"$",
"items",
",",
"function",
... | Removes menu items from an array if the supplied user lacks permission.
@param User $user A user object
@param array $items A collection of menu items
@return array The filtered menu items | [
"Removes",
"menu",
"items",
"from",
"an",
"array",
"if",
"the",
"supplied",
"user",
"lacks",
"permission",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/NavigationManager.php#L478-L493 | train | Filter items by permissions | [
30522,
5123,
3853,
11307,
4221,
8737,
2121,
25481,
2015,
1006,
1002,
5310,
1010,
9140,
1002,
5167,
1007,
1063,
2065,
1006,
999,
1002,
5310,
1007,
1063,
2709,
1002,
5167,
1025,
1065,
1002,
5167,
1027,
9140,
1035,
11307,
1006,
1002,
5167,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/WinCache.php | Zend_Cache_Backend_WinCache.save | public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
$result = wincache_ucache_set($id, array($data, time(), $lifetime), $lifetime);
if (count($tags) > 0) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
}
return $result;
} | php | public function save($data, $id, $tags = array(), $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
$result = wincache_ucache_set($id, array($data, time(), $lifetime), $lifetime);
if (count($tags) > 0) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_WINCACHE_BACKEND);
}
return $result;
} | [
"public",
"function",
"save",
"(",
"$",
"data",
",",
"$",
"id",
",",
"$",
"tags",
"=",
"array",
"(",
")",
",",
"$",
"specificLifetime",
"=",
"false",
")",
"{",
"$",
"lifetime",
"=",
"$",
"this",
"->",
"getLifetime",
"(",
"$",
"specificLifetime",
")",... | Save some string datas into a cache record
Note : $data is always "string" (serialization is done by the
core not by the backend)
@param string $data datas to cache
@param string $id cache id
@param array $tags array of strings, the cache record will be tagged by each string entry
@param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime)
@return boolean true if no problem | [
"Save",
"some",
"string",
"datas",
"into",
"a",
"cache",
"record"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/WinCache.php#L109-L117 | train | Save data into the cache | [
30522,
2270,
3853,
3828,
1006,
1002,
2951,
1010,
1002,
8909,
1010,
1002,
22073,
1027,
9140,
1006,
1007,
1010,
1002,
3563,
15509,
7292,
1027,
6270,
1007,
1063,
1002,
6480,
1027,
1002,
2023,
1011,
1028,
2131,
15509,
7292,
1006,
1002,
3563,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getTextAttribute | public function getTextAttribute($attr)
{
return \array_key_exists($this->style, self::$enTextAttributes) && \array_key_exists($attr, self::$enTextAttributes[$this->style]) ? self::$enTextAttributes[$this->style][$attr] : false;
} | php | public function getTextAttribute($attr)
{
return \array_key_exists($this->style, self::$enTextAttributes) && \array_key_exists($attr, self::$enTextAttributes[$this->style]) ? self::$enTextAttributes[$this->style][$attr] : false;
} | [
"public",
"function",
"getTextAttribute",
"(",
"$",
"attr",
")",
"{",
"return",
"\\",
"array_key_exists",
"(",
"$",
"this",
"->",
"style",
",",
"self",
"::",
"$",
"enTextAttributes",
")",
"&&",
"\\",
"array_key_exists",
"(",
"$",
"attr",
",",
"self",
"::",... | Not supported. Returns a formatter text attribute value.
@param int $attr An attribute specifier, one of the text attribute constants
@return bool|string The attribute value or false on error
@see http://www.php.net/manual/en/numberformatter.gettextattribute.php | [
"Not",
"supported",
".",
"Returns",
"a",
"formatter",
"text",
"attribute",
"value",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php#L475-L478 | train | Get the value of a text attribute | [
30522,
2270,
3853,
2131,
18209,
19321,
3089,
8569,
2618,
1006,
1002,
2012,
16344,
1007,
1063,
2709,
1032,
9140,
1035,
3145,
1035,
6526,
1006,
1002,
2023,
1011,
1028,
2806,
1010,
2969,
1024,
1024,
1002,
4372,
18209,
19321,
3089,
8569,
4570,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Connectors/Connector.php | Connector.createConnection | public function createConnection($dsn, array $config, array $options)
{
[$username, $password] = [
$config['username'] ?? null, $config['password'] ?? null,
];
try {
return $this->createPdoConnection(
$dsn, $username, $password, $options
);
} catch (Exception $e) {
return $this->tryAgainIfCausedByLostConnection(
$e, $dsn, $username, $password, $options
);
}
} | php | public function createConnection($dsn, array $config, array $options)
{
[$username, $password] = [
$config['username'] ?? null, $config['password'] ?? null,
];
try {
return $this->createPdoConnection(
$dsn, $username, $password, $options
);
} catch (Exception $e) {
return $this->tryAgainIfCausedByLostConnection(
$e, $dsn, $username, $password, $options
);
}
} | [
"public",
"function",
"createConnection",
"(",
"$",
"dsn",
",",
"array",
"$",
"config",
",",
"array",
"$",
"options",
")",
"{",
"[",
"$",
"username",
",",
"$",
"password",
"]",
"=",
"[",
"$",
"config",
"[",
"'username'",
"]",
"??",
"null",
",",
"$",
... | Create a new PDO connection.
@param string $dsn
@param array $config
@param array $options
@return \PDO
@throws \Exception | [
"Create",
"a",
"new",
"PDO",
"connection",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connectors/Connector.php#L38-L53 | train | Create a new PDO connection | [
30522,
2270,
3853,
3443,
8663,
2638,
7542,
1006,
1002,
16233,
2078,
1010,
9140,
1002,
9530,
8873,
2290,
1010,
9140,
1002,
7047,
1007,
1063,
1031,
1002,
5310,
18442,
1010,
1002,
20786,
1033,
1027,
1031,
1002,
9530,
8873,
2290,
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... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.o_cidSystemInfo | protected function o_cidSystemInfo($id, $action)
{
switch ($action) {
case 'new':
$this->objects[$id] = array(
't' => 'cidSystemInfo'
);
break;
case 'add':
break;
case 'out':
$ordering = '(UCS)';
$registry = '(Adobe)';
if ($this->encrypted) {
$this->encryptInit($id);
$ordering = $this->ARC4($ordering);
$registry = $this->ARC4($registry);
}
$res = "\n$id 0 obj\n";
$res .= '<</Registry ' . $registry . "\n"; // A string identifying an issuer of character collections
$res .= '/Ordering ' . $ordering . "\n"; // A string that uniquely names a character collection issued by a specific registry
$res .= "/Supplement 0\n"; // The supplement number of the character collection.
$res .= ">>";
$res .= "\nendobj";;
return $res;
}
return null;
} | php | protected function o_cidSystemInfo($id, $action)
{
switch ($action) {
case 'new':
$this->objects[$id] = array(
't' => 'cidSystemInfo'
);
break;
case 'add':
break;
case 'out':
$ordering = '(UCS)';
$registry = '(Adobe)';
if ($this->encrypted) {
$this->encryptInit($id);
$ordering = $this->ARC4($ordering);
$registry = $this->ARC4($registry);
}
$res = "\n$id 0 obj\n";
$res .= '<</Registry ' . $registry . "\n"; // A string identifying an issuer of character collections
$res .= '/Ordering ' . $ordering . "\n"; // A string that uniquely names a character collection issued by a specific registry
$res .= "/Supplement 0\n"; // The supplement number of the character collection.
$res .= ">>";
$res .= "\nendobj";;
return $res;
}
return null;
} | [
"protected",
"function",
"o_cidSystemInfo",
"(",
"$",
"id",
",",
"$",
"action",
")",
"{",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'new'",
":",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",
"]",
"=",
"array",
"(",
"'t'",
"=>",
"'cidSystemInfo... | CID system info section, needed for unicode fonts
@param $id
@param $action
@return null|string | [
"CID",
"system",
"info",
"section",
"needed",
"for",
"unicode",
"fonts"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L1230-L1264 | train | o_cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo - cidSystemInfo | [
30522,
5123,
3853,
1051,
1035,
28744,
6508,
13473,
10020,
14876,
1006,
1002,
8909,
1010,
1002,
2895,
1007,
1063,
6942,
1006,
1002,
2895,
1007,
1063,
2553,
1005,
2047,
1005,
1024,
1002,
2023,
1011,
1028,
5200,
1031,
1002,
8909,
1033,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/NumberFormatter.php | NumberFormatter.formatPercentEvolution | public function formatPercentEvolution($value)
{
$isPositiveEvolution = !empty($value) && ($value > 0 || $value[0] == '+');
$formatted = self::formatPercent($value);
if ($isPositiveEvolution) {
// $this->symbols has already been initialized from formatPercent().
$language = $this->translator->getCurrentLanguage();
return $this->symbols[$language]['+'] . $formatted;
}
return $formatted;
} | php | public function formatPercentEvolution($value)
{
$isPositiveEvolution = !empty($value) && ($value > 0 || $value[0] == '+');
$formatted = self::formatPercent($value);
if ($isPositiveEvolution) {
// $this->symbols has already been initialized from formatPercent().
$language = $this->translator->getCurrentLanguage();
return $this->symbols[$language]['+'] . $formatted;
}
return $formatted;
} | [
"public",
"function",
"formatPercentEvolution",
"(",
"$",
"value",
")",
"{",
"$",
"isPositiveEvolution",
"=",
"!",
"empty",
"(",
"$",
"value",
")",
"&&",
"(",
"$",
"value",
">",
"0",
"||",
"$",
"value",
"[",
"0",
"]",
"==",
"'+'",
")",
";",
"$",
"f... | Formats given number as percent value, but keep the leading + sign if found
@param $value
@return string | [
"Formats",
"given",
"number",
"as",
"percent",
"value",
"but",
"keep",
"the",
"leading",
"+",
"sign",
"if",
"found"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/NumberFormatter.php#L106-L118 | train | Format percent evolution | [
30522,
2270,
3853,
4289,
4842,
13013,
6777,
4747,
13700,
1006,
1002,
3643,
1007,
1063,
1002,
2003,
6873,
28032,
3512,
6777,
4747,
13700,
1027,
999,
4064,
1006,
1002,
3643,
1007,
1004,
1004,
1006,
1002,
3643,
1028,
1014,
1064,
1064,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Queue.php | Queue.withCreatePayloadHooks | protected function withCreatePayloadHooks($queue, array $payload)
{
if (! empty(static::$createPayloadCallbacks)) {
foreach (static::$createPayloadCallbacks as $callback) {
$payload = array_merge($payload, call_user_func(
$callback, $this->getConnectionName(), $queue, $payload
));
}
}
return $payload;
} | php | protected function withCreatePayloadHooks($queue, array $payload)
{
if (! empty(static::$createPayloadCallbacks)) {
foreach (static::$createPayloadCallbacks as $callback) {
$payload = array_merge($payload, call_user_func(
$callback, $this->getConnectionName(), $queue, $payload
));
}
}
return $payload;
} | [
"protected",
"function",
"withCreatePayloadHooks",
"(",
"$",
"queue",
",",
"array",
"$",
"payload",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"static",
"::",
"$",
"createPayloadCallbacks",
")",
")",
"{",
"foreach",
"(",
"static",
"::",
"$",
"createPayloadCallb... | Create the given payload using any registered payload hooks.
@param string $queue
@param array $payload
@return array | [
"Create",
"the",
"given",
"payload",
"using",
"any",
"registered",
"payload",
"hooks",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Queue.php#L234-L245 | train | Create payload hooks | [
30522,
5123,
3853,
2007,
16748,
3686,
4502,
8516,
10441,
16425,
14659,
2015,
1006,
1002,
24240,
1010,
9140,
1002,
18093,
1007,
1063,
2065,
1006,
999,
4064,
1006,
10763,
1024,
1024,
1002,
3443,
4502,
8516,
10441,
16409,
8095,
12221,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/BinaryFileResponse.php | BinaryFileResponse.sendContent | public function sendContent()
{
if (!$this->isSuccessful()) {
return parent::sendContent();
}
if (0 === $this->maxlen) {
return $this;
}
$out = fopen('php://output', 'wb');
$file = fopen($this->file->getPathname(), 'rb');
stream_copy_to_stream($file, $out, $this->maxlen, $this->offset);
fclose($out);
fclose($file);
if ($this->deleteFileAfterSend && file_exists($this->file->getPathname())) {
unlink($this->file->getPathname());
}
return $this;
} | php | public function sendContent()
{
if (!$this->isSuccessful()) {
return parent::sendContent();
}
if (0 === $this->maxlen) {
return $this;
}
$out = fopen('php://output', 'wb');
$file = fopen($this->file->getPathname(), 'rb');
stream_copy_to_stream($file, $out, $this->maxlen, $this->offset);
fclose($out);
fclose($file);
if ($this->deleteFileAfterSend && file_exists($this->file->getPathname())) {
unlink($this->file->getPathname());
}
return $this;
} | [
"public",
"function",
"sendContent",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"return",
"parent",
"::",
"sendContent",
"(",
")",
";",
"}",
"if",
"(",
"0",
"===",
"$",
"this",
"->",
"maxlen",
")",
"{",
... | Sends the file.
{@inheritdoc} | [
"Sends",
"the",
"file",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php#L285-L308 | train | Send content to the file | [
30522,
2270,
3853,
4604,
8663,
6528,
2102,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
26354,
14194,
9623,
22747,
5313,
1006,
1007,
1007,
1063,
2709,
6687,
1024,
1024,
4604,
8663,
6528,
2102,
1006,
1007,
1025,
1065,
2065,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Url.php | Url.getCurrentUrlWithoutQueryString | public static function getCurrentUrlWithoutQueryString($checkTrustedHost = true)
{
return self::getCurrentScheme() . '://'
. self::getCurrentHost($default = 'unknown', $checkTrustedHost)
. self::getCurrentScriptName(false);
} | php | public static function getCurrentUrlWithoutQueryString($checkTrustedHost = true)
{
return self::getCurrentScheme() . '://'
. self::getCurrentHost($default = 'unknown', $checkTrustedHost)
. self::getCurrentScriptName(false);
} | [
"public",
"static",
"function",
"getCurrentUrlWithoutQueryString",
"(",
"$",
"checkTrustedHost",
"=",
"true",
")",
"{",
"return",
"self",
"::",
"getCurrentScheme",
"(",
")",
".",
"'://'",
".",
"self",
"::",
"getCurrentHost",
"(",
"$",
"default",
"=",
"'unknown'"... | Returns the current URL without the query string.
@param bool $checkTrustedHost Whether to do trusted host check. Should ALWAYS be true,
except in {@link Piwik\Plugin\Controller}.
@return string eg, `"http://example.org/dir1/dir2/index.php"` if the current URL is
`"http://example.org/dir1/dir2/index.php?param1=value1¶m2=value2"`.
@api | [
"Returns",
"the",
"current",
"URL",
"without",
"the",
"query",
"string",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Url.php#L76-L81 | train | Get Current URL without Query String | [
30522,
2270,
10763,
3853,
2131,
10841,
14343,
3372,
3126,
2140,
24415,
5833,
4226,
24769,
18886,
3070,
1006,
1002,
4638,
24669,
2098,
15006,
2102,
1027,
2995,
1007,
1063,
2709,
2969,
1024,
1024,
2131,
10841,
14343,
7666,
5403,
4168,
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... |
laravel/framework | src/Illuminate/Support/Str.php | Str.start | public static function start($value, $prefix)
{
$quoted = preg_quote($prefix, '/');
return $prefix.preg_replace('/^(?:'.$quoted.')+/u', '', $value);
} | php | public static function start($value, $prefix)
{
$quoted = preg_quote($prefix, '/');
return $prefix.preg_replace('/^(?:'.$quoted.')+/u', '', $value);
} | [
"public",
"static",
"function",
"start",
"(",
"$",
"value",
",",
"$",
"prefix",
")",
"{",
"$",
"quoted",
"=",
"preg_quote",
"(",
"$",
"prefix",
",",
"'/'",
")",
";",
"return",
"$",
"prefix",
".",
"preg_replace",
"(",
"'/^(?:'",
".",
"$",
"quoted",
".... | Begin a string with a single instance of a given value.
@param string $value
@param string $prefix
@return string | [
"Begin",
"a",
"string",
"with",
"a",
"single",
"instance",
"of",
"a",
"given",
"value",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Str.php#L390-L395 | train | Starts the current namespace | [
30522,
2270,
10763,
3853,
2707,
1006,
1002,
3643,
1010,
1002,
17576,
1007,
1063,
1002,
9339,
1027,
3653,
2290,
1035,
14686,
1006,
1002,
17576,
1010,
1005,
1013,
1005,
1007,
1025,
2709,
1002,
17576,
1012,
3653,
2290,
1035,
5672,
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... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.arrayFilterRecursive | public static function arrayFilterRecursive(Array $source, $fn)
{
$result = [];
foreach ($source as $key => $value) {
if (is_array($value)) {
$result[$key] = static::arrayFilterRecursive($value, $fn);
continue;
}
if ($fn($key, $value)) {
$result[$key] = $value; // KEEP
continue;
}
}
return $result;
} | php | public static function arrayFilterRecursive(Array $source, $fn)
{
$result = [];
foreach ($source as $key => $value) {
if (is_array($value)) {
$result[$key] = static::arrayFilterRecursive($value, $fn);
continue;
}
if ($fn($key, $value)) {
$result[$key] = $value; // KEEP
continue;
}
}
return $result;
} | [
"public",
"static",
"function",
"arrayFilterRecursive",
"(",
"Array",
"$",
"source",
",",
"$",
"fn",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"source",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
... | Recursively filter an array, filtering values by processing them through the $fn function argument
@param array $source the Array to filter
@param callable $fn the function to pass through each array item
@return array | [
"Recursively",
"filter",
"an",
"array",
"filtering",
"values",
"by",
"processing",
"them",
"through",
"the",
"$fn",
"function",
"argument"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L883-L898 | train | Array Filter Recursive | [
30522,
2270,
10763,
3853,
9140,
8873,
21928,
2890,
10841,
2869,
3512,
1006,
9140,
1002,
3120,
1010,
1002,
1042,
2078,
1007,
1063,
1002,
2765,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
3120,
2004,
1002,
3145,
1027,
1028,
1002,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Session/Store.php | Store.has | public function has($key)
{
return ! collect(is_array($key) ? $key : func_get_args())->contains(function ($key) {
return is_null($this->get($key));
});
} | php | public function has($key)
{
return ! collect(is_array($key) ? $key : func_get_args())->contains(function ($key) {
return is_null($this->get($key));
});
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"return",
"!",
"collect",
"(",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"func_get_args",
"(",
")",
")",
"->",
"contains",
"(",
"function",
"(",
"$",
"key",
")",
"{",
"return",
... | Checks if a key is present and not null.
@param string|array $key
@return bool | [
"Checks",
"if",
"a",
"key",
"is",
"present",
"and",
"not",
"null",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Session/Store.php#L191-L196 | train | Has a key? | [
30522,
2270,
3853,
2038,
1006,
1002,
3145,
1007,
1063,
2709,
999,
8145,
1006,
2003,
1035,
9140,
1006,
1002,
3145,
1007,
1029,
1002,
3145,
1024,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
1007,
1011,
1028,
3397,
1006,
3853,
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... |
dompdf/dompdf | src/FrameDecorator/ListBulletImage.php | ListBulletImage.get_margin_width | function get_margin_width()
{
//ignore image width, use same width as on predefined bullet ListBullet
//for proper alignment of bullet image and text. Allow image to not fitting on left border.
//This controls the extra indentation of text to make room for the bullet image.
//Here use actual image size, not predefined bullet size
//return $this->_frame->get_style()->get_font_size()*ListBullet::BULLET_SIZE +
// 2 * ListBullet::BULLET_PADDING;
// Small hack to prevent indenting of list text
// Image Might not exist, then position like on list_bullet_frame_decorator fallback to none.
if ($this->_frame->get_style()->list_style_position === "outside" || $this->_width == 0) {
return 0;
}
//This aligns the "inside" image position with the text.
//The text starts to the right of the image.
//Between the image and the text there is an added margin of image width.
//Where this comes from is unknown.
//The corresponding ListBullet sets a smaller margin. bullet size?
return $this->_width + 2 * ListBullet::BULLET_PADDING;
} | php | function get_margin_width()
{
//ignore image width, use same width as on predefined bullet ListBullet
//for proper alignment of bullet image and text. Allow image to not fitting on left border.
//This controls the extra indentation of text to make room for the bullet image.
//Here use actual image size, not predefined bullet size
//return $this->_frame->get_style()->get_font_size()*ListBullet::BULLET_SIZE +
// 2 * ListBullet::BULLET_PADDING;
// Small hack to prevent indenting of list text
// Image Might not exist, then position like on list_bullet_frame_decorator fallback to none.
if ($this->_frame->get_style()->list_style_position === "outside" || $this->_width == 0) {
return 0;
}
//This aligns the "inside" image position with the text.
//The text starts to the right of the image.
//Between the image and the text there is an added margin of image width.
//Where this comes from is unknown.
//The corresponding ListBullet sets a smaller margin. bullet size?
return $this->_width + 2 * ListBullet::BULLET_PADDING;
} | [
"function",
"get_margin_width",
"(",
")",
"{",
"//ignore image width, use same width as on predefined bullet ListBullet",
"//for proper alignment of bullet image and text. Allow image to not fitting on left border.",
"//This controls the extra indentation of text to make room for the bullet image.",
... | Override get_margin_width
@return int | [
"Override",
"get_margin_width"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameDecorator/ListBulletImage.php#L110-L130 | train | Get the width of the bullet image | [
30522,
3853,
2131,
1035,
7785,
1035,
9381,
1006,
1007,
1063,
1013,
1013,
8568,
3746,
9381,
1010,
2224,
2168,
9381,
2004,
2006,
3653,
3207,
23460,
2094,
7960,
2862,
8569,
22592,
1013,
1013,
2005,
5372,
12139,
1997,
7960,
3746,
1998,
3793,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/Model.php | Model.getSitesIdFromSiteUrlHavingAccess | public function getSitesIdFromSiteUrlHavingAccess($login, $urls)
{
$siteUrlTable = Common::prefixTable('site_url');
$sqlAccessSite = Access::getSqlAccessSite('idsite');
$db = $this->getDb();
$ids = $db->fetchAll(
'SELECT idsite
FROM ' . $this->table . '
WHERE main_url IN ( ' . Common::getSqlStringFieldsArray($urls) . ')' .
'AND idsite IN (' . $sqlAccessSite . ') ' .
'UNION
SELECT idsite
FROM ' . $siteUrlTable . '
WHERE url IN ( ' . Common::getSqlStringFieldsArray($urls) . ')' .
'AND idsite IN (' . $sqlAccessSite . ')',
// Bind
array_merge( $urls,
array( $login ),
$urls,
array( $login )
)
);
return $ids;
} | php | public function getSitesIdFromSiteUrlHavingAccess($login, $urls)
{
$siteUrlTable = Common::prefixTable('site_url');
$sqlAccessSite = Access::getSqlAccessSite('idsite');
$db = $this->getDb();
$ids = $db->fetchAll(
'SELECT idsite
FROM ' . $this->table . '
WHERE main_url IN ( ' . Common::getSqlStringFieldsArray($urls) . ')' .
'AND idsite IN (' . $sqlAccessSite . ') ' .
'UNION
SELECT idsite
FROM ' . $siteUrlTable . '
WHERE url IN ( ' . Common::getSqlStringFieldsArray($urls) . ')' .
'AND idsite IN (' . $sqlAccessSite . ')',
// Bind
array_merge( $urls,
array( $login ),
$urls,
array( $login )
)
);
return $ids;
} | [
"public",
"function",
"getSitesIdFromSiteUrlHavingAccess",
"(",
"$",
"login",
",",
"$",
"urls",
")",
"{",
"$",
"siteUrlTable",
"=",
"Common",
"::",
"prefixTable",
"(",
"'site_url'",
")",
";",
"$",
"sqlAccessSite",
"=",
"Access",
"::",
"getSqlAccessSite",
"(",
... | Returns the list of websites ID associated with a URL.
@param string $login
@param array $urls
@return array list of websites ID | [
"Returns",
"the",
"list",
"of",
"websites",
"ID",
"associated",
"with",
"a",
"URL",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L139-L165 | train | Get list of site ids from site_url having access | [
30522,
2270,
3853,
4152,
7616,
3593,
19699,
22225,
4221,
3126,
2140,
3270,
6455,
6305,
9623,
2015,
1006,
1002,
8833,
2378,
1010,
1002,
24471,
4877,
1007,
1063,
1002,
2609,
3126,
24458,
3468,
1027,
2691,
1024,
1024,
17576,
10880,
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 | libs/HTML/QuickForm2/Rule/Compare.php | HTML_QuickForm2_Rule_Compare.mergeConfig | public static function mergeConfig($localConfig, $globalConfig)
{
$config = null;
if (is_array($globalConfig) && 0 < count($globalConfig)) {
$config = self::toCanonicalForm($globalConfig, 'operator');
}
if (is_array($localConfig) && 0 < count($localConfig)) {
$config = (isset($config)? $config: array())
+ self::toCanonicalForm($localConfig);
}
return $config;
} | php | public static function mergeConfig($localConfig, $globalConfig)
{
$config = null;
if (is_array($globalConfig) && 0 < count($globalConfig)) {
$config = self::toCanonicalForm($globalConfig, 'operator');
}
if (is_array($localConfig) && 0 < count($localConfig)) {
$config = (isset($config)? $config: array())
+ self::toCanonicalForm($localConfig);
}
return $config;
} | [
"public",
"static",
"function",
"mergeConfig",
"(",
"$",
"localConfig",
",",
"$",
"globalConfig",
")",
"{",
"$",
"config",
"=",
"null",
";",
"if",
"(",
"is_array",
"(",
"$",
"globalConfig",
")",
"&&",
"0",
"<",
"count",
"(",
"$",
"globalConfig",
")",
"... | Merges local configuration with that provided for registerRule()
"Global" configuration may be passed to
{@link HTML_QuickForm2_Factory::registerRule()} in
either of the following formats
- operator
- array(operator[, operand])
- array(['operator' => operator, ]['operand' => operand])
"Local" configuration may be passed to the constructor in either of
the following formats
- operand
- array([operator, ]operand)
- array(['operator' => operator, ]['operand' => operand])
As usual, global configuration overrides local one.
@param mixed Local configuration
@param mixed Global configuration
@return mixed Merged configuration | [
"Merges",
"local",
"configuration",
"with",
"that",
"provided",
"for",
"registerRule",
"()"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule/Compare.php#L175-L186 | train | Merge local and global config with global config | [
30522,
2270,
10763,
3853,
13590,
8663,
8873,
2290,
1006,
1002,
2334,
8663,
8873,
2290,
1010,
1002,
3795,
8663,
8873,
2290,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
19701,
1025,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
3795,
8663,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Form.php | Form.submit | public function submit($submittedData, $clearMissing = true)
{
if ($this->submitted) {
throw new AlreadySubmittedException('A form can only be submitted once');
}
// Initialize errors in the very beginning so we're sure
// they are collectable during submission only
$this->errors = [];
// Obviously, a disabled form should not change its data upon submission.
if ($this->isDisabled()) {
$this->submitted = true;
return $this;
}
// The data must be initialized if it was not initialized yet.
// This is necessary to guarantee that the *_SET_DATA listeners
// are always invoked before submit() takes place.
if (!$this->defaultDataSet) {
$this->setData($this->config->getData());
}
// Treat false as NULL to support binding false to checkboxes.
// Don't convert NULL to a string here in order to determine later
// whether an empty value has been submitted or whether no value has
// been submitted at all. This is important for processing checkboxes
// and radio buttons with empty values.
if (false === $submittedData) {
$submittedData = null;
} elseif (is_scalar($submittedData)) {
$submittedData = (string) $submittedData;
} elseif ($this->config->getRequestHandler()->isFileUpload($submittedData)) {
if (!$this->config->getOption('allow_file_upload')) {
$submittedData = null;
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, file upload given.');
}
} elseif (\is_array($submittedData) && !$this->config->getCompound() && !$this->config->hasOption('multiple')) {
$submittedData = null;
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, array given.');
}
$dispatcher = LegacyEventDispatcherProxy::decorate($this->config->getEventDispatcher());
$modelData = null;
$normData = null;
$viewData = null;
try {
if (null !== $this->transformationFailure) {
throw $this->transformationFailure;
}
// Hook to change content of the data submitted by the browser
if ($dispatcher->hasListeners(FormEvents::PRE_SUBMIT)) {
$event = new PreSubmitEvent($this, $submittedData);
$dispatcher->dispatch($event, FormEvents::PRE_SUBMIT);
$submittedData = $event->getData();
}
// Check whether the form is compound.
// This check is preferable over checking the number of children,
// since forms without children may also be compound.
// (think of empty collection forms)
if ($this->config->getCompound()) {
if (null === $submittedData) {
$submittedData = [];
}
if (!\is_array($submittedData)) {
throw new TransformationFailedException('Compound forms expect an array or NULL on submission.');
}
foreach ($this->children as $name => $child) {
$isSubmitted = \array_key_exists($name, $submittedData);
if ($isSubmitted || $clearMissing) {
$child->submit($isSubmitted ? $submittedData[$name] : null, $clearMissing);
unset($submittedData[$name]);
if (null !== $this->clickedButton) {
continue;
}
if ($child instanceof ClickableInterface && $child->isClicked()) {
$this->clickedButton = $child;
continue;
}
if (method_exists($child, 'getClickedButton') && null !== $child->getClickedButton()) {
$this->clickedButton = $child->getClickedButton();
}
}
}
$this->extraData = $submittedData;
}
// Forms that inherit their parents' data also are not processed,
// because then it would be too difficult to merge the changes in
// the child and the parent form. Instead, the parent form also takes
// changes in the grandchildren (i.e. children of the form that inherits
// its parent's data) into account.
// (see InheritDataAwareIterator below)
if (!$this->inheritData) {
// If the form is compound, the view data is merged with the data
// of the children using the data mapper.
// If the form is not compound, the view data is assigned to the submitted data.
$viewData = $this->config->getCompound() ? $this->viewData : $submittedData;
if (FormUtil::isEmpty($viewData)) {
$emptyData = $this->config->getEmptyData();
if ($emptyData instanceof \Closure) {
$emptyData = $emptyData($this, $viewData);
}
$viewData = $emptyData;
}
// Merge form data from children into existing view data
// It is not necessary to invoke this method if the form has no children,
// even if it is compound.
if (\count($this->children) > 0) {
// Use InheritDataAwareIterator to process children of
// descendants that inherit this form's data.
// These descendants will not be submitted normally (see the check
// for $this->config->getInheritData() above)
$this->config->getDataMapper()->mapFormsToData(
new \RecursiveIteratorIterator(new InheritDataAwareIterator($this->children)),
$viewData
);
}
// Normalize data to unified representation
$normData = $this->viewToNorm($viewData);
// Hook to change content of the data in the normalized
// representation
if ($dispatcher->hasListeners(FormEvents::SUBMIT)) {
$event = new SubmitEvent($this, $normData);
$dispatcher->dispatch($event, FormEvents::SUBMIT);
$normData = $event->getData();
}
// Synchronize representations - must not change the content!
$modelData = $this->normToModel($normData);
$viewData = $this->normToView($normData);
}
} catch (TransformationFailedException $e) {
$this->transformationFailure = $e;
// If $viewData was not yet set, set it to $submittedData so that
// the erroneous data is accessible on the form.
// Forms that inherit data never set any data, because the getters
// forward to the parent form's getters anyway.
if (null === $viewData && !$this->inheritData) {
$viewData = $submittedData;
}
}
$this->submitted = true;
$this->modelData = $modelData;
$this->normData = $normData;
$this->viewData = $viewData;
if ($dispatcher->hasListeners(FormEvents::POST_SUBMIT)) {
$event = new PostSubmitEvent($this, $viewData);
$dispatcher->dispatch($event, FormEvents::POST_SUBMIT);
}
return $this;
} | php | public function submit($submittedData, $clearMissing = true)
{
if ($this->submitted) {
throw new AlreadySubmittedException('A form can only be submitted once');
}
// Initialize errors in the very beginning so we're sure
// they are collectable during submission only
$this->errors = [];
// Obviously, a disabled form should not change its data upon submission.
if ($this->isDisabled()) {
$this->submitted = true;
return $this;
}
// The data must be initialized if it was not initialized yet.
// This is necessary to guarantee that the *_SET_DATA listeners
// are always invoked before submit() takes place.
if (!$this->defaultDataSet) {
$this->setData($this->config->getData());
}
// Treat false as NULL to support binding false to checkboxes.
// Don't convert NULL to a string here in order to determine later
// whether an empty value has been submitted or whether no value has
// been submitted at all. This is important for processing checkboxes
// and radio buttons with empty values.
if (false === $submittedData) {
$submittedData = null;
} elseif (is_scalar($submittedData)) {
$submittedData = (string) $submittedData;
} elseif ($this->config->getRequestHandler()->isFileUpload($submittedData)) {
if (!$this->config->getOption('allow_file_upload')) {
$submittedData = null;
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, file upload given.');
}
} elseif (\is_array($submittedData) && !$this->config->getCompound() && !$this->config->hasOption('multiple')) {
$submittedData = null;
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, array given.');
}
$dispatcher = LegacyEventDispatcherProxy::decorate($this->config->getEventDispatcher());
$modelData = null;
$normData = null;
$viewData = null;
try {
if (null !== $this->transformationFailure) {
throw $this->transformationFailure;
}
// Hook to change content of the data submitted by the browser
if ($dispatcher->hasListeners(FormEvents::PRE_SUBMIT)) {
$event = new PreSubmitEvent($this, $submittedData);
$dispatcher->dispatch($event, FormEvents::PRE_SUBMIT);
$submittedData = $event->getData();
}
// Check whether the form is compound.
// This check is preferable over checking the number of children,
// since forms without children may also be compound.
// (think of empty collection forms)
if ($this->config->getCompound()) {
if (null === $submittedData) {
$submittedData = [];
}
if (!\is_array($submittedData)) {
throw new TransformationFailedException('Compound forms expect an array or NULL on submission.');
}
foreach ($this->children as $name => $child) {
$isSubmitted = \array_key_exists($name, $submittedData);
if ($isSubmitted || $clearMissing) {
$child->submit($isSubmitted ? $submittedData[$name] : null, $clearMissing);
unset($submittedData[$name]);
if (null !== $this->clickedButton) {
continue;
}
if ($child instanceof ClickableInterface && $child->isClicked()) {
$this->clickedButton = $child;
continue;
}
if (method_exists($child, 'getClickedButton') && null !== $child->getClickedButton()) {
$this->clickedButton = $child->getClickedButton();
}
}
}
$this->extraData = $submittedData;
}
// Forms that inherit their parents' data also are not processed,
// because then it would be too difficult to merge the changes in
// the child and the parent form. Instead, the parent form also takes
// changes in the grandchildren (i.e. children of the form that inherits
// its parent's data) into account.
// (see InheritDataAwareIterator below)
if (!$this->inheritData) {
// If the form is compound, the view data is merged with the data
// of the children using the data mapper.
// If the form is not compound, the view data is assigned to the submitted data.
$viewData = $this->config->getCompound() ? $this->viewData : $submittedData;
if (FormUtil::isEmpty($viewData)) {
$emptyData = $this->config->getEmptyData();
if ($emptyData instanceof \Closure) {
$emptyData = $emptyData($this, $viewData);
}
$viewData = $emptyData;
}
// Merge form data from children into existing view data
// It is not necessary to invoke this method if the form has no children,
// even if it is compound.
if (\count($this->children) > 0) {
// Use InheritDataAwareIterator to process children of
// descendants that inherit this form's data.
// These descendants will not be submitted normally (see the check
// for $this->config->getInheritData() above)
$this->config->getDataMapper()->mapFormsToData(
new \RecursiveIteratorIterator(new InheritDataAwareIterator($this->children)),
$viewData
);
}
// Normalize data to unified representation
$normData = $this->viewToNorm($viewData);
// Hook to change content of the data in the normalized
// representation
if ($dispatcher->hasListeners(FormEvents::SUBMIT)) {
$event = new SubmitEvent($this, $normData);
$dispatcher->dispatch($event, FormEvents::SUBMIT);
$normData = $event->getData();
}
// Synchronize representations - must not change the content!
$modelData = $this->normToModel($normData);
$viewData = $this->normToView($normData);
}
} catch (TransformationFailedException $e) {
$this->transformationFailure = $e;
// If $viewData was not yet set, set it to $submittedData so that
// the erroneous data is accessible on the form.
// Forms that inherit data never set any data, because the getters
// forward to the parent form's getters anyway.
if (null === $viewData && !$this->inheritData) {
$viewData = $submittedData;
}
}
$this->submitted = true;
$this->modelData = $modelData;
$this->normData = $normData;
$this->viewData = $viewData;
if ($dispatcher->hasListeners(FormEvents::POST_SUBMIT)) {
$event = new PostSubmitEvent($this, $viewData);
$dispatcher->dispatch($event, FormEvents::POST_SUBMIT);
}
return $this;
} | [
"public",
"function",
"submit",
"(",
"$",
"submittedData",
",",
"$",
"clearMissing",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"submitted",
")",
"{",
"throw",
"new",
"AlreadySubmittedException",
"(",
"'A form can only be submitted once'",
")",
";",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Form.php#L501-L675 | train | Submits the form with the given data. | [
30522,
2270,
3853,
12040,
1006,
1002,
7864,
2850,
2696,
1010,
1002,
3154,
15630,
7741,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
7864,
1007,
1063,
5466,
2047,
2525,
6342,
25526,
27100,
3207,
2595,
24422,
1006,
1005,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/helpers/File.php | File.validatePath | public static function validatePath($filePath, $maxNesting = 2)
{
if (strpos($filePath, '..') !== false) {
return false;
}
if (strpos($filePath, './') !== false || strpos($filePath, '//') !== false) {
return false;
}
$segments = explode('/', $filePath);
if ($maxNesting !== null && count($segments) > $maxNesting) {
return false;
}
foreach ($segments as $segment) {
if (!self::validateName($segment)) {
return false;
}
}
return true;
} | php | public static function validatePath($filePath, $maxNesting = 2)
{
if (strpos($filePath, '..') !== false) {
return false;
}
if (strpos($filePath, './') !== false || strpos($filePath, '//') !== false) {
return false;
}
$segments = explode('/', $filePath);
if ($maxNesting !== null && count($segments) > $maxNesting) {
return false;
}
foreach ($segments as $segment) {
if (!self::validateName($segment)) {
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"validatePath",
"(",
"$",
"filePath",
",",
"$",
"maxNesting",
"=",
"2",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"filePath",
",",
"'..'",
")",
"!==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"strpos",... | Validates a CMS object path.
CMS object directory and file names can contain only alphanumeric symbols, dashes and dots.
CMS objects support only a single level of subdirectories.
@param string $filePath Specifies a path to validate
@param integer $maxNesting Specifies the maximum allowed nesting level
@return boolean Returns true if the file name is valid. Otherwise returns false. | [
"Validates",
"a",
"CMS",
"object",
"path",
".",
"CMS",
"object",
"directory",
"and",
"file",
"names",
"can",
"contain",
"only",
"alphanumeric",
"symbols",
"dashes",
"and",
"dots",
".",
"CMS",
"objects",
"support",
"only",
"a",
"single",
"level",
"of",
"subdi... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/helpers/File.php#L48-L70 | train | Validate a file path | [
30522,
2270,
10763,
3853,
9398,
3686,
15069,
1006,
1002,
5371,
15069,
1010,
1002,
4098,
5267,
3436,
1027,
1016,
1007,
1063,
2065,
1006,
2358,
14536,
2891,
1006,
1002,
5371,
15069,
1010,
1005,
1012,
1012,
1005,
1007,
999,
1027,
1027,
6270,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Debug/ErrorHandler.php | ErrorHandler.reRegister | private function reRegister($prev)
{
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
$handler = set_error_handler('var_dump');
$handler = \is_array($handler) ? $handler[0] : null;
restore_error_handler();
if ($handler === $this) {
restore_error_handler();
if ($this->isRoot) {
set_error_handler([$this, 'handleError'], $this->thrownErrors | $this->loggedErrors);
} else {
set_error_handler([$this, 'handleError']);
}
}
}
} | php | private function reRegister($prev)
{
if ($prev !== $this->thrownErrors | $this->loggedErrors) {
$handler = set_error_handler('var_dump');
$handler = \is_array($handler) ? $handler[0] : null;
restore_error_handler();
if ($handler === $this) {
restore_error_handler();
if ($this->isRoot) {
set_error_handler([$this, 'handleError'], $this->thrownErrors | $this->loggedErrors);
} else {
set_error_handler([$this, 'handleError']);
}
}
}
} | [
"private",
"function",
"reRegister",
"(",
"$",
"prev",
")",
"{",
"if",
"(",
"$",
"prev",
"!==",
"$",
"this",
"->",
"thrownErrors",
"|",
"$",
"this",
"->",
"loggedErrors",
")",
"{",
"$",
"handler",
"=",
"set_error_handler",
"(",
"'var_dump'",
")",
";",
... | Re-registers as a PHP error handler if levels changed. | [
"Re",
"-",
"registers",
"as",
"a",
"PHP",
"error",
"handler",
"if",
"levels",
"changed",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Debug/ErrorHandler.php#L352-L367 | train | Re - registers error handlers | [
30522,
2797,
3853,
2128,
2890,
24063,
2121,
1006,
1002,
3653,
2615,
1007,
1063,
2065,
1006,
1002,
3653,
2615,
999,
1027,
1027,
1002,
2023,
1011,
1028,
6908,
2121,
29165,
2015,
1064,
1002,
2023,
1011,
1028,
26618,
2121,
29165,
2015,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/PrivacyManager/ReportsPurger.php | ReportsPurger.findSegmentArchives | private function findSegmentArchives($numericTables)
{
if (!is_null($this->segmentArchiveIds) || empty($numericTables)) {
return;
}
foreach ($numericTables as $table) {
$tableDate = ArchiveTableCreator::getDateFromTableName($table);
$maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table");
$sql = "SELECT idarchive FROM $table
WHERE name != 'done'
AND name LIKE 'done_%.%'
AND idarchive >= ?
AND idarchive < ?";
if (is_null($this->segmentArchiveIds)) {
$this->segmentArchiveIds = array();
}
$this->segmentArchiveIds[$tableDate] = array();
foreach (Db::segmentedFetchAll($sql, 0, $maxIdArchive, self::$selectSegmentSize) as $row) {
$this->segmentArchiveIds[$tableDate][] = $row['idarchive'];
}
}
} | php | private function findSegmentArchives($numericTables)
{
if (!is_null($this->segmentArchiveIds) || empty($numericTables)) {
return;
}
foreach ($numericTables as $table) {
$tableDate = ArchiveTableCreator::getDateFromTableName($table);
$maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table");
$sql = "SELECT idarchive FROM $table
WHERE name != 'done'
AND name LIKE 'done_%.%'
AND idarchive >= ?
AND idarchive < ?";
if (is_null($this->segmentArchiveIds)) {
$this->segmentArchiveIds = array();
}
$this->segmentArchiveIds[$tableDate] = array();
foreach (Db::segmentedFetchAll($sql, 0, $maxIdArchive, self::$selectSegmentSize) as $row) {
$this->segmentArchiveIds[$tableDate][] = $row['idarchive'];
}
}
} | [
"private",
"function",
"findSegmentArchives",
"(",
"$",
"numericTables",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"segmentArchiveIds",
")",
"||",
"empty",
"(",
"$",
"numericTables",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"... | If we're going to keep segmented reports, we need to know which archives are
for segments. This info is only in the numeric tables, so we must query them. | [
"If",
"we",
"re",
"going",
"to",
"keep",
"segmented",
"reports",
"we",
"need",
"to",
"know",
"which",
"archives",
"are",
"for",
"segments",
".",
"This",
"info",
"is",
"only",
"in",
"the",
"numeric",
"tables",
"so",
"we",
"must",
"query",
"them",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/ReportsPurger.php#L315-L341 | train | Find segmentArchives for numeric tables | [
30522,
2797,
3853,
4858,
13910,
3672,
2906,
5428,
6961,
1006,
1002,
16371,
25531,
10880,
2015,
1007,
1063,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
6903,
2906,
5428,
3726,
9821,
1007,
1064,
1064,
4064,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php | TextDescriptor.describeContainerDefinition | protected function describeContainerDefinition(Definition $definition, array $options = [])
{
if (isset($options['id'])) {
$options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id']));
}
if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) {
$options['output']->text($classDescription."\n");
}
$tableHeaders = ['Option', 'Value'];
$tableRows[] = ['Service ID', isset($options['id']) ? $options['id'] : '-'];
$tableRows[] = ['Class', $definition->getClass() ?: '-'];
$omitTags = isset($options['omit_tags']) && $options['omit_tags'];
if (!$omitTags && ($tags = $definition->getTags())) {
$tagInformation = [];
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $tagParameters) {
$parameters = array_map(function ($key, $value) {
return sprintf('<info>%s</info>: %s', $key, $value);
}, array_keys($tagParameters), array_values($tagParameters));
$parameters = implode(', ', $parameters);
if ('' === $parameters) {
$tagInformation[] = sprintf('%s', $tagName);
} else {
$tagInformation[] = sprintf('%s (%s)', $tagName, $parameters);
}
}
}
$tagInformation = implode("\n", $tagInformation);
} else {
$tagInformation = '-';
}
$tableRows[] = ['Tags', $tagInformation];
$calls = $definition->getMethodCalls();
if (\count($calls) > 0) {
$callInformation = [];
foreach ($calls as $call) {
$callInformation[] = $call[0];
}
$tableRows[] = ['Calls', implode(', ', $callInformation)];
}
$tableRows[] = ['Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no'];
$tableRows[] = ['Synthetic', $definition->isSynthetic() ? 'yes' : 'no'];
$tableRows[] = ['Lazy', $definition->isLazy() ? 'yes' : 'no'];
$tableRows[] = ['Shared', $definition->isShared() ? 'yes' : 'no'];
$tableRows[] = ['Abstract', $definition->isAbstract() ? 'yes' : 'no'];
$tableRows[] = ['Autowired', $definition->isAutowired() ? 'yes' : 'no'];
$tableRows[] = ['Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no'];
if ($definition->getFile()) {
$tableRows[] = ['Required File', $definition->getFile() ?: '-'];
}
if ($factory = $definition->getFactory()) {
if (\is_array($factory)) {
if ($factory[0] instanceof Reference) {
$tableRows[] = ['Factory Service', $factory[0]];
} elseif ($factory[0] instanceof Definition) {
throw new \InvalidArgumentException('Factory is not describable.');
} else {
$tableRows[] = ['Factory Class', $factory[0]];
}
$tableRows[] = ['Factory Method', $factory[1]];
} else {
$tableRows[] = ['Factory Function', $factory];
}
}
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
$argumentsInformation = [];
if ($showArguments && ($arguments = $definition->getArguments())) {
foreach ($arguments as $argument) {
if ($argument instanceof ServiceClosureArgument) {
$argument = $argument->getValues()[0];
}
if ($argument instanceof Reference) {
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
} elseif ($argument instanceof IteratorArgument) {
$argumentsInformation[] = sprintf('Iterator (%d element(s))', \count($argument->getValues()));
} elseif ($argument instanceof ServiceLocatorArgument) {
$argumentsInformation[] = sprintf('Service locator (%d element(s))', \count($argument->getValues()));
} elseif ($argument instanceof Definition) {
$argumentsInformation[] = 'Inlined Service';
} else {
$argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument;
}
}
$tableRows[] = ['Arguments', implode("\n", $argumentsInformation)];
}
$options['output']->table($tableHeaders, $tableRows);
} | php | protected function describeContainerDefinition(Definition $definition, array $options = [])
{
if (isset($options['id'])) {
$options['output']->title(sprintf('Information for Service "<info>%s</info>"', $options['id']));
}
if ('' !== $classDescription = $this->getClassDescription((string) $definition->getClass())) {
$options['output']->text($classDescription."\n");
}
$tableHeaders = ['Option', 'Value'];
$tableRows[] = ['Service ID', isset($options['id']) ? $options['id'] : '-'];
$tableRows[] = ['Class', $definition->getClass() ?: '-'];
$omitTags = isset($options['omit_tags']) && $options['omit_tags'];
if (!$omitTags && ($tags = $definition->getTags())) {
$tagInformation = [];
foreach ($tags as $tagName => $tagData) {
foreach ($tagData as $tagParameters) {
$parameters = array_map(function ($key, $value) {
return sprintf('<info>%s</info>: %s', $key, $value);
}, array_keys($tagParameters), array_values($tagParameters));
$parameters = implode(', ', $parameters);
if ('' === $parameters) {
$tagInformation[] = sprintf('%s', $tagName);
} else {
$tagInformation[] = sprintf('%s (%s)', $tagName, $parameters);
}
}
}
$tagInformation = implode("\n", $tagInformation);
} else {
$tagInformation = '-';
}
$tableRows[] = ['Tags', $tagInformation];
$calls = $definition->getMethodCalls();
if (\count($calls) > 0) {
$callInformation = [];
foreach ($calls as $call) {
$callInformation[] = $call[0];
}
$tableRows[] = ['Calls', implode(', ', $callInformation)];
}
$tableRows[] = ['Public', $definition->isPublic() && !$definition->isPrivate() ? 'yes' : 'no'];
$tableRows[] = ['Synthetic', $definition->isSynthetic() ? 'yes' : 'no'];
$tableRows[] = ['Lazy', $definition->isLazy() ? 'yes' : 'no'];
$tableRows[] = ['Shared', $definition->isShared() ? 'yes' : 'no'];
$tableRows[] = ['Abstract', $definition->isAbstract() ? 'yes' : 'no'];
$tableRows[] = ['Autowired', $definition->isAutowired() ? 'yes' : 'no'];
$tableRows[] = ['Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no'];
if ($definition->getFile()) {
$tableRows[] = ['Required File', $definition->getFile() ?: '-'];
}
if ($factory = $definition->getFactory()) {
if (\is_array($factory)) {
if ($factory[0] instanceof Reference) {
$tableRows[] = ['Factory Service', $factory[0]];
} elseif ($factory[0] instanceof Definition) {
throw new \InvalidArgumentException('Factory is not describable.');
} else {
$tableRows[] = ['Factory Class', $factory[0]];
}
$tableRows[] = ['Factory Method', $factory[1]];
} else {
$tableRows[] = ['Factory Function', $factory];
}
}
$showArguments = isset($options['show_arguments']) && $options['show_arguments'];
$argumentsInformation = [];
if ($showArguments && ($arguments = $definition->getArguments())) {
foreach ($arguments as $argument) {
if ($argument instanceof ServiceClosureArgument) {
$argument = $argument->getValues()[0];
}
if ($argument instanceof Reference) {
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
} elseif ($argument instanceof IteratorArgument) {
$argumentsInformation[] = sprintf('Iterator (%d element(s))', \count($argument->getValues()));
} elseif ($argument instanceof ServiceLocatorArgument) {
$argumentsInformation[] = sprintf('Service locator (%d element(s))', \count($argument->getValues()));
} elseif ($argument instanceof Definition) {
$argumentsInformation[] = 'Inlined Service';
} else {
$argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument;
}
}
$tableRows[] = ['Arguments', implode("\n", $argumentsInformation)];
}
$options['output']->table($tableHeaders, $tableRows);
} | [
"protected",
"function",
"describeContainerDefinition",
"(",
"Definition",
"$",
"definition",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'output'"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php#L266-L364 | train | Describes the container definition | [
30522,
5123,
3853,
6235,
8663,
18249,
2121,
3207,
16294,
22753,
1006,
6210,
1002,
6210,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
7047,
1031,
1005,
8909,
1005,
1033,
1007,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Config/Util/XmlUtils.php | XmlUtils.parse | public static function parse($content, $schemaOrCallable = null)
{
if (!\extension_loaded('dom')) {
throw new \LogicException('Extension DOM is required.');
}
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(true);
libxml_clear_errors();
$dom = new \DOMDocument();
$dom->validateOnParse = true;
if (!$dom->loadXML($content, LIBXML_NONET | (\defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
libxml_disable_entity_loader($disableEntities);
throw new XmlParsingException(implode("\n", static::getXmlErrors($internalErrors)));
}
$dom->normalizeDocument();
libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);
foreach ($dom->childNodes as $child) {
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
throw new XmlParsingException('Document types are not allowed.');
}
}
if (null !== $schemaOrCallable) {
$internalErrors = libxml_use_internal_errors(true);
libxml_clear_errors();
$e = null;
if (\is_callable($schemaOrCallable)) {
try {
$valid = $schemaOrCallable($dom, $internalErrors);
} catch (\Exception $e) {
$valid = false;
}
} elseif (!\is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) {
$schemaSource = file_get_contents((string) $schemaOrCallable);
$valid = @$dom->schemaValidateSource($schemaSource);
} else {
libxml_use_internal_errors($internalErrors);
throw new XmlParsingException('The schemaOrCallable argument has to be a valid path to XSD file or callable.');
}
if (!$valid) {
$messages = static::getXmlErrors($internalErrors);
if (empty($messages)) {
throw new InvalidXmlException('The XML is not valid.', 0, $e);
}
throw new XmlParsingException(implode("\n", $messages), 0, $e);
}
}
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
return $dom;
} | php | public static function parse($content, $schemaOrCallable = null)
{
if (!\extension_loaded('dom')) {
throw new \LogicException('Extension DOM is required.');
}
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(true);
libxml_clear_errors();
$dom = new \DOMDocument();
$dom->validateOnParse = true;
if (!$dom->loadXML($content, LIBXML_NONET | (\defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
libxml_disable_entity_loader($disableEntities);
throw new XmlParsingException(implode("\n", static::getXmlErrors($internalErrors)));
}
$dom->normalizeDocument();
libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);
foreach ($dom->childNodes as $child) {
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
throw new XmlParsingException('Document types are not allowed.');
}
}
if (null !== $schemaOrCallable) {
$internalErrors = libxml_use_internal_errors(true);
libxml_clear_errors();
$e = null;
if (\is_callable($schemaOrCallable)) {
try {
$valid = $schemaOrCallable($dom, $internalErrors);
} catch (\Exception $e) {
$valid = false;
}
} elseif (!\is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) {
$schemaSource = file_get_contents((string) $schemaOrCallable);
$valid = @$dom->schemaValidateSource($schemaSource);
} else {
libxml_use_internal_errors($internalErrors);
throw new XmlParsingException('The schemaOrCallable argument has to be a valid path to XSD file or callable.');
}
if (!$valid) {
$messages = static::getXmlErrors($internalErrors);
if (empty($messages)) {
throw new InvalidXmlException('The XML is not valid.', 0, $e);
}
throw new XmlParsingException(implode("\n", $messages), 0, $e);
}
}
libxml_clear_errors();
libxml_use_internal_errors($internalErrors);
return $dom;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"content",
",",
"$",
"schemaOrCallable",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"\\",
"extension_loaded",
"(",
"'dom'",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Extension DOM is required... | Parses an XML string.
@param string $content An XML string
@param string|callable|null $schemaOrCallable An XSD schema file path, a callable, or null to disable validation
@return \DOMDocument
@throws XmlParsingException When parsing of XML file returns error
@throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself
@throws \RuntimeException When DOM extension is missing | [
"Parses",
"an",
"XML",
"string",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Util/XmlUtils.php#L47-L109 | train | Parse XML content | [
30522,
2270,
10763,
3853,
11968,
3366,
1006,
1002,
4180,
1010,
1002,
8040,
28433,
2953,
9289,
20470,
2571,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1032,
5331,
1035,
8209,
1006,
1005,
14383,
1005,
1007,
1007,
1063,
5466,
2047,
1032,
7961,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Session/Namespace.php | Zend_Session_Namespace.applySet | public function applySet($callback)
{
$arg_list = func_get_args();
$arg_list[0] = $_SESSION[$this->_namespace];
$result = call_user_func_array($callback, $arg_list);
if (!is_array($result)) {
/**
* @see Zend_Session_Exception
*/
// require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception('Result must be an array. Got: ' . gettype($result));
}
$_SESSION[$this->_namespace] = $result;
return $result;
} | php | public function applySet($callback)
{
$arg_list = func_get_args();
$arg_list[0] = $_SESSION[$this->_namespace];
$result = call_user_func_array($callback, $arg_list);
if (!is_array($result)) {
/**
* @see Zend_Session_Exception
*/
// require_once 'Zend/Session/Exception.php';
throw new Zend_Session_Exception('Result must be an array. Got: ' . gettype($result));
}
$_SESSION[$this->_namespace] = $result;
return $result;
} | [
"public",
"function",
"applySet",
"(",
"$",
"callback",
")",
"{",
"$",
"arg_list",
"=",
"func_get_args",
"(",
")",
";",
"$",
"arg_list",
"[",
"0",
"]",
"=",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"_namespace",
"]",
";",
"$",
"result",
"=",
"call_us... | applySet() - enables applying user-selected function, and sets entire namespace to the result
Result of $callback must be an array.
Parameters following the $callback argument are passed to the callback function.
Caveat: ignores members expiring now.
Example:
$namespace->applySet('array_merge', array('tree' => 'apple', 'fruit' => 'peach'), array('flower' => 'rose'));
@param string|array $callback - callback function | [
"applySet",
"()",
"-",
"enables",
"applying",
"user",
"-",
"selected",
"function",
"and",
"sets",
"entire",
"namespace",
"to",
"the",
"result",
"Result",
"of",
"$callback",
"must",
"be",
"an",
"array",
".",
"Parameters",
"following",
"the",
"$callback",
"argum... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session/Namespace.php#L361-L375 | train | Apply a callback to the session | [
30522,
2270,
3853,
6611,
13462,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
12098,
2290,
1035,
2862,
1027,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
1025,
1002,
12098,
2290,
1035,
2862,
1031,
1014,
1033,
1027,
1002,
1035,
5219,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Controller.php | Controller.runPage | public function runPage($page, $useAjax = true)
{
$this->page = $page;
/*
* If the page doesn't refer any layout, create the fallback layout.
* Otherwise load the layout specified in the page.
*/
if (!$page->layout) {
$layout = Layout::initFallback($this->theme);
}
elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) {
throw new CmsException(Lang::get('cms::lang.layout.not_found_name', ['name'=>$page->layout]));
}
$this->layout = $layout;
/*
* The 'this' variable is reserved for default variables.
*/
$this->vars['this'] = [
'page' => $this->page,
'layout' => $this->layout,
'theme' => $this->theme,
'param' => $this->router->getParameters(),
'controller' => $this,
'environment' => App::environment(),
'session' => App::make('session'),
];
/*
* Check for the presence of validation errors in the session.
*/
$this->vars['errors'] = (Config::get('session.driver') && Session::has('errors'))
? Session::get('errors')
: new \Illuminate\Support\ViewErrorBag;
/*
* Handle AJAX requests and execute the life cycle functions
*/
$this->initCustomObjects();
$this->initComponents();
/*
* Give the layout and page an opportunity to participate
* after components are initialized and before AJAX is handled.
*/
if ($this->layoutObj) {
CmsException::mask($this->layout, 300);
$this->layoutObj->onInit();
CmsException::unmask();
}
CmsException::mask($this->page, 300);
$this->pageObj->onInit();
CmsException::unmask();
/**
* @event cms.page.init
* Provides an opportunity to return a custom response from Controller->runPage() before AJAX handlers are executed
*
* Example usage:
*
* Event::listen('cms.page.init', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* });
*
* Or
*
* $CmsController->bindEvent('page.init', function ((\Cms\Classes\Page) $page) {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.init', [$page])) {
return $event;
}
/*
* Execute AJAX event
*/
if ($useAjax && $ajaxResponse = $this->execAjaxHandlers()) {
return $ajaxResponse;
}
/*
* Execute postback handler
*/
if (
$useAjax &&
($handler = post('_handler')) &&
$this->verifyCsrfToken() &&
($handlerResponse = $this->runAjaxHandler($handler)) &&
$handlerResponse !== true
) {
return $handlerResponse;
}
/*
* Execute page lifecycle
*/
if ($cycleResponse = $this->execPageCycle()) {
return $cycleResponse;
}
/**
* @event cms.page.beforeRenderPage
* Fires after AJAX handlers are dealt with and provides an opportunity to modify the page contents
*
* Example usage:
*
* Event::listen('cms.page.beforeRenderPage', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
* return 'Custom page contents';
* });
*
* Or
*
* $CmsController->bindEvent('page.beforeRenderPage', function ((\Cms\Classes\Page) $page) {
* return 'Custom page contents';
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.beforeRenderPage', [$page])) {
$this->pageContents = $event;
}
else {
/*
* Render the page
*/
CmsException::mask($this->page, 400);
$this->loader->setObject($this->page);
$template = $this->twig->loadTemplate($this->page->getFilePath());
$this->pageContents = $template->render($this->vars);
CmsException::unmask();
}
/*
* Render the layout
*/
CmsException::mask($this->layout, 400);
$this->loader->setObject($this->layout);
$template = $this->twig->loadTemplate($this->layout->getFilePath());
$result = $template->render($this->vars);
CmsException::unmask();
return $result;
} | php | public function runPage($page, $useAjax = true)
{
$this->page = $page;
/*
* If the page doesn't refer any layout, create the fallback layout.
* Otherwise load the layout specified in the page.
*/
if (!$page->layout) {
$layout = Layout::initFallback($this->theme);
}
elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) {
throw new CmsException(Lang::get('cms::lang.layout.not_found_name', ['name'=>$page->layout]));
}
$this->layout = $layout;
/*
* The 'this' variable is reserved for default variables.
*/
$this->vars['this'] = [
'page' => $this->page,
'layout' => $this->layout,
'theme' => $this->theme,
'param' => $this->router->getParameters(),
'controller' => $this,
'environment' => App::environment(),
'session' => App::make('session'),
];
/*
* Check for the presence of validation errors in the session.
*/
$this->vars['errors'] = (Config::get('session.driver') && Session::has('errors'))
? Session::get('errors')
: new \Illuminate\Support\ViewErrorBag;
/*
* Handle AJAX requests and execute the life cycle functions
*/
$this->initCustomObjects();
$this->initComponents();
/*
* Give the layout and page an opportunity to participate
* after components are initialized and before AJAX is handled.
*/
if ($this->layoutObj) {
CmsException::mask($this->layout, 300);
$this->layoutObj->onInit();
CmsException::unmask();
}
CmsException::mask($this->page, 300);
$this->pageObj->onInit();
CmsException::unmask();
/**
* @event cms.page.init
* Provides an opportunity to return a custom response from Controller->runPage() before AJAX handlers are executed
*
* Example usage:
*
* Event::listen('cms.page.init', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* });
*
* Or
*
* $CmsController->bindEvent('page.init', function ((\Cms\Classes\Page) $page) {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.init', [$page])) {
return $event;
}
/*
* Execute AJAX event
*/
if ($useAjax && $ajaxResponse = $this->execAjaxHandlers()) {
return $ajaxResponse;
}
/*
* Execute postback handler
*/
if (
$useAjax &&
($handler = post('_handler')) &&
$this->verifyCsrfToken() &&
($handlerResponse = $this->runAjaxHandler($handler)) &&
$handlerResponse !== true
) {
return $handlerResponse;
}
/*
* Execute page lifecycle
*/
if ($cycleResponse = $this->execPageCycle()) {
return $cycleResponse;
}
/**
* @event cms.page.beforeRenderPage
* Fires after AJAX handlers are dealt with and provides an opportunity to modify the page contents
*
* Example usage:
*
* Event::listen('cms.page.beforeRenderPage', function ((\Cms\Classes\Controller) $controller, (\Cms\Classes\Page) $page) {
* return 'Custom page contents';
* });
*
* Or
*
* $CmsController->bindEvent('page.beforeRenderPage', function ((\Cms\Classes\Page) $page) {
* return 'Custom page contents';
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.beforeRenderPage', [$page])) {
$this->pageContents = $event;
}
else {
/*
* Render the page
*/
CmsException::mask($this->page, 400);
$this->loader->setObject($this->page);
$template = $this->twig->loadTemplate($this->page->getFilePath());
$this->pageContents = $template->render($this->vars);
CmsException::unmask();
}
/*
* Render the layout
*/
CmsException::mask($this->layout, 400);
$this->loader->setObject($this->layout);
$template = $this->twig->loadTemplate($this->layout->getFilePath());
$result = $template->render($this->vars);
CmsException::unmask();
return $result;
} | [
"public",
"function",
"runPage",
"(",
"$",
"page",
",",
"$",
"useAjax",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"page",
"=",
"$",
"page",
";",
"/*\n * If the page doesn't refer any layout, create the fallback layout.\n * Otherwise load the layout specified... | Runs a page directly from its object and supplied parameters.
@param \Cms\Classes\Page $page Specifies the CMS page to run.
@return string | [
"Runs",
"a",
"page",
"directly",
"from",
"its",
"object",
"and",
"supplied",
"parameters",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Controller.php#L291-L438 | train | Runs the page. | [
30522,
2270,
3853,
2448,
13704,
1006,
1002,
3931,
1010,
1002,
2224,
22734,
2595,
1027,
2995,
1007,
1063,
1002,
2023,
1011,
1028,
3931,
1027,
1002,
3931,
1025,
1013,
1008,
1008,
2065,
1996,
3931,
2987,
1005,
1056,
6523,
2151,
9621,
1010,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Style/SymfonyStyle.php | SymfonyStyle.newLine | public function newLine($count = 1)
{
parent::newLine($count);
$this->bufferedOutput->write(str_repeat("\n", $count));
} | php | public function newLine($count = 1)
{
parent::newLine($count);
$this->bufferedOutput->write(str_repeat("\n", $count));
} | [
"public",
"function",
"newLine",
"(",
"$",
"count",
"=",
"1",
")",
"{",
"parent",
"::",
"newLine",
"(",
"$",
"count",
")",
";",
"$",
"this",
"->",
"bufferedOutput",
"->",
"write",
"(",
"str_repeat",
"(",
"\"\\n\"",
",",
"$",
"count",
")",
")",
";",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Style/SymfonyStyle.php#L337-L341 | train | This method is called by the parent class to write a new line of code. | [
30522,
2270,
3853,
2047,
4179,
1006,
1002,
4175,
1027,
1015,
1007,
1063,
6687,
1024,
1024,
2047,
4179,
1006,
1002,
4175,
1007,
1025,
1002,
2023,
1011,
1028,
17698,
26010,
4904,
18780,
1011,
1028,
4339,
1006,
2358,
2099,
1035,
9377,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Mbox.php | Zend_Mail_Storage_Mbox._openMboxFile | protected function _openMboxFile($filename)
{
if ($this->_fh) {
$this->close();
}
$this->_fh = @fopen($filename, 'r');
if (!$this->_fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot open mbox file');
}
$this->_filename = $filename;
$this->_filemtime = filemtime($this->_filename);
if (!$this->_isMboxFile($this->_fh, false)) {
@fclose($this->_fh);
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('file is not a valid mbox format');
}
$messagePos = array('start' => ftell($this->_fh), 'separator' => 0, 'end' => 0);
while (($line = fgets($this->_fh)) !== false) {
if (strpos($line, 'From ') === 0) {
$messagePos['end'] = ftell($this->_fh) - strlen($line) - 2; // + newline
if (!$messagePos['separator']) {
$messagePos['separator'] = $messagePos['end'];
}
$this->_positions[] = $messagePos;
$messagePos = array('start' => ftell($this->_fh), 'separator' => 0, 'end' => 0);
}
if (!$messagePos['separator'] && !trim($line)) {
$messagePos['separator'] = ftell($this->_fh);
}
}
$messagePos['end'] = ftell($this->_fh);
if (!$messagePos['separator']) {
$messagePos['separator'] = $messagePos['end'];
}
$this->_positions[] = $messagePos;
} | php | protected function _openMboxFile($filename)
{
if ($this->_fh) {
$this->close();
}
$this->_fh = @fopen($filename, 'r');
if (!$this->_fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot open mbox file');
}
$this->_filename = $filename;
$this->_filemtime = filemtime($this->_filename);
if (!$this->_isMboxFile($this->_fh, false)) {
@fclose($this->_fh);
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('file is not a valid mbox format');
}
$messagePos = array('start' => ftell($this->_fh), 'separator' => 0, 'end' => 0);
while (($line = fgets($this->_fh)) !== false) {
if (strpos($line, 'From ') === 0) {
$messagePos['end'] = ftell($this->_fh) - strlen($line) - 2; // + newline
if (!$messagePos['separator']) {
$messagePos['separator'] = $messagePos['end'];
}
$this->_positions[] = $messagePos;
$messagePos = array('start' => ftell($this->_fh), 'separator' => 0, 'end' => 0);
}
if (!$messagePos['separator'] && !trim($line)) {
$messagePos['separator'] = ftell($this->_fh);
}
}
$messagePos['end'] = ftell($this->_fh);
if (!$messagePos['separator']) {
$messagePos['separator'] = $messagePos['end'];
}
$this->_positions[] = $messagePos;
} | [
"protected",
"function",
"_openMboxFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_fh",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_fh",
"=",
"@",
"fopen",
"(",
"$",
"filename",
",",
"'r'"... | open given file as current mbox file
@param string $filename filename of mbox file
@return null
@throws Zend_Mail_Storage_Exception | [
"open",
"given",
"file",
"as",
"current",
"mbox",
"file"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Mbox.php#L282-L328 | train | Open a mbox file and extract the message positions | [
30522,
5123,
3853,
1035,
2330,
13344,
2595,
8873,
2571,
1006,
1002,
5371,
18442,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
1042,
2232,
1007,
1063,
1002,
2023,
1011,
1028,
2485,
1006,
1007,
1025,
1065,
1002,
2023,
1011,
1028,
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/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php | CompiledUrlMatcherDumper.getCompiledRoutes | public function getCompiledRoutes(bool $forDump = false): array
{
// Group hosts by same-suffix, re-order when possible
$matchHost = false;
$routes = new StaticPrefixCollection();
foreach ($this->getRoutes()->all() as $name => $route) {
if ($host = $route->getHost()) {
$matchHost = true;
$host = '/'.strtr(strrev($host), '}.{', '(/)');
}
$routes->addRoute($host ?: '/(.*)', [$name, $route]);
}
if ($matchHost) {
$compiledRoutes = [true];
$routes = $routes->populateCollection(new RouteCollection());
} else {
$compiledRoutes = [false];
$routes = $this->getRoutes();
}
list($staticRoutes, $dynamicRoutes) = $this->groupStaticRoutes($routes);
$conditions = [null];
$compiledRoutes[] = $this->compileStaticRoutes($staticRoutes, $conditions);
$chunkLimit = \count($dynamicRoutes);
while (true) {
try {
$this->signalingException = new \RuntimeException('preg_match(): Compilation failed: regular expression is too large');
$compiledRoutes = array_merge($compiledRoutes, $this->compileDynamicRoutes($dynamicRoutes, $matchHost, $chunkLimit, $conditions));
break;
} catch (\Exception $e) {
if (1 < $chunkLimit && $this->signalingException === $e) {
$chunkLimit = 1 + ($chunkLimit >> 1);
continue;
}
throw $e;
}
}
if ($forDump) {
$compiledRoutes[2] = $compiledRoutes[4];
}
unset($conditions[0]);
if ($conditions) {
foreach ($conditions as $expression => $condition) {
$conditions[$expression] = "case {$condition}: return {$expression};";
}
$checkConditionCode = <<<EOF
static function (\$condition, \$context, \$request) { // \$checkCondition
switch (\$condition) {
{$this->indent(implode("\n", $conditions), 3)}
}
}
EOF;
$compiledRoutes[4] = $forDump ? $checkConditionCode .= ",\n" : eval('return '.$checkConditionCode.';');
} else {
$compiledRoutes[4] = $forDump ? " null, // \$checkCondition\n" : null;
}
return $compiledRoutes;
} | php | public function getCompiledRoutes(bool $forDump = false): array
{
// Group hosts by same-suffix, re-order when possible
$matchHost = false;
$routes = new StaticPrefixCollection();
foreach ($this->getRoutes()->all() as $name => $route) {
if ($host = $route->getHost()) {
$matchHost = true;
$host = '/'.strtr(strrev($host), '}.{', '(/)');
}
$routes->addRoute($host ?: '/(.*)', [$name, $route]);
}
if ($matchHost) {
$compiledRoutes = [true];
$routes = $routes->populateCollection(new RouteCollection());
} else {
$compiledRoutes = [false];
$routes = $this->getRoutes();
}
list($staticRoutes, $dynamicRoutes) = $this->groupStaticRoutes($routes);
$conditions = [null];
$compiledRoutes[] = $this->compileStaticRoutes($staticRoutes, $conditions);
$chunkLimit = \count($dynamicRoutes);
while (true) {
try {
$this->signalingException = new \RuntimeException('preg_match(): Compilation failed: regular expression is too large');
$compiledRoutes = array_merge($compiledRoutes, $this->compileDynamicRoutes($dynamicRoutes, $matchHost, $chunkLimit, $conditions));
break;
} catch (\Exception $e) {
if (1 < $chunkLimit && $this->signalingException === $e) {
$chunkLimit = 1 + ($chunkLimit >> 1);
continue;
}
throw $e;
}
}
if ($forDump) {
$compiledRoutes[2] = $compiledRoutes[4];
}
unset($conditions[0]);
if ($conditions) {
foreach ($conditions as $expression => $condition) {
$conditions[$expression] = "case {$condition}: return {$expression};";
}
$checkConditionCode = <<<EOF
static function (\$condition, \$context, \$request) { // \$checkCondition
switch (\$condition) {
{$this->indent(implode("\n", $conditions), 3)}
}
}
EOF;
$compiledRoutes[4] = $forDump ? $checkConditionCode .= ",\n" : eval('return '.$checkConditionCode.';');
} else {
$compiledRoutes[4] = $forDump ? " null, // \$checkCondition\n" : null;
}
return $compiledRoutes;
} | [
"public",
"function",
"getCompiledRoutes",
"(",
"bool",
"$",
"forDump",
"=",
"false",
")",
":",
"array",
"{",
"// Group hosts by same-suffix, re-order when possible",
"$",
"matchHost",
"=",
"false",
";",
"$",
"routes",
"=",
"new",
"StaticPrefixCollection",
"(",
")",... | Generates the arrays for CompiledUrlMatcher's constructor. | [
"Generates",
"the",
"arrays",
"for",
"CompiledUrlMatcher",
"s",
"constructor",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Matcher/Dumper/CompiledUrlMatcherDumper.php#L64-L130 | train | Returns the compiled routes. | [
30522,
2270,
3853,
2131,
9006,
22090,
22196,
10421,
2015,
1006,
22017,
2140,
1002,
4811,
24237,
1027,
6270,
1007,
1024,
9140,
1063,
1013,
1013,
2177,
6184,
2011,
2168,
1011,
16809,
1010,
2128,
1011,
2344,
2043,
2825,
1002,
2674,
15006,
2102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db.php | Db.segmentedFetchOne | public static function segmentedFetchOne($sql, $first, $last, $step, $params = array())
{
$result = array();
if ($step > 0) {
for ($i = $first; $i <= $last; $i += $step) {
$result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
}
} else {
for ($i = $first; $i >= $last; $i += $step) {
$result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
}
}
return $result;
} | php | public static function segmentedFetchOne($sql, $first, $last, $step, $params = array())
{
$result = array();
if ($step > 0) {
for ($i = $first; $i <= $last; $i += $step) {
$result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
}
} else {
for ($i = $first; $i >= $last; $i += $step) {
$result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
}
}
return $result;
} | [
"public",
"static",
"function",
"segmentedFetchOne",
"(",
"$",
"sql",
",",
"$",
"first",
",",
"$",
"last",
",",
"$",
"step",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"step",... | Performs a `SELECT` on a table one chunk at a time and returns an array
of every fetched value.
This function will break up a `SELECT` query into several smaller queries by
using only a limited number of rows at a time. It will accumulate the results
of each smaller query and return the result.
This function should be used when performing a `SELECT` that can
take a long time to finish. Using several smaller queries will ensure that
the table will not be locked for too long.
@param string $sql The SQL to perform. The last two conditions of the `WHERE`
expression must be as follows: `'id >= ? AND id < ?'` where
**id** is the int id of the table.
@param int $first The minimum ID to loop from.
@param int $last The maximum ID to loop to.
@param int $step The maximum number of rows to scan in one query.
@param array $params Parameters to bind in the query, `array(param1 => value1, param2 => value2)`
@return array An array of primitive values. | [
"Performs",
"a",
"SELECT",
"on",
"a",
"table",
"one",
"chunk",
"at",
"a",
"time",
"and",
"returns",
"an",
"array",
"of",
"every",
"fetched",
"value",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db.php#L551-L566 | train | Performs a SELECT or SHOW statement on the database. | [
30522,
2270,
10763,
3853,
6903,
2098,
7959,
10649,
5643,
1006,
1002,
29296,
1010,
1002,
2034,
1010,
1002,
2197,
1010,
1002,
3357,
1010,
1002,
11498,
5244,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
2765,
1027,
9140,
1006,
1007,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php | MySqlGrammar.modifySrid | protected function modifySrid(Blueprint $blueprint, Fluent $column)
{
if (! is_null($column->srid) && is_int($column->srid) && $column->srid > 0) {
return ' srid '.$column->srid;
}
} | php | protected function modifySrid(Blueprint $blueprint, Fluent $column)
{
if (! is_null($column->srid) && is_int($column->srid) && $column->srid > 0) {
return ' srid '.$column->srid;
}
} | [
"protected",
"function",
"modifySrid",
"(",
"Blueprint",
"$",
"blueprint",
",",
"Fluent",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"column",
"->",
"srid",
")",
"&&",
"is_int",
"(",
"$",
"column",
"->",
"srid",
")",
"&&",
"$",
"co... | Get the SQL for a SRID column modifier.
@param \Illuminate\Database\Schema\Blueprint $blueprint
@param \Illuminate\Support\Fluent $column
@return string|null | [
"Get",
"the",
"SQL",
"for",
"a",
"SRID",
"column",
"modifier",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php#L1024-L1029 | train | Protected modify Srid | [
30522,
5123,
3853,
19933,
21338,
3593,
1006,
2630,
16550,
1002,
2630,
16550,
1010,
19376,
1002,
5930,
1007,
1063,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
5930,
1011,
1028,
5185,
2094,
1007,
1004,
1004,
2003,
1035,
20014,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Abstract.php | Zend_Db_Adapter_Abstract.rollBack | public function rollBack()
{
$this->_connect();
$q = $this->_profiler->queryStart('rollback', Zend_Db_Profiler::TRANSACTION);
$this->_rollBack();
$this->_profiler->queryEnd($q);
return $this;
} | php | public function rollBack()
{
$this->_connect();
$q = $this->_profiler->queryStart('rollback', Zend_Db_Profiler::TRANSACTION);
$this->_rollBack();
$this->_profiler->queryEnd($q);
return $this;
} | [
"public",
"function",
"rollBack",
"(",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"$",
"q",
"=",
"$",
"this",
"->",
"_profiler",
"->",
"queryStart",
"(",
"'rollback'",
",",
"Zend_Db_Profiler",
"::",
"TRANSACTION",
")",
";",
"$",
"this",
"-... | Roll back a transaction and return to autocommit mode.
@return Zend_Db_Adapter_Abstract | [
"Roll",
"back",
"a",
"transaction",
"and",
"return",
"to",
"autocommit",
"mode",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Abstract.php#L519-L526 | train | Rollback all changes to the database | [
30522,
2270,
3853,
4897,
5963,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1002,
1053,
1027,
1002,
2023,
1011,
1028,
1035,
6337,
2099,
1011,
1028,
23032,
14117,
2102,
1006,
1005,
4897,
5963,
30524,
23032,
10497,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/models/ThemeData.php | ThemeData.getFormFields | public function getFormFields()
{
if (!$theme = CmsTheme::load($this->theme)) {
throw new Exception(Lang::get('Unable to find theme with name :name', $this->theme));
}
$config = $theme->getFormConfig();
return array_get($config, 'fields', []) +
array_get($config, 'tabs.fields', []) +
array_get($config, 'secondaryTabs.fields', []);
} | php | public function getFormFields()
{
if (!$theme = CmsTheme::load($this->theme)) {
throw new Exception(Lang::get('Unable to find theme with name :name', $this->theme));
}
$config = $theme->getFormConfig();
return array_get($config, 'fields', []) +
array_get($config, 'tabs.fields', []) +
array_get($config, 'secondaryTabs.fields', []);
} | [
"public",
"function",
"getFormFields",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"theme",
"=",
"CmsTheme",
"::",
"load",
"(",
"$",
"this",
"->",
"theme",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Lang",
"::",
"get",
"(",
"'Unable to find theme with nam... | Returns all fields defined for this model, based on form field definitions.
@return array | [
"Returns",
"all",
"fields",
"defined",
"for",
"this",
"model",
"based",
"on",
"form",
"field",
"definitions",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/models/ThemeData.php#L190-L201 | train | Get form fields | [
30522,
2270,
3853,
2131,
14192,
15155,
1006,
1007,
1063,
2065,
1006,
999,
1002,
4323,
1027,
4642,
3367,
29122,
2063,
1024,
1024,
7170,
1006,
1002,
2023,
1011,
1028,
4323,
1007,
1007,
1063,
5466,
2047,
6453,
1006,
11374,
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/Bridge/Twig/Node/DumpNode.php | DumpNode.compile | public function compile(Compiler $compiler)
{
$compiler
->write("if (\$this->env->isDebug()) {\n")
->indent();
if (!$this->hasNode('values')) {
// remove embedded templates (macros) from the context
$compiler
->write(sprintf('$%svars = [];'."\n", $this->varPrefix))
->write(sprintf('foreach ($context as $%1$skey => $%1$sval) {'."\n", $this->varPrefix))
->indent()
->write(sprintf('if (!$%sval instanceof \Twig\Template) {'."\n", $this->varPrefix))
->indent()
->write(sprintf('$%1$svars[$%1$skey] = $%1$sval;'."\n", $this->varPrefix))
->outdent()
->write("}\n")
->outdent()
->write("}\n")
->addDebugInfo($this)
->write(sprintf('\Symfony\Component\VarDumper\VarDumper::dump($%svars);'."\n", $this->varPrefix));
} elseif (($values = $this->getNode('values')) && 1 === $values->count()) {
$compiler
->addDebugInfo($this)
->write('\Symfony\Component\VarDumper\VarDumper::dump(')
->subcompile($values->getNode(0))
->raw(");\n");
} else {
$compiler
->addDebugInfo($this)
->write('\Symfony\Component\VarDumper\VarDumper::dump(['."\n")
->indent();
foreach ($values as $node) {
$compiler->write('');
if ($node->hasAttribute('name')) {
$compiler
->string($node->getAttribute('name'))
->raw(' => ');
}
$compiler
->subcompile($node)
->raw(",\n");
}
$compiler
->outdent()
->write("]);\n");
}
$compiler
->outdent()
->write("}\n");
} | php | public function compile(Compiler $compiler)
{
$compiler
->write("if (\$this->env->isDebug()) {\n")
->indent();
if (!$this->hasNode('values')) {
// remove embedded templates (macros) from the context
$compiler
->write(sprintf('$%svars = [];'."\n", $this->varPrefix))
->write(sprintf('foreach ($context as $%1$skey => $%1$sval) {'."\n", $this->varPrefix))
->indent()
->write(sprintf('if (!$%sval instanceof \Twig\Template) {'."\n", $this->varPrefix))
->indent()
->write(sprintf('$%1$svars[$%1$skey] = $%1$sval;'."\n", $this->varPrefix))
->outdent()
->write("}\n")
->outdent()
->write("}\n")
->addDebugInfo($this)
->write(sprintf('\Symfony\Component\VarDumper\VarDumper::dump($%svars);'."\n", $this->varPrefix));
} elseif (($values = $this->getNode('values')) && 1 === $values->count()) {
$compiler
->addDebugInfo($this)
->write('\Symfony\Component\VarDumper\VarDumper::dump(')
->subcompile($values->getNode(0))
->raw(");\n");
} else {
$compiler
->addDebugInfo($this)
->write('\Symfony\Component\VarDumper\VarDumper::dump(['."\n")
->indent();
foreach ($values as $node) {
$compiler->write('');
if ($node->hasAttribute('name')) {
$compiler
->string($node->getAttribute('name'))
->raw(' => ');
}
$compiler
->subcompile($node)
->raw(",\n");
}
$compiler
->outdent()
->write("]);\n");
}
$compiler
->outdent()
->write("}\n");
} | [
"public",
"function",
"compile",
"(",
"Compiler",
"$",
"compiler",
")",
"{",
"$",
"compiler",
"->",
"write",
"(",
"\"if (\\$this->env->isDebug()) {\\n\"",
")",
"->",
"indent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasNode",
"(",
"'values'",
")... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/Node/DumpNode.php#L38-L89 | train | Compiles the context into the PHP code | [
30522,
2270,
3853,
4012,
22090,
1006,
21624,
1002,
21624,
1007,
1063,
1002,
21624,
1011,
1028,
4339,
1006,
1000,
2065,
1006,
1032,
1002,
2023,
1011,
1028,
4372,
2615,
1011,
1028,
2003,
3207,
8569,
2290,
1006,
1007,
1007,
1063,
1032,
1050,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/DatabaseStore.php | DatabaseStore.put | public function put($key, $value, $seconds)
{
$key = $this->prefix.$key;
$value = $this->serialize($value);
$expiration = $this->getTime() + $seconds;
try {
return $this->table()->insert(compact('key', 'value', 'expiration'));
} catch (Exception $e) {
$result = $this->table()->where('key', $key)->update(compact('value', 'expiration'));
return $result > 0;
}
} | php | public function put($key, $value, $seconds)
{
$key = $this->prefix.$key;
$value = $this->serialize($value);
$expiration = $this->getTime() + $seconds;
try {
return $this->table()->insert(compact('key', 'value', 'expiration'));
} catch (Exception $e) {
$result = $this->table()->where('key', $key)->update(compact('value', 'expiration'));
return $result > 0;
}
} | [
"public",
"function",
"put",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"seconds",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"prefix",
".",
"$",
"key",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"serialize",
"(",
"$",
"value",
")",
";",
... | Store an item in the cache for a given number of seconds.
@param string $key
@param mixed $value
@param int $seconds
@return bool | [
"Store",
"an",
"item",
"in",
"the",
"cache",
"for",
"a",
"given",
"number",
"of",
"seconds",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/DatabaseStore.php#L94-L109 | train | Put a value into the cache | [
30522,
2270,
3853,
2404,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
1002,
3823,
1007,
1063,
1002,
3145,
1027,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
3145,
1025,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
7642,
4697,
1006,
1002,
3643,
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/Grammars/RenameColumn.php | RenameColumn.compile | public static function compile(Grammar $grammar, Blueprint $blueprint, Fluent $command, Connection $connection)
{
$column = $connection->getDoctrineColumn(
$grammar->getTablePrefix().$blueprint->getTable(), $command->from
);
$schema = $connection->getDoctrineSchemaManager();
return (array) $schema->getDatabasePlatform()->getAlterTableSQL(static::getRenamedDiff(
$grammar, $blueprint, $command, $column, $schema
));
} | php | public static function compile(Grammar $grammar, Blueprint $blueprint, Fluent $command, Connection $connection)
{
$column = $connection->getDoctrineColumn(
$grammar->getTablePrefix().$blueprint->getTable(), $command->from
);
$schema = $connection->getDoctrineSchemaManager();
return (array) $schema->getDatabasePlatform()->getAlterTableSQL(static::getRenamedDiff(
$grammar, $blueprint, $command, $column, $schema
));
} | [
"public",
"static",
"function",
"compile",
"(",
"Grammar",
"$",
"grammar",
",",
"Blueprint",
"$",
"blueprint",
",",
"Fluent",
"$",
"command",
",",
"Connection",
"$",
"connection",
")",
"{",
"$",
"column",
"=",
"$",
"connection",
"->",
"getDoctrineColumn",
"(... | Compile a rename column command.
@param \Illuminate\Database\Schema\Grammars\Grammar $grammar
@param \Illuminate\Database\Schema\Blueprint $blueprint
@param \Illuminate\Support\Fluent $command
@param \Illuminate\Database\Connection $connection
@return array | [
"Compile",
"a",
"rename",
"column",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/RenameColumn.php#L23-L34 | train | Compiles a alter table command. | [
30522,
2270,
10763,
3853,
4012,
22090,
1006,
8035,
1002,
8035,
1010,
2630,
16550,
1002,
2630,
16550,
1010,
19376,
1002,
3094,
1010,
4434,
1002,
4434,
1007,
1063,
1002,
5930,
1027,
1002,
4434,
1011,
1028,
2131,
3527,
6593,
11467,
25778,
2819... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/Archiver.php | Archiver.setLatitudeLongitude | private function setLatitudeLongitude(DataTable $tableCity)
{
foreach ($tableCity->getRows() as $row) {
$label = $row->getColumn('label');
if (isset($this->latLongForCities[$label])) {
// get lat/long for city
list($lat, $long) = $this->latLongForCities[$label];
$lat = round($lat, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
$long = round($long, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
// set latitude + longitude metadata
$row->setMetadata('lat', $lat);
$row->setMetadata('long', $long);
}
}
} | php | private function setLatitudeLongitude(DataTable $tableCity)
{
foreach ($tableCity->getRows() as $row) {
$label = $row->getColumn('label');
if (isset($this->latLongForCities[$label])) {
// get lat/long for city
list($lat, $long) = $this->latLongForCities[$label];
$lat = round($lat, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
$long = round($long, LocationProvider::GEOGRAPHIC_COORD_PRECISION);
// set latitude + longitude metadata
$row->setMetadata('lat', $lat);
$row->setMetadata('long', $long);
}
}
} | [
"private",
"function",
"setLatitudeLongitude",
"(",
"DataTable",
"$",
"tableCity",
")",
"{",
"foreach",
"(",
"$",
"tableCity",
"->",
"getRows",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"label",
"=",
"$",
"row",
"->",
"getColumn",
"(",
"'label'",
")",
... | Utility method, appends latitude/longitude pairs to city table labels, if that data
exists for the city. | [
"Utility",
"method",
"appends",
"latitude",
"/",
"longitude",
"pairs",
"to",
"city",
"table",
"labels",
"if",
"that",
"data",
"exists",
"for",
"the",
"city",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/Archiver.php#L172-L187 | train | Set latitude + longitude metadata for city rows | [
30522,
2797,
3853,
2275,
20051,
18679,
10052,
18679,
1006,
2951,
10880,
1002,
2795,
12972,
1007,
1063,
18921,
6776,
1006,
1002,
2795,
12972,
1011,
1028,
2131,
10524,
2015,
1006,
1007,
2004,
1002,
5216,
1007,
1063,
1002,
3830,
1027,
1002,
52... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | BelongsToMany.save | public function save(Model $model, array $pivotAttributes = [], $touch = true)
{
$model->save(['touch' => false]);
$this->attach($model, $pivotAttributes, $touch);
return $model;
} | php | public function save(Model $model, array $pivotAttributes = [], $touch = true)
{
$model->save(['touch' => false]);
$this->attach($model, $pivotAttributes, $touch);
return $model;
} | [
"public",
"function",
"save",
"(",
"Model",
"$",
"model",
",",
"array",
"$",
"pivotAttributes",
"=",
"[",
"]",
",",
"$",
"touch",
"=",
"true",
")",
"{",
"$",
"model",
"->",
"save",
"(",
"[",
"'touch'",
"=>",
"false",
"]",
")",
";",
"$",
"this",
"... | Save a new model and attach it to the parent model.
@param \Illuminate\Database\Eloquent\Model $model
@param array $pivotAttributes
@param bool $touch
@return \Illuminate\Database\Eloquent\Model | [
"Save",
"a",
"new",
"model",
"and",
"attach",
"it",
"to",
"the",
"parent",
"model",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L871-L878 | train | Save a model and attach it to the parent | [
30522,
2270,
3853,
3828,
1006,
2944,
1002,
2944,
1010,
9140,
1002,
14255,
22994,
19321,
3089,
8569,
4570,
1027,
1031,
1033,
1010,
1002,
3543,
1027,
2995,
1007,
1063,
1002,
2944,
1011,
1028,
3828,
1006,
1031,
1005,
3543,
1005,
1027,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php | TextDescriptor.describeEventDispatcherListeners | protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
{
$event = \array_key_exists('event', $options) ? $options['event'] : null;
if (null !== $event) {
$title = sprintf('Registered Listeners for "%s" Event', $event);
} else {
$title = 'Registered Listeners Grouped by Event';
}
$options['output']->title($title);
$registeredListeners = $eventDispatcher->getListeners($event);
if (null !== $event) {
$this->renderEventListenerTable($eventDispatcher, $event, $registeredListeners, $options['output']);
} else {
ksort($registeredListeners);
foreach ($registeredListeners as $eventListened => $eventListeners) {
$options['output']->section(sprintf('"%s" event', $eventListened));
$this->renderEventListenerTable($eventDispatcher, $eventListened, $eventListeners, $options['output']);
}
}
} | php | protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = [])
{
$event = \array_key_exists('event', $options) ? $options['event'] : null;
if (null !== $event) {
$title = sprintf('Registered Listeners for "%s" Event', $event);
} else {
$title = 'Registered Listeners Grouped by Event';
}
$options['output']->title($title);
$registeredListeners = $eventDispatcher->getListeners($event);
if (null !== $event) {
$this->renderEventListenerTable($eventDispatcher, $event, $registeredListeners, $options['output']);
} else {
ksort($registeredListeners);
foreach ($registeredListeners as $eventListened => $eventListeners) {
$options['output']->section(sprintf('"%s" event', $eventListened));
$this->renderEventListenerTable($eventDispatcher, $eventListened, $eventListeners, $options['output']);
}
}
} | [
"protected",
"function",
"describeEventDispatcherListeners",
"(",
"EventDispatcherInterface",
"$",
"eventDispatcher",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"event",
"=",
"\\",
"array_key_exists",
"(",
"'event'",
",",
"$",
"options",
")",
"?... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php#L465-L487 | train | Describes registered listeners | [
30522,
5123,
3853,
6235,
18697,
3372,
10521,
4502,
10649,
2121,
9863,
24454,
2015,
1006,
2724,
10521,
4502,
10649,
23282,
3334,
12172,
1002,
2724,
10521,
4502,
10649,
2121,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
2724,
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/Validator/Constraints/IbanValidator.php | IbanValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Iban) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Iban');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
// Remove spaces and convert to uppercase
$canonicalized = str_replace(' ', '', strtoupper($value));
// The IBAN must contain only digits and characters...
if (!ctype_alnum($canonicalized)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
// ...start with a two-letter country code
$countryCode = substr($canonicalized, 0, 2);
if (!ctype_alpha($countryCode)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::INVALID_COUNTRY_CODE_ERROR)
->addViolation();
return;
}
// ...have a format available
if (!\array_key_exists($countryCode, self::$formats)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR)
->addViolation();
return;
}
// ...and have a valid format
if (!preg_match('/^'.self::$formats[$countryCode].'$/', $canonicalized)
) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::INVALID_FORMAT_ERROR)
->addViolation();
return;
}
// Move the first four characters to the end
// e.g. CH93 0076 2011 6238 5295 7
// -> 0076 2011 6238 5295 7 CH93
$canonicalized = substr($canonicalized, 4).substr($canonicalized, 0, 4);
// Convert all remaining letters to their ordinals
// The result is an integer, which is too large for PHP's int
// data type, so we store it in a string instead.
// e.g. 0076 2011 6238 5295 7 CH93
// -> 0076 2011 6238 5295 7 121893
$checkSum = self::toBigInt($canonicalized);
// Do a modulo-97 operation on the large integer
// We cannot use PHP's modulo operator, so we calculate the
// modulo step-wisely instead
if (1 !== self::bigModulo97($checkSum)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::CHECKSUM_FAILED_ERROR)
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Iban) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Iban');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
// Remove spaces and convert to uppercase
$canonicalized = str_replace(' ', '', strtoupper($value));
// The IBAN must contain only digits and characters...
if (!ctype_alnum($canonicalized)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
// ...start with a two-letter country code
$countryCode = substr($canonicalized, 0, 2);
if (!ctype_alpha($countryCode)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::INVALID_COUNTRY_CODE_ERROR)
->addViolation();
return;
}
// ...have a format available
if (!\array_key_exists($countryCode, self::$formats)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR)
->addViolation();
return;
}
// ...and have a valid format
if (!preg_match('/^'.self::$formats[$countryCode].'$/', $canonicalized)
) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::INVALID_FORMAT_ERROR)
->addViolation();
return;
}
// Move the first four characters to the end
// e.g. CH93 0076 2011 6238 5295 7
// -> 0076 2011 6238 5295 7 CH93
$canonicalized = substr($canonicalized, 4).substr($canonicalized, 0, 4);
// Convert all remaining letters to their ordinals
// The result is an integer, which is too large for PHP's int
// data type, so we store it in a string instead.
// e.g. 0076 2011 6238 5295 7 CH93
// -> 0076 2011 6238 5295 7 121893
$checkSum = self::toBigInt($canonicalized);
// Do a modulo-97 operation on the large integer
// We cannot use PHP's modulo operator, so we calculate the
// modulo step-wisely instead
if (1 !== self::bigModulo97($checkSum)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Iban::CHECKSUM_FAILED_ERROR)
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Iban",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/IbanValidator.php#L143-L226 | train | Validates IBAN value | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
21307,
2319,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
1035,
3415,
153... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FrameworkExtension.php | FrameworkExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('web.xml');
$loader->load('services.xml');
$loader->load('fragment_renderer.xml');
$container->registerAliasForArgument('parameter_bag', PsrContainerInterface::class);
if (class_exists(Application::class)) {
$loader->load('console.xml');
if (!class_exists(BaseXliffLintCommand::class)) {
$container->removeDefinition('console.command.xliff_lint');
}
if (!class_exists(BaseYamlLintCommand::class)) {
$container->removeDefinition('console.command.yaml_lint');
}
}
// Load Cache configuration first as it is used by other components
$loader->load('cache.xml');
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->annotationsConfigEnabled = $this->isConfigEnabled($container, $config['annotations']);
$this->translationConfigEnabled = $this->isConfigEnabled($container, $config['translator']);
// A translator must always be registered (as support is included by
// default in the Form and Validator component). If disabled, an identity
// translator will be used and everything will still work as expected.
if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) {
if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) {
throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
}
if (class_exists(Translator::class)) {
$loader->load('identity_translator.xml');
}
}
if (isset($config['secret'])) {
$container->setParameter('kernel.secret', $config['secret']);
}
$container->setParameter('kernel.http_method_override', $config['http_method_override']);
$container->setParameter('kernel.trusted_hosts', $config['trusted_hosts']);
$container->setParameter('kernel.default_locale', $config['default_locale']);
if (!$container->hasParameter('debug.file_link_format')) {
if (!$container->hasParameter('templating.helper.code.file_link_format')) {
$links = [
'textmate' => 'txmt://open?url=file://%%f&line=%%l',
'macvim' => 'mvim://open?url=file://%%f&line=%%l',
'emacs' => 'emacs://open?url=file://%%f&line=%%l',
'sublime' => 'subl://open?url=file://%%f&line=%%l',
'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
'vscode' => 'vscode://file/%%f:%%l',
];
$ide = $config['ide'];
// mark any env vars found in the ide setting as used
$container->resolveEnvPlaceholders($ide);
$container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide));
}
$container->setParameter('debug.file_link_format', '%templating.helper.code.file_link_format%');
}
if (!empty($config['test'])) {
$loader->load('test.xml');
if (!class_exists(AbstractBrowser::class)) {
$container->removeDefinition('test.client');
}
}
if ($this->isConfigEnabled($container, $config['session'])) {
$this->sessionConfigEnabled = true;
$this->registerSessionConfiguration($config['session'], $container, $loader);
if (!empty($config['test'])) {
$container->getDefinition('test.session.listener')->setArgument(1, '%session.storage.options%');
}
}
if ($this->isConfigEnabled($container, $config['request'])) {
$this->registerRequestConfiguration($config['request'], $container, $loader);
}
if (null === $config['csrf_protection']['enabled']) {
$config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class);
}
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
if ($this->isConfigEnabled($container, $config['form'])) {
if (!class_exists('Symfony\Component\Form\Form')) {
throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
}
$this->formConfigEnabled = true;
$this->registerFormConfiguration($config, $container, $loader);
if (class_exists('Symfony\Component\Validator\Validation')) {
$config['validation']['enabled'] = true;
} else {
$container->setParameter('validator.translation_domain', 'validators');
$container->removeDefinition('form.type_extension.form.validator');
$container->removeDefinition('form.type_guesser.validator');
}
} else {
$container->removeDefinition('console.command.form_debug');
}
if ($this->isConfigEnabled($container, $config['assets'])) {
if (!class_exists('Symfony\Component\Asset\Package')) {
throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
}
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['templating'])) {
@trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
if (!class_exists('Symfony\Component\Templating\PhpEngine')) {
throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".');
}
$this->registerTemplatingConfiguration($config['templating'], $container, $loader);
}
if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) {
$this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['serializer'], $config['validation']);
} else {
$container->removeDefinition('console.command.messenger_consume_messages');
$container->removeDefinition('console.command.messenger_debug');
$container->removeDefinition('console.command.messenger_stop_workers');
$container->removeDefinition('console.command.messenger_setup_transports');
$container->removeDefinition('console.command.messenger_failed_messages_retry');
$container->removeDefinition('console.command.messenger_failed_messages_show');
$container->removeDefinition('console.command.messenger_failed_messages_remove');
}
$propertyInfoEnabled = $this->isConfigEnabled($container, $config['property_info']);
$this->registerValidationConfiguration($config['validation'], $container, $loader, $propertyInfoEnabled);
$this->registerEsiConfiguration($config['esi'], $container, $loader);
$this->registerSsiConfiguration($config['ssi'], $container, $loader);
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
$this->registerTranslatorConfiguration($config['translator'], $container, $loader);
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
$this->registerCacheConfiguration($config['cache'], $container);
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
$this->registerDebugConfiguration($config['php_errors'], $container, $loader);
$this->registerRouterConfiguration($config['router'], $container, $loader);
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
if ($this->isConfigEnabled($container, $config['serializer'])) {
if (!class_exists('Symfony\Component\Serializer\Serializer')) {
throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
}
$this->registerSerializerConfiguration($config['serializer'], $container, $loader);
}
if ($propertyInfoEnabled) {
$this->registerPropertyInfoConfiguration($container, $loader);
}
if ($this->isConfigEnabled($container, $config['lock'])) {
$this->registerLockConfiguration($config['lock'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['http_client'])) {
$this->registerHttpClientConfiguration($config['http_client'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['mailer'])) {
$this->registerMailerConfiguration($config['mailer'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['web_link'])) {
if (!class_exists(HttpHeaderSerializer::class)) {
throw new LogicException('WebLink support cannot be enabled as the WebLink component is not installed. Try running "composer require symfony/weblink".');
}
$loader->load('web_link.xml');
}
$this->addAnnotatedClassesToCompile([
'**\\Controller\\',
'**\\Entity\\',
// Added explicitly so that we don't rely on the class map being dumped to make it work
'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController',
]);
if (class_exists(MimeTypes::class)) {
$loader->load('mime_type.xml');
}
$container->registerForAutoconfiguration(Command::class)
->addTag('console.command');
$container->registerForAutoconfiguration(ResourceCheckerInterface::class)
->addTag('config_cache.resource_checker');
$container->registerForAutoconfiguration(EnvVarProcessorInterface::class)
->addTag('container.env_var_processor');
$container->registerForAutoconfiguration(ServiceLocator::class)
->addTag('container.service_locator');
$container->registerForAutoconfiguration(ServiceSubscriberInterface::class)
->addTag('container.service_subscriber');
$container->registerForAutoconfiguration(ArgumentValueResolverInterface::class)
->addTag('controller.argument_value_resolver');
$container->registerForAutoconfiguration(AbstractController::class)
->addTag('controller.service_arguments');
$container->registerForAutoconfiguration('Symfony\Bundle\FrameworkBundle\Controller\Controller')
->addTag('controller.service_arguments');
$container->registerForAutoconfiguration(DataCollectorInterface::class)
->addTag('data_collector');
$container->registerForAutoconfiguration(FormTypeInterface::class)
->addTag('form.type');
$container->registerForAutoconfiguration(FormTypeGuesserInterface::class)
->addTag('form.type_guesser');
$container->registerForAutoconfiguration(FormTypeExtensionInterface::class)
->addTag('form.type_extension');
$container->registerForAutoconfiguration(CacheClearerInterface::class)
->addTag('kernel.cache_clearer');
$container->registerForAutoconfiguration(CacheWarmerInterface::class)
->addTag('kernel.cache_warmer');
$container->registerForAutoconfiguration(EventSubscriberInterface::class)
->addTag('kernel.event_subscriber');
$container->registerForAutoconfiguration(LocaleAwareInterface::class)
->addTag('kernel.locale_aware');
$container->registerForAutoconfiguration(ResetInterface::class)
->addTag('kernel.reset', ['method' => 'reset']);
if (!interface_exists(MarshallerInterface::class)) {
$container->registerForAutoconfiguration(ResettableInterface::class)
->addTag('kernel.reset', ['method' => 'reset']);
}
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
->addTag('property_info.list_extractor');
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
->addTag('property_info.type_extractor');
$container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class)
->addTag('property_info.description_extractor');
$container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class)
->addTag('property_info.access_extractor');
$container->registerForAutoconfiguration(PropertyInitializableExtractorInterface::class)
->addTag('property_info.initializable_extractor');
$container->registerForAutoconfiguration(EncoderInterface::class)
->addTag('serializer.encoder');
$container->registerForAutoconfiguration(DecoderInterface::class)
->addTag('serializer.encoder');
$container->registerForAutoconfiguration(NormalizerInterface::class)
->addTag('serializer.normalizer');
$container->registerForAutoconfiguration(DenormalizerInterface::class)
->addTag('serializer.normalizer');
$container->registerForAutoconfiguration(ConstraintValidatorInterface::class)
->addTag('validator.constraint_validator');
$container->registerForAutoconfiguration(ObjectInitializerInterface::class)
->addTag('validator.initializer');
$container->registerForAutoconfiguration(MessageHandlerInterface::class)
->addTag('messenger.message_handler');
$container->registerForAutoconfiguration(TransportFactoryInterface::class)
->addTag('messenger.transport_factory');
$container->registerForAutoconfiguration(MimeTypeGuesserInterface::class)
->addTag('mime.mime_type_guesser');
$container->registerForAutoconfiguration(LoggerAwareInterface::class)
->addMethodCall('setLogger', [new Reference('logger')]);
if (!$container->getParameter('kernel.debug')) {
// remove tagged iterator argument for resource checkers
$container->getDefinition('config_cache_factory')->setArguments([]);
}
if (!$config['disallow_search_engine_index'] ?? false) {
$container->removeDefinition('disallow_search_engine_index_response_listener');
}
} | php | public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('web.xml');
$loader->load('services.xml');
$loader->load('fragment_renderer.xml');
$container->registerAliasForArgument('parameter_bag', PsrContainerInterface::class);
if (class_exists(Application::class)) {
$loader->load('console.xml');
if (!class_exists(BaseXliffLintCommand::class)) {
$container->removeDefinition('console.command.xliff_lint');
}
if (!class_exists(BaseYamlLintCommand::class)) {
$container->removeDefinition('console.command.yaml_lint');
}
}
// Load Cache configuration first as it is used by other components
$loader->load('cache.xml');
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->annotationsConfigEnabled = $this->isConfigEnabled($container, $config['annotations']);
$this->translationConfigEnabled = $this->isConfigEnabled($container, $config['translator']);
// A translator must always be registered (as support is included by
// default in the Form and Validator component). If disabled, an identity
// translator will be used and everything will still work as expected.
if ($this->isConfigEnabled($container, $config['translator']) || $this->isConfigEnabled($container, $config['form']) || $this->isConfigEnabled($container, $config['validation'])) {
if (!class_exists('Symfony\Component\Translation\Translator') && $this->isConfigEnabled($container, $config['translator'])) {
throw new LogicException('Translation support cannot be enabled as the Translation component is not installed. Try running "composer require symfony/translation".');
}
if (class_exists(Translator::class)) {
$loader->load('identity_translator.xml');
}
}
if (isset($config['secret'])) {
$container->setParameter('kernel.secret', $config['secret']);
}
$container->setParameter('kernel.http_method_override', $config['http_method_override']);
$container->setParameter('kernel.trusted_hosts', $config['trusted_hosts']);
$container->setParameter('kernel.default_locale', $config['default_locale']);
if (!$container->hasParameter('debug.file_link_format')) {
if (!$container->hasParameter('templating.helper.code.file_link_format')) {
$links = [
'textmate' => 'txmt://open?url=file://%%f&line=%%l',
'macvim' => 'mvim://open?url=file://%%f&line=%%l',
'emacs' => 'emacs://open?url=file://%%f&line=%%l',
'sublime' => 'subl://open?url=file://%%f&line=%%l',
'phpstorm' => 'phpstorm://open?file=%%f&line=%%l',
'atom' => 'atom://core/open/file?filename=%%f&line=%%l',
'vscode' => 'vscode://file/%%f:%%l',
];
$ide = $config['ide'];
// mark any env vars found in the ide setting as used
$container->resolveEnvPlaceholders($ide);
$container->setParameter('templating.helper.code.file_link_format', str_replace('%', '%%', ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format')) ?: (isset($links[$ide]) ? $links[$ide] : $ide));
}
$container->setParameter('debug.file_link_format', '%templating.helper.code.file_link_format%');
}
if (!empty($config['test'])) {
$loader->load('test.xml');
if (!class_exists(AbstractBrowser::class)) {
$container->removeDefinition('test.client');
}
}
if ($this->isConfigEnabled($container, $config['session'])) {
$this->sessionConfigEnabled = true;
$this->registerSessionConfiguration($config['session'], $container, $loader);
if (!empty($config['test'])) {
$container->getDefinition('test.session.listener')->setArgument(1, '%session.storage.options%');
}
}
if ($this->isConfigEnabled($container, $config['request'])) {
$this->registerRequestConfiguration($config['request'], $container, $loader);
}
if (null === $config['csrf_protection']['enabled']) {
$config['csrf_protection']['enabled'] = $this->sessionConfigEnabled && !class_exists(FullStack::class) && interface_exists(CsrfTokenManagerInterface::class);
}
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
if ($this->isConfigEnabled($container, $config['form'])) {
if (!class_exists('Symfony\Component\Form\Form')) {
throw new LogicException('Form support cannot be enabled as the Form component is not installed. Try running "composer require symfony/form".');
}
$this->formConfigEnabled = true;
$this->registerFormConfiguration($config, $container, $loader);
if (class_exists('Symfony\Component\Validator\Validation')) {
$config['validation']['enabled'] = true;
} else {
$container->setParameter('validator.translation_domain', 'validators');
$container->removeDefinition('form.type_extension.form.validator');
$container->removeDefinition('form.type_guesser.validator');
}
} else {
$container->removeDefinition('console.command.form_debug');
}
if ($this->isConfigEnabled($container, $config['assets'])) {
if (!class_exists('Symfony\Component\Asset\Package')) {
throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
}
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['templating'])) {
@trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
if (!class_exists('Symfony\Component\Templating\PhpEngine')) {
throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".');
}
$this->registerTemplatingConfiguration($config['templating'], $container, $loader);
}
if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) {
$this->registerMessengerConfiguration($config['messenger'], $container, $loader, $config['serializer'], $config['validation']);
} else {
$container->removeDefinition('console.command.messenger_consume_messages');
$container->removeDefinition('console.command.messenger_debug');
$container->removeDefinition('console.command.messenger_stop_workers');
$container->removeDefinition('console.command.messenger_setup_transports');
$container->removeDefinition('console.command.messenger_failed_messages_retry');
$container->removeDefinition('console.command.messenger_failed_messages_show');
$container->removeDefinition('console.command.messenger_failed_messages_remove');
}
$propertyInfoEnabled = $this->isConfigEnabled($container, $config['property_info']);
$this->registerValidationConfiguration($config['validation'], $container, $loader, $propertyInfoEnabled);
$this->registerEsiConfiguration($config['esi'], $container, $loader);
$this->registerSsiConfiguration($config['ssi'], $container, $loader);
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
$this->registerTranslatorConfiguration($config['translator'], $container, $loader);
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
$this->registerCacheConfiguration($config['cache'], $container);
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
$this->registerDebugConfiguration($config['php_errors'], $container, $loader);
$this->registerRouterConfiguration($config['router'], $container, $loader);
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
if ($this->isConfigEnabled($container, $config['serializer'])) {
if (!class_exists('Symfony\Component\Serializer\Serializer')) {
throw new LogicException('Serializer support cannot be enabled as the Serializer component is not installed. Try running "composer require symfony/serializer-pack".');
}
$this->registerSerializerConfiguration($config['serializer'], $container, $loader);
}
if ($propertyInfoEnabled) {
$this->registerPropertyInfoConfiguration($container, $loader);
}
if ($this->isConfigEnabled($container, $config['lock'])) {
$this->registerLockConfiguration($config['lock'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['http_client'])) {
$this->registerHttpClientConfiguration($config['http_client'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['mailer'])) {
$this->registerMailerConfiguration($config['mailer'], $container, $loader);
}
if ($this->isConfigEnabled($container, $config['web_link'])) {
if (!class_exists(HttpHeaderSerializer::class)) {
throw new LogicException('WebLink support cannot be enabled as the WebLink component is not installed. Try running "composer require symfony/weblink".');
}
$loader->load('web_link.xml');
}
$this->addAnnotatedClassesToCompile([
'**\\Controller\\',
'**\\Entity\\',
// Added explicitly so that we don't rely on the class map being dumped to make it work
'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController',
]);
if (class_exists(MimeTypes::class)) {
$loader->load('mime_type.xml');
}
$container->registerForAutoconfiguration(Command::class)
->addTag('console.command');
$container->registerForAutoconfiguration(ResourceCheckerInterface::class)
->addTag('config_cache.resource_checker');
$container->registerForAutoconfiguration(EnvVarProcessorInterface::class)
->addTag('container.env_var_processor');
$container->registerForAutoconfiguration(ServiceLocator::class)
->addTag('container.service_locator');
$container->registerForAutoconfiguration(ServiceSubscriberInterface::class)
->addTag('container.service_subscriber');
$container->registerForAutoconfiguration(ArgumentValueResolverInterface::class)
->addTag('controller.argument_value_resolver');
$container->registerForAutoconfiguration(AbstractController::class)
->addTag('controller.service_arguments');
$container->registerForAutoconfiguration('Symfony\Bundle\FrameworkBundle\Controller\Controller')
->addTag('controller.service_arguments');
$container->registerForAutoconfiguration(DataCollectorInterface::class)
->addTag('data_collector');
$container->registerForAutoconfiguration(FormTypeInterface::class)
->addTag('form.type');
$container->registerForAutoconfiguration(FormTypeGuesserInterface::class)
->addTag('form.type_guesser');
$container->registerForAutoconfiguration(FormTypeExtensionInterface::class)
->addTag('form.type_extension');
$container->registerForAutoconfiguration(CacheClearerInterface::class)
->addTag('kernel.cache_clearer');
$container->registerForAutoconfiguration(CacheWarmerInterface::class)
->addTag('kernel.cache_warmer');
$container->registerForAutoconfiguration(EventSubscriberInterface::class)
->addTag('kernel.event_subscriber');
$container->registerForAutoconfiguration(LocaleAwareInterface::class)
->addTag('kernel.locale_aware');
$container->registerForAutoconfiguration(ResetInterface::class)
->addTag('kernel.reset', ['method' => 'reset']);
if (!interface_exists(MarshallerInterface::class)) {
$container->registerForAutoconfiguration(ResettableInterface::class)
->addTag('kernel.reset', ['method' => 'reset']);
}
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class)
->addTag('property_info.list_extractor');
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
->addTag('property_info.type_extractor');
$container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class)
->addTag('property_info.description_extractor');
$container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class)
->addTag('property_info.access_extractor');
$container->registerForAutoconfiguration(PropertyInitializableExtractorInterface::class)
->addTag('property_info.initializable_extractor');
$container->registerForAutoconfiguration(EncoderInterface::class)
->addTag('serializer.encoder');
$container->registerForAutoconfiguration(DecoderInterface::class)
->addTag('serializer.encoder');
$container->registerForAutoconfiguration(NormalizerInterface::class)
->addTag('serializer.normalizer');
$container->registerForAutoconfiguration(DenormalizerInterface::class)
->addTag('serializer.normalizer');
$container->registerForAutoconfiguration(ConstraintValidatorInterface::class)
->addTag('validator.constraint_validator');
$container->registerForAutoconfiguration(ObjectInitializerInterface::class)
->addTag('validator.initializer');
$container->registerForAutoconfiguration(MessageHandlerInterface::class)
->addTag('messenger.message_handler');
$container->registerForAutoconfiguration(TransportFactoryInterface::class)
->addTag('messenger.transport_factory');
$container->registerForAutoconfiguration(MimeTypeGuesserInterface::class)
->addTag('mime.mime_type_guesser');
$container->registerForAutoconfiguration(LoggerAwareInterface::class)
->addMethodCall('setLogger', [new Reference('logger')]);
if (!$container->getParameter('kernel.debug')) {
// remove tagged iterator argument for resource checkers
$container->getDefinition('config_cache_factory')->setArguments([]);
}
if (!$config['disallow_search_engine_index'] ?? false) {
$container->removeDefinition('disallow_search_engine_index_response_listener');
}
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"loader",
"=",
"new",
"XmlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"\\",
"dirname",
"(",
"__DIR__",
")",
".",
... | Responds to the app.config configuration parameter.
@throws LogicException | [
"Responds",
"to",
"the",
"app",
".",
"config",
"configuration",
"parameter",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L148-L431 | train | Loads the configuration and registers the alias for arguments and parameters bag. | [
30522,
2270,
3853,
7170,
1006,
9140,
1002,
9530,
8873,
5620,
1010,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
1002,
7170,
2121,
1027,
2047,
20950,
8873,
2571,
11066,
2121,
1006,
1002,
11661,
1010,
2047,
5371,
4135,
11266,
2953,
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/MobileMessaging/API.php | API.getCreditLeft | public function getCreditLeft()
{
$this->checkCredentialManagementRights();
$credential = $this->getSMSAPICredential();
$SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]);
return $SMSProvider->getCreditLeft(
$credential[MobileMessaging::API_KEY_OPTION]
);
} | php | public function getCreditLeft()
{
$this->checkCredentialManagementRights();
$credential = $this->getSMSAPICredential();
$SMSProvider = SMSProvider::factory($credential[MobileMessaging::PROVIDER_OPTION]);
return $SMSProvider->getCreditLeft(
$credential[MobileMessaging::API_KEY_OPTION]
);
} | [
"public",
"function",
"getCreditLeft",
"(",
")",
"{",
"$",
"this",
"->",
"checkCredentialManagementRights",
"(",
")",
";",
"$",
"credential",
"=",
"$",
"this",
"->",
"getSMSAPICredential",
"(",
")",
";",
"$",
"SMSProvider",
"=",
"SMSProvider",
"::",
"factory",... | get remaining credit
@return string remaining credit | [
"get",
"remaining",
"credit"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L181-L190 | train | Get credit left | [
30522,
2270,
3853,
2131,
16748,
23194,
2571,
6199,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
4638,
16748,
16454,
4818,
24805,
20511,
15950,
2015,
1006,
1007,
1025,
1002,
13675,
14728,
19909,
1027,
1002,
2023,
1011,
1028,
4152,
5244,
9331,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreVisualizations/Visualizations/Graph.php | Graph.afterAllFiltersAreApplied | public function afterAllFiltersAreApplied()
{
$this->determineWhichRowsAreSelectable();
// set default selectable columns, if none specified
$selectableColumns = $this->config->selectable_columns;
if (false === $selectableColumns) {
$this->generateSelectableColumns();
}
$this->ensureValidColumnsToDisplay();
$this->addTranslations();
$this->config->selectable_rows = array_values($this->selectableRows);
} | php | public function afterAllFiltersAreApplied()
{
$this->determineWhichRowsAreSelectable();
// set default selectable columns, if none specified
$selectableColumns = $this->config->selectable_columns;
if (false === $selectableColumns) {
$this->generateSelectableColumns();
}
$this->ensureValidColumnsToDisplay();
$this->addTranslations();
$this->config->selectable_rows = array_values($this->selectableRows);
} | [
"public",
"function",
"afterAllFiltersAreApplied",
"(",
")",
"{",
"$",
"this",
"->",
"determineWhichRowsAreSelectable",
"(",
")",
";",
"// set default selectable columns, if none specified",
"$",
"selectableColumns",
"=",
"$",
"this",
"->",
"config",
"->",
"selectable_col... | Defaults the selectable_columns property if it has not been set and then transforms
it into something the SeriesPicker JavaScript class can use. | [
"Defaults",
"the",
"selectable_columns",
"property",
"if",
"it",
"has",
"not",
"been",
"set",
"and",
"then",
"transforms",
"it",
"into",
"something",
"the",
"SeriesPicker",
"JavaScript",
"class",
"can",
"use",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/Visualizations/Graph.php#L116-L132 | train | This method is called after all filters are applied. | [
30522,
2270,
3853,
2044,
8095,
8873,
21928,
10286,
5243,
9397,
8751,
2094,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
5646,
2860,
16066,
8093,
15568,
17933,
12260,
23576,
1006,
1007,
1025,
1013,
1013,
2275,
12398,
7276,
3085,
7753,
1010,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Controller.php | Controller.run | public function run($url = '/')
{
if ($url === null) {
$url = Request::path();
}
if (empty($url)) {
$url = '/';
}
/*
* Hidden page
*/
$page = $this->router->findByUrl($url);
if ($page && $page->is_hidden && !BackendAuth::getUser()) {
$page = null;
}
/*
* Maintenance mode
*/
if (
MaintenanceSetting::isConfigured() &&
MaintenanceSetting::get('is_enabled', false) &&
!BackendAuth::getUser()
) {
if (!Request::ajax()) {
$this->setStatusCode(503);
}
$page = Page::loadCached($this->theme, MaintenanceSetting::get('cms_page'));
}
/**
* @event cms.page.beforeDisplay
* Provides an opportunity to swap the page that gets displayed immediately after loading the page assigned to the URL.
*
* Example usage:
*
* Event::listen('cms.page.beforeDisplay', function ((\Cms\Classes\Controller) $controller, (string) $url, (\Cms\Classes\Page) $page) {
* if ($url === '/tricked-you') {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* }
* });
*
* Or
*
* $CmsController->bindEvent('page.beforeDisplay', function ((string) $url, (\Cms\Classes\Page) $page) {
* if ($url === '/tricked-you') {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* }
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.beforeDisplay', [$url, $page])) {
if ($event instanceof Page) {
$page = $event;
}
else {
return $event;
}
}
/*
* If the page was not found, render the 404 page - either provided by the theme or the built-in one.
*/
if (!$page || $url === '404') {
if (!Request::ajax()) {
$this->setStatusCode(404);
}
// Log the 404 request
if (!App::runningUnitTests()) {
RequestLog::add();
}
if (!$page = $this->router->findByUrl('/404')) {
return Response::make(View::make('cms::404'), $this->statusCode);
}
}
/*
* Run the page
*/
$result = $this->runPage($page);
/*
* Post-processing
*/
$result = $this->postProcessResult($page, $url, $result);
/**
* @event cms.page.display
* Provides an opportunity to modify the response after the page for the URL has been processed. `$result` could be a string representing the HTML to be returned or it could be a Response instance.
*
* Example usage:
*
* Event::listen('cms.page.display', function ((\Cms\Classes\Controller) $controller, (string) $url, (\Cms\Classes\Page) $page, (mixed) $result) {
* if ($url === '/tricked-you') {
* return Response::make('Boo!', 200);
* }
* });
*
* Or
*
* $CmsController->bindEvent('page.display', function ((string) $url, (\Cms\Classes\Page) $page, (mixed) $result) {
* if ($url === '/tricked-you') {
* return Response::make('Boo!', 200);
* }
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.display', [$url, $page, $result])) {
return $event;
}
if (!is_string($result)) {
return $result;
}
return Response::make($result, $this->statusCode);
} | php | public function run($url = '/')
{
if ($url === null) {
$url = Request::path();
}
if (empty($url)) {
$url = '/';
}
/*
* Hidden page
*/
$page = $this->router->findByUrl($url);
if ($page && $page->is_hidden && !BackendAuth::getUser()) {
$page = null;
}
/*
* Maintenance mode
*/
if (
MaintenanceSetting::isConfigured() &&
MaintenanceSetting::get('is_enabled', false) &&
!BackendAuth::getUser()
) {
if (!Request::ajax()) {
$this->setStatusCode(503);
}
$page = Page::loadCached($this->theme, MaintenanceSetting::get('cms_page'));
}
/**
* @event cms.page.beforeDisplay
* Provides an opportunity to swap the page that gets displayed immediately after loading the page assigned to the URL.
*
* Example usage:
*
* Event::listen('cms.page.beforeDisplay', function ((\Cms\Classes\Controller) $controller, (string) $url, (\Cms\Classes\Page) $page) {
* if ($url === '/tricked-you') {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* }
* });
*
* Or
*
* $CmsController->bindEvent('page.beforeDisplay', function ((string) $url, (\Cms\Classes\Page) $page) {
* if ($url === '/tricked-you') {
* return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
* }
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.beforeDisplay', [$url, $page])) {
if ($event instanceof Page) {
$page = $event;
}
else {
return $event;
}
}
/*
* If the page was not found, render the 404 page - either provided by the theme or the built-in one.
*/
if (!$page || $url === '404') {
if (!Request::ajax()) {
$this->setStatusCode(404);
}
// Log the 404 request
if (!App::runningUnitTests()) {
RequestLog::add();
}
if (!$page = $this->router->findByUrl('/404')) {
return Response::make(View::make('cms::404'), $this->statusCode);
}
}
/*
* Run the page
*/
$result = $this->runPage($page);
/*
* Post-processing
*/
$result = $this->postProcessResult($page, $url, $result);
/**
* @event cms.page.display
* Provides an opportunity to modify the response after the page for the URL has been processed. `$result` could be a string representing the HTML to be returned or it could be a Response instance.
*
* Example usage:
*
* Event::listen('cms.page.display', function ((\Cms\Classes\Controller) $controller, (string) $url, (\Cms\Classes\Page) $page, (mixed) $result) {
* if ($url === '/tricked-you') {
* return Response::make('Boo!', 200);
* }
* });
*
* Or
*
* $CmsController->bindEvent('page.display', function ((string) $url, (\Cms\Classes\Page) $page, (mixed) $result) {
* if ($url === '/tricked-you') {
* return Response::make('Boo!', 200);
* }
* });
*
*/
if ($event = $this->fireSystemEvent('cms.page.display', [$url, $page, $result])) {
return $event;
}
if (!is_string($result)) {
return $result;
}
return Response::make($result, $this->statusCode);
} | [
"public",
"function",
"run",
"(",
"$",
"url",
"=",
"'/'",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"null",
")",
"{",
"$",
"url",
"=",
"Request",
"::",
"path",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url"... | Finds and serves the requested page.
If the page cannot be found, returns the page with the URL /404.
If the /404 page doesn't exist, returns the system 404 page.
@param string $url Specifies the requested page URL.
If the parameter is omitted, the current URL used.
@return string Returns the processed page content. | [
"Finds",
"and",
"serves",
"the",
"requested",
"page",
".",
"If",
"the",
"page",
"cannot",
"be",
"found",
"returns",
"the",
"page",
"with",
"the",
"URL",
"/",
"404",
".",
"If",
"the",
"/",
"404",
"page",
"doesn",
"t",
"exist",
"returns",
"the",
"system"... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Controller.php#L140-L261 | train | Runs the action | [
30522,
2270,
3853,
2448,
1006,
1002,
24471,
2140,
1027,
1005,
1013,
1005,
1007,
1063,
2065,
1006,
1002,
24471,
2140,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
24471,
2140,
1027,
5227,
1024,
1024,
4130,
1006,
1007,
1025,
1065,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php | MorphOneOrMany.setForeignAttributesForCreate | protected function setForeignAttributesForCreate(Model $model)
{
$model->{$this->getForeignKeyName()} = $this->getParentKey();
$model->{$this->getMorphType()} = $this->morphClass;
} | php | protected function setForeignAttributesForCreate(Model $model)
{
$model->{$this->getForeignKeyName()} = $this->getParentKey();
$model->{$this->getMorphType()} = $this->morphClass;
} | [
"protected",
"function",
"setForeignAttributesForCreate",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"getForeignKeyName",
"(",
")",
"}",
"=",
"$",
"this",
"->",
"getParentKey",
"(",
")",
";",
"$",
"model",
"->",
"{"... | Set the foreign ID and type for creating a related model.
@param \Illuminate\Database\Eloquent\Model $model
@return void | [
"Set",
"the",
"foreign",
"ID",
"and",
"type",
"for",
"creating",
"a",
"related",
"model",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php#L76-L81 | train | Set foreign attributes for create | [
30522,
5123,
3853,
2275,
29278,
7416,
16989,
4779,
3089,
8569,
4570,
29278,
16748,
3686,
1006,
2944,
1002,
2944,
1007,
1063,
30524,
2131,
5302,
14536,
11039,
18863,
1006,
1007,
1065,
1027,
1002,
2023,
1011,
1028,
22822,
8458,
26266,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/BrowserKit/Client.php | Client.getRequest | public function getRequest()
{
if (null === $this->request) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
return $this->request;
} | php | public function getRequest()
{
if (null === $this->request) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
return $this->request;
} | [
"public",
"function",
"getRequest",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"request",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'Calling the \"%s()\" method before the \"request()\" one is deprecated since Symfony 4.1 and will throw an excep... | Returns the current origin Request instance.
The origin request is the request instance that is sent
to the code that handles requests.
@return object A Request instance
@see doRequest() | [
"Returns",
"the",
"current",
"origin",
"Request",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/Client.php#L271-L279 | train | Get the request object | [
30522,
2270,
3853,
2131,
2890,
15500,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
5227,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
4214,
1996,
1000,
1003,
1055,
1006,
1007,
1000,
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... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.pathPrefixedByLangCode | public static function pathPrefixedByLangCode($string)
{
if (strlen($string) <= 3) {
return false;
}
$languages_enabled = Grav::instance()['config']->get('system.languages.supported', []);
$parts = explode('/', trim($string, '/'));
if (count($parts) > 0 && in_array($parts[0], $languages_enabled)) {
return true;
}
return false;
} | php | public static function pathPrefixedByLangCode($string)
{
if (strlen($string) <= 3) {
return false;
}
$languages_enabled = Grav::instance()['config']->get('system.languages.supported', []);
$parts = explode('/', trim($string, '/'));
if (count($parts) > 0 && in_array($parts[0], $languages_enabled)) {
return true;
}
return false;
} | [
"public",
"static",
"function",
"pathPrefixedByLangCode",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"string",
")",
"<=",
"3",
")",
"{",
"return",
"false",
";",
"}",
"$",
"languages_enabled",
"=",
"Grav",
"::",
"instance",
"(",
")",
"... | Checks if the passed path contains the language code prefix
@param string $string The path
@return bool | [
"Checks",
"if",
"the",
"passed",
"path",
"contains",
"the",
"language",
"code",
"prefix"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L980-L994 | train | Check if a path is in language code format | [
30522,
2270,
10763,
3853,
4130,
28139,
23901,
3762,
25023,
16044,
1006,
1002,
5164,
1007,
1063,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
5164,
1007,
1026,
1027,
1017,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
4155,
1035,
9124,
1027,
24665... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php | NativeSessionStorage.clear | public function clear()
{
// clear out the bags
foreach ($this->bags as $bag) {
$bag->clear();
}
// clear out the session
$_SESSION = [];
// reconnect the bags to the session
$this->loadSession();
} | php | public function clear()
{
// clear out the bags
foreach ($this->bags as $bag) {
$bag->clear();
}
// clear out the session
$_SESSION = [];
// reconnect the bags to the session
$this->loadSession();
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"// clear out the bags",
"foreach",
"(",
"$",
"this",
"->",
"bags",
"as",
"$",
"bag",
")",
"{",
"$",
"bag",
"->",
"clear",
"(",
")",
";",
"}",
"// clear out the session",
"$",
"_SESSION",
"=",
"[",
"]",
";"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L275-L287 | train | Clear out all bags and session | [
30522,
2270,
3853,
3154,
1006,
1007,
1063,
1013,
1013,
3154,
2041,
1996,
8641,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
8641,
2004,
1002,
4524,
1007,
1063,
1002,
4524,
1011,
1028,
3154,
1006,
1007,
1025,
1065,
1013,
1013,
3154,
2041,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Filter/CalculateEvolutionFilter.php | CalculateEvolutionFilter.formatValue | protected function formatValue($value, $divisor)
{
$value = self::getPercentageValue($value, $divisor, $this->quotientPrecision);
$value = self::appendPercentSign($value);
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
return $value;
} | php | protected function formatValue($value, $divisor)
{
$value = self::getPercentageValue($value, $divisor, $this->quotientPrecision);
$value = self::appendPercentSign($value);
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
return $value;
} | [
"protected",
"function",
"formatValue",
"(",
"$",
"value",
",",
"$",
"divisor",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"getPercentageValue",
"(",
"$",
"value",
",",
"$",
"divisor",
",",
"$",
"this",
"->",
"quotientPrecision",
")",
";",
"$",
"value",
... | Calculates and formats a quotient based on a divisor and dividend.
Unlike ColumnCallbackAddColumnPercentage's,
version of this method, this method will return 100% if the past
value of a metric is 0, and the current value is not 0. For a
value representative of an evolution, this makes sense.
@param int|float $value The dividend.
@param int|float $divisor
@return string | [
"Calculates",
"and",
"formats",
"a",
"quotient",
"based",
"on",
"a",
"divisor",
"and",
"dividend",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/CalculateEvolutionFilter.php#L125-L133 | train | Formats a value with percentage sign and quotient precision | [
30522,
5123,
3853,
4289,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
4487,
11365,
2953,
1007,
1063,
1002,
3643,
1027,
2969,
1024,
1024,
2131,
4842,
13013,
4270,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
4487,
11365,
2953,
1010,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php | ObjectNormalizer.setAttributeValue | protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = [])
{
try {
$this->propertyAccessor->setValue($object, $attribute, $value);
} catch (NoSuchPropertyException $exception) {
// Properties not found are ignored
}
} | php | protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = [])
{
try {
$this->propertyAccessor->setValue($object, $attribute, $value);
} catch (NoSuchPropertyException $exception) {
// Properties not found are ignored
}
} | [
"protected",
"function",
"setAttributeValue",
"(",
"$",
"object",
",",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"propertyAccessor",
"->",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L138-L145 | train | Set the value of an attribute in 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,
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/Cache/Adapter/ChainAdapter.php | ChainAdapter.getItem | public function getItem($key)
{
$syncItem = $this->syncItem;
$misses = [];
foreach ($this->adapters as $i => $adapter) {
$item = $adapter->getItem($key);
if ($item->isHit()) {
while (0 <= --$i) {
$this->adapters[$i]->save($syncItem($item, $misses[$i]));
}
return $item;
}
$misses[$i] = $item;
}
return $item;
} | php | public function getItem($key)
{
$syncItem = $this->syncItem;
$misses = [];
foreach ($this->adapters as $i => $adapter) {
$item = $adapter->getItem($key);
if ($item->isHit()) {
while (0 <= --$i) {
$this->adapters[$i]->save($syncItem($item, $misses[$i]));
}
return $item;
}
$misses[$i] = $item;
}
return $item;
} | [
"public",
"function",
"getItem",
"(",
"$",
"key",
")",
"{",
"$",
"syncItem",
"=",
"$",
"this",
"->",
"syncItem",
";",
"$",
"misses",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"adapters",
"as",
"$",
"i",
"=>",
"$",
"adapter",
")",
"{"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/ChainAdapter.php#L118-L138 | train | Get an item from the cache | [
30522,
2270,
3853,
2131,
4221,
2213,
1006,
1002,
3145,
1007,
1063,
1002,
26351,
4221,
2213,
1027,
1002,
2023,
1011,
1028,
26351,
4221,
2213,
1025,
1002,
22182,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
15581,
2545,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ReportRenderer/Pdf.php | Pdf.paintReportHeader | private function paintReportHeader()
{
$isAggregateReport = !empty($this->reportMetadata['dimension']);
// Graph-only report
static $graphOnlyReportCount = 0;
$graphOnlyReport = $isAggregateReport && $this->displayGraph && !$this->displayTable;
// Table-only report
$tableOnlyReport = $isAggregateReport
&& !$this->displayGraph
&& $this->displayTable;
$columnCount = count($this->reportColumns);
// Table-only 2-column report
static $tableOnly2ColumnReportCount = 0;
$tableOnly2ColumnReport = $tableOnlyReport
&& $columnCount == 2;
// Table-only report with more than 2 columns
static $tableOnlyManyColumnReportRowCount = 0;
$tableOnlyManyColumnReport = $tableOnlyReport
&& $columnCount > 3;
$reportHasData = $this->reportHasData();
$rowCount = $reportHasData ? $this->report->getRowsCount() + self::TABLE_HEADER_ROW_COUNT : self::NO_DATA_ROW_COUNT;
// Only a page break before if the current report has some data
if ($reportHasData &&
// and
(
// it is the first report
$this->currentPage == 0
// or, it is a graph-only report and it is the first of a series of self::MAX_GRAPH_REPORTS
|| ($graphOnlyReport && $graphOnlyReportCount == 0)
// or, it is a table-only 2-column report and it is the first of a series of self::MAX_2COL_TABLE_REPORTS
|| ($tableOnly2ColumnReport && $tableOnly2ColumnReportCount == 0)
// or it is a table-only report with more than 2 columns and it is the first of its series or there isn't enough space left on the page
|| ($tableOnlyManyColumnReport && ($tableOnlyManyColumnReportRowCount == 0 || $tableOnlyManyColumnReportRowCount + $rowCount >= self::MAX_ROW_COUNT))
// or it is a report with both a table and a graph
|| !$graphOnlyReport && !$tableOnlyReport
)
) {
$this->currentPage++;
$this->TCPDF->AddPage();
// Table-only reports with more than 2 columns are always landscape
if ($tableOnlyManyColumnReport) {
$tableOnlyManyColumnReportRowCount = 0;
$this->orientation = self::LANDSCAPE;
} else {
// Graph-only reports are always portrait
$this->orientation = $graphOnlyReport ? self::PORTRAIT : ($columnCount > $this->maxColumnCountPortraitOrientation ? self::LANDSCAPE : self::PORTRAIT);
}
$this->TCPDF->setPageOrientation($this->orientation, '', $this->bottomMargin);
}
$graphOnlyReportCount = ($graphOnlyReport && $reportHasData) ? ($graphOnlyReportCount + 1) % self::MAX_GRAPH_REPORTS : 0;
$tableOnly2ColumnReportCount = ($tableOnly2ColumnReport && $reportHasData) ? ($tableOnly2ColumnReportCount + 1) % self::MAX_2COL_TABLE_REPORTS : 0;
$tableOnlyManyColumnReportRowCount = $tableOnlyManyColumnReport ? ($tableOnlyManyColumnReportRowCount + $rowCount) : 0;
$title = $this->formatText($this->reportMetadata['name']);
$this->TCPDF->SetFont($this->reportFont, $this->reportFontStyle, $this->reportHeaderFontSize);
$this->TCPDF->SetTextColor($this->headerTextColor[0], $this->headerTextColor[1], $this->headerTextColor[2]);
$this->TCPDF->Bookmark($title);
$this->TCPDF->Cell(40, 15, $title);
$this->TCPDF->Ln();
$this->TCPDF->SetFont($this->reportFont, '', $this->reportSimpleFontSize);
$this->TCPDF->SetTextColor($this->reportTextColor[0], $this->reportTextColor[1], $this->reportTextColor[2]);
} | php | private function paintReportHeader()
{
$isAggregateReport = !empty($this->reportMetadata['dimension']);
// Graph-only report
static $graphOnlyReportCount = 0;
$graphOnlyReport = $isAggregateReport && $this->displayGraph && !$this->displayTable;
// Table-only report
$tableOnlyReport = $isAggregateReport
&& !$this->displayGraph
&& $this->displayTable;
$columnCount = count($this->reportColumns);
// Table-only 2-column report
static $tableOnly2ColumnReportCount = 0;
$tableOnly2ColumnReport = $tableOnlyReport
&& $columnCount == 2;
// Table-only report with more than 2 columns
static $tableOnlyManyColumnReportRowCount = 0;
$tableOnlyManyColumnReport = $tableOnlyReport
&& $columnCount > 3;
$reportHasData = $this->reportHasData();
$rowCount = $reportHasData ? $this->report->getRowsCount() + self::TABLE_HEADER_ROW_COUNT : self::NO_DATA_ROW_COUNT;
// Only a page break before if the current report has some data
if ($reportHasData &&
// and
(
// it is the first report
$this->currentPage == 0
// or, it is a graph-only report and it is the first of a series of self::MAX_GRAPH_REPORTS
|| ($graphOnlyReport && $graphOnlyReportCount == 0)
// or, it is a table-only 2-column report and it is the first of a series of self::MAX_2COL_TABLE_REPORTS
|| ($tableOnly2ColumnReport && $tableOnly2ColumnReportCount == 0)
// or it is a table-only report with more than 2 columns and it is the first of its series or there isn't enough space left on the page
|| ($tableOnlyManyColumnReport && ($tableOnlyManyColumnReportRowCount == 0 || $tableOnlyManyColumnReportRowCount + $rowCount >= self::MAX_ROW_COUNT))
// or it is a report with both a table and a graph
|| !$graphOnlyReport && !$tableOnlyReport
)
) {
$this->currentPage++;
$this->TCPDF->AddPage();
// Table-only reports with more than 2 columns are always landscape
if ($tableOnlyManyColumnReport) {
$tableOnlyManyColumnReportRowCount = 0;
$this->orientation = self::LANDSCAPE;
} else {
// Graph-only reports are always portrait
$this->orientation = $graphOnlyReport ? self::PORTRAIT : ($columnCount > $this->maxColumnCountPortraitOrientation ? self::LANDSCAPE : self::PORTRAIT);
}
$this->TCPDF->setPageOrientation($this->orientation, '', $this->bottomMargin);
}
$graphOnlyReportCount = ($graphOnlyReport && $reportHasData) ? ($graphOnlyReportCount + 1) % self::MAX_GRAPH_REPORTS : 0;
$tableOnly2ColumnReportCount = ($tableOnly2ColumnReport && $reportHasData) ? ($tableOnly2ColumnReportCount + 1) % self::MAX_2COL_TABLE_REPORTS : 0;
$tableOnlyManyColumnReportRowCount = $tableOnlyManyColumnReport ? ($tableOnlyManyColumnReportRowCount + $rowCount) : 0;
$title = $this->formatText($this->reportMetadata['name']);
$this->TCPDF->SetFont($this->reportFont, $this->reportFontStyle, $this->reportHeaderFontSize);
$this->TCPDF->SetTextColor($this->headerTextColor[0], $this->headerTextColor[1], $this->headerTextColor[2]);
$this->TCPDF->Bookmark($title);
$this->TCPDF->Cell(40, 15, $title);
$this->TCPDF->Ln();
$this->TCPDF->SetFont($this->reportFont, '', $this->reportSimpleFontSize);
$this->TCPDF->SetTextColor($this->reportTextColor[0], $this->reportTextColor[1], $this->reportTextColor[2]);
} | [
"private",
"function",
"paintReportHeader",
"(",
")",
"{",
"$",
"isAggregateReport",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"reportMetadata",
"[",
"'dimension'",
"]",
")",
";",
"// Graph-only report",
"static",
"$",
"graphOnlyReportCount",
"=",
"0",
";",
"... | Generate a header of page. | [
"Generate",
"a",
"header",
"of",
"page",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ReportRenderer/Pdf.php#L220-L292 | train | paints the report header | [
30522,
2797,
3853,
6773,
2890,
6442,
4974,
2121,
1006,
1007,
1063,
1002,
18061,
13871,
2890,
5867,
2890,
6442,
1027,
999,
4064,
1006,
1002,
2023,
1011,
1028,
3189,
11368,
8447,
2696,
1031,
1005,
9812,
1005,
1033,
1007,
1025,
1013,
1013,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/LanguagesManager/API.php | API.getLanguageForUser | public function getLanguageForUser($login)
{
if ($login == 'anonymous') {
return false;
}
Piwik::checkUserHasSuperUserAccessOrIsTheUser($login);
$lang = $this->getModel()->getLanguageForUser($login);
return $lang;
} | php | public function getLanguageForUser($login)
{
if ($login == 'anonymous') {
return false;
}
Piwik::checkUserHasSuperUserAccessOrIsTheUser($login);
$lang = $this->getModel()->getLanguageForUser($login);
return $lang;
} | [
"public",
"function",
"getLanguageForUser",
"(",
"$",
"login",
")",
"{",
"if",
"(",
"$",
"login",
"==",
"'anonymous'",
")",
"{",
"return",
"false",
";",
"}",
"Piwik",
"::",
"checkUserHasSuperUserAccessOrIsTheUser",
"(",
"$",
"login",
")",
";",
"$",
"lang",
... | Returns the language for the user
@param string $login
@return string | [
"Returns",
"the",
"language",
"for",
"the",
"user"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/API.php#L273-L284 | train | Returns the language for the given user | [
30522,
2270,
3853,
2131,
25023,
6692,
3351,
29278,
20330,
1006,
1002,
8833,
2378,
1007,
1063,
2065,
1006,
1002,
8833,
2378,
1027,
1027,
1005,
10812,
1005,
1007,
1063,
2709,
6270,
1025,
1065,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Config/ConfigFileFinder.php | ConfigFileFinder.locateFileInFolder | public function locateFileInFolder($filename, array $folders)
{
$list = [];
foreach ($folders as $folder) {
$list += $this->detectInFolder($folder, $filename);
}
return $list;
} | php | public function locateFileInFolder($filename, array $folders)
{
$list = [];
foreach ($folders as $folder) {
$list += $this->detectInFolder($folder, $filename);
}
return $list;
} | [
"public",
"function",
"locateFileInFolder",
"(",
"$",
"filename",
",",
"array",
"$",
"folders",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"$",
"list",
"+=",
"$",
"this",
"->",
"detectInF... | Find filename from a list of folders.
Note: Only finds the last override.
@param string $filename
@param array $folders
@return array | [
"Find",
"filename",
"from",
"a",
"list",
"of",
"folders",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Config/ConfigFileFinder.php#L93-L100 | train | Locates a file in a list of folders | [
30522,
2270,
3853,
12453,
8873,
19856,
10371,
2121,
1006,
1002,
5371,
18442,
1010,
9140,
1002,
19622,
2015,
1007,
1063,
1002,
2862,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
19622,
2015,
2004,
1002,
19622,
1007,
1063,
1002,
2862,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Constraints/Collection.php | Collection.initializeNestedConstraints | protected function initializeNestedConstraints()
{
parent::initializeNestedConstraints();
if (!\is_array($this->fields)) {
throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint %s', __CLASS__));
}
foreach ($this->fields as $fieldName => $field) {
// the XmlFileLoader and YamlFileLoader pass the field Optional
// and Required constraint as an array with exactly one element
if (\is_array($field) && 1 == \count($field)) {
$this->fields[$fieldName] = $field = $field[0];
}
if (!$field instanceof Optional && !$field instanceof Required) {
$this->fields[$fieldName] = new Required($field);
}
}
} | php | protected function initializeNestedConstraints()
{
parent::initializeNestedConstraints();
if (!\is_array($this->fields)) {
throw new ConstraintDefinitionException(sprintf('The option "fields" is expected to be an array in constraint %s', __CLASS__));
}
foreach ($this->fields as $fieldName => $field) {
// the XmlFileLoader and YamlFileLoader pass the field Optional
// and Required constraint as an array with exactly one element
if (\is_array($field) && 1 == \count($field)) {
$this->fields[$fieldName] = $field = $field[0];
}
if (!$field instanceof Optional && !$field instanceof Required) {
$this->fields[$fieldName] = new Required($field);
}
}
} | [
"protected",
"function",
"initializeNestedConstraints",
"(",
")",
"{",
"parent",
"::",
"initializeNestedConstraints",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"fields",
")",
")",
"{",
"throw",
"new",
"ConstraintDefinitionException... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/Collection.php#L55-L74 | train | Initializes nested constraints | [
30522,
5123,
3853,
3988,
4697,
5267,
3064,
8663,
20528,
18447,
2015,
1006,
1007,
1063,
6687,
1024,
1024,
3988,
4697,
5267,
3064,
8663,
20528,
18447,
2015,
1006,
1007,
1025,
2065,
1006,
999,
1032,
2003,
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/Tracker/VisitExcluded.php | VisitExcluded.isNonHumanBot | protected function isNonHumanBot()
{
$allowBots = $this->request->getParam('bots');
$deviceDetector = DeviceDetectorFactory::getInstance($this->userAgent);
return !$allowBots
&& ($deviceDetector->isBot() || $this->isIpInRange());
} | php | protected function isNonHumanBot()
{
$allowBots = $this->request->getParam('bots');
$deviceDetector = DeviceDetectorFactory::getInstance($this->userAgent);
return !$allowBots
&& ($deviceDetector->isBot() || $this->isIpInRange());
} | [
"protected",
"function",
"isNonHumanBot",
"(",
")",
"{",
"$",
"allowBots",
"=",
"$",
"this",
"->",
"request",
"->",
"getParam",
"(",
"'bots'",
")",
";",
"$",
"deviceDetector",
"=",
"DeviceDetectorFactory",
"::",
"getInstance",
"(",
"$",
"this",
"->",
"userAg... | Live/Bing/MSN bot and Googlebot are evolving to detect cloaked websites.
As a result, these sophisticated bots exhibit characteristics of
browsers (cookies enabled, executing JavaScript, etc).
@see \DeviceDetector\Parser\Bot
@return boolean | [
"Live",
"/",
"Bing",
"/",
"MSN",
"bot",
"and",
"Googlebot",
"are",
"evolving",
"to",
"detect",
"cloaked",
"websites",
".",
"As",
"a",
"result",
"these",
"sophisticated",
"bots",
"exhibit",
"characteristics",
"of",
"browsers",
"(",
"cookies",
"enabled",
"execut... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/VisitExcluded.php#L174-L182 | train | Check if the user is not a human bot | [
30522,
5123,
3853,
3475,
2239,
28600,
2319,
18384,
1006,
1007,
1063,
1002,
3499,
27014,
1027,
1002,
2023,
1011,
1028,
5227,
1011,
1028,
2131,
28689,
2213,
1006,
1005,
28516,
2015,
1005,
1007,
1025,
1002,
5080,
3207,
26557,
4263,
1027,
5080,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Constraints/LuhnValidator.php | LuhnValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Luhn) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Luhn');
}
if (null === $value || '' === $value) {
return;
}
// Work with strings only, because long numbers are represented as floats
// internally and don't work with strlen()
if (!\is_string($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
if (!ctype_digit($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Luhn::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
$checkSum = 0;
$length = \strlen($value);
// Starting with the last digit and walking left, add every second
// digit to the check sum
// e.g. 7 9 9 2 7 3 9 8 7 1 3
// ^ ^ ^ ^ ^ ^
// = 7 + 9 + 7 + 9 + 7 + 3
for ($i = $length - 1; $i >= 0; $i -= 2) {
$checkSum += $value[$i];
}
// Starting with the second last digit and walking left, double every
// second digit and add it to the check sum
// For doubles greater than 9, sum the individual digits
// e.g. 7 9 9 2 7 3 9 8 7 1 3
// ^ ^ ^ ^ ^
// = 1+8 + 4 + 6 + 1+6 + 2
for ($i = $length - 2; $i >= 0; $i -= 2) {
$checkSum += array_sum(str_split($value[$i] * 2));
}
if (0 === $checkSum || 0 !== $checkSum % 10) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Luhn::CHECKSUM_FAILED_ERROR)
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Luhn) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Luhn');
}
if (null === $value || '' === $value) {
return;
}
// Work with strings only, because long numbers are represented as floats
// internally and don't work with strlen()
if (!\is_string($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
if (!ctype_digit($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Luhn::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
$checkSum = 0;
$length = \strlen($value);
// Starting with the last digit and walking left, add every second
// digit to the check sum
// e.g. 7 9 9 2 7 3 9 8 7 1 3
// ^ ^ ^ ^ ^ ^
// = 7 + 9 + 7 + 9 + 7 + 3
for ($i = $length - 1; $i >= 0; $i -= 2) {
$checkSum += $value[$i];
}
// Starting with the second last digit and walking left, double every
// second digit and add it to the check sum
// For doubles greater than 9, sum the individual digits
// e.g. 7 9 9 2 7 3 9 8 7 1 3
// ^ ^ ^ ^ ^
// = 1+8 + 4 + 6 + 1+6 + 2
for ($i = $length - 2; $i >= 0; $i -= 2) {
$checkSum += array_sum(str_split($value[$i] * 2));
}
if (0 === $checkSum || 0 !== $checkSum % 10) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Luhn::CHECKSUM_FAILED_ERROR)
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Luhn",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",
"... | Validates a credit card number with the Luhn algorithm.
@param mixed $value
@param Constraint $constraint
@throws UnexpectedTypeException when the given credit card number is no string | [
"Validates",
"a",
"credit",
"card",
"number",
"with",
"the",
"Luhn",
"algorithm",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/LuhnValidator.php#L41-L96 | train | Validate the value of the constraint | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
11320,
7295,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
1035,
3415,
153... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/MediaLibrary.php | MediaLibrary.makeFolder | public function makeFolder($path)
{
$path = self::validatePath($path);
$fullPath = $this->getMediaPath($path);
return $this->getStorageDisk()->makeDirectory($fullPath);
} | php | public function makeFolder($path)
{
$path = self::validatePath($path);
$fullPath = $this->getMediaPath($path);
return $this->getStorageDisk()->makeDirectory($fullPath);
} | [
"public",
"function",
"makeFolder",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"validatePath",
"(",
"$",
"path",
")",
";",
"$",
"fullPath",
"=",
"$",
"this",
"->",
"getMediaPath",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
... | Creates a folder.
@param string $path Specifies the folder path.
@return boolean | [
"Creates",
"a",
"folder",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L435-L441 | train | Create a folder in the current folder | [
30522,
2270,
3853,
2191,
10371,
2121,
1006,
1002,
4130,
1007,
1063,
1002,
4130,
1027,
2969,
1024,
1024,
9398,
3686,
15069,
1006,
1002,
4130,
1007,
1025,
1002,
2440,
15069,
1027,
1002,
2023,
1011,
1028,
2131,
16969,
15069,
1006,
1002,
4130,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Traits/ModelTree.php | ModelTree.buildSelectOptions | protected function buildSelectOptions(array $nodes = [], $parentId = 0, $prefix = '')
{
$prefix = $prefix ?: str_repeat(' ', 6);
$options = [];
if (empty($nodes)) {
$nodes = $this->allNodes();
}
foreach ($nodes as $node) {
$node[$this->titleColumn] = $prefix.' '.$node[$this->titleColumn];
if ($node[$this->parentColumn] == $parentId) {
$children = $this->buildSelectOptions($nodes, $node[$this->getKeyName()], $prefix.$prefix);
$options[$node[$this->getKeyName()]] = $node[$this->titleColumn];
if ($children) {
$options += $children;
}
}
}
return $options;
} | php | protected function buildSelectOptions(array $nodes = [], $parentId = 0, $prefix = '')
{
$prefix = $prefix ?: str_repeat(' ', 6);
$options = [];
if (empty($nodes)) {
$nodes = $this->allNodes();
}
foreach ($nodes as $node) {
$node[$this->titleColumn] = $prefix.' '.$node[$this->titleColumn];
if ($node[$this->parentColumn] == $parentId) {
$children = $this->buildSelectOptions($nodes, $node[$this->getKeyName()], $prefix.$prefix);
$options[$node[$this->getKeyName()]] = $node[$this->titleColumn];
if ($children) {
$options += $children;
}
}
}
return $options;
} | [
"protected",
"function",
"buildSelectOptions",
"(",
"array",
"$",
"nodes",
"=",
"[",
"]",
",",
"$",
"parentId",
"=",
"0",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"$",
"prefix",
"=",
"$",
"prefix",
"?",
":",
"str_repeat",
"(",
"' '",
",",
"6",
... | Build options of select field in form.
@param array $nodes
@param int $parentId
@param string $prefix
@return array | [
"Build",
"options",
"of",
"select",
"field",
"in",
"form",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Traits/ModelTree.php#L254-L278 | train | Build select options | [
30522,
5123,
3853,
16473,
12260,
6593,
7361,
9285,
1006,
9140,
1002,
14164,
1027,
1031,
1033,
1010,
1002,
6687,
3593,
1027,
1014,
1010,
1002,
17576,
1027,
1005,
1005,
1007,
1063,
1002,
17576,
1027,
1002,
17576,
1029,
1024,
2358,
2099,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php | PdoSessionHandler.updateTimestamp | public function updateTimestamp($sessionId, $data)
{
$maxlifetime = (int) ini_get('session.gc_maxlifetime');
try {
$updateStmt = $this->pdo->prepare(
"UPDATE $this->table SET $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"
);
$updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
$updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
$updateStmt->execute();
} catch (\PDOException $e) {
$this->rollback();
throw $e;
}
return true;
} | php | public function updateTimestamp($sessionId, $data)
{
$maxlifetime = (int) ini_get('session.gc_maxlifetime');
try {
$updateStmt = $this->pdo->prepare(
"UPDATE $this->table SET $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id"
);
$updateStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
$updateStmt->bindParam(':lifetime', $maxlifetime, \PDO::PARAM_INT);
$updateStmt->bindValue(':time', time(), \PDO::PARAM_INT);
$updateStmt->execute();
} catch (\PDOException $e) {
$this->rollback();
throw $e;
}
return true;
} | [
"public",
"function",
"updateTimestamp",
"(",
"$",
"sessionId",
",",
"$",
"data",
")",
"{",
"$",
"maxlifetime",
"=",
"(",
"int",
")",
"ini_get",
"(",
"'session.gc_maxlifetime'",
")",
";",
"try",
"{",
"$",
"updateStmt",
"=",
"$",
"this",
"->",
"pdo",
"->"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L370-L389 | train | Update timestamp of session | [
30522,
2270,
3853,
10651,
7292,
9153,
8737,
1006,
1002,
5219,
3593,
1010,
1002,
2951,
1007,
1063,
1002,
4098,
15509,
7292,
1027,
1006,
20014,
1007,
1999,
2072,
1035,
2131,
1006,
1005,
5219,
1012,
1043,
2278,
1035,
4098,
15509,
7292,
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/Mail/Transport/MailgunTransport.php | MailgunTransport.getTo | protected function getTo(Swift_Mime_SimpleMessage $message)
{
return collect($this->allContacts($message))->map(function ($display, $address) {
return $display ? $display." <{$address}>" : $address;
})->values()->implode(',');
} | php | protected function getTo(Swift_Mime_SimpleMessage $message)
{
return collect($this->allContacts($message))->map(function ($display, $address) {
return $display ? $display." <{$address}>" : $address;
})->values()->implode(',');
} | [
"protected",
"function",
"getTo",
"(",
"Swift_Mime_SimpleMessage",
"$",
"message",
")",
"{",
"return",
"collect",
"(",
"$",
"this",
"->",
"allContacts",
"(",
"$",
"message",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"display",
",",
"$",
"address",
... | Get the "to" payload field for the API request.
@param \Swift_Mime_SimpleMessage $message
@return string | [
"Get",
"the",
"to",
"payload",
"field",
"for",
"the",
"API",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Transport/MailgunTransport.php#L112-L117 | train | Get To address of message | [
30522,
5123,
3853,
2131,
3406,
1006,
9170,
1035,
2771,
4168,
1035,
3722,
7834,
3736,
3351,
1002,
4471,
1007,
1063,
2709,
8145,
1006,
1002,
2023,
1011,
1028,
2035,
8663,
2696,
16649,
1006,
1002,
4471,
1007,
1007,
1011,
1028,
4949,
1006,
38... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/VarDumper/Cloner/Data.php | Data.dump | public function dump(DumperInterface $dumper)
{
$refs = [0];
$this->dumpItem($dumper, new Cursor(), $refs, $this->data[$this->position][$this->key]);
} | php | public function dump(DumperInterface $dumper)
{
$refs = [0];
$this->dumpItem($dumper, new Cursor(), $refs, $this->data[$this->position][$this->key]);
} | [
"public",
"function",
"dump",
"(",
"DumperInterface",
"$",
"dumper",
")",
"{",
"$",
"refs",
"=",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"dumpItem",
"(",
"$",
"dumper",
",",
"new",
"Cursor",
"(",
")",
",",
"$",
"refs",
",",
"$",
"this",
"->",
"dat... | Dumps data with a DumperInterface dumper. | [
"Dumps",
"data",
"with",
"a",
"DumperInterface",
"dumper",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Cloner/Data.php#L262-L266 | train | Dump the current item to the given DumperInterface | [
30522,
2270,
3853,
15653,
1006,
15653,
23282,
3334,
12172,
1002,
15653,
2121,
1007,
1063,
1002,
25416,
2015,
1027,
1031,
1014,
1033,
1025,
1002,
2023,
1011,
1028,
15653,
4221,
2213,
1006,
1002,
15653,
2121,
1010,
2047,
12731,
25301,
2099,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.getHomeRoute | public static function getHomeRoute()
{
if (empty(self::$home_route)) {
$grav = Grav::instance();
/** @var Config $config */
$config = $grav['config'];
/** @var Language $language */
$language = $grav['language'];
$home = $config->get('system.home.alias');
if ($language->enabled()) {
$home_aliases = $config->get('system.home.aliases');
if ($home_aliases) {
$active = $language->getActive();
$default = $language->getDefault();
try {
if ($active) {
$home = $home_aliases[$active];
} else {
$home = $home_aliases[$default];
}
} catch (ErrorException $e) {
$home = $home_aliases[$default];
}
}
}
self::$home_route = trim($home, '/');
}
return self::$home_route;
} | php | public static function getHomeRoute()
{
if (empty(self::$home_route)) {
$grav = Grav::instance();
/** @var Config $config */
$config = $grav['config'];
/** @var Language $language */
$language = $grav['language'];
$home = $config->get('system.home.alias');
if ($language->enabled()) {
$home_aliases = $config->get('system.home.aliases');
if ($home_aliases) {
$active = $language->getActive();
$default = $language->getDefault();
try {
if ($active) {
$home = $home_aliases[$active];
} else {
$home = $home_aliases[$default];
}
} catch (ErrorException $e) {
$home = $home_aliases[$default];
}
}
}
self::$home_route = trim($home, '/');
}
return self::$home_route;
} | [
"public",
"static",
"function",
"getHomeRoute",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"home_route",
")",
")",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"/** @var Config $config */",
"$",
"config",
"=",
"$",
"g... | Gets the home route
@return string | [
"Gets",
"the",
"home",
"route"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L888-L924 | train | Get home route | [
30522,
2270,
10763,
3853,
2131,
23393,
10624,
10421,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
2969,
1024,
1024,
1002,
2188,
1035,
2799,
1007,
1007,
1063,
1002,
24665,
11431,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1025,
1013,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/TokenGuard.php | TokenGuard.validate | public function validate(array $credentials = [])
{
if (empty($credentials[$this->inputKey])) {
return false;
}
$credentials = [$this->storageKey => $credentials[$this->inputKey]];
if ($this->provider->retrieveByCredentials($credentials)) {
return true;
}
return false;
} | php | public function validate(array $credentials = [])
{
if (empty($credentials[$this->inputKey])) {
return false;
}
$credentials = [$this->storageKey => $credentials[$this->inputKey]];
if ($this->provider->retrieveByCredentials($credentials)) {
return true;
}
return false;
} | [
"public",
"function",
"validate",
"(",
"array",
"$",
"credentials",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"credentials",
"[",
"$",
"this",
"->",
"inputKey",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"credentials",
"=",
... | Validate a user's credentials.
@param array $credentials
@return bool | [
"Validate",
"a",
"user",
"s",
"credentials",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/TokenGuard.php#L122-L135 | train | Validate if the user is logged in | [
30522,
2270,
3853,
9398,
3686,
1006,
9140,
1002,
22496,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
22496,
1031,
1002,
2023,
1011,
1028,
7953,
14839,
1033,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
22496,
1027,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/TableStyle.php | TableStyle.setHorizontalBorderChar | public function setHorizontalBorderChar($horizontalBorderChar)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED);
return $this->setHorizontalBorderChars($horizontalBorderChar, $horizontalBorderChar);
} | php | public function setHorizontalBorderChar($horizontalBorderChar)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.', __METHOD__), E_USER_DEPRECATED);
return $this->setHorizontalBorderChars($horizontalBorderChar, $horizontalBorderChar);
} | [
"public",
"function",
"setHorizontalBorderChar",
"(",
"$",
"horizontalBorderChar",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'The \"%s()\" method is deprecated since Symfony 4.1, use setHorizontalBorderChars() instead.'",
",",
"__METHOD__",
")",
",",
"E_USER_DEPRECATE... | Sets horizontal border character.
@param string $horizontalBorderChar
@return $this
@deprecated since Symfony 4.1, use {@link setHorizontalBorderChars()} instead. | [
"Sets",
"horizontal",
"border",
"character",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/TableStyle.php#L113-L118 | train | Sets horizontal border character for all page elements | [
30522,
2270,
3853,
6662,
10050,
11597,
9080,
12821,
4063,
7507,
2099,
1006,
1002,
9876,
12821,
4063,
7507,
2099,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
1996,
1000,
1003,
1055,
1006,
1007,
1000,
4118,
2003,
2139,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/GeoIPAutoUpdater.php | GeoIPAutoUpdater.performRedundantDbChecks | protected function performRedundantDbChecks($logErrors = true)
{
$databaseTypes = array_keys(GeoIp::$dbNames);
foreach ($databaseTypes as $type) {
$customNames = array(
'loc' => array(),
'isp' => array(),
'org' => array()
);
$customNames[$type] = GeoIp::$dbNames[$type];
// create provider that only uses the DB type we're testing
$provider = new Php($customNames);
// test the provider. on error, we rename the broken DB.
self::getTestLocationCatchPhpErrors($provider);
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
if ($logErrors) {
StaticContainer::get(LoggerInterface::class)->error("GeoIPAutoUpdater: Encountered PHP error when performing redundant tests on GeoIP "
. "{type} database: {errno}: {errstr} on line {errline} of {errfile}.", [
'ignoreInScreenWriter' => true,
'type' => $type,
'errno' => $errno,
'errstr' => $errstr,
'errline' => $errline,
'errfile' => $errfile,
]);
}
// get the current filename for the DB and an available new one to rename it to
list($oldPath, $newPath) = $this->getOldAndNewPathsForBrokenDb($customNames[$type]);
// rename the DB so tracking will not fail
if ($oldPath !== false
&& $newPath !== false
) {
if (file_exists($newPath)) {
unlink($newPath);
}
rename($oldPath, $newPath);
}
}
}
} | php | protected function performRedundantDbChecks($logErrors = true)
{
$databaseTypes = array_keys(GeoIp::$dbNames);
foreach ($databaseTypes as $type) {
$customNames = array(
'loc' => array(),
'isp' => array(),
'org' => array()
);
$customNames[$type] = GeoIp::$dbNames[$type];
// create provider that only uses the DB type we're testing
$provider = new Php($customNames);
// test the provider. on error, we rename the broken DB.
self::getTestLocationCatchPhpErrors($provider);
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
if ($logErrors) {
StaticContainer::get(LoggerInterface::class)->error("GeoIPAutoUpdater: Encountered PHP error when performing redundant tests on GeoIP "
. "{type} database: {errno}: {errstr} on line {errline} of {errfile}.", [
'ignoreInScreenWriter' => true,
'type' => $type,
'errno' => $errno,
'errstr' => $errstr,
'errline' => $errline,
'errfile' => $errfile,
]);
}
// get the current filename for the DB and an available new one to rename it to
list($oldPath, $newPath) = $this->getOldAndNewPathsForBrokenDb($customNames[$type]);
// rename the DB so tracking will not fail
if ($oldPath !== false
&& $newPath !== false
) {
if (file_exists($newPath)) {
unlink($newPath);
}
rename($oldPath, $newPath);
}
}
}
} | [
"protected",
"function",
"performRedundantDbChecks",
"(",
"$",
"logErrors",
"=",
"true",
")",
"{",
"$",
"databaseTypes",
"=",
"array_keys",
"(",
"GeoIp",
"::",
"$",
"dbNames",
")",
";",
"foreach",
"(",
"$",
"databaseTypes",
"as",
"$",
"type",
")",
"{",
"$"... | Utility function that checks if geolocation works with each installed database,
and if one or more doesn't, they are renamed to make sure tracking will work.
This is a safety measure used to make sure tracking isn't affected if strange
update errors occur.
Databases are renamed to ${original}.broken .
Note: method is protected for testability.
@param $logErrors - only used to hide error logs during tests | [
"Utility",
"function",
"that",
"checks",
"if",
"geolocation",
"works",
"with",
"each",
"installed",
"database",
"and",
"if",
"one",
"or",
"more",
"doesn",
"t",
"they",
"are",
"renamed",
"to",
"make",
"sure",
"tracking",
"will",
"work",
".",
"This",
"is",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/GeoIPAutoUpdater.php#L559-L606 | train | Perform redundant database checks | [
30522,
5123,
3853,
4685,
5596,
18426,
3372,
18939,
5403,
10603,
1006,
1002,
8833,
2121,
29165,
2015,
1027,
2995,
1007,
1063,
1002,
7809,
13874,
2015,
1027,
9140,
1035,
6309,
1006,
20248,
11514,
1024,
1024,
1002,
16962,
18442,
2015,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Pipeline/Pipeline.php | Pipeline.carry | protected function carry()
{
return function ($stack, $pipe) {
return function ($passable) use ($stack, $pipe) {
if (is_callable($pipe)) {
// If the pipe is an instance of a Closure, we will just call it directly but
// otherwise we'll resolve the pipes out of the container and call it with
// the appropriate method and arguments, returning the results back out.
return $pipe($passable, $stack);
} elseif (! is_object($pipe)) {
[$name, $parameters] = $this->parsePipeString($pipe);
// If the pipe is a string we will parse the string and resolve the class out
// of the dependency injection container. We can then build a callable and
// execute the pipe function giving in the parameters that are required.
$pipe = $this->getContainer()->make($name);
$parameters = array_merge([$passable, $stack], $parameters);
} else {
// If the pipe is already an object we'll just make a callable and pass it to
// the pipe as-is. There is no need to do any extra parsing and formatting
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$response = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $response instanceof Responsable
? $response->toResponse($this->getContainer()->make(Request::class))
: $response;
};
};
} | php | protected function carry()
{
return function ($stack, $pipe) {
return function ($passable) use ($stack, $pipe) {
if (is_callable($pipe)) {
// If the pipe is an instance of a Closure, we will just call it directly but
// otherwise we'll resolve the pipes out of the container and call it with
// the appropriate method and arguments, returning the results back out.
return $pipe($passable, $stack);
} elseif (! is_object($pipe)) {
[$name, $parameters] = $this->parsePipeString($pipe);
// If the pipe is a string we will parse the string and resolve the class out
// of the dependency injection container. We can then build a callable and
// execute the pipe function giving in the parameters that are required.
$pipe = $this->getContainer()->make($name);
$parameters = array_merge([$passable, $stack], $parameters);
} else {
// If the pipe is already an object we'll just make a callable and pass it to
// the pipe as-is. There is no need to do any extra parsing and formatting
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$response = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $response instanceof Responsable
? $response->toResponse($this->getContainer()->make(Request::class))
: $response;
};
};
} | [
"protected",
"function",
"carry",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"stack",
",",
"$",
"pipe",
")",
"{",
"return",
"function",
"(",
"$",
"passable",
")",
"use",
"(",
"$",
"stack",
",",
"$",
"pipe",
")",
"{",
"if",
"(",
"is_callable",
"... | Get a Closure that represents a slice of the application onion.
@return \Closure | [
"Get",
"a",
"Closure",
"that",
"represents",
"a",
"slice",
"of",
"the",
"application",
"onion",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Pipeline/Pipeline.php#L137-L171 | train | Returns a closure that will be used to carry the result of the method | [
30522,
5123,
3853,
4287,
1006,
1007,
1063,
2709,
3853,
1006,
1002,
9991,
1010,
1002,
8667,
1007,
1063,
2709,
3853,
1006,
1002,
3413,
3085,
1007,
2224,
1006,
1002,
9991,
1010,
1002,
8667,
1007,
1063,
2065,
1006,
2003,
1035,
2655,
3085,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/PostgresGrammar.php | PostgresGrammar.dateBasedWhere | protected function dateBasedWhere($type, Builder $query, $where)
{
$value = $this->parameter($where['value']);
return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
} | php | protected function dateBasedWhere($type, Builder $query, $where)
{
$value = $this->parameter($where['value']);
return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
} | [
"protected",
"function",
"dateBasedWhere",
"(",
"$",
"type",
",",
"Builder",
"$",
"query",
",",
"$",
"where",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"parameter",
"(",
"$",
"where",
"[",
"'value'",
"]",
")",
";",
"return",
"'extract('",
".",
... | Compile a date based where clause.
@param string $type
@param \Illuminate\Database\Query\Builder $query
@param array $where
@return string | [
"Compile",
"a",
"date",
"based",
"where",
"clause",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php#L100-L105 | train | Date based where | [
30522,
5123,
3853,
3058,
15058,
2094,
2860,
5886,
2063,
1006,
1002,
2828,
1010,
12508,
1002,
23032,
1010,
1002,
2073,
1007,
1063,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
16381,
1006,
1002,
2073,
1031,
1005,
3643,
1005,
1033,
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/classes/Skin.php | Skin.getActive | public static function getActive()
{
if (self::$skinCache !== null) {
return self::$skinCache;
}
$skinClass = Config::get('cms.backendSkin');
$skinObject = new $skinClass();
return self::$skinCache = $skinObject;
} | php | public static function getActive()
{
if (self::$skinCache !== null) {
return self::$skinCache;
}
$skinClass = Config::get('cms.backendSkin');
$skinObject = new $skinClass();
return self::$skinCache = $skinObject;
} | [
"public",
"static",
"function",
"getActive",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"skinCache",
"!==",
"null",
")",
"{",
"return",
"self",
"::",
"$",
"skinCache",
";",
"}",
"$",
"skinClass",
"=",
"Config",
"::",
"get",
"(",
"'cms.backendSkin'",
... | Returns the active skin. | [
"Returns",
"the",
"active",
"skin",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Skin.php#L101-L110 | train | Get the active backend skin | [
30522,
2270,
10763,
3853,
2131,
19620,
1006,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
1002,
3096,
3540,
5403,
999,
1027,
1027,
19701,
1007,
1063,
2709,
2969,
1024,
1024,
1002,
3096,
3540,
5403,
1025,
1065,
1002,
3096,
26266,
1027,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/console/OctoberUtil.php | OctoberUtil.utilGitPull | protected function utilGitPull()
{
foreach (File::directories(plugins_path()) as $authorDir) {
foreach (File::directories($authorDir) as $pluginDir) {
if (!File::isDirectory($pluginDir.'/.git')) continue;
$exec = 'cd ' . $pluginDir . ' && ';
$exec .= 'git pull 2>&1';
echo 'Updating plugin: '. basename(dirname($pluginDir)) .'.'. basename($pluginDir) . PHP_EOL;
echo shell_exec($exec);
}
}
foreach (File::directories(themes_path()) as $themeDir) {
if (!File::isDirectory($themeDir.'/.git')) continue;
$exec = 'cd ' . $themeDir . ' && ';
$exec .= 'git pull 2>&1';
echo 'Updating theme: '. basename($themeDir) . PHP_EOL;
echo shell_exec($exec);
}
} | php | protected function utilGitPull()
{
foreach (File::directories(plugins_path()) as $authorDir) {
foreach (File::directories($authorDir) as $pluginDir) {
if (!File::isDirectory($pluginDir.'/.git')) continue;
$exec = 'cd ' . $pluginDir . ' && ';
$exec .= 'git pull 2>&1';
echo 'Updating plugin: '. basename(dirname($pluginDir)) .'.'. basename($pluginDir) . PHP_EOL;
echo shell_exec($exec);
}
}
foreach (File::directories(themes_path()) as $themeDir) {
if (!File::isDirectory($themeDir.'/.git')) continue;
$exec = 'cd ' . $themeDir . ' && ';
$exec .= 'git pull 2>&1';
echo 'Updating theme: '. basename($themeDir) . PHP_EOL;
echo shell_exec($exec);
}
} | [
"protected",
"function",
"utilGitPull",
"(",
")",
"{",
"foreach",
"(",
"File",
"::",
"directories",
"(",
"plugins_path",
"(",
")",
")",
"as",
"$",
"authorDir",
")",
"{",
"foreach",
"(",
"File",
"::",
"directories",
"(",
"$",
"authorDir",
")",
"as",
"$",
... | This command requires the git binary to be installed. | [
"This",
"command",
"requires",
"the",
"git",
"binary",
"to",
"be",
"installed",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/console/OctoberUtil.php#L313-L332 | train | Git pull - update all plugins and themes | [
30522,
5123,
3853,
21183,
4014,
23806,
14289,
3363,
1006,
1007,
1063,
18921,
6776,
1006,
5371,
1024,
1024,
2472,
3111,
1006,
13354,
7076,
1035,
4130,
1006,
1007,
1007,
2004,
1002,
3166,
4305,
2099,
1007,
1063,
18921,
6776,
1006,
5371,
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... |
dompdf/dompdf | src/Css/Style.php | Style.set_background_image | function set_background_image($val)
{
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_image"] = null;
$this->_props["background_image"] = $this->_image($val);
} | php | function set_background_image($val)
{
//see __set and __get, on all assignments clear cache, not needed on direct set through __set
$this->_prop_cache["background_image"] = null;
$this->_props["background_image"] = $this->_image($val);
} | [
"function",
"set_background_image",
"(",
"$",
"val",
")",
"{",
"//see __set and __get, on all assignments clear cache, not needed on direct set through __set",
"$",
"this",
"->",
"_prop_cache",
"[",
"\"background_image\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"_props",... | Set the background image url
@link http://www.w3.org/TR/CSS21/colors.html#background-properties
@param string $val | [
"Set",
"the",
"background",
"image",
"url",
"@link",
"http",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"TR",
"/",
"CSS21",
"/",
"colors",
".",
"html#background",
"-",
"properties"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Style.php#L1845-L1850 | train | set background image | [
30522,
3853,
2275,
1035,
4281,
1035,
3746,
1006,
1002,
11748,
1007,
1063,
1013,
1013,
2156,
1035,
1035,
2275,
1998,
1035,
1035,
2131,
1010,
2006,
2035,
14799,
3154,
17053,
1010,
2025,
2734,
2006,
3622,
2275,
2083,
1035,
1035,
2275,
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/Console/Descriptor/MarkdownDescriptor.php | MarkdownDescriptor.describeInputArgument | protected function describeInputArgument(InputArgument $argument, array $options = [])
{
$this->write(
'#### `'.($argument->getName() ?: '<none>')."`\n\n"
.($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '')
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
);
} | php | protected function describeInputArgument(InputArgument $argument, array $options = [])
{
$this->write(
'#### `'.($argument->getName() ?: '<none>')."`\n\n"
.($argument->getDescription() ? preg_replace('/\s*[\r\n]\s*/', "\n", $argument->getDescription())."\n\n" : '')
.'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
.'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
.'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
);
} | [
"protected",
"function",
"describeInputArgument",
"(",
"InputArgument",
"$",
"argument",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"write",
"(",
"'#### `'",
".",
"(",
"$",
"argument",
"->",
"getName",
"(",
")",
"?",
":",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php#L55-L64 | train | Describes an InputArgument | [
30522,
5123,
3853,
6235,
2378,
18780,
2906,
22850,
4765,
1006,
7953,
2906,
22850,
4765,
1002,
6685,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
4339,
1006,
1005,
1001,
1001,
1001,
1001,
1036,
1005,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Rules/Unique.php | Unique.ignoreModel | public function ignoreModel($model, $idColumn = null)
{
$this->idColumn = $idColumn ?? $model->getKeyName();
$this->ignore = $model->{$this->idColumn};
return $this;
} | php | public function ignoreModel($model, $idColumn = null)
{
$this->idColumn = $idColumn ?? $model->getKeyName();
$this->ignore = $model->{$this->idColumn};
return $this;
} | [
"public",
"function",
"ignoreModel",
"(",
"$",
"model",
",",
"$",
"idColumn",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"idColumn",
"=",
"$",
"idColumn",
"??",
"$",
"model",
"->",
"getKeyName",
"(",
")",
";",
"$",
"this",
"->",
"ignore",
"=",
"$",
... | Ignore the given model during the unique check.
@param \Illuminate\Database\Eloquent\Model $model
@param string|null $idColumn
@return $this | [
"Ignore",
"the",
"given",
"model",
"during",
"the",
"unique",
"check",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Rules/Unique.php#L51-L57 | train | Ignore a model | [
30522,
2270,
3853,
8568,
5302,
9247,
1006,
1002,
2944,
1010,
1002,
8909,
25778,
2819,
2078,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
8909,
25778,
2819,
2078,
1027,
1002,
8909,
25778,
2819,
2078,
1029,
1029,
1002,
2944,
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/Form/Extension/Core/Type/DateIntervalType.php | DateIntervalType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['with_years'] && !$options['with_months'] && !$options['with_weeks'] && !$options['with_days'] && !$options['with_hours'] && !$options['with_minutes'] && !$options['with_seconds']) {
throw new InvalidConfigurationException('You must enable at least one interval field.');
}
if ($options['with_invert'] && 'single_text' === $options['widget']) {
throw new InvalidConfigurationException('The single_text widget does not support invertible intervals.');
}
if ($options['with_weeks'] && $options['with_days']) {
throw new InvalidConfigurationException('You can not enable weeks and days fields together.');
}
$format = 'P';
$parts = [];
if ($options['with_years']) {
$format .= '%yY';
$parts[] = 'years';
}
if ($options['with_months']) {
$format .= '%mM';
$parts[] = 'months';
}
if ($options['with_weeks']) {
$format .= '%wW';
$parts[] = 'weeks';
}
if ($options['with_days']) {
$format .= '%dD';
$parts[] = 'days';
}
if ($options['with_hours'] || $options['with_minutes'] || $options['with_seconds']) {
$format .= 'T';
}
if ($options['with_hours']) {
$format .= '%hH';
$parts[] = 'hours';
}
if ($options['with_minutes']) {
$format .= '%iM';
$parts[] = 'minutes';
}
if ($options['with_seconds']) {
$format .= '%sS';
$parts[] = 'seconds';
}
if ($options['with_invert']) {
$parts[] = 'invert';
}
if ('single_text' === $options['widget']) {
$builder->addViewTransformer(new DateIntervalToStringTransformer($format));
} else {
foreach ($this->timeParts as $part) {
if ($options['with_'.$part]) {
$childOptions = [
'error_bubbling' => true,
'label' => $options['labels'][$part],
// Append generic carry-along options
'required' => $options['required'],
'translation_domain' => $options['translation_domain'],
// when compound the array entries are ignored, we need to cascade the configuration here
'empty_data' => isset($options['empty_data'][$part]) ? $options['empty_data'][$part] : null,
];
if ('choice' === $options['widget']) {
$childOptions['choice_translation_domain'] = false;
$childOptions['choices'] = $options[$part];
$childOptions['placeholder'] = $options['placeholder'][$part];
}
$childForm = $builder->create($part, self::$widgets[$options['widget']], $childOptions);
if ('integer' === $options['widget']) {
$childForm->addModelTransformer(
new ReversedTransformer(
new IntegerToLocalizedStringTransformer()
)
);
}
$builder->add($childForm);
}
}
if ($options['with_invert']) {
$builder->add('invert', CheckboxType::class, [
'label' => $options['labels']['invert'],
'error_bubbling' => true,
'required' => false,
'translation_domain' => $options['translation_domain'],
]);
}
$builder->addViewTransformer(new DateIntervalToArrayTransformer($parts, 'text' === $options['widget']));
}
if ('string' === $options['input']) {
$builder->addModelTransformer(
new ReversedTransformer(
new DateIntervalToStringTransformer($format)
)
);
} elseif ('array' === $options['input']) {
$builder->addModelTransformer(
new ReversedTransformer(
new DateIntervalToArrayTransformer($parts)
)
);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['with_years'] && !$options['with_months'] && !$options['with_weeks'] && !$options['with_days'] && !$options['with_hours'] && !$options['with_minutes'] && !$options['with_seconds']) {
throw new InvalidConfigurationException('You must enable at least one interval field.');
}
if ($options['with_invert'] && 'single_text' === $options['widget']) {
throw new InvalidConfigurationException('The single_text widget does not support invertible intervals.');
}
if ($options['with_weeks'] && $options['with_days']) {
throw new InvalidConfigurationException('You can not enable weeks and days fields together.');
}
$format = 'P';
$parts = [];
if ($options['with_years']) {
$format .= '%yY';
$parts[] = 'years';
}
if ($options['with_months']) {
$format .= '%mM';
$parts[] = 'months';
}
if ($options['with_weeks']) {
$format .= '%wW';
$parts[] = 'weeks';
}
if ($options['with_days']) {
$format .= '%dD';
$parts[] = 'days';
}
if ($options['with_hours'] || $options['with_minutes'] || $options['with_seconds']) {
$format .= 'T';
}
if ($options['with_hours']) {
$format .= '%hH';
$parts[] = 'hours';
}
if ($options['with_minutes']) {
$format .= '%iM';
$parts[] = 'minutes';
}
if ($options['with_seconds']) {
$format .= '%sS';
$parts[] = 'seconds';
}
if ($options['with_invert']) {
$parts[] = 'invert';
}
if ('single_text' === $options['widget']) {
$builder->addViewTransformer(new DateIntervalToStringTransformer($format));
} else {
foreach ($this->timeParts as $part) {
if ($options['with_'.$part]) {
$childOptions = [
'error_bubbling' => true,
'label' => $options['labels'][$part],
// Append generic carry-along options
'required' => $options['required'],
'translation_domain' => $options['translation_domain'],
// when compound the array entries are ignored, we need to cascade the configuration here
'empty_data' => isset($options['empty_data'][$part]) ? $options['empty_data'][$part] : null,
];
if ('choice' === $options['widget']) {
$childOptions['choice_translation_domain'] = false;
$childOptions['choices'] = $options[$part];
$childOptions['placeholder'] = $options['placeholder'][$part];
}
$childForm = $builder->create($part, self::$widgets[$options['widget']], $childOptions);
if ('integer' === $options['widget']) {
$childForm->addModelTransformer(
new ReversedTransformer(
new IntegerToLocalizedStringTransformer()
)
);
}
$builder->add($childForm);
}
}
if ($options['with_invert']) {
$builder->add('invert', CheckboxType::class, [
'label' => $options['labels']['invert'],
'error_bubbling' => true,
'required' => false,
'translation_domain' => $options['translation_domain'],
]);
}
$builder->addViewTransformer(new DateIntervalToArrayTransformer($parts, 'text' === $options['widget']));
}
if ('string' === $options['input']) {
$builder->addModelTransformer(
new ReversedTransformer(
new DateIntervalToStringTransformer($format)
)
);
} elseif ('array' === $options['input']) {
$builder->addModelTransformer(
new ReversedTransformer(
new DateIntervalToArrayTransformer($parts)
)
);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"options",
"[",
"'with_years'",
"]",
"&&",
"!",
"$",
"options",
"[",
"'with_months'",
"]",
"&&",
"!",
"$",
"optio... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php#L49-L149 | train | Build the form. | [
30522,
2270,
3853,
3857,
14192,
1006,
2433,
8569,
23891,
6657,
3334,
12172,
1002,
12508,
1010,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
999,
1002,
7047,
1031,
1005,
2007,
1035,
2086,
1005,
1033,
1004,
1004,
999,
1002,
7047,
1031,
1005,
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... |
overtrue/wechat | src/OpenWork/Corp/Client.php | Client.getAuthorization | public function getAuthorization(string $authCorpId, string $permanentCode)
{
$params = [
'auth_corpid' => $authCorpId,
'permanent_code' => $permanentCode,
];
return $this->httpPostJson('cgi-bin/service/get_auth_info', $params);
} | php | public function getAuthorization(string $authCorpId, string $permanentCode)
{
$params = [
'auth_corpid' => $authCorpId,
'permanent_code' => $permanentCode,
];
return $this->httpPostJson('cgi-bin/service/get_auth_info', $params);
} | [
"public",
"function",
"getAuthorization",
"(",
"string",
"$",
"authCorpId",
",",
"string",
"$",
"permanentCode",
")",
"{",
"$",
"params",
"=",
"[",
"'auth_corpid'",
"=>",
"$",
"authCorpId",
",",
"'permanent_code'",
"=>",
"$",
"permanentCode",
",",
"]",
";",
... | 获取企业授权信息.
@param string $authCorpId
@param string $permanentCode
@return mixed
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"获取企业授权信息",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenWork/Corp/Client.php#L123-L131 | train | Get Authorization Info | [
30522,
2270,
3853,
2131,
4887,
27844,
3989,
1006,
5164,
1002,
8740,
2705,
24586,
3593,
1010,
5164,
1002,
4568,
16044,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
8740,
2705,
1035,
13058,
3593,
1005,
1027,
1028,
1002,
8740,
2705,
24586,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/KernelBrowser.php | KernelBrowser.doRequest | protected function doRequest($request)
{
// avoid shutting down the Kernel if no request has been performed yet
// WebTestCase::createClient() boots the Kernel but do not handle a request
if ($this->hasPerformedRequest && $this->reboot) {
$this->kernel->shutdown();
} else {
$this->hasPerformedRequest = true;
}
if ($this->profiler) {
$this->profiler = false;
$this->kernel->boot();
$this->kernel->getContainer()->get('profiler')->enable();
}
return parent::doRequest($request);
} | php | protected function doRequest($request)
{
// avoid shutting down the Kernel if no request has been performed yet
// WebTestCase::createClient() boots the Kernel but do not handle a request
if ($this->hasPerformedRequest && $this->reboot) {
$this->kernel->shutdown();
} else {
$this->hasPerformedRequest = true;
}
if ($this->profiler) {
$this->profiler = false;
$this->kernel->boot();
$this->kernel->getContainer()->get('profiler')->enable();
}
return parent::doRequest($request);
} | [
"protected",
"function",
"doRequest",
"(",
"$",
"request",
")",
"{",
"// avoid shutting down the Kernel if no request has been performed yet",
"// WebTestCase::createClient() boots the Kernel but do not handle a request",
"if",
"(",
"$",
"this",
"->",
"hasPerformedRequest",
"&&",
"... | {@inheritdoc}
@param Request $request A Request instance
@return Response A Response instance | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php#L114-L132 | train | Override doRequest to disable profiler and shutdown if request has been performed | [
30522,
5123,
3853,
2079,
2890,
15500,
1006,
1002,
5227,
1007,
1063,
1013,
1013,
4468,
17521,
2091,
1996,
16293,
2065,
2053,
5227,
2038,
2042,
2864,
2664,
1013,
1013,
4773,
22199,
18382,
1024,
1024,
3443,
20464,
11638,
1006,
1007,
6879,
1996... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db.php | Db.getDatabaseConfig | public static function getDatabaseConfig($dbConfig = null)
{
$config = Config::getInstance();
if (is_null($dbConfig)) {
$dbConfig = $config->database;
}
/**
* Triggered before a database connection is established.
*
* This event can be used to change the settings used to establish a connection.
*
* @param array *$dbInfos Reference to an array containing database connection info,
* including:
*
* - **host**: The host name or IP address to the MySQL database.
* - **username**: The username to use when connecting to the
* database.
* - **password**: The password to use when connecting to the
* database.
* - **dbname**: The name of the Piwik MySQL database.
* - **port**: The MySQL database port to use.
* - **adapter**: either `'PDO\MYSQL'` or `'MYSQLI'`
* - **type**: The MySQL engine to use, for instance 'InnoDB'
*/
Piwik::postEvent('Db.getDatabaseConfig', array(&$dbConfig));
$dbConfig['profiler'] = @$config->Debug['enable_sql_profiler'];
return $dbConfig;
} | php | public static function getDatabaseConfig($dbConfig = null)
{
$config = Config::getInstance();
if (is_null($dbConfig)) {
$dbConfig = $config->database;
}
/**
* Triggered before a database connection is established.
*
* This event can be used to change the settings used to establish a connection.
*
* @param array *$dbInfos Reference to an array containing database connection info,
* including:
*
* - **host**: The host name or IP address to the MySQL database.
* - **username**: The username to use when connecting to the
* database.
* - **password**: The password to use when connecting to the
* database.
* - **dbname**: The name of the Piwik MySQL database.
* - **port**: The MySQL database port to use.
* - **adapter**: either `'PDO\MYSQL'` or `'MYSQLI'`
* - **type**: The MySQL engine to use, for instance 'InnoDB'
*/
Piwik::postEvent('Db.getDatabaseConfig', array(&$dbConfig));
$dbConfig['profiler'] = @$config->Debug['enable_sql_profiler'];
return $dbConfig;
} | [
"public",
"static",
"function",
"getDatabaseConfig",
"(",
"$",
"dbConfig",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"dbConfig",
")",
")",
"{",
"$",
"dbConfig",
"=",
"$",
... | Returns an array with the Database connection information.
@param array|null $dbConfig
@return array | [
"Returns",
"an",
"array",
"with",
"the",
"Database",
"connection",
"information",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db.php#L66-L97 | train | Get the database configuration | [
30522,
2270,
10763,
3853,
2131,
2850,
2696,
15058,
8663,
8873,
2290,
1006,
1002,
16962,
8663,
8873,
2290,
1027,
19701,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1025,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataAccess/ArchiveTableCreator.php | ArchiveTableCreator.getTablesArchivesInstalled | public static function getTablesArchivesInstalled($type = null)
{
if (is_null(self::$tablesAlreadyInstalled)) {
self::refreshTableList();
}
if (empty($type)) {
$tableMatchRegex = '/archive_(numeric|blob)_/';
} else {
$tableMatchRegex = '/archive_' . preg_quote($type) . '_/';
}
$archiveTables = array();
foreach (self::$tablesAlreadyInstalled as $table) {
if (preg_match($tableMatchRegex, $table)) {
$archiveTables[] = $table;
}
}
return $archiveTables;
} | php | public static function getTablesArchivesInstalled($type = null)
{
if (is_null(self::$tablesAlreadyInstalled)) {
self::refreshTableList();
}
if (empty($type)) {
$tableMatchRegex = '/archive_(numeric|blob)_/';
} else {
$tableMatchRegex = '/archive_' . preg_quote($type) . '_/';
}
$archiveTables = array();
foreach (self::$tablesAlreadyInstalled as $table) {
if (preg_match($tableMatchRegex, $table)) {
$archiveTables[] = $table;
}
}
return $archiveTables;
} | [
"public",
"static",
"function",
"getTablesArchivesInstalled",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"tablesAlreadyInstalled",
")",
")",
"{",
"self",
"::",
"refreshTableList",
"(",
")",
";",
"}",
"if",
"(",
... | Returns all table names archive_*
@param string $type The type of table to return. Either `self::NUMERIC_TABLE` or `self::BLOB_TABLE`.
@return array | [
"Returns",
"all",
"table",
"names",
"archive_",
"*"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/ArchiveTableCreator.php#L77-L96 | train | Get tablesArchivesInstalled - Returns array of tables which match given type | [
30522,
2270,
10763,
3853,
2131,
10880,
10286,
5428,
6961,
7076,
9080,
3709,
1006,
1002,
2828,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
2969,
1024,
1024,
1002,
7251,
2389,
16416,
5149,
7076,
9080,
3709,
1007,
1007,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.ARC4 | function ARC4($text)
{
$len = mb_strlen($text, '8bit');
$a = 0;
$b = 0;
$c = $this->arc4;
$out = '';
for ($i = 0; $i < $len; $i++) {
$a = ($a + 1) % 256;
$t = $c[$a];
$b = ($b + ord($t)) % 256;
$c[$a] = $c[$b];
$c[$b] = $t;
$k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
$out .= chr(ord($text[$i]) ^ $k);
}
return $out;
} | php | function ARC4($text)
{
$len = mb_strlen($text, '8bit');
$a = 0;
$b = 0;
$c = $this->arc4;
$out = '';
for ($i = 0; $i < $len; $i++) {
$a = ($a + 1) % 256;
$t = $c[$a];
$b = ($b + ord($t)) % 256;
$c[$a] = $c[$b];
$c[$b] = $t;
$k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
$out .= chr(ord($text[$i]) ^ $k);
}
return $out;
} | [
"function",
"ARC4",
"(",
"$",
"text",
")",
"{",
"$",
"len",
"=",
"mb_strlen",
"(",
"$",
"text",
",",
"'8bit'",
")",
";",
"$",
"a",
"=",
"0",
";",
"$",
"b",
"=",
"0",
";",
"$",
"c",
"=",
"$",
"this",
"->",
"arc4",
";",
"$",
"out",
"=",
"''... | ARC4 encrypt a text string
@param $text
@return string | [
"ARC4",
"encrypt",
"a",
"text",
"string"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2188-L2206 | train | ARC4 - Format text | [
30522,
3853,
8115,
2549,
1006,
1002,
3793,
1007,
1063,
1002,
18798,
1027,
16914,
1035,
2358,
20927,
2078,
1006,
1002,
3793,
1010,
1005,
1022,
16313,
1005,
1007,
1025,
1002,
1037,
1027,
1014,
1025,
1002,
1038,
1027,
1014,
1025,
1002,
1039,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.forPageBeforeId | public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id')
{
$this->orders = $this->removeExistingOrdersFor($column);
if (! is_null($lastId)) {
$this->where($column, '<', $lastId);
}
return $this->orderBy($column, 'desc')
->take($perPage);
} | php | public function forPageBeforeId($perPage = 15, $lastId = 0, $column = 'id')
{
$this->orders = $this->removeExistingOrdersFor($column);
if (! is_null($lastId)) {
$this->where($column, '<', $lastId);
}
return $this->orderBy($column, 'desc')
->take($perPage);
} | [
"public",
"function",
"forPageBeforeId",
"(",
"$",
"perPage",
"=",
"15",
",",
"$",
"lastId",
"=",
"0",
",",
"$",
"column",
"=",
"'id'",
")",
"{",
"$",
"this",
"->",
"orders",
"=",
"$",
"this",
"->",
"removeExistingOrdersFor",
"(",
"$",
"column",
")",
... | Constrain the query to the previous "page" of results before a given ID.
@param int $perPage
@param int|null $lastId
@param string $column
@return \Illuminate\Database\Query\Builder|static | [
"Constrain",
"the",
"query",
"to",
"the",
"previous",
"page",
"of",
"results",
"before",
"a",
"given",
"ID",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L1953-L1963 | train | take pages before id | [
30522,
2270,
3853,
2005,
13704,
4783,
29278,
7416,
2094,
1006,
1002,
2566,
13704,
1027,
2321,
1010,
1002,
2197,
3593,
1027,
1014,
1010,
1002,
5930,
1027,
30524,
1006,
1002,
5930,
1007,
1025,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php | SendMessageMiddleware.getSenders | private function getSenders(Envelope $envelope, &$handle, ?RedeliveryStamp $redeliveryStamp): iterable
{
if (null !== $redeliveryStamp) {
return [
$redeliveryStamp->getSenderClassOrAlias() => $this->sendersLocator->getSenderByAlias($redeliveryStamp->getSenderClassOrAlias()),
];
}
return $this->sendersLocator->getSenders($envelope, $handle);
} | php | private function getSenders(Envelope $envelope, &$handle, ?RedeliveryStamp $redeliveryStamp): iterable
{
if (null !== $redeliveryStamp) {
return [
$redeliveryStamp->getSenderClassOrAlias() => $this->sendersLocator->getSenderByAlias($redeliveryStamp->getSenderClassOrAlias()),
];
}
return $this->sendersLocator->getSenders($envelope, $handle);
} | [
"private",
"function",
"getSenders",
"(",
"Envelope",
"$",
"envelope",
",",
"&",
"$",
"handle",
",",
"?",
"RedeliveryStamp",
"$",
"redeliveryStamp",
")",
":",
"iterable",
"{",
"if",
"(",
"null",
"!==",
"$",
"redeliveryStamp",
")",
"{",
"return",
"[",
"$",
... | * @return iterable|SenderInterface[] | [
"*"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php#L110-L119 | train | Get all sender objects for a given envelope and handle. | [
30522,
2797,
3853,
4152,
10497,
2545,
1006,
11255,
1002,
11255,
1010,
1004,
1002,
5047,
1010,
1029,
2417,
20806,
27900,
9153,
8737,
1002,
2417,
20806,
27900,
9153,
8737,
1007,
1024,
2009,
6906,
3468,
1063,
2065,
1006,
19701,
999,
1027,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Contracts/Service/ServiceLocatorTrait.php | ServiceLocatorTrait.get | public function get($id)
{
if (!isset($this->factories[$id])) {
throw $this->createNotFoundException($id);
}
if (isset($this->loading[$id])) {
$ids = array_values($this->loading);
$ids = \array_slice($this->loading, array_search($id, $ids));
$ids[] = $id;
throw $this->createCircularReferenceException($id, $ids);
}
$this->loading[$id] = $id;
try {
return $this->factories[$id]($this);
} finally {
unset($this->loading[$id]);
}
} | php | public function get($id)
{
if (!isset($this->factories[$id])) {
throw $this->createNotFoundException($id);
}
if (isset($this->loading[$id])) {
$ids = array_values($this->loading);
$ids = \array_slice($this->loading, array_search($id, $ids));
$ids[] = $id;
throw $this->createCircularReferenceException($id, $ids);
}
$this->loading[$id] = $id;
try {
return $this->factories[$id]($this);
} finally {
unset($this->loading[$id]);
}
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"factories",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"$",
"id",
")",
";",
"}",
"if",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Contracts/Service/ServiceLocatorTrait.php#L48-L68 | train | Get a fact by its id | [
30522,
2270,
3853,
2131,
1006,
1002,
8909,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
11123,
1031,
1002,
8909,
1033,
1007,
1007,
1063,
5466,
1002,
2023,
1011,
1028,
3443,
17048,
14876,
8630,
10288,
24422,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Kernel/Support/AES.php | AES.encrypt | public static function encrypt(string $text, string $key, string $iv, int $option = OPENSSL_RAW_DATA): string
{
self::validateKey($key);
self::validateIv($iv);
return openssl_encrypt($text, self::getMode($key), $key, $option, $iv);
} | php | public static function encrypt(string $text, string $key, string $iv, int $option = OPENSSL_RAW_DATA): string
{
self::validateKey($key);
self::validateIv($iv);
return openssl_encrypt($text, self::getMode($key), $key, $option, $iv);
} | [
"public",
"static",
"function",
"encrypt",
"(",
"string",
"$",
"text",
",",
"string",
"$",
"key",
",",
"string",
"$",
"iv",
",",
"int",
"$",
"option",
"=",
"OPENSSL_RAW_DATA",
")",
":",
"string",
"{",
"self",
"::",
"validateKey",
"(",
"$",
"key",
")",
... | @param string $text
@param string $key
@param string $iv
@param int $option
@return string | [
"@param",
"string",
"$text",
"@param",
"string",
"$key",
"@param",
"string",
"$iv",
"@param",
"int",
"$option"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/Support/AES.php#L29-L35 | train | Encrypts text using the openssl_encrypt function | [
30522,
2270,
10763,
3853,
4372,
26775,
22571,
2102,
1006,
5164,
1002,
3793,
30524,
1007,
1025,
2969,
1024,
1024,
9398,
3686,
12848,
1006,
1002,
4921,
1007,
1025,
2709,
7480,
14540,
1035,
4372,
26775,
22571,
2102,
1006,
1002,
3793,
1010,
296... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/HandlerStack.php | HandlerStack.splice | private function splice($findName, $withName, callable $middleware, $before)
{
$this->cached = null;
$idx = $this->findByName($findName);
$tuple = [$middleware, $withName];
if ($before) {
if ($idx === 0) {
array_unshift($this->stack, $tuple);
} else {
$replacement = [$tuple, $this->stack[$idx]];
array_splice($this->stack, $idx, 1, $replacement);
}
} elseif ($idx === count($this->stack) - 1) {
$this->stack[] = $tuple;
} else {
$replacement = [$this->stack[$idx], $tuple];
array_splice($this->stack, $idx, 1, $replacement);
}
} | php | private function splice($findName, $withName, callable $middleware, $before)
{
$this->cached = null;
$idx = $this->findByName($findName);
$tuple = [$middleware, $withName];
if ($before) {
if ($idx === 0) {
array_unshift($this->stack, $tuple);
} else {
$replacement = [$tuple, $this->stack[$idx]];
array_splice($this->stack, $idx, 1, $replacement);
}
} elseif ($idx === count($this->stack) - 1) {
$this->stack[] = $tuple;
} else {
$replacement = [$this->stack[$idx], $tuple];
array_splice($this->stack, $idx, 1, $replacement);
}
} | [
"private",
"function",
"splice",
"(",
"$",
"findName",
",",
"$",
"withName",
",",
"callable",
"$",
"middleware",
",",
"$",
"before",
")",
"{",
"$",
"this",
"->",
"cached",
"=",
"null",
";",
"$",
"idx",
"=",
"$",
"this",
"->",
"findByName",
"(",
"$",
... | Splices a function into the middleware list at a specific position.
@param string $findName
@param string $withName
@param callable $middleware
@param bool $before | [
"Splices",
"a",
"function",
"into",
"the",
"middleware",
"list",
"at",
"a",
"specific",
"position",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/HandlerStack.php#L231-L250 | train | Splice a middleware into the stack | [
30522,
2797,
3853,
11867,
13231,
1006,
1002,
2424,
18442,
1010,
1002,
2007,
18442,
1010,
2655,
3085,
1002,
2690,
8059,
1010,
1002,
2077,
1007,
1063,
1002,
2023,
1011,
1028,
17053,
2094,
1027,
19701,
1025,
1002,
8909,
2595,
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... |
matomo-org/matomo | plugins/Login/Controller.php | Controller.configureView | protected function configureView($view)
{
$this->setBasicVariablesNoneAdminView($view);
$view->linkTitle = Piwik::getRandomTitle();
// crsf token: don't trust the submitted value; generate/fetch it from session data
$view->nonce = Nonce::getNonce('Login.login');
} | php | protected function configureView($view)
{
$this->setBasicVariablesNoneAdminView($view);
$view->linkTitle = Piwik::getRandomTitle();
// crsf token: don't trust the submitted value; generate/fetch it from session data
$view->nonce = Nonce::getNonce('Login.login');
} | [
"protected",
"function",
"configureView",
"(",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"setBasicVariablesNoneAdminView",
"(",
"$",
"view",
")",
";",
"$",
"view",
"->",
"linkTitle",
"=",
"Piwik",
"::",
"getRandomTitle",
"(",
")",
";",
"// crsf token: don't tr... | Configure common view properties
@param View $view | [
"Configure",
"common",
"view",
"properties"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/Controller.php#L175-L183 | train | Configure the view for the admin | [
30522,
5123,
3853,
9530,
8873,
27390,
6777,
2666,
2860,
1006,
1002,
3193,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
22083,
2594,
10755,
19210,
2015,
8540,
13775,
10020,
8584,
1006,
1002,
3193,
1007,
1025,
1002,
3193,
1011,
1028,
4957,
3775,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.callBeforeCallbacks | public function callBeforeCallbacks(Container $container)
{
foreach ($this->beforeCallbacks as $callback) {
$container->call($callback);
}
} | php | public function callBeforeCallbacks(Container $container)
{
foreach ($this->beforeCallbacks as $callback) {
$container->call($callback);
}
} | [
"public",
"function",
"callBeforeCallbacks",
"(",
"Container",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"beforeCallbacks",
"as",
"$",
"callback",
")",
"{",
"$",
"container",
"->",
"call",
"(",
"$",
"callback",
")",
";",
"}",
"}"
] | Call all of the "before" callbacks for the event.
@param \Illuminate\Contracts\Container\Container $container
@return void | [
"Call",
"all",
"of",
"the",
"before",
"callbacks",
"for",
"the",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/Event.php#L242-L247 | train | Call all before callbacks | [
30522,
2270,
3853,
2655,
4783,
29278,
19281,
3363,
12221,
1006,
11661,
1002,
11661,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2077,
9289,
20850,
8684,
2015,
2004,
1002,
2655,
5963,
1007,
1063,
1002,
11661,
1011,
1028,
2655,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/SessionGuard.php | SessionGuard.once | public function once(array $credentials = [])
{
$this->fireAttemptEvent($credentials);
if ($this->validate($credentials)) {
$this->setUser($this->lastAttempted);
return true;
}
return false;
} | php | public function once(array $credentials = [])
{
$this->fireAttemptEvent($credentials);
if ($this->validate($credentials)) {
$this->setUser($this->lastAttempted);
return true;
}
return false;
} | [
"public",
"function",
"once",
"(",
"array",
"$",
"credentials",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"fireAttemptEvent",
"(",
"$",
"credentials",
")",
";",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
"$",
"credentials",
")",
")",
"{",
"$",
... | Log a user into the application without sessions or cookies.
@param array $credentials
@return bool | [
"Log",
"a",
"user",
"into",
"the",
"application",
"without",
"sessions",
"or",
"cookies",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/SessionGuard.php#L213-L224 | train | This method is used to check if the user is logged in and if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if so if | [
30522,
2270,
3853,
2320,
1006,
9140,
1002,
22496,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
2543,
19321,
6633,
13876,
18697,
3372,
1006,
1002,
22496,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
9398,
3686,
1006,
1002,
22496,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Nonce.php | Nonce.getAcceptableOrigins | public static function getAcceptableOrigins()
{
$host = Url::getCurrentHost(null);
$port = '';
// parse host:port
if (preg_match('/^([^:]+):([0-9]+)$/D', $host, $matches)) {
$host = $matches[1];
$port = $matches[2];
}
if (empty($host)) {
return array();
}
// standard ports
$origins = array(
'http://' . $host,
'https://' . $host,
);
// non-standard ports
if (!empty($port) && $port != 80 && $port != 443) {
$origins[] = 'http://' . $host . ':' . $port;
$origins[] = 'https://' . $host . ':' . $port;
}
return $origins;
} | php | public static function getAcceptableOrigins()
{
$host = Url::getCurrentHost(null);
$port = '';
// parse host:port
if (preg_match('/^([^:]+):([0-9]+)$/D', $host, $matches)) {
$host = $matches[1];
$port = $matches[2];
}
if (empty($host)) {
return array();
}
// standard ports
$origins = array(
'http://' . $host,
'https://' . $host,
);
// non-standard ports
if (!empty($port) && $port != 80 && $port != 443) {
$origins[] = 'http://' . $host . ':' . $port;
$origins[] = 'https://' . $host . ':' . $port;
}
return $origins;
} | [
"public",
"static",
"function",
"getAcceptableOrigins",
"(",
")",
"{",
"$",
"host",
"=",
"Url",
"::",
"getCurrentHost",
"(",
"null",
")",
";",
"$",
"port",
"=",
"''",
";",
"// parse host:port",
"if",
"(",
"preg_match",
"(",
"'/^([^:]+):([0-9]+)$/D'",
",",
"$... | Returns a list acceptable values for the HTTP **Origin** header.
@return array | [
"Returns",
"a",
"list",
"acceptable",
"values",
"for",
"the",
"HTTP",
"**",
"Origin",
"**",
"header",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Nonce.php#L127-L155 | train | Get acceptable origins | [
30522,
2270,
10763,
3853,
2131,
6305,
3401,
22799,
3468,
10050,
16529,
1006,
1007,
1063,
1002,
3677,
1027,
24471,
2140,
1024,
1024,
2131,
10841,
14343,
3372,
15006,
2102,
1006,
19701,
1007,
1025,
1002,
3417,
1027,
1005,
1005,
1025,
1013,
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/Mail/Storage/Writable/Maildir.php | Zend_Mail_Storage_Writable_Maildir.removeFolder | public function removeFolder($name)
{
// TODO: This could fail in the middle of the task, which is not optimal.
// But there is no defined standard way to mark a folder as removed and there is no atomar fs-op
// to remove a directory. Also moving the folder to a/the trash folder is not possible, as
// all parent folders must be created. What we could do is add a dash to the front of the
// directory name and it should be ignored as long as other processes obey the standard.
if ($name instanceof Zend_Mail_Storage_Folder) {
$name = $name->getGlobalName();
}
$name = trim($name, $this->_delim);
if (strpos($name, 'INBOX' . $this->_delim) === 0) {
$name = substr($name, 6);
}
// check if folder exists and has no children
if (!$this->getFolders($name)->isLeaf()) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('delete children first');
}
if ($name == 'INBOX' || $name == DIRECTORY_SEPARATOR || $name == '/') {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('wont delete INBOX');
}
if ($name == $this->getCurrentFolder()) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('wont delete selected folder');
}
foreach (array('tmp', 'new', 'cur', '.') as $subdir) {
$dir = $this->_rootdir . '.' . $name . DIRECTORY_SEPARATOR . $subdir;
if (!file_exists($dir)) {
continue;
}
$dh = opendir($dir);
if (!$dh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error opening $subdir");
}
while (($entry = readdir($dh)) !== false) {
if ($entry == '.' || $entry == '..') {
continue;
}
if (!unlink($dir . DIRECTORY_SEPARATOR . $entry)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error cleaning $subdir");
}
}
closedir($dh);
if ($subdir !== '.') {
if (!rmdir($dir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error removing $subdir");
}
}
}
if (!rmdir($this->_rootdir . '.' . $name)) {
// at least we should try to make it a valid maildir again
mkdir($this->_rootdir . '.' . $name . DIRECTORY_SEPARATOR . 'cur');
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error removing maindir");
}
$parent = strpos($name, $this->_delim) ? substr($name, 0, strrpos($name, $this->_delim)) : null;
$localName = $parent ? substr($name, strlen($parent) + 1) : $name;
unset($this->getFolders($parent)->$localName);
} | php | public function removeFolder($name)
{
// TODO: This could fail in the middle of the task, which is not optimal.
// But there is no defined standard way to mark a folder as removed and there is no atomar fs-op
// to remove a directory. Also moving the folder to a/the trash folder is not possible, as
// all parent folders must be created. What we could do is add a dash to the front of the
// directory name and it should be ignored as long as other processes obey the standard.
if ($name instanceof Zend_Mail_Storage_Folder) {
$name = $name->getGlobalName();
}
$name = trim($name, $this->_delim);
if (strpos($name, 'INBOX' . $this->_delim) === 0) {
$name = substr($name, 6);
}
// check if folder exists and has no children
if (!$this->getFolders($name)->isLeaf()) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('delete children first');
}
if ($name == 'INBOX' || $name == DIRECTORY_SEPARATOR || $name == '/') {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('wont delete INBOX');
}
if ($name == $this->getCurrentFolder()) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('wont delete selected folder');
}
foreach (array('tmp', 'new', 'cur', '.') as $subdir) {
$dir = $this->_rootdir . '.' . $name . DIRECTORY_SEPARATOR . $subdir;
if (!file_exists($dir)) {
continue;
}
$dh = opendir($dir);
if (!$dh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error opening $subdir");
}
while (($entry = readdir($dh)) !== false) {
if ($entry == '.' || $entry == '..') {
continue;
}
if (!unlink($dir . DIRECTORY_SEPARATOR . $entry)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error cleaning $subdir");
}
}
closedir($dh);
if ($subdir !== '.') {
if (!rmdir($dir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error removing $subdir");
}
}
}
if (!rmdir($this->_rootdir . '.' . $name)) {
// at least we should try to make it a valid maildir again
mkdir($this->_rootdir . '.' . $name . DIRECTORY_SEPARATOR . 'cur');
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("error removing maindir");
}
$parent = strpos($name, $this->_delim) ? substr($name, 0, strrpos($name, $this->_delim)) : null;
$localName = $parent ? substr($name, strlen($parent) + 1) : $name;
unset($this->getFolders($parent)->$localName);
} | [
"public",
"function",
"removeFolder",
"(",
"$",
"name",
")",
"{",
"// TODO: This could fail in the middle of the task, which is not optimal.",
"// But there is no defined standard way to mark a folder as removed and there is no atomar fs-op",
"// to remove a directory. Also moving the folder to ... | remove a folder
@param string|Zend_Mail_Storage_Folder $name name or instance of folder
@return null
@throws Zend_Mail_Storage_Exception | [
"remove",
"a",
"folder"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L222-L314 | train | Remove folder from the store | [
30522,
2270,
3853,
6366,
10371,
2121,
1006,
1002,
2171,
1007,
1063,
1013,
1013,
28681,
2080,
1024,
2023,
2071,
8246,
1999,
1996,
2690,
1997,
1996,
4708,
1010,
2029,
2003,
2025,
15502,
1012,
1013,
1013,
2021,
2045,
2003,
2053,
4225,
3115,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RecursiveDirectoryFilterIterator.php | RecursiveDirectoryFilterIterator.accept | public function accept()
{
/** @var \SplFileInfo $file */
$file = $this->current();
$filename = $file->getFilename();
$relative_filename = str_replace($this::$root . '/', '', $file->getPathname());
if ($file->isDir()) {
if (in_array($relative_filename, $this::$ignore_folders, true)) {
return false;
}
if (!in_array($filename, $this::$ignore_files, true)) {
return true;
}
} elseif ($file->isFile() && !in_array($filename, $this::$ignore_files, true)) {
return true;
}
return false;
} | php | public function accept()
{
/** @var \SplFileInfo $file */
$file = $this->current();
$filename = $file->getFilename();
$relative_filename = str_replace($this::$root . '/', '', $file->getPathname());
if ($file->isDir()) {
if (in_array($relative_filename, $this::$ignore_folders, true)) {
return false;
}
if (!in_array($filename, $this::$ignore_files, true)) {
return true;
}
} elseif ($file->isFile() && !in_array($filename, $this::$ignore_files, true)) {
return true;
}
return false;
} | [
"public",
"function",
"accept",
"(",
")",
"{",
"/** @var \\SplFileInfo $file */",
"$",
"file",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"file",
"->",
"getFilename",
"(",
")",
";",
"$",
"relative_filename",
"=",
"str_repl... | Check whether the current element of the iterator is acceptable
@return bool true if the current element is acceptable, otherwise false. | [
"Check",
"whether",
"the",
"current",
"element",
"of",
"the",
"iterator",
"is",
"acceptable"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Filesystem/RecursiveDirectoryFilterIterator.php#L40-L58 | train | Accept a file or folder | [
30522,
2270,
3853,
5138,
1006,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
1032,
11867,
10270,
9463,
2378,
14876,
1002,
5371,
1008,
1013,
1002,
5371,
1027,
1002,
2023,
1011,
1028,
2783,
1006,
1007,
1025,
1002,
5371,
18442,
1027,
1002,
5371,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/CreditCard.php | Zend_Validate_CreditCard.addType | public function addType($type)
{
if (is_string($type)) {
$type = array($type);
}
foreach($type as $typ) {
if (defined('self::' . strtoupper($typ)) && !in_array($typ, $this->_type)) {
$this->_type[] = $typ;
}
if (($typ == self::ALL)) {
$this->_type = array_keys($this->_cardLength);
}
}
return $this;
} | php | public function addType($type)
{
if (is_string($type)) {
$type = array($type);
}
foreach($type as $typ) {
if (defined('self::' . strtoupper($typ)) && !in_array($typ, $this->_type)) {
$this->_type[] = $typ;
}
if (($typ == self::ALL)) {
$this->_type = array_keys($this->_cardLength);
}
}
return $this;
} | [
"public",
"function",
"addType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"array",
"(",
"$",
"type",
")",
";",
"}",
"foreach",
"(",
"$",
"type",
"as",
"$",
"typ",
")",
"{",
"if",
"... | Adds a CCI to be accepted by validation
@param string|array $type Type to allow for validation
@return Zend_Validate_CreditCard Provides a fluid interface | [
"Adds",
"a",
"CCI",
"to",
"be",
"accepted",
"by",
"validation"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/CreditCard.php#L193-L210 | train | Add type to the list of types | [
30522,
2270,
3853,
5587,
13874,
1006,
1002,
2828,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
2828,
1007,
1007,
1063,
1002,
2828,
1027,
9140,
1006,
1002,
2828,
1007,
1025,
1065,
18921,
6776,
1006,
1002,
2828,
2004,
1002,
5939,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Mysqli.php | Zend_Db_Adapter_Mysqli.setFetchMode | public function setFetchMode($mode)
{
switch ($mode) {
case Zend_Db::FETCH_LAZY:
case Zend_Db::FETCH_ASSOC:
case Zend_Db::FETCH_NUM:
case Zend_Db::FETCH_BOTH:
case Zend_Db::FETCH_NAMED:
case Zend_Db::FETCH_OBJ:
$this->_fetchMode = $mode;
break;
case Zend_Db::FETCH_BOUND: // bound to PHP variable
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception('FETCH_BOUND is not supported yet');
break;
default:
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception("Invalid fetch mode '$mode' specified");
}
} | php | public function setFetchMode($mode)
{
switch ($mode) {
case Zend_Db::FETCH_LAZY:
case Zend_Db::FETCH_ASSOC:
case Zend_Db::FETCH_NUM:
case Zend_Db::FETCH_BOTH:
case Zend_Db::FETCH_NAMED:
case Zend_Db::FETCH_OBJ:
$this->_fetchMode = $mode;
break;
case Zend_Db::FETCH_BOUND: // bound to PHP variable
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception('FETCH_BOUND is not supported yet');
break;
default:
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception("Invalid fetch mode '$mode' specified");
}
} | [
"public",
"function",
"setFetchMode",
"(",
"$",
"mode",
")",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"Zend_Db",
"::",
"FETCH_LAZY",
":",
"case",
"Zend_Db",
"::",
"FETCH_ASSOC",
":",
"case",
"Zend_Db",
"::",
"FETCH_NUM",
":",
"case",
"Zend_Db",
... | Set the fetch mode.
@param int $mode
@return void
@throws Zend_Db_Adapter_Mysqli_Exception | [
"Set",
"the",
"fetch",
"mode",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L491-L516 | train | Set the fetch mode | [
30522,
2270,
3853,
2275,
7959,
10649,
5302,
3207,
1006,
1002,
5549,
1007,
1063,
6942,
1006,
1002,
5549,
1007,
1063,
2553,
16729,
2094,
1035,
16962,
1024,
1024,
18584,
1035,
13971,
1024,
2553,
16729,
2094,
1035,
16962,
1024,
1024,
18584,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.