repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
symfony/symfony | src/Symfony/Component/Translation/Loader/IcuResFileLoader.php | IcuResFileLoader.load | public function load($resource, $locale, $domain = 'messages')
{
if (!stream_is_local($resource)) {
throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
}
if (!is_dir($resource)) {
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
}
try {
$rb = new \ResourceBundle($locale, $resource);
} catch (\Exception $e) {
$rb = null;
}
if (!$rb) {
throw new InvalidResourceException(sprintf('Cannot load resource "%s"', $resource));
} elseif (intl_is_failure($rb->getErrorCode())) {
throw new InvalidResourceException($rb->getErrorMessage(), $rb->getErrorCode());
}
$messages = $this->flatten($rb);
$catalogue = new MessageCatalogue($locale);
$catalogue->add($messages, $domain);
if (class_exists('Symfony\Component\Config\Resource\DirectoryResource')) {
$catalogue->addResource(new DirectoryResource($resource));
}
return $catalogue;
} | php | public function load($resource, $locale, $domain = 'messages')
{
if (!stream_is_local($resource)) {
throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
}
if (!is_dir($resource)) {
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
}
try {
$rb = new \ResourceBundle($locale, $resource);
} catch (\Exception $e) {
$rb = null;
}
if (!$rb) {
throw new InvalidResourceException(sprintf('Cannot load resource "%s"', $resource));
} elseif (intl_is_failure($rb->getErrorCode())) {
throw new InvalidResourceException($rb->getErrorMessage(), $rb->getErrorCode());
}
$messages = $this->flatten($rb);
$catalogue = new MessageCatalogue($locale);
$catalogue->add($messages, $domain);
if (class_exists('Symfony\Component\Config\Resource\DirectoryResource')) {
$catalogue->addResource(new DirectoryResource($resource));
}
return $catalogue;
} | [
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"locale",
",",
"$",
"domain",
"=",
"'messages'",
")",
"{",
"if",
"(",
"!",
"stream_is_local",
"(",
"$",
"resource",
")",
")",
"{",
"throw",
"new",
"InvalidResourceException",
"(",
"sprintf",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Loader/IcuResFileLoader.php#L29-L60 | train | Load a resource | [
30522,
2270,
3853,
7170,
1006,
1002,
7692,
1010,
1002,
2334,
2063,
1010,
1002,
5884,
1027,
1005,
7696,
1005,
30524,
1000,
1012,
1005,
1010,
1002,
7692,
1007,
1007,
1025,
1065,
2065,
1006,
999,
2003,
1035,
16101,
1006,
1002,
7692,
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/Http/Response.php | Response.setContent | public function setContent($content)
{
$this->original = $content;
// If the content is "JSONable" we will set the appropriate header and convert
// the content to JSON. This is useful when returning something like models
// from routes that will be automatically transformed to their JSON form.
if ($this->shouldBeJson($content)) {
$this->header('Content-Type', 'application/json');
$content = $this->morphToJson($content);
}
// If this content implements the "Renderable" interface then we will call the
// render method on the object so we will avoid any "__toString" exceptions
// that might be thrown and have their errors obscured by PHP's handling.
elseif ($content instanceof Renderable) {
$content = $content->render();
}
parent::setContent($content);
return $this;
} | php | public function setContent($content)
{
$this->original = $content;
// If the content is "JSONable" we will set the appropriate header and convert
// the content to JSON. This is useful when returning something like models
// from routes that will be automatically transformed to their JSON form.
if ($this->shouldBeJson($content)) {
$this->header('Content-Type', 'application/json');
$content = $this->morphToJson($content);
}
// If this content implements the "Renderable" interface then we will call the
// render method on the object so we will avoid any "__toString" exceptions
// that might be thrown and have their errors obscured by PHP's handling.
elseif ($content instanceof Renderable) {
$content = $content->render();
}
parent::setContent($content);
return $this;
} | [
"public",
"function",
"setContent",
"(",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"original",
"=",
"$",
"content",
";",
"// If the content is \"JSONable\" we will set the appropriate header and convert",
"// the content to JSON. This is useful when returning something like mode... | Set the content on the response.
@param mixed $content
@return $this | [
"Set",
"the",
"content",
"on",
"the",
"response",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Response.php#L25-L48 | train | Set the content of the page | [
30522,
2270,
3853,
2275,
8663,
6528,
2102,
1006,
1002,
4180,
1007,
1063,
1002,
2023,
1011,
1028,
2434,
1027,
1002,
4180,
1025,
1013,
1013,
2065,
1996,
4180,
2003,
1000,
1046,
3385,
3085,
1000,
2057,
2097,
2275,
1996,
6413,
20346,
1998,
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/Asset/Packages.php | Packages.getPackage | public function getPackage($name = null)
{
if (null === $name) {
if (null === $this->defaultPackage) {
throw new LogicException('There is no default asset package, configure one first.');
}
return $this->defaultPackage;
}
if (!isset($this->packages[$name])) {
throw new InvalidArgumentException(sprintf('There is no "%s" asset package.', $name));
}
return $this->packages[$name];
} | php | public function getPackage($name = null)
{
if (null === $name) {
if (null === $this->defaultPackage) {
throw new LogicException('There is no default asset package, configure one first.');
}
return $this->defaultPackage;
}
if (!isset($this->packages[$name])) {
throw new InvalidArgumentException(sprintf('There is no "%s" asset package.', $name));
}
return $this->packages[$name];
} | [
"public",
"function",
"getPackage",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"name",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"defaultPackage",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'There is no ... | Returns an asset package.
@param string $name The name of the package or null for the default package
@return PackageInterface An asset package
@throws InvalidArgumentException If there is no package by that name
@throws LogicException If no default package is defined | [
"Returns",
"an",
"asset",
"package",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Asset/Packages.php#L67-L82 | train | Get the package | [
30522,
2270,
3853,
2131,
23947,
4270,
1006,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2171,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
12398,
23947,
4270,
1007,
1063,
5466,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Frontend/Page.php | Zend_Cache_Frontend_Page._makePartialId | protected function _makePartialId($arrayName, $bool1, $bool2)
{
switch ($arrayName) {
case 'Get':
$var = $_GET;
break;
case 'Post':
$var = $_POST;
break;
case 'Session':
if (isset($_SESSION)) {
$var = $_SESSION;
} else {
$var = null;
}
break;
case 'Cookie':
if (isset($_COOKIE)) {
$var = $_COOKIE;
} else {
$var = null;
}
break;
case 'Files':
$var = $_FILES;
break;
default:
return false;
}
if ($bool1) {
if ($bool2) {
return serialize($var);
}
return '';
}
if (count($var) > 0) {
return false;
}
return '';
} | php | protected function _makePartialId($arrayName, $bool1, $bool2)
{
switch ($arrayName) {
case 'Get':
$var = $_GET;
break;
case 'Post':
$var = $_POST;
break;
case 'Session':
if (isset($_SESSION)) {
$var = $_SESSION;
} else {
$var = null;
}
break;
case 'Cookie':
if (isset($_COOKIE)) {
$var = $_COOKIE;
} else {
$var = null;
}
break;
case 'Files':
$var = $_FILES;
break;
default:
return false;
}
if ($bool1) {
if ($bool2) {
return serialize($var);
}
return '';
}
if (count($var) > 0) {
return false;
}
return '';
} | [
"protected",
"function",
"_makePartialId",
"(",
"$",
"arrayName",
",",
"$",
"bool1",
",",
"$",
"bool2",
")",
"{",
"switch",
"(",
"$",
"arrayName",
")",
"{",
"case",
"'Get'",
":",
"$",
"var",
"=",
"$",
"_GET",
";",
"break",
";",
"case",
"'Post'",
":",... | Make a partial id depending on options
@param string $arrayName Superglobal array name
@param bool $bool1 If true, cache is still on even if there are some variables in the superglobal array
@param bool $bool2 If true, we have to use the content of the superglobal array to make a partial id
@return mixed|false Partial id (string) or false if the cache should have not to be used | [
"Make",
"a",
"partial",
"id",
"depending",
"on",
"options"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Page.php#L363-L402 | train | This method is used to make partial ID | [
30522,
5123,
3853,
1035,
2191,
19362,
20925,
3593,
1006,
1002,
9140,
18442,
1010,
1002,
22017,
2140,
2487,
1010,
1002,
22017,
2140,
2475,
1007,
1063,
6942,
1006,
1002,
9140,
18442,
1007,
1063,
2553,
1005,
2131,
1005,
1024,
1002,
13075,
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/Archive.php | Archive.getDataTableFromNumeric | public function getDataTableFromNumeric($names)
{
$data = $this->get($names, 'numeric');
return $data->getDataTable($this->getResultIndices());
} | php | public function getDataTableFromNumeric($names)
{
$data = $this->get($names, 'numeric');
return $data->getDataTable($this->getResultIndices());
} | [
"public",
"function",
"getDataTableFromNumeric",
"(",
"$",
"names",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"names",
",",
"'numeric'",
")",
";",
"return",
"$",
"data",
"->",
"getDataTable",
"(",
"$",
"this",
"->",
"getResultIndice... | Queries and returns metric data in a DataTable instance.
If multiple sites were requested in {@link build()} or {@link factory()} the result will
be a DataTable\Map that is indexed by site ID.
If multiple periods were requested in {@link build()} or {@link factory()} the result will
be a {@link 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.
_Note: Every DataTable instance returned will have at most one row in it. The contents of each
row will be the requested metrics for the appropriate site and period._
@param string|array $names One or more archive names, eg, 'nb_visits', 'Referrers_distinctKeywords',
etc.
@return DataTable|DataTable\Map A DataTable if multiple sites and periods were not requested.
An appropriately indexed DataTable\Map if otherwise. | [
"Queries",
"and",
"returns",
"metric",
"data",
"in",
"a",
"DataTable",
"instance",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive.php#L301-L305 | train | Get Data Table from numeric array | [
30522,
2270,
3853,
2131,
2850,
29336,
3085,
19699,
5358,
19172,
22420,
1006,
1002,
3415,
1007,
1063,
1002,
2951,
1027,
1002,
2023,
1011,
1028,
2131,
1006,
1002,
3415,
1010,
1005,
16371,
25531,
1005,
1007,
1025,
2709,
1002,
2951,
1011,
1028,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php | QueriesRelationships.hasNested | protected function hasNested($relations, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
{
$relations = explode('.', $relations);
$doesntHave = $operator === '<' && $count === 1;
if ($doesntHave) {
$operator = '>=';
$count = 1;
}
$closure = function ($q) use (&$closure, &$relations, $operator, $count, $callback) {
// In order to nest "has", we need to add count relation constraints on the
// callback Closure. We'll do this by simply passing the Closure its own
// reference to itself so it calls itself recursively on each segment.
count($relations) > 1
? $q->whereHas(array_shift($relations), $closure)
: $q->has(array_shift($relations), $operator, $count, 'and', $callback);
};
return $this->has(array_shift($relations), $doesntHave ? '<' : '>=', 1, $boolean, $closure);
} | php | protected function hasNested($relations, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
{
$relations = explode('.', $relations);
$doesntHave = $operator === '<' && $count === 1;
if ($doesntHave) {
$operator = '>=';
$count = 1;
}
$closure = function ($q) use (&$closure, &$relations, $operator, $count, $callback) {
// In order to nest "has", we need to add count relation constraints on the
// callback Closure. We'll do this by simply passing the Closure its own
// reference to itself so it calls itself recursively on each segment.
count($relations) > 1
? $q->whereHas(array_shift($relations), $closure)
: $q->has(array_shift($relations), $operator, $count, 'and', $callback);
};
return $this->has(array_shift($relations), $doesntHave ? '<' : '>=', 1, $boolean, $closure);
} | [
"protected",
"function",
"hasNested",
"(",
"$",
"relations",
",",
"$",
"operator",
"=",
"'>='",
",",
"$",
"count",
"=",
"1",
",",
"$",
"boolean",
"=",
"'and'",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"relations",
"=",
"explode",
"(",
"'.'",... | Add nested relationship count / exists conditions to the query.
Sets up recursive call to whereHas until we finish the nested relation.
@param string $relations
@param string $operator
@param int $count
@param string $boolean
@param \Closure|null $callback
@return \Illuminate\Database\Eloquent\Builder|static | [
"Add",
"nested",
"relationship",
"count",
"/",
"exists",
"conditions",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php#L73-L94 | train | Nest nested has | [
30522,
5123,
3853,
8440,
17944,
1006,
1002,
4262,
1010,
1002,
6872,
1027,
1005,
1028,
1027,
1005,
1010,
1002,
4175,
1027,
1015,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1010,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
1002,
4262,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/File/AbstractFile.php | AbstractFile.getExtension | public function getExtension(bool $withDot = false): string
{
if (null === $this->extension) {
$this->setPathInfo();
}
return ($withDot ? '.' : '') . $this->extension;
} | php | public function getExtension(bool $withDot = false): string
{
if (null === $this->extension) {
$this->setPathInfo();
}
return ($withDot ? '.' : '') . $this->extension;
} | [
"public",
"function",
"getExtension",
"(",
"bool",
"$",
"withDot",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"extension",
")",
"{",
"$",
"this",
"->",
"setPathInfo",
"(",
")",
";",
"}",
"return",
"(",
"$",
... | {@inheritdoc}
@see FileInterface::getExtension() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/File/AbstractFile.php#L137-L144 | train | Get the file extension | [
30522,
2270,
3853,
2131,
10288,
29048,
1006,
22017,
2140,
1002,
2007,
27364,
1027,
6270,
1007,
1024,
5164,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
5331,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
15069,
2378,
14876... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Workflow/MarkingStore/MultipleStateMarkingStore.php | MultipleStateMarkingStore.setMarking | public function setMarking($subject, Marking $marking/*, array $context = []*/)
{
$this->propertyAccessor->setValue($subject, $this->property, $marking->getPlaces());
} | php | public function setMarking($subject, Marking $marking/*, array $context = []*/)
{
$this->propertyAccessor->setValue($subject, $this->property, $marking->getPlaces());
} | [
"public",
"function",
"setMarking",
"(",
"$",
"subject",
",",
"Marking",
"$",
"marking",
"/*, array $context = []*/",
")",
"{",
"$",
"this",
"->",
"propertyAccessor",
"->",
"setValue",
"(",
"$",
"subject",
",",
"$",
"this",
"->",
"property",
",",
"$",
"marki... | {@inheritdoc}
@param array $context Some context | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore.php#L55-L58 | train | Set the marking of the subject | [
30522,
2270,
3853,
2275,
10665,
2075,
1006,
1002,
3395,
1010,
10060,
1002,
10060,
1013,
1008,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1008,
1013,
1007,
1063,
1002,
2023,
1011,
1028,
3200,
6305,
9623,
21748,
1011,
1028,
2275,
10175,
5657,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Controller.php | Controller.runAjaxHandlerForWidget | protected function runAjaxHandlerForWidget($widget, $handler)
{
$this->addViewPath($widget->getViewPaths());
$result = call_user_func_array([$widget, $handler], $this->params);
$this->vars = $widget->vars + $this->vars;
return $result;
} | php | protected function runAjaxHandlerForWidget($widget, $handler)
{
$this->addViewPath($widget->getViewPaths());
$result = call_user_func_array([$widget, $handler], $this->params);
$this->vars = $widget->vars + $this->vars;
return $result;
} | [
"protected",
"function",
"runAjaxHandlerForWidget",
"(",
"$",
"widget",
",",
"$",
"handler",
")",
"{",
"$",
"this",
"->",
"addViewPath",
"(",
"$",
"widget",
"->",
"getViewPaths",
"(",
")",
")",
";",
"$",
"result",
"=",
"call_user_func_array",
"(",
"[",
"$"... | Specific code for executing an AJAX handler for a widget.
This will append the widget view paths to the controller and merge the vars.
@return mixed | [
"Specific",
"code",
"for",
"executing",
"an",
"AJAX",
"handler",
"for",
"a",
"widget",
".",
"This",
"will",
"append",
"the",
"widget",
"view",
"paths",
"to",
"the",
"controller",
"and",
"merge",
"the",
"vars",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L610-L619 | train | Runs an AJAX handler for a widget | [
30522,
5123,
3853,
2448,
22734,
2595,
11774,
3917,
29278,
9148,
24291,
1006,
1002,
15536,
24291,
1010,
1002,
28213,
1007,
1063,
1002,
2023,
1011,
1028,
5587,
8584,
15069,
1006,
1002,
15536,
24291,
1011,
1028,
2131,
8584,
15069,
2015,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Common.php | Common.sendHeader | public static function sendHeader($header, $replace = true)
{
// don't send header in CLI mode
if (!Common::isPhpCliMode() and !headers_sent()) {
header($header, $replace);
}
} | php | public static function sendHeader($header, $replace = true)
{
// don't send header in CLI mode
if (!Common::isPhpCliMode() and !headers_sent()) {
header($header, $replace);
}
} | [
"public",
"static",
"function",
"sendHeader",
"(",
"$",
"header",
",",
"$",
"replace",
"=",
"true",
")",
"{",
"// don't send header in CLI mode",
"if",
"(",
"!",
"Common",
"::",
"isPhpCliMode",
"(",
")",
"and",
"!",
"headers_sent",
"(",
")",
")",
"{",
"hea... | Sets outgoing header.
@param string $header The header.
@param bool $replace Whether to replace existing or not. | [
"Sets",
"outgoing",
"header",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Common.php#L1168-L1174 | train | Sends header to the browser | [
30522,
2270,
10763,
3853,
4604,
4974,
2121,
1006,
1002,
20346,
1010,
1002,
5672,
1027,
2995,
1007,
1063,
1013,
1013,
2123,
1005,
1056,
4604,
20346,
1999,
18856,
2072,
5549,
2065,
1006,
999,
2691,
1024,
1024,
2003,
8458,
15042,
17960,
10244,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.convertValuesToBoolean | protected function convertValuesToBoolean($values)
{
return array_map(function ($value) {
if ($value === 'true') {
return true;
} elseif ($value === 'false') {
return false;
}
return $value;
}, $values);
} | php | protected function convertValuesToBoolean($values)
{
return array_map(function ($value) {
if ($value === 'true') {
return true;
} elseif ($value === 'false') {
return false;
}
return $value;
}, $values);
} | [
"protected",
"function",
"convertValuesToBoolean",
"(",
"$",
"values",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"'true'",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"$",
"v... | Convert the given values to boolean if they are string "true" / "false".
@param array $values
@return array | [
"Convert",
"the",
"given",
"values",
"to",
"boolean",
"if",
"they",
"are",
"string",
"true",
"/",
"false",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L1348-L1359 | train | Convert the values to boolean | [
30522,
5123,
3853,
10463,
10175,
15808,
3406,
5092,
9890,
2319,
1006,
1002,
5300,
1007,
1063,
2709,
9140,
1035,
4949,
1006,
3853,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
3643,
1027,
1027,
1027,
1005,
2995,
1005,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Writable/Maildir.php | Zend_Mail_Storage_Writable_Maildir._createTmpFile | protected function _createTmpFile($folder = 'INBOX')
{
if ($folder == 'INBOX') {
$tmpdir = $this->_rootdir . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
} else {
$tmpdir = $this->_rootdir . '.' . $folder . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
}
if (!file_exists($tmpdir)) {
if (!mkdir($tmpdir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('problems creating tmp dir');
}
}
// we should retry to create a unique id if a file with the same name exists
// to avoid a script timeout we only wait 1 second (instead of 2) and stop
// after a defined retry count
// if you change this variable take into account that it can take up to $max_tries seconds
// normally we should have a valid unique name after the first try, we're just following the "standard" here
$max_tries = 5;
for ($i = 0; $i < $max_tries; ++$i) {
$uniq = $this->_createUniqueId();
if (!file_exists($tmpdir . $uniq)) {
// here is the race condition! - as defined in the standard
// to avoid having a long time between stat()ing the file and creating it we're opening it here
// to mark the filename as taken
$fh = fopen($tmpdir . $uniq, 'w');
if (!$fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('could not open temp file');
}
break;
}
sleep(1);
}
if (!$fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("tried $max_tries unique ids for a temp file, but all were taken"
. ' - giving up');
}
return array('dirname' => $this->_rootdir . '.' . $folder, 'uniq' => $uniq, 'filename' => $tmpdir . $uniq,
'handle' => $fh);
} | php | protected function _createTmpFile($folder = 'INBOX')
{
if ($folder == 'INBOX') {
$tmpdir = $this->_rootdir . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
} else {
$tmpdir = $this->_rootdir . '.' . $folder . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
}
if (!file_exists($tmpdir)) {
if (!mkdir($tmpdir)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('problems creating tmp dir');
}
}
// we should retry to create a unique id if a file with the same name exists
// to avoid a script timeout we only wait 1 second (instead of 2) and stop
// after a defined retry count
// if you change this variable take into account that it can take up to $max_tries seconds
// normally we should have a valid unique name after the first try, we're just following the "standard" here
$max_tries = 5;
for ($i = 0; $i < $max_tries; ++$i) {
$uniq = $this->_createUniqueId();
if (!file_exists($tmpdir . $uniq)) {
// here is the race condition! - as defined in the standard
// to avoid having a long time between stat()ing the file and creating it we're opening it here
// to mark the filename as taken
$fh = fopen($tmpdir . $uniq, 'w');
if (!$fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('could not open temp file');
}
break;
}
sleep(1);
}
if (!$fh) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception("tried $max_tries unique ids for a temp file, but all were taken"
. ' - giving up');
}
return array('dirname' => $this->_rootdir . '.' . $folder, 'uniq' => $uniq, 'filename' => $tmpdir . $uniq,
'handle' => $fh);
} | [
"protected",
"function",
"_createTmpFile",
"(",
"$",
"folder",
"=",
"'INBOX'",
")",
"{",
"if",
"(",
"$",
"folder",
"==",
"'INBOX'",
")",
"{",
"$",
"tmpdir",
"=",
"$",
"this",
"->",
"_rootdir",
".",
"DIRECTORY_SEPARATOR",
".",
"'tmp'",
".",
"DIRECTORY_SEPAR... | open a temporary maildir file
makes sure tmp/ exists and create a file with a unique name
you should close the returned filehandle!
@param string $folder name of current folder without leading .
@return array array('dirname' => dir of maildir folder, 'uniq' => unique id, 'filename' => name of create file
'handle' => file opened for writing)
@throws Zend_Mail_Storage_Exception | [
"open",
"a",
"temporary",
"maildir",
"file"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L433-L486 | train | Create a temporary file for the mailbox | [
30522,
5123,
3853,
1035,
3443,
21246,
14376,
9463,
1006,
1002,
19622,
1027,
1005,
1999,
8758,
1005,
1007,
1063,
2065,
1006,
1002,
30524,
1002,
1056,
8737,
4305,
2099,
1027,
1002,
2023,
1011,
1028,
1035,
7117,
4305,
2099,
1012,
14176,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php | InteractsWithPivotTable.detach | public function detach($ids = null, $touch = true)
{
if ($this->using && ! empty($ids) && empty($this->pivotWheres) && empty($this->pivotWhereIns)) {
$results = $this->detachUsingCustomClass($ids);
} else {
$query = $this->newPivotQuery();
// If associated IDs were passed to the method we will only delete those
// associations, otherwise all of the association ties will be broken.
// We'll return the numbers of affected rows when we do the deletes.
if (! is_null($ids)) {
$ids = $this->parseIds($ids);
if (empty($ids)) {
return 0;
}
$query->whereIn($this->relatedPivotKey, (array) $ids);
}
// Once we have all of the conditions set on the statement, we are ready
// to run the delete on the pivot table. Then, if the touch parameter
// is true, we will go ahead and touch all related models to sync.
$results = $query->delete();
}
if ($touch) {
$this->touchIfTouching();
}
return $results;
} | php | public function detach($ids = null, $touch = true)
{
if ($this->using && ! empty($ids) && empty($this->pivotWheres) && empty($this->pivotWhereIns)) {
$results = $this->detachUsingCustomClass($ids);
} else {
$query = $this->newPivotQuery();
// If associated IDs were passed to the method we will only delete those
// associations, otherwise all of the association ties will be broken.
// We'll return the numbers of affected rows when we do the deletes.
if (! is_null($ids)) {
$ids = $this->parseIds($ids);
if (empty($ids)) {
return 0;
}
$query->whereIn($this->relatedPivotKey, (array) $ids);
}
// Once we have all of the conditions set on the statement, we are ready
// to run the delete on the pivot table. Then, if the touch parameter
// is true, we will go ahead and touch all related models to sync.
$results = $query->delete();
}
if ($touch) {
$this->touchIfTouching();
}
return $results;
} | [
"public",
"function",
"detach",
"(",
"$",
"ids",
"=",
"null",
",",
"$",
"touch",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"using",
"&&",
"!",
"empty",
"(",
"$",
"ids",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"pivotWheres",
")",
... | Detach models from the relationship.
@param mixed $ids
@param bool $touch
@return int | [
"Detach",
"models",
"from",
"the",
"relationship",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php#L404-L435 | train | Detaches records from the pivot table | [
30522,
2270,
3853,
20010,
6776,
1006,
1002,
8909,
2015,
1027,
19701,
1010,
1002,
3543,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2478,
1004,
1004,
999,
4064,
1006,
1002,
8909,
2015,
1007,
1004,
1004,
4064,
1006,
1002,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/ServiceProvider.php | ServiceProvider.bootMenuItemEvents | protected function bootMenuItemEvents()
{
Event::listen('pages.menuitem.listTypes', function () {
return [
'cms-page' => 'cms::lang.page.cms_page'
];
});
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
if ($type === 'cms-page') {
return CmsPage::getMenuTypeInfo($type);
}
});
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
if ($type === 'cms-page') {
return CmsPage::resolveMenuItem($item, $url, $theme);
}
});
} | php | protected function bootMenuItemEvents()
{
Event::listen('pages.menuitem.listTypes', function () {
return [
'cms-page' => 'cms::lang.page.cms_page'
];
});
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
if ($type === 'cms-page') {
return CmsPage::getMenuTypeInfo($type);
}
});
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
if ($type === 'cms-page') {
return CmsPage::resolveMenuItem($item, $url, $theme);
}
});
} | [
"protected",
"function",
"bootMenuItemEvents",
"(",
")",
"{",
"Event",
"::",
"listen",
"(",
"'pages.menuitem.listTypes'",
",",
"function",
"(",
")",
"{",
"return",
"[",
"'cms-page'",
"=>",
"'cms::lang.page.cms_page'",
"]",
";",
"}",
")",
";",
"Event",
"::",
"l... | Registers events for menu items. | [
"Registers",
"events",
"for",
"menu",
"items",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/ServiceProvider.php#L289-L308 | train | Boots menu item events | [
30522,
5123,
3853,
9573,
3549,
14663,
21382,
15338,
2015,
1006,
1007,
1063,
2724,
1024,
1024,
4952,
1006,
1005,
5530,
1012,
12183,
4221,
2213,
1012,
2862,
13874,
2015,
1005,
1010,
3853,
1006,
1007,
1063,
2709,
1031,
1005,
4642,
2015,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/MediaLibrary.php | MediaLibrary.isVisible | protected function isVisible($path)
{
$baseName = basename($path);
if (in_array($baseName, $this->ignoreNames)) {
return false;
}
foreach ($this->ignorePatterns as $pattern) {
if (preg_match('/'.$pattern.'/', $baseName)) {
return false;
}
}
return true;
} | php | protected function isVisible($path)
{
$baseName = basename($path);
if (in_array($baseName, $this->ignoreNames)) {
return false;
}
foreach ($this->ignorePatterns as $pattern) {
if (preg_match('/'.$pattern.'/', $baseName)) {
return false;
}
}
return true;
} | [
"protected",
"function",
"isVisible",
"(",
"$",
"path",
")",
"{",
"$",
"baseName",
"=",
"basename",
"(",
"$",
"path",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"baseName",
",",
"$",
"this",
"->",
"ignoreNames",
")",
")",
"{",
"return",
"false",
";",... | Determines if the path should be visible (not ignored).
@param string $path Specifies a path to check.
@return boolean Returns TRUE if the path is visible. | [
"Determines",
"if",
"the",
"path",
"should",
"be",
"visible",
"(",
"not",
"ignored",
")",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L574-L589 | train | Check if file is visible | [
30522,
5123,
3853,
2003,
11365,
7028,
1006,
1002,
4130,
1007,
1063,
1002,
2918,
18442,
1027,
2918,
18442,
1006,
1002,
4130,
1007,
1025,
2065,
1006,
1999,
1035,
9140,
1006,
1002,
2918,
18442,
1010,
1002,
2023,
1011,
1028,
8568,
18442,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UsersManager/LastSeenTimeLogger.php | LastSeenTimeLogger.logCurrentUserLastSeenTime | public function logCurrentUserLastSeenTime()
{
$module = Common::getRequestVar('module', false);
$currentUserLogin = Piwik::getCurrentUserLogin();
// only log time for non-anonymous visits to the reporting UI
if ($module == 'API'
|| $module == 'Proxy'
|| Piwik::isUserIsAnonymous()
) {
return;
}
// get the last known time
$optionName = self::OPTION_PREFIX . $currentUserLogin;
$lastSeen = Option::get($optionName);
// do not log if last known time is less than N minutes from now (so we don't make too many
// queries)
if (time() - $lastSeen <= self::LAST_TIME_SAVE_DELTA) {
return;
}
// log last seen time (Note: autoload is important so the Option::get above does not result in
// a separate query)
Option::set($optionName, time(), $autoload = 1);
} | php | public function logCurrentUserLastSeenTime()
{
$module = Common::getRequestVar('module', false);
$currentUserLogin = Piwik::getCurrentUserLogin();
// only log time for non-anonymous visits to the reporting UI
if ($module == 'API'
|| $module == 'Proxy'
|| Piwik::isUserIsAnonymous()
) {
return;
}
// get the last known time
$optionName = self::OPTION_PREFIX . $currentUserLogin;
$lastSeen = Option::get($optionName);
// do not log if last known time is less than N minutes from now (so we don't make too many
// queries)
if (time() - $lastSeen <= self::LAST_TIME_SAVE_DELTA) {
return;
}
// log last seen time (Note: autoload is important so the Option::get above does not result in
// a separate query)
Option::set($optionName, time(), $autoload = 1);
} | [
"public",
"function",
"logCurrentUserLastSeenTime",
"(",
")",
"{",
"$",
"module",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'module'",
",",
"false",
")",
";",
"$",
"currentUserLogin",
"=",
"Piwik",
"::",
"getCurrentUserLogin",
"(",
")",
";",
"// only log time ... | Saves the current time for a user as an option if the current request is for something
in the reporting UI, the current user is not anonymous and the time hasn't been saved
in the last 5 minutes. | [
"Saves",
"the",
"current",
"time",
"for",
"a",
"user",
"as",
"an",
"option",
"if",
"the",
"current",
"request",
"is",
"for",
"something",
"in",
"the",
"reporting",
"UI",
"the",
"current",
"user",
"is",
"not",
"anonymous",
"and",
"the",
"time",
"hasn",
"t... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/LastSeenTimeLogger.php#L35-L61 | train | Log the current user s last seen time | [
30522,
2270,
3853,
8833,
10841,
14343,
3372,
20330,
8523,
3215,
12129,
7292,
1006,
1007,
1063,
1002,
11336,
1027,
2691,
1024,
1024,
2131,
2890,
15500,
10755,
1006,
1005,
11336,
1005,
1010,
6270,
1007,
1025,
1002,
2783,
20330,
21197,
2378,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/controllers/Users.php | Users.formExtendFields | public function formExtendFields($form)
{
if ($form->getContext() == 'myaccount') {
return;
}
if (!$this->user->isSuperUser()) {
$form->removeField('is_superuser');
}
/*
* Add permissions tab
*/
$form->addTabFields($this->generatePermissionsField());
/*
* Mark default groups
*/
if (!$form->model->exists) {
$defaultGroupIds = UserGroup::where('is_new_user_default', true)->lists('id');
$groupField = $form->getField('groups');
$groupField->value = $defaultGroupIds;
}
} | php | public function formExtendFields($form)
{
if ($form->getContext() == 'myaccount') {
return;
}
if (!$this->user->isSuperUser()) {
$form->removeField('is_superuser');
}
/*
* Add permissions tab
*/
$form->addTabFields($this->generatePermissionsField());
/*
* Mark default groups
*/
if (!$form->model->exists) {
$defaultGroupIds = UserGroup::where('is_new_user_default', true)->lists('id');
$groupField = $form->getField('groups');
$groupField->value = $defaultGroupIds;
}
} | [
"public",
"function",
"formExtendFields",
"(",
"$",
"form",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"getContext",
"(",
")",
"==",
"'myaccount'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"user",
"->",
"isSuperUser",
"(",
")",
... | Add available permission fields to the User form.
Mark default groups as checked for new Users. | [
"Add",
"available",
"permission",
"fields",
"to",
"the",
"User",
"form",
".",
"Mark",
"default",
"groups",
"as",
"checked",
"for",
"new",
"Users",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/controllers/Users.php#L167-L191 | train | Extend form fields | [
30522,
2270,
3853,
2433,
10288,
6528,
20952,
12891,
2015,
1006,
1002,
2433,
1007,
1063,
2065,
1006,
1002,
2433,
1011,
1028,
2131,
8663,
18209,
1006,
1007,
1027,
1027,
1005,
2026,
6305,
3597,
16671,
1005,
1007,
1063,
2709,
1025,
1065,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Twig/TwigExtension.php | TwigExtension.sortByKeyFilter | public function sortByKeyFilter($input, $filter, $direction = SORT_ASC, $sort_flags = SORT_REGULAR)
{
return Utils::sortArrayByKey($input, $filter, $direction, $sort_flags);
} | php | public function sortByKeyFilter($input, $filter, $direction = SORT_ASC, $sort_flags = SORT_REGULAR)
{
return Utils::sortArrayByKey($input, $filter, $direction, $sort_flags);
} | [
"public",
"function",
"sortByKeyFilter",
"(",
"$",
"input",
",",
"$",
"filter",
",",
"$",
"direction",
"=",
"SORT_ASC",
",",
"$",
"sort_flags",
"=",
"SORT_REGULAR",
")",
"{",
"return",
"Utils",
"::",
"sortArrayByKey",
"(",
"$",
"input",
",",
"$",
"filter",... | Sorts a collection by key
@param array $input
@param string $filter
@param int $direction
@param int $sort_flags
@return array | [
"Sorts",
"a",
"collection",
"by",
"key"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TwigExtension.php#L405-L408 | train | Sort an array by a filter key | [
30522,
2270,
3853,
4066,
3762,
14839,
8873,
21928,
1006,
1002,
7953,
1010,
1002,
11307,
1010,
1002,
3257,
1027,
4066,
1035,
2004,
2278,
1010,
1002,
4066,
1035,
9245,
1027,
4066,
1035,
3180,
1007,
1063,
2709,
21183,
12146,
1024,
1024,
4066,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Map.php | Map.mergeSubtables | public function mergeSubtables()
{
$result = $this->getEmptyClone();
foreach ($this->getDataTables() as $label => $childTable) {
$result->addTable($childTable->mergeSubtables(), $label);
}
return $result;
} | php | public function mergeSubtables()
{
$result = $this->getEmptyClone();
foreach ($this->getDataTables() as $label => $childTable) {
$result->addTable($childTable->mergeSubtables(), $label);
}
return $result;
} | [
"public",
"function",
"mergeSubtables",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getEmptyClone",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getDataTables",
"(",
")",
"as",
"$",
"label",
"=>",
"$",
"childTable",
")",
"{",
"$",
"r... | Returns a new DataTable\Map w/ child tables that have had their
subtables merged.
See {@link DataTable::mergeSubtables()}.
@return Map | [
"Returns",
"a",
"new",
"DataTable",
"\\",
"Map",
"w",
"/",
"child",
"tables",
"that",
"have",
"had",
"their",
"subtables",
"merged",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Map.php#L475-L482 | train | Merge subtables of this table into a new table | [
30522,
2270,
3853,
13590,
6342,
19279,
3085,
2015,
1006,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
2131,
6633,
13876,
2100,
20464,
5643,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
2850,
29336,
3085,
2015,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php | ObjectNormalizer.extractAttributes | protected function extractAttributes($object, $format = null, array $context = [])
{
// If not using groups, detect manually
$attributes = [];
// methods
$class = ($this->objectClassResolver)($object);
$reflClass = new \ReflectionClass($class);
foreach ($reflClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflMethod) {
if (
0 !== $reflMethod->getNumberOfRequiredParameters() ||
$reflMethod->isStatic() ||
$reflMethod->isConstructor() ||
$reflMethod->isDestructor()
) {
continue;
}
$name = $reflMethod->name;
$attributeName = null;
if (0 === strpos($name, 'get') || 0 === strpos($name, 'has')) {
// getters and hassers
$attributeName = substr($name, 3);
if (!$reflClass->hasProperty($attributeName)) {
$attributeName = lcfirst($attributeName);
}
} elseif (0 === strpos($name, 'is')) {
// issers
$attributeName = substr($name, 2);
if (!$reflClass->hasProperty($attributeName)) {
$attributeName = lcfirst($attributeName);
}
}
if (null !== $attributeName && $this->isAllowedAttribute($object, $attributeName, $format, $context)) {
$attributes[$attributeName] = true;
}
}
// properties
foreach ($reflClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $reflProperty) {
if ($reflProperty->isStatic() || !$this->isAllowedAttribute($object, $reflProperty->name, $format, $context)) {
continue;
}
$attributes[$reflProperty->name] = true;
}
return array_keys($attributes);
} | php | protected function extractAttributes($object, $format = null, array $context = [])
{
// If not using groups, detect manually
$attributes = [];
// methods
$class = ($this->objectClassResolver)($object);
$reflClass = new \ReflectionClass($class);
foreach ($reflClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflMethod) {
if (
0 !== $reflMethod->getNumberOfRequiredParameters() ||
$reflMethod->isStatic() ||
$reflMethod->isConstructor() ||
$reflMethod->isDestructor()
) {
continue;
}
$name = $reflMethod->name;
$attributeName = null;
if (0 === strpos($name, 'get') || 0 === strpos($name, 'has')) {
// getters and hassers
$attributeName = substr($name, 3);
if (!$reflClass->hasProperty($attributeName)) {
$attributeName = lcfirst($attributeName);
}
} elseif (0 === strpos($name, 'is')) {
// issers
$attributeName = substr($name, 2);
if (!$reflClass->hasProperty($attributeName)) {
$attributeName = lcfirst($attributeName);
}
}
if (null !== $attributeName && $this->isAllowedAttribute($object, $attributeName, $format, $context)) {
$attributes[$attributeName] = true;
}
}
// properties
foreach ($reflClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $reflProperty) {
if ($reflProperty->isStatic() || !$this->isAllowedAttribute($object, $reflProperty->name, $format, $context)) {
continue;
}
$attributes[$reflProperty->name] = true;
}
return array_keys($attributes);
} | [
"protected",
"function",
"extractAttributes",
"(",
"$",
"object",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"// If not using groups, detect manually",
"$",
"attributes",
"=",
"[",
"]",
";",
"// methods",
"$",
"cl... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L63-L116 | train | Extract all public attributes from the object | [
30522,
5123,
3853,
14817,
19321,
3089,
8569,
4570,
1006,
1002,
4874,
1010,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
1013,
1013,
2065,
2025,
2478,
2967,
1010,
11487,
21118,
1002,
12332,
1027,
1031,
1033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Settings.php | Settings.getConfigHash | protected function getConfigHash(Request $request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java,
$plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF,
$plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip,
$browserLang)
{
// prevent the config hash from being the same, across different Piwik instances
// (limits ability of different Piwik instances to cross-match users)
$salt = SettingsPiwik::getSalt();
$configString =
$os
. $browserName . $browserVersion
. $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF
. $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie
. $ip
. $browserLang
. $salt;
if (!$this->isSameFingerprintsAcrossWebsites) {
$configString .= $request->getIdSite();
}
$hash = md5($configString, $raw_output = true);
return substr($hash, 0, Tracker::LENGTH_BINARY_ID);
} | php | protected function getConfigHash(Request $request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java,
$plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF,
$plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip,
$browserLang)
{
// prevent the config hash from being the same, across different Piwik instances
// (limits ability of different Piwik instances to cross-match users)
$salt = SettingsPiwik::getSalt();
$configString =
$os
. $browserName . $browserVersion
. $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF
. $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie
. $ip
. $browserLang
. $salt;
if (!$this->isSameFingerprintsAcrossWebsites) {
$configString .= $request->getIdSite();
}
$hash = md5($configString, $raw_output = true);
return substr($hash, 0, Tracker::LENGTH_BINARY_ID);
} | [
"protected",
"function",
"getConfigHash",
"(",
"Request",
"$",
"request",
",",
"$",
"os",
",",
"$",
"browserName",
",",
"$",
"browserVersion",
",",
"$",
"plugin_Flash",
",",
"$",
"plugin_Java",
",",
"$",
"plugin_Director",
",",
"$",
"plugin_Quicktime",
",",
... | Returns a 64-bit hash that attemps to identify a user.
Maintaining some privacy by default, eg. prevents the merging of several Piwik serve together for matching across instances..
@param $os
@param $browserName
@param $browserVersion
@param $plugin_Flash
@param $plugin_Java
@param $plugin_Director
@param $plugin_Quicktime
@param $plugin_RealPlayer
@param $plugin_PDF
@param $plugin_WindowsMedia
@param $plugin_Gears
@param $plugin_Silverlight
@param $plugin_Cookie
@param $ip
@param $browserLang
@return string | [
"Returns",
"a",
"64",
"-",
"bit",
"hash",
"that",
"attemps",
"to",
"identify",
"a",
"user",
".",
"Maintaining",
"some",
"privacy",
"by",
"default",
"eg",
".",
"prevents",
"the",
"merging",
"of",
"several",
"Piwik",
"serve",
"together",
"for",
"matching",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Settings.php#L100-L125 | train | Generate a hash of the config string | [
30522,
5123,
3853,
2131,
8663,
8873,
5603,
11823,
1006,
5227,
1002,
5227,
1010,
1002,
9808,
1010,
1002,
16602,
18442,
1010,
1002,
16602,
27774,
1010,
1002,
13354,
2378,
1035,
5956,
1010,
1002,
13354,
2378,
1035,
9262,
1010,
1002,
13354,
237... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Console/Gpm/InstallCommand.php | InstallCommand.installDependencies | public function installDependencies($dependencies, $type, $message, $required = true)
{
$packages = array_filter($dependencies, function ($action) use ($type) { return $action === $type; });
if (\count($packages) > 0) {
$this->output->writeln($message);
foreach ($packages as $dependencyName => $dependencyVersion) {
$this->output->writeln(" |- Package <cyan>{$dependencyName}</cyan>");
}
$this->output->writeln('');
$helper = $this->getHelper('question');
if ($type === 'install') {
$questionAction = 'Install';
} else {
$questionAction = 'Update';
}
if (\count($packages) === 1) {
$questionArticle = 'this';
} else {
$questionArticle = 'these';
}
if (\count($packages) === 1) {
$questionNoun = 'package';
} else {
$questionNoun = 'packages';
}
$question = new ConfirmationQuestion("${questionAction} {$questionArticle} {$questionNoun}? [Y|n] ", true);
$answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question);
if ($answer) {
foreach ($packages as $dependencyName => $dependencyVersion) {
$package = $this->gpm->findPackage($dependencyName);
$this->processPackage($package, $type === 'update');
}
$this->output->writeln('');
} else {
if ($required) {
throw new \Exception();
}
}
}
} | php | public function installDependencies($dependencies, $type, $message, $required = true)
{
$packages = array_filter($dependencies, function ($action) use ($type) { return $action === $type; });
if (\count($packages) > 0) {
$this->output->writeln($message);
foreach ($packages as $dependencyName => $dependencyVersion) {
$this->output->writeln(" |- Package <cyan>{$dependencyName}</cyan>");
}
$this->output->writeln('');
$helper = $this->getHelper('question');
if ($type === 'install') {
$questionAction = 'Install';
} else {
$questionAction = 'Update';
}
if (\count($packages) === 1) {
$questionArticle = 'this';
} else {
$questionArticle = 'these';
}
if (\count($packages) === 1) {
$questionNoun = 'package';
} else {
$questionNoun = 'packages';
}
$question = new ConfirmationQuestion("${questionAction} {$questionArticle} {$questionNoun}? [Y|n] ", true);
$answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question);
if ($answer) {
foreach ($packages as $dependencyName => $dependencyVersion) {
$package = $this->gpm->findPackage($dependencyName);
$this->processPackage($package, $type === 'update');
}
$this->output->writeln('');
} else {
if ($required) {
throw new \Exception();
}
}
}
} | [
"public",
"function",
"installDependencies",
"(",
"$",
"dependencies",
",",
"$",
"type",
",",
"$",
"message",
",",
"$",
"required",
"=",
"true",
")",
"{",
"$",
"packages",
"=",
"array_filter",
"(",
"$",
"dependencies",
",",
"function",
"(",
"$",
"action",
... | Given a $dependencies list, filters their type according to $type and
shows $message prior to listing them to the user. Then asks the user a confirmation prior
to installing them.
@param array $dependencies The dependencies array
@param string $type The type of dependency to show: install, update, ignore
@param string $message A message to be shown prior to listing the dependencies
@param bool $required A flag that determines if the installation is required or optional
@throws \Exception | [
"Given",
"a",
"$dependencies",
"list",
"filters",
"their",
"type",
"according",
"to",
"$type",
"and",
"shows",
"$message",
"prior",
"to",
"listing",
"them",
"to",
"the",
"user",
".",
"Then",
"asks",
"the",
"user",
"a",
"confirmation",
"prior",
"to",
"install... | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/Gpm/InstallCommand.php#L271-L318 | train | Installs packages that depend on a specific type | [
30522,
2270,
3853,
16500,
3207,
11837,
4181,
9243,
1006,
1002,
12530,
15266,
1010,
1002,
2828,
1010,
1002,
4471,
1010,
1002,
3223,
1027,
2995,
1007,
1063,
1002,
14555,
1027,
9140,
1035,
11307,
1006,
1002,
12530,
15266,
1010,
3853,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Lock/Store/ZookeeperStore.php | ZookeeperStore.save | public function save(Key $key)
{
if ($this->exists($key)) {
return;
}
$resource = $this->getKeyResource($key);
$token = $this->getUniqueToken($key);
$this->createNewLock($resource, $token);
} | php | public function save(Key $key)
{
if ($this->exists($key)) {
return;
}
$resource = $this->getKeyResource($key);
$token = $this->getUniqueToken($key);
$this->createNewLock($resource, $token);
} | [
"public",
"function",
"save",
"(",
"Key",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"key",
")",
")",
"{",
"return",
";",
"}",
"$",
"resource",
"=",
"$",
"this",
"->",
"getKeyResource",
"(",
"$",
"key",
")",
";",
"$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Store/ZookeeperStore.php#L38-L48 | train | Save a key to the cache | [
30522,
2270,
3853,
3828,
1006,
3145,
1002,
3145,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
6526,
1006,
1002,
3145,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
7692,
1027,
1002,
2023,
1011,
1028,
2131,
14839,
6072,
8162,
3401,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/MediaLibrary.php | MediaLibrary.deleteFiles | public function deleteFiles($paths)
{
$fullPaths = [];
foreach ($paths as $path) {
$path = self::validatePath($path);
$fullPaths[] = $this->getMediaPath($path);
}
return $this->getStorageDisk()->delete($fullPaths);
} | php | public function deleteFiles($paths)
{
$fullPaths = [];
foreach ($paths as $path) {
$path = self::validatePath($path);
$fullPaths[] = $this->getMediaPath($path);
}
return $this->getStorageDisk()->delete($fullPaths);
} | [
"public",
"function",
"deleteFiles",
"(",
"$",
"paths",
")",
"{",
"$",
"fullPaths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"validatePath",
"(",
"$",
"path",
")",
";",
"$",
"f... | Deletes a file from the Library.
@param array $paths A list of file paths relative to the Library root to delete. | [
"Deletes",
"a",
"file",
"from",
"the",
"Library",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L209-L218 | train | Delete files from the media directory | [
30522,
2270,
3853,
3972,
12870,
8873,
4244,
1006,
1002,
10425,
1007,
1063,
1002,
2440,
15069,
2015,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
10425,
2004,
1002,
4130,
1007,
1063,
1002,
4130,
1027,
2969,
1024,
1024,
9398,
3686,
15069,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DataUriNormalizer.php | DataUriNormalizer.denormalize | public function denormalize($data, $class, $format = null, array $context = [])
{
if (!preg_match('/^data:([a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}\/[a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
throw new NotNormalizableValueException('The provided "data:" URI is not valid.');
}
try {
switch ($class) {
case 'Symfony\Component\HttpFoundation\File\File':
return new File($data, false);
case 'SplFileObject':
case 'SplFileInfo':
return new \SplFileObject($data);
}
} catch (\RuntimeException $exception) {
throw new NotNormalizableValueException($exception->getMessage(), $exception->getCode(), $exception);
}
throw new InvalidArgumentException(sprintf('The class parameter "%s" is not supported. It must be one of "SplFileInfo", "SplFileObject" or "Symfony\Component\HttpFoundation\File\File".', $class));
} | php | public function denormalize($data, $class, $format = null, array $context = [])
{
if (!preg_match('/^data:([a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}\/[a-z0-9][a-z0-9\!\#\$\&\-\^\_\+\.]{0,126}(;[a-z0-9\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\\\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i', $data)) {
throw new NotNormalizableValueException('The provided "data:" URI is not valid.');
}
try {
switch ($class) {
case 'Symfony\Component\HttpFoundation\File\File':
return new File($data, false);
case 'SplFileObject':
case 'SplFileInfo':
return new \SplFileObject($data);
}
} catch (\RuntimeException $exception) {
throw new NotNormalizableValueException($exception->getMessage(), $exception->getCode(), $exception);
}
throw new InvalidArgumentException(sprintf('The class parameter "%s" is not supported. It must be one of "SplFileInfo", "SplFileObject" or "Symfony\Component\HttpFoundation\File\File".', $class));
} | [
"public",
"function",
"denormalize",
"(",
"$",
"data",
",",
"$",
"class",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^data:([a-z0-9][a-z0-9\\!\\#\\$\\&\\-\\^\\_\\+\\.]{0,126}\\/... | {@inheritdoc}
Regex adapted from Brian Grinstead code.
@see https://gist.github.com/bgrins/6194623
@throws InvalidArgumentException
@throws NotNormalizableValueException | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/DataUriNormalizer.php#L106-L126 | train | Denormalizes the provided data into a file object | [
30522,
2270,
3853,
7939,
2953,
9067,
4697,
1006,
1002,
2951,
1010,
1002,
2465,
1010,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
999,
3653,
2290,
1035,
2674,
1006,
1005,
1013,
1034,
2951,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/controllers/Users.php | Users.formExtendQuery | public function formExtendQuery($query)
{
if (!$this->user->isSuperUser()) {
$query->where('is_superuser', false);
}
// Ensure soft-deleted records can still be managed
$query->withTrashed();
} | php | public function formExtendQuery($query)
{
if (!$this->user->isSuperUser()) {
$query->where('is_superuser', false);
}
// Ensure soft-deleted records can still be managed
$query->withTrashed();
} | [
"public",
"function",
"formExtendQuery",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"user",
"->",
"isSuperUser",
"(",
")",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'is_superuser'",
",",
"false",
")",
";",
"}",
"// Ensure soft-d... | Extends the form query to prevent non-superusers from accessing superusers at all | [
"Extends",
"the",
"form",
"query",
"to",
"prevent",
"non",
"-",
"superusers",
"from",
"accessing",
"superusers",
"at",
"all"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/controllers/Users.php#L98-L106 | train | Form extend query | [
30522,
2270,
3853,
2433,
10288,
6528,
2094,
4226,
2854,
1006,
1002,
23032,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
5310,
1011,
1028,
26354,
6279,
21608,
2121,
1006,
1007,
1007,
1063,
1002,
23032,
1011,
1028,
2073,
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... |
symfony/symfony | src/Symfony/Component/Form/FormError.php | FormError.setOrigin | public function setOrigin(FormInterface $origin)
{
if (null !== $this->origin) {
throw new BadMethodCallException('setOrigin() must only be called once.');
}
$this->origin = $origin;
} | php | public function setOrigin(FormInterface $origin)
{
if (null !== $this->origin) {
throw new BadMethodCallException('setOrigin() must only be called once.');
}
$this->origin = $origin;
} | [
"public",
"function",
"setOrigin",
"(",
"FormInterface",
"$",
"origin",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"origin",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'setOrigin() must only be called once.'",
")",
";",
"}",
"$",
"th... | Sets the form that caused this error.
This method must only be called once.
@param FormInterface $origin The form that caused this error
@throws BadMethodCallException If the method is called more than once | [
"Sets",
"the",
"form",
"that",
"caused",
"this",
"error",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormError.php#L118-L125 | train | Set the origin | [
30522,
2270,
3853,
2275,
10050,
11528,
1006,
2433,
18447,
2121,
12172,
1002,
4761,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
4761,
1007,
1063,
5466,
2047,
2919,
11368,
6806,
16409,
24164,
2595,
24422,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Controller.php | HTML_QuickForm2_Controller.getPage | public function getPage($pageId)
{
if (!empty($this->pages[$pageId])) {
return $this->pages[$pageId];
} else {
throw new HTML_QuickForm2_NotFoundException(
"Unknown page '{$pageId}'"
);
}
} | php | public function getPage($pageId)
{
if (!empty($this->pages[$pageId])) {
return $this->pages[$pageId];
} else {
throw new HTML_QuickForm2_NotFoundException(
"Unknown page '{$pageId}'"
);
}
} | [
"public",
"function",
"getPage",
"(",
"$",
"pageId",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"pages",
"[",
"$",
"pageId",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"pages",
"[",
"$",
"pageId",
"]",
";",
"}",
"else",
"{... | Returns a page
@param string Page ID
@return HTML_QuickForm2_Controller_Page
@throws HTML_QuickForm2_NotFoundException if there is no page with
the given ID | [
"Returns",
"a",
"page"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Controller.php#L337-L346 | train | Returns the page object | [
30522,
2270,
3853,
2131,
13704,
1006,
1002,
3931,
3593,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
2023,
1011,
1028,
5530,
1031,
1002,
3931,
3593,
1033,
1007,
1007,
1063,
2709,
1002,
30524,
1000,
4242,
3931,
1005,
1063,
1002,
3931,
35... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php | CompiledUrlGeneratorDumper.generateDeclaredRoutes | private function generateDeclaredRoutes(): string
{
$routes = '';
foreach ($this->getCompiledRoutes() as $name => $properties) {
$routes .= sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
}
return $routes;
} | php | private function generateDeclaredRoutes(): string
{
$routes = '';
foreach ($this->getCompiledRoutes() as $name => $properties) {
$routes .= sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
}
return $routes;
} | [
"private",
"function",
"generateDeclaredRoutes",
"(",
")",
":",
"string",
"{",
"$",
"routes",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCompiledRoutes",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"properties",
")",
"{",
"$",
"routes",
".=",
"... | Generates PHP code representing an array of defined routes
together with the routes properties (e.g. requirements). | [
"Generates",
"PHP",
"code",
"representing",
"an",
"array",
"of",
"defined",
"routes",
"together",
"with",
"the",
"routes",
"properties",
"(",
"e",
".",
"g",
".",
"requirements",
")",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php#L64-L72 | train | Generate declared routes | [
30522,
2797,
3853,
7013,
8586,
8017,
2098,
22494,
4570,
1006,
1007,
1024,
5164,
1063,
1002,
5847,
1027,
1005,
1005,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
9006,
22090,
22196,
10421,
2015,
1006,
1007,
2004,
1002,
2171,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.validateDateTimeValue | protected function validateDateTimeValue($value, $column)
{
$value = DateTimeHelper::makeCarbon($value, false);
if (!$value instanceof Carbon) {
throw new ApplicationException(Lang::get(
'backend::lang.list.invalid_column_datetime',
['column' => $column->columnName]
));
}
return $value;
} | php | protected function validateDateTimeValue($value, $column)
{
$value = DateTimeHelper::makeCarbon($value, false);
if (!$value instanceof Carbon) {
throw new ApplicationException(Lang::get(
'backend::lang.list.invalid_column_datetime',
['column' => $column->columnName]
));
}
return $value;
} | [
"protected",
"function",
"validateDateTimeValue",
"(",
"$",
"value",
",",
"$",
"column",
")",
"{",
"$",
"value",
"=",
"DateTimeHelper",
"::",
"makeCarbon",
"(",
"$",
"value",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"Carbon",
"... | Validates a column type as a date | [
"Validates",
"a",
"column",
"type",
"as",
"a",
"date"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1359-L1371 | train | Validate a column value as a Carbon object | [
30522,
5123,
3853,
9398,
4383,
3686,
7292,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
5930,
1007,
1063,
1002,
3643,
1027,
3058,
7292,
16001,
4842,
1024,
1024,
2191,
26190,
1006,
1002,
3643,
1010,
6270,
1007,
1025,
2065,
1006,
999,
1002,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/AuthManager.php | AuthManager.createTokenDriver | public function createTokenDriver($name, $config)
{
// The token guard implements a basic API token based guard implementation
// that takes an API token field from the request and matches it to the
// user in the database or another persistence layer where users are.
$guard = new TokenGuard(
$this->createUserProvider($config['provider'] ?? null),
$this->app['request'],
$config['input_key'] ?? 'api_token',
$config['storage_key'] ?? 'api_token',
$config['hash'] ?? false
);
$this->app->refresh('request', $guard, 'setRequest');
return $guard;
} | php | public function createTokenDriver($name, $config)
{
// The token guard implements a basic API token based guard implementation
// that takes an API token field from the request and matches it to the
// user in the database or another persistence layer where users are.
$guard = new TokenGuard(
$this->createUserProvider($config['provider'] ?? null),
$this->app['request'],
$config['input_key'] ?? 'api_token',
$config['storage_key'] ?? 'api_token',
$config['hash'] ?? false
);
$this->app->refresh('request', $guard, 'setRequest');
return $guard;
} | [
"public",
"function",
"createTokenDriver",
"(",
"$",
"name",
",",
"$",
"config",
")",
"{",
"// The token guard implements a basic API token based guard implementation",
"// that takes an API token field from the request and matches it to the",
"// user in the database or another persistenc... | Create a token based authentication guard.
@param string $name
@param array $config
@return \Illuminate\Auth\TokenGuard | [
"Create",
"a",
"token",
"based",
"authentication",
"guard",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/AuthManager.php#L152-L168 | train | Create a token guard | [
30522,
2270,
3853,
3443,
18715,
10497,
24352,
1006,
1002,
2171,
1010,
1002,
9530,
8873,
2290,
1007,
1063,
1013,
1013,
1996,
19204,
3457,
22164,
1037,
3937,
17928,
19204,
2241,
3457,
7375,
1013,
1013,
2008,
3138,
2019,
17928,
19204,
2492,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.cloneWithout | public function cloneWithout(array $properties)
{
return tap(clone $this, function ($clone) use ($properties) {
foreach ($properties as $property) {
$clone->{$property} = null;
}
});
} | php | public function cloneWithout(array $properties)
{
return tap(clone $this, function ($clone) use ($properties) {
foreach ($properties as $property) {
$clone->{$property} = null;
}
});
} | [
"public",
"function",
"cloneWithout",
"(",
"array",
"$",
"properties",
")",
"{",
"return",
"tap",
"(",
"clone",
"$",
"this",
",",
"function",
"(",
"$",
"clone",
")",
"use",
"(",
"$",
"properties",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",... | Clone the query without the given properties.
@param array $properties
@return static | [
"Clone",
"the",
"query",
"without",
"the",
"given",
"properties",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L2957-L2964 | train | Clone the current object without the given properties. | [
30522,
2270,
3853,
17598,
24415,
5833,
1006,
9140,
1002,
5144,
1007,
1063,
2709,
11112,
1006,
17598,
1002,
2023,
1010,
3853,
1006,
1002,
17598,
1007,
2224,
1006,
1002,
5144,
1007,
1063,
18921,
6776,
1006,
1002,
5144,
2004,
1002,
3200,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Db/Mysqli.php | Mysqli.connect | public function connect()
{
if (self::$profiling) {
$timer = $this->initProfiler();
}
$this->connection = mysqli_init();
if($this->enable_ssl){
mysqli_ssl_set($this->connection, $this->ssl_key, $this->ssl_cert, $this->ssl_ca, $this->ssl_ca_path, $this->ssl_cipher);
}
// Make sure MySQL returns all matched rows on update queries including
// rows that actually didn't have to be updated because the values didn't
// change. This matches common behaviour among other database systems.
// See #6296 why this is important in tracker
$flags = MYSQLI_CLIENT_FOUND_ROWS;
if ($this->enable_ssl){
$flags = $flags | MYSQLI_CLIENT_SSL;
}
if ($this->ssl_no_verify && defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT')){
$flags = $flags | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
}
mysqli_real_connect($this->connection, $this->host, $this->username, $this->password, $this->dbname, $this->port, $this->socket, $flags);
if (!$this->connection || mysqli_connect_errno()) {
throw new DbException("Connect failed: " . mysqli_connect_error());
}
if ($this->charset && !mysqli_set_charset($this->connection, $this->charset)) {
throw new DbException("Set Charset failed: " . mysqli_error($this->connection));
}
$this->password = '';
if (self::$profiling && isset($timer)) {
$this->recordQueryProfile('connect', $timer);
}
} | php | public function connect()
{
if (self::$profiling) {
$timer = $this->initProfiler();
}
$this->connection = mysqli_init();
if($this->enable_ssl){
mysqli_ssl_set($this->connection, $this->ssl_key, $this->ssl_cert, $this->ssl_ca, $this->ssl_ca_path, $this->ssl_cipher);
}
// Make sure MySQL returns all matched rows on update queries including
// rows that actually didn't have to be updated because the values didn't
// change. This matches common behaviour among other database systems.
// See #6296 why this is important in tracker
$flags = MYSQLI_CLIENT_FOUND_ROWS;
if ($this->enable_ssl){
$flags = $flags | MYSQLI_CLIENT_SSL;
}
if ($this->ssl_no_verify && defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT')){
$flags = $flags | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
}
mysqli_real_connect($this->connection, $this->host, $this->username, $this->password, $this->dbname, $this->port, $this->socket, $flags);
if (!$this->connection || mysqli_connect_errno()) {
throw new DbException("Connect failed: " . mysqli_connect_error());
}
if ($this->charset && !mysqli_set_charset($this->connection, $this->charset)) {
throw new DbException("Set Charset failed: " . mysqli_error($this->connection));
}
$this->password = '';
if (self::$profiling && isset($timer)) {
$this->recordQueryProfile('connect', $timer);
}
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"profiling",
")",
"{",
"$",
"timer",
"=",
"$",
"this",
"->",
"initProfiler",
"(",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"=",
"mysqli_init",
"(",
")",
";",
"if",... | Connects to the DB
@throws Exception|DbException if there was an error connecting the DB | [
"Connects",
"to",
"the",
"DB"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Db/Mysqli.php#L102-L140 | train | Connects to the database and sets the connection to the database | [
30522,
2270,
3853,
7532,
1006,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
1002,
30524,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
9585,
1035,
7020,
2140,
1007,
1063,
2026,
2015,
4160,
3669,
1035,
7020,
2140,
1035,
2275,
1006,
1002,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php | AnnotationFileLoader.findClass | protected function findClass($file)
{
$class = false;
$namespace = false;
$tokens = token_get_all(file_get_contents($file));
if (1 === \count($tokens) && T_INLINE_HTML === $tokens[0][0]) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain PHP code. Did you forgot to add the "<?php" start tag at the beginning of the file?', $file));
}
for ($i = 0; isset($tokens[$i]); ++$i) {
$token = $tokens[$i];
if (!isset($token[1])) {
continue;
}
if (true === $class && T_STRING === $token[0]) {
return $namespace.'\\'.$token[1];
}
if (true === $namespace && T_STRING === $token[0]) {
$namespace = $token[1];
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING])) {
$namespace .= $tokens[$i][1];
}
$token = $tokens[$i];
}
if (T_CLASS === $token[0]) {
// Skip usage of ::class constant and anonymous classes
$skipClassToken = false;
for ($j = $i - 1; $j > 0; --$j) {
if (!isset($tokens[$j][1])) {
break;
}
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
$skipClassToken = true;
break;
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
break;
}
}
if (!$skipClassToken) {
$class = true;
}
}
if (T_NAMESPACE === $token[0]) {
$namespace = true;
}
}
return false;
} | php | protected function findClass($file)
{
$class = false;
$namespace = false;
$tokens = token_get_all(file_get_contents($file));
if (1 === \count($tokens) && T_INLINE_HTML === $tokens[0][0]) {
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain PHP code. Did you forgot to add the "<?php" start tag at the beginning of the file?', $file));
}
for ($i = 0; isset($tokens[$i]); ++$i) {
$token = $tokens[$i];
if (!isset($token[1])) {
continue;
}
if (true === $class && T_STRING === $token[0]) {
return $namespace.'\\'.$token[1];
}
if (true === $namespace && T_STRING === $token[0]) {
$namespace = $token[1];
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING])) {
$namespace .= $tokens[$i][1];
}
$token = $tokens[$i];
}
if (T_CLASS === $token[0]) {
// Skip usage of ::class constant and anonymous classes
$skipClassToken = false;
for ($j = $i - 1; $j > 0; --$j) {
if (!isset($tokens[$j][1])) {
break;
}
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
$skipClassToken = true;
break;
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
break;
}
}
if (!$skipClassToken) {
$class = true;
}
}
if (T_NAMESPACE === $token[0]) {
$namespace = true;
}
}
return false;
} | [
"protected",
"function",
"findClass",
"(",
"$",
"file",
")",
"{",
"$",
"class",
"=",
"false",
";",
"$",
"namespace",
"=",
"false",
";",
"$",
"tokens",
"=",
"token_get_all",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
";",
"if",
"(",
"1",
"=... | Returns the full class name for the first class in the file.
@param string $file A PHP file path
@return string|false Full class name if found, false otherwise | [
"Returns",
"the",
"full",
"class",
"name",
"for",
"the",
"first",
"class",
"in",
"the",
"file",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php#L88-L144 | train | Finds the class name of the class in the file | [
30522,
5123,
3853,
2424,
26266,
1006,
1002,
5371,
1007,
1063,
1002,
2465,
1027,
6270,
1025,
1002,
3415,
15327,
1027,
6270,
1025,
1002,
19204,
2015,
1027,
19204,
1035,
2131,
1035,
2035,
1006,
5371,
1035,
2131,
1035,
8417,
1006,
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... |
z-song/laravel-admin | src/Form/Field/HasMany.php | HasMany.getKeyName | protected function getKeyName()
{
if (is_null($this->form)) {
return;
}
return $this->form->model()->{$this->relationName}()->getRelated()->getKeyName();
} | php | protected function getKeyName()
{
if (is_null($this->form)) {
return;
}
return $this->form->model()->{$this->relationName}()->getRelated()->getKeyName();
} | [
"protected",
"function",
"getKeyName",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"form",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"form",
"->",
"model",
"(",
")",
"->",
"{",
"$",
"this",
"->",
"relationName... | Get the HasMany relation key name.
@return string | [
"Get",
"the",
"HasMany",
"relation",
"key",
"name",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/HasMany.php#L307-L314 | train | Get the foreign key name of the related model | [
30522,
5123,
3853,
2131,
14839,
18442,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
2433,
1007,
1007,
1063,
2709,
1025,
1065,
2709,
1002,
2023,
1011,
1028,
2433,
1011,
1028,
2944,
1006,
1007,
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... |
dompdf/dompdf | src/Adapter/CPDF.php | CPDF._set_stroke_color | protected function _set_stroke_color($color)
{
$this->_pdf->setStrokeColor($color);
$alpha = isset($color["alpha"]) ? $color["alpha"] : 1;
if ($this->_current_opacity != 1) {
$alpha *= $this->_current_opacity;
}
$this->_set_line_transparency("Normal", $alpha);
} | php | protected function _set_stroke_color($color)
{
$this->_pdf->setStrokeColor($color);
$alpha = isset($color["alpha"]) ? $color["alpha"] : 1;
if ($this->_current_opacity != 1) {
$alpha *= $this->_current_opacity;
}
$this->_set_line_transparency("Normal", $alpha);
} | [
"protected",
"function",
"_set_stroke_color",
"(",
"$",
"color",
")",
"{",
"$",
"this",
"->",
"_pdf",
"->",
"setStrokeColor",
"(",
"$",
"color",
")",
";",
"$",
"alpha",
"=",
"isset",
"(",
"$",
"color",
"[",
"\"alpha\"",
"]",
")",
"?",
"$",
"color",
"... | Sets the stroke color
See {@link Style::set_color()} for the format of the color array.
@param array $color | [
"Sets",
"the",
"stroke",
"color"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/CPDF.php#L436-L444 | train | Set the stroke color and line transparency for the current page | [
30522,
5123,
3853,
1035,
2275,
1035,
6909,
1035,
3609,
1006,
1002,
3609,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
11135,
1011,
1028,
4520,
13181,
3489,
18717,
1006,
1002,
3609,
1007,
1025,
1002,
6541,
1027,
26354,
3388,
1006,
1002,
3609,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Collection/AbstractIndexCollection.php | AbstractIndexCollection.slice | public function slice($offset, $length = null)
{
return $this->loadElements(\array_slice($this->entries, $offset, $length, true));
} | php | public function slice($offset, $length = null)
{
return $this->loadElements(\array_slice($this->entries, $offset, $length, true));
} | [
"public",
"function",
"slice",
"(",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"loadElements",
"(",
"\\",
"array_slice",
"(",
"$",
"this",
"->",
"entries",
",",
"$",
"offset",
",",
"$",
"length",
",",
"true... | {@inheritDoc} | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Collection/AbstractIndexCollection.php#L341-L344 | train | Returns a slice of the entries | [
30522,
2270,
3853,
14704,
1006,
1002,
16396,
1010,
1002,
3091,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7170,
12260,
8163,
1006,
1032,
9140,
1035,
14704,
1006,
1002,
2023,
1011,
1028,
10445,
1010,
1002,
16396,
1010,
1002,
3091... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getAjaxHandler | public function getAjaxHandler()
{
if (!Request::ajax() || Request::method() != 'POST') {
return null;
}
if ($handler = Request::header('X_OCTOBER_REQUEST_HANDLER')) {
return trim($handler);
}
return null;
} | php | public function getAjaxHandler()
{
if (!Request::ajax() || Request::method() != 'POST') {
return null;
}
if ($handler = Request::header('X_OCTOBER_REQUEST_HANDLER')) {
return trim($handler);
}
return null;
} | [
"public",
"function",
"getAjaxHandler",
"(",
")",
"{",
"if",
"(",
"!",
"Request",
"::",
"ajax",
"(",
")",
"||",
"Request",
"::",
"method",
"(",
")",
"!=",
"'POST'",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"handler",
"=",
"Request",
":... | Returns the AJAX handler for the current request, if available.
@return string | [
"Returns",
"the",
"AJAX",
"handler",
"for",
"the",
"current",
"request",
"if",
"available",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Controller.php#L691-L702 | train | Get the X_OCTOBER_REQUEST_HANDLER value if ajax is enabled | [
30522,
2270,
3853,
2131,
22734,
2595,
11774,
3917,
1006,
1007,
1063,
2065,
1006,
999,
5227,
1024,
1024,
18176,
1006,
1007,
1064,
1064,
5227,
1024,
1024,
4118,
1006,
1007,
999,
1027,
1005,
2695,
1005,
1007,
1063,
2709,
19701,
1025,
1065,
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/Config/Writer/Xml.php | Zend_Config_Writer_Xml._addBranch | protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
{
$branchType = null;
foreach ($config as $key => $value) {
if ($branchType === null) {
if (is_numeric($key)) {
$branchType = 'numeric';
$branchName = $xml->getName();
$xml = $parent;
unset($parent->{$branchName});
} else {
$branchType = 'string';
}
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
// require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
}
if ($branchType === 'numeric') {
if ($value instanceof Zend_Config) {
$child = $parent->addChild($branchName);
$this->_addBranch($value, $child, $parent);
} else {
$parent->addChild($branchName, (string) $value);
}
} else {
if ($value instanceof Zend_Config) {
$child = $xml->addChild($key);
$this->_addBranch($value, $child, $xml);
} else {
$xml->addChild($key, (string) $value);
}
}
}
} | php | protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
{
$branchType = null;
foreach ($config as $key => $value) {
if ($branchType === null) {
if (is_numeric($key)) {
$branchType = 'numeric';
$branchName = $xml->getName();
$xml = $parent;
unset($parent->{$branchName});
} else {
$branchType = 'string';
}
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
// require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
}
if ($branchType === 'numeric') {
if ($value instanceof Zend_Config) {
$child = $parent->addChild($branchName);
$this->_addBranch($value, $child, $parent);
} else {
$parent->addChild($branchName, (string) $value);
}
} else {
if ($value instanceof Zend_Config) {
$child = $xml->addChild($key);
$this->_addBranch($value, $child, $xml);
} else {
$xml->addChild($key, (string) $value);
}
}
}
} | [
"protected",
"function",
"_addBranch",
"(",
"Zend_Config",
"$",
"config",
",",
"SimpleXMLElement",
"$",
"xml",
",",
"SimpleXMLElement",
"$",
"parent",
")",
"{",
"$",
"branchType",
"=",
"null",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$"... | Add a branch to an XML object recursively
@param Zend_Config $config
@param SimpleXMLElement $xml
@param SimpleXMLElement $parent
@return void | [
"Add",
"a",
"branch",
"to",
"an",
"XML",
"object",
"recursively"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer/Xml.php#L88-L126 | train | Add branch to XML | [
30522,
5123,
3853,
1035,
5587,
10024,
12680,
30524,
12260,
3672,
1002,
20950,
1010,
3722,
2595,
19968,
12260,
3672,
1002,
6687,
1007,
1063,
1002,
3589,
13874,
1027,
19701,
1025,
18921,
6776,
1006,
1002,
9530,
8873,
2290,
2004,
1002,
3145,
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/Container/Container.php | Container.resolvePrimitive | protected function resolvePrimitive(ReflectionParameter $parameter)
{
if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->name))) {
return $concrete instanceof Closure ? $concrete($this) : $concrete;
}
if ($parameter->isDefaultValueAvailable()) {
return $parameter->getDefaultValue();
}
$this->unresolvablePrimitive($parameter);
} | php | protected function resolvePrimitive(ReflectionParameter $parameter)
{
if (! is_null($concrete = $this->getContextualConcrete('$'.$parameter->name))) {
return $concrete instanceof Closure ? $concrete($this) : $concrete;
}
if ($parameter->isDefaultValueAvailable()) {
return $parameter->getDefaultValue();
}
$this->unresolvablePrimitive($parameter);
} | [
"protected",
"function",
"resolvePrimitive",
"(",
"ReflectionParameter",
"$",
"parameter",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"concrete",
"=",
"$",
"this",
"->",
"getContextualConcrete",
"(",
"'$'",
".",
"$",
"parameter",
"->",
"name",
")",
")",
... | Resolve a non-class hinted primitive dependency.
@param \ReflectionParameter $parameter
@return mixed
@throws \Illuminate\Contracts\Container\BindingResolutionException | [
"Resolve",
"a",
"non",
"-",
"class",
"hinted",
"primitive",
"dependency",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L901-L912 | train | Resolves a primitive value. | [
30522,
5123,
3853,
10663,
18098,
27605,
6024,
1006,
9185,
28689,
22828,
1002,
16381,
1007,
1063,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
5509,
1027,
1002,
2023,
1011,
1028,
2131,
8663,
18209,
8787,
8663,
16748,
2618,
1006,
1005,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Manager.php | Manager.getPluginsLoadedAndActivated | public function getPluginsLoadedAndActivated()
{
if (is_null($this->pluginsLoadedAndActivated)) {
$enabled = $this->getActivatedPlugins();
if (empty($enabled)) {
return array();
}
$plugins = $this->getLoadedPlugins();
$enabled = array_combine($enabled, $enabled);
$plugins = array_intersect_key($plugins, $enabled);
$this->pluginsLoadedAndActivated = $plugins;
}
return $this->pluginsLoadedAndActivated;
} | php | public function getPluginsLoadedAndActivated()
{
if (is_null($this->pluginsLoadedAndActivated)) {
$enabled = $this->getActivatedPlugins();
if (empty($enabled)) {
return array();
}
$plugins = $this->getLoadedPlugins();
$enabled = array_combine($enabled, $enabled);
$plugins = array_intersect_key($plugins, $enabled);
$this->pluginsLoadedAndActivated = $plugins;
}
return $this->pluginsLoadedAndActivated;
} | [
"public",
"function",
"getPluginsLoadedAndActivated",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"pluginsLoadedAndActivated",
")",
")",
"{",
"$",
"enabled",
"=",
"$",
"this",
"->",
"getActivatedPlugins",
"(",
")",
";",
"if",
"(",
"empty",
... | Returns an array of plugins that are currently loaded and activated,
mapping loaded plugin names with their plugin objects, eg,
array(
'UserCountry' => Plugin $pluginObject,
'UserLanguage' => Plugin $pluginObject,
);
@return Plugin[] | [
"Returns",
"an",
"array",
"of",
"plugins",
"that",
"are",
"currently",
"loaded",
"and",
"activated",
"mapping",
"loaded",
"plugin",
"names",
"with",
"their",
"plugin",
"objects",
"eg"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Manager.php#L947-L964 | train | Get all plugins that are loaded and activated | [
30522,
2270,
3853,
2131,
24759,
15916,
7076,
17468,
13832,
6593,
21967,
1006,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2023,
1011,
1028,
13354,
7076,
17468,
13832,
6593,
21967,
1007,
1007,
1063,
1002,
9124,
1027,
1002,
2023,
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/Installation/ServerFilesGenerator.php | ServerFilesGenerator.createHtAccess | protected static function createHtAccess($path, $overwrite = true, $content)
{
$file = $path . '/.htaccess';
$content = "# This file is auto generated by Matomo, do not edit directly\n# Please report any issue or improvement directly to the Matomo team.\n\n" . $content;
if ($overwrite || !file_exists($file)) {
@file_put_contents($file, $content, LOCK_EX);
}
} | php | protected static function createHtAccess($path, $overwrite = true, $content)
{
$file = $path . '/.htaccess';
$content = "# This file is auto generated by Matomo, do not edit directly\n# Please report any issue or improvement directly to the Matomo team.\n\n" . $content;
if ($overwrite || !file_exists($file)) {
@file_put_contents($file, $content, LOCK_EX);
}
} | [
"protected",
"static",
"function",
"createHtAccess",
"(",
"$",
"path",
",",
"$",
"overwrite",
"=",
"true",
",",
"$",
"content",
")",
"{",
"$",
"file",
"=",
"$",
"path",
".",
"'/.htaccess'",
";",
"$",
"content",
"=",
"\"# This file is auto generated by Matomo, ... | Create .htaccess file in specified directory
Apache-specific; for IIS @see web.config
.htaccess files are created on all webservers even Nginx, as sometimes Nginx knows how to handle .htaccess files
@param string $path without trailing slash
@param bool $overwrite whether to overwrite an existing file or not
@param string $content | [
"Create",
".",
"htaccess",
"file",
"in",
"specified",
"directory"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/ServerFilesGenerator.php#L96-L104 | train | Create. htaccess file | [
30522,
5123,
10763,
3853,
3443,
22893,
9468,
7971,
1006,
1002,
4130,
1010,
1002,
2058,
26373,
1027,
2995,
1010,
1002,
4180,
1007,
1063,
1002,
5371,
1027,
1002,
4130,
1012,
1005,
1013,
30524,
1002,
4180,
1027,
1000,
1001,
2023,
5371,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/GPM/Response.php | Response.getFopen | private static function getFopen()
{
if (\count($args = func_get_args()) === 1) {
$args = $args[0];
}
$uri = $args[0];
$options = $args[1] ?? [];
$callback = $args[2] ?? null;
if ($callback) {
$options['fopen']['notification'] = ['self', 'progress'];
}
if (isset($options['fopen']['ssl'])) {
$ssl = $options['fopen']['ssl'];
unset($options['fopen']['ssl']);
$stream = stream_context_create([
'http' => $options['fopen'],
'ssl' => $ssl
], $options['fopen']);
} else {
$stream = stream_context_create(['http' => $options['fopen']], $options['fopen']);
}
$content = @file_get_contents($uri, false, $stream);
if ($content === false) {
$code = null;
// Function file_get_contents() creates local variable $http_response_header, check it
if (isset($http_response_header)) {
$code = explode(' ', $http_response_header[0] ?? '')[1] ?? null;
}
switch ($code) {
case '404':
throw new \RuntimeException('Page not found');
case '401':
throw new \RuntimeException('Invalid LICENSE');
default:
throw new \RuntimeException("Error while trying to download (code: {$code}): {$uri}\n");
}
}
return $content;
} | php | private static function getFopen()
{
if (\count($args = func_get_args()) === 1) {
$args = $args[0];
}
$uri = $args[0];
$options = $args[1] ?? [];
$callback = $args[2] ?? null;
if ($callback) {
$options['fopen']['notification'] = ['self', 'progress'];
}
if (isset($options['fopen']['ssl'])) {
$ssl = $options['fopen']['ssl'];
unset($options['fopen']['ssl']);
$stream = stream_context_create([
'http' => $options['fopen'],
'ssl' => $ssl
], $options['fopen']);
} else {
$stream = stream_context_create(['http' => $options['fopen']], $options['fopen']);
}
$content = @file_get_contents($uri, false, $stream);
if ($content === false) {
$code = null;
// Function file_get_contents() creates local variable $http_response_header, check it
if (isset($http_response_header)) {
$code = explode(' ', $http_response_header[0] ?? '')[1] ?? null;
}
switch ($code) {
case '404':
throw new \RuntimeException('Page not found');
case '401':
throw new \RuntimeException('Invalid LICENSE');
default:
throw new \RuntimeException("Error while trying to download (code: {$code}): {$uri}\n");
}
}
return $content;
} | [
"private",
"static",
"function",
"getFopen",
"(",
")",
"{",
"if",
"(",
"\\",
"count",
"(",
"$",
"args",
"=",
"func_get_args",
"(",
")",
")",
"===",
"1",
")",
"{",
"$",
"args",
"=",
"$",
"args",
"[",
"0",
"]",
";",
"}",
"$",
"uri",
"=",
"$",
"... | Starts a HTTP request via fopen
@return string The response of the request | [
"Starts",
"a",
"HTTP",
"request",
"via",
"fopen"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/Response.php#L274-L321 | train | Get the content of a file | [
30522,
2797,
10763,
3853,
2131,
14876,
11837,
1006,
1007,
1063,
2065,
1006,
1032,
4175,
1006,
1002,
12098,
5620,
1027,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
1007,
1027,
1027,
1027,
1015,
1007,
1063,
1002,
12098,
5620,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php | IdnAddressEncoder.encodeString | public function encodeString(string $address): string
{
$i = strrpos($address, '@');
if (false !== $i) {
$local = substr($address, 0, $i);
$domain = substr($address, $i + 1);
if (preg_match('/[^\x00-\x7F]/', $local)) {
throw new AddressEncoderException(sprintf('Non-ASCII characters not supported in local-part os "%s".', $address));
}
if (preg_match('/[^\x00-\x7F]/', $domain)) {
$address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46));
}
}
return $address;
} | php | public function encodeString(string $address): string
{
$i = strrpos($address, '@');
if (false !== $i) {
$local = substr($address, 0, $i);
$domain = substr($address, $i + 1);
if (preg_match('/[^\x00-\x7F]/', $local)) {
throw new AddressEncoderException(sprintf('Non-ASCII characters not supported in local-part os "%s".', $address));
}
if (preg_match('/[^\x00-\x7F]/', $domain)) {
$address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46));
}
}
return $address;
} | [
"public",
"function",
"encodeString",
"(",
"string",
"$",
"address",
")",
":",
"string",
"{",
"$",
"i",
"=",
"strrpos",
"(",
"$",
"address",
",",
"'@'",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"i",
")",
"{",
"$",
"local",
"=",
"substr",
"(",
"$... | Encodes the domain part of an address using IDN.
@throws AddressEncoderException If local-part contains non-ASCII characters | [
"Encodes",
"the",
"domain",
"part",
"of",
"an",
"address",
"using",
"IDN",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/Encoder/IdnAddressEncoder.php#L38-L55 | train | Encode a string to IDNA format | [
30522,
2270,
3853,
4372,
23237,
18886,
3070,
1006,
5164,
1002,
4769,
1007,
1024,
5164,
1063,
1002,
1045,
1027,
2358,
12171,
6873,
2015,
1006,
1002,
4769,
1010,
1005,
1030,
1005,
1007,
1025,
2065,
1006,
6270,
999,
1027,
1027,
1002,
1045,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select.order | public function order($spec)
{
if (!is_array($spec)) {
$spec = array($spec);
}
// force 'ASC' or 'DESC' on each order spec, default is ASC.
foreach ($spec as $val) {
if ($val instanceof Zend_Db_Expr) {
$expr = $val->__toString();
if (empty($expr)) {
continue;
}
$this->_parts[self::ORDER][] = $val;
} else {
if (empty($val)) {
continue;
}
$direction = self::SQL_ASC;
if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) {
$val = trim($matches[1]);
$direction = $matches[2];
}
if (preg_match('/\(.*\)/', $val)) {
$val = new Zend_Db_Expr($val);
}
$this->_parts[self::ORDER][] = array($val, $direction);
}
}
return $this;
} | php | public function order($spec)
{
if (!is_array($spec)) {
$spec = array($spec);
}
// force 'ASC' or 'DESC' on each order spec, default is ASC.
foreach ($spec as $val) {
if ($val instanceof Zend_Db_Expr) {
$expr = $val->__toString();
if (empty($expr)) {
continue;
}
$this->_parts[self::ORDER][] = $val;
} else {
if (empty($val)) {
continue;
}
$direction = self::SQL_ASC;
if (preg_match('/(.*\W)(' . self::SQL_ASC . '|' . self::SQL_DESC . ')\b/si', $val, $matches)) {
$val = trim($matches[1]);
$direction = $matches[2];
}
if (preg_match('/\(.*\)/', $val)) {
$val = new Zend_Db_Expr($val);
}
$this->_parts[self::ORDER][] = array($val, $direction);
}
}
return $this;
} | [
"public",
"function",
"order",
"(",
"$",
"spec",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"spec",
")",
")",
"{",
"$",
"spec",
"=",
"array",
"(",
"$",
"spec",
")",
";",
"}",
"// force 'ASC' or 'DESC' on each order spec, default is ASC.",
"foreach",
"... | Adds a row order to the query.
@param mixed $spec The column(s) and direction to order by.
@return Zend_Db_Select This Zend_Db_Select object. | [
"Adds",
"a",
"row",
"order",
"to",
"the",
"query",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L581-L612 | train | Order by spec | [
30522,
2270,
3853,
2344,
1006,
1002,
28699,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
28699,
1007,
1007,
1063,
1002,
28699,
1027,
9140,
1006,
1002,
28699,
1007,
1025,
1065,
1013,
1013,
2486,
1005,
2004,
2278,
1005,
2030,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Application.php | Application.get | public function get($name)
{
$this->registerCommands();
$command = parent::get($name);
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->kernel->getContainer());
}
return $command;
} | php | public function get($name)
{
$this->registerCommands();
$command = parent::get($name);
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->kernel->getContainer());
}
return $command;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"registerCommands",
"(",
")",
";",
"$",
"command",
"=",
"parent",
"::",
"get",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"command",
"instanceof",
"ContainerAwareInterface",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Application.php#L113-L124 | train | Get a command by name | [
30522,
2270,
3853,
2131,
1006,
1002,
2171,
1007,
1063,
1002,
2023,
1011,
1028,
4236,
9006,
2386,
5104,
1006,
1007,
1025,
1002,
3094,
1027,
6687,
1024,
1024,
2131,
1006,
1002,
2171,
1007,
1025,
2065,
1006,
1002,
3094,
6013,
11253,
11661,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Oracle.php | Zend_Db_Adapter_Oracle.isConnected | public function isConnected()
{
return ((bool) (is_resource($this->_connection)
&& (get_resource_type($this->_connection) == 'oci8 connection'
|| get_resource_type($this->_connection) == 'oci8 persistent connection')));
} | php | public function isConnected()
{
return ((bool) (is_resource($this->_connection)
&& (get_resource_type($this->_connection) == 'oci8 connection'
|| get_resource_type($this->_connection) == 'oci8 persistent connection')));
} | [
"public",
"function",
"isConnected",
"(",
")",
"{",
"return",
"(",
"(",
"bool",
")",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"_connection",
")",
"&&",
"(",
"get_resource_type",
"(",
"$",
"this",
"->",
"_connection",
")",
"==",
"'oci8 connection'",
"||"... | Test if a connection is active
@return boolean | [
"Test",
"if",
"a",
"connection",
"is",
"active"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Oracle.php#L147-L152 | train | Check if connection is available | [
30522,
2270,
3853,
2003,
24230,
1006,
1007,
1063,
2709,
1006,
1006,
22017,
2140,
1007,
1006,
2003,
1035,
7692,
1006,
1002,
2023,
1011,
1028,
1035,
4434,
1007,
1004,
1004,
1006,
2131,
1035,
7692,
1035,
2828,
1006,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php | HasManyThrough.getRelationExistenceQueryForThroughSelfRelation | public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
{
$table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();
$query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());
if ($this->throughParentSoftDeletes()) {
$query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
}
return $query->select($columns)->whereColumn(
$parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
);
} | php | public function getRelationExistenceQueryForThroughSelfRelation(Builder $query, Builder $parentQuery, $columns = ['*'])
{
$table = $this->throughParent->getTable().' as '.$hash = $this->getRelationCountHash();
$query->join($table, $hash.'.'.$this->secondLocalKey, '=', $this->getQualifiedFarKeyName());
if ($this->throughParentSoftDeletes()) {
$query->whereNull($hash.'.'.$this->throughParent->getDeletedAtColumn());
}
return $query->select($columns)->whereColumn(
$parentQuery->getQuery()->from.'.'.$this->localKey, '=', $hash.'.'.$this->firstKey
);
} | [
"public",
"function",
"getRelationExistenceQueryForThroughSelfRelation",
"(",
"Builder",
"$",
"query",
",",
"Builder",
"$",
"parentQuery",
",",
"$",
"columns",
"=",
"[",
"'*'",
"]",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"throughParent",
"->",
"getTab... | Add the constraints for a relationship query on the same table as the through parent.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Builder $parentQuery
@param array|mixed $columns
@return \Illuminate\Database\Eloquent\Builder | [
"Add",
"the",
"constraints",
"for",
"a",
"relationship",
"query",
"on",
"the",
"same",
"table",
"as",
"the",
"through",
"parent",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php#L551-L564 | train | Get Query for relation existence for a throughSelfRelation | [
30522,
2270,
3853,
2131,
16570,
3370,
10288,
27870,
5897,
4226,
2854,
15628,
22494,
5603,
11246,
19699,
10581,
3508,
1006,
12508,
1002,
23032,
1010,
12508,
1002,
6687,
4226,
2854,
1010,
1002,
7753,
1027,
1031,
1005,
1008,
1005,
1033,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/Util/IcuVersion.php | IcuVersion.normalize | public static function normalize($version, $precision)
{
$version = preg_replace('/^(\d)\.(\d)/', '$1$2', $version);
if (1 === \strlen($version)) {
$version .= '0';
}
return Version::normalize($version, $precision);
} | php | public static function normalize($version, $precision)
{
$version = preg_replace('/^(\d)\.(\d)/', '$1$2', $version);
if (1 === \strlen($version)) {
$version .= '0';
}
return Version::normalize($version, $precision);
} | [
"public",
"static",
"function",
"normalize",
"(",
"$",
"version",
",",
"$",
"precision",
")",
"{",
"$",
"version",
"=",
"preg_replace",
"(",
"'/^(\\d)\\.(\\d)/'",
",",
"'$1$2'",
",",
"$",
"version",
")",
";",
"if",
"(",
"1",
"===",
"\\",
"strlen",
"(",
... | Normalizes a version string to the number of components given in the
parameter $precision.
A single digit release version and a single digit major version are
contracted to a two digit release version. If no major version is given,
it is substituted by zero.
Examples:
IcuVersion::normalize('1.2.3.4');
// => '12.3.4'
IcuVersion::normalize('1.2.3.4', 1);
// => '12'
IcuVersion::normalize('1.2.3.4', 2);
// => '12.3'
@param string $version An ICU version string
@param int|null $precision The number of components to include. Pass
NULL to return the version unchanged.
@return string|null the normalized ICU version or NULL if it couldn't be
normalized | [
"Normalizes",
"a",
"version",
"string",
"to",
"the",
"number",
"of",
"components",
"given",
"in",
"the",
"parameter",
"$precision",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Util/IcuVersion.php#L90-L99 | train | Normalize the version number | [
30522,
2270,
10763,
3853,
3671,
4697,
1006,
1002,
2544,
1010,
1002,
11718,
1007,
1063,
1002,
2544,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
1013,
1034,
1006,
1032,
1040,
1007,
1032,
1012,
1006,
1032,
1040,
1007,
1013,
1005,
1010,
1005,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Console/Scheduling/Event.php | Event.onSuccess | public function onSuccess(Closure $callback)
{
return $this->then(function (Container $container) use ($callback) {
if (0 === $this->exitCode) {
$container->call($callback);
}
});
} | php | public function onSuccess(Closure $callback)
{
return $this->then(function (Container $container) use ($callback) {
if (0 === $this->exitCode) {
$container->call($callback);
}
});
} | [
"public",
"function",
"onSuccess",
"(",
"Closure",
"$",
"callback",
")",
"{",
"return",
"$",
"this",
"->",
"then",
"(",
"function",
"(",
"Container",
"$",
"container",
")",
"use",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"this",
"-... | Register a callback to be called if the operation succeeds.
@param \Closure $callback
@return $this | [
"Register",
"a",
"callback",
"to",
"be",
"called",
"if",
"the",
"operation",
"succeeds",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/Event.php#L714-L721 | train | Callback function that will be called when the process is successful. | [
30522,
2270,
3853,
2006,
6342,
9468,
7971,
1006,
30524,
1002,
11661,
1007,
2224,
1006,
1002,
2655,
5963,
1007,
1063,
2065,
1006,
1014,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
6164,
16044,
1007,
1063,
1002,
11661,
1011,
1028,
2655,
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... |
z-song/laravel-admin | src/Grid/Tools/BatchActions.php | BatchActions.setUpScripts | protected function setUpScripts()
{
Admin::script($this->script());
foreach ($this->actions as $action) {
$action->setGrid($this->grid);
Admin::script($action->script());
}
} | php | protected function setUpScripts()
{
Admin::script($this->script());
foreach ($this->actions as $action) {
$action->setGrid($this->grid);
Admin::script($action->script());
}
} | [
"protected",
"function",
"setUpScripts",
"(",
")",
"{",
"Admin",
"::",
"script",
"(",
"$",
"this",
"->",
"script",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"actions",
"as",
"$",
"action",
")",
"{",
"$",
"action",
"->",
"setGrid",
"(",
... | Setup scripts of batch actions.
@return void | [
"Setup",
"scripts",
"of",
"batch",
"actions",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Tools/BatchActions.php#L101-L110 | train | Set up scripts | [
30522,
5123,
3853,
16437,
22483,
2015,
1006,
1007,
1063,
4748,
10020,
1024,
1024,
5896,
1006,
1002,
2023,
1011,
1028,
5896,
1006,
1007,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
4506,
2004,
1002,
2895,
1007,
1063,
1002,
2895,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.onChangeView | public function onChangeView()
{
$viewMode = Input::get('view');
$path = Input::get('path');
$this->setViewMode($viewMode);
$this->setCurrentFolder($path);
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list'),
'#'.$this->getId('folder-path') => $this->makePartial('folder-path'),
'#'.$this->getId('view-mode-buttons') => $this->makePartial('view-mode-buttons')
];
} | php | public function onChangeView()
{
$viewMode = Input::get('view');
$path = Input::get('path');
$this->setViewMode($viewMode);
$this->setCurrentFolder($path);
$this->prepareVars();
return [
'#'.$this->getId('item-list') => $this->makePartial('item-list'),
'#'.$this->getId('folder-path') => $this->makePartial('folder-path'),
'#'.$this->getId('view-mode-buttons') => $this->makePartial('view-mode-buttons')
];
} | [
"public",
"function",
"onChangeView",
"(",
")",
"{",
"$",
"viewMode",
"=",
"Input",
"::",
"get",
"(",
"'view'",
")",
";",
"$",
"path",
"=",
"Input",
"::",
"get",
"(",
"'path'",
")",
";",
"$",
"this",
"->",
"setViewMode",
"(",
"$",
"viewMode",
")",
... | Set view preference AJAX handler
@return array | [
"Set",
"view",
"preference",
"AJAX",
"handler"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L219-L234 | train | Change view mode and path | [
30522,
2270,
3853,
2006,
22305,
6777,
2666,
2860,
1006,
1007,
1063,
1002,
3193,
5302,
3207,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
3193,
1005,
1007,
1025,
1002,
4130,
1027,
7953,
1024,
1024,
2131,
1006,
1005,
4130,
1005,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Connection.php | Connection.prepared | protected function prepared(PDOStatement $statement)
{
$statement->setFetchMode($this->fetchMode);
$this->event(new Events\StatementPrepared(
$this, $statement
));
return $statement;
} | php | protected function prepared(PDOStatement $statement)
{
$statement->setFetchMode($this->fetchMode);
$this->event(new Events\StatementPrepared(
$this, $statement
));
return $statement;
} | [
"protected",
"function",
"prepared",
"(",
"PDOStatement",
"$",
"statement",
")",
"{",
"$",
"statement",
"->",
"setFetchMode",
"(",
"$",
"this",
"->",
"fetchMode",
")",
";",
"$",
"this",
"->",
"event",
"(",
"new",
"Events",
"\\",
"StatementPrepared",
"(",
"... | Configure the PDO prepared statement.
@param \PDOStatement $statement
@return \PDOStatement | [
"Configure",
"the",
"PDO",
"prepared",
"statement",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connection.php#L380-L389 | train | Prepares a statement for execution | [
30522,
5123,
3853,
4810,
1006,
22851,
28696,
18532,
4765,
1002,
4861,
1007,
1063,
1002,
4861,
1011,
1028,
2275,
7959,
30524,
2023,
1011,
1028,
2724,
1006,
2047,
2824,
1032,
4861,
28139,
19362,
2098,
1006,
1002,
2023,
1010,
1002,
4861,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/behaviors/FormController.php | FormController.extendFormFields | public static function extendFormFields($callback)
{
$calledClass = self::getCalledExtensionClass();
Event::listen('backend.form.extendFields', function ($widget) use ($calledClass, $callback) {
if (!is_a($widget->getController(), $calledClass)) {
return;
}
call_user_func_array($callback, [$widget, $widget->model, $widget->getContext()]);
});
} | php | public static function extendFormFields($callback)
{
$calledClass = self::getCalledExtensionClass();
Event::listen('backend.form.extendFields', function ($widget) use ($calledClass, $callback) {
if (!is_a($widget->getController(), $calledClass)) {
return;
}
call_user_func_array($callback, [$widget, $widget->model, $widget->getContext()]);
});
} | [
"public",
"static",
"function",
"extendFormFields",
"(",
"$",
"callback",
")",
"{",
"$",
"calledClass",
"=",
"self",
"::",
"getCalledExtensionClass",
"(",
")",
";",
"Event",
"::",
"listen",
"(",
"'backend.form.extendFields'",
",",
"function",
"(",
"$",
"widget",... | Static helper for extending form fields.
@param callable $callback
@return void | [
"Static",
"helper",
"for",
"extending",
"form",
"fields",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/FormController.php#L857-L866 | train | Extend form fields | [
30522,
2270,
10763,
3853,
7949,
14192,
15155,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
2170,
26266,
1027,
2969,
1024,
1024,
2131,
9289,
3709,
10288,
29048,
26266,
1006,
1007,
1025,
2724,
1024,
1024,
4952,
1006,
1005,
2067,
10497,
1012,
243... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form.php | Form.prepareUpdate | protected function prepareUpdate(array $updates, $oneToOneRelation = false)
{
$prepared = [];
/** @var Field $field */
foreach ($this->builder->fields() as $field) {
$columns = $field->column();
// If column not in input array data, then continue.
if (!Arr::has($updates, $columns)) {
continue;
}
if ($this->invalidColumn($columns, $oneToOneRelation)) {
continue;
}
$value = $this->getDataByColumn($updates, $columns);
$value = $field->prepare($value);
if (is_array($columns)) {
foreach ($columns as $name => $column) {
Arr::set($prepared, $column, $value[$name]);
}
} elseif (is_string($columns)) {
Arr::set($prepared, $columns, $value);
}
}
return $prepared;
} | php | protected function prepareUpdate(array $updates, $oneToOneRelation = false)
{
$prepared = [];
/** @var Field $field */
foreach ($this->builder->fields() as $field) {
$columns = $field->column();
// If column not in input array data, then continue.
if (!Arr::has($updates, $columns)) {
continue;
}
if ($this->invalidColumn($columns, $oneToOneRelation)) {
continue;
}
$value = $this->getDataByColumn($updates, $columns);
$value = $field->prepare($value);
if (is_array($columns)) {
foreach ($columns as $name => $column) {
Arr::set($prepared, $column, $value[$name]);
}
} elseif (is_string($columns)) {
Arr::set($prepared, $columns, $value);
}
}
return $prepared;
} | [
"protected",
"function",
"prepareUpdate",
"(",
"array",
"$",
"updates",
",",
"$",
"oneToOneRelation",
"=",
"false",
")",
"{",
"$",
"prepared",
"=",
"[",
"]",
";",
"/** @var Field $field */",
"foreach",
"(",
"$",
"this",
"->",
"builder",
"->",
"fields",
"(",
... | Prepare input data for update.
@param array $updates
@param bool $oneToOneRelation If column is one-to-one relation.
@return array | [
"Prepare",
"input",
"data",
"for",
"update",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form.php#L865-L896 | train | Prepare update data | [
30522,
5123,
3853,
7374,
6279,
13701,
1006,
9140,
1002,
14409,
1010,
1002,
2028,
3406,
5643,
16570,
3370,
1027,
6270,
1007,
1063,
1002,
4810,
1027,
1031,
1033,
1025,
1013,
1008,
1008,
1030,
13075,
2492,
1002,
2492,
1008,
1013,
18921,
6776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Session/SessionInitializer.php | SessionInitializer.processSuccessfulSession | protected function processSuccessfulSession(AuthResult $authResult)
{
$sessionIdentifier = new SessionFingerprint();
$sessionIdentifier->initialize($authResult->getIdentity(), $this->isRemembered());
/**
* @ignore
*/
Piwik::postEvent('Login.authenticate.processSuccessfulSession.end', array($authResult->getIdentity()));
} | php | protected function processSuccessfulSession(AuthResult $authResult)
{
$sessionIdentifier = new SessionFingerprint();
$sessionIdentifier->initialize($authResult->getIdentity(), $this->isRemembered());
/**
* @ignore
*/
Piwik::postEvent('Login.authenticate.processSuccessfulSession.end', array($authResult->getIdentity()));
} | [
"protected",
"function",
"processSuccessfulSession",
"(",
"AuthResult",
"$",
"authResult",
")",
"{",
"$",
"sessionIdentifier",
"=",
"new",
"SessionFingerprint",
"(",
")",
";",
"$",
"sessionIdentifier",
"->",
"initialize",
"(",
"$",
"authResult",
"->",
"getIdentity",... | Executed when the session was successfully authenticated.
@param AuthResult $authResult The successful authentication result. | [
"Executed",
"when",
"the",
"session",
"was",
"successfully",
"authenticated",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Session/SessionInitializer.php#L83-L92 | train | This method is called when a session is successfully authenticated. | [
30522,
5123,
3853,
2832,
6342,
9468,
7971,
3993,
8583,
10992,
1006,
8740,
2705,
6072,
11314,
1002,
8740,
2705,
6072,
11314,
1007,
1063,
1002,
5219,
5178,
16778,
8873,
2121,
1027,
2047,
5219,
20349,
16550,
1006,
1007,
1025,
1002,
5219,
5178,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreVisualizations/Visualizations/Cloud.php | Cloud.addWord | public function addWord($word, $value = 1)
{
if (isset($this->wordsArray[$word])) {
$this->wordsArray[$word] += $value;
} else {
$this->wordsArray[$word] = $value;
}
} | php | public function addWord($word, $value = 1)
{
if (isset($this->wordsArray[$word])) {
$this->wordsArray[$word] += $value;
} else {
$this->wordsArray[$word] = $value;
}
} | [
"public",
"function",
"addWord",
"(",
"$",
"word",
",",
"$",
"value",
"=",
"1",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"wordsArray",
"[",
"$",
"word",
"]",
")",
")",
"{",
"$",
"this",
"->",
"wordsArray",
"[",
"$",
"word",
"]",
"+... | Assign word to array
@param string $word
@param int $value
@return string | [
"Assign",
"word",
"to",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/Visualizations/Cloud.php#L91-L98 | train | Add word to the words array | [
30522,
2270,
3853,
5587,
18351,
1006,
1002,
2773,
1010,
1002,
3643,
1027,
1015,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2616,
2906,
9447,
1031,
1002,
2773,
1033,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
2616,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Console/ControllerMakeCommand.php | ControllerMakeCommand.buildModelReplacements | protected function buildModelReplacements(array $replace)
{
$modelClass = $this->parseModel($this->option('model'));
if (! class_exists($modelClass)) {
if ($this->confirm("A {$modelClass} model does not exist. Do you want to generate it?", true)) {
$this->call('make:model', ['name' => $modelClass]);
}
}
return array_merge($replace, [
'DummyFullModelClass' => $modelClass,
'DummyModelClass' => class_basename($modelClass),
'DummyModelVariable' => lcfirst(class_basename($modelClass)),
]);
} | php | protected function buildModelReplacements(array $replace)
{
$modelClass = $this->parseModel($this->option('model'));
if (! class_exists($modelClass)) {
if ($this->confirm("A {$modelClass} model does not exist. Do you want to generate it?", true)) {
$this->call('make:model', ['name' => $modelClass]);
}
}
return array_merge($replace, [
'DummyFullModelClass' => $modelClass,
'DummyModelClass' => class_basename($modelClass),
'DummyModelVariable' => lcfirst(class_basename($modelClass)),
]);
} | [
"protected",
"function",
"buildModelReplacements",
"(",
"array",
"$",
"replace",
")",
"{",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"parseModel",
"(",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",... | Build the model replacement values.
@param array $replace
@return array | [
"Build",
"the",
"model",
"replacement",
"values",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Console/ControllerMakeCommand.php#L131-L146 | train | Build model replacements | [
30522,
5123,
3853,
3857,
5302,
9247,
2890,
24759,
10732,
8163,
1006,
9140,
1002,
5672,
1007,
1063,
1002,
2944,
26266,
1027,
1002,
2023,
1011,
1028,
11968,
3366,
5302,
9247,
1006,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
2944,
1005,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/Middleware.php | Middleware.mapResponse | public static function mapResponse(callable $fn)
{
return function (callable $handler) use ($fn) {
return function ($request, array $options) use ($handler, $fn) {
return $handler($request, $options)->then($fn);
};
};
} | php | public static function mapResponse(callable $fn)
{
return function (callable $handler) use ($fn) {
return function ($request, array $options) use ($handler, $fn) {
return $handler($request, $options)->then($fn);
};
};
} | [
"public",
"static",
"function",
"mapResponse",
"(",
"callable",
"$",
"fn",
")",
"{",
"return",
"function",
"(",
"callable",
"$",
"handler",
")",
"use",
"(",
"$",
"fn",
")",
"{",
"return",
"function",
"(",
"$",
"request",
",",
"array",
"$",
"options",
"... | Middleware that applies a map function to the resolved promise's
response.
@param callable $fn Function that accepts a ResponseInterface and
returns a ResponseInterface.
@return callable | [
"Middleware",
"that",
"applies",
"a",
"map",
"function",
"to",
"the",
"resolved",
"promise",
"s",
"response",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Middleware.php#L247-L254 | train | Returns a closure that will map the response to the response. | [
30522,
2270,
10763,
3853,
4949,
6072,
26029,
3366,
1006,
2655,
3085,
1002,
1042,
2078,
1007,
1063,
2709,
3853,
1006,
2655,
3085,
1002,
28213,
1007,
2224,
1006,
1002,
1042,
2078,
1007,
1063,
2709,
3853,
1006,
1002,
5227,
1010,
9140,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Traits/ModelTree.php | ModelTree.allNodes | public function allNodes()
{
$orderColumn = DB::getQueryGrammar()->wrap($this->orderColumn);
$byOrder = $orderColumn.' = 0,'.$orderColumn;
$self = new static();
if ($this->queryCallback instanceof \Closure) {
$self = call_user_func($this->queryCallback, $self);
}
return $self->orderByRaw($byOrder)->get()->toArray();
} | php | public function allNodes()
{
$orderColumn = DB::getQueryGrammar()->wrap($this->orderColumn);
$byOrder = $orderColumn.' = 0,'.$orderColumn;
$self = new static();
if ($this->queryCallback instanceof \Closure) {
$self = call_user_func($this->queryCallback, $self);
}
return $self->orderByRaw($byOrder)->get()->toArray();
} | [
"public",
"function",
"allNodes",
"(",
")",
"{",
"$",
"orderColumn",
"=",
"DB",
"::",
"getQueryGrammar",
"(",
")",
"->",
"wrap",
"(",
"$",
"this",
"->",
"orderColumn",
")",
";",
"$",
"byOrder",
"=",
"$",
"orderColumn",
".",
"' = 0,'",
".",
"$",
"orderC... | Get all elements.
@return mixed | [
"Get",
"all",
"elements",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Traits/ModelTree.php#L175-L187 | train | Get all nodes in the tree | [
30522,
2270,
3853,
2035,
3630,
6155,
1006,
1007,
1063,
1002,
2344,
25778,
2819,
2078,
1027,
16962,
1024,
1024,
2131,
4226,
2854,
13113,
7849,
1006,
1007,
1011,
1028,
10236,
1006,
1002,
2023,
1011,
1028,
2344,
25778,
2819,
2078,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Mailer/Transport/Smtp/Auth/PlainAuthenticator.php | PlainAuthenticator.authenticate | public function authenticate(EsmtpTransport $client): void
{
$client->executeCommand(sprintf("AUTH PLAIN %s\r\n", base64_encode($client->getUsername().\chr(0).$client->getUsername().\chr(0).$client->getPassword())), [235]);
} | php | public function authenticate(EsmtpTransport $client): void
{
$client->executeCommand(sprintf("AUTH PLAIN %s\r\n", base64_encode($client->getUsername().\chr(0).$client->getUsername().\chr(0).$client->getPassword())), [235]);
} | [
"public",
"function",
"authenticate",
"(",
"EsmtpTransport",
"$",
"client",
")",
":",
"void",
"{",
"$",
"client",
"->",
"executeCommand",
"(",
"sprintf",
"(",
"\"AUTH PLAIN %s\\r\\n\"",
",",
"base64_encode",
"(",
"$",
"client",
"->",
"getUsername",
"(",
")",
"... | {@inheritdoc}
@see https://www.ietf.org/rfc/rfc4954.txt | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mailer/Transport/Smtp/Auth/PlainAuthenticator.php#L35-L38 | train | Authenticates the user using the PLAIN method of the EsmtpTransport | [
30522,
2270,
3853,
14469,
3686,
1006,
9686,
20492,
13876,
5521,
20205,
1002,
7396,
1007,
1024,
11675,
1063,
1002,
7396,
1011,
1028,
15389,
9006,
2386,
2094,
1006,
9043,
2546,
1006,
1000,
8740,
2705,
5810,
1003,
1055,
1032,
1054,
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... |
symfony/symfony | src/Symfony/Component/Translation/Formatter/MessageFormatter.php | MessageFormatter.format | public function format($message, $locale, array $parameters = [])
{
if ($this->translator instanceof TranslatorInterface) {
return $this->translator->trans($message, $parameters, null, $locale);
}
return strtr($message, $parameters);
} | php | public function format($message, $locale, array $parameters = [])
{
if ($this->translator instanceof TranslatorInterface) {
return $this->translator->trans($message, $parameters, null, $locale);
}
return strtr($message, $parameters);
} | [
"public",
"function",
"format",
"(",
"$",
"message",
",",
"$",
"locale",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"translator",
"instanceof",
"TranslatorInterface",
")",
"{",
"return",
"$",
"this",
"->",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Formatter/MessageFormatter.php#L45-L52 | train | Format message with parameters | [
30522,
2270,
3853,
4289,
1006,
1002,
4471,
1010,
1002,
2334,
2063,
1010,
9140,
1002,
11709,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11403,
6013,
11253,
11403,
18447,
2121,
12172,
1007,
1063,
2709,
1002,
2023,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Collection.php | Collection.loadMissingRelation | protected function loadMissingRelation(self $models, array $path)
{
$relation = array_shift($path);
$name = explode(':', key($relation))[0];
if (is_string(reset($relation))) {
$relation = reset($relation);
}
$models->filter(function ($model) use ($name) {
return ! is_null($model) && ! $model->relationLoaded($name);
})->load($relation);
if (empty($path)) {
return;
}
$models = $models->pluck($name);
if ($models->first() instanceof BaseCollection) {
$models = $models->collapse();
}
$this->loadMissingRelation(new static($models), $path);
} | php | protected function loadMissingRelation(self $models, array $path)
{
$relation = array_shift($path);
$name = explode(':', key($relation))[0];
if (is_string(reset($relation))) {
$relation = reset($relation);
}
$models->filter(function ($model) use ($name) {
return ! is_null($model) && ! $model->relationLoaded($name);
})->load($relation);
if (empty($path)) {
return;
}
$models = $models->pluck($name);
if ($models->first() instanceof BaseCollection) {
$models = $models->collapse();
}
$this->loadMissingRelation(new static($models), $path);
} | [
"protected",
"function",
"loadMissingRelation",
"(",
"self",
"$",
"models",
",",
"array",
"$",
"path",
")",
"{",
"$",
"relation",
"=",
"array_shift",
"(",
"$",
"path",
")",
";",
"$",
"name",
"=",
"explode",
"(",
"':'",
",",
"key",
"(",
"$",
"relation",... | Load a relationship path if it is not already eager loaded.
@param \Illuminate\Database\Eloquent\Collection $models
@param array $path
@return void | [
"Load",
"a",
"relationship",
"path",
"if",
"it",
"is",
"not",
"already",
"eager",
"loaded",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Collection.php#L144-L169 | train | Load missing relation | [
30522,
5123,
3853,
7170,
15630,
7741,
16570,
3370,
1006,
2969,
1002,
4275,
1010,
9140,
1002,
4130,
1007,
1063,
1002,
7189,
1027,
9140,
1035,
5670,
1006,
1002,
4130,
1007,
1025,
1002,
2171,
1027,
15044,
1006,
1005,
1024,
1005,
1010,
3145,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Console/Scheduling/Schedule.php | Schedule.serverShouldRun | public function serverShouldRun(Event $event, DateTimeInterface $time)
{
return $this->schedulingMutex->create($event, $time);
} | php | public function serverShouldRun(Event $event, DateTimeInterface $time)
{
return $this->schedulingMutex->create($event, $time);
} | [
"public",
"function",
"serverShouldRun",
"(",
"Event",
"$",
"event",
",",
"DateTimeInterface",
"$",
"time",
")",
"{",
"return",
"$",
"this",
"->",
"schedulingMutex",
"->",
"create",
"(",
"$",
"event",
",",
"$",
"time",
")",
";",
"}"
] | Determine if the server is allowed to run this event.
@param \Illuminate\Console\Scheduling\Event $event
@param \DateTimeInterface $time
@return bool | [
"Determine",
"if",
"the",
"server",
"is",
"allowed",
"to",
"run",
"this",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/Schedule.php#L165-L168 | train | Checks if the server should run the given event. | [
30522,
2270,
3853,
14903,
6806,
21285,
15532,
1006,
2724,
1002,
2724,
1010,
3058,
7292,
18447,
2121,
12172,
1002,
2051,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
19940,
26746,
2595,
1011,
1028,
3443,
1006,
1002,
2724,
1010,
1002,
2051,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Form/FormFlash.php | FormFlash.removeFile | public function removeFile(string $name, string $field = null): bool
{
if (!$name) {
return false;
}
$field = $field ?: 'undefined';
$upload = $this->files[$field][$name] ?? null;
if (null !== $upload) {
$this->removeTmpFile($upload['tmp_name'] ?? '');
}
$upload = $this->files[$field . '/original'][$name] ?? null;
if (null !== $upload) {
$this->removeTmpFile($upload['tmp_name'] ?? '');
}
// Mark file as deleted.
$this->files[$field][$name] = null;
$this->files[$field . '/original'][$name] = null;
unset(
$this->uploadedFiles[$field][$name],
$this->uploadedFiles[$field . '/original'][$name]
);
return true;
} | php | public function removeFile(string $name, string $field = null): bool
{
if (!$name) {
return false;
}
$field = $field ?: 'undefined';
$upload = $this->files[$field][$name] ?? null;
if (null !== $upload) {
$this->removeTmpFile($upload['tmp_name'] ?? '');
}
$upload = $this->files[$field . '/original'][$name] ?? null;
if (null !== $upload) {
$this->removeTmpFile($upload['tmp_name'] ?? '');
}
// Mark file as deleted.
$this->files[$field][$name] = null;
$this->files[$field . '/original'][$name] = null;
unset(
$this->uploadedFiles[$field][$name],
$this->uploadedFiles[$field . '/original'][$name]
);
return true;
} | [
"public",
"function",
"removeFile",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"field",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"{",
"return",
"false",
";",
"}",
"$",
"field",
"=",
"$",
"field",
"?",
":",
"'unde... | Remove any file from form flash.
@param string $name
@param string $field
@return bool | [
"Remove",
"any",
"file",
"from",
"form",
"flash",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/FormFlash.php#L291-L318 | train | Removes a file from the temporary directory | [
30522,
2270,
3853,
6366,
8873,
2571,
1006,
5164,
1002,
2171,
1010,
5164,
1002,
2492,
1027,
19701,
1007,
1024,
22017,
2140,
1063,
2065,
1006,
999,
1002,
2171,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
2492,
1027,
1002,
2492,
1029,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.applyFiltersFromModel | protected function applyFiltersFromModel()
{
/*
* Standard usage
*/
if (method_exists($this->model, 'filterFields')) {
$this->model->filterFields((object) $this->allFields, $this->getContext());
}
/*
* Advanced usage
*/
if (method_exists($this->model, 'fireEvent')) {
/**
* @event model.form.filterFields
* Called after the form is initialized
*
* Example usage:
*
* $model->bindEvent('model.form.filterFields', function ((\Backend\Widgets\Form) $formWidget, (stdClass) $fields, (string) $context) use (\October\Rain\Database\Model $model) {
* if ($model->source_type == 'http') {
* $fields->source_url->hidden = false;
* $fields->git_branch->hidden = true;
* } elseif ($model->source_type == 'git') {
* $fields->source_url->hidden = false;
* $fields->git_branch->hidden = false;
* } else {
* $fields->source_url->hidden = true;
* $fields->git_branch->hidden = true;
* }
* });
*
*/
$this->model->fireEvent('model.form.filterFields', [$this, (object) $this->allFields, $this->getContext()]);
}
} | php | protected function applyFiltersFromModel()
{
/*
* Standard usage
*/
if (method_exists($this->model, 'filterFields')) {
$this->model->filterFields((object) $this->allFields, $this->getContext());
}
/*
* Advanced usage
*/
if (method_exists($this->model, 'fireEvent')) {
/**
* @event model.form.filterFields
* Called after the form is initialized
*
* Example usage:
*
* $model->bindEvent('model.form.filterFields', function ((\Backend\Widgets\Form) $formWidget, (stdClass) $fields, (string) $context) use (\October\Rain\Database\Model $model) {
* if ($model->source_type == 'http') {
* $fields->source_url->hidden = false;
* $fields->git_branch->hidden = true;
* } elseif ($model->source_type == 'git') {
* $fields->source_url->hidden = false;
* $fields->git_branch->hidden = false;
* } else {
* $fields->source_url->hidden = true;
* $fields->git_branch->hidden = true;
* }
* });
*
*/
$this->model->fireEvent('model.form.filterFields', [$this, (object) $this->allFields, $this->getContext()]);
}
} | [
"protected",
"function",
"applyFiltersFromModel",
"(",
")",
"{",
"/*\n * Standard usage\n */",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"model",
",",
"'filterFields'",
")",
")",
"{",
"$",
"this",
"->",
"model",
"->",
"filterFields",
"(",... | /*
Allow the model to filter fields. | [
"/",
"*",
"Allow",
"the",
"model",
"to",
"filter",
"fields",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L1183-L1218 | train | Applies filters from the model | [
30522,
5123,
3853,
6611,
8873,
21928,
22747,
21716,
5302,
9247,
1006,
1007,
1063,
1013,
1008,
1008,
3115,
8192,
1008,
1013,
2065,
1006,
4118,
1035,
6526,
1006,
1002,
2023,
1011,
1028,
2944,
1010,
1005,
11307,
15155,
1005,
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... |
laravel/framework | src/Illuminate/Cache/ApcWrapper.php | ApcWrapper.increment | public function increment($key, $value)
{
return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value);
} | php | public function increment($key, $value)
{
return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value);
} | [
"public",
"function",
"increment",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"apcu",
"?",
"apcu_inc",
"(",
"$",
"key",
",",
"$",
"value",
")",
":",
"apc_inc",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Increment the value of an item in the cache.
@param string $key
@param mixed $value
@return int|bool | [
"Increment",
"the",
"value",
"of",
"an",
"item",
"in",
"the",
"cache",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/ApcWrapper.php#L55-L58 | train | Increments the value of the key in the APC or APCU cache | [
30522,
2270,
3853,
4297,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
3643,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
9706,
10841,
1029,
9706,
10841,
1035,
4297,
1006,
1002,
3145,
1010,
1002,
3643,
1007,
1024,
9706,
2278,
1035,
4297,
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/Mail/Transport/MailgunTransport.php | MailgunTransport.allContacts | protected function allContacts(Swift_Mime_SimpleMessage $message)
{
return array_merge(
(array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc()
);
} | php | protected function allContacts(Swift_Mime_SimpleMessage $message)
{
return array_merge(
(array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc()
);
} | [
"protected",
"function",
"allContacts",
"(",
"Swift_Mime_SimpleMessage",
"$",
"message",
")",
"{",
"return",
"array_merge",
"(",
"(",
"array",
")",
"$",
"message",
"->",
"getTo",
"(",
")",
",",
"(",
"array",
")",
"$",
"message",
"->",
"getCc",
"(",
")",
... | Get all of the contacts for the message.
@param \Swift_Mime_SimpleMessage $message
@return array | [
"Get",
"all",
"of",
"the",
"contacts",
"for",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Transport/MailgunTransport.php#L125-L130 | train | Get all contacts from message | [
30522,
5123,
3853,
2035,
8663,
2696,
16649,
1006,
9170,
1035,
2771,
4168,
1035,
3722,
7834,
3736,
3351,
1002,
4471,
1007,
1063,
2709,
9140,
1035,
13590,
1006,
1006,
9140,
1007,
1002,
4471,
1011,
1028,
2131,
3406,
1006,
1007,
1010,
1006,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Mysqli.php | Zend_Db_Adapter_Mysqli._connect | protected function _connect()
{
if ($this->_connection) {
return;
}
if (!extension_loaded('mysqli')) {
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded');
}
if (isset($this->_config['port'])) {
$port = (integer) $this->_config['port'];
} else {
$port = null;
}
$this->_connection = mysqli_init();
$enable_ssl = false;
$ssl_options = array (
'ssl_ca' => null,
'ssl_ca_path' => null,
'ssl_cert' => null,
'ssl_cipher' => null,
'ssl_key' => null,
);
if(!empty($this->_config['driver_options'])) {
foreach($this->_config['driver_options'] as $option=>$value) {
if(array_key_exists($option, $ssl_options)) {
$ssl_options[$option] = $value;
$enable_ssl = true;
} elseif(is_string($option)) {
// Suppress warnings here
// Ignore it if it's not a valid constant
$option = @constant(strtoupper($option));
if($option === null)
continue;
}
mysqli_options($this->_connection, $option, $value);
}
}
if ($enable_ssl) {
mysqli_ssl_set(
$this->_connection,
$ssl_options['ssl_key'],
$ssl_options['ssl_cert'],
$ssl_options['ssl_ca'],
$ssl_options['ssl_ca_path'],
$ssl_options['ssl_cipher']
);
}
$flags = null;
if ($enable_ssl) {
$flags = MYSQLI_CLIENT_SSL;
if (!empty($this->_config['driver_options']['ssl_no_verify'])
&& defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT')
) {
$flags = MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
}
}
// Suppress connection warnings here.
// Throw an exception instead.
$_isConnected = @mysqli_real_connect(
$this->_connection,
$this->_config['host'],
$this->_config['username'],
$this->_config['password'],
$this->_config['dbname'],
$port,
$socket = null,
$enable_ssl ? $flags : null
);
if ($_isConnected === false || mysqli_connect_errno()) {
$this->closeConnection();
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error());
}
if (!empty($this->_config['charset'])) {
mysqli_set_charset($this->_connection, $this->_config['charset']);
}
} | php | protected function _connect()
{
if ($this->_connection) {
return;
}
if (!extension_loaded('mysqli')) {
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception('The Mysqli extension is required for this adapter but the extension is not loaded');
}
if (isset($this->_config['port'])) {
$port = (integer) $this->_config['port'];
} else {
$port = null;
}
$this->_connection = mysqli_init();
$enable_ssl = false;
$ssl_options = array (
'ssl_ca' => null,
'ssl_ca_path' => null,
'ssl_cert' => null,
'ssl_cipher' => null,
'ssl_key' => null,
);
if(!empty($this->_config['driver_options'])) {
foreach($this->_config['driver_options'] as $option=>$value) {
if(array_key_exists($option, $ssl_options)) {
$ssl_options[$option] = $value;
$enable_ssl = true;
} elseif(is_string($option)) {
// Suppress warnings here
// Ignore it if it's not a valid constant
$option = @constant(strtoupper($option));
if($option === null)
continue;
}
mysqli_options($this->_connection, $option, $value);
}
}
if ($enable_ssl) {
mysqli_ssl_set(
$this->_connection,
$ssl_options['ssl_key'],
$ssl_options['ssl_cert'],
$ssl_options['ssl_ca'],
$ssl_options['ssl_ca_path'],
$ssl_options['ssl_cipher']
);
}
$flags = null;
if ($enable_ssl) {
$flags = MYSQLI_CLIENT_SSL;
if (!empty($this->_config['driver_options']['ssl_no_verify'])
&& defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT')
) {
$flags = MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
}
}
// Suppress connection warnings here.
// Throw an exception instead.
$_isConnected = @mysqli_real_connect(
$this->_connection,
$this->_config['host'],
$this->_config['username'],
$this->_config['password'],
$this->_config['dbname'],
$port,
$socket = null,
$enable_ssl ? $flags : null
);
if ($_isConnected === false || mysqli_connect_errno()) {
$this->closeConnection();
/**
* @see Zend_Db_Adapter_Mysqli_Exception
*/
// require_once 'Zend/Db/Adapter/Mysqli/Exception.php';
throw new Zend_Db_Adapter_Mysqli_Exception(mysqli_connect_error());
}
if (!empty($this->_config['charset'])) {
mysqli_set_charset($this->_connection, $this->_config['charset']);
}
} | [
"protected",
"function",
"_connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_connection",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"extension_loaded",
"(",
"'mysqli'",
")",
")",
"{",
"/**\n * @see Zend_Db_Adapter_Mysqli_Exception\n ... | Creates a connection to the database.
@return void
@throws Zend_Db_Adapter_Mysqli_Exception | [
"Creates",
"a",
"connection",
"to",
"the",
"database",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L280-L375 | train | Connect to the database | [
30522,
5123,
3853,
1035,
7532,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
4434,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
999,
5331,
1035,
8209,
1006,
1005,
2026,
2015,
4160,
3669,
1005,
1007,
1007,
1063,
1013,
1008,
1008... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/Date.php | Zend_Validate_Date.isValid | public function isValid($value)
{
if (!is_string($value) && !is_int($value) && !is_float($value) &&
!is_array($value) && !($value instanceof Zend_Date)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
if (($this->_format !== null) || ($this->_locale !== null) || is_array($value) ||
$value instanceof Zend_Date) {
// require_once 'Zend/Date.php';
if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) {
if ($this->_checkFormat($value) === false) {
$this->_error(self::FALSEFORMAT);
} else {
$this->_error(self::INVALID_DATE);
}
return false;
}
} else {
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
$this->_format = 'yyyy-MM-dd';
$this->_error(self::FALSEFORMAT);
$this->_format = null;
return false;
}
list($year, $month, $day) = sscanf($value, '%d-%d-%d');
if (!checkdate($month, $day, $year)) {
$this->_error(self::INVALID_DATE);
return false;
}
}
return true;
} | php | public function isValid($value)
{
if (!is_string($value) && !is_int($value) && !is_float($value) &&
!is_array($value) && !($value instanceof Zend_Date)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
if (($this->_format !== null) || ($this->_locale !== null) || is_array($value) ||
$value instanceof Zend_Date) {
// require_once 'Zend/Date.php';
if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) {
if ($this->_checkFormat($value) === false) {
$this->_error(self::FALSEFORMAT);
} else {
$this->_error(self::INVALID_DATE);
}
return false;
}
} else {
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
$this->_format = 'yyyy-MM-dd';
$this->_error(self::FALSEFORMAT);
$this->_format = null;
return false;
}
list($year, $month, $day) = sscanf($value, '%d-%d-%d');
if (!checkdate($month, $day, $year)) {
$this->_error(self::INVALID_DATE);
return false;
}
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"!",
"is_int",
"(",
"$",
"value",
")",
"&&",
"!",
"is_float",
"(",
"$",
"value",
")",
"&&",
"!",
"is_array",
"(",
"$",
"value... | Defined by Zend_Validate_Interface
Returns true if $value is a valid date of the format YYYY-MM-DD
If optional $format or $locale is set the date format is checked
according to Zend_Date, see Zend_Date::isDate()
@param string|array|Zend_Date $value
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Date.php#L162-L200 | train | Valida o valor de una date | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
999,
2003,
1035,
5164,
1006,
1002,
3643,
1007,
1004,
1004,
999,
2003,
1035,
20014,
1006,
1002,
3643,
1007,
1004,
1004,
999,
2003,
1035,
14257,
30524,
1025,
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/Loader/YamlFileLoader.php | YamlFileLoader.loadFile | protected function loadFile($file)
{
if (!class_exists('Symfony\Component\Yaml\Parser')) {
throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.');
}
if (!stream_is_local($file)) {
throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
}
if (!file_exists($file)) {
throw new InvalidArgumentException(sprintf('The file "%s" does not exist.', $file));
}
if (null === $this->yamlParser) {
$this->yamlParser = new YamlParser();
}
try {
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
} catch (ParseException $e) {
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s', $file, $e->getMessage()), 0, $e);
}
return $this->validate($configuration, $file);
} | php | protected function loadFile($file)
{
if (!class_exists('Symfony\Component\Yaml\Parser')) {
throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.');
}
if (!stream_is_local($file)) {
throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
}
if (!file_exists($file)) {
throw new InvalidArgumentException(sprintf('The file "%s" does not exist.', $file));
}
if (null === $this->yamlParser) {
$this->yamlParser = new YamlParser();
}
try {
$configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
} catch (ParseException $e) {
throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML: %s', $file, $e->getMessage()), 0, $e);
}
return $this->validate($configuration, $file);
} | [
"protected",
"function",
"loadFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'Symfony\\Component\\Yaml\\Parser'",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable to load YAML config files as the Symfony Yaml Component is not instal... | Loads a YAML file.
@param string $file
@return array The file content
@throws InvalidArgumentException when the given file is not a local file or when it does not exist | [
"Loads",
"a",
"YAML",
"file",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php#L629-L654 | train | Load a YAML config file | [
30522,
5123,
3853,
7170,
8873,
2571,
1006,
1002,
5371,
1007,
1063,
2065,
1006,
999,
2465,
1035,
6526,
1006,
1005,
25353,
2213,
14876,
4890,
1032,
6922,
1032,
8038,
19968,
1032,
11968,
8043,
1005,
1007,
1007,
1063,
5466,
2047,
2448,
7292,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Part.php | Zend_Mail_Part.getPart | public function getPart($num)
{
if (isset($this->_parts[$num])) {
return $this->_parts[$num];
}
if (!$this->_mail && $this->_content === null) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('part not found');
}
if ($this->_mail && $this->_mail->hasFetchPart) {
// TODO: fetch part
// return
}
$this->_cacheContent();
if (!isset($this->_parts[$num])) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('part not found');
}
return $this->_parts[$num];
} | php | public function getPart($num)
{
if (isset($this->_parts[$num])) {
return $this->_parts[$num];
}
if (!$this->_mail && $this->_content === null) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('part not found');
}
if ($this->_mail && $this->_mail->hasFetchPart) {
// TODO: fetch part
// return
}
$this->_cacheContent();
if (!isset($this->_parts[$num])) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('part not found');
}
return $this->_parts[$num];
} | [
"public",
"function",
"getPart",
"(",
"$",
"num",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_parts",
"[",
"$",
"num",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_parts",
"[",
"$",
"num",
"]",
";",
"}",
"if",
"(",
"!",
"$",... | Get part of multipart message
@param int $num number of part starting with 1 for first part
@return Zend_Mail_Part wanted part
@throws Zend_Mail_Exception | [
"Get",
"part",
"of",
"multipart",
"message"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Part.php#L239-L269 | train | Get a part from the message | [
30522,
2270,
3853,
2131,
19362,
2102,
1006,
1002,
16371,
2213,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
1002,
16371,
2213,
1033,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
1035,
3033,
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... |
overtrue/wechat | src/BasicService/Media/Client.php | Client.get | public function get(string $mediaId)
{
$response = $this->requestRaw('media/get', 'GET', [
'query' => [
'media_id' => $mediaId,
],
]);
if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
return StreamResponse::buildFromPsrResponse($response);
}
return $this->castResponseToType($response, $this->app['config']->get('response_type'));
} | php | public function get(string $mediaId)
{
$response = $this->requestRaw('media/get', 'GET', [
'query' => [
'media_id' => $mediaId,
],
]);
if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
return StreamResponse::buildFromPsrResponse($response);
}
return $this->castResponseToType($response, $this->app['config']->get('response_type'));
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"mediaId",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"requestRaw",
"(",
"'media/get'",
",",
"'GET'",
",",
"[",
"'query'",
"=>",
"[",
"'media_id'",
"=>",
"$",
"mediaId",
",",
"]",
",",
"]",
")"... | Fetch item from WeChat server.
@param string $mediaId
@return \EasyWeChat\Kernel\Http\StreamResponse|\Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"Fetch",
"item",
"from",
"WeChat",
"server",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/BasicService/Media/Client.php#L162-L175 | train | Get a single media | [
30522,
2270,
3853,
2131,
1006,
5164,
1002,
2865,
3593,
1007,
1063,
1002,
3433,
1027,
1002,
2023,
1011,
1028,
5227,
2527,
2860,
1006,
1005,
2865,
1013,
2131,
1005,
1010,
1005,
2131,
1005,
1010,
1031,
1005,
23032,
1005,
1027,
1028,
1031,
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/Validator/Constraints/Regex.php | Regex.getHtmlPattern | public function getHtmlPattern()
{
// If htmlPattern is specified, use it
if (null !== $this->htmlPattern) {
return empty($this->htmlPattern)
? null
: $this->htmlPattern;
}
// Quit if delimiters not at very beginning/end (e.g. when options are passed)
if ($this->pattern[0] !== $this->pattern[\strlen($this->pattern) - 1]) {
return;
}
$delimiter = $this->pattern[0];
// Unescape the delimiter
$pattern = str_replace('\\'.$delimiter, $delimiter, substr($this->pattern, 1, -1));
// If the pattern is inverted, we can wrap it in
// ((?!pattern).)*
if (!$this->match) {
return '((?!'.$pattern.').)*';
}
// If the pattern contains an or statement, wrap the pattern in
// .*(pattern).* and quit. Otherwise we'd need to parse the pattern
if (false !== strpos($pattern, '|')) {
return '.*('.$pattern.').*';
}
// Trim leading ^, otherwise prepend .*
$pattern = '^' === $pattern[0] ? substr($pattern, 1) : '.*'.$pattern;
// Trim trailing $, otherwise append .*
$pattern = '$' === $pattern[\strlen($pattern) - 1] ? substr($pattern, 0, -1) : $pattern.'.*';
return $pattern;
} | php | public function getHtmlPattern()
{
// If htmlPattern is specified, use it
if (null !== $this->htmlPattern) {
return empty($this->htmlPattern)
? null
: $this->htmlPattern;
}
// Quit if delimiters not at very beginning/end (e.g. when options are passed)
if ($this->pattern[0] !== $this->pattern[\strlen($this->pattern) - 1]) {
return;
}
$delimiter = $this->pattern[0];
// Unescape the delimiter
$pattern = str_replace('\\'.$delimiter, $delimiter, substr($this->pattern, 1, -1));
// If the pattern is inverted, we can wrap it in
// ((?!pattern).)*
if (!$this->match) {
return '((?!'.$pattern.').)*';
}
// If the pattern contains an or statement, wrap the pattern in
// .*(pattern).* and quit. Otherwise we'd need to parse the pattern
if (false !== strpos($pattern, '|')) {
return '.*('.$pattern.').*';
}
// Trim leading ^, otherwise prepend .*
$pattern = '^' === $pattern[0] ? substr($pattern, 1) : '.*'.$pattern;
// Trim trailing $, otherwise append .*
$pattern = '$' === $pattern[\strlen($pattern) - 1] ? substr($pattern, 0, -1) : $pattern.'.*';
return $pattern;
} | [
"public",
"function",
"getHtmlPattern",
"(",
")",
"{",
"// If htmlPattern is specified, use it",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"htmlPattern",
")",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"htmlPattern",
")",
"?",
"null",
":",
"$",
"this... | Converts the htmlPattern to a suitable format for HTML5 pattern.
Example: /^[a-z]+$/ would be converted to [a-z]+
However, if options are specified, it cannot be converted.
Pattern is also ignored if match=false since the pattern should
then be reversed before application.
@see http://dev.w3.org/html5/spec/single-page.html#the-pattern-attribute
@return string|null | [
"Converts",
"the",
"htmlPattern",
"to",
"a",
"suitable",
"format",
"for",
"HTML5",
"pattern",
".",
"Example",
":",
"/",
"^",
"[",
"a",
"-",
"z",
"]",
"+",
"$",
"/",
"would",
"be",
"converted",
"to",
"[",
"a",
"-",
"z",
"]",
"+",
"However",
"if",
... | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/Regex.php#L74-L112 | train | Returns the HTML pattern | [
30522,
2270,
3853,
2131,
11039,
19968,
4502,
12079,
2078,
1006,
1007,
1063,
1013,
1013,
2065,
16129,
4502,
12079,
2078,
2003,
9675,
1010,
2224,
2009,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
16129,
4502,
12079,
2078,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Row.php | Row.addColumn | public function addColumn($name, $value)
{
if (isset($this[$name])) {
throw new Exception("Column $name already in the array!");
}
$this->setColumn($name, $value);
} | php | public function addColumn($name, $value)
{
if (isset($this[$name])) {
throw new Exception("Column $name already in the array!");
}
$this->setColumn($name, $value);
} | [
"public",
"function",
"addColumn",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Column $name already in the array!\"",
")",
";",
"}",
"$"... | Add a new column to the row. If the column already exists, throws an exception.
@param string $name name of the column to add.
@param mixed $value value of the column to set or a PHP callable.
@throws Exception if the column already exists. | [
"Add",
"a",
"new",
"column",
"to",
"the",
"row",
".",
"If",
"the",
"column",
"already",
"exists",
"throws",
"an",
"exception",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L391-L397 | train | Add a new column to the array | [
30522,
2270,
3853,
5587,
25778,
2819,
2078,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1031,
1002,
2171,
1033,
1007,
1007,
1063,
5466,
2047,
6453,
1006,
1000,
5930,
1002,
2171,
2525,
1999,
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/Plugin/Manager.php | Manager.reloadActivatedPlugins | private function reloadActivatedPlugins()
{
$pluginsToPostPendingEventsTo = array();
foreach ($this->pluginsToLoad as $pluginName) {
$pluginsToPostPendingEventsTo = $this->reloadActivatedPlugin($pluginName, $pluginsToPostPendingEventsTo);
}
// post pending events after all plugins are successfully loaded
foreach ($pluginsToPostPendingEventsTo as $plugin) {
EventDispatcher::getInstance()->postPendingEventsTo($plugin);
}
} | php | private function reloadActivatedPlugins()
{
$pluginsToPostPendingEventsTo = array();
foreach ($this->pluginsToLoad as $pluginName) {
$pluginsToPostPendingEventsTo = $this->reloadActivatedPlugin($pluginName, $pluginsToPostPendingEventsTo);
}
// post pending events after all plugins are successfully loaded
foreach ($pluginsToPostPendingEventsTo as $plugin) {
EventDispatcher::getInstance()->postPendingEventsTo($plugin);
}
} | [
"private",
"function",
"reloadActivatedPlugins",
"(",
")",
"{",
"$",
"pluginsToPostPendingEventsTo",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"pluginsToLoad",
"as",
"$",
"pluginName",
")",
"{",
"$",
"pluginsToPostPendingEventsTo",
"=",
"$"... | Load the plugins classes installed.
Register the observers for every plugin. | [
"Load",
"the",
"plugins",
"classes",
"installed",
".",
"Register",
"the",
"observers",
"for",
"every",
"plugin",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Manager.php#L1007-L1018 | train | Reload activated plugins | [
30522,
2797,
3853,
2128,
11066,
18908,
21967,
24759,
15916,
7076,
1006,
1007,
1063,
1002,
13354,
7076,
14399,
14122,
11837,
4667,
18697,
7666,
3406,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
13354,
7076,
3406,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DecisionTree.php | DecisionTree.setColumnNames | public function setColumnNames(array $names)
{
if ($this->featureCount !== 0 && count($names) !== $this->featureCount) {
throw new InvalidArgumentException(sprintf('Length of the given array should be equal to feature count %s', $this->featureCount));
}
$this->columnNames = $names;
return $this;
} | php | public function setColumnNames(array $names)
{
if ($this->featureCount !== 0 && count($names) !== $this->featureCount) {
throw new InvalidArgumentException(sprintf('Length of the given array should be equal to feature count %s', $this->featureCount));
}
$this->columnNames = $names;
return $this;
} | [
"public",
"function",
"setColumnNames",
"(",
"array",
"$",
"names",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"featureCount",
"!==",
"0",
"&&",
"count",
"(",
"$",
"names",
")",
"!==",
"$",
"this",
"->",
"featureCount",
")",
"{",
"throw",
"new",
"InvalidA... | A string array to represent columns. Useful when HTML output or
column importances are desired to be inspected.
@return $this
@throws InvalidArgumentException | [
"A",
"string",
"array",
"to",
"represent",
"columns",
".",
"Useful",
"when",
"HTML",
"output",
"or",
"column",
"importances",
"are",
"desired",
"to",
"be",
"inspected",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Classification/DecisionTree.php#L180-L189 | train | Set the column names | [
30522,
2270,
3853,
2275,
25778,
2819,
9516,
7834,
1006,
9140,
1002,
3415,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3444,
3597,
16671,
999,
1027,
1027,
1014,
1004,
1004,
4175,
1006,
1002,
3415,
1007,
999,
1027,
1027,
1002,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php | LdapBindAuthenticationProvider.checkAuthentication | protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
{
$username = $token->getUsername();
$password = $token->getCredentials();
if ('' === (string) $password) {
throw new BadCredentialsException('The presented password must not be empty.');
}
try {
$username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_DN);
if ($this->queryString) {
$query = str_replace('{username}', $username, $this->queryString);
$result = $this->ldap->query($this->dnString, $query)->execute();
if (1 !== $result->count()) {
throw new BadCredentialsException('The presented username is invalid.');
}
$dn = $result[0]->getDn();
} else {
$dn = str_replace('{username}', $username, $this->dnString);
}
$this->ldap->bind($dn, $password);
} catch (ConnectionException $e) {
throw new BadCredentialsException('The presented password is invalid.');
}
} | php | protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
{
$username = $token->getUsername();
$password = $token->getCredentials();
if ('' === (string) $password) {
throw new BadCredentialsException('The presented password must not be empty.');
}
try {
$username = $this->ldap->escape($username, '', LdapInterface::ESCAPE_DN);
if ($this->queryString) {
$query = str_replace('{username}', $username, $this->queryString);
$result = $this->ldap->query($this->dnString, $query)->execute();
if (1 !== $result->count()) {
throw new BadCredentialsException('The presented username is invalid.');
}
$dn = $result[0]->getDn();
} else {
$dn = str_replace('{username}', $username, $this->dnString);
}
$this->ldap->bind($dn, $password);
} catch (ConnectionException $e) {
throw new BadCredentialsException('The presented password is invalid.');
}
} | [
"protected",
"function",
"checkAuthentication",
"(",
"UserInterface",
"$",
"user",
",",
"UsernamePasswordToken",
"$",
"token",
")",
"{",
"$",
"username",
"=",
"$",
"token",
"->",
"getUsername",
"(",
")",
";",
"$",
"password",
"=",
"$",
"token",
"->",
"getCre... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php#L72-L100 | train | Checks if the user is authenticated. | [
30522,
5123,
3853,
4638,
4887,
10760,
16778,
10719,
1006,
5310,
18447,
2121,
12172,
1002,
5310,
1010,
5310,
18442,
15194,
18351,
18715,
2368,
1002,
19204,
1007,
1063,
1002,
5310,
18442,
1027,
1002,
19204,
1011,
1028,
2131,
20330,
18442,
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/ExampleAPI/API.php | API.getSum | public function getSum($a = 0, $b = 0)
{
if (!is_numeric($a) || !is_numeric($b)) {
throw new \Exception('Given parameters need to be numeric');
}
return (float)($a + $b);
} | php | public function getSum($a = 0, $b = 0)
{
if (!is_numeric($a) || !is_numeric($b)) {
throw new \Exception('Given parameters need to be numeric');
}
return (float)($a + $b);
} | [
"public",
"function",
"getSum",
"(",
"$",
"a",
"=",
"0",
",",
"$",
"b",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"a",
")",
"||",
"!",
"is_numeric",
"(",
"$",
"b",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Giv... | Sums two floats and returns the result.
The paramaters are set automatically from the GET request
when the API function is called. You can also use default values
as shown in this example.
@param float|int $a
@param float|int $b
@return float | [
"Sums",
"two",
"floats",
"and",
"returns",
"the",
"result",
".",
"The",
"paramaters",
"are",
"set",
"automatically",
"from",
"the",
"GET",
"request",
"when",
"the",
"API",
"function",
"is",
"called",
".",
"You",
"can",
"also",
"use",
"default",
"values",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleAPI/API.php#L77-L84 | train | Get the sum of two values | [
30522,
2270,
3853,
4152,
2819,
1006,
1002,
1037,
1027,
1014,
1010,
1002,
1038,
1027,
1014,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16371,
25531,
1006,
1002,
1037,
1007,
1064,
1064,
999,
2003,
1035,
16371,
25531,
1006,
1002,
1038,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Db/Pdo/Mysql.php | Mysql.rollBack | public function rollBack($xid)
{
if ($this->activeTransaction != $xid || $this->activeTransaction === false) {
return;
}
$this->activeTransaction = false;
if (!$this->connection->rollBack()) {
throw new DbException("Rollback failed");
}
} | php | public function rollBack($xid)
{
if ($this->activeTransaction != $xid || $this->activeTransaction === false) {
return;
}
$this->activeTransaction = false;
if (!$this->connection->rollBack()) {
throw new DbException("Rollback failed");
}
} | [
"public",
"function",
"rollBack",
"(",
"$",
"xid",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"activeTransaction",
"!=",
"$",
"xid",
"||",
"$",
"this",
"->",
"activeTransaction",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"activeTran... | Rollback Transaction
@param $xid
@throws DbException
@internal param TransactionID $string from beginTransaction | [
"Rollback",
"Transaction"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Db/Pdo/Mysql.php#L321-L332 | train | Rollbacks a transaction | [
30522,
2270,
3853,
4897,
5963,
1006,
1002,
8418,
2094,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3161,
6494,
3619,
18908,
3258,
999,
1027,
1002,
8418,
2094,
1064,
1064,
1002,
2023,
1011,
1028,
3161,
6494,
3619,
18908,
3258,
1027,
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/Routing/Matcher/UrlMatcher.php | UrlMatcher.matchRequest | public function matchRequest(Request $request)
{
$this->request = $request;
$ret = $this->match($request->getPathInfo());
$this->request = null;
return $ret;
} | php | public function matchRequest(Request $request)
{
$this->request = $request;
$ret = $this->match($request->getPathInfo());
$this->request = null;
return $ret;
} | [
"public",
"function",
"matchRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"match",
"(",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
")",
";",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Matcher/UrlMatcher.php#L104-L113 | train | Match the request against the path info of the current request | [
30522,
2270,
3853,
2674,
2890,
15500,
1006,
5227,
1002,
5227,
1007,
1063,
1002,
2023,
1011,
1028,
5227,
1027,
1002,
5227,
1025,
1002,
2128,
2102,
1027,
1002,
2023,
1011,
1028,
2674,
1006,
1002,
5227,
1011,
1028,
2131,
15069,
2378,
14876,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Core.php | Zend_Cache_Core.getIdsMatchingTags | public function getIdsMatchingTags($tags = array())
{
if (!$this->_extendedBackend) {
Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
if (!($this->_backendCapabilities['tags'])) {
Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
}
$ids = $this->_backend->getIdsMatchingTags($tags);
// we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
$prefix = & $this->_options['cache_id_prefix'];
$prefixLen = strlen($prefix);
foreach ($ids as &$id) {
if (strpos($id, $prefix) === 0) {
$id = substr($id, $prefixLen);
}
}
}
return $ids;
} | php | public function getIdsMatchingTags($tags = array())
{
if (!$this->_extendedBackend) {
Zend_Cache::throwException(self::BACKEND_NOT_IMPLEMENTS_EXTENDED_IF);
}
if (!($this->_backendCapabilities['tags'])) {
Zend_Cache::throwException(self::BACKEND_NOT_SUPPORTS_TAG);
}
$ids = $this->_backend->getIdsMatchingTags($tags);
// we need to remove cache_id_prefix from ids (see #ZF-6178, #ZF-7600)
if (isset($this->_options['cache_id_prefix']) && $this->_options['cache_id_prefix'] !== '') {
$prefix = & $this->_options['cache_id_prefix'];
$prefixLen = strlen($prefix);
foreach ($ids as &$id) {
if (strpos($id, $prefix) === 0) {
$id = substr($id, $prefixLen);
}
}
}
return $ids;
} | [
"public",
"function",
"getIdsMatchingTags",
"(",
"$",
"tags",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_extendedBackend",
")",
"{",
"Zend_Cache",
"::",
"throwException",
"(",
"self",
"::",
"BACKEND_NOT_IMPLEMENTS_EXTENDED_IF",
")",... | Return an array of stored cache ids which match given tags
In case of multiple tags, a logical AND is made between tags
@param array $tags array of tags
@return array array of matching cache ids (string) | [
"Return",
"an",
"array",
"of",
"stored",
"cache",
"ids",
"which",
"match",
"given",
"tags"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Core.php#L475-L498 | train | Get all cache ids matching a set of tags | [
30522,
2270,
3853,
2131,
9821,
18900,
8450,
15900,
2015,
1006,
1002,
22073,
1027,
9140,
1006,
1007,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
3668,
5963,
10497,
1007,
1063,
16729,
2094,
1035,
17053,
1024,
1024,
5466,
10288,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/controllers/Index.php | Index.createTemplate | protected function createTemplate($type)
{
$class = $this->resolveTypeClassName($type);
if (!($template = $class::inTheme($this->theme))) {
throw new ApplicationException(trans('cms::lang.template.not_found'));
}
return $template;
} | php | protected function createTemplate($type)
{
$class = $this->resolveTypeClassName($type);
if (!($template = $class::inTheme($this->theme))) {
throw new ApplicationException(trans('cms::lang.template.not_found'));
}
return $template;
} | [
"protected",
"function",
"createTemplate",
"(",
"$",
"type",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"resolveTypeClassName",
"(",
"$",
"type",
")",
";",
"if",
"(",
"!",
"(",
"$",
"template",
"=",
"$",
"class",
"::",
"inTheme",
"(",
"$",
"this... | Creates a new template of a given type
@param string $type
@return mixed | [
"Creates",
"a",
"new",
"template",
"of",
"a",
"given",
"type"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/controllers/Index.php#L478-L487 | train | Create a template from a type name | [
30522,
5123,
3853,
3443,
18532,
15725,
1006,
1002,
2828,
1007,
1063,
1002,
2465,
1027,
1002,
2023,
1011,
1028,
10663,
13874,
26266,
18442,
1006,
1002,
2828,
1007,
1025,
2065,
1006,
999,
1006,
1002,
23561,
1027,
1002,
2465,
1024,
1024,
20014... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Process/Process.php | Process.setEnv | public function setEnv(array $env)
{
// Process can not handle env values that are arrays
$env = array_filter($env, function ($value) {
return !\is_array($value);
});
$this->env = $env;
return $this;
} | php | public function setEnv(array $env)
{
// Process can not handle env values that are arrays
$env = array_filter($env, function ($value) {
return !\is_array($value);
});
$this->env = $env;
return $this;
} | [
"public",
"function",
"setEnv",
"(",
"array",
"$",
"env",
")",
"{",
"// Process can not handle env values that are arrays",
"$",
"env",
"=",
"array_filter",
"(",
"$",
"env",
",",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"!",
"\\",
"is_array",
"(",
... | Sets the environment variables.
Each environment variable value should be a string.
If it is an array, the variable is ignored.
If it is false or null, it will be removed when
env vars are otherwise inherited.
That happens in PHP when 'argv' is registered into
the $_ENV array for instance.
@param array $env The new environment variables
@return self The current Process instance | [
"Sets",
"the",
"environment",
"variables",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L1159-L1169 | train | Set the environment variables | [
30522,
2270,
3853,
2275,
2368,
2615,
1006,
9140,
1002,
4372,
2615,
1007,
1063,
1013,
1013,
2832,
2064,
2025,
5047,
4372,
2615,
5300,
2008,
2024,
27448,
1002,
4372,
2615,
1027,
9140,
1035,
11307,
1006,
1002,
4372,
2615,
1010,
3853,
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... |
matomo-org/matomo | core/FileIntegrity.php | FileIntegrity.getDirectoryParentFromList | protected static function getDirectoryParentFromList($directory, $directories)
{
foreach($directories as $directoryMaybeParent) {
if ($directory == $directoryMaybeParent) {
continue;
}
$isParentDirectory = strpos($directory, $directoryMaybeParent) === 0;
if ($isParentDirectory) {
return $directoryMaybeParent;
}
}
return null;
} | php | protected static function getDirectoryParentFromList($directory, $directories)
{
foreach($directories as $directoryMaybeParent) {
if ($directory == $directoryMaybeParent) {
continue;
}
$isParentDirectory = strpos($directory, $directoryMaybeParent) === 0;
if ($isParentDirectory) {
return $directoryMaybeParent;
}
}
return null;
} | [
"protected",
"static",
"function",
"getDirectoryParentFromList",
"(",
"$",
"directory",
",",
"$",
"directories",
")",
"{",
"foreach",
"(",
"$",
"directories",
"as",
"$",
"directoryMaybeParent",
")",
"{",
"if",
"(",
"$",
"directory",
"==",
"$",
"directoryMaybePar... | When the parent directory of $directory is found within $directories, return it.
@param $directory
@param $directories
@return string | [
"When",
"the",
"parent",
"directory",
"of",
"$directory",
"is",
"found",
"within",
"$directories",
"return",
"it",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/FileIntegrity.php#L449-L462 | train | Returns directory parent from list of directories | [
30522,
5123,
10763,
3853,
2131,
4305,
2890,
16761,
22571,
12069,
3372,
19699,
5358,
9863,
1006,
1002,
14176,
1010,
1002,
2472,
3111,
1007,
1063,
18921,
6776,
1006,
1002,
2472,
3111,
2004,
1002,
14176,
27871,
4783,
19362,
4765,
1007,
1063,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Router.php | Router.bind | public function bind($key, $binder)
{
$this->binders[str_replace('-', '_', $key)] = RouteBinding::forCallback(
$this->container, $binder
);
} | php | public function bind($key, $binder)
{
$this->binders[str_replace('-', '_', $key)] = RouteBinding::forCallback(
$this->container, $binder
);
} | [
"public",
"function",
"bind",
"(",
"$",
"key",
",",
"$",
"binder",
")",
"{",
"$",
"this",
"->",
"binders",
"[",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"$",
"key",
")",
"]",
"=",
"RouteBinding",
"::",
"forCallback",
"(",
"$",
"this",
"->",
"con... | Add a new route parameter binder.
@param string $key
@param string|callable $binder
@return void | [
"Add",
"a",
"new",
"route",
"parameter",
"binder",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Router.php#L922-L927 | train | Binds a route to the container. | [
30522,
2270,
3853,
14187,
1006,
1002,
3145,
1010,
1002,
14187,
2121,
1007,
1063,
1002,
2023,
1011,
1028,
14187,
2545,
1031,
2358,
2099,
1035,
5672,
1006,
1005,
1011,
1005,
1010,
1005,
1035,
1005,
1010,
1002,
3145,
1007,
1033,
1027,
2799,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Protocols/Websocket.php | Websocket.parseHttpHeader | protected static function parseHttpHeader($buffer)
{
// Parse headers.
list($http_header, ) = explode("\r\n\r\n", $buffer, 2);
$header_data = explode("\r\n", $http_header);
if ($_SERVER) {
$_SERVER = array();
}
list($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], $_SERVER['SERVER_PROTOCOL']) = explode(' ',
$header_data[0]);
unset($header_data[0]);
foreach ($header_data as $content) {
// \r\n\r\n
if (empty($content)) {
continue;
}
list($key, $value) = explode(':', $content, 2);
$key = str_replace('-', '_', strtoupper($key));
$value = trim($value);
$_SERVER['HTTP_' . $key] = $value;
switch ($key) {
// HTTP_HOST
case 'HOST':
$tmp = explode(':', $value);
$_SERVER['SERVER_NAME'] = $tmp[0];
if (isset($tmp[1])) {
$_SERVER['SERVER_PORT'] = $tmp[1];
}
break;
// cookie
case 'COOKIE':
parse_str(str_replace('; ', '&', $_SERVER['HTTP_COOKIE']), $_COOKIE);
break;
}
}
// QUERY_STRING
$_SERVER['QUERY_STRING'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
if ($_SERVER['QUERY_STRING']) {
// $GET
parse_str($_SERVER['QUERY_STRING'], $_GET);
} else {
$_SERVER['QUERY_STRING'] = '';
}
} | php | protected static function parseHttpHeader($buffer)
{
// Parse headers.
list($http_header, ) = explode("\r\n\r\n", $buffer, 2);
$header_data = explode("\r\n", $http_header);
if ($_SERVER) {
$_SERVER = array();
}
list($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], $_SERVER['SERVER_PROTOCOL']) = explode(' ',
$header_data[0]);
unset($header_data[0]);
foreach ($header_data as $content) {
// \r\n\r\n
if (empty($content)) {
continue;
}
list($key, $value) = explode(':', $content, 2);
$key = str_replace('-', '_', strtoupper($key));
$value = trim($value);
$_SERVER['HTTP_' . $key] = $value;
switch ($key) {
// HTTP_HOST
case 'HOST':
$tmp = explode(':', $value);
$_SERVER['SERVER_NAME'] = $tmp[0];
if (isset($tmp[1])) {
$_SERVER['SERVER_PORT'] = $tmp[1];
}
break;
// cookie
case 'COOKIE':
parse_str(str_replace('; ', '&', $_SERVER['HTTP_COOKIE']), $_COOKIE);
break;
}
}
// QUERY_STRING
$_SERVER['QUERY_STRING'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
if ($_SERVER['QUERY_STRING']) {
// $GET
parse_str($_SERVER['QUERY_STRING'], $_GET);
} else {
$_SERVER['QUERY_STRING'] = '';
}
} | [
"protected",
"static",
"function",
"parseHttpHeader",
"(",
"$",
"buffer",
")",
"{",
"// Parse headers.",
"list",
"(",
"$",
"http_header",
",",
")",
"=",
"explode",
"(",
"\"\\r\\n\\r\\n\"",
",",
"$",
"buffer",
",",
"2",
")",
";",
"$",
"header_data",
"=",
"e... | Parse http header.
@param string $buffer
@return void | [
"Parse",
"http",
"header",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Websocket.php#L456-L503 | train | Parse HTTP headers into array | [
30522,
5123,
10763,
3853,
11968,
3366,
11039,
25856,
4974,
2121,
1006,
1002,
17698,
1007,
1063,
1013,
1013,
11968,
3366,
20346,
2015,
1012,
2862,
1006,
1002,
8299,
1035,
20346,
1010,
1007,
1027,
15044,
1006,
1000,
1032,
1054,
1032,
1050,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/Medium.php | Medium.modified | public function modified()
{
$path = $this->get('filepath');
if (!file_exists($path)) {
return null;
}
return filemtime($path) ?: null;
} | php | public function modified()
{
$path = $this->get('filepath');
if (!file_exists($path)) {
return null;
}
return filemtime($path) ?: null;
} | [
"public",
"function",
"modified",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get",
"(",
"'filepath'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"filemtime",
"(",
"$",
... | Get file modification time for the medium.
@return int|null | [
"Get",
"file",
"modification",
"time",
"for",
"the",
"medium",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/Medium.php#L135-L144 | train | Get modified time of the file | [
30522,
2270,
3853,
6310,
1006,
1007,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
2131,
1006,
1005,
5371,
15069,
1005,
1007,
1025,
2065,
1006,
999,
5371,
1035,
6526,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
19701,
1025,
1065,
2709,
53... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ComponentNode.php | ComponentNode.compile | public function compile(Twig_Compiler $compiler)
{
$compiler->addDebugInfo($this);
$compiler->write("\$context['__cms_component_params'] = [];\n");
for ($i = 1; $i < count($this->getNode('nodes')); $i++) {
$compiler->write("\$context['__cms_component_params']['".$this->getAttribute('names')[$i-1]."'] = ");
$compiler->subcompile($this->getNode('nodes')->getNode($i));
$compiler->write(";\n");
}
$compiler
->write("echo \$this->env->getExtension('Cms\Twig\Extension')->componentFunction(")
->subcompile($this->getNode('nodes')->getNode(0))
->write(", \$context['__cms_component_params']")
->write(");\n")
;
$compiler->write("unset(\$context['__cms_component_params']);\n");
} | php | public function compile(Twig_Compiler $compiler)
{
$compiler->addDebugInfo($this);
$compiler->write("\$context['__cms_component_params'] = [];\n");
for ($i = 1; $i < count($this->getNode('nodes')); $i++) {
$compiler->write("\$context['__cms_component_params']['".$this->getAttribute('names')[$i-1]."'] = ");
$compiler->subcompile($this->getNode('nodes')->getNode($i));
$compiler->write(";\n");
}
$compiler
->write("echo \$this->env->getExtension('Cms\Twig\Extension')->componentFunction(")
->subcompile($this->getNode('nodes')->getNode(0))
->write(", \$context['__cms_component_params']")
->write(");\n")
;
$compiler->write("unset(\$context['__cms_component_params']);\n");
} | [
"public",
"function",
"compile",
"(",
"Twig_Compiler",
"$",
"compiler",
")",
"{",
"$",
"compiler",
"->",
"addDebugInfo",
"(",
"$",
"this",
")",
";",
"$",
"compiler",
"->",
"write",
"(",
"\"\\$context['__cms_component_params'] = [];\\n\"",
")",
";",
"for",
"(",
... | Compiles the node to PHP.
@param Twig_Compiler $compiler A Twig_Compiler instance | [
"Compiles",
"the",
"node",
"to",
"PHP",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/ComponentNode.php#L24-L44 | train | Compiles the component function. | [
30522,
2270,
3853,
4012,
22090,
1006,
1056,
16279,
1035,
21624,
1002,
21624,
1007,
1063,
1002,
21624,
1011,
1028,
5587,
3207,
8569,
11528,
14876,
1006,
1002,
2023,
1007,
1025,
1002,
21624,
1011,
1028,
4339,
1006,
1000,
1032,
1002,
6123,
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... |
symfony/symfony | src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php | TextBundleWriter.write | public function write($path, $locale, $data, $fallback = true)
{
$file = fopen($path.'/'.$locale.'.txt', 'w');
$this->writeResourceBundle($file, $locale, $data, $fallback);
fclose($file);
} | php | public function write($path, $locale, $data, $fallback = true)
{
$file = fopen($path.'/'.$locale.'.txt', 'w');
$this->writeResourceBundle($file, $locale, $data, $fallback);
fclose($file);
} | [
"public",
"function",
"write",
"(",
"$",
"path",
",",
"$",
"locale",
",",
"$",
"data",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"$",
"file",
"=",
"fopen",
"(",
"$",
"path",
".",
"'/'",
".",
"$",
"locale",
".",
"'.txt'",
",",
"'w'",
")",
";"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php#L34-L41 | train | Write a resource bundle | [
30522,
2270,
3853,
4339,
1006,
1002,
4130,
1010,
1002,
2334,
2063,
1010,
1002,
2951,
1010,
1002,
2991,
5963,
1027,
2995,
1007,
1063,
1002,
5371,
1027,
1042,
26915,
1006,
1002,
4130,
1012,
1005,
1013,
1005,
1012,
1002,
2334,
2063,
1012,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Login/Controller.php | Controller.login | function login($messageNoAccess = null, $infoMessage = false)
{
$form = new FormLogin();
if ($form->validate()) {
$nonce = $form->getSubmitValue('form_nonce');
if (Nonce::verifyNonce('Login.login', $nonce)) {
$loginOrEmail = $form->getSubmitValue('form_login');
$login = $this->getLoginFromLoginOrEmail($loginOrEmail);
$password = $form->getSubmitValue('form_password');
try {
$this->authenticateAndRedirect($login, $password);
} catch (Exception $e) {
$messageNoAccess = $e->getMessage();
}
} else {
$messageNoAccess = $this->getMessageExceptionNoAccess();
}
}
$view = new View('@Login/login');
$view->AccessErrorString = $messageNoAccess;
$view->infoMessage = nl2br($infoMessage);
$view->addForm($form);
$this->configureView($view);
self::setHostValidationVariablesView($view);
return $view->render();
} | php | function login($messageNoAccess = null, $infoMessage = false)
{
$form = new FormLogin();
if ($form->validate()) {
$nonce = $form->getSubmitValue('form_nonce');
if (Nonce::verifyNonce('Login.login', $nonce)) {
$loginOrEmail = $form->getSubmitValue('form_login');
$login = $this->getLoginFromLoginOrEmail($loginOrEmail);
$password = $form->getSubmitValue('form_password');
try {
$this->authenticateAndRedirect($login, $password);
} catch (Exception $e) {
$messageNoAccess = $e->getMessage();
}
} else {
$messageNoAccess = $this->getMessageExceptionNoAccess();
}
}
$view = new View('@Login/login');
$view->AccessErrorString = $messageNoAccess;
$view->infoMessage = nl2br($infoMessage);
$view->addForm($form);
$this->configureView($view);
self::setHostValidationVariablesView($view);
return $view->render();
} | [
"function",
"login",
"(",
"$",
"messageNoAccess",
"=",
"null",
",",
"$",
"infoMessage",
"=",
"false",
")",
"{",
"$",
"form",
"=",
"new",
"FormLogin",
"(",
")",
";",
"if",
"(",
"$",
"form",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"nonce",
"=",
... | Login form
@param string $messageNoAccess Access error message
@param bool $infoMessage
@internal param string $currentUrl Current URL
@return string | [
"Login",
"form"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/Controller.php#L127-L155 | train | Login Page - Shows Login form | [
30522,
3853,
8833,
2378,
1006,
1002,
4471,
3630,
6305,
9623,
2015,
1027,
19701,
1010,
1002,
18558,
7834,
3736,
3351,
1027,
6270,
1007,
1063,
1002,
2433,
1027,
2047,
2433,
21197,
2378,
1006,
1007,
1025,
2065,
1006,
1002,
2433,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php | AcceptHeaderItem.fromString | public static function fromString($itemValue)
{
$parts = HeaderUtils::split($itemValue, ';=');
$part = array_shift($parts);
$attributes = HeaderUtils::combine($parts);
return new self($part[0], $attributes);
} | php | public static function fromString($itemValue)
{
$parts = HeaderUtils::split($itemValue, ';=');
$part = array_shift($parts);
$attributes = HeaderUtils::combine($parts);
return new self($part[0], $attributes);
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"itemValue",
")",
"{",
"$",
"parts",
"=",
"HeaderUtils",
"::",
"split",
"(",
"$",
"itemValue",
",",
"';='",
")",
";",
"$",
"part",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"$",
"attributes... | Builds an AcceptHeaderInstance instance from a string.
@param string $itemValue
@return self | [
"Builds",
"an",
"AcceptHeaderInstance",
"instance",
"from",
"a",
"string",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/AcceptHeaderItem.php#L41-L49 | train | Creates a new instance from a string | [
30522,
2270,
10763,
3853,
2013,
3367,
4892,
1006,
1002,
8875,
10175,
5657,
1007,
1063,
1002,
3033,
1027,
20346,
21823,
4877,
1024,
1024,
3975,
1006,
1002,
8875,
10175,
5657,
1010,
1005,
1025,
1027,
1005,
1007,
1025,
1002,
2112,
1027,
9140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/View/Factory.php | Factory.make | public function make($view, $data = [], $mergeData = [])
{
$path = $this->finder->find(
$view = $this->normalizeName($view)
);
// Next, we will create the view instance and call the view creator for the view
// which can set any data, etc. Then we will return the view instance back to
// the caller for rendering or performing other view manipulations on this.
$data = array_merge($mergeData, $this->parseData($data));
return tap($this->viewInstance($view, $path, $data), function ($view) {
$this->callCreator($view);
});
} | php | public function make($view, $data = [], $mergeData = [])
{
$path = $this->finder->find(
$view = $this->normalizeName($view)
);
// Next, we will create the view instance and call the view creator for the view
// which can set any data, etc. Then we will return the view instance back to
// the caller for rendering or performing other view manipulations on this.
$data = array_merge($mergeData, $this->parseData($data));
return tap($this->viewInstance($view, $path, $data), function ($view) {
$this->callCreator($view);
});
} | [
"public",
"function",
"make",
"(",
"$",
"view",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"mergeData",
"=",
"[",
"]",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"finder",
"->",
"find",
"(",
"$",
"view",
"=",
"$",
"this",
"->",
"normalizeNa... | Get the evaluated view contents for the given view.
@param string $view
@param \Illuminate\Contracts\Support\Arrayable|array $data
@param array $mergeData
@return \Illuminate\Contracts\View\View | [
"Get",
"the",
"evaluated",
"view",
"contents",
"for",
"the",
"given",
"view",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Factory.php#L127-L141 | train | Make a view instance. | [
30522,
2270,
3853,
2191,
1006,
1002,
3193,
1010,
1002,
2951,
1027,
1031,
1033,
1010,
1002,
5314,
6790,
1027,
1031,
1033,
1007,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
2424,
2121,
1011,
1028,
2424,
1006,
1002,
3193,
1027,
1002,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/Filesystem.php | Filesystem.sharedGet | public function sharedGet($path)
{
$contents = '';
$handle = fopen($path, 'rb');
if ($handle) {
try {
if (flock($handle, LOCK_SH)) {
clearstatcache(true, $path);
$contents = fread($handle, $this->size($path) ?: 1);
flock($handle, LOCK_UN);
}
} finally {
fclose($handle);
}
}
return $contents;
} | php | public function sharedGet($path)
{
$contents = '';
$handle = fopen($path, 'rb');
if ($handle) {
try {
if (flock($handle, LOCK_SH)) {
clearstatcache(true, $path);
$contents = fread($handle, $this->size($path) ?: 1);
flock($handle, LOCK_UN);
}
} finally {
fclose($handle);
}
}
return $contents;
} | [
"public",
"function",
"sharedGet",
"(",
"$",
"path",
")",
"{",
"$",
"contents",
"=",
"''",
";",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"path",
",",
"'rb'",
")",
";",
"if",
"(",
"$",
"handle",
")",
"{",
"try",
"{",
"if",
"(",
"flock",
"(",
"$",
... | Get contents of a file with shared access.
@param string $path
@return string | [
"Get",
"contents",
"of",
"a",
"file",
"with",
"shared",
"access",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/Filesystem.php#L50-L71 | train | Get shared content | [
30522,
2270,
3853,
4207,
18150,
1006,
1002,
4130,
1007,
1063,
1002,
8417,
1027,
1005,
1005,
1025,
1002,
5047,
1027,
1042,
26915,
1006,
1002,
4130,
1010,
1005,
21144,
1005,
1007,
1025,
2065,
1006,
1002,
5047,
1007,
1063,
3046,
1063,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Manager.php | Manager.addLoadedPlugin | public function addLoadedPlugin($pluginName, Plugin $newPlugin)
{
$this->resetTransientCache();
$this->loadedPlugins[$pluginName] = $newPlugin;
} | php | public function addLoadedPlugin($pluginName, Plugin $newPlugin)
{
$this->resetTransientCache();
$this->loadedPlugins[$pluginName] = $newPlugin;
} | [
"public",
"function",
"addLoadedPlugin",
"(",
"$",
"pluginName",
",",
"Plugin",
"$",
"newPlugin",
")",
"{",
"$",
"this",
"->",
"resetTransientCache",
"(",
")",
";",
"$",
"this",
"->",
"loadedPlugins",
"[",
"$",
"pluginName",
"]",
"=",
"$",
"newPlugin",
";"... | Add a plugin in the loaded plugins array
@param string $pluginName plugin name without prefix (eg. 'UserCountry')
@param Plugin $newPlugin
@internal | [
"Add",
"a",
"plugin",
"in",
"the",
"loaded",
"plugins",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Manager.php#L1259-L1264 | train | Add a new loaded plugin to the page | [
30522,
2270,
3853,
5587,
17468,
24759,
15916,
2378,
1006,
1002,
13354,
23111,
14074,
1010,
13354,
2378,
1002,
2047,
24759,
15916,
2378,
1007,
1063,
1002,
2023,
1011,
1028,
25141,
6494,
3619,
11638,
3540,
5403,
1006,
1007,
1025,
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/Config/Definition/BaseNode.php | BaseNode.normalize | final public function normalize($value)
{
$value = $this->preNormalize($value);
// run custom normalization closures
foreach ($this->normalizationClosures as $closure) {
$value = $closure($value);
}
// resolve placeholder value
if ($value !== $placeholders = self::resolvePlaceholderValue($value)) {
foreach ($placeholders as $placeholder) {
$this->handlingPlaceholder = $value;
try {
$this->normalize($placeholder);
} finally {
$this->handlingPlaceholder = null;
}
}
return $value;
}
// replace value with their equivalent
foreach ($this->equivalentValues as $data) {
if ($data[0] === $value) {
$value = $data[1];
}
}
// validate type
$this->doValidateType($value);
// normalize value
return $this->normalizeValue($value);
} | php | final public function normalize($value)
{
$value = $this->preNormalize($value);
// run custom normalization closures
foreach ($this->normalizationClosures as $closure) {
$value = $closure($value);
}
// resolve placeholder value
if ($value !== $placeholders = self::resolvePlaceholderValue($value)) {
foreach ($placeholders as $placeholder) {
$this->handlingPlaceholder = $value;
try {
$this->normalize($placeholder);
} finally {
$this->handlingPlaceholder = null;
}
}
return $value;
}
// replace value with their equivalent
foreach ($this->equivalentValues as $data) {
if ($data[0] === $value) {
$value = $data[1];
}
}
// validate type
$this->doValidateType($value);
// normalize value
return $this->normalizeValue($value);
} | [
"final",
"public",
"function",
"normalize",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"preNormalize",
"(",
"$",
"value",
")",
";",
"// run custom normalization closures",
"foreach",
"(",
"$",
"this",
"->",
"normalizationClosures",
"as"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/BaseNode.php#L329-L364 | train | Normalize value. | [
30522,
2345,
2270,
3853,
3671,
4697,
1006,
1002,
3643,
1007,
1063,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
3653,
12131,
9067,
4697,
1006,
1002,
3643,
1007,
1025,
1013,
1013,
2448,
7661,
3671,
3989,
8503,
2015,
18921,
6776,
1006,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Uri.php | Uri.ip | public static function ip()
{
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
} elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
} elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
} elseif (getenv('REMOTE_ADDR')){
$ip = getenv('REMOTE_ADDR');
} else {
$ip = 'UNKNOWN';
}
return $ip;
} | php | public static function ip()
{
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
} elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
} elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
} elseif (getenv('REMOTE_ADDR')){
$ip = getenv('REMOTE_ADDR');
} else {
$ip = 'UNKNOWN';
}
return $ip;
} | [
"public",
"static",
"function",
"ip",
"(",
")",
"{",
"if",
"(",
"getenv",
"(",
"'HTTP_CLIENT_IP'",
")",
")",
"{",
"$",
"ip",
"=",
"getenv",
"(",
"'HTTP_CLIENT_IP'",
")",
";",
"}",
"elseif",
"(",
"getenv",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
")",
"{",
"... | Return the IP address of the current user
@return string ip address | [
"Return",
"the",
"IP",
"address",
"of",
"the",
"current",
"user"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L628-L647 | train | Get the ip | [
30522,
2270,
10763,
3853,
12997,
1006,
1007,
1063,
2065,
1006,
2131,
2368,
2615,
1006,
1005,
8299,
1035,
7396,
1035,
12997,
1005,
1007,
1007,
1063,
1002,
12997,
1027,
2131,
2368,
2615,
1006,
1005,
8299,
1035,
7396,
1035,
12997,
1005,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DomCrawler/Crawler.php | Crawler.addHtmlContent | public function addHtmlContent($content, $charset = 'UTF-8')
{
// Use HTML5 parser if the content is HTML5 and the library is available
if (!$this->html5Parser
&& class_exists(HTML5::class)
&& '<!doctype html>' === strtolower(substr(ltrim($content), 0, 15))) {
$this->html5Parser = new HTML5(['disable_html_ns' => true]);
}
$dom = null !== $this->html5Parser ? $this->parseHtml5($content, $charset) : $this->parseXhtml($content, $charset);
$this->addDocument($dom);
$base = $this->filterRelativeXPath('descendant-or-self::base')->extract(['href']);
$baseHref = current($base);
if (\count($base) && !empty($baseHref)) {
if ($this->baseHref) {
$linkNode = $dom->createElement('a');
$linkNode->setAttribute('href', $baseHref);
$link = new Link($linkNode, $this->baseHref);
$this->baseHref = $link->getUri();
} else {
$this->baseHref = $baseHref;
}
}
} | php | public function addHtmlContent($content, $charset = 'UTF-8')
{
// Use HTML5 parser if the content is HTML5 and the library is available
if (!$this->html5Parser
&& class_exists(HTML5::class)
&& '<!doctype html>' === strtolower(substr(ltrim($content), 0, 15))) {
$this->html5Parser = new HTML5(['disable_html_ns' => true]);
}
$dom = null !== $this->html5Parser ? $this->parseHtml5($content, $charset) : $this->parseXhtml($content, $charset);
$this->addDocument($dom);
$base = $this->filterRelativeXPath('descendant-or-self::base')->extract(['href']);
$baseHref = current($base);
if (\count($base) && !empty($baseHref)) {
if ($this->baseHref) {
$linkNode = $dom->createElement('a');
$linkNode->setAttribute('href', $baseHref);
$link = new Link($linkNode, $this->baseHref);
$this->baseHref = $link->getUri();
} else {
$this->baseHref = $baseHref;
}
}
} | [
"public",
"function",
"addHtmlContent",
"(",
"$",
"content",
",",
"$",
"charset",
"=",
"'UTF-8'",
")",
"{",
"// Use HTML5 parser if the content is HTML5 and the library is available",
"if",
"(",
"!",
"$",
"this",
"->",
"html5Parser",
"&&",
"class_exists",
"(",
"HTML5"... | Adds an HTML content to the list of nodes.
The libxml errors are disabled when the content is parsed.
If you want to get parsing errors, be sure to enable
internal errors via libxml_use_internal_errors(true)
and then, get the errors via libxml_get_errors(). Be
sure to clear errors with libxml_clear_errors() afterward.
@param string $content The HTML content
@param string $charset The charset | [
"Adds",
"an",
"HTML",
"content",
"to",
"the",
"list",
"of",
"nodes",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/Crawler.php#L190-L215 | train | Adds HTML content to the document | [
30522,
2270,
3853,
5587,
11039,
19968,
8663,
6528,
2102,
1006,
1002,
4180,
1010,
1002,
25869,
13462,
1027,
1005,
21183,
2546,
1011,
1022,
1005,
1007,
1063,
1013,
1013,
2224,
16129,
2629,
11968,
8043,
2065,
1996,
4180,
2003,
16129,
2629,
199... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Application/Kernel/PluginList.php | PluginList.sortPlugins | public function sortPlugins(array $plugins)
{
$global = $this->getPluginsBundledWithPiwik();
if (empty($global)) {
return $plugins;
}
// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
$global = array_merge($global, $this->corePluginsDisabledByDefault);
$global = array_values($global);
$plugins = array_values($plugins);
$defaultPluginsLoadedFirst = array_intersect($global, $plugins);
$otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
// sort by name to have a predictable order for those extra plugins
natcasesort($otherPluginsToLoadAfterDefaultPlugins);
$sorted = array_merge($defaultPluginsLoadedFirst, $otherPluginsToLoadAfterDefaultPlugins);
return $sorted;
} | php | public function sortPlugins(array $plugins)
{
$global = $this->getPluginsBundledWithPiwik();
if (empty($global)) {
return $plugins;
}
// we need to make sure a possibly disabled plugin will be still loaded before any 3rd party plugin
$global = array_merge($global, $this->corePluginsDisabledByDefault);
$global = array_values($global);
$plugins = array_values($plugins);
$defaultPluginsLoadedFirst = array_intersect($global, $plugins);
$otherPluginsToLoadAfterDefaultPlugins = array_diff($plugins, $defaultPluginsLoadedFirst);
// sort by name to have a predictable order for those extra plugins
natcasesort($otherPluginsToLoadAfterDefaultPlugins);
$sorted = array_merge($defaultPluginsLoadedFirst, $otherPluginsToLoadAfterDefaultPlugins);
return $sorted;
} | [
"public",
"function",
"sortPlugins",
"(",
"array",
"$",
"plugins",
")",
"{",
"$",
"global",
"=",
"$",
"this",
"->",
"getPluginsBundledWithPiwik",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"global",
")",
")",
"{",
"return",
"$",
"plugins",
";",
"}",
... | Sorts an array of plugins in the order they should be loaded. We cannot use DI here as DI is not initialized
at this stage.
@params string[] $plugins
@return \string[] | [
"Sorts",
"an",
"array",
"of",
"plugins",
"in",
"the",
"order",
"they",
"should",
"be",
"loaded",
".",
"We",
"cannot",
"use",
"DI",
"here",
"as",
"DI",
"is",
"not",
"initialized",
"at",
"this",
"stage",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Application/Kernel/PluginList.php#L101-L124 | train | Sort the plugins by name | [
30522,
2270,
3853,
4066,
24759,
15916,
7076,
1006,
9140,
1002,
13354,
7076,
1007,
1063,
1002,
3795,
1027,
1002,
2023,
1011,
1028,
2131,
24759,
15916,
7076,
27265,
3709,
24415,
8197,
9148,
2243,
1006,
1007,
1025,
2065,
1006,
4064,
1006,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/LanguagesManager/TranslationWriter/Writer.php | Writer.applyFilters | protected function applyFilters()
{
// skip if already cleaned
if ($this->currentState == self::FILTERED) {
return $this->wasFiltered();
}
$this->filterMessages = array();
// skip if not translations available
if (!$this->hasTranslations()) {
$this->currentState = self::FILTERED;
return false;
}
$cleanedTranslations = $this->translations;
foreach ($this->filters as $filter) {
$cleanedTranslations = $filter->filter($cleanedTranslations);
$filteredData = $filter->getFilteredData();
if (!empty($filteredData)) {
$this->filterMessages[] = get_class($filter) . " changed: " . var_export($filteredData, 1);
}
}
$this->currentState = self::FILTERED;
if ($cleanedTranslations != $this->translations) {
$this->filterMessages[] = 'translations have been cleaned';
}
$this->translations = $cleanedTranslations;
return $this->wasFiltered();
} | php | protected function applyFilters()
{
// skip if already cleaned
if ($this->currentState == self::FILTERED) {
return $this->wasFiltered();
}
$this->filterMessages = array();
// skip if not translations available
if (!$this->hasTranslations()) {
$this->currentState = self::FILTERED;
return false;
}
$cleanedTranslations = $this->translations;
foreach ($this->filters as $filter) {
$cleanedTranslations = $filter->filter($cleanedTranslations);
$filteredData = $filter->getFilteredData();
if (!empty($filteredData)) {
$this->filterMessages[] = get_class($filter) . " changed: " . var_export($filteredData, 1);
}
}
$this->currentState = self::FILTERED;
if ($cleanedTranslations != $this->translations) {
$this->filterMessages[] = 'translations have been cleaned';
}
$this->translations = $cleanedTranslations;
return $this->wasFiltered();
} | [
"protected",
"function",
"applyFilters",
"(",
")",
"{",
"// skip if already cleaned",
"if",
"(",
"$",
"this",
"->",
"currentState",
"==",
"self",
"::",
"FILTERED",
")",
"{",
"return",
"$",
"this",
"->",
"wasFiltered",
"(",
")",
";",
"}",
"$",
"this",
"->",... | @throws \Exception
@return bool error state | [
"@throws",
"\\",
"Exception"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/TranslationWriter/Writer.php#L353-L387 | train | Apply filters to the language | [
30522,
5123,
3853,
6611,
8873,
21928,
2015,
1006,
1007,
1063,
1013,
1013,
13558,
2065,
2525,
12176,
2065,
1006,
1002,
2023,
1011,
1028,
14731,
12259,
1027,
1027,
2969,
1024,
1024,
21839,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2001,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.