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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matomo-org/matomo | libs/Zend/Cache/Backend/Apc.php | Zend_Cache_Backend_Apc.getIds | public function getIds()
{
$res = array();
$array = apc_cache_info('user', false);
$records = $array['cache_list'];
foreach ($records as $record) {
$res[] = $record['info'];
}
return $res;
} | php | public function getIds()
{
$res = array();
$array = apc_cache_info('user', false);
$records = $array['cache_list'];
foreach ($records as $record) {
$res[] = $record['info'];
}
return $res;
} | [
"public",
"function",
"getIds",
"(",
")",
"{",
"$",
"res",
"=",
"array",
"(",
")",
";",
"$",
"array",
"=",
"apc_cache_info",
"(",
"'user'",
",",
"false",
")",
";",
"$",
"records",
"=",
"$",
"array",
"[",
"'cache_list'",
"]",
";",
"foreach",
"(",
"$... | Return an array of stored cache ids
@return array array of stored cache ids (string) | [
"Return",
"an",
"array",
"of",
"stored",
"cache",
"ids"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Apc.php#L257-L266 | train | Get all the ids of the user | [
30522,
2270,
3853,
2131,
9821,
1006,
1007,
1063,
1002,
24501,
1027,
9140,
1006,
1007,
1025,
1002,
9140,
1027,
9706,
2278,
1035,
17053,
1035,
18558,
1006,
1005,
5310,
1005,
1010,
6270,
1007,
1025,
1002,
2636,
1027,
1002,
9140,
1031,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Validator.php | Validator.sometimes | public function sometimes($attribute, $rules, callable $callback)
{
$payload = new Fluent($this->getData());
if (call_user_func($callback, $payload)) {
foreach ((array) $attribute as $key) {
$this->addRules([$key => $rules]);
}
}
return $this;
} | php | public function sometimes($attribute, $rules, callable $callback)
{
$payload = new Fluent($this->getData());
if (call_user_func($callback, $payload)) {
foreach ((array) $attribute as $key) {
$this->addRules([$key => $rules]);
}
}
return $this;
} | [
"public",
"function",
"sometimes",
"(",
"$",
"attribute",
",",
"$",
"rules",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"payload",
"=",
"new",
"Fluent",
"(",
"$",
"this",
"->",
"getData",
"(",
")",
")",
";",
"if",
"(",
"call_user_func",
"(",
"$... | Add conditions to a given field based on a Closure.
@param string|array $attribute
@param string|array $rules
@param callable $callback
@return $this | [
"Add",
"conditions",
"to",
"a",
"given",
"field",
"based",
"on",
"a",
"Closure",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Validator.php#L859-L870 | train | Add rules to the current data if the callback is called | [
30522,
2270,
3853,
2823,
1006,
1002,
17961,
1010,
1002,
3513,
1010,
2655,
3085,
1002,
2655,
5963,
1007,
1063,
1002,
18093,
1027,
2047,
19376,
1006,
1002,
2023,
1011,
1028,
2131,
2850,
2696,
1006,
1007,
1007,
1025,
2065,
1006,
2655,
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/Validation/Validator.php | Validator.isNotNullIfMarkedAsNullable | protected function isNotNullIfMarkedAsNullable($rule, $attribute)
{
if ($this->isImplicit($rule) || ! $this->hasRule($attribute, ['Nullable'])) {
return true;
}
return ! is_null(Arr::get($this->data, $attribute, 0));
} | php | protected function isNotNullIfMarkedAsNullable($rule, $attribute)
{
if ($this->isImplicit($rule) || ! $this->hasRule($attribute, ['Nullable'])) {
return true;
}
return ! is_null(Arr::get($this->data, $attribute, 0));
} | [
"protected",
"function",
"isNotNullIfMarkedAsNullable",
"(",
"$",
"rule",
",",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isImplicit",
"(",
"$",
"rule",
")",
"||",
"!",
"$",
"this",
"->",
"hasRule",
"(",
"$",
"attribute",
",",
"[",
"'Nu... | Determine if the attribute fails the nullable check.
@param string $rule
@param string $attribute
@return bool | [
"Determine",
"if",
"the",
"attribute",
"fails",
"the",
"nullable",
"check",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Validator.php#L539-L546 | train | Check if the attribute is not null if marked as nullable | [
30522,
5123,
3853,
3475,
4140,
11231,
6894,
16715,
17007,
11960,
2015,
11231,
4571,
3468,
1006,
1002,
3627,
1010,
1002,
17961,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
5714,
24759,
28775,
2102,
1006,
1002,
3627,
1007,
1064,
106... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Broadcasting/BroadcastEvent.php | BroadcastEvent.getPayloadFromEvent | protected function getPayloadFromEvent($event)
{
if (method_exists($event, 'broadcastWith')) {
return array_merge(
$event->broadcastWith(), ['socket' => data_get($event, 'socket')]
);
}
$payload = [];
foreach ((new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
$payload[$property->getName()] = $this->formatProperty($property->getValue($event));
}
unset($payload['broadcastQueue']);
return $payload;
} | php | protected function getPayloadFromEvent($event)
{
if (method_exists($event, 'broadcastWith')) {
return array_merge(
$event->broadcastWith(), ['socket' => data_get($event, 'socket')]
);
}
$payload = [];
foreach ((new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
$payload[$property->getName()] = $this->formatProperty($property->getValue($event));
}
unset($payload['broadcastQueue']);
return $payload;
} | [
"protected",
"function",
"getPayloadFromEvent",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"event",
",",
"'broadcastWith'",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"event",
"->",
"broadcastWith",
"(",
")",
",",
"[",
"'sock... | Get the payload for the given event.
@param mixed $event
@return array | [
"Get",
"the",
"payload",
"for",
"the",
"given",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Broadcasting/BroadcastEvent.php#L58-L75 | train | Get the payload from the event | [
30522,
5123,
3853,
2131,
4502,
8516,
10441,
20952,
21716,
18697,
3372,
1006,
1002,
2724,
1007,
1063,
2065,
1006,
4118,
1035,
6526,
1006,
1002,
2724,
1010,
1005,
3743,
24415,
1005,
1007,
1007,
1063,
2709,
9140,
1035,
13590,
1006,
1002,
2724,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.findInContextualBindings | protected function findInContextualBindings($abstract)
{
if (isset($this->contextual[end($this->buildStack)][$abstract])) {
return $this->contextual[end($this->buildStack)][$abstract];
}
} | php | protected function findInContextualBindings($abstract)
{
if (isset($this->contextual[end($this->buildStack)][$abstract])) {
return $this->contextual[end($this->buildStack)][$abstract];
}
} | [
"protected",
"function",
"findInContextualBindings",
"(",
"$",
"abstract",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"contextual",
"[",
"end",
"(",
"$",
"this",
"->",
"buildStack",
")",
"]",
"[",
"$",
"abstract",
"]",
")",
")",
"{",
"return... | Find the concrete binding for the given abstract in the contextual binding array.
@param string $abstract
@return \Closure|string|null | [
"Find",
"the",
"concrete",
"binding",
"for",
"the",
"given",
"abstract",
"in",
"the",
"contextual",
"binding",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L754-L759 | train | Find the contextual bindings of an abstract. | [
30522,
5123,
3853,
2424,
2378,
8663,
18209,
8787,
8428,
4667,
2015,
1006,
1002,
10061,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
6123,
8787,
1031,
2203,
1006,
1002,
2023,
1011,
1028,
16473,
2696,
3600,
1007,
1033,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php | Connection.countMessagesInQueues | public function countMessagesInQueues(): int
{
return array_sum(array_map(function ($queueName) {
return $this->queue($queueName)->declareQueue();
}, $this->getQueueNames()));
} | php | public function countMessagesInQueues(): int
{
return array_sum(array_map(function ($queueName) {
return $this->queue($queueName)->declareQueue();
}, $this->getQueueNames()));
} | [
"public",
"function",
"countMessagesInQueues",
"(",
")",
":",
"int",
"{",
"return",
"array_sum",
"(",
"array_map",
"(",
"function",
"(",
"$",
"queueName",
")",
"{",
"return",
"$",
"this",
"->",
"queue",
"(",
"$",
"queueName",
")",
"->",
"declareQueue",
"("... | Returns an approximate count of the messages in defined queues. | [
"Returns",
"an",
"approximate",
"count",
"of",
"the",
"messages",
"in",
"defined",
"queues",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php#L200-L205 | train | Count the number of messages in all queues | [
30522,
2270,
3853,
4175,
7834,
3736,
8449,
2378,
4226,
15808,
1006,
1007,
1024,
20014,
1063,
2709,
9140,
1035,
7680,
1006,
9140,
1035,
4949,
1006,
3853,
1006,
1002,
24240,
18442,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
24240,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/File.php | Zend_Cache_Backend_File.save | public function save($data, $id, $tags = array(), $specificLifetime = false)
{
clearstatcache();
$file = $this->_file($id);
$path = $this->_path($id);
if ($this->_options['hashed_directory_level'] > 0) {
if (!is_writable($path)) {
// maybe, we just have to build the directory structure
$this->_recursiveMkdirAndChmod($id);
}
if (!is_writable($path)) {
return false;
}
}
if ($this->_options['read_control']) {
$hash = $this->_hash($data, $this->_options['read_control_type']);
} else {
$hash = '';
}
$metadatas = array(
'hash' => $hash,
'mtime' => time(),
'expire' => $this->_expireTime($this->getLifetime($specificLifetime)),
'tags' => $tags
);
$res = $this->_setMetadatas($id, $metadatas);
if (!$res) {
$this->_log('Zend_Cache_Backend_File::save() / error on saving metadata');
return false;
}
$res = $this->_filePutContents($file, $data);
return $res;
} | php | public function save($data, $id, $tags = array(), $specificLifetime = false)
{
clearstatcache();
$file = $this->_file($id);
$path = $this->_path($id);
if ($this->_options['hashed_directory_level'] > 0) {
if (!is_writable($path)) {
// maybe, we just have to build the directory structure
$this->_recursiveMkdirAndChmod($id);
}
if (!is_writable($path)) {
return false;
}
}
if ($this->_options['read_control']) {
$hash = $this->_hash($data, $this->_options['read_control_type']);
} else {
$hash = '';
}
$metadatas = array(
'hash' => $hash,
'mtime' => time(),
'expire' => $this->_expireTime($this->getLifetime($specificLifetime)),
'tags' => $tags
);
$res = $this->_setMetadatas($id, $metadatas);
if (!$res) {
$this->_log('Zend_Cache_Backend_File::save() / error on saving metadata');
return false;
}
$res = $this->_filePutContents($file, $data);
return $res;
} | [
"public",
"function",
"save",
"(",
"$",
"data",
",",
"$",
"id",
",",
"$",
"tags",
"=",
"array",
"(",
")",
",",
"$",
"specificLifetime",
"=",
"false",
")",
"{",
"clearstatcache",
"(",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"_file",
"(",
"$... | Save some string datas into a cache record
Note : $data is always "string" (serialization is done by the
core not by the backend)
@param string $data Datas to cache
@param string $id Cache id
@param array $tags Array of strings, the cache record will be tagged by each string entry
@param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
@return boolean true if no problem | [
"Save",
"some",
"string",
"datas",
"into",
"a",
"cache",
"record"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/File.php#L219-L251 | train | Save cache file | [
30522,
2270,
3853,
3828,
1006,
1002,
2951,
1010,
1002,
8909,
1010,
1002,
22073,
1027,
9140,
1006,
1007,
1010,
30524,
1011,
1028,
1035,
7047,
1031,
1005,
23325,
2098,
1035,
14176,
1035,
2504,
1005,
1033,
1028,
1014,
1007,
1063,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Frontend/Capture.php | Zend_Cache_Frontend_Capture.start | public function start($id, array $tags, $extension = null)
{
$this->_tags = $tags;
$this->_extension = $extension;
ob_start(array($this, '_flush'));
ob_implicit_flush(false);
$this->_idStack[] = $id;
return false;
} | php | public function start($id, array $tags, $extension = null)
{
$this->_tags = $tags;
$this->_extension = $extension;
ob_start(array($this, '_flush'));
ob_implicit_flush(false);
$this->_idStack[] = $id;
return false;
} | [
"public",
"function",
"start",
"(",
"$",
"id",
",",
"array",
"$",
"tags",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_tags",
"=",
"$",
"tags",
";",
"$",
"this",
"->",
"_extension",
"=",
"$",
"extension",
";",
"ob_start",
"(",... | Start the cache
@param string $id Cache id
@return mixed True if the cache is hit (false else) with $echoData=true (default) ; string else (datas) | [
"Start",
"the",
"cache"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Capture.php#L58-L66 | train | Start the current context | [
30522,
2270,
3853,
2707,
1006,
1002,
8909,
1010,
9140,
1002,
22073,
1010,
1002,
5331,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
22073,
1027,
1002,
22073,
1025,
1002,
2023,
1011,
1028,
1035,
5331,
1027,
1002,
5331,
1025,
27885,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Language/Language.php | Language.getLanguageURLPrefix | public function getLanguageURLPrefix($lang = null)
{
// if active lang is not passed in, use current active
if (!$lang) {
$lang = $this->getLanguage();
}
return $this->isIncludeDefaultLanguage($lang) ? '/' . $lang : '';
} | php | public function getLanguageURLPrefix($lang = null)
{
// if active lang is not passed in, use current active
if (!$lang) {
$lang = $this->getLanguage();
}
return $this->isIncludeDefaultLanguage($lang) ? '/' . $lang : '';
} | [
"public",
"function",
"getLanguageURLPrefix",
"(",
"$",
"lang",
"=",
"null",
")",
"{",
"// if active lang is not passed in, use current active",
"if",
"(",
"!",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"getLanguage",
"(",
")",
";",
"}",
"r... | Get's a URL prefix based on configuration
@param string|null $lang
@return string | [
"Get",
"s",
"a",
"URL",
"prefix",
"based",
"on",
"configuration"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L242-L250 | train | Get language URL prefix | [
30522,
2270,
3853,
2131,
25023,
6692,
3351,
3126,
14277,
2890,
8873,
2595,
1006,
1002,
11374,
1027,
19701,
1007,
1063,
1013,
1013,
2065,
3161,
11374,
2003,
2025,
2979,
1999,
1010,
2224,
2783,
3161,
2065,
1006,
999,
1002,
11374,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Adapter/GD.php | GD.rectangle | public function rectangle($x1, $y1, $w, $h, $color, $width, $style = null)
{
// Scale by the AA factor and DPI
$x1 = $this->_upscale($x1);
$y1 = $this->_upscale($y1);
$w = $this->_upscale($w);
$h = $this->_upscale($h);
$width = $this->_upscale($width);
$c = $this->_allocate_color($color);
// Convert the style array if required
if (is_array($style) && count($style) > 0) {
$gd_style = array();
foreach ($style as $length) {
for ($i = 0; $i < $length; $i++) {
$gd_style[] = $c;
}
}
if (!empty($gd_style)) {
imagesetstyle($this->get_image(), $gd_style);
$c = IMG_COLOR_STYLED;
}
}
imagesetthickness($this->get_image(), $width);
imagerectangle($this->get_image(), $x1, $y1, $x1 + $w, $y1 + $h, $c);
} | php | public function rectangle($x1, $y1, $w, $h, $color, $width, $style = null)
{
// Scale by the AA factor and DPI
$x1 = $this->_upscale($x1);
$y1 = $this->_upscale($y1);
$w = $this->_upscale($w);
$h = $this->_upscale($h);
$width = $this->_upscale($width);
$c = $this->_allocate_color($color);
// Convert the style array if required
if (is_array($style) && count($style) > 0) {
$gd_style = array();
foreach ($style as $length) {
for ($i = 0; $i < $length; $i++) {
$gd_style[] = $c;
}
}
if (!empty($gd_style)) {
imagesetstyle($this->get_image(), $gd_style);
$c = IMG_COLOR_STYLED;
}
}
imagesetthickness($this->get_image(), $width);
imagerectangle($this->get_image(), $x1, $y1, $x1 + $w, $y1 + $h, $c);
} | [
"public",
"function",
"rectangle",
"(",
"$",
"x1",
",",
"$",
"y1",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"color",
",",
"$",
"width",
",",
"$",
"style",
"=",
"null",
")",
"{",
"// Scale by the AA factor and DPI",
"$",
"x1",
"=",
"$",
"this",
"->",... | Draws a rectangle at x1,y1 with width w and height h
See {@link Style::munge_color()} for the format of the color array.
See {@link Cpdf::setLineStyle()} for a description of the $style
parameter (aka dash)
@param float $x1
@param float $y1
@param float $w
@param float $h
@param array $color
@param float $width
@param array $style | [
"Draws",
"a",
"rectangle",
"at",
"x1",
"y1",
"with",
"width",
"w",
"and",
"height",
"h"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L444-L475 | train | Rectangle - Image - Image | [
30522,
2270,
3853,
28667,
23395,
1006,
1002,
1060,
2487,
1010,
1002,
1061,
2487,
1010,
1002,
1059,
1010,
1002,
1044,
1010,
1002,
3609,
1010,
1002,
9381,
1010,
1002,
2806,
1027,
19701,
1007,
1063,
1013,
1013,
4094,
2011,
1996,
9779,
5387,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Yaml/Inline.php | Inline.parseScalar | public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array $references = [])
{
if (\in_array($scalar[$i], ['"', "'"])) {
// quoted scalar
$output = self::parseQuotedScalar($scalar, $i);
if (null !== $delimiters) {
$tmp = ltrim(substr($scalar, $i), ' ');
if ('' === $tmp) {
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
if (!\in_array($tmp[0], $delimiters)) {
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
}
} else {
// "normal" string
if (!$delimiters) {
$output = substr($scalar, $i);
$i += \strlen($output);
// remove comments
if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
$output = substr($output, 0, $match[0][1]);
}
} elseif (Parser::preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
$output = $match[1];
$i += \strlen($output);
$output = trim($output);
} else {
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
}
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0] || '%' === $output[0])) {
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]), self::$parsedLineNumber + 1, $output, self::$parsedFilename);
}
if ($evaluate) {
$output = self::evaluateScalar($output, $flags, $references);
}
}
return $output;
} | php | public static function parseScalar(string $scalar, int $flags = 0, array $delimiters = null, int &$i = 0, bool $evaluate = true, array $references = [])
{
if (\in_array($scalar[$i], ['"', "'"])) {
// quoted scalar
$output = self::parseQuotedScalar($scalar, $i);
if (null !== $delimiters) {
$tmp = ltrim(substr($scalar, $i), ' ');
if ('' === $tmp) {
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
if (!\in_array($tmp[0], $delimiters)) {
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
}
}
} else {
// "normal" string
if (!$delimiters) {
$output = substr($scalar, $i);
$i += \strlen($output);
// remove comments
if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
$output = substr($output, 0, $match[0][1]);
}
} elseif (Parser::preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
$output = $match[1];
$i += \strlen($output);
$output = trim($output);
} else {
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
}
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0] || '%' === $output[0])) {
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]), self::$parsedLineNumber + 1, $output, self::$parsedFilename);
}
if ($evaluate) {
$output = self::evaluateScalar($output, $flags, $references);
}
}
return $output;
} | [
"public",
"static",
"function",
"parseScalar",
"(",
"string",
"$",
"scalar",
",",
"int",
"$",
"flags",
"=",
"0",
",",
"array",
"$",
"delimiters",
"=",
"null",
",",
"int",
"&",
"$",
"i",
"=",
"0",
",",
"bool",
"$",
"evaluate",
"=",
"true",
",",
"arr... | Parses a YAML scalar.
@return mixed
@throws ParseException When malformed inline YAML string is parsed | [
"Parses",
"a",
"YAML",
"scalar",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Yaml/Inline.php#L266-L310 | train | Parse a YAML scalar. | [
30522,
2270,
10763,
3853,
11968,
8583,
25015,
2099,
1006,
5164,
1002,
26743,
2099,
1010,
20014,
1002,
9245,
1027,
1014,
1010,
9140,
1002,
3972,
27605,
7747,
1027,
19701,
1010,
20014,
1004,
1002,
1045,
1027,
1014,
1010,
22017,
2140,
1002,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/GD.php | GD.stream | public function stream($filename, $options = array())
{
if (headers_sent()) {
die("Unable to stream image: headers already sent");
}
if (!isset($options["type"])) $options["type"] = "png";
if (!isset($options["Attachment"])) $options["Attachment"] = true;
$type = strtolower($options["type"]);
switch ($type) {
case "jpg":
case "jpeg":
$contentType = "image/jpeg";
$extension = ".jpg";
break;
case "png":
default:
$contentType = "image/png";
$extension = ".png";
break;
}
header("Cache-Control: private");
header("Content-Type: $contentType");
$filename = str_replace(array("\n", "'"), "", basename($filename, ".$type")) . $extension;
$attachment = $options["Attachment"] ? "attachment" : "inline";
header(Helpers::buildContentDispositionHeader($attachment, $filename));
$this->_output($options);
flush();
} | php | public function stream($filename, $options = array())
{
if (headers_sent()) {
die("Unable to stream image: headers already sent");
}
if (!isset($options["type"])) $options["type"] = "png";
if (!isset($options["Attachment"])) $options["Attachment"] = true;
$type = strtolower($options["type"]);
switch ($type) {
case "jpg":
case "jpeg":
$contentType = "image/jpeg";
$extension = ".jpg";
break;
case "png":
default:
$contentType = "image/png";
$extension = ".png";
break;
}
header("Cache-Control: private");
header("Content-Type: $contentType");
$filename = str_replace(array("\n", "'"), "", basename($filename, ".$type")) . $extension;
$attachment = $options["Attachment"] ? "attachment" : "inline";
header(Helpers::buildContentDispositionHeader($attachment, $filename));
$this->_output($options);
flush();
} | [
"public",
"function",
"stream",
"(",
"$",
"filename",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"die",
"(",
"\"Unable to stream image: headers already sent\"",
")",
";",
"}",
"if",
"(",
"!",
"is... | Streams the image to the client.
@param string $filename The filename to present to the client.
@param array $options Associative array: 'type' => jpeg|jpg|png; 'quality' => 0 - 100 (JPEG only);
'page' => Number of the page to output (defaults to the first); 'Attachment': 1 or 0 (default 1). | [
"Streams",
"the",
"image",
"to",
"the",
"client",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L993-L1025 | train | Streams an image to the browser | [
30522,
2270,
3853,
5460,
1006,
1002,
5371,
18442,
1010,
1002,
7047,
1027,
9140,
1006,
1007,
1007,
1063,
2065,
1006,
20346,
2015,
1035,
2741,
1006,
1007,
1007,
1063,
3280,
1006,
1000,
4039,
2000,
5460,
3746,
1024,
20346,
2015,
2525,
2741,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Controllers/AuthController.php | AuthController.sendLoginResponse | protected function sendLoginResponse(Request $request)
{
admin_toastr(trans('admin.login_successful'));
$request->session()->regenerate();
return redirect()->intended($this->redirectPath());
} | php | protected function sendLoginResponse(Request $request)
{
admin_toastr(trans('admin.login_successful'));
$request->session()->regenerate();
return redirect()->intended($this->redirectPath());
} | [
"protected",
"function",
"sendLoginResponse",
"(",
"Request",
"$",
"request",
")",
"{",
"admin_toastr",
"(",
"trans",
"(",
"'admin.login_successful'",
")",
")",
";",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"regenerate",
"(",
")",
";",
"return",
"red... | Send the response after the user was authenticated.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"Send",
"the",
"response",
"after",
"the",
"user",
"was",
"authenticated",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Controllers/AuthController.php#L189-L196 | train | Send the login response to the user | [
30522,
5123,
3853,
4604,
21197,
2378,
6072,
26029,
3366,
1006,
5227,
1002,
5227,
1007,
1063,
4748,
10020,
1035,
15174,
2099,
1006,
9099,
1006,
1005,
4748,
10020,
1012,
8833,
2378,
1035,
3144,
1005,
1007,
1007,
1025,
1002,
5227,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Traits/MemcachedTrait.php | MemcachedTrait.doDelete | protected function doDelete(array $ids)
{
$ok = true;
$encodedIds = array_map('rawurlencode', $ids);
foreach ($this->checkResultCode($this->getClient()->deleteMulti($encodedIds)) as $result) {
if (\Memcached::RES_SUCCESS !== $result && \Memcached::RES_NOTFOUND !== $result) {
$ok = false;
}
}
return $ok;
} | php | protected function doDelete(array $ids)
{
$ok = true;
$encodedIds = array_map('rawurlencode', $ids);
foreach ($this->checkResultCode($this->getClient()->deleteMulti($encodedIds)) as $result) {
if (\Memcached::RES_SUCCESS !== $result && \Memcached::RES_NOTFOUND !== $result) {
$ok = false;
}
}
return $ok;
} | [
"protected",
"function",
"doDelete",
"(",
"array",
"$",
"ids",
")",
"{",
"$",
"ok",
"=",
"true",
";",
"$",
"encodedIds",
"=",
"array_map",
"(",
"'rawurlencode'",
",",
"$",
"ids",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"checkResultCode",
"(",
"$",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/MemcachedTrait.php#L277-L288 | train | Delete all entries from the cache | [
30522,
5123,
3853,
26489,
12260,
2618,
1006,
9140,
1002,
8909,
2015,
1007,
1063,
1002,
7929,
1027,
2995,
1025,
1002,
12359,
9821,
1027,
9140,
1035,
4949,
1006,
1005,
6315,
3126,
7770,
16044,
1005,
1010,
1002,
8909,
2015,
1007,
1025,
18921,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php | Connection.publish | public function publish(string $body, array $headers = [], int $delay = 0, AmqpStamp $amqpStamp = null): void
{
if (0 !== $delay) {
$this->publishWithDelay($body, $headers, $delay, $amqpStamp);
return;
}
if ($this->shouldSetup()) {
$this->setup();
}
$this->publishOnExchange(
$this->exchange(),
$body,
(null !== $amqpStamp ? $amqpStamp->getRoutingKey() : null) ?? $this->getDefaultPublishRoutingKey(),
[
'headers' => $headers,
],
$amqpStamp
);
} | php | public function publish(string $body, array $headers = [], int $delay = 0, AmqpStamp $amqpStamp = null): void
{
if (0 !== $delay) {
$this->publishWithDelay($body, $headers, $delay, $amqpStamp);
return;
}
if ($this->shouldSetup()) {
$this->setup();
}
$this->publishOnExchange(
$this->exchange(),
$body,
(null !== $amqpStamp ? $amqpStamp->getRoutingKey() : null) ?? $this->getDefaultPublishRoutingKey(),
[
'headers' => $headers,
],
$amqpStamp
);
} | [
"public",
"function",
"publish",
"(",
"string",
"$",
"body",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"int",
"$",
"delay",
"=",
"0",
",",
"AmqpStamp",
"$",
"amqpStamp",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"0",
"!==",
"$",
"del... | @param int $delay The delay in milliseconds
@throws \AMQPException | [
"@param",
"int",
"$delay",
"The",
"delay",
"in",
"milliseconds"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php#L174-L195 | train | Publishes a message to the exchange | [
30522,
2270,
3853,
10172,
1006,
5164,
1002,
2303,
1010,
9140,
1002,
20346,
2015,
1027,
1031,
1033,
1010,
20014,
1002,
8536,
1027,
1014,
1010,
2572,
4160,
4523,
15464,
2361,
1002,
2572,
4160,
4523,
15464,
2361,
1027,
19701,
1007,
1024,
11675... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.recurse | protected function recurse($directory, PageInterface $parent = null)
{
$directory = rtrim($directory, DS);
$page = new Page;
/** @var Config $config */
$config = $this->grav['config'];
/** @var Language $language */
$language = $this->grav['language'];
// Stuff to do at root page
// Fire event for memory and time consuming plugins...
if ($parent === null && $config->get('system.pages.events.page')) {
$this->grav->fireEvent('onBuildPagesInitialized');
}
$page->path($directory);
if ($parent) {
$page->parent($parent);
}
$page->orderDir($config->get('system.pages.order.dir'));
$page->orderBy($config->get('system.pages.order.by'));
// Add into instances
if (!isset($this->instances[$page->path()])) {
$this->instances[$page->path()] = $page;
if ($parent && $page->path()) {
$this->children[$parent->path()][$page->path()] = ['slug' => $page->slug()];
}
} else {
throw new \RuntimeException('Fatal error when creating page instances.');
}
// Build regular expression for all the allowed page extensions.
$page_extensions = $language->getFallbackPageExtensions();
$regex = '/^[^\.]*(' . implode('|', array_map(
function ($str) {
return preg_quote($str, '/');
},
$page_extensions
)) . ')$/';
$folders = [];
$page_found = null;
$page_extension = '.md';
$last_modified = 0;
$iterator = new \FilesystemIterator($directory);
/** @var \FilesystemIterator $file */
foreach ($iterator as $file) {
$filename = $file->getFilename();
// Ignore all hidden files if set.
if ($this->ignore_hidden && $filename && strpos($filename, '.') === 0) {
continue;
}
// Handle folders later.
if ($file->isDir()) {
// But ignore all folders in ignore list.
if (!\in_array($filename, $this->ignore_folders, true)) {
$folders[] = $file;
}
continue;
}
// Ignore all files in ignore list.
if (\in_array($filename, $this->ignore_files, true)) {
continue;
}
// Update last modified date to match the last updated file in the folder.
$modified = $file->getMTime();
if ($modified > $last_modified) {
$last_modified = $modified;
}
// Page is the one that matches to $page_extensions list with the lowest index number.
if (preg_match($regex, $filename, $matches, PREG_OFFSET_CAPTURE)) {
$ext = $matches[1][0];
if ($page_found === null || array_search($ext, $page_extensions, true) < array_search($page_extension, $page_extensions, true)) {
$page_found = $file;
$page_extension = $ext;
}
}
}
$content_exists = false;
if ($parent && $page_found) {
$page->init($page_found, $page_extension);
$content_exists = true;
if ($config->get('system.pages.events.page')) {
$this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
}
}
// Now handle all the folders under the page.
/** @var \FilesystemIterator $file */
foreach ($folders as $file) {
$filename = $file->getFilename();
// if folder contains separator, continue
if (Utils::contains($file->getFilename(), $config->get('system.param_sep', ':'))) {
continue;
}
if (!$page->path()) {
$page->path($file->getPath());
}
$path = $directory . DS . $filename;
$child = $this->recurse($path, $page);
if (Utils::startsWith($filename, '_')) {
$child->routable(false);
}
$this->children[$page->path()][$child->path()] = ['slug' => $child->slug()];
if ($config->get('system.pages.events.page')) {
$this->grav->fireEvent('onFolderProcessed', new Event(['page' => $page]));
}
}
if (!$content_exists) {
// Set routability to false if no page found
$page->routable(false);
// Hide empty folders if option set
if ($config->get('system.pages.hide_empty_folders')) {
$page->visible(false);
}
}
// Override the modified time if modular
if ($page->template() === 'modular') {
foreach ($page->collection() as $child) {
$modified = $child->modified();
if ($modified > $last_modified) {
$last_modified = $modified;
}
}
}
// Override the modified and ID so that it takes the latest change into account
$page->modified($last_modified);
$page->id($last_modified . md5($page->filePath()));
// Sort based on Defaults or Page Overridden sort order
$this->children[$page->path()] = $this->sort($page);
return $page;
} | php | protected function recurse($directory, PageInterface $parent = null)
{
$directory = rtrim($directory, DS);
$page = new Page;
/** @var Config $config */
$config = $this->grav['config'];
/** @var Language $language */
$language = $this->grav['language'];
// Stuff to do at root page
// Fire event for memory and time consuming plugins...
if ($parent === null && $config->get('system.pages.events.page')) {
$this->grav->fireEvent('onBuildPagesInitialized');
}
$page->path($directory);
if ($parent) {
$page->parent($parent);
}
$page->orderDir($config->get('system.pages.order.dir'));
$page->orderBy($config->get('system.pages.order.by'));
// Add into instances
if (!isset($this->instances[$page->path()])) {
$this->instances[$page->path()] = $page;
if ($parent && $page->path()) {
$this->children[$parent->path()][$page->path()] = ['slug' => $page->slug()];
}
} else {
throw new \RuntimeException('Fatal error when creating page instances.');
}
// Build regular expression for all the allowed page extensions.
$page_extensions = $language->getFallbackPageExtensions();
$regex = '/^[^\.]*(' . implode('|', array_map(
function ($str) {
return preg_quote($str, '/');
},
$page_extensions
)) . ')$/';
$folders = [];
$page_found = null;
$page_extension = '.md';
$last_modified = 0;
$iterator = new \FilesystemIterator($directory);
/** @var \FilesystemIterator $file */
foreach ($iterator as $file) {
$filename = $file->getFilename();
// Ignore all hidden files if set.
if ($this->ignore_hidden && $filename && strpos($filename, '.') === 0) {
continue;
}
// Handle folders later.
if ($file->isDir()) {
// But ignore all folders in ignore list.
if (!\in_array($filename, $this->ignore_folders, true)) {
$folders[] = $file;
}
continue;
}
// Ignore all files in ignore list.
if (\in_array($filename, $this->ignore_files, true)) {
continue;
}
// Update last modified date to match the last updated file in the folder.
$modified = $file->getMTime();
if ($modified > $last_modified) {
$last_modified = $modified;
}
// Page is the one that matches to $page_extensions list with the lowest index number.
if (preg_match($regex, $filename, $matches, PREG_OFFSET_CAPTURE)) {
$ext = $matches[1][0];
if ($page_found === null || array_search($ext, $page_extensions, true) < array_search($page_extension, $page_extensions, true)) {
$page_found = $file;
$page_extension = $ext;
}
}
}
$content_exists = false;
if ($parent && $page_found) {
$page->init($page_found, $page_extension);
$content_exists = true;
if ($config->get('system.pages.events.page')) {
$this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
}
}
// Now handle all the folders under the page.
/** @var \FilesystemIterator $file */
foreach ($folders as $file) {
$filename = $file->getFilename();
// if folder contains separator, continue
if (Utils::contains($file->getFilename(), $config->get('system.param_sep', ':'))) {
continue;
}
if (!$page->path()) {
$page->path($file->getPath());
}
$path = $directory . DS . $filename;
$child = $this->recurse($path, $page);
if (Utils::startsWith($filename, '_')) {
$child->routable(false);
}
$this->children[$page->path()][$child->path()] = ['slug' => $child->slug()];
if ($config->get('system.pages.events.page')) {
$this->grav->fireEvent('onFolderProcessed', new Event(['page' => $page]));
}
}
if (!$content_exists) {
// Set routability to false if no page found
$page->routable(false);
// Hide empty folders if option set
if ($config->get('system.pages.hide_empty_folders')) {
$page->visible(false);
}
}
// Override the modified time if modular
if ($page->template() === 'modular') {
foreach ($page->collection() as $child) {
$modified = $child->modified();
if ($modified > $last_modified) {
$last_modified = $modified;
}
}
}
// Override the modified and ID so that it takes the latest change into account
$page->modified($last_modified);
$page->id($last_modified . md5($page->filePath()));
// Sort based on Defaults or Page Overridden sort order
$this->children[$page->path()] = $this->sort($page);
return $page;
} | [
"protected",
"function",
"recurse",
"(",
"$",
"directory",
",",
"PageInterface",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"directory",
"=",
"rtrim",
"(",
"$",
"directory",
",",
"DS",
")",
";",
"$",
"page",
"=",
"new",
"Page",
";",
"/** @var Config $con... | Recursive function to load & build page relationships.
@param string $directory
@param PageInterface|null $parent
@return PageInterface
@throws \RuntimeException
@internal | [
"Recursive",
"function",
"to",
"load",
"&",
"build",
"page",
"relationships",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L1029-L1188 | train | Recurse through the directory and build pages | [
30522,
5123,
3853,
28667,
28393,
1006,
1002,
14176,
1010,
3931,
18447,
2121,
12172,
1002,
6687,
1027,
19701,
1007,
1063,
1002,
14176,
1027,
19387,
20026,
1006,
1002,
14176,
1010,
30524,
1008,
1008,
1030,
13075,
9530,
8873,
2290,
1002,
9530,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php | FileProfilerStorage.find | public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null)
{
$file = $this->getIndexFilename();
if (!file_exists($file)) {
return [];
}
$file = fopen($file, 'r');
fseek($file, 0, SEEK_END);
$result = [];
while (\count($result) < $limit && $line = $this->readLineFromFile($file)) {
$values = str_getcsv($line);
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode) = $values;
$csvTime = (int) $csvTime;
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method) || $statusCode && false === strpos($csvStatusCode, $statusCode)) {
continue;
}
if (!empty($start) && $csvTime < $start) {
continue;
}
if (!empty($end) && $csvTime > $end) {
continue;
}
$result[$csvToken] = [
'token' => $csvToken,
'ip' => $csvIp,
'method' => $csvMethod,
'url' => $csvUrl,
'time' => $csvTime,
'parent' => $csvParent,
'status_code' => $csvStatusCode,
];
}
fclose($file);
return array_values($result);
} | php | public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null)
{
$file = $this->getIndexFilename();
if (!file_exists($file)) {
return [];
}
$file = fopen($file, 'r');
fseek($file, 0, SEEK_END);
$result = [];
while (\count($result) < $limit && $line = $this->readLineFromFile($file)) {
$values = str_getcsv($line);
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent, $csvStatusCode) = $values;
$csvTime = (int) $csvTime;
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method) || $statusCode && false === strpos($csvStatusCode, $statusCode)) {
continue;
}
if (!empty($start) && $csvTime < $start) {
continue;
}
if (!empty($end) && $csvTime > $end) {
continue;
}
$result[$csvToken] = [
'token' => $csvToken,
'ip' => $csvIp,
'method' => $csvMethod,
'url' => $csvUrl,
'time' => $csvTime,
'parent' => $csvParent,
'status_code' => $csvStatusCode,
];
}
fclose($file);
return array_values($result);
} | [
"public",
"function",
"find",
"(",
"$",
"ip",
",",
"$",
"url",
",",
"$",
"limit",
",",
"$",
"method",
",",
"$",
"start",
"=",
"null",
",",
"$",
"end",
"=",
"null",
",",
"$",
"statusCode",
"=",
"null",
")",
"{",
"$",
"file",
"=",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php#L50-L93 | train | Find all tokens in the index file | [
30522,
2270,
3853,
2424,
1006,
1002,
12997,
1010,
1002,
24471,
2140,
1010,
1002,
5787,
1010,
1002,
4118,
1010,
1002,
2707,
1027,
19701,
1010,
1002,
2203,
1027,
19701,
1010,
1002,
3570,
16044,
1027,
19701,
1007,
1063,
1002,
5371,
1027,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php | RequestDecoratorTrait.withUri | public function withUri(UriInterface $uri, $preserveHost = false): self
{
$new = clone $this;
$new->message = $this->getRequest()->withUri($uri, $preserveHost);
return $new;
} | php | public function withUri(UriInterface $uri, $preserveHost = false): self
{
$new = clone $this;
$new->message = $this->getRequest()->withUri($uri, $preserveHost);
return $new;
} | [
"public",
"function",
"withUri",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"preserveHost",
"=",
"false",
")",
":",
"self",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"message",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
... | {@inheritdoc} | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Psr7/Traits/RequestDecoratorTrait.php#L105-L111 | train | Create a new instance with the request with the specified URI. | [
30522,
2270,
3853,
2007,
9496,
1006,
24471,
6137,
10111,
12881,
10732,
1002,
24471,
2072,
1010,
1002,
7969,
15006,
2102,
1027,
6270,
1007,
1024,
2969,
1063,
1002,
2047,
1027,
17598,
1002,
2023,
1025,
1002,
2047,
1011,
1028,
4471,
1027,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Filter/PatternRecursive.php | PatternRecursive.filter | public function filter($table)
{
$rows = $table->getRows();
foreach ($rows as $key => $row) {
// A row is deleted if
// 1 - its label doesn't contain the pattern
// AND 2 - the label is not found in the children
$patternNotFoundInChildren = false;
$subTable = $row->getSubtable();
if (!$subTable) {
$patternNotFoundInChildren = true;
} else {
// we delete the row if we couldn't find the pattern in any row in the
// children hierarchy
if ($this->filter($subTable) == 0) {
$patternNotFoundInChildren = true;
}
}
if ($patternNotFoundInChildren
&& !Pattern::match($this->patternToSearchQuoted, $row->getColumn($this->columnToFilter), $invertedMatch = false)
) {
$table->deleteRow($key);
}
}
return $table->getRowsCount();
} | php | public function filter($table)
{
$rows = $table->getRows();
foreach ($rows as $key => $row) {
// A row is deleted if
// 1 - its label doesn't contain the pattern
// AND 2 - the label is not found in the children
$patternNotFoundInChildren = false;
$subTable = $row->getSubtable();
if (!$subTable) {
$patternNotFoundInChildren = true;
} else {
// we delete the row if we couldn't find the pattern in any row in the
// children hierarchy
if ($this->filter($subTable) == 0) {
$patternNotFoundInChildren = true;
}
}
if ($patternNotFoundInChildren
&& !Pattern::match($this->patternToSearchQuoted, $row->getColumn($this->columnToFilter), $invertedMatch = false)
) {
$table->deleteRow($key);
}
}
return $table->getRowsCount();
} | [
"public",
"function",
"filter",
"(",
"$",
"table",
")",
"{",
"$",
"rows",
"=",
"$",
"table",
"->",
"getRows",
"(",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"// A row is deleted if",
"// 1 - its label doesn't co... | See {@link PatternRecursive}.
@param DataTable $table
@return int The number of deleted rows. | [
"See",
"{",
"@link",
"PatternRecursive",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/PatternRecursive.php#L53-L82 | train | Filter the table and return the number of rows that match the pattern to filter | [
30522,
2270,
3853,
11307,
1006,
1002,
2795,
1007,
1063,
1002,
10281,
1027,
1002,
2795,
1011,
1028,
2131,
10524,
2015,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
10281,
2004,
1002,
3145,
1027,
1028,
1002,
5216,
1007,
1063,
1013,
1013,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Factory.php | Factory.addExtensions | protected function addExtensions(Validator $validator)
{
$validator->addExtensions($this->extensions);
// Next, we will add the implicit extensions, which are similar to the required
// and accepted rule in that they are run even if the attributes is not in a
// array of data that is given to a validator instances via instantiation.
$validator->addImplicitExtensions($this->implicitExtensions);
$validator->addDependentExtensions($this->dependentExtensions);
$validator->addReplacers($this->replacers);
$validator->setFallbackMessages($this->fallbackMessages);
} | php | protected function addExtensions(Validator $validator)
{
$validator->addExtensions($this->extensions);
// Next, we will add the implicit extensions, which are similar to the required
// and accepted rule in that they are run even if the attributes is not in a
// array of data that is given to a validator instances via instantiation.
$validator->addImplicitExtensions($this->implicitExtensions);
$validator->addDependentExtensions($this->dependentExtensions);
$validator->addReplacers($this->replacers);
$validator->setFallbackMessages($this->fallbackMessages);
} | [
"protected",
"function",
"addExtensions",
"(",
"Validator",
"$",
"validator",
")",
"{",
"$",
"validator",
"->",
"addExtensions",
"(",
"$",
"this",
"->",
"extensions",
")",
";",
"// Next, we will add the implicit extensions, which are similar to the required",
"// and accept... | Add the extensions to a validator instance.
@param \Illuminate\Validation\Validator $validator
@return void | [
"Add",
"the",
"extensions",
"to",
"a",
"validator",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Factory.php#L163-L177 | train | Add the extensions to the validator | [
30522,
5123,
3853,
5587,
10288,
29048,
2015,
1006,
9398,
8844,
1002,
9398,
8844,
1007,
1063,
1002,
9398,
8844,
1011,
1028,
5587,
10288,
29048,
2015,
1006,
1002,
2023,
1011,
1028,
14305,
1007,
1025,
1013,
1013,
2279,
1010,
2057,
2097,
5587,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Renderer/Xml.php | Xml.renderDataTableMap | protected function renderDataTableMap($table, $array, $prefixLines = "")
{
// CASE 1
//array
// 'day1' => string '14' (length=2)
// 'day2' => string '6' (length=1)
$firstTable = current($array);
if (!is_array($firstTable)) {
$xml = '';
$nameDescriptionAttribute = $table->getKeyName();
foreach ($array as $valueAttribute => $value) {
if (empty($value)) {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\" />\n";
} elseif ($value instanceof Map) {
$out = $this->renderTable($value, true);
//TODO somehow this code is not tested, cover this case
$xml .= "\t<result $nameDescriptionAttribute=\"$valueAttribute\">\n$out</result>\n";
} else {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">" . self::formatValueXml($value) . "</result>\n";
}
}
return $xml;
}
$subTables = $table->getDataTables();
$firstTable = current($subTables);
// CASE 2
//array
// 'day1' =>
// array
// 'nb_uniq_visitors' => string '18'
// 'nb_visits' => string '101'
// 'day2' =>
// array
// 'nb_uniq_visitors' => string '28'
// 'nb_visits' => string '11'
if ($firstTable instanceof Simple) {
$xml = '';
$nameDescriptionAttribute = $table->getKeyName();
foreach ($array as $valueAttribute => $dataTableSimple) {
if (count($dataTableSimple) == 0) {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\" />\n";
} else {
if (is_array($dataTableSimple)) {
$dataTableSimple = "\n" . $this->renderDataTableSimple($dataTableSimple, $prefixLines . "\t") . $prefixLines . "\t";
}
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">" . $dataTableSimple . "</result>\n";
}
}
return $xml;
}
// CASE 3
//array
// 'day1' =>
// array
// 0 =>
// array
// 'label' => string 'phpmyvisites'
// 'nb_uniq_visitors' => int 11
// 'nb_visits' => int 13
// 1 =>
// array
// 'label' => string 'phpmyvisits'
// 'nb_uniq_visitors' => int 2
// 'nb_visits' => int 2
// 'day2' =>
// array
// 0 =>
// array
// 'label' => string 'piwik'
// 'nb_uniq_visitors' => int 121
// 'nb_visits' => int 130
// 1 =>
// array
// 'label' => string 'piwik bis'
// 'nb_uniq_visitors' => int 20
// 'nb_visits' => int 120
if ($firstTable instanceof DataTable) {
$xml = '';
$nameDescriptionAttribute = $table->getKeyName();
foreach ($array as $keyName => $arrayForSingleDate) {
$dataTableOut = $this->renderDataTable($arrayForSingleDate, $prefixLines . "\t");
if (empty($dataTableOut)) {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$keyName\" />\n";
} else {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$keyName\">\n";
$xml .= $dataTableOut;
$xml .= $prefixLines . "\t</result>\n";
}
}
return $xml;
}
if ($firstTable instanceof Map) {
$xml = '';
$tables = $table->getDataTables();
$nameDescriptionAttribute = $table->getKeyName();
foreach ($tables as $valueAttribute => $tableInArray) {
$out = $this->renderTable($tableInArray, true, $prefixLines . "\t");
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">\n" . $out . $prefixLines . "\t</result>\n";
}
return $xml;
}
return '';
} | php | protected function renderDataTableMap($table, $array, $prefixLines = "")
{
// CASE 1
//array
// 'day1' => string '14' (length=2)
// 'day2' => string '6' (length=1)
$firstTable = current($array);
if (!is_array($firstTable)) {
$xml = '';
$nameDescriptionAttribute = $table->getKeyName();
foreach ($array as $valueAttribute => $value) {
if (empty($value)) {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\" />\n";
} elseif ($value instanceof Map) {
$out = $this->renderTable($value, true);
//TODO somehow this code is not tested, cover this case
$xml .= "\t<result $nameDescriptionAttribute=\"$valueAttribute\">\n$out</result>\n";
} else {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">" . self::formatValueXml($value) . "</result>\n";
}
}
return $xml;
}
$subTables = $table->getDataTables();
$firstTable = current($subTables);
// CASE 2
//array
// 'day1' =>
// array
// 'nb_uniq_visitors' => string '18'
// 'nb_visits' => string '101'
// 'day2' =>
// array
// 'nb_uniq_visitors' => string '28'
// 'nb_visits' => string '11'
if ($firstTable instanceof Simple) {
$xml = '';
$nameDescriptionAttribute = $table->getKeyName();
foreach ($array as $valueAttribute => $dataTableSimple) {
if (count($dataTableSimple) == 0) {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\" />\n";
} else {
if (is_array($dataTableSimple)) {
$dataTableSimple = "\n" . $this->renderDataTableSimple($dataTableSimple, $prefixLines . "\t") . $prefixLines . "\t";
}
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">" . $dataTableSimple . "</result>\n";
}
}
return $xml;
}
// CASE 3
//array
// 'day1' =>
// array
// 0 =>
// array
// 'label' => string 'phpmyvisites'
// 'nb_uniq_visitors' => int 11
// 'nb_visits' => int 13
// 1 =>
// array
// 'label' => string 'phpmyvisits'
// 'nb_uniq_visitors' => int 2
// 'nb_visits' => int 2
// 'day2' =>
// array
// 0 =>
// array
// 'label' => string 'piwik'
// 'nb_uniq_visitors' => int 121
// 'nb_visits' => int 130
// 1 =>
// array
// 'label' => string 'piwik bis'
// 'nb_uniq_visitors' => int 20
// 'nb_visits' => int 120
if ($firstTable instanceof DataTable) {
$xml = '';
$nameDescriptionAttribute = $table->getKeyName();
foreach ($array as $keyName => $arrayForSingleDate) {
$dataTableOut = $this->renderDataTable($arrayForSingleDate, $prefixLines . "\t");
if (empty($dataTableOut)) {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$keyName\" />\n";
} else {
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$keyName\">\n";
$xml .= $dataTableOut;
$xml .= $prefixLines . "\t</result>\n";
}
}
return $xml;
}
if ($firstTable instanceof Map) {
$xml = '';
$tables = $table->getDataTables();
$nameDescriptionAttribute = $table->getKeyName();
foreach ($tables as $valueAttribute => $tableInArray) {
$out = $this->renderTable($tableInArray, true, $prefixLines . "\t");
$xml .= $prefixLines . "\t<result $nameDescriptionAttribute=\"$valueAttribute\">\n" . $out . $prefixLines . "\t</result>\n";
}
return $xml;
}
return '';
} | [
"protected",
"function",
"renderDataTableMap",
"(",
"$",
"table",
",",
"$",
"array",
",",
"$",
"prefixLines",
"=",
"\"\"",
")",
"{",
"// CASE 1",
"//array",
"// 'day1' => string '14' (length=2)",
"// 'day2' => string '6' (length=1)",
"$",
"firstTable",
"=",
"current",... | Computes the output for the given data table array
@param Map $table
@param array $array
@param string $prefixLines
@return string | [
"Computes",
"the",
"output",
"for",
"the",
"given",
"data",
"table",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Renderer/Xml.php#L223-L330 | train | Render the data table | [
30522,
5123,
3853,
17552,
2850,
29336,
3085,
2863,
2361,
1006,
1002,
2795,
1010,
1002,
9140,
1010,
1002,
17576,
12735,
1027,
1000,
1000,
1007,
1063,
1013,
1013,
2553,
1015,
1013,
1013,
9140,
1013,
1013,
1005,
2154,
2487,
1005,
1027,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Exceptions/Handler.php | Handler.convertValidationExceptionToResponse | protected function convertValidationExceptionToResponse(ValidationException $e, $request)
{
if ($e->response) {
return $e->response;
}
return $request->expectsJson()
? $this->invalidJson($request, $e)
: $this->invalid($request, $e);
} | php | protected function convertValidationExceptionToResponse(ValidationException $e, $request)
{
if ($e->response) {
return $e->response;
}
return $request->expectsJson()
? $this->invalidJson($request, $e)
: $this->invalid($request, $e);
} | [
"protected",
"function",
"convertValidationExceptionToResponse",
"(",
"ValidationException",
"$",
"e",
",",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"response",
")",
"{",
"return",
"$",
"e",
"->",
"response",
";",
"}",
"return",
"$",
"request",
... | Create a response object from the given validation exception.
@param \Illuminate\Validation\ValidationException $e
@param \Illuminate\Http\Request $request
@return \Symfony\Component\HttpFoundation\Response | [
"Create",
"a",
"response",
"object",
"from",
"the",
"given",
"validation",
"exception",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Exceptions/Handler.php#L231-L240 | train | Convert a validation exception to a response | [
30522,
5123,
3853,
10463,
10175,
8524,
3508,
10288,
24422,
19277,
13102,
5644,
2063,
1006,
27354,
10288,
24422,
1002,
1041,
1010,
1002,
5227,
1007,
1063,
2065,
1006,
1002,
1041,
1011,
1028,
3433,
1007,
1063,
2709,
1002,
1041,
1011,
1028,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
slimphp/Slim | Slim/Http/Stream.php | Stream.close | public function close()
{
if ($this->isAttached() === true) {
if ($this->isPipe()) {
pclose($this->stream);
} else {
fclose($this->stream);
}
}
$this->detach();
} | php | public function close()
{
if ($this->isAttached() === true) {
if ($this->isPipe()) {
pclose($this->stream);
} else {
fclose($this->stream);
}
}
$this->detach();
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAttached",
"(",
")",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPipe",
"(",
")",
")",
"{",
"pclose",
"(",
"$",
"this",
"->",
"stream",
")",
";",
"}",
... | Closes the stream and any underlying resources. | [
"Closes",
"the",
"stream",
"and",
"any",
"underlying",
"resources",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Stream.php#L208-L219 | train | Closes the stream | [
30522,
2270,
3853,
2485,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
18061,
5946,
7690,
1006,
1007,
1027,
1027,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
24548,
1006,
1007,
1007,
1063,
7473,
10483,
2063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php | ControllerResolver.createController | protected function createController($controller)
{
if (false === strpos($controller, '::') && 2 === substr_count($controller, ':')) {
// controller in the a:b:c notation then
$deprecatedNotation = $controller;
$controller = $this->parser->parse($deprecatedNotation, false);
@trigger_error(sprintf('Referencing controllers with %s is deprecated since Symfony 4.1. Use %s instead.', $deprecatedNotation, $controller), E_USER_DEPRECATED);
}
return parent::createController($controller);
} | php | protected function createController($controller)
{
if (false === strpos($controller, '::') && 2 === substr_count($controller, ':')) {
// controller in the a:b:c notation then
$deprecatedNotation = $controller;
$controller = $this->parser->parse($deprecatedNotation, false);
@trigger_error(sprintf('Referencing controllers with %s is deprecated since Symfony 4.1. Use %s instead.', $deprecatedNotation, $controller), E_USER_DEPRECATED);
}
return parent::createController($controller);
} | [
"protected",
"function",
"createController",
"(",
"$",
"controller",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"controller",
",",
"'::'",
")",
"&&",
"2",
"===",
"substr_count",
"(",
"$",
"controller",
",",
"':'",
")",
")",
"{",
"// control... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php#L36-L47 | train | Create a controller from a string | [
30522,
5123,
3853,
3443,
8663,
13181,
10820,
1006,
1002,
11486,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
2358,
14536,
2891,
1006,
1002,
11486,
1010,
1005,
1024,
1024,
1005,
1007,
1004,
1004,
1016,
1027,
1027,
1027,
4942,
3367,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Renderer.php | Renderer.translateColumnNames | protected function translateColumnNames($names)
{
if (!$this->apiMethod) {
return $names;
}
// load the translations only once
// when multiple dates are requested (date=...,...&period=day), the meta data would
// be loaded lots of times otherwise
if ($this->columnTranslations === false) {
$meta = $this->getApiMetaData();
if ($meta === false) {
return $names;
}
$t = Metrics::getDefaultMetricTranslations();
foreach (array('metrics', 'processedMetrics', 'metricsGoal', 'processedMetricsGoal') as $index) {
if (isset($meta[$index]) && is_array($meta[$index])) {
$t = array_merge($t, $meta[$index]);
}
}
foreach (Dimension::getAllDimensions() as $dimension) {
$dimensionId = str_replace('.', '_', $dimension->getId());
$dimensionName = $dimension->getName();
if (!empty($dimensionId) && !empty($dimensionName)) {
$t[$dimensionId] = $dimensionName;
}
}
$this->columnTranslations = & $t;
}
foreach ($names as &$name) {
if (isset($this->columnTranslations[$name])) {
$name = $this->columnTranslations[$name];
}
}
return $names;
} | php | protected function translateColumnNames($names)
{
if (!$this->apiMethod) {
return $names;
}
// load the translations only once
// when multiple dates are requested (date=...,...&period=day), the meta data would
// be loaded lots of times otherwise
if ($this->columnTranslations === false) {
$meta = $this->getApiMetaData();
if ($meta === false) {
return $names;
}
$t = Metrics::getDefaultMetricTranslations();
foreach (array('metrics', 'processedMetrics', 'metricsGoal', 'processedMetricsGoal') as $index) {
if (isset($meta[$index]) && is_array($meta[$index])) {
$t = array_merge($t, $meta[$index]);
}
}
foreach (Dimension::getAllDimensions() as $dimension) {
$dimensionId = str_replace('.', '_', $dimension->getId());
$dimensionName = $dimension->getName();
if (!empty($dimensionId) && !empty($dimensionName)) {
$t[$dimensionId] = $dimensionName;
}
}
$this->columnTranslations = & $t;
}
foreach ($names as &$name) {
if (isset($this->columnTranslations[$name])) {
$name = $this->columnTranslations[$name];
}
}
return $names;
} | [
"protected",
"function",
"translateColumnNames",
"(",
"$",
"names",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"apiMethod",
")",
"{",
"return",
"$",
"names",
";",
"}",
"// load the translations only once",
"// when multiple dates are requested (date=...,...&period=day... | Translate column names to the current language.
Used in subclasses.
@param array $names
@return array | [
"Translate",
"column",
"names",
"to",
"the",
"current",
"language",
".",
"Used",
"in",
"subclasses",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Renderer.php#L212-L253 | train | Translates column names | [
30522,
5123,
3853,
17637,
25778,
2819,
9516,
7834,
1006,
1002,
3415,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
17928,
11368,
6806,
2094,
1007,
1063,
2709,
1002,
3415,
1025,
1065,
1013,
1013,
7170,
1996,
11913,
2069,
2320,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php | FormTypeCsrfExtension.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['csrf_protection']) {
return;
}
$builder
->addEventSubscriber(new CsrfValidationListener(
$options['csrf_field_name'],
$options['csrf_token_manager'],
$options['csrf_token_id'] ?: ($builder->getName() ?: \get_class($builder->getType()->getInnerType())),
$options['csrf_message'],
$this->translator,
$this->translationDomain,
$this->serverParams
))
;
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['csrf_protection']) {
return;
}
$builder
->addEventSubscriber(new CsrfValidationListener(
$options['csrf_field_name'],
$options['csrf_token_manager'],
$options['csrf_token_id'] ?: ($builder->getName() ?: \get_class($builder->getType()->getInnerType())),
$options['csrf_message'],
$this->translator,
$this->translationDomain,
$this->serverParams
))
;
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"$",
"options",
"[",
"'csrf_protection'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"builder",
"->",
"addEventSubscriber",
... | Adds a CSRF field to the form when the CSRF protection is enabled.
@param FormBuilderInterface $builder The form builder
@param array $options The options | [
"Adds",
"a",
"CSRF",
"field",
"to",
"the",
"form",
"when",
"the",
"CSRF",
"protection",
"is",
"enabled",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php#L60-L77 | train | Adds the CSRF protection to the form builder | [
30522,
2270,
3853,
3857,
14192,
1006,
2433,
8569,
23891,
6657,
3334,
12172,
1002,
12508,
1010,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
999,
1002,
7047,
1031,
1005,
20116,
12881,
1035,
3860,
1005,
1033,
1007,
1063,
2709,
1025,
1065,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Protocols/Http.php | Http.sessionSavePath | public static function sessionSavePath($path = null)
{
if (PHP_SAPI != 'cli') {
return $path ? session_save_path($path) : session_save_path();
}
if ($path && is_dir($path) && is_writable($path) && !static::sessionStarted()) {
HttpCache::$sessionPath = $path;
}
return HttpCache::$sessionPath;
} | php | public static function sessionSavePath($path = null)
{
if (PHP_SAPI != 'cli') {
return $path ? session_save_path($path) : session_save_path();
}
if ($path && is_dir($path) && is_writable($path) && !static::sessionStarted()) {
HttpCache::$sessionPath = $path;
}
return HttpCache::$sessionPath;
} | [
"public",
"static",
"function",
"sessionSavePath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"PHP_SAPI",
"!=",
"'cli'",
")",
"{",
"return",
"$",
"path",
"?",
"session_save_path",
"(",
"$",
"path",
")",
":",
"session_save_path",
"(",
")",
";",
... | sessionSavePath
@param string $path
@return void | [
"sessionSavePath"
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Http.php#L416-L425 | train | Return session save path | [
30522,
2270,
10763,
3853,
6521,
10696,
15069,
1006,
1002,
4130,
1027,
19701,
1007,
1063,
2065,
1006,
25718,
1035,
20066,
2072,
999,
1027,
1005,
18856,
2072,
1005,
1007,
1063,
2709,
1002,
4130,
1029,
5219,
1035,
3828,
1035,
4130,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Transport/File.php | Zend_Mail_Transport_File.setOptions | public function setOptions(array $options)
{
if (isset($options['path']) && is_dir($options['path'])) {
$this->_path = $options['path'];
}
if (isset($options['callback']) && is_callable($options['callback'])) {
$this->_callback = $options['callback'];
}
} | php | public function setOptions(array $options)
{
if (isset($options['path']) && is_dir($options['path'])) {
$this->_path = $options['path'];
}
if (isset($options['callback']) && is_callable($options['callback'])) {
$this->_callback = $options['callback'];
}
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'path'",
"]",
")",
"&&",
"is_dir",
"(",
"$",
"options",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_path",
"=",
... | Sets options
@param array $options
@return void | [
"Sets",
"options"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Transport/File.php#L87-L95 | train | Set options for this class | [
30522,
2270,
3853,
2275,
7361,
9285,
1006,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
7047,
1031,
1005,
4130,
1005,
1033,
1007,
1004,
1004,
2003,
1035,
16101,
1006,
1002,
7047,
1031,
1005,
4130,
1005,
1033,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php | AbstractObjectNormalizer.getAttributes | protected function getAttributes($object, $format = null, array $context)
{
$class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object);
$key = $class.'-'.$context['cache_key'];
if (isset($this->attributesCache[$key])) {
return $this->attributesCache[$key];
}
$allowedAttributes = $this->getAllowedAttributes($object, $context, true);
if (false !== $allowedAttributes) {
if ($context['cache_key']) {
$this->attributesCache[$key] = $allowedAttributes;
}
return $allowedAttributes;
}
$attributes = $this->extractAttributes($object, $format, $context);
if ($this->classDiscriminatorResolver && $mapping = $this->classDiscriminatorResolver->getMappingForMappedObject($object)) {
array_unshift($attributes, $mapping->getTypeProperty());
}
if ($context['cache_key']) {
$this->attributesCache[$key] = $attributes;
}
return $attributes;
} | php | protected function getAttributes($object, $format = null, array $context)
{
$class = $this->objectClassResolver ? ($this->objectClassResolver)($object) : \get_class($object);
$key = $class.'-'.$context['cache_key'];
if (isset($this->attributesCache[$key])) {
return $this->attributesCache[$key];
}
$allowedAttributes = $this->getAllowedAttributes($object, $context, true);
if (false !== $allowedAttributes) {
if ($context['cache_key']) {
$this->attributesCache[$key] = $allowedAttributes;
}
return $allowedAttributes;
}
$attributes = $this->extractAttributes($object, $format, $context);
if ($this->classDiscriminatorResolver && $mapping = $this->classDiscriminatorResolver->getMappingForMappedObject($object)) {
array_unshift($attributes, $mapping->getTypeProperty());
}
if ($context['cache_key']) {
$this->attributesCache[$key] = $attributes;
}
return $attributes;
} | [
"protected",
"function",
"getAttributes",
"(",
"$",
"object",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"objectClassResolver",
"?",
"(",
"$",
"this",
"->",
"objectClassResolver",
")",
"... | Gets and caches attributes for the given object, format and context.
@param object $object
@param string|null $format
@param array $context
@return string[] | [
"Gets",
"and",
"caches",
"attributes",
"for",
"the",
"given",
"object",
"format",
"and",
"context",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php#L243-L273 | train | Get the attributes of an object | [
30522,
5123,
3853,
2131,
19321,
3089,
8569,
4570,
1006,
1002,
4874,
1010,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1007,
1063,
1002,
2465,
1027,
1002,
2023,
1011,
1028,
4874,
26266,
6072,
4747,
6299,
1029,
1006,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/UpdateManager.php | UpdateManager.updatePlugin | public function updatePlugin($name)
{
/*
* Update the plugin database and version
*/
if (!($plugin = $this->pluginManager->findByIdentifier($name))) {
$this->note('<error>Unable to find:</error> ' . $name);
return;
}
$this->note($name);
$this->versionManager->resetNotes()->setNotesOutput($this->notesOutput);
if ($this->versionManager->updatePlugin($plugin) !== false) {
foreach ($this->versionManager->getNotes() as $note) {
$this->note($note);
}
}
return $this;
} | php | public function updatePlugin($name)
{
/*
* Update the plugin database and version
*/
if (!($plugin = $this->pluginManager->findByIdentifier($name))) {
$this->note('<error>Unable to find:</error> ' . $name);
return;
}
$this->note($name);
$this->versionManager->resetNotes()->setNotesOutput($this->notesOutput);
if ($this->versionManager->updatePlugin($plugin) !== false) {
foreach ($this->versionManager->getNotes() as $note) {
$this->note($note);
}
}
return $this;
} | [
"public",
"function",
"updatePlugin",
"(",
"$",
"name",
")",
"{",
"/*\n * Update the plugin database and version\n */",
"if",
"(",
"!",
"(",
"$",
"plugin",
"=",
"$",
"this",
"->",
"pluginManager",
"->",
"findByIdentifier",
"(",
"$",
"name",
")",
")... | Runs update on a single plugin
@param string $name Plugin name.
@return self | [
"Runs",
"update",
"on",
"a",
"single",
"plugin"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/UpdateManager.php#L511-L533 | train | Update the plugin database and version | [
30522,
2270,
3853,
10651,
24759,
15916,
2378,
1006,
1002,
2171,
1007,
1063,
1013,
1008,
1008,
10651,
1996,
13354,
2378,
7809,
1998,
2544,
1008,
1013,
2065,
1006,
999,
1006,
1002,
13354,
2378,
1027,
1002,
2023,
1011,
1028,
13354,
2378,
24805... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php | FormDataExtractor.extractConfiguration | public function extractConfiguration(FormInterface $form)
{
$data = [
'id' => $this->buildId($form),
'name' => $form->getName(),
'type_class' => \get_class($form->getConfig()->getType()->getInnerType()),
'synchronized' => $form->isSynchronized(),
'passed_options' => [],
'resolved_options' => [],
];
foreach ($form->getConfig()->getAttribute('data_collector/passed_options', []) as $option => $value) {
$data['passed_options'][$option] = $value;
}
foreach ($form->getConfig()->getOptions() as $option => $value) {
$data['resolved_options'][$option] = $value;
}
ksort($data['passed_options']);
ksort($data['resolved_options']);
return $data;
} | php | public function extractConfiguration(FormInterface $form)
{
$data = [
'id' => $this->buildId($form),
'name' => $form->getName(),
'type_class' => \get_class($form->getConfig()->getType()->getInnerType()),
'synchronized' => $form->isSynchronized(),
'passed_options' => [],
'resolved_options' => [],
];
foreach ($form->getConfig()->getAttribute('data_collector/passed_options', []) as $option => $value) {
$data['passed_options'][$option] = $value;
}
foreach ($form->getConfig()->getOptions() as $option => $value) {
$data['resolved_options'][$option] = $value;
}
ksort($data['passed_options']);
ksort($data['resolved_options']);
return $data;
} | [
"public",
"function",
"extractConfiguration",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"data",
"=",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"buildId",
"(",
"$",
"form",
")",
",",
"'name'",
"=>",
"$",
"form",
"->",
"getName",
"(",
")",
",",
"'t... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php#L28-L51 | train | Extract configuration from form | [
30522,
2270,
3853,
14817,
8663,
8873,
27390,
3370,
1006,
2433,
18447,
2121,
12172,
1002,
2433,
1007,
1063,
1002,
2951,
1027,
1031,
1005,
8909,
1005,
1027,
1028,
1002,
2023,
1011,
1028,
3857,
3593,
1006,
1002,
2433,
1007,
1010,
1005,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field.php | Field.getElementClass | protected function getElementClass()
{
if (!$this->elementClass) {
$name = $this->elementName ?: $this->formatName($this->column);
$this->elementClass = (array) str_replace(['[', ']'], '_', $name);
}
return $this->elementClass;
} | php | protected function getElementClass()
{
if (!$this->elementClass) {
$name = $this->elementName ?: $this->formatName($this->column);
$this->elementClass = (array) str_replace(['[', ']'], '_', $name);
}
return $this->elementClass;
} | [
"protected",
"function",
"getElementClass",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"elementClass",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"elementName",
"?",
":",
"$",
"this",
"->",
"formatName",
"(",
"$",
"this",
"->",
"column",
"... | Get element class.
@return array | [
"Get",
"element",
"class",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field.php#L931-L940 | train | Get element class | [
30522,
5123,
3853,
2131,
12260,
3672,
26266,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
5783,
26266,
1007,
30524,
9140,
1007,
2358,
2099,
1035,
5672,
1006,
1031,
1005,
1031,
1005,
1010,
1005,
1033,
1005,
1033,
1010,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/Model.php | Model.getAliasSiteUrlsFromId | public function getAliasSiteUrlsFromId($idSite)
{
$db = $this->getDb();
$result = $db->fetchAll("SELECT url FROM " . Common::prefixTable("site_url") . "
WHERE idsite = ?", $idSite);
$urls = array();
foreach ($result as $url) {
$urls[] = $url['url'];
}
return $urls;
} | php | public function getAliasSiteUrlsFromId($idSite)
{
$db = $this->getDb();
$result = $db->fetchAll("SELECT url FROM " . Common::prefixTable("site_url") . "
WHERE idsite = ?", $idSite);
$urls = array();
foreach ($result as $url) {
$urls[] = $url['url'];
}
return $urls;
} | [
"public",
"function",
"getAliasSiteUrlsFromId",
"(",
"$",
"idSite",
")",
"{",
"$",
"db",
"=",
"$",
"this",
"->",
"getDb",
"(",
")",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"fetchAll",
"(",
"\"SELECT url FROM \"",
".",
"Common",
"::",
"prefixTable",
"("... | Returns the list of alias URLs registered for the given idSite.
The website ID must be valid when calling this method!
@param int $idSite
@return array list of alias URLs | [
"Returns",
"the",
"list",
"of",
"alias",
"URLs",
"registered",
"for",
"the",
"given",
"idSite",
".",
"The",
"website",
"ID",
"must",
"be",
"valid",
"when",
"calling",
"this",
"method!"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L283-L295 | train | Get alias site urls from id | [
30522,
2270,
3853,
2131,
22786,
18719,
2618,
3126,
4877,
19699,
20936,
2094,
1006,
1002,
8909,
28032,
2063,
1007,
1063,
1002,
16962,
1027,
1002,
2023,
1011,
1028,
2131,
18939,
1006,
1007,
1025,
1002,
2765,
1027,
1002,
16962,
1011,
1028,
185... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/RedisStore.php | RedisStore.forever | public function forever($key, $value)
{
return (bool) $this->connection()->set($this->prefix.$key, $this->serialize($value));
} | php | public function forever($key, $value)
{
return (bool) $this->connection()->set($this->prefix.$key, $this->serialize($value));
} | [
"public",
"function",
"forever",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"connection",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"key",
",",
"$",
"this",
"->",
"seriali... | Store an item in the cache indefinitely.
@param string $key
@param mixed $value
@return bool | [
"Store",
"an",
"item",
"in",
"the",
"cache",
"indefinitely",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/RedisStore.php#L169-L172 | train | Store a value in the cache forever | [
30522,
2270,
3853,
5091,
1006,
1002,
3145,
1010,
1002,
3643,
1007,
1063,
2709,
1006,
22017,
2140,
1007,
1002,
2023,
1011,
1028,
4434,
1006,
1007,
1011,
1028,
2275,
1006,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
3145,
1010,
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... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.selectSub | public function selectSub($query, $as)
{
[$query, $bindings] = $this->createSub($query);
return $this->selectRaw(
'('.$query.') as '.$this->grammar->wrap($as), $bindings
);
} | php | public function selectSub($query, $as)
{
[$query, $bindings] = $this->createSub($query);
return $this->selectRaw(
'('.$query.') as '.$this->grammar->wrap($as), $bindings
);
} | [
"public",
"function",
"selectSub",
"(",
"$",
"query",
",",
"$",
"as",
")",
"{",
"[",
"$",
"query",
",",
"$",
"bindings",
"]",
"=",
"$",
"this",
"->",
"createSub",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
"->",
"selectRaw",
"(",
"'('",
... | Add a subselect expression to the query.
@param \Closure|\Illuminate\Database\Query\Builder|string $query
@param string $as
@return \Illuminate\Database\Query\Builder|static
@throws \InvalidArgumentException | [
"Add",
"a",
"subselect",
"expression",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L236-L243 | train | Select a sub - term or term. | [
30522,
2270,
3853,
27034,
12083,
1006,
1002,
23032,
1010,
1002,
2004,
1007,
1063,
1031,
1002,
23032,
1010,
1002,
8031,
2015,
1033,
1027,
1002,
2023,
1011,
1028,
9005,
12083,
1006,
1002,
23032,
1007,
1025,
2709,
1002,
2023,
1011,
1028,
7276,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Controller.php | HTML_QuickForm2_Controller.findControllerID | public static function findControllerID()
{
if (empty($_REQUEST[self::KEY_ID])
|| empty($_SESSION[sprintf(self::KEY_CONTAINER, $_REQUEST[self::KEY_ID])])
) {
return null;
} else {
return $_REQUEST[self::KEY_ID];
}
} | php | public static function findControllerID()
{
if (empty($_REQUEST[self::KEY_ID])
|| empty($_SESSION[sprintf(self::KEY_CONTAINER, $_REQUEST[self::KEY_ID])])
) {
return null;
} else {
return $_REQUEST[self::KEY_ID];
}
} | [
"public",
"static",
"function",
"findControllerID",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_REQUEST",
"[",
"self",
"::",
"KEY_ID",
"]",
")",
"||",
"empty",
"(",
"$",
"_SESSION",
"[",
"sprintf",
"(",
"self",
"::",
"KEY_CONTAINER",
",",
"$",
"_REQ... | Finds a controller name in $_REQUEST
@return string|null Returns nulle if either a KEY_ID is not present
in $_REQUEST or KEY_CONTAINER is not present in
$_SESSION | [
"Finds",
"a",
"controller",
"name",
"in",
"$_REQUEST"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Controller.php#L129-L138 | train | Find Controller ID | [
30522,
2270,
10763,
3853,
2424,
8663,
13181,
10820,
3593,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
1035,
5227,
1031,
2969,
1024,
1024,
3145,
1035,
8909,
1033,
1007,
1064,
1064,
4064,
1006,
1002,
1035,
5219,
1031,
9043,
2546,
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/AssetManager/UIAssetMinifier.php | UIAssetMinifier.isMinifiedJs | public function isMinifiedJs($content)
{
$lineCount = substr_count($content, "\n");
if ($lineCount == 0) {
return true;
}
$contentSize = strlen($content);
$ratio = $contentSize / $lineCount;
return $ratio > self::MINIFIED_JS_RATIO;
} | php | public function isMinifiedJs($content)
{
$lineCount = substr_count($content, "\n");
if ($lineCount == 0) {
return true;
}
$contentSize = strlen($content);
$ratio = $contentSize / $lineCount;
return $ratio > self::MINIFIED_JS_RATIO;
} | [
"public",
"function",
"isMinifiedJs",
"(",
"$",
"content",
")",
"{",
"$",
"lineCount",
"=",
"substr_count",
"(",
"$",
"content",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"lineCount",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"$",
"contentSize",... | Indicates if the provided JavaScript content has already been minified or not.
The heuristic is based on a custom ratio : (size of file) / (number of lines).
The threshold (100) has been found empirically on existing files :
- the ratio never exceeds 50 for non-minified content and
- it never goes under 150 for minified content.
@param string $content Contents of the JavaScript file
@return boolean | [
"Indicates",
"if",
"the",
"provided",
"JavaScript",
"content",
"has",
"already",
"been",
"minified",
"or",
"not",
".",
"The",
"heuristic",
"is",
"based",
"on",
"a",
"custom",
"ratio",
":",
"(",
"size",
"of",
"file",
")",
"/",
"(",
"number",
"of",
"lines"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/AssetManager/UIAssetMinifier.php#L36-L49 | train | Checks if the content is minified JS | [
30522,
2270,
3853,
2003,
25300,
10451,
22578,
1006,
1002,
4180,
1007,
1063,
1002,
2240,
3597,
16671,
1027,
4942,
3367,
2099,
1035,
4175,
1006,
1002,
4180,
1010,
1000,
1032,
1050,
1000,
1007,
1025,
2065,
1006,
1002,
2240,
3597,
16671,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Collection.php | Collection.published | public function published()
{
$published = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->published()) {
$published[$path] = $slug;
}
}
$this->items = $published;
return $this;
} | php | public function published()
{
$published = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->published()) {
$published[$path] = $slug;
}
}
$this->items = $published;
return $this;
} | [
"public",
"function",
"published",
"(",
")",
"{",
"$",
"published",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"path",
"=>",
"$",
"slug",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"pages",
"->",
"get",
"(",
... | Creates new collection with only published pages
@return Collection The collection with only published pages | [
"Creates",
"new",
"collection",
"with",
"only",
"published",
"pages"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Collection.php#L439-L452 | train | Get published pages | [
30522,
2270,
3853,
2405,
1006,
1007,
1063,
1002,
2405,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
5167,
2004,
1002,
4130,
1027,
1028,
1002,
23667,
1007,
1063,
1002,
3931,
1027,
1002,
2023,
1011,
1028,
5530,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Connectors/DatabaseConnector.php | DatabaseConnector.connect | public function connect(array $config)
{
return new DatabaseQueue(
$this->connections->connection($config['connection'] ?? null),
$config['table'],
$config['queue'],
$config['retry_after'] ?? 60
);
} | php | public function connect(array $config)
{
return new DatabaseQueue(
$this->connections->connection($config['connection'] ?? null),
$config['table'],
$config['queue'],
$config['retry_after'] ?? 60
);
} | [
"public",
"function",
"connect",
"(",
"array",
"$",
"config",
")",
"{",
"return",
"new",
"DatabaseQueue",
"(",
"$",
"this",
"->",
"connections",
"->",
"connection",
"(",
"$",
"config",
"[",
"'connection'",
"]",
"??",
"null",
")",
",",
"$",
"config",
"[",... | Establish a queue connection.
@param array $config
@return \Illuminate\Contracts\Queue\Queue | [
"Establish",
"a",
"queue",
"connection",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Connectors/DatabaseConnector.php#L34-L42 | train | Connect to database and return a queue | [
30522,
2270,
3853,
7532,
1006,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
2709,
2047,
7809,
4226,
5657,
1006,
1002,
2023,
1011,
1028,
7264,
1011,
1028,
4434,
1006,
1002,
9530,
8873,
2290,
1031,
1005,
4434,
1005,
1033,
1029,
1029,
19701,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.clearAllRecipients | public function clearAllRecipients()
{
$this->to = [];
$this->cc = [];
$this->bcc = [];
$this->all_recipients = [];
$this->RecipientsQueue = [];
} | php | public function clearAllRecipients()
{
$this->to = [];
$this->cc = [];
$this->bcc = [];
$this->all_recipients = [];
$this->RecipientsQueue = [];
} | [
"public",
"function",
"clearAllRecipients",
"(",
")",
"{",
"$",
"this",
"->",
"to",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"cc",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"bcc",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"all_recipients",
"=",
"[",
"]... | Clear all recipient types. | [
"Clear",
"all",
"recipient",
"types",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L3562-L3569 | train | Clear all recipients | [
30522,
2270,
3853,
3154,
8095,
2890,
6895,
14756,
7666,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2000,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
10507,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
4647,
2278,
1027,
1031,
1033,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Console/MakeCommand.php | MakeCommand.handle | public function handle()
{
if (!$this->modelExists()) {
$this->error('Model does not exists !');
return false;
}
$stub = $this->option('stub');
if ($stub and !is_file($stub)) {
$this->error('The stub file dose not exist.');
return false;
}
$modelName = $this->option('model');
$this->generator = new ResourceGenerator($modelName);
if ($this->option('output')) {
return $this->output($modelName);
}
parent::handle();
} | php | public function handle()
{
if (!$this->modelExists()) {
$this->error('Model does not exists !');
return false;
}
$stub = $this->option('stub');
if ($stub and !is_file($stub)) {
$this->error('The stub file dose not exist.');
return false;
}
$modelName = $this->option('model');
$this->generator = new ResourceGenerator($modelName);
if ($this->option('output')) {
return $this->output($modelName);
}
parent::handle();
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modelExists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'Model does not exists !'",
")",
";",
"return",
"false",
";",
"}",
"$",
"stub",
"=",
"$",
"this",
... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/MakeCommand.php#L37-L62 | train | Handle the resource generation | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2944,
10288,
5130,
1006,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
7561,
1006,
1005,
2944,
2515,
2025,
6526,
999,
1005,
1007,
1025,
2709,
6270,
1025,
1065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.dataArrayGet | protected function dataArrayGet(array $array, array $parts, $default = null)
{
if ($parts === null) {
return $array;
}
if (count($parts) === 1) {
$key = array_shift($parts);
if (isset($array[$key])) {
return $array[$key];
}
return $default;
}
foreach ($parts as $segment) {
if (!is_array($array) || !array_key_exists($segment, $array)) {
return $default;
}
$array = $array[$segment];
}
return $array;
} | php | protected function dataArrayGet(array $array, array $parts, $default = null)
{
if ($parts === null) {
return $array;
}
if (count($parts) === 1) {
$key = array_shift($parts);
if (isset($array[$key])) {
return $array[$key];
}
return $default;
}
foreach ($parts as $segment) {
if (!is_array($array) || !array_key_exists($segment, $array)) {
return $default;
}
$array = $array[$segment];
}
return $array;
} | [
"protected",
"function",
"dataArrayGet",
"(",
"array",
"$",
"array",
",",
"array",
"$",
"parts",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parts",
"===",
"null",
")",
"{",
"return",
"$",
"array",
";",
"}",
"if",
"(",
"count",
"("... | Variant to array_get() but preserves dots in key names.
@param array $array
@param array $parts
@param null $default
@return array|null | [
"Variant",
"to",
"array_get",
"()",
"but",
"preserves",
"dots",
"in",
"key",
"names",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L1340-L1364 | train | Get array value from array | [
30522,
5123,
3853,
2951,
2906,
9447,
18150,
1006,
9140,
1002,
9140,
1010,
9140,
1002,
3033,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
3033,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
1002,
9140,
1025,
1065,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/ExampleAPI/API.php | API.getCompetitionDatatable | public function getCompetitionDatatable()
{
$dataTable = new DataTable();
$row1 = new Row();
$row1->setColumns(array('name' => 'piwik', 'license' => 'GPL'));
// Rows Metadata is useful to store non stats data for example (logos, urls, etc.)
// When printed out, they are simply merged with columns
$row1->setMetadata('logo', 'logo.png');
$dataTable->addRow($row1);
$dataTable->addRowFromSimpleArray(array('name' => 'google analytics', 'license' => 'commercial'));
return $dataTable;
} | php | public function getCompetitionDatatable()
{
$dataTable = new DataTable();
$row1 = new Row();
$row1->setColumns(array('name' => 'piwik', 'license' => 'GPL'));
// Rows Metadata is useful to store non stats data for example (logos, urls, etc.)
// When printed out, they are simply merged with columns
$row1->setMetadata('logo', 'logo.png');
$dataTable->addRow($row1);
$dataTable->addRowFromSimpleArray(array('name' => 'google analytics', 'license' => 'commercial'));
return $dataTable;
} | [
"public",
"function",
"getCompetitionDatatable",
"(",
")",
"{",
"$",
"dataTable",
"=",
"new",
"DataTable",
"(",
")",
";",
"$",
"row1",
"=",
"new",
"Row",
"(",
")",
";",
"$",
"row1",
"->",
"setColumns",
"(",
"array",
"(",
"'name'",
"=>",
"'piwik'",
",",... | Returns a custom data table.
This data table will be converted to all available formats
when requested in the API request.
@return DataTable | [
"Returns",
"a",
"custom",
"data",
"table",
".",
"This",
"data",
"table",
"will",
"be",
"converted",
"to",
"all",
"available",
"formats",
"when",
"requested",
"in",
"the",
"API",
"request",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleAPI/API.php#L115-L130 | train | Returns the competition datatable | [
30522,
2270,
3853,
2131,
9006,
22327,
22753,
2850,
29336,
3085,
1006,
1007,
1063,
1002,
2951,
10880,
1027,
2047,
2951,
10880,
1006,
1007,
1025,
1002,
5216,
2487,
1027,
2047,
5216,
1006,
1007,
1025,
1002,
5216,
2487,
1011,
1028,
2275,
25778,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Ecommerce/Columns/BaseConversion.php | BaseConversion.roundRevenueIfNeeded | protected function roundRevenueIfNeeded($revenue)
{
if (false === $revenue) {
return false;
}
if (round($revenue) == $revenue) {
return $revenue;
}
$value = round($revenue, GoalManager::REVENUE_PRECISION);
return $value;
} | php | protected function roundRevenueIfNeeded($revenue)
{
if (false === $revenue) {
return false;
}
if (round($revenue) == $revenue) {
return $revenue;
}
$value = round($revenue, GoalManager::REVENUE_PRECISION);
return $value;
} | [
"protected",
"function",
"roundRevenueIfNeeded",
"(",
"$",
"revenue",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"revenue",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"round",
"(",
"$",
"revenue",
")",
"==",
"$",
"revenue",
")",
"{",
"return",
... | Returns rounded decimal revenue, or if revenue is integer, then returns as is.
@param int|float $revenue
@return int|float | [
"Returns",
"rounded",
"decimal",
"revenue",
"or",
"if",
"revenue",
"is",
"integer",
"then",
"returns",
"as",
"is",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Ecommerce/Columns/BaseConversion.php#L22-L35 | train | roundRevenueIfNeeded - Round the revenue value if needed | [
30522,
5123,
3853,
2461,
2890,
8159,
5657,
10128,
24045,
5732,
1006,
1002,
6599,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
1002,
6599,
1007,
1063,
2709,
6270,
1025,
1065,
2065,
1006,
2461,
1006,
1002,
6599,
1007,
1027,
1027,
1002,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Mapping/Loader/YamlFileLoader.php | YamlFileLoader.loadClassMetadata | public function loadClassMetadata(ClassMetadataInterface $classMetadata)
{
if (null === $this->classes) {
$this->classes = $this->getClassesFromYaml();
}
if (!$this->classes) {
return false;
}
if (!isset($this->classes[$classMetadata->getName()])) {
return false;
}
$yaml = $this->classes[$classMetadata->getName()];
if (isset($yaml['attributes']) && \is_array($yaml['attributes'])) {
$attributesMetadata = $classMetadata->getAttributesMetadata();
foreach ($yaml['attributes'] as $attribute => $data) {
if (isset($attributesMetadata[$attribute])) {
$attributeMetadata = $attributesMetadata[$attribute];
} else {
$attributeMetadata = new AttributeMetadata($attribute);
$classMetadata->addAttributeMetadata($attributeMetadata);
}
if (isset($data['groups'])) {
if (!\is_array($data['groups'])) {
throw new MappingException(sprintf('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
foreach ($data['groups'] as $group) {
if (!\is_string($group)) {
throw new MappingException(sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
$attributeMetadata->addGroup($group);
}
}
if (isset($data['max_depth'])) {
if (!\is_int($data['max_depth'])) {
throw new MappingException(sprintf('The "max_depth" value must be an integer in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
$attributeMetadata->setMaxDepth($data['max_depth']);
}
if (isset($data['serialized_name'])) {
if (!\is_string($data['serialized_name']) || empty($data['serialized_name'])) {
throw new MappingException(sprintf('The "serialized_name" value must be a non-empty string in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
$attributeMetadata->setSerializedName($data['serialized_name']);
}
}
}
if (isset($yaml['discriminator_map'])) {
if (!isset($yaml['discriminator_map']['type_property'])) {
throw new MappingException(sprintf('The "type_property" key must be set for the discriminator map of the class "%s" in "%s".', $classMetadata->getName(), $this->file));
}
if (!isset($yaml['discriminator_map']['mapping'])) {
throw new MappingException(sprintf('The "mapping" key must be set for the discriminator map of the class "%s" in "%s".', $classMetadata->getName(), $this->file));
}
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
$yaml['discriminator_map']['type_property'],
$yaml['discriminator_map']['mapping']
));
}
return true;
} | php | public function loadClassMetadata(ClassMetadataInterface $classMetadata)
{
if (null === $this->classes) {
$this->classes = $this->getClassesFromYaml();
}
if (!$this->classes) {
return false;
}
if (!isset($this->classes[$classMetadata->getName()])) {
return false;
}
$yaml = $this->classes[$classMetadata->getName()];
if (isset($yaml['attributes']) && \is_array($yaml['attributes'])) {
$attributesMetadata = $classMetadata->getAttributesMetadata();
foreach ($yaml['attributes'] as $attribute => $data) {
if (isset($attributesMetadata[$attribute])) {
$attributeMetadata = $attributesMetadata[$attribute];
} else {
$attributeMetadata = new AttributeMetadata($attribute);
$classMetadata->addAttributeMetadata($attributeMetadata);
}
if (isset($data['groups'])) {
if (!\is_array($data['groups'])) {
throw new MappingException(sprintf('The "groups" key must be an array of strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
foreach ($data['groups'] as $group) {
if (!\is_string($group)) {
throw new MappingException(sprintf('Group names must be strings in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
$attributeMetadata->addGroup($group);
}
}
if (isset($data['max_depth'])) {
if (!\is_int($data['max_depth'])) {
throw new MappingException(sprintf('The "max_depth" value must be an integer in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
$attributeMetadata->setMaxDepth($data['max_depth']);
}
if (isset($data['serialized_name'])) {
if (!\is_string($data['serialized_name']) || empty($data['serialized_name'])) {
throw new MappingException(sprintf('The "serialized_name" value must be a non-empty string in "%s" for the attribute "%s" of the class "%s".', $this->file, $attribute, $classMetadata->getName()));
}
$attributeMetadata->setSerializedName($data['serialized_name']);
}
}
}
if (isset($yaml['discriminator_map'])) {
if (!isset($yaml['discriminator_map']['type_property'])) {
throw new MappingException(sprintf('The "type_property" key must be set for the discriminator map of the class "%s" in "%s".', $classMetadata->getName(), $this->file));
}
if (!isset($yaml['discriminator_map']['mapping'])) {
throw new MappingException(sprintf('The "mapping" key must be set for the discriminator map of the class "%s" in "%s".', $classMetadata->getName(), $this->file));
}
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
$yaml['discriminator_map']['type_property'],
$yaml['discriminator_map']['mapping']
));
}
return true;
} | [
"public",
"function",
"loadClassMetadata",
"(",
"ClassMetadataInterface",
"$",
"classMetadata",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"classes",
")",
"{",
"$",
"this",
"->",
"classes",
"=",
"$",
"this",
"->",
"getClassesFromYaml",
"(",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Mapping/Loader/YamlFileLoader.php#L40-L115 | train | Load class metadata from yaml | [
30522,
2270,
3853,
7170,
26266,
11368,
8447,
2696,
1006,
2465,
11368,
8447,
18249,
3334,
12172,
1002,
2465,
11368,
8447,
2696,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
4280,
1007,
1063,
1002,
2023,
1011,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Mailable.php | Mailable.buildFrom | protected function buildFrom($message)
{
if (! empty($this->from)) {
$message->from($this->from[0]['address'], $this->from[0]['name']);
}
return $this;
} | php | protected function buildFrom($message)
{
if (! empty($this->from)) {
$message->from($this->from[0]['address'], $this->from[0]['name']);
}
return $this;
} | [
"protected",
"function",
"buildFrom",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"from",
")",
")",
"{",
"$",
"message",
"->",
"from",
"(",
"$",
"this",
"->",
"from",
"[",
"0",
"]",
"[",
"'address'",
"]",
",",
... | Add the sender to the message.
@param \Illuminate\Mail\Message $message
@return $this | [
"Add",
"the",
"sender",
"to",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailable.php#L315-L322 | train | Build From - Message | [
30522,
5123,
3853,
3857,
19699,
5358,
1006,
1002,
4471,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
2023,
1011,
1028,
2013,
1007,
1007,
1063,
1002,
4471,
1011,
1028,
2013,
1006,
1002,
2023,
1011,
1028,
2013,
1031,
1014,
1033,
1031,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.whereJsonLength | public function whereJsonLength($column, $operator, $value = null, $boolean = 'and')
{
$type = 'JsonLength';
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
$this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');
if (! $value instanceof Expression) {
$this->addBinding($value);
}
return $this;
} | php | public function whereJsonLength($column, $operator, $value = null, $boolean = 'and')
{
$type = 'JsonLength';
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
$this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean');
if (! $value instanceof Expression) {
$this->addBinding($value);
}
return $this;
} | [
"public",
"function",
"whereJsonLength",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
",",
"$",
"boolean",
"=",
"'and'",
")",
"{",
"$",
"type",
"=",
"'JsonLength'",
";",
"[",
"$",
"value",
",",
"$",
"operator",
"]",
"=",
... | Add a "where JSON length" clause to the query.
@param string $column
@param mixed $operator
@param mixed $value
@param string $boolean
@return $this | [
"Add",
"a",
"where",
"JSON",
"length",
"clause",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L1574-L1589 | train | Add a where JSON length clause to the query. | [
30522,
2270,
3853,
2073,
22578,
2239,
7770,
13512,
2232,
1006,
1002,
5930,
1010,
1002,
6872,
1010,
1002,
3643,
1027,
19701,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1007,
1063,
1002,
2828,
1027,
1005,
1046,
3385,
7770,
13512,
2232,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Debug/ErrorHandler.php | ErrorHandler.setLoggers | public function setLoggers(array $loggers)
{
$prevLogged = $this->loggedErrors;
$prev = $this->loggers;
$flush = [];
foreach ($loggers as $type => $log) {
if (!isset($prev[$type])) {
throw new \InvalidArgumentException('Unknown error type: '.$type);
}
if (!\is_array($log)) {
$log = [$log];
} elseif (!\array_key_exists(0, $log)) {
throw new \InvalidArgumentException('No logger provided');
}
if (null === $log[0]) {
$this->loggedErrors &= ~$type;
} elseif ($log[0] instanceof LoggerInterface) {
$this->loggedErrors |= $type;
} else {
throw new \InvalidArgumentException('Invalid logger provided');
}
$this->loggers[$type] = $log + $prev[$type];
if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
$flush[$type] = $type;
}
}
$this->reRegister($prevLogged | $this->thrownErrors);
if ($flush) {
foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
$type = $log[2]['exception'] instanceof \ErrorException ? $log[2]['exception']->getSeverity() : E_ERROR;
if (!isset($flush[$type])) {
$this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
} elseif ($this->loggers[$type][0]) {
$this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
}
}
}
return $prev;
} | php | public function setLoggers(array $loggers)
{
$prevLogged = $this->loggedErrors;
$prev = $this->loggers;
$flush = [];
foreach ($loggers as $type => $log) {
if (!isset($prev[$type])) {
throw new \InvalidArgumentException('Unknown error type: '.$type);
}
if (!\is_array($log)) {
$log = [$log];
} elseif (!\array_key_exists(0, $log)) {
throw new \InvalidArgumentException('No logger provided');
}
if (null === $log[0]) {
$this->loggedErrors &= ~$type;
} elseif ($log[0] instanceof LoggerInterface) {
$this->loggedErrors |= $type;
} else {
throw new \InvalidArgumentException('Invalid logger provided');
}
$this->loggers[$type] = $log + $prev[$type];
if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
$flush[$type] = $type;
}
}
$this->reRegister($prevLogged | $this->thrownErrors);
if ($flush) {
foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
$type = $log[2]['exception'] instanceof \ErrorException ? $log[2]['exception']->getSeverity() : E_ERROR;
if (!isset($flush[$type])) {
$this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
} elseif ($this->loggers[$type][0]) {
$this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
}
}
}
return $prev;
} | [
"public",
"function",
"setLoggers",
"(",
"array",
"$",
"loggers",
")",
"{",
"$",
"prevLogged",
"=",
"$",
"this",
"->",
"loggedErrors",
";",
"$",
"prev",
"=",
"$",
"this",
"->",
"loggers",
";",
"$",
"flush",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
... | Sets a logger for each error level.
@param array $loggers Error levels to [LoggerInterface|null, LogLevel::*] map
@return array The previous map
@throws \InvalidArgumentException | [
"Sets",
"a",
"logger",
"for",
"each",
"error",
"level",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Debug/ErrorHandler.php#L213-L255 | train | Sets the loggers | [
30522,
2270,
3853,
2275,
21197,
15776,
1006,
9140,
1002,
8833,
15776,
1007,
1063,
1002,
3653,
2615,
21197,
5999,
1027,
1002,
2023,
1011,
1028,
26618,
2121,
29165,
2015,
1025,
1002,
3653,
2615,
1027,
1002,
2023,
1011,
1028,
8833,
15776,
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/Security/Core/User/ChainUserProvider.php | ChainUserProvider.refreshUser | public function refreshUser(UserInterface $user)
{
$supportedUserFound = false;
foreach ($this->providers as $provider) {
try {
return $provider->refreshUser($user);
} catch (UnsupportedUserException $e) {
// try next one
} catch (UsernameNotFoundException $e) {
$supportedUserFound = true;
// try next one
}
}
if ($supportedUserFound) {
$e = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
$e->setUsername($user->getUsername());
throw $e;
} else {
throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', \get_class($user)));
}
} | php | public function refreshUser(UserInterface $user)
{
$supportedUserFound = false;
foreach ($this->providers as $provider) {
try {
return $provider->refreshUser($user);
} catch (UnsupportedUserException $e) {
// try next one
} catch (UsernameNotFoundException $e) {
$supportedUserFound = true;
// try next one
}
}
if ($supportedUserFound) {
$e = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
$e->setUsername($user->getUsername());
throw $e;
} else {
throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', \get_class($user)));
}
} | [
"public",
"function",
"refreshUser",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"supportedUserFound",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"providers",
"as",
"$",
"provider",
")",
"{",
"try",
"{",
"return",
"$",
"provider",
"->",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/User/ChainUserProvider.php#L70-L92 | train | Refreshes a user | [
30522,
2270,
3853,
25416,
21898,
20330,
1006,
5310,
18447,
2121,
12172,
1002,
5310,
1007,
1063,
1002,
3569,
20330,
14876,
8630,
1027,
6270,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
11670,
2004,
1002,
10802,
1007,
1063,
3046,
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... |
barryvdh/laravel-debugbar | src/LaravelDebugbar.php | LaravelDebugbar.addServerTimingHeaders | protected function addServerTimingHeaders(Response $response)
{
if ($this->hasCollector('time')) {
$collector = $this->getCollector('time');
$headers = [];
foreach ($collector->collect()['measures'] as $k => $m) {
$headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'] * 1000, str_replace('"', "'", $m['label']));
}
$response->headers->set('Server-Timing', $headers, false);
}
} | php | protected function addServerTimingHeaders(Response $response)
{
if ($this->hasCollector('time')) {
$collector = $this->getCollector('time');
$headers = [];
foreach ($collector->collect()['measures'] as $k => $m) {
$headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'] * 1000, str_replace('"', "'", $m['label']));
}
$response->headers->set('Server-Timing', $headers, false);
}
} | [
"protected",
"function",
"addServerTimingHeaders",
"(",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasCollector",
"(",
"'time'",
")",
")",
"{",
"$",
"collector",
"=",
"$",
"this",
"->",
"getCollector",
"(",
"'time'",
")",
";",
... | Add Server-Timing headers for the TimeData collector
@see https://www.w3.org/TR/server-timing/
@param Response $response | [
"Add",
"Server",
"-",
"Timing",
"headers",
"for",
"the",
"TimeData",
"collector"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/LaravelDebugbar.php#L1053-L1065 | train | Adds Server - Timing headers to response | [
30522,
5123,
3853,
9909,
2121,
16874,
27605,
3070,
4974,
2545,
1006,
3433,
1002,
3433,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2038,
26895,
22471,
2953,
1006,
1005,
2051,
1005,
1007,
1007,
1063,
1002,
10018,
1027,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/ListColumn.php | ListColumn.getColumnNameFromData | protected function getColumnNameFromData($columnName, $data, $default = null)
{
/*
* Array column name, eg: column[key][key2][key3]
*/
$keyParts = HtmlHelper::nameToArray($columnName);
$result = $data;
/*
* Loop the column key parts and build a value.
* To support relations only the last column should return the
* relation value, all others will look up the relation object as normal.
*/
foreach ($keyParts as $key) {
if ($result instanceof Model && $result->hasRelation($key)) {
$result = $result->{$key};
}
else {
if (is_array($result) && array_key_exists($key, $result)) {
return $result[$key];
}
if (!isset($result->{$key})) {
return $default;
}
$result = $result->{$key};
}
}
return $result;
} | php | protected function getColumnNameFromData($columnName, $data, $default = null)
{
/*
* Array column name, eg: column[key][key2][key3]
*/
$keyParts = HtmlHelper::nameToArray($columnName);
$result = $data;
/*
* Loop the column key parts and build a value.
* To support relations only the last column should return the
* relation value, all others will look up the relation object as normal.
*/
foreach ($keyParts as $key) {
if ($result instanceof Model && $result->hasRelation($key)) {
$result = $result->{$key};
}
else {
if (is_array($result) && array_key_exists($key, $result)) {
return $result[$key];
}
if (!isset($result->{$key})) {
return $default;
}
$result = $result->{$key};
}
}
return $result;
} | [
"protected",
"function",
"getColumnNameFromData",
"(",
"$",
"columnName",
",",
"$",
"data",
",",
"$",
"default",
"=",
"null",
")",
"{",
"/*\n * Array column name, eg: column[key][key2][key3]\n */",
"$",
"keyParts",
"=",
"HtmlHelper",
"::",
"nameToArray",
... | Internal method to extract the value of a column name from a data set.
@param string $columnName
@param mixed $data
@param mixed $default
@return mixed | [
"Internal",
"method",
"to",
"extract",
"the",
"value",
"of",
"a",
"column",
"name",
"from",
"a",
"data",
"set",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/ListColumn.php#L234-L264 | train | Get column name from data | [
30522,
5123,
3853,
2131,
25778,
2819,
9516,
4168,
19699,
5358,
30524,
1002,
3145,
26950,
1027,
16129,
16001,
4842,
1024,
1024,
2171,
3406,
2906,
9447,
1006,
1002,
5930,
18442,
1007,
1025,
1002,
2765,
1027,
1002,
2951,
1025,
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 | core/Translation/Transifex/API.php | API.resourceExists | public function resourceExists($resource)
{
$resources = $this->getAvailableResources();
foreach ($resources as $res) {
if ($res->slug == $resource) {
return true;
}
}
return false;
} | php | public function resourceExists($resource)
{
$resources = $this->getAvailableResources();
foreach ($resources as $res) {
if ($res->slug == $resource) {
return true;
}
}
return false;
} | [
"public",
"function",
"resourceExists",
"(",
"$",
"resource",
")",
"{",
"$",
"resources",
"=",
"$",
"this",
"->",
"getAvailableResources",
"(",
")",
";",
"foreach",
"(",
"$",
"resources",
"as",
"$",
"res",
")",
"{",
"if",
"(",
"$",
"res",
"->",
"slug",... | Checks if the given resource exists in Transifex project
@param string $resource
@return bool | [
"Checks",
"if",
"the",
"given",
"resource",
"exists",
"in",
"Transifex",
"project"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Translation/Transifex/API.php#L56-L65 | train | Checks if a resource exists | [
30522,
2270,
3853,
7692,
10288,
5130,
1006,
1002,
7692,
1007,
1063,
1002,
4219,
1027,
1002,
2023,
1011,
1028,
2131,
12462,
11733,
16213,
2229,
8162,
9623,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
4219,
2004,
1002,
24501,
1007,
1063,
2065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Traits/DoctrineTrait.php | DoctrineTrait.doDelete | protected function doDelete(array $ids)
{
$ok = true;
foreach ($ids as $id) {
$ok = $this->provider->delete($id) && $ok;
}
return $ok;
} | php | protected function doDelete(array $ids)
{
$ok = true;
foreach ($ids as $id) {
$ok = $this->provider->delete($id) && $ok;
}
return $ok;
} | [
"protected",
"function",
"doDelete",
"(",
"array",
"$",
"ids",
")",
"{",
"$",
"ok",
"=",
"true",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"ok",
"=",
"$",
"this",
"->",
"provider",
"->",
"delete",
"(",
"$",
"id",
")",
"&&... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/DoctrineTrait.php#L81-L89 | train | Delete all entries from the cache | [
30522,
5123,
3853,
26489,
12260,
2618,
1006,
9140,
1002,
8909,
2015,
1007,
1063,
1002,
7929,
1027,
2995,
1025,
18921,
6776,
1006,
1002,
8909,
2015,
2004,
1002,
8909,
1007,
1063,
1002,
7929,
1027,
1002,
2023,
1011,
1028,
10802,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Archive/Chunk.php | Chunk.getRecordNameForTableId | public function getRecordNameForTableId($recordName, $tableId)
{
$chunk = (floor($tableId / self::NUM_TABLES_IN_CHUNK));
$start = $chunk * self::NUM_TABLES_IN_CHUNK;
$end = $start + self::NUM_TABLES_IN_CHUNK - 1;
return $recordName . $this->getAppendix() . $start . '_' . $end;
} | php | public function getRecordNameForTableId($recordName, $tableId)
{
$chunk = (floor($tableId / self::NUM_TABLES_IN_CHUNK));
$start = $chunk * self::NUM_TABLES_IN_CHUNK;
$end = $start + self::NUM_TABLES_IN_CHUNK - 1;
return $recordName . $this->getAppendix() . $start . '_' . $end;
} | [
"public",
"function",
"getRecordNameForTableId",
"(",
"$",
"recordName",
",",
"$",
"tableId",
")",
"{",
"$",
"chunk",
"=",
"(",
"floor",
"(",
"$",
"tableId",
"/",
"self",
"::",
"NUM_TABLES_IN_CHUNK",
")",
")",
";",
"$",
"start",
"=",
"$",
"chunk",
"*",
... | Get's the record name to use for a given tableId/subtableId.
@param string $recordName eg 'Actions_ActionsUrl'
@param int $tableId eg '5' for tableId '5'
@return string eg 'Actions_ActionsUrl_chunk_0_99' as the table should be stored under this blob id. | [
"Get",
"s",
"the",
"record",
"name",
"to",
"use",
"for",
"a",
"given",
"tableId",
"/",
"subtableId",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/Chunk.php#L33-L40 | train | Get record name for table id | [
30522,
2270,
3853,
2131,
2890,
27108,
28911,
4168,
13028,
3085,
3593,
1006,
1002,
2501,
18442,
1010,
1002,
2795,
3593,
1007,
1063,
1002,
20000,
1027,
1006,
2723,
1006,
1002,
2795,
3593,
1013,
2969,
1024,
1024,
16371,
2213,
1035,
7251,
1035,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php | VariadicValueResolver.supports | public function supports(Request $request, ArgumentMetadata $argument)
{
return $argument->isVariadic() && $request->attributes->has($argument->getName());
} | php | public function supports(Request $request, ArgumentMetadata $argument)
{
return $argument->isVariadic() && $request->attributes->has($argument->getName());
} | [
"public",
"function",
"supports",
"(",
"Request",
"$",
"request",
",",
"ArgumentMetadata",
"$",
"argument",
")",
"{",
"return",
"$",
"argument",
"->",
"isVariadic",
"(",
")",
"&&",
"$",
"request",
"->",
"attributes",
"->",
"has",
"(",
"$",
"argument",
"->"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/VariadicValueResolver.php#L28-L31 | train | Returns true if the argument is a variadic argument. | [
30522,
2270,
3853,
6753,
1006,
5227,
1002,
5227,
1010,
6685,
11368,
8447,
2696,
1002,
6685,
1007,
1063,
2709,
1002,
6685,
1011,
1028,
2003,
10755,
28665,
2594,
1006,
1007,
1004,
1004,
1002,
5227,
1011,
1028,
12332,
1011,
1028,
2038,
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... |
PHPMailer/PHPMailer | src/POP3.php | POP3.authorise | public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if (false === $port) {
$this->port = static::DEFAULT_PORT;
} else {
$this->port = (int) $port;
}
// If no timeout value provided, use default
if (false === $timeout) {
$this->tval = static::DEFAULT_TIMEOUT;
} else {
$this->tval = (int) $timeout;
}
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Reset the error log
$this->errors = [];
// connect
$result = $this->connect($this->host, $this->port, $this->tval);
if ($result) {
$login_result = $this->login($this->username, $this->password);
if ($login_result) {
$this->disconnect();
return true;
}
}
// We need to disconnect regardless of whether the login succeeded
$this->disconnect();
return false;
} | php | public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
if (false === $port) {
$this->port = static::DEFAULT_PORT;
} else {
$this->port = (int) $port;
}
// If no timeout value provided, use default
if (false === $timeout) {
$this->tval = static::DEFAULT_TIMEOUT;
} else {
$this->tval = (int) $timeout;
}
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Reset the error log
$this->errors = [];
// connect
$result = $this->connect($this->host, $this->port, $this->tval);
if ($result) {
$login_result = $this->login($this->username, $this->password);
if ($login_result) {
$this->disconnect();
return true;
}
}
// We need to disconnect regardless of whether the login succeeded
$this->disconnect();
return false;
} | [
"public",
"function",
"authorise",
"(",
"$",
"host",
",",
"$",
"port",
"=",
"false",
",",
"$",
"timeout",
"=",
"false",
",",
"$",
"username",
"=",
"''",
",",
"$",
"password",
"=",
"''",
",",
"$",
"debug_level",
"=",
"0",
")",
"{",
"$",
"this",
"-... | Authenticate with a POP3 server.
A connect, login, disconnect sequence
appropriate for POP-before SMTP authorisation.
@param string $host The hostname to connect to
@param int|bool $port The port number to connect to
@param int|bool $timeout The timeout value
@param string $username
@param string $password
@param int $debug_level
@return bool | [
"Authenticate",
"with",
"a",
"POP3",
"server",
".",
"A",
"connect",
"login",
"disconnect",
"sequence",
"appropriate",
"for",
"POP",
"-",
"before",
"SMTP",
"authorisation",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/POP3.php#L172-L206 | train | Authorise the current session | [
30522,
2270,
3853,
3166,
5562,
1006,
1002,
3677,
1010,
1002,
3417,
1027,
6270,
1010,
1002,
2051,
5833,
1027,
6270,
1010,
1002,
5310,
18442,
1027,
1005,
1005,
1010,
1002,
20786,
1027,
1005,
1005,
1010,
1002,
2139,
8569,
2290,
1035,
2504,
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... |
overtrue/wechat | src/OpenWork/Provider/Client.php | Client.setAgentScope | public function setAgentScope(
string $accessToken,
string $agentId,
array $allowUser = [],
array $allowParty = [],
array $allowTag = []
) {
$params = [
'agentid' => $agentId,
'allow_user' => $allowUser,
'allow_party' => $allowParty,
'allow_tag' => $allowTag,
'access_token' => $accessToken,
];
return $this->httpGet('cgi-bin/agent/set_scope', $params);
} | php | public function setAgentScope(
string $accessToken,
string $agentId,
array $allowUser = [],
array $allowParty = [],
array $allowTag = []
) {
$params = [
'agentid' => $agentId,
'allow_user' => $allowUser,
'allow_party' => $allowParty,
'allow_tag' => $allowTag,
'access_token' => $accessToken,
];
return $this->httpGet('cgi-bin/agent/set_scope', $params);
} | [
"public",
"function",
"setAgentScope",
"(",
"string",
"$",
"accessToken",
",",
"string",
"$",
"agentId",
",",
"array",
"$",
"allowUser",
"=",
"[",
"]",
",",
"array",
"$",
"allowParty",
"=",
"[",
"]",
",",
"array",
"$",
"allowTag",
"=",
"[",
"]",
")",
... | 设置授权应用可见范围.
Desc:调用该接口前提是开启通讯录迁移,收到授权成功通知后可调用。
企业注册初始化安装应用后,应用默认可见范围为根部门。
如需修改应用可见范围,服务商可以调用该接口设置授权应用的可见范围。
该接口只能使用注册完成回调事件或者查询注册状态返回的access_token。
调用设置通讯录同步完成后或者access_token超过30分钟失效(即解除通讯录锁定状态)则不能继续调用该接口。
@param string $accessToken
@param string $agentId
@param array $allowUser
@param array $allowParty
@param array $allowTag
@return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"设置授权应用可见范围",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenWork/Provider/Client.php#L160-L176 | train | Set Scope of Agent | [
30522,
2270,
3853,
2275,
4270,
7666,
16186,
1006,
5164,
1002,
3229,
18715,
2368,
1010,
5164,
1002,
4005,
3593,
1010,
9140,
1002,
3499,
20330,
1027,
1031,
1033,
1010,
9140,
1002,
3499,
19362,
3723,
1027,
1031,
1033,
1010,
9140,
1002,
3499,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Actions/ArchivingHelper.php | ArchivingHelper.updateActionsTableWithRowQuery | public static function updateActionsTableWithRowQuery($query, $fieldQueried, & $actionsTablesByType, $metricsConfig)
{
$rowsProcessed = 0;
while ($row = $query->fetch()) {
if (empty($row['idaction'])) {
$row['type'] = ($fieldQueried == 'idaction_url' ? Action::TYPE_PAGE_URL : Action::TYPE_PAGE_TITLE);
// This will be replaced with 'X not defined' later
$row['name'] = '';
// Yes, this is kind of a hack, so we don't mix 'page url not defined' with 'page title not defined' etc.
$row['idaction'] = -$row['type'];
}
if ($row['type'] != Action::TYPE_SITE_SEARCH) {
unset($row[PiwikMetrics::INDEX_SITE_SEARCH_HAS_NO_RESULT]);
}
if (in_array($row['type'], array(Action::TYPE_CONTENT, Action::TYPE_EVENT, Action::TYPE_EVENT_NAME, Action::TYPE_CONTENT_PIECE, Action::TYPE_CONTENT_TARGET))) {
continue;
}
$hasRowName = !empty($row['name']) && $row['name'] != DataTable::LABEL_SUMMARY_ROW;
// This will appear as <url /> in the API, which is actually very important to keep
// eg. When there's at least one row in a report that does not have a URL, not having this <url/> would break HTML/PDF reports.
$url = '';
$pageTitlePath = null;
if ($row['type'] == Action::TYPE_SITE_SEARCH
|| $row['type'] == Action::TYPE_PAGE_TITLE
) {
$url = null;
if ($hasRowName) {
$pageTitlePath = $row['name'];
}
} elseif ($hasRowName) {
$url = PageUrl::reconstructNormalizedUrl((string)$row['name'], $row['url_prefix']);
}
if (isset($row['name'])
&& isset($row['type'])
) {
$actionName = $row['name'];
$actionType = $row['type'];
$urlPrefix = $row['url_prefix'];
$idaction = $row['idaction'];
// in some unknown case, the type field is NULL, as reported in #1082 - we ignore this page view
if (empty($actionType)) {
if ($idaction != DataTable::LABEL_SUMMARY_ROW) {
self::setCachedActionRow($idaction, $actionType, false);
}
continue;
}
$actionRow = self::getActionRow($actionName, $actionType, $urlPrefix, $actionsTablesByType);
self::setCachedActionRow($idaction, $actionType, $actionRow);
} else {
$actionRow = self::getCachedActionRow($row['idaction'], $row['type']);
// Action processed as "to skip" for some reasons
if ($actionRow === false) {
continue;
}
}
if (is_null($actionRow)) {
continue;
}
// Here we do ensure that, the Metadata URL set for a given row, is the one from the Pageview with the most hits.
// This is to ensure that when, different URLs are loaded with the same page name.
// For example http://piwik.org and http://id.piwik.org are reported in Piwik > Actions > Pages with /index
// But, we must make sure http://piwik.org is used to link & for transitions
// Note: this code is partly duplicated from Row->sumRowMetadata()
if (!is_null($url)
&& !$actionRow->isSummaryRow()
) {
if (($existingUrl = $actionRow->getMetadata('url')) !== false) {
if (!empty($row[PiwikMetrics::INDEX_PAGE_NB_HITS])
&& $row[PiwikMetrics::INDEX_PAGE_NB_HITS] > $actionRow->maxVisitsSummed
) {
$actionRow->setMetadata('url', $url);
$actionRow->maxVisitsSummed = $row[PiwikMetrics::INDEX_PAGE_NB_HITS];
}
} else {
$actionRow->setMetadata('url', $url);
$actionRow->maxVisitsSummed = !empty($row[PiwikMetrics::INDEX_PAGE_NB_HITS]) ? $row[PiwikMetrics::INDEX_PAGE_NB_HITS] : 0;
}
}
if ($pageTitlePath !== null
&& !$actionRow->isSummaryRow()
) {
$actionRow->setMetadata('page_title_path', $pageTitlePath);
}
if ($row['type'] != Action::TYPE_PAGE_URL
&& $row['type'] != Action::TYPE_PAGE_TITLE
) {
// only keep performance metrics when they're used (i.e. for URLs and page titles)
if (array_key_exists(PiwikMetrics::INDEX_PAGE_SUM_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_SUM_TIME_GENERATION]);
}
if (array_key_exists(PiwikMetrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION]);
}
if (array_key_exists(PiwikMetrics::INDEX_PAGE_MIN_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_MIN_TIME_GENERATION]);
}
if (array_key_exists(PiwikMetrics::INDEX_PAGE_MAX_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_MAX_TIME_GENERATION]);
}
}
unset($row['name']);
unset($row['type']);
unset($row['idaction']);
unset($row['url_prefix']);
foreach ($row as $name => $value) {
// in some edge cases, we have twice the same action name with 2 different idaction
// - this happens when 2 visitors visit the same new page at the same time, and 2 actions get recorded for the same name
// - this could also happen when 2 URLs end up having the same label (eg. 2 subdomains get aggregated to the "/index" page name)
if (($alreadyValue = $actionRow->getColumn($name)) !== false) {
$newValue = self::getColumnValuesMerged($name, $alreadyValue, $value, $metricsConfig);
$actionRow->setColumn($name, $newValue);
} else {
$actionRow->addColumn($name, $value);
}
}
// if the exit_action was not recorded properly in the log_link_visit_action
// there would be an error message when getting the nb_hits column
// we must fake the record and add the columns
if ($actionRow->getColumn(PiwikMetrics::INDEX_PAGE_NB_HITS) === false) {
// to test this code: delete the entries in log_link_action_visit for
// a given exit_idaction_url
foreach (self::getDefaultRow()->getColumns() as $name => $value) {
$actionRow->addColumn($name, $value);
}
}
$rowsProcessed++;
}
// just to make sure php copies the last $actionRow in the $parentTable array
$actionRow =& $actionsTablesByType;
return $rowsProcessed;
} | php | public static function updateActionsTableWithRowQuery($query, $fieldQueried, & $actionsTablesByType, $metricsConfig)
{
$rowsProcessed = 0;
while ($row = $query->fetch()) {
if (empty($row['idaction'])) {
$row['type'] = ($fieldQueried == 'idaction_url' ? Action::TYPE_PAGE_URL : Action::TYPE_PAGE_TITLE);
// This will be replaced with 'X not defined' later
$row['name'] = '';
// Yes, this is kind of a hack, so we don't mix 'page url not defined' with 'page title not defined' etc.
$row['idaction'] = -$row['type'];
}
if ($row['type'] != Action::TYPE_SITE_SEARCH) {
unset($row[PiwikMetrics::INDEX_SITE_SEARCH_HAS_NO_RESULT]);
}
if (in_array($row['type'], array(Action::TYPE_CONTENT, Action::TYPE_EVENT, Action::TYPE_EVENT_NAME, Action::TYPE_CONTENT_PIECE, Action::TYPE_CONTENT_TARGET))) {
continue;
}
$hasRowName = !empty($row['name']) && $row['name'] != DataTable::LABEL_SUMMARY_ROW;
// This will appear as <url /> in the API, which is actually very important to keep
// eg. When there's at least one row in a report that does not have a URL, not having this <url/> would break HTML/PDF reports.
$url = '';
$pageTitlePath = null;
if ($row['type'] == Action::TYPE_SITE_SEARCH
|| $row['type'] == Action::TYPE_PAGE_TITLE
) {
$url = null;
if ($hasRowName) {
$pageTitlePath = $row['name'];
}
} elseif ($hasRowName) {
$url = PageUrl::reconstructNormalizedUrl((string)$row['name'], $row['url_prefix']);
}
if (isset($row['name'])
&& isset($row['type'])
) {
$actionName = $row['name'];
$actionType = $row['type'];
$urlPrefix = $row['url_prefix'];
$idaction = $row['idaction'];
// in some unknown case, the type field is NULL, as reported in #1082 - we ignore this page view
if (empty($actionType)) {
if ($idaction != DataTable::LABEL_SUMMARY_ROW) {
self::setCachedActionRow($idaction, $actionType, false);
}
continue;
}
$actionRow = self::getActionRow($actionName, $actionType, $urlPrefix, $actionsTablesByType);
self::setCachedActionRow($idaction, $actionType, $actionRow);
} else {
$actionRow = self::getCachedActionRow($row['idaction'], $row['type']);
// Action processed as "to skip" for some reasons
if ($actionRow === false) {
continue;
}
}
if (is_null($actionRow)) {
continue;
}
// Here we do ensure that, the Metadata URL set for a given row, is the one from the Pageview with the most hits.
// This is to ensure that when, different URLs are loaded with the same page name.
// For example http://piwik.org and http://id.piwik.org are reported in Piwik > Actions > Pages with /index
// But, we must make sure http://piwik.org is used to link & for transitions
// Note: this code is partly duplicated from Row->sumRowMetadata()
if (!is_null($url)
&& !$actionRow->isSummaryRow()
) {
if (($existingUrl = $actionRow->getMetadata('url')) !== false) {
if (!empty($row[PiwikMetrics::INDEX_PAGE_NB_HITS])
&& $row[PiwikMetrics::INDEX_PAGE_NB_HITS] > $actionRow->maxVisitsSummed
) {
$actionRow->setMetadata('url', $url);
$actionRow->maxVisitsSummed = $row[PiwikMetrics::INDEX_PAGE_NB_HITS];
}
} else {
$actionRow->setMetadata('url', $url);
$actionRow->maxVisitsSummed = !empty($row[PiwikMetrics::INDEX_PAGE_NB_HITS]) ? $row[PiwikMetrics::INDEX_PAGE_NB_HITS] : 0;
}
}
if ($pageTitlePath !== null
&& !$actionRow->isSummaryRow()
) {
$actionRow->setMetadata('page_title_path', $pageTitlePath);
}
if ($row['type'] != Action::TYPE_PAGE_URL
&& $row['type'] != Action::TYPE_PAGE_TITLE
) {
// only keep performance metrics when they're used (i.e. for URLs and page titles)
if (array_key_exists(PiwikMetrics::INDEX_PAGE_SUM_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_SUM_TIME_GENERATION]);
}
if (array_key_exists(PiwikMetrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION]);
}
if (array_key_exists(PiwikMetrics::INDEX_PAGE_MIN_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_MIN_TIME_GENERATION]);
}
if (array_key_exists(PiwikMetrics::INDEX_PAGE_MAX_TIME_GENERATION, $row)) {
unset($row[PiwikMetrics::INDEX_PAGE_MAX_TIME_GENERATION]);
}
}
unset($row['name']);
unset($row['type']);
unset($row['idaction']);
unset($row['url_prefix']);
foreach ($row as $name => $value) {
// in some edge cases, we have twice the same action name with 2 different idaction
// - this happens when 2 visitors visit the same new page at the same time, and 2 actions get recorded for the same name
// - this could also happen when 2 URLs end up having the same label (eg. 2 subdomains get aggregated to the "/index" page name)
if (($alreadyValue = $actionRow->getColumn($name)) !== false) {
$newValue = self::getColumnValuesMerged($name, $alreadyValue, $value, $metricsConfig);
$actionRow->setColumn($name, $newValue);
} else {
$actionRow->addColumn($name, $value);
}
}
// if the exit_action was not recorded properly in the log_link_visit_action
// there would be an error message when getting the nb_hits column
// we must fake the record and add the columns
if ($actionRow->getColumn(PiwikMetrics::INDEX_PAGE_NB_HITS) === false) {
// to test this code: delete the entries in log_link_action_visit for
// a given exit_idaction_url
foreach (self::getDefaultRow()->getColumns() as $name => $value) {
$actionRow->addColumn($name, $value);
}
}
$rowsProcessed++;
}
// just to make sure php copies the last $actionRow in the $parentTable array
$actionRow =& $actionsTablesByType;
return $rowsProcessed;
} | [
"public",
"static",
"function",
"updateActionsTableWithRowQuery",
"(",
"$",
"query",
",",
"$",
"fieldQueried",
",",
"&",
"$",
"actionsTablesByType",
",",
"$",
"metricsConfig",
")",
"{",
"$",
"rowsProcessed",
"=",
"0",
";",
"while",
"(",
"$",
"row",
"=",
"$",... | Ideally this should use the DataArray object instead of custom data structure
@param Zend_Db_Statement|PDOStatement $query
@param string|bool $fieldQueried
@param array $actionsTablesByType
@return int | [
"Ideally",
"this",
"should",
"use",
"the",
"DataArray",
"object",
"instead",
"of",
"custom",
"data",
"structure"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/ArchivingHelper.php#L40-L187 | train | Updates the actions table with rows from a query | [
30522,
2270,
10763,
3853,
10651,
18908,
8496,
10880,
24415,
10524,
4226,
2854,
1006,
1002,
23032,
1010,
1002,
2492,
4226,
11998,
1010,
1004,
1002,
4506,
10880,
14478,
13874,
1010,
1002,
12046,
9363,
2078,
8873,
2290,
1007,
1063,
1002,
10281,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/PostCode.php | Zend_Validate_PostCode.isValid | public function isValid($value)
{
$this->_setValue($value);
if (!is_string($value) && !is_int($value)) {
$this->_error(self::INVALID);
return false;
}
$format = $this->getFormat();
if (!preg_match($format, $value)) {
$this->_error(self::NO_MATCH);
return false;
}
return true;
} | php | public function isValid($value)
{
$this->_setValue($value);
if (!is_string($value) && !is_int($value)) {
$this->_error(self::INVALID);
return false;
}
$format = $this->getFormat();
if (!preg_match($format, $value)) {
$this->_error(self::NO_MATCH);
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_setValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"!",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
... | Defined by Zend_Validate_Interface
Returns true if and only if $value is a valid postalcode
@param string $value
@return boolean | [
"Defined",
"by",
"Zend_Validate_Interface"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/PostCode.php#L194-L209 | train | Valida o valor de una peticion | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
3643,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
2275,
10175,
5657,
1006,
1002,
3643,
1007,
1025,
2065,
1006,
999,
2003,
1035,
5164,
1006,
1002,
3643,
1007,
1004,
1004,
999,
2003,
1035,
200... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php | MongoDbSessionHandler.doWrite | protected function doWrite($sessionId, $data)
{
$expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) ini_get('session.gc_maxlifetime')) * 1000);
$fields = [
$this->options['time_field'] => new \MongoDB\BSON\UTCDateTime(),
$this->options['expiry_field'] => $expiry,
$this->options['data_field'] => new \MongoDB\BSON\Binary($data, \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
];
$this->getCollection()->updateOne(
[$this->options['id_field'] => $sessionId],
['$set' => $fields],
['upsert' => true]
);
return true;
} | php | protected function doWrite($sessionId, $data)
{
$expiry = new \MongoDB\BSON\UTCDateTime((time() + (int) ini_get('session.gc_maxlifetime')) * 1000);
$fields = [
$this->options['time_field'] => new \MongoDB\BSON\UTCDateTime(),
$this->options['expiry_field'] => $expiry,
$this->options['data_field'] => new \MongoDB\BSON\Binary($data, \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
];
$this->getCollection()->updateOne(
[$this->options['id_field'] => $sessionId],
['$set' => $fields],
['upsert' => true]
);
return true;
} | [
"protected",
"function",
"doWrite",
"(",
"$",
"sessionId",
",",
"$",
"data",
")",
"{",
"$",
"expiry",
"=",
"new",
"\\",
"MongoDB",
"\\",
"BSON",
"\\",
"UTCDateTime",
"(",
"(",
"time",
"(",
")",
"+",
"(",
"int",
")",
"ini_get",
"(",
"'session.gc_maxlife... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php#L120-L137 | train | Write session data to database | [
30522,
5123,
3853,
23268,
17625,
1006,
1002,
5219,
3593,
1010,
1002,
2951,
1007,
1063,
1002,
4654,
8197,
2854,
1027,
2047,
1032,
12256,
3995,
18939,
1032,
18667,
2239,
1032,
11396,
13701,
7292,
1006,
1006,
2051,
1006,
1007,
1009,
1006,
2001... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/thrift | lib/php/lib/Transport/TFramedTransport.php | TFramedTransport.putBack | public function putBack($data)
{
if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
$this->rBuf_ = $data;
} else {
$this->rBuf_ = ($data . $this->rBuf_);
}
} | php | public function putBack($data)
{
if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) {
$this->rBuf_ = $data;
} else {
$this->rBuf_ = ($data . $this->rBuf_);
}
} | [
"public",
"function",
"putBack",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"TStringFuncFactory",
"::",
"create",
"(",
")",
"->",
"strlen",
"(",
"$",
"this",
"->",
"rBuf_",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"rBuf_",
"=",
"$",
"data",
";",
... | Put previously read data back into the buffer
@param string $data data to return | [
"Put",
"previously",
"read",
"data",
"back",
"into",
"the",
"buffer"
] | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Transport/TFramedTransport.php#L133-L140 | train | Put back the data in the buffer | [
30522,
2270,
3853,
2404,
5963,
1006,
1002,
2951,
1007,
1063,
2065,
1006,
24529,
18886,
3070,
11263,
12273,
21450,
1024,
1024,
3443,
1006,
1007,
1011,
1028,
2358,
20927,
2078,
1006,
1002,
2023,
1011,
1028,
21144,
16093,
1035,
1007,
1027,
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... |
symfony/symfony | src/Symfony/Component/CssSelector/XPath/Translator.php | Translator.cssToXPath | public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
{
$selectors = $this->parseSelectors($cssExpr);
/** @var SelectorNode $selector */
foreach ($selectors as $index => $selector) {
if (null !== $selector->getPseudoElement()) {
throw new ExpressionErrorException('Pseudo-elements are not supported.');
}
$selectors[$index] = $this->selectorToXPath($selector, $prefix);
}
return implode(' | ', $selectors);
} | php | public function cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::'): string
{
$selectors = $this->parseSelectors($cssExpr);
/** @var SelectorNode $selector */
foreach ($selectors as $index => $selector) {
if (null !== $selector->getPseudoElement()) {
throw new ExpressionErrorException('Pseudo-elements are not supported.');
}
$selectors[$index] = $this->selectorToXPath($selector, $prefix);
}
return implode(' | ', $selectors);
} | [
"public",
"function",
"cssToXPath",
"(",
"string",
"$",
"cssExpr",
",",
"string",
"$",
"prefix",
"=",
"'descendant-or-self::'",
")",
":",
"string",
"{",
"$",
"selectors",
"=",
"$",
"this",
"->",
"parseSelectors",
"(",
"$",
"cssExpr",
")",
";",
"/** @var Sele... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/CssSelector/XPath/Translator.php#L93-L107 | train | Converts a CSS expression to an XPath string. | [
30522,
2270,
3853,
20116,
16033,
2595,
15069,
1006,
5164,
1002,
20116,
3366,
2595,
18098,
1010,
5164,
1002,
17576,
1027,
1005,
12608,
1011,
2030,
1011,
2969,
1024,
1024,
1005,
1007,
1024,
5164,
1063,
1002,
27000,
2015,
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/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php | InlineServiceDefinitionsPass.processValue | protected function processValue($value, $isRoot = false)
{
if ($value instanceof ArgumentInterface) {
// Reference found in ArgumentInterface::getValues() are not inlineable
return $value;
}
if ($value instanceof Definition && $this->cloningIds) {
if ($value->isShared()) {
return $value;
}
$value = clone $value;
}
if (!$value instanceof Reference) {
return parent::processValue($value, $isRoot);
} elseif (!$this->container->hasDefinition($id = (string) $value)) {
return $value;
}
$definition = $this->container->getDefinition($id);
if (!$this->isInlineableDefinition($id, $definition)) {
return $value;
}
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
$this->inlinedIds[$id] = $definition->isPublic() || !$definition->isShared();
$this->notInlinedIds[$this->currentId] = true;
if ($definition->isShared()) {
return $definition;
}
if (isset($this->cloningIds[$id])) {
$ids = array_keys($this->cloningIds);
$ids[] = $id;
throw new ServiceCircularReferenceException($id, \array_slice($ids, array_search($id, $ids)));
}
$this->cloningIds[$id] = true;
try {
return $this->processValue($definition);
} finally {
unset($this->cloningIds[$id]);
}
} | php | protected function processValue($value, $isRoot = false)
{
if ($value instanceof ArgumentInterface) {
// Reference found in ArgumentInterface::getValues() are not inlineable
return $value;
}
if ($value instanceof Definition && $this->cloningIds) {
if ($value->isShared()) {
return $value;
}
$value = clone $value;
}
if (!$value instanceof Reference) {
return parent::processValue($value, $isRoot);
} elseif (!$this->container->hasDefinition($id = (string) $value)) {
return $value;
}
$definition = $this->container->getDefinition($id);
if (!$this->isInlineableDefinition($id, $definition)) {
return $value;
}
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
$this->inlinedIds[$id] = $definition->isPublic() || !$definition->isShared();
$this->notInlinedIds[$this->currentId] = true;
if ($definition->isShared()) {
return $definition;
}
if (isset($this->cloningIds[$id])) {
$ids = array_keys($this->cloningIds);
$ids[] = $id;
throw new ServiceCircularReferenceException($id, \array_slice($ids, array_search($id, $ids)));
}
$this->cloningIds[$id] = true;
try {
return $this->processValue($definition);
} finally {
unset($this->cloningIds[$id]);
}
} | [
"protected",
"function",
"processValue",
"(",
"$",
"value",
",",
"$",
"isRoot",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"ArgumentInterface",
")",
"{",
"// Reference found in ArgumentInterface::getValues() are not inlineable",
"return",
"$",
"val... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php#L118-L165 | train | Process value. | [
30522,
5123,
3853,
2832,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
2003,
3217,
4140,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
3643,
6013,
11253,
6685,
18447,
2121,
12172,
1007,
1063,
1013,
1013,
4431,
2179,
1999,
6685,
18447,
2121,
12172,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.postSend | public function postSend()
{
try {
// Choose the mailer and send through it
switch ($this->Mailer) {
case 'sendmail':
case 'qmail':
return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
case 'smtp':
return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
case 'mail':
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
default:
$sendMethod = $this->Mailer . 'Send';
if (method_exists($this, $sendMethod)) {
return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
}
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
}
} catch (Exception $exc) {
$this->setError($exc->getMessage());
$this->edebug($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
}
return false;
} | php | public function postSend()
{
try {
// Choose the mailer and send through it
switch ($this->Mailer) {
case 'sendmail':
case 'qmail':
return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
case 'smtp':
return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
case 'mail':
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
default:
$sendMethod = $this->Mailer . 'Send';
if (method_exists($this, $sendMethod)) {
return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
}
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
}
} catch (Exception $exc) {
$this->setError($exc->getMessage());
$this->edebug($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
}
return false;
} | [
"public",
"function",
"postSend",
"(",
")",
"{",
"try",
"{",
"// Choose the mailer and send through it",
"switch",
"(",
"$",
"this",
"->",
"Mailer",
")",
"{",
"case",
"'sendmail'",
":",
"case",
"'qmail'",
":",
"return",
"$",
"this",
"->",
"sendmailSend",
"(",
... | Actually send a message via the selected mechanism.
@throws Exception
@return bool | [
"Actually",
"send",
"a",
"message",
"via",
"the",
"selected",
"mechanism",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L1530-L1559 | train | Post send method | [
30522,
2270,
3853,
8466,
10497,
1006,
1007,
1063,
3046,
1063,
1013,
1013,
5454,
1996,
5653,
2121,
1998,
4604,
2083,
2009,
6942,
1006,
1002,
2023,
1011,
1028,
5653,
2121,
1007,
1063,
2553,
1005,
4604,
21397,
1005,
1024,
2553,
1005,
1053,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Dimension/VisitDimension.php | VisitDimension.getDimensions | public static function getDimensions(Plugin $plugin)
{
$dimensions = $plugin->findMultipleComponents('Columns', '\\Piwik\\Plugin\\Dimension\\VisitDimension');
$instances = array();
foreach ($dimensions as $dimension) {
$instances[] = new $dimension();
}
return $instances;
} | php | public static function getDimensions(Plugin $plugin)
{
$dimensions = $plugin->findMultipleComponents('Columns', '\\Piwik\\Plugin\\Dimension\\VisitDimension');
$instances = array();
foreach ($dimensions as $dimension) {
$instances[] = new $dimension();
}
return $instances;
} | [
"public",
"static",
"function",
"getDimensions",
"(",
"Plugin",
"$",
"plugin",
")",
"{",
"$",
"dimensions",
"=",
"$",
"plugin",
"->",
"findMultipleComponents",
"(",
"'Columns'",
",",
"'\\\\Piwik\\\\Plugin\\\\Dimension\\\\VisitDimension'",
")",
";",
"$",
"instances",
... | Get all visit dimensions that are defined by the given plugin.
@param Plugin $plugin
@return VisitDimension[]
@ignore | [
"Get",
"all",
"visit",
"dimensions",
"that",
"are",
"defined",
"by",
"the",
"given",
"plugin",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Dimension/VisitDimension.php#L338-L348 | train | Returns an array of Dimension objects for the given plugin. | [
30522,
2270,
10763,
3853,
2131,
22172,
6132,
8496,
1006,
13354,
2378,
1002,
13354,
2378,
1007,
1063,
1002,
9646,
1027,
1002,
13354,
2378,
1011,
1028,
2424,
12274,
7096,
11514,
2571,
9006,
29513,
7666,
1006,
1005,
7753,
1005,
1010,
1005,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Serializer.php | Serializer.decode | final public function decode($data, $format, array $context = [])
{
return $this->decoder->decode($data, $format, $context);
} | php | final public function decode($data, $format, array $context = [])
{
return $this->decoder->decode($data, $format, $context);
} | [
"final",
"public",
"function",
"decode",
"(",
"$",
"data",
",",
"$",
"format",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"decoder",
"->",
"decode",
"(",
"$",
"data",
",",
"$",
"format",
",",
"$",
"context",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Serializer.php#L307-L310 | train | Decodes the data into a list of objects | [
30522,
2345,
2270,
3853,
21933,
3207,
1006,
1002,
2951,
1010,
1002,
4289,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
21933,
4063,
1011,
1028,
21933,
3207,
1006,
1002,
2951,
1010,
1002,
4289,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Columns/Dimension.php | Dimension.groupValue | public function groupValue($value, $idSite)
{
switch ($this->type) {
case Dimension::TYPE_URL:
return str_replace(array('http://', 'https://'), '', $value);
case Dimension::TYPE_BOOL:
return !empty($value) ? '1' : '0';
case Dimension::TYPE_DURATION_MS:
return number_format($value / 1000, 2); // because we divide we need to group them and cannot do this in formatting step
}
return $value;
} | php | public function groupValue($value, $idSite)
{
switch ($this->type) {
case Dimension::TYPE_URL:
return str_replace(array('http://', 'https://'), '', $value);
case Dimension::TYPE_BOOL:
return !empty($value) ? '1' : '0';
case Dimension::TYPE_DURATION_MS:
return number_format($value / 1000, 2); // because we divide we need to group them and cannot do this in formatting step
}
return $value;
} | [
"public",
"function",
"groupValue",
"(",
"$",
"value",
",",
"$",
"idSite",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"Dimension",
"::",
"TYPE_URL",
":",
"return",
"str_replace",
"(",
"array",
"(",
"'http://'",
",",
"'https://'... | A dimension should group values by using this method. Otherwise the same row may appear several times.
@param mixed $value
@param int $idSite
@return mixed
@api since Piwik 3.2.0 | [
"A",
"dimension",
"should",
"group",
"values",
"by",
"using",
"this",
"method",
".",
"Otherwise",
"the",
"same",
"row",
"may",
"appear",
"several",
"times",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Columns/Dimension.php#L405-L416 | train | Group Dimension value by type | [
30522,
2270,
3853,
2177,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
8909,
28032,
2063,
1007,
1063,
6942,
1006,
1002,
2023,
1011,
1028,
2828,
1007,
1063,
2553,
9812,
1024,
1024,
2828,
1035,
24471,
2140,
1024,
2709,
2358,
2099,
1035,
5672,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/UpdateManager.php | UpdateManager.extractTheme | public function extractTheme($name, $hash)
{
$fileCode = $name . $hash;
$filePath = $this->getFilePath($fileCode);
if (!Zip::extract($filePath, $this->baseDirectory . '/themes/')) {
throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath]));
}
if ($this->themeManager) {
$this->themeManager->setInstalled($name);
}
@unlink($filePath);
} | php | public function extractTheme($name, $hash)
{
$fileCode = $name . $hash;
$filePath = $this->getFilePath($fileCode);
if (!Zip::extract($filePath, $this->baseDirectory . '/themes/')) {
throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath]));
}
if ($this->themeManager) {
$this->themeManager->setInstalled($name);
}
@unlink($filePath);
} | [
"public",
"function",
"extractTheme",
"(",
"$",
"name",
",",
"$",
"hash",
")",
"{",
"$",
"fileCode",
"=",
"$",
"name",
".",
"$",
"hash",
";",
"$",
"filePath",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"fileCode",
")",
";",
"if",
"(",
"!",
... | Extracts a theme after it has been downloaded. | [
"Extracts",
"a",
"theme",
"after",
"it",
"has",
"been",
"downloaded",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/UpdateManager.php#L623-L637 | train | Extracts a theme from the zip archive | [
30522,
2270,
3853,
14817,
10760,
4168,
1006,
1002,
2171,
1010,
1002,
23325,
1007,
1063,
1002,
5371,
30524,
16761,
2100,
1012,
1005,
1013,
6991,
1013,
1005,
1007,
1007,
1063,
5466,
2047,
4646,
10288,
24422,
1006,
11374,
1024,
1024,
2131,
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/Zend/Mail/Storage/Imap.php | Zend_Mail_Storage_Imap.removeFolder | public function removeFolder($name)
{
if ($name instanceof Zend_Mail_Storage_Folder) {
$name = $name->getGlobalName();
}
if (!$this->_protocol->delete($name)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot delete folder');
}
} | php | public function removeFolder($name)
{
if ($name instanceof Zend_Mail_Storage_Folder) {
$name = $name->getGlobalName();
}
if (!$this->_protocol->delete($name)) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot delete folder');
}
} | [
"public",
"function",
"removeFolder",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"name",
"instanceof",
"Zend_Mail_Storage_Folder",
")",
"{",
"$",
"name",
"=",
"$",
"name",
"->",
"getGlobalName",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
... | remove a folder
@param string|Zend_Mail_Storage_Folder $name name or instance of folder
@return null
@throws Zend_Mail_Storage_Exception | [
"remove",
"a",
"folder"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Imap.php#L521-L534 | train | Delete a folder | [
30522,
2270,
3853,
6366,
10371,
2121,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
1002,
2171,
6013,
11253,
16729,
2094,
1035,
5653,
1035,
5527,
1035,
19622,
1007,
1063,
1002,
2171,
1027,
1002,
2171,
1011,
1028,
2131,
23296,
16429,
2389,
18442... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Support/Facades/Event.php | Event.fake | public static function fake($eventsToFake = [])
{
static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake));
Model::setEventDispatcher($fake);
return $fake;
} | php | public static function fake($eventsToFake = [])
{
static::swap($fake = new EventFake(static::getFacadeRoot(), $eventsToFake));
Model::setEventDispatcher($fake);
return $fake;
} | [
"public",
"static",
"function",
"fake",
"(",
"$",
"eventsToFake",
"=",
"[",
"]",
")",
"{",
"static",
"::",
"swap",
"(",
"$",
"fake",
"=",
"new",
"EventFake",
"(",
"static",
"::",
"getFacadeRoot",
"(",
")",
",",
"$",
"eventsToFake",
")",
")",
";",
"Mo... | Replace the bound instance with a fake.
@param array|string $eventsToFake
@return \Illuminate\Support\Testing\Fakes\EventFake | [
"Replace",
"the",
"bound",
"instance",
"with",
"a",
"fake",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Facades/Event.php#L29-L36 | train | Fake the events to be fired by the model | [
30522,
2270,
10763,
3853,
8275,
1006,
1002,
2824,
3406,
7011,
3489,
1027,
1031,
1033,
1007,
1063,
10763,
1024,
1024,
19948,
1006,
1002,
8275,
1027,
2047,
2724,
7011,
3489,
1006,
10763,
1024,
1024,
2131,
7011,
21869,
3217,
4140,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/Controller.php | Controller.makeHintPartial | public function makeHintPartial($name, $partial = null, $params = [])
{
if (is_array($partial)) {
$params = $partial;
$partial = null;
}
if (!$partial) {
$partial = array_get($params, 'partial', $name);
}
return $this->makeLayoutPartial('hint', [
'hintName' => $name,
'hintPartial' => $partial,
'hintContent' => array_get($params, 'content'),
'hintParams' => $params
] + $params);
} | php | public function makeHintPartial($name, $partial = null, $params = [])
{
if (is_array($partial)) {
$params = $partial;
$partial = null;
}
if (!$partial) {
$partial = array_get($params, 'partial', $name);
}
return $this->makeLayoutPartial('hint', [
'hintName' => $name,
'hintPartial' => $partial,
'hintContent' => array_get($params, 'content'),
'hintParams' => $params
] + $params);
} | [
"public",
"function",
"makeHintPartial",
"(",
"$",
"name",
",",
"$",
"partial",
"=",
"null",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"partial",
")",
")",
"{",
"$",
"params",
"=",
"$",
"partial",
";",
"$",
"pa... | Renders a hint partial, used for displaying informative information that
can be hidden by the user. If you don't want to render a partial, you can
supply content via the 'content' key of $params.
@param string $name Unique key name
@param string $partial Reference to content (partial name)
@param array $params Extra parameters
@return string | [
"Renders",
"a",
"hint",
"partial",
"used",
"for",
"displaying",
"informative",
"information",
"that",
"can",
"be",
"hidden",
"by",
"the",
"user",
".",
"If",
"you",
"don",
"t",
"want",
"to",
"render",
"a",
"partial",
"you",
"can",
"supply",
"content",
"via"... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L665-L682 | train | Return partial for hint | [
30522,
2270,
3853,
2191,
10606,
25856,
8445,
4818,
1006,
1002,
2171,
1010,
1002,
7704,
1027,
19701,
1010,
1002,
11498,
5244,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
7704,
1007,
1007,
1063,
1002,
11498,
5244,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ServerBag.php | ServerBag.getHeaders | public function getHeaders()
{
$headers = [];
$contentHeaders = ['CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true];
foreach ($this->parameters as $key => $value) {
if (0 === strpos($key, 'HTTP_')) {
$headers[substr($key, 5)] = $value;
}
// CONTENT_* are not prefixed with HTTP_
elseif (isset($contentHeaders[$key])) {
$headers[$key] = $value;
}
}
if (isset($this->parameters['PHP_AUTH_USER'])) {
$headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
$headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
} else {
/*
* php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default
* For this workaround to work, add these lines to your .htaccess file:
* RewriteCond %{HTTP:Authorization} ^(.+)$
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
*
* A sample .htaccess file:
* RewriteEngine On
* RewriteCond %{HTTP:Authorization} ^(.+)$
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
* RewriteCond %{REQUEST_FILENAME} !-f
* RewriteRule ^(.*)$ app.php [QSA,L]
*/
$authorizationHeader = null;
if (isset($this->parameters['HTTP_AUTHORIZATION'])) {
$authorizationHeader = $this->parameters['HTTP_AUTHORIZATION'];
} elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
$authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION'];
}
if (null !== $authorizationHeader) {
if (0 === stripos($authorizationHeader, 'basic ')) {
// Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic
$exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2);
if (2 == \count($exploded)) {
list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
}
} elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) {
// In some circumstances PHP_AUTH_DIGEST needs to be set
$headers['PHP_AUTH_DIGEST'] = $authorizationHeader;
$this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader;
} elseif (0 === stripos($authorizationHeader, 'bearer ')) {
/*
* XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables,
* I'll just set $headers['AUTHORIZATION'] here.
* http://php.net/manual/en/reserved.variables.server.php
*/
$headers['AUTHORIZATION'] = $authorizationHeader;
}
}
}
if (isset($headers['AUTHORIZATION'])) {
return $headers;
}
// PHP_AUTH_USER/PHP_AUTH_PW
if (isset($headers['PHP_AUTH_USER'])) {
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);
} elseif (isset($headers['PHP_AUTH_DIGEST'])) {
$headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST'];
}
return $headers;
} | php | public function getHeaders()
{
$headers = [];
$contentHeaders = ['CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true];
foreach ($this->parameters as $key => $value) {
if (0 === strpos($key, 'HTTP_')) {
$headers[substr($key, 5)] = $value;
}
// CONTENT_* are not prefixed with HTTP_
elseif (isset($contentHeaders[$key])) {
$headers[$key] = $value;
}
}
if (isset($this->parameters['PHP_AUTH_USER'])) {
$headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
$headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
} else {
/*
* php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default
* For this workaround to work, add these lines to your .htaccess file:
* RewriteCond %{HTTP:Authorization} ^(.+)$
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
*
* A sample .htaccess file:
* RewriteEngine On
* RewriteCond %{HTTP:Authorization} ^(.+)$
* RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
* RewriteCond %{REQUEST_FILENAME} !-f
* RewriteRule ^(.*)$ app.php [QSA,L]
*/
$authorizationHeader = null;
if (isset($this->parameters['HTTP_AUTHORIZATION'])) {
$authorizationHeader = $this->parameters['HTTP_AUTHORIZATION'];
} elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
$authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION'];
}
if (null !== $authorizationHeader) {
if (0 === stripos($authorizationHeader, 'basic ')) {
// Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW when authorization header is basic
$exploded = explode(':', base64_decode(substr($authorizationHeader, 6)), 2);
if (2 == \count($exploded)) {
list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
}
} elseif (empty($this->parameters['PHP_AUTH_DIGEST']) && (0 === stripos($authorizationHeader, 'digest '))) {
// In some circumstances PHP_AUTH_DIGEST needs to be set
$headers['PHP_AUTH_DIGEST'] = $authorizationHeader;
$this->parameters['PHP_AUTH_DIGEST'] = $authorizationHeader;
} elseif (0 === stripos($authorizationHeader, 'bearer ')) {
/*
* XXX: Since there is no PHP_AUTH_BEARER in PHP predefined variables,
* I'll just set $headers['AUTHORIZATION'] here.
* http://php.net/manual/en/reserved.variables.server.php
*/
$headers['AUTHORIZATION'] = $authorizationHeader;
}
}
}
if (isset($headers['AUTHORIZATION'])) {
return $headers;
}
// PHP_AUTH_USER/PHP_AUTH_PW
if (isset($headers['PHP_AUTH_USER'])) {
$headers['AUTHORIZATION'] = 'Basic '.base64_encode($headers['PHP_AUTH_USER'].':'.$headers['PHP_AUTH_PW']);
} elseif (isset($headers['PHP_AUTH_DIGEST'])) {
$headers['AUTHORIZATION'] = $headers['PHP_AUTH_DIGEST'];
}
return $headers;
} | [
"public",
"function",
"getHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"$",
"contentHeaders",
"=",
"[",
"'CONTENT_LENGTH'",
"=>",
"true",
",",
"'CONTENT_MD5'",
"=>",
"true",
",",
"'CONTENT_TYPE'",
"=>",
"true",
"]",
";",
"foreach",
"(",
"... | Gets the HTTP headers.
@return array | [
"Gets",
"the",
"HTTP",
"headers",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/ServerBag.php#L28-L101 | train | Get HTTP headers | [
30522,
2270,
3853,
2131,
4974,
2545,
1006,
1007,
1063,
1002,
20346,
2015,
1027,
1031,
1033,
1025,
1002,
4180,
4974,
2545,
1027,
1031,
1005,
4180,
1035,
3091,
1005,
1027,
1028,
2995,
1010,
1005,
4180,
1035,
9108,
2629,
1005,
1027,
1028,
29... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid.php | Grid.disableRowSelector | public function disableRowSelector(bool $disable = true)
{
$this->tools->disableBatchActions($disable);
return $this->option('show_row_selector', !$disable);
} | php | public function disableRowSelector(bool $disable = true)
{
$this->tools->disableBatchActions($disable);
return $this->option('show_row_selector', !$disable);
} | [
"public",
"function",
"disableRowSelector",
"(",
"bool",
"$",
"disable",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"tools",
"->",
"disableBatchActions",
"(",
"$",
"disable",
")",
";",
"return",
"$",
"this",
"->",
"option",
"(",
"'show_row_selector'",
",",
... | Disable row selector.
@return Grid|mixed | [
"Disable",
"row",
"selector",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid.php#L542-L547 | train | Disable Row Selector | [
30522,
2270,
3853,
4487,
19150,
10524,
11246,
22471,
2953,
1006,
22017,
2140,
1002,
4487,
19150,
1027,
2995,
1007,
1063,
1002,
2023,
1011,
1028,
5906,
1011,
1028,
4487,
19150,
14479,
7507,
22014,
1006,
1002,
4487,
19150,
1007,
1025,
2709,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter/Group.php | Group.equal | public function equal($label = '', $operator = '=')
{
$label = $label ?: $operator;
$condition = [$this->column, $operator, $this->value];
return $this->joinGroup($label, $condition);
} | php | public function equal($label = '', $operator = '=')
{
$label = $label ?: $operator;
$condition = [$this->column, $operator, $this->value];
return $this->joinGroup($label, $condition);
} | [
"public",
"function",
"equal",
"(",
"$",
"label",
"=",
"''",
",",
"$",
"operator",
"=",
"'='",
")",
"{",
"$",
"label",
"=",
"$",
"label",
"?",
":",
"$",
"operator",
";",
"$",
"condition",
"=",
"[",
"$",
"this",
"->",
"column",
",",
"$",
"operator... | Filter out `equal` records.
@param string $label
@param string $operator
@return Group | [
"Filter",
"out",
"equal",
"records",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/Group.php#L87-L94 | train | Filter the result by a column = value | [
30522,
2270,
3853,
5020,
1006,
1002,
3830,
1027,
1005,
1005,
1010,
1002,
6872,
1027,
1005,
1027,
1005,
1007,
1063,
1002,
3830,
1027,
1002,
3830,
1029,
1024,
1002,
6872,
1025,
1002,
4650,
1027,
1031,
1002,
2023,
1011,
1028,
5930,
1010,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/FormatsMessages.php | FormatsMessages.getWildcardCustomMessages | protected function getWildcardCustomMessages($messages, $search, $default)
{
foreach ($messages as $key => $message) {
if ($search === $key || (Str::contains($key, ['*']) && Str::is($key, $search))) {
return $message;
}
}
return $default;
} | php | protected function getWildcardCustomMessages($messages, $search, $default)
{
foreach ($messages as $key => $message) {
if ($search === $key || (Str::contains($key, ['*']) && Str::is($key, $search))) {
return $message;
}
}
return $default;
} | [
"protected",
"function",
"getWildcardCustomMessages",
"(",
"$",
"messages",
",",
"$",
"search",
",",
"$",
"default",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"key",
"=>",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"search",
"===",
"$",
"key... | Check the given messages for a wildcard key.
@param array $messages
@param string $search
@param string $default
@return string | [
"Check",
"the",
"given",
"messages",
"for",
"a",
"wildcard",
"key",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/FormatsMessages.php#L140-L149 | train | Get the wildcard custom messages | [
30522,
5123,
3853,
2131,
29602,
16409,
4232,
7874,
20389,
7834,
3736,
8449,
1006,
1002,
7696,
1010,
1002,
3945,
1010,
1002,
12398,
1007,
1063,
18921,
6776,
1006,
1002,
7696,
2004,
1002,
3145,
1027,
1028,
1002,
4471,
1007,
1063,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Auth/Database/HasPermissions.php | HasPermissions.visible | public function visible(array $roles = []) : bool
{
if (empty($roles)) {
return true;
}
$roles = array_column($roles, 'slug');
return $this->inRoles($roles) || $this->isAdministrator();
} | php | public function visible(array $roles = []) : bool
{
if (empty($roles)) {
return true;
}
$roles = array_column($roles, 'slug');
return $this->inRoles($roles) || $this->isAdministrator();
} | [
"public",
"function",
"visible",
"(",
"array",
"$",
"roles",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"roles",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"roles",
"=",
"array_column",
"(",
"$",
"roles",
",",
"'slug... | If visible for roles.
@param $roles
@return bool | [
"If",
"visible",
"for",
"roles",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Auth/Database/HasPermissions.php#L93-L102 | train | Check if the user is visible to the given roles | [
30522,
2270,
3853,
5710,
1006,
9140,
1002,
4395,
1027,
1031,
1033,
1007,
1024,
22017,
2140,
1063,
2065,
1006,
4064,
1006,
1002,
4395,
1007,
1007,
1063,
2709,
2995,
1025,
1065,
1002,
4395,
1027,
9140,
1035,
5930,
1006,
1002,
4395,
1010,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php | FormTypeValidatorExtension.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
// Constraint should always be converted to an array
$constraintsNormalizer = function (Options $options, $constraints) {
return \is_object($constraints) ? [$constraints] : (array) $constraints;
};
$resolver->setDefaults([
'error_mapping' => [],
'constraints' => [],
'invalid_message' => 'This value is not valid.',
'invalid_message_parameters' => [],
'allow_extra_fields' => false,
'extra_fields_message' => 'This form should not contain extra fields.',
]);
$resolver->setNormalizer('constraints', $constraintsNormalizer);
} | php | public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
// Constraint should always be converted to an array
$constraintsNormalizer = function (Options $options, $constraints) {
return \is_object($constraints) ? [$constraints] : (array) $constraints;
};
$resolver->setDefaults([
'error_mapping' => [],
'constraints' => [],
'invalid_message' => 'This value is not valid.',
'invalid_message_parameters' => [],
'allow_extra_fields' => false,
'extra_fields_message' => 'This form should not contain extra fields.',
]);
$resolver->setNormalizer('constraints', $constraintsNormalizer);
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"parent",
"::",
"configureOptions",
"(",
"$",
"resolver",
")",
";",
"// Constraint should always be converted to an array",
"$",
"constraintsNormalizer",
"=",
"function",
"(",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php#L47-L66 | train | Configure the options for the validator | [
30522,
2270,
3853,
9530,
8873,
27390,
8780,
16790,
2015,
1006,
7047,
6072,
4747,
6299,
1002,
10663,
2099,
1007,
1063,
6687,
1024,
1024,
9530,
8873,
27390,
8780,
16790,
2015,
1006,
1002,
10663,
2099,
1007,
1025,
1013,
1013,
27142,
2323,
2467... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/BrowserKit/Client.php | Client.getInternalRequest | public function getInternalRequest()
{
if (null === $this->internalRequest) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
return $this->internalRequest;
} | php | public function getInternalRequest()
{
if (null === $this->internalRequest) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
return $this->internalRequest;
} | [
"public",
"function",
"getInternalRequest",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"internalRequest",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'Calling the \"%s()\" method before the \"request()\" one is deprecated since Symfony 4.1 and wil... | Returns the current BrowserKit Request instance.
@return Request A BrowserKit Request instance | [
"Returns",
"the",
"current",
"BrowserKit",
"Request",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/Client.php#L251-L259 | train | Returns the internal request object | [
30522,
2270,
3853,
2131,
18447,
11795,
2389,
2890,
15500,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
4722,
2890,
15500,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
4214,
1996,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php | SymfonyQuestionHelper.writeError | protected function writeError(OutputInterface $output, \Exception $error)
{
if ($output instanceof SymfonyStyle) {
$output->newLine();
$output->error($error->getMessage());
return;
}
parent::writeError($output, $error);
} | php | protected function writeError(OutputInterface $output, \Exception $error)
{
if ($output instanceof SymfonyStyle) {
$output->newLine();
$output->error($error->getMessage());
return;
}
parent::writeError($output, $error);
} | [
"protected",
"function",
"writeError",
"(",
"OutputInterface",
"$",
"output",
",",
"\\",
"Exception",
"$",
"error",
")",
"{",
"if",
"(",
"$",
"output",
"instanceof",
"SymfonyStyle",
")",
"{",
"$",
"output",
"->",
"newLine",
"(",
")",
";",
"$",
"output",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/SymfonyQuestionHelper.php#L85-L95 | train | Write error to output | [
30522,
5123,
3853,
4339,
2121,
29165,
1006,
6434,
18447,
2121,
12172,
1002,
6434,
1010,
1032,
6453,
1002,
7561,
1007,
1063,
2065,
1006,
1002,
6434,
6013,
11253,
25353,
2213,
14876,
4890,
21756,
2571,
1007,
1063,
1002,
6434,
1011,
1028,
2047... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/Connectors/PhpRedisConnector.php | PhpRedisConnector.connectToCluster | public function connectToCluster(array $config, array $clusterOptions, array $options)
{
$options = array_merge($options, $clusterOptions, Arr::pull($config, 'options', []));
return new PhpRedisClusterConnection($this->createRedisClusterInstance(
array_map([$this, 'buildClusterConnectionString'], $config), $options
));
} | php | public function connectToCluster(array $config, array $clusterOptions, array $options)
{
$options = array_merge($options, $clusterOptions, Arr::pull($config, 'options', []));
return new PhpRedisClusterConnection($this->createRedisClusterInstance(
array_map([$this, 'buildClusterConnectionString'], $config), $options
));
} | [
"public",
"function",
"connectToCluster",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"clusterOptions",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"options",
",",
"$",
"clusterOptions",
",",
"Arr",
"::",
"pull... | Create a new clustered PhpRedis connection.
@param array $config
@param array $clusterOptions
@param array $options
@return \Illuminate\Redis\Connections\PhpRedisClusterConnection | [
"Create",
"a",
"new",
"clustered",
"PhpRedis",
"connection",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Connectors/PhpRedisConnector.php#L35-L42 | train | Connect to a Redis cluster | [
30522,
2270,
3853,
7532,
3406,
20464,
19966,
2121,
1006,
9140,
1002,
9530,
8873,
2290,
1010,
9140,
1002,
9324,
7361,
9285,
1010,
9140,
1002,
7047,
1007,
1063,
1002,
7047,
1027,
9140,
1035,
13590,
1006,
1002,
7047,
1010,
1002,
9324,
7361,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Filter/AddSegmentBySegmentValue.php | AddSegmentBySegmentValue.filter | public function filter($table)
{
if (empty($this->report) || !$table->getRowsCount()) {
return;
}
$dimension = $this->report->getDimension();
if (empty($dimension)) {
return;
}
$segments = $dimension->getSegments();
if (empty($segments)) {
return;
}
$this->enableRecursive(true);
/** @var \Piwik\Plugin\Segment $segment */
$segment = reset($segments);
$segmentName = $segment->getSegment();
foreach ($table->getRows() as $row) {
$value = $row->getMetadata('segmentValue');
$filter = $row->getMetadata('segment');
if ($value !== false && $filter === false) {
$row->setMetadata('segment', sprintf('%s==%s', $segmentName, urlencode($value)));
}
$this->filterSubTable($row);
}
} | php | public function filter($table)
{
if (empty($this->report) || !$table->getRowsCount()) {
return;
}
$dimension = $this->report->getDimension();
if (empty($dimension)) {
return;
}
$segments = $dimension->getSegments();
if (empty($segments)) {
return;
}
$this->enableRecursive(true);
/** @var \Piwik\Plugin\Segment $segment */
$segment = reset($segments);
$segmentName = $segment->getSegment();
foreach ($table->getRows() as $row) {
$value = $row->getMetadata('segmentValue');
$filter = $row->getMetadata('segment');
if ($value !== false && $filter === false) {
$row->setMetadata('segment', sprintf('%s==%s', $segmentName, urlencode($value)));
}
$this->filterSubTable($row);
}
} | [
"public",
"function",
"filter",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"report",
")",
"||",
"!",
"$",
"table",
"->",
"getRowsCount",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"dimension",
"=",
"$",
"this",
"->... | See {@link AddSegmentBySegmentValue}.
@param DataTable $table
@return int The number of deleted rows. | [
"See",
"{",
"@link",
"AddSegmentBySegmentValue",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/AddSegmentBySegmentValue.php#L47-L81 | train | Filter the table rows to only include rows with a value equal to the value of the dimension. | [
30522,
2270,
3853,
11307,
1006,
1002,
2795,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
3189,
1007,
1064,
1064,
999,
1002,
2795,
1011,
1028,
2131,
10524,
9363,
16671,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
9812,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Filesystem/Filesystem.php | Filesystem.dirnameInternal | protected function dirnameInternal(?string $scheme, string $path, int $levels = 1): array
{
$path = \dirname($path, $levels);
if (null !== $scheme && $path === '.') {
return [$scheme, ''];
}
return [$scheme, $path];
} | php | protected function dirnameInternal(?string $scheme, string $path, int $levels = 1): array
{
$path = \dirname($path, $levels);
if (null !== $scheme && $path === '.') {
return [$scheme, ''];
}
return [$scheme, $path];
} | [
"protected",
"function",
"dirnameInternal",
"(",
"?",
"string",
"$",
"scheme",
",",
"string",
"$",
"path",
",",
"int",
"$",
"levels",
"=",
"1",
")",
":",
"array",
"{",
"$",
"path",
"=",
"\\",
"dirname",
"(",
"$",
"path",
",",
"$",
"levels",
")",
";... | @param string|null $scheme
@param string $path
@param int $levels
@return array | [
"@param",
"string|null",
"$scheme",
"@param",
"string",
"$path",
"@param",
"int",
"$levels"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Filesystem/Filesystem.php#L171-L180 | train | Internal function to get the path of a directory. | [
30522,
5123,
3853,
16101,
18442,
18447,
11795,
2389,
1006,
1029,
5164,
1002,
5679,
1010,
5164,
1002,
4130,
1010,
20014,
1002,
3798,
1027,
1015,
1007,
1024,
9140,
1063,
1002,
4130,
1027,
1032,
16101,
18442,
1006,
1002,
4130,
1010,
1002,
3798... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Simple/PhpArrayCache.php | PhpArrayCache.set | public function set($key, $value, $ttl = null)
{
if (!\is_string($key)) {
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key)));
}
if (null === $this->values) {
$this->initialize();
}
return !isset($this->keys[$key]) && $this->pool->set($key, $value, $ttl);
} | php | public function set($key, $value, $ttl = null)
{
if (!\is_string($key)) {
throw new InvalidArgumentException(sprintf('Cache key must be string, "%s" given.', \is_object($key) ? \get_class($key) : \gettype($key)));
}
if (null === $this->values) {
$this->initialize();
}
return !isset($this->keys[$key]) && $this->pool->set($key, $value, $ttl);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Cache key m... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Simple/PhpArrayCache.php#L177-L187 | train | Set a value in the cache | [
30522,
2270,
3853,
2275,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
1002,
23746,
2140,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1032,
2003,
1035,
5164,
1006,
1002,
3145,
1007,
1007,
1063,
5466,
2047,
19528,
2906,
22850,
15781,
2595,
24422,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/Card/CodeClient.php | CodeClient.deposit | public function deposit(string $cardId, array $codes)
{
$params = [
'card_id' => $cardId,
'code' => $codes,
];
return $this->httpPostJson('card/code/deposit', $params);
} | php | public function deposit(string $cardId, array $codes)
{
$params = [
'card_id' => $cardId,
'code' => $codes,
];
return $this->httpPostJson('card/code/deposit', $params);
} | [
"public",
"function",
"deposit",
"(",
"string",
"$",
"cardId",
",",
"array",
"$",
"codes",
")",
"{",
"$",
"params",
"=",
"[",
"'card_id'",
"=>",
"$",
"cardId",
",",
"'code'",
"=>",
"$",
"codes",
",",
"]",
";",
"return",
"$",
"this",
"->",
"httpPostJs... | 导入code接口.
@param string $cardId
@param array $codes
@return mixed | [
"导入code接口",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Card/CodeClient.php#L31-L39 | train | Deposit Card Code | [
30522,
2270,
3853,
12816,
1006,
5164,
1002,
4003,
3593,
1010,
9140,
1002,
9537,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
4003,
1035,
8909,
1005,
1027,
1028,
1002,
4003,
3593,
1010,
1005,
3642,
1005,
1027,
1028,
1002,
9537,
1010,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fullcalendar/fullcalendar | demos/php/utils.php | Event.toArray | public function toArray() {
// Start with the misc properties (don't worry, PHP won't affect the original array)
$array = $this->properties;
$array['title'] = $this->title;
// Figure out the date format. This essentially encodes allDay into the date string.
if ($this->allDay) {
$format = 'Y-m-d'; // output like "2013-12-29"
}
else {
$format = 'c'; // full ISO8601 output, like "2013-12-29T09:00:00+08:00"
}
// Serialize dates into strings
$array['start'] = $this->start->format($format);
if (isset($this->end)) {
$array['end'] = $this->end->format($format);
}
return $array;
} | php | public function toArray() {
// Start with the misc properties (don't worry, PHP won't affect the original array)
$array = $this->properties;
$array['title'] = $this->title;
// Figure out the date format. This essentially encodes allDay into the date string.
if ($this->allDay) {
$format = 'Y-m-d'; // output like "2013-12-29"
}
else {
$format = 'c'; // full ISO8601 output, like "2013-12-29T09:00:00+08:00"
}
// Serialize dates into strings
$array['start'] = $this->start->format($format);
if (isset($this->end)) {
$array['end'] = $this->end->format($format);
}
return $array;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"// Start with the misc properties (don't worry, PHP won't affect the original array)",
"$",
"array",
"=",
"$",
"this",
"->",
"properties",
";",
"$",
"array",
"[",
"'title'",
"]",
"=",
"$",
"this",
"->",
"title",
";",
... | Converts this Event object back to a plain data array, to be used for generating JSON | [
"Converts",
"this",
"Event",
"object",
"back",
"to",
"a",
"plain",
"data",
"array",
"to",
"be",
"used",
"for",
"generating",
"JSON"
] | f827f233581338ceb9723eabb7f895731498fd5b | https://github.com/fullcalendar/fullcalendar/blob/f827f233581338ceb9723eabb7f895731498fd5b/demos/php/utils.php#L79-L101 | train | Returns the array representation of the object | [
30522,
2270,
3853,
2000,
2906,
9447,
1006,
1007,
1063,
1013,
1013,
2707,
2007,
1996,
28616,
2278,
5144,
1006,
2123,
1005,
1056,
4737,
1010,
25718,
2180,
1005,
1056,
7461,
1996,
2434,
9140,
1007,
1002,
9140,
1027,
1002,
2023,
1011,
1028,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/CustomerService/Client.php | Client.invite | public function invite(string $account, string $wechatId)
{
$params = [
'kf_account' => $account,
'invite_wx' => $wechatId,
];
return $this->httpPostJson('customservice/kfaccount/inviteworker', $params);
} | php | public function invite(string $account, string $wechatId)
{
$params = [
'kf_account' => $account,
'invite_wx' => $wechatId,
];
return $this->httpPostJson('customservice/kfaccount/inviteworker', $params);
} | [
"public",
"function",
"invite",
"(",
"string",
"$",
"account",
",",
"string",
"$",
"wechatId",
")",
"{",
"$",
"params",
"=",
"[",
"'kf_account'",
"=>",
"$",
"account",
",",
"'invite_wx'",
"=>",
"$",
"wechatId",
",",
"]",
";",
"return",
"$",
"this",
"->... | Invite a staff.
@param string $account
@param string $wechatId
@return mixed | [
"Invite",
"a",
"staff",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/CustomerService/Client.php#L99-L107 | train | Invites a user to the specified account | [
30522,
2270,
3853,
13260,
1006,
5164,
1002,
4070,
1010,
5164,
1002,
2057,
7507,
3775,
2094,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
1047,
2546,
1035,
4070,
1005,
1027,
1028,
1002,
4070,
1010,
1005,
13260,
1035,
1059,
2595,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Scheduler/Scheduler.php | Scheduler.runTaskNow | public function runTaskNow($taskName)
{
$tasks = $this->loader->loadTasks();
foreach ($tasks as $task) {
if ($task->getName() === $taskName) {
return $this->executeTask($task);
}
}
throw new \InvalidArgumentException('Task ' . $taskName . ' not found');
} | php | public function runTaskNow($taskName)
{
$tasks = $this->loader->loadTasks();
foreach ($tasks as $task) {
if ($task->getName() === $taskName) {
return $this->executeTask($task);
}
}
throw new \InvalidArgumentException('Task ' . $taskName . ' not found');
} | [
"public",
"function",
"runTaskNow",
"(",
"$",
"taskName",
")",
"{",
"$",
"tasks",
"=",
"$",
"this",
"->",
"loader",
"->",
"loadTasks",
"(",
")",
";",
"foreach",
"(",
"$",
"tasks",
"as",
"$",
"task",
")",
"{",
"if",
"(",
"$",
"task",
"->",
"getName"... | Run a specific task now. Will ignore the schedule completely.
@param string $taskName
@return string Task output. | [
"Run",
"a",
"specific",
"task",
"now",
".",
"Will",
"ignore",
"the",
"schedule",
"completely",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Scheduler/Scheduler.php#L154-L165 | train | Runs the task now | [
30522,
2270,
3853,
2448,
10230,
2243,
19779,
1006,
1002,
4708,
18442,
1007,
1063,
1002,
8518,
1027,
1002,
2023,
1011,
1028,
7170,
2121,
1011,
1028,
7170,
10230,
5705,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
8518,
2004,
1002,
4708,
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/Filesystem.php | Filesystem.directoryDiff | public static function directoryDiff($source, $target)
{
$sourceFiles = self::globr($source, '*');
$targetFiles = self::globr($target, '*');
$sourceFiles = array_map(function ($file) use ($source) {
return str_replace($source, '', $file);
}, $sourceFiles);
$targetFiles = array_map(function ($file) use ($target) {
return str_replace($target, '', $file);
}, $targetFiles);
$diff = array_diff($targetFiles, $sourceFiles);
return array_values($diff);
} | php | public static function directoryDiff($source, $target)
{
$sourceFiles = self::globr($source, '*');
$targetFiles = self::globr($target, '*');
$sourceFiles = array_map(function ($file) use ($source) {
return str_replace($source, '', $file);
}, $sourceFiles);
$targetFiles = array_map(function ($file) use ($target) {
return str_replace($target, '', $file);
}, $targetFiles);
$diff = array_diff($targetFiles, $sourceFiles);
return array_values($diff);
} | [
"public",
"static",
"function",
"directoryDiff",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"$",
"sourceFiles",
"=",
"self",
"::",
"globr",
"(",
"$",
"source",
",",
"'*'",
")",
";",
"$",
"targetFiles",
"=",
"self",
"::",
"globr",
"(",
"$",
"ta... | Computes the difference of directories. Compares $target against $source and returns a relative path to all files
and directories in $target that are not present in $source.
@param $source
@param $target
@return string[] | [
"Computes",
"the",
"difference",
"of",
"directories",
".",
"Compares",
"$target",
"against",
"$source",
"and",
"returns",
"a",
"relative",
"path",
"to",
"all",
"files",
"and",
"directories",
"in",
"$target",
"that",
"are",
"not",
"present",
"in",
"$source",
".... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L285-L301 | train | Get the files in the directory that are not in the target directory | [
30522,
2270,
10763,
3853,
14176,
4305,
4246,
1006,
1002,
3120,
1010,
1002,
4539,
1007,
1063,
1002,
3120,
8873,
4244,
1027,
2969,
1024,
1024,
1043,
4135,
19892,
1006,
1002,
3120,
1010,
1005,
1008,
1005,
1007,
1025,
1002,
4539,
8873,
4244,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Generator/LanguageDataGenerator.php | LanguageDataGenerator.generateDataForMeta | protected function generateDataForMeta(BundleReaderInterface $reader, $tempDir)
{
$rootBundle = $reader->read($tempDir, 'root');
$metadataBundle = $reader->read($tempDir, 'metadata');
$this->languageCodes = array_unique($this->languageCodes);
sort($this->languageCodes);
return [
'Version' => $rootBundle['Version'],
'Languages' => $this->languageCodes,
'Aliases' => array_column(iterator_to_array($metadataBundle['alias']['language']), 'replacement'),
'Alpha2ToAlpha3' => $this->generateAlpha2ToAlpha3Mapping($metadataBundle),
];
} | php | protected function generateDataForMeta(BundleReaderInterface $reader, $tempDir)
{
$rootBundle = $reader->read($tempDir, 'root');
$metadataBundle = $reader->read($tempDir, 'metadata');
$this->languageCodes = array_unique($this->languageCodes);
sort($this->languageCodes);
return [
'Version' => $rootBundle['Version'],
'Languages' => $this->languageCodes,
'Aliases' => array_column(iterator_to_array($metadataBundle['alias']['language']), 'replacement'),
'Alpha2ToAlpha3' => $this->generateAlpha2ToAlpha3Mapping($metadataBundle),
];
} | [
"protected",
"function",
"generateDataForMeta",
"(",
"BundleReaderInterface",
"$",
"reader",
",",
"$",
"tempDir",
")",
"{",
"$",
"rootBundle",
"=",
"$",
"reader",
"->",
"read",
"(",
"$",
"tempDir",
",",
"'root'",
")",
";",
"$",
"metadataBundle",
"=",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Data/Generator/LanguageDataGenerator.php#L155-L170 | train | Generate data for meta | [
30522,
5123,
3853,
7013,
6790,
14192,
12928,
1006,
14012,
16416,
4063,
18447,
2121,
12172,
1002,
8068,
1010,
1002,
8915,
8737,
4305,
2099,
1007,
1063,
1002,
7117,
27265,
2571,
1027,
1002,
8068,
1011,
1028,
3191,
1006,
1002,
8915,
8737,
4305... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Work/User/TagClient.php | TagClient.update | public function update(int $tagId, string $tagName)
{
$params = [
'tagid' => $tagId,
'tagname' => $tagName,
];
return $this->httpPostJson('cgi-bin/tag/update', $params);
} | php | public function update(int $tagId, string $tagName)
{
$params = [
'tagid' => $tagId,
'tagname' => $tagName,
];
return $this->httpPostJson('cgi-bin/tag/update', $params);
} | [
"public",
"function",
"update",
"(",
"int",
"$",
"tagId",
",",
"string",
"$",
"tagName",
")",
"{",
"$",
"params",
"=",
"[",
"'tagid'",
"=>",
"$",
"tagId",
",",
"'tagname'",
"=>",
"$",
"tagName",
",",
"]",
";",
"return",
"$",
"this",
"->",
"httpPostJs... | Update tag.
@param int $tagId
@param string $tagName
@return mixed | [
"Update",
"tag",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Work/User/TagClient.php#L49-L57 | train | Update the tag | [
30522,
2270,
3853,
10651,
1006,
20014,
1002,
6415,
3593,
1010,
5164,
1002,
6415,
18442,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
6415,
3593,
1005,
1027,
1028,
1002,
6415,
3593,
1010,
1005,
6415,
18442,
1005,
1027,
1028,
1002,
6415,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/GeoIp2/LocationProvider/GeoIp2/ServerModule.php | ServerModule.isAvailable | public function isAvailable()
{
if (function_exists('apache_get_modules')) {
foreach (apache_get_modules() as $name) {
if (strpos($name, 'maxminddb') !== false) {
return true;
}
}
}
$settings = self::getGeoIpServerVars();
$available = array_key_exists($settings[self::CONTINENT_CODE_KEY], $_SERVER)
|| array_key_exists($settings[self::COUNTRY_CODE_KEY], $_SERVER)
|| array_key_exists($settings[self::REGION_CODE_KEY], $_SERVER)
|| array_key_exists($settings[self::CITY_NAME_KEY], $_SERVER);
if ($available) {
return true;
}
// if not available return message w/ extra info
if (!function_exists('apache_get_modules')) {
return Piwik::translate('General_Note') . ': ' . Piwik::translate('UserCountry_AssumingNonApache');
}
$message = "<strong>" . Piwik::translate('General_Note') . ': '
. Piwik::translate('UserCountry_FoundApacheModules')
. "</strong>:<br/><br/>\n<ul style=\"list-style:disc;margin-left:24px\">\n";
foreach (apache_get_modules() as $name) {
$message .= "<li>$name</li>\n";
}
$message .= "</ul>";
return $message;
} | php | public function isAvailable()
{
if (function_exists('apache_get_modules')) {
foreach (apache_get_modules() as $name) {
if (strpos($name, 'maxminddb') !== false) {
return true;
}
}
}
$settings = self::getGeoIpServerVars();
$available = array_key_exists($settings[self::CONTINENT_CODE_KEY], $_SERVER)
|| array_key_exists($settings[self::COUNTRY_CODE_KEY], $_SERVER)
|| array_key_exists($settings[self::REGION_CODE_KEY], $_SERVER)
|| array_key_exists($settings[self::CITY_NAME_KEY], $_SERVER);
if ($available) {
return true;
}
// if not available return message w/ extra info
if (!function_exists('apache_get_modules')) {
return Piwik::translate('General_Note') . ': ' . Piwik::translate('UserCountry_AssumingNonApache');
}
$message = "<strong>" . Piwik::translate('General_Note') . ': '
. Piwik::translate('UserCountry_FoundApacheModules')
. "</strong>:<br/><br/>\n<ul style=\"list-style:disc;margin-left:24px\">\n";
foreach (apache_get_modules() as $name) {
$message .= "<li>$name</li>\n";
}
$message .= "</ul>";
return $message;
} | [
"public",
"function",
"isAvailable",
"(",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'apache_get_modules'",
")",
")",
"{",
"foreach",
"(",
"apache_get_modules",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'maxmi... | Checks if an mod_maxminddb has been installed and MMDB_ADDR server variable is defined.
There's a special check for the Apache module, but we can't check specifically
for anything else.
@return bool|string | [
"Checks",
"if",
"an",
"mod_maxminddb",
"has",
"been",
"installed",
"and",
"MMDB_ADDR",
"server",
"variable",
"is",
"defined",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/LocationProvider/GeoIp2/ServerModule.php#L139-L173 | train | Check if the module is available | [
30522,
2270,
3853,
18061,
3567,
11733,
3468,
1006,
1007,
1063,
2065,
1006,
3853,
1035,
6526,
1006,
1005,
15895,
1035,
2131,
1035,
14184,
1005,
1007,
1007,
1063,
18921,
6776,
1006,
15895,
1035,
2131,
1035,
14184,
1006,
1007,
2004,
1002,
2171... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.withoutSelectAliases | protected function withoutSelectAliases(array $columns)
{
return array_map(function ($column) {
return is_string($column) && ($aliasPosition = stripos($column, ' as ')) !== false
? substr($column, 0, $aliasPosition) : $column;
}, $columns);
} | php | protected function withoutSelectAliases(array $columns)
{
return array_map(function ($column) {
return is_string($column) && ($aliasPosition = stripos($column, ' as ')) !== false
? substr($column, 0, $aliasPosition) : $column;
}, $columns);
} | [
"protected",
"function",
"withoutSelectAliases",
"(",
"array",
"$",
"columns",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"$",
"column",
")",
"{",
"return",
"is_string",
"(",
"$",
"column",
")",
"&&",
"(",
"$",
"aliasPosition",
"=",
"stripos",
... | Remove the column aliases since they will break count queries.
@param array $columns
@return array | [
"Remove",
"the",
"column",
"aliases",
"since",
"they",
"will",
"break",
"count",
"queries",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L2220-L2226 | train | Returns the columns without select aliases | [
30522,
5123,
3853,
2302,
11246,
22471,
22786,
8583,
1006,
9140,
1002,
7753,
1007,
1063,
2709,
9140,
1035,
4949,
1006,
3853,
1006,
1002,
5930,
1007,
1063,
2709,
2003,
1035,
5164,
1006,
1002,
5930,
1007,
1004,
1004,
1006,
1002,
14593,
26994,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/html5lib/InputStream.php | HTML5_InputStream.charsUntil | public function charsUntil($bytes, $max = null) {
if ($this->char < $this->EOF) {
if ($max === 0 || $max) {
$len = strcspn($this->data, $bytes, $this->char, $max);
} else {
$len = strcspn($this->data, $bytes, $this->char);
}
$string = (string) substr($this->data, $this->char, $len);
$this->char += $len;
return $string;
} else {
return false;
}
} | php | public function charsUntil($bytes, $max = null) {
if ($this->char < $this->EOF) {
if ($max === 0 || $max) {
$len = strcspn($this->data, $bytes, $this->char, $max);
} else {
$len = strcspn($this->data, $bytes, $this->char);
}
$string = (string) substr($this->data, $this->char, $len);
$this->char += $len;
return $string;
} else {
return false;
}
} | [
"public",
"function",
"charsUntil",
"(",
"$",
"bytes",
",",
"$",
"max",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"char",
"<",
"$",
"this",
"->",
"EOF",
")",
"{",
"if",
"(",
"$",
"max",
"===",
"0",
"||",
"$",
"max",
")",
"{",
"$",
... | Matches as far as possible until we reach a certain set of bytes
and returns the matched substring.
@param $bytes | Bytes to match.
@param null $max
@return bool|string | [
"Matches",
"as",
"far",
"as",
"possible",
"until",
"we",
"reach",
"a",
"certain",
"set",
"of",
"bytes",
"and",
"returns",
"the",
"matched",
"substring",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/InputStream.php#L253-L266 | train | Matches until the next character is at the given byte position. | [
30522,
2270,
3853,
25869,
19729,
3775,
2140,
1006,
1002,
27507,
1010,
1002,
4098,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
25869,
1026,
1002,
2023,
1011,
1028,
1041,
11253,
1007,
1063,
2065,
1006,
1002,
4098,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/GeoIPAutoUpdater.php | GeoIPAutoUpdater.setUpdaterOptions | public static function setUpdaterOptions($options)
{
// set url options
foreach (self::$urlOptions as $optionKey => $optionName) {
if (!isset($options[$optionKey])) {
continue;
}
$url = $options[$optionKey];
$url = self::removeDateFromUrl($url);
Option::set($optionName, $url);
}
// set period option
if (!empty($options['period'])) {
$period = $options['period'];
if ($period != self::SCHEDULE_PERIOD_MONTHLY
&& $period != self::SCHEDULE_PERIOD_WEEKLY
) {
throw new Exception(Piwik::translate(
'UserCountry_InvalidGeoIPUpdatePeriod',
array("'$period'", "'" . self::SCHEDULE_PERIOD_MONTHLY . "', '" . self::SCHEDULE_PERIOD_WEEKLY . "'")
));
}
Option::set(self::SCHEDULE_PERIOD_OPTION_NAME, $period);
/** @var Scheduler $scheduler */
$scheduler = StaticContainer::getContainer()->get('Piwik\Scheduler\Scheduler');
$scheduler->rescheduleTaskAndRunTomorrow(new GeoIPAutoUpdater());
}
} | php | public static function setUpdaterOptions($options)
{
// set url options
foreach (self::$urlOptions as $optionKey => $optionName) {
if (!isset($options[$optionKey])) {
continue;
}
$url = $options[$optionKey];
$url = self::removeDateFromUrl($url);
Option::set($optionName, $url);
}
// set period option
if (!empty($options['period'])) {
$period = $options['period'];
if ($period != self::SCHEDULE_PERIOD_MONTHLY
&& $period != self::SCHEDULE_PERIOD_WEEKLY
) {
throw new Exception(Piwik::translate(
'UserCountry_InvalidGeoIPUpdatePeriod',
array("'$period'", "'" . self::SCHEDULE_PERIOD_MONTHLY . "', '" . self::SCHEDULE_PERIOD_WEEKLY . "'")
));
}
Option::set(self::SCHEDULE_PERIOD_OPTION_NAME, $period);
/** @var Scheduler $scheduler */
$scheduler = StaticContainer::getContainer()->get('Piwik\Scheduler\Scheduler');
$scheduler->rescheduleTaskAndRunTomorrow(new GeoIPAutoUpdater());
}
} | [
"public",
"static",
"function",
"setUpdaterOptions",
"(",
"$",
"options",
")",
"{",
"// set url options",
"foreach",
"(",
"self",
"::",
"$",
"urlOptions",
"as",
"$",
"optionKey",
"=>",
"$",
"optionName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"option... | Sets the options used by this class based on the elements in $options.
The following elements of $options are used:
'loc' - URL for location database.
'isp' - URL for ISP database.
'org' - URL for Organization database.
'period' - 'weekly' or 'monthly'. When to run the updates.
@param array $options
@throws Exception | [
"Sets",
"the",
"options",
"used",
"by",
"this",
"class",
"based",
"on",
"the",
"elements",
"in",
"$options",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/GeoIPAutoUpdater.php#L340-L374 | train | Set update options | [
30522,
2270,
10763,
3853,
16437,
13701,
18981,
9285,
1006,
1002,
7047,
1007,
1063,
1013,
1013,
2275,
24471,
2140,
7047,
18921,
6776,
1006,
2969,
1024,
1024,
1002,
24471,
4135,
16790,
2015,
2004,
1002,
5724,
14839,
1027,
1028,
1002,
5724,
18... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/console/OctoberUpdate.php | OctoberUpdate.handle | public function handle()
{
$this->output->writeln('<info>Updating October...</info>');
$manager = UpdateManager::instance()->setNotesOutput($this->output);
$forceUpdate = $this->option('force');
/*
* Check for disabilities
*/
$disableCore = $disablePlugins = $disableThemes = false;
if ($this->option('plugins')) {
$disableCore = true;
$disableThemes = true;
}
if ($this->option('core')) {
$disablePlugins = true;
$disableThemes = true;
}
/*
* Perform update
*/
$updateList = $manager->requestUpdateList($forceUpdate);
$updates = (int) array_get($updateList, 'update', 0);
if ($updates == 0) {
$this->output->writeln('<info>No new updates found</info>');
return;
}
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
$coreHash = $disableCore ? null : array_get($updateList, 'core.hash');
$coreBuild = array_get($updateList, 'core.build');
if ($coreHash) {
$this->output->writeln('<info>Downloading application files</info>');
$manager->downloadCore($coreHash);
}
$plugins = $disablePlugins ? [] : array_get($updateList, 'plugins');
foreach ($plugins as $code => $plugin) {
$pluginName = array_get($plugin, 'name');
$pluginHash = array_get($plugin, 'hash');
$this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $pluginName));
$manager->downloadPlugin($code, $pluginHash);
}
if ($coreHash) {
$this->output->writeln('<info>Unpacking application files</info>');
$manager->extractCore();
$manager->setBuild($coreBuild, $coreHash);
}
foreach ($plugins as $code => $plugin) {
$pluginName = array_get($plugin, 'name');
$pluginHash = array_get($plugin, 'hash');
$this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $pluginName));
$manager->extractPlugin($code, $pluginHash);
}
/*
* Run migrations
*/
$this->call('october:up');
} | php | public function handle()
{
$this->output->writeln('<info>Updating October...</info>');
$manager = UpdateManager::instance()->setNotesOutput($this->output);
$forceUpdate = $this->option('force');
/*
* Check for disabilities
*/
$disableCore = $disablePlugins = $disableThemes = false;
if ($this->option('plugins')) {
$disableCore = true;
$disableThemes = true;
}
if ($this->option('core')) {
$disablePlugins = true;
$disableThemes = true;
}
/*
* Perform update
*/
$updateList = $manager->requestUpdateList($forceUpdate);
$updates = (int) array_get($updateList, 'update', 0);
if ($updates == 0) {
$this->output->writeln('<info>No new updates found</info>');
return;
}
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
$coreHash = $disableCore ? null : array_get($updateList, 'core.hash');
$coreBuild = array_get($updateList, 'core.build');
if ($coreHash) {
$this->output->writeln('<info>Downloading application files</info>');
$manager->downloadCore($coreHash);
}
$plugins = $disablePlugins ? [] : array_get($updateList, 'plugins');
foreach ($plugins as $code => $plugin) {
$pluginName = array_get($plugin, 'name');
$pluginHash = array_get($plugin, 'hash');
$this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $pluginName));
$manager->downloadPlugin($code, $pluginHash);
}
if ($coreHash) {
$this->output->writeln('<info>Unpacking application files</info>');
$manager->extractCore();
$manager->setBuild($coreBuild, $coreHash);
}
foreach ($plugins as $code => $plugin) {
$pluginName = array_get($plugin, 'name');
$pluginHash = array_get($plugin, 'hash');
$this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $pluginName));
$manager->extractPlugin($code, $pluginHash);
}
/*
* Run migrations
*/
$this->call('october:up');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'<info>Updating October...</info>'",
")",
";",
"$",
"manager",
"=",
"UpdateManager",
"::",
"instance",
"(",
")",
"->",
"setNotesOutput",
"(",
"$",
"this",
"->"... | Execute the console command. | [
"Execute",
"the",
"console",
"command",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/console/OctoberUpdate.php#L34-L103 | train | Handle the update | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
6434,
1011,
1028,
4339,
19666,
1006,
1005,
1026,
18558,
1028,
2039,
16616,
2255,
1012,
1012,
1012,
1026,
1013,
18558,
1028,
1005,
1007,
1025,
1002,
3208,
1027,
10651,
24805,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MessageCatalogue.php | MessageCatalogue.getMetadata | public function getMetadata($key = '', $domain = 'messages')
{
if ('' == $domain) {
return $this->metadata;
}
if (isset($this->metadata[$domain])) {
if ('' == $key) {
return $this->metadata[$domain];
}
if (isset($this->metadata[$domain][$key])) {
return $this->metadata[$domain][$key];
}
}
} | php | public function getMetadata($key = '', $domain = 'messages')
{
if ('' == $domain) {
return $this->metadata;
}
if (isset($this->metadata[$domain])) {
if ('' == $key) {
return $this->metadata[$domain];
}
if (isset($this->metadata[$domain][$key])) {
return $this->metadata[$domain][$key];
}
}
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"key",
"=",
"''",
",",
"$",
"domain",
"=",
"'messages'",
")",
"{",
"if",
"(",
"''",
"==",
"$",
"domain",
")",
"{",
"return",
"$",
"this",
"->",
"metadata",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"th... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/MessageCatalogue.php#L249-L264 | train | Return the metadata of the message | [
30522,
2270,
3853,
2131,
11368,
8447,
2696,
1006,
1002,
3145,
1027,
1005,
1005,
1010,
1002,
5884,
1027,
1005,
7696,
1005,
1007,
1063,
2065,
1006,
1005,
1005,
1027,
1027,
1002,
5884,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
27425,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Templating/Helper/SlotsHelper.php | SlotsHelper.stop | public function stop()
{
if (!$this->openSlots) {
throw new \LogicException('No slot started.');
}
$name = array_pop($this->openSlots);
$this->slots[$name] = ob_get_clean();
} | php | public function stop()
{
if (!$this->openSlots) {
throw new \LogicException('No slot started.');
}
$name = array_pop($this->openSlots);
$this->slots[$name] = ob_get_clean();
} | [
"public",
"function",
"stop",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"openSlots",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'No slot started.'",
")",
";",
"}",
"$",
"name",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"openSlots",... | Stops a slot.
@throws \LogicException if no slot has been started | [
"Stops",
"a",
"slot",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Templating/Helper/SlotsHelper.php#L52-L61 | train | Stop the current slot | [
30522,
2270,
3853,
2644,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
7480,
10994,
2015,
1007,
1063,
5466,
2047,
1032,
7961,
10288,
24422,
1006,
1005,
2053,
10453,
2318,
1012,
1005,
1007,
1025,
1065,
1002,
2171,
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... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.validateTree | public function validateTree()
{
if (!$this->showTree) {
return;
}
$this->showSorting = $this->showPagination = false;
if (!$this->model->methodExists('getChildren')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildren"'
);
}
if (!$this->model->methodExists('getChildCount')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildCount"'
);
}
} | php | public function validateTree()
{
if (!$this->showTree) {
return;
}
$this->showSorting = $this->showPagination = false;
if (!$this->model->methodExists('getChildren')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildren"'
);
}
if (!$this->model->methodExists('getChildCount')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildCount"'
);
}
} | [
"public",
"function",
"validateTree",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"showTree",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"showSorting",
"=",
"$",
"this",
"->",
"showPagination",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"t... | Validates the model and settings if showTree is used
@return void | [
"Validates",
"the",
"model",
"and",
"settings",
"if",
"showTree",
"is",
"used"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1636-L1655 | train | Validate tree. | [
30522,
2270,
3853,
9398,
3686,
13334,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2265,
13334,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
3065,
11589,
2075,
1027,
1002,
2023,
1011,
1028,
2265,
4502,
20876,
3508,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.isSendmail | public function isSendmail()
{
$ini_sendmail_path = ini_get('sendmail_path');
if (false === stripos($ini_sendmail_path, 'sendmail')) {
$this->Sendmail = '/usr/sbin/sendmail';
} else {
$this->Sendmail = $ini_sendmail_path;
}
$this->Mailer = 'sendmail';
} | php | public function isSendmail()
{
$ini_sendmail_path = ini_get('sendmail_path');
if (false === stripos($ini_sendmail_path, 'sendmail')) {
$this->Sendmail = '/usr/sbin/sendmail';
} else {
$this->Sendmail = $ini_sendmail_path;
}
$this->Mailer = 'sendmail';
} | [
"public",
"function",
"isSendmail",
"(",
")",
"{",
"$",
"ini_sendmail_path",
"=",
"ini_get",
"(",
"'sendmail_path'",
")",
";",
"if",
"(",
"false",
"===",
"stripos",
"(",
"$",
"ini_sendmail_path",
",",
"'sendmail'",
")",
")",
"{",
"$",
"this",
"->",
"Sendma... | Send messages using $Sendmail. | [
"Send",
"messages",
"using",
"$Sendmail",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L910-L920 | train | Check if sendmail is set in the current context | [
30522,
2270,
3853,
26354,
10497,
21397,
1006,
1007,
1063,
1002,
1999,
2072,
1035,
4604,
21397,
1035,
4130,
1027,
1999,
2072,
1035,
2131,
1006,
1005,
4604,
21397,
1035,
4130,
1005,
1007,
1025,
2065,
1006,
6270,
1027,
1027,
1027,
6167,
2891,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/GPM.php | GPM.getPackageType | public static function getPackageType($source)
{
$plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m';
$theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m';
if (
file_exists($source . 'system/defines.php') &&
file_exists($source . 'system/config/system.yaml')
) {
return 'grav';
}
// must have a blueprint
if (!file_exists($source . 'blueprints.yaml')) {
return false;
}
// either theme or plugin
$name = basename($source);
if (Utils::contains($name, 'theme')) {
return 'theme';
}
if (Utils::contains($name, 'plugin')) {
return 'plugin';
}
foreach (glob($source . '*.php') as $filename) {
$contents = file_get_contents($filename);
if (preg_match($theme_regex, $contents)) {
return 'theme';
}
if (preg_match($plugin_regex, $contents)) {
return 'plugin';
}
}
// Assume it's a theme
return 'theme';
} | php | public static function getPackageType($source)
{
$plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m';
$theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m';
if (
file_exists($source . 'system/defines.php') &&
file_exists($source . 'system/config/system.yaml')
) {
return 'grav';
}
// must have a blueprint
if (!file_exists($source . 'blueprints.yaml')) {
return false;
}
// either theme or plugin
$name = basename($source);
if (Utils::contains($name, 'theme')) {
return 'theme';
}
if (Utils::contains($name, 'plugin')) {
return 'plugin';
}
foreach (glob($source . '*.php') as $filename) {
$contents = file_get_contents($filename);
if (preg_match($theme_regex, $contents)) {
return 'theme';
}
if (preg_match($plugin_regex, $contents)) {
return 'plugin';
}
}
// Assume it's a theme
return 'theme';
} | [
"public",
"static",
"function",
"getPackageType",
"(",
"$",
"source",
")",
"{",
"$",
"plugin_regex",
"=",
"'/^class\\\\s{1,}[a-zA-Z0-9]{1,}\\\\s{1,}extends.+Plugin/m'",
";",
"$",
"theme_regex",
"=",
"'/^class\\\\s{1,}[a-zA-Z0-9]{1,}\\\\s{1,}extends.+Theme/m'",
";",
"if",
"(",... | Try to guess the package type from the source files
@param string $source
@return bool|string | [
"Try",
"to",
"guess",
"the",
"package",
"type",
"from",
"the",
"source",
"files"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/GPM.php#L559-L596 | train | Get the package type | [
30522,
2270,
10763,
3853,
2131,
23947,
4270,
13874,
1006,
1002,
3120,
1007,
1063,
1002,
13354,
2378,
1035,
19723,
10288,
1027,
1005,
1013,
1034,
2465,
1032,
1032,
1055,
1063,
1015,
1010,
1065,
1031,
1037,
1011,
23564,
1011,
1062,
2692,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.