repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
symfony/symfony | src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php | Connection.createDelayQueue | private function createDelayQueue(int $delay, ?string $routingKey)
{
$queue = $this->amqpFactory->createQueue($this->channel());
$queue->setName(str_replace('%delay%', $delay, $this->connectionOptions['delay']['queue_name_pattern']));
$queue->setArguments([
'x-message-ttl' => $delay,
'x-dead-letter-exchange' => $this->exchange()->getName(),
]);
$routingKey = $routingKey ?? $this->getDefaultPublishRoutingKey();
if (null !== $routingKey) {
// after being released from to DLX, this routing key will be used
$queue->setArgument('x-dead-letter-routing-key', $routingKey);
}
return $queue;
} | php | private function createDelayQueue(int $delay, ?string $routingKey)
{
$queue = $this->amqpFactory->createQueue($this->channel());
$queue->setName(str_replace('%delay%', $delay, $this->connectionOptions['delay']['queue_name_pattern']));
$queue->setArguments([
'x-message-ttl' => $delay,
'x-dead-letter-exchange' => $this->exchange()->getName(),
]);
$routingKey = $routingKey ?? $this->getDefaultPublishRoutingKey();
if (null !== $routingKey) {
// after being released from to DLX, this routing key will be used
$queue->setArgument('x-dead-letter-routing-key', $routingKey);
}
return $queue;
} | [
"private",
"function",
"createDelayQueue",
"(",
"int",
"$",
"delay",
",",
"?",
"string",
"$",
"routingKey",
")",
"{",
"$",
"queue",
"=",
"$",
"this",
"->",
"amqpFactory",
"->",
"createQueue",
"(",
"$",
"this",
"->",
"channel",
"(",
")",
")",
";",
"$",
... | Creates a delay queue that will delay for a certain amount of time.
This works by setting message TTL for the delay and pointing
the dead letter exchange to the original exchange. The result
is that after the TTL, the message is sent to the dead-letter-exchange,
which is the original exchange, resulting on it being put back into
the original queue. | [
"Creates",
"a",
"delay",
"queue",
"that",
"will",
"delay",
"for",
"a",
"certain",
"amount",
"of",
"time",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php#L271-L287 | train | Create delay queue | [
30522,
2797,
3853,
2580,
10581,
2100,
4226,
5657,
1006,
20014,
1002,
8536,
1010,
1029,
5164,
1002,
16972,
14839,
1007,
1063,
1002,
24240,
1027,
1002,
2023,
1011,
1028,
2572,
4160,
14376,
18908,
10253,
1011,
1028,
3443,
4226,
5657,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter/Group.php | Group.like | public function like($label = '', $operator = 'like')
{
$label = $label ?: $operator;
$condition = [$this->column, $operator, "%{$this->value}%"];
return $this->joinGroup($label, $condition);
} | php | public function like($label = '', $operator = 'like')
{
$label = $label ?: $operator;
$condition = [$this->column, $operator, "%{$this->value}%"];
return $this->joinGroup($label, $condition);
} | [
"public",
"function",
"like",
"(",
"$",
"label",
"=",
"''",
",",
"$",
"operator",
"=",
"'like'",
")",
"{",
"$",
"label",
"=",
"$",
"label",
"?",
":",
"$",
"operator",
";",
"$",
"condition",
"=",
"[",
"$",
"this",
"->",
"column",
",",
"$",
"operat... | Specify a where like query.
@param string $label
@param string $operator
@return Group | [
"Specify",
"a",
"where",
"like",
"query",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/Group.php#L195-L202 | train | Returns a query part that requires a LIKE operator. | [
30522,
2270,
3853,
2066,
1006,
1002,
3830,
1027,
1005,
1005,
1010,
1002,
6872,
1027,
1005,
2066,
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... |
php-ai/php-ml | src/Association/Apriori.php | Apriori.getRules | public function getRules(): array
{
if (count($this->large) === 0) {
$this->large = $this->apriori();
}
if (count($this->rules) > 0) {
return $this->rules;
}
$this->rules = [];
$this->generateAllRules();
return $this->rules;
} | php | public function getRules(): array
{
if (count($this->large) === 0) {
$this->large = $this->apriori();
}
if (count($this->rules) > 0) {
return $this->rules;
}
$this->rules = [];
$this->generateAllRules();
return $this->rules;
} | [
"public",
"function",
"getRules",
"(",
")",
":",
"array",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"large",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"large",
"=",
"$",
"this",
"->",
"apriori",
"(",
")",
";",
"}",
"if",
"(",
"count"... | Get all association rules which are generated for every k-length frequent item set.
@return mixed[][] | [
"Get",
"all",
"association",
"rules",
"which",
"are",
"generated",
"for",
"every",
"k",
"-",
"length",
"frequent",
"item",
"set",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Association/Apriori.php#L65-L80 | train | Get rules from all languages | [
30522,
2270,
3853,
2131,
6820,
4244,
1006,
1007,
1024,
9140,
1063,
2065,
1006,
4175,
1006,
1002,
2023,
1011,
1028,
2312,
1007,
1027,
1027,
1027,
1014,
1007,
1063,
1002,
2023,
1011,
1028,
2312,
1027,
1002,
2023,
1011,
1028,
19804,
25346,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Table/Abstract.php | Zend_Db_Table_Abstract.update | public function update(array $data, $where)
{
$tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
return $this->_db->update($tableSpec, $data, $where);
} | php | public function update(array $data, $where)
{
$tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
return $this->_db->update($tableSpec, $data, $where);
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"data",
",",
"$",
"where",
")",
"{",
"$",
"tableSpec",
"=",
"(",
"$",
"this",
"->",
"_schema",
"?",
"$",
"this",
"->",
"_schema",
".",
"'.'",
":",
"''",
")",
".",
"$",
"this",
"->",
"_name",
";",... | Updates existing rows.
@param array $data Column-value pairs.
@param array|string $where An SQL WHERE clause, or an array of SQL WHERE clauses.
@return int The number of rows updated. | [
"Updates",
"existing",
"rows",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Abstract.php#L1129-L1133 | train | Update the record in the database | [
30522,
2270,
3853,
10651,
1006,
9140,
1002,
2951,
1010,
1002,
2073,
1007,
1063,
1002,
7251,
5051,
2278,
1027,
1006,
1002,
2023,
1011,
1028,
1035,
8040,
28433,
1029,
1002,
2023,
1011,
1028,
1035,
8040,
28433,
1012,
1005,
1012,
1005,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php | HasRelationships.newMorphTo | protected function newMorphTo(Builder $query, Model $parent, $foreignKey, $ownerKey, $type, $relation)
{
return new MorphTo($query, $parent, $foreignKey, $ownerKey, $type, $relation);
} | php | protected function newMorphTo(Builder $query, Model $parent, $foreignKey, $ownerKey, $type, $relation)
{
return new MorphTo($query, $parent, $foreignKey, $ownerKey, $type, $relation);
} | [
"protected",
"function",
"newMorphTo",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"parent",
",",
"$",
"foreignKey",
",",
"$",
"ownerKey",
",",
"$",
"type",
",",
"$",
"relation",
")",
"{",
"return",
"new",
"MorphTo",
"(",
"$",
"query",
",",
"$",
... | Instantiate a new MorphTo relationship.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $parent
@param string $foreignKey
@param string $ownerKey
@param string $type
@param string $relation
@return \Illuminate\Database\Eloquent\Relations\MorphTo | [
"Instantiate",
"a",
"new",
"MorphTo",
"relationship",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php#L289-L292 | train | Create a new MorphTo | [
30522,
5123,
3853,
2047,
5302,
14536,
11039,
2080,
1006,
12508,
1002,
23032,
1010,
2944,
1002,
6687,
1010,
1002,
3097,
14839,
1010,
1002,
3954,
14839,
1010,
1002,
2828,
1010,
1002,
7189,
1007,
1063,
2709,
2047,
22822,
8458,
3406,
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... |
laravel/framework | src/Illuminate/Foundation/Console/ClearCompiledCommand.php | ClearCompiledCommand.handle | public function handle()
{
if (file_exists($servicesPath = $this->laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}
if (file_exists($packagesPath = $this->laravel->getCachedPackagesPath())) {
@unlink($packagesPath);
}
$this->info('Compiled services and packages files removed!');
} | php | public function handle()
{
if (file_exists($servicesPath = $this->laravel->getCachedServicesPath())) {
@unlink($servicesPath);
}
if (file_exists($packagesPath = $this->laravel->getCachedPackagesPath())) {
@unlink($packagesPath);
}
$this->info('Compiled services and packages files removed!');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"servicesPath",
"=",
"$",
"this",
"->",
"laravel",
"->",
"getCachedServicesPath",
"(",
")",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"servicesPath",
")",
";",
"}",
"if",
... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/ClearCompiledCommand.php#L28-L39 | train | Remove compiled services and packages files | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
2065,
1006,
5371,
1035,
6526,
1006,
1002,
2578,
15069,
1027,
1002,
2023,
1011,
1028,
13679,
15985,
1011,
1028,
2131,
3540,
7690,
8043,
7903,
2229,
15069,
1006,
1007,
1007,
1007,
1063,
1030,
4895,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Console/TableCommand.php | TableCommand.replaceMigration | protected function replaceMigration($path, $table, $tableClassName)
{
$stub = str_replace(
['{{table}}', '{{tableClassName}}'],
[$table, $tableClassName],
$this->files->get(__DIR__.'/stubs/jobs.stub')
);
$this->files->put($path, $stub);
} | php | protected function replaceMigration($path, $table, $tableClassName)
{
$stub = str_replace(
['{{table}}', '{{tableClassName}}'],
[$table, $tableClassName],
$this->files->get(__DIR__.'/stubs/jobs.stub')
);
$this->files->put($path, $stub);
} | [
"protected",
"function",
"replaceMigration",
"(",
"$",
"path",
",",
"$",
"table",
",",
"$",
"tableClassName",
")",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"[",
"'{{table}}'",
",",
"'{{tableClassName}}'",
"]",
",",
"[",
"$",
"table",
",",
"$",
"tableClas... | Replace the generated migration with the job table stub.
@param string $path
@param string $table
@param string $tableClassName
@return void | [
"Replace",
"the",
"generated",
"migration",
"with",
"the",
"job",
"table",
"stub",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Console/TableCommand.php#L92-L101 | train | Replace the migration stub with the actual table and class name | [
30522,
5123,
3853,
5672,
4328,
29397,
1006,
1002,
4130,
1010,
1002,
2795,
1010,
1002,
2795,
26266,
18442,
1007,
1063,
1002,
24646,
2497,
1027,
2358,
2099,
1035,
5672,
1006,
1031,
1005,
1063,
1063,
2795,
1065,
1065,
1005,
1010,
1005,
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... |
matomo-org/matomo | core/DataTable/Manager.php | Manager.deleteAll | public function deleteAll($deleteWhenIdTableGreaterThan = 0)
{
foreach ($this as $id => $table) {
if ($id > $deleteWhenIdTableGreaterThan) {
$this->deleteTable($id);
}
}
if ($deleteWhenIdTableGreaterThan == 0) {
$this->exchangeArray(array());
$this->nextTableId = 0;
}
} | php | public function deleteAll($deleteWhenIdTableGreaterThan = 0)
{
foreach ($this as $id => $table) {
if ($id > $deleteWhenIdTableGreaterThan) {
$this->deleteTable($id);
}
}
if ($deleteWhenIdTableGreaterThan == 0) {
$this->exchangeArray(array());
$this->nextTableId = 0;
}
} | [
"public",
"function",
"deleteAll",
"(",
"$",
"deleteWhenIdTableGreaterThan",
"=",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"id",
"=>",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"id",
">",
"$",
"deleteWhenIdTableGreaterThan",
")",
"{",
"$",
... | Delete all the registered DataTables from the manager | [
"Delete",
"all",
"the",
"registered",
"DataTables",
"from",
"the",
"manager"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Manager.php#L84-L96 | train | Delete all tables from the database | [
30522,
2270,
3853,
3972,
12870,
8095,
1006,
1002,
3972,
12870,
2860,
10222,
3593,
10880,
17603,
24932,
21604,
1027,
1014,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
2004,
1002,
8909,
1027,
1028,
1002,
2795,
1007,
1063,
2065,
1006,
1002,
890... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Session/SaveHandler/DbTable.php | DbTable.destroy | public function destroy($id)
{
$sql = 'DELETE FROM ' . $this->config['name'] . ' WHERE ' . $this->config['primary'] . ' = ?';
$this->query($sql, array($id));
return true;
} | php | public function destroy($id)
{
$sql = 'DELETE FROM ' . $this->config['name'] . ' WHERE ' . $this->config['primary'] . ' = ?';
$this->query($sql, array($id));
return true;
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"sql",
"=",
"'DELETE FROM '",
".",
"$",
"this",
"->",
"config",
"[",
"'name'",
"]",
".",
"' WHERE '",
".",
"$",
"this",
"->",
"config",
"[",
"'primary'",
"]",
".",
"' = ?'",
";",
"$",
... | Destroy Session - remove data from resource for
given session id
@param string $id
@return boolean | [
"Destroy",
"Session",
"-",
"remove",
"data",
"from",
"resource",
"for",
"given",
"session",
"id"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Session/SaveHandler/DbTable.php#L157-L164 | train | Destroy a record | [
30522,
2270,
3853,
6033,
1006,
1002,
8909,
1007,
1063,
1002,
29296,
1027,
1005,
3972,
12870,
2013,
1005,
1012,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1031,
1005,
2171,
1005,
1033,
1012,
1005,
2073,
1005,
1012,
1002,
2023,
1011,
1028,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Installation/FormDatabaseSetup.php | FormDatabaseSetup.createDatabaseObject | public function createDatabaseObject()
{
$dbname = trim($this->getSubmitValue('dbname'));
if (empty($dbname)) // disallow database object creation w/ no selected database
{
throw new Exception("No database name");
}
$adapter = $this->getSubmitValue('adapter');
$port = Adapter::getDefaultPortForAdapter($adapter);
$host = $this->getSubmitValue('host');
$tables_prefix = $this->getSubmitValue('tables_prefix');
$dbInfos = array(
'host' => (is_null($host)) ? $host : trim($host),
'username' => $this->getSubmitValue('username'),
'password' => $this->getSubmitValue('password'),
'dbname' => $dbname,
'tables_prefix' => (is_null($tables_prefix)) ? $tables_prefix : trim($tables_prefix),
'adapter' => $adapter,
'port' => $port,
'schema' => Config::getInstance()->database['schema'],
'type' => $this->getSubmitValue('type')
);
if (($portIndex = strpos($dbInfos['host'], '/')) !== false) {
// unix_socket=/path/sock.n
$dbInfos['port'] = substr($dbInfos['host'], $portIndex);
$dbInfos['host'] = '';
} else if (($portIndex = strpos($dbInfos['host'], ':')) !== false) {
// host:port
$dbInfos['port'] = substr($dbInfos['host'], $portIndex + 1);
$dbInfos['host'] = substr($dbInfos['host'], 0, $portIndex);
}
try {
@Db::createDatabaseObject($dbInfos);
} catch (Zend_Db_Adapter_Exception $e) {
$db = Adapter::factory($adapter, $dbInfos, $connect = false);
// database not found, we try to create it
if ($db->isErrNo($e, '1049')) {
$dbInfosConnectOnly = $dbInfos;
$dbInfosConnectOnly['dbname'] = null;
@Db::createDatabaseObject($dbInfosConnectOnly);
@DbHelper::createDatabase($dbInfos['dbname']);
// select the newly created database
@Db::createDatabaseObject($dbInfos);
} else {
throw $e;
}
}
return $dbInfos;
} | php | public function createDatabaseObject()
{
$dbname = trim($this->getSubmitValue('dbname'));
if (empty($dbname)) // disallow database object creation w/ no selected database
{
throw new Exception("No database name");
}
$adapter = $this->getSubmitValue('adapter');
$port = Adapter::getDefaultPortForAdapter($adapter);
$host = $this->getSubmitValue('host');
$tables_prefix = $this->getSubmitValue('tables_prefix');
$dbInfos = array(
'host' => (is_null($host)) ? $host : trim($host),
'username' => $this->getSubmitValue('username'),
'password' => $this->getSubmitValue('password'),
'dbname' => $dbname,
'tables_prefix' => (is_null($tables_prefix)) ? $tables_prefix : trim($tables_prefix),
'adapter' => $adapter,
'port' => $port,
'schema' => Config::getInstance()->database['schema'],
'type' => $this->getSubmitValue('type')
);
if (($portIndex = strpos($dbInfos['host'], '/')) !== false) {
// unix_socket=/path/sock.n
$dbInfos['port'] = substr($dbInfos['host'], $portIndex);
$dbInfos['host'] = '';
} else if (($portIndex = strpos($dbInfos['host'], ':')) !== false) {
// host:port
$dbInfos['port'] = substr($dbInfos['host'], $portIndex + 1);
$dbInfos['host'] = substr($dbInfos['host'], 0, $portIndex);
}
try {
@Db::createDatabaseObject($dbInfos);
} catch (Zend_Db_Adapter_Exception $e) {
$db = Adapter::factory($adapter, $dbInfos, $connect = false);
// database not found, we try to create it
if ($db->isErrNo($e, '1049')) {
$dbInfosConnectOnly = $dbInfos;
$dbInfosConnectOnly['dbname'] = null;
@Db::createDatabaseObject($dbInfosConnectOnly);
@DbHelper::createDatabase($dbInfos['dbname']);
// select the newly created database
@Db::createDatabaseObject($dbInfos);
} else {
throw $e;
}
}
return $dbInfos;
} | [
"public",
"function",
"createDatabaseObject",
"(",
")",
"{",
"$",
"dbname",
"=",
"trim",
"(",
"$",
"this",
"->",
"getSubmitValue",
"(",
"'dbname'",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"dbname",
")",
")",
"// disallow database object creation w/ no sel... | Creates database object based on form data.
@throws Exception|Zend_Db_Adapter_Exception
@return array The database connection info. Can be passed into Piwik::createDatabaseObject. | [
"Creates",
"database",
"object",
"based",
"on",
"form",
"data",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/FormDatabaseSetup.php#L111-L167 | train | Create database object | [
30522,
2270,
3853,
2580,
6790,
15058,
16429,
20614,
1006,
1007,
1063,
1002,
16962,
18442,
1027,
12241,
1006,
1002,
2023,
1011,
1028,
4152,
12083,
22930,
10175,
5657,
1006,
1005,
16962,
18442,
1005,
1007,
1007,
1025,
2065,
1006,
4064,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Input/InputArgument.php | InputArgument.setDefault | public function setDefault($default = null)
{
if (self::REQUIRED === $this->mode && null !== $default) {
throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
}
if ($this->isArray()) {
if (null === $default) {
$default = [];
} elseif (!\is_array($default)) {
throw new LogicException('A default value for an array argument must be an array.');
}
}
$this->default = $default;
} | php | public function setDefault($default = null)
{
if (self::REQUIRED === $this->mode && null !== $default) {
throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
}
if ($this->isArray()) {
if (null === $default) {
$default = [];
} elseif (!\is_array($default)) {
throw new LogicException('A default value for an array argument must be an array.');
}
}
$this->default = $default;
} | [
"public",
"function",
"setDefault",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"REQUIRED",
"===",
"$",
"this",
"->",
"mode",
"&&",
"null",
"!==",
"$",
"default",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Cannot set a de... | Sets the default value.
@param string|string[]|null $default The default value
@throws LogicException When incorrect default value is given | [
"Sets",
"the",
"default",
"value",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Input/InputArgument.php#L93-L108 | train | Set default value | [
30522,
2270,
3853,
2275,
3207,
7011,
11314,
1006,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
3223,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
5549,
1004,
1004,
19701,
999,
1027,
1027,
1002,
12398,
1007,
1063,
5466,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/SettingsPiwik.php | SettingsPiwik.isUniqueVisitorsEnabled | public static function isUniqueVisitorsEnabled($periodLabel)
{
$generalSettings = Config::getInstance()->General;
$settingName = "enable_processing_unique_visitors_$periodLabel";
$result = !empty($generalSettings[$settingName]) && $generalSettings[$settingName] == 1;
// check enable_processing_unique_visitors_year_and_range for backwards compatibility
if (($periodLabel == 'year' || $periodLabel == 'range')
&& isset($generalSettings['enable_processing_unique_visitors_year_and_range'])
) {
$result |= $generalSettings['enable_processing_unique_visitors_year_and_range'] == 1;
}
return $result;
} | php | public static function isUniqueVisitorsEnabled($periodLabel)
{
$generalSettings = Config::getInstance()->General;
$settingName = "enable_processing_unique_visitors_$periodLabel";
$result = !empty($generalSettings[$settingName]) && $generalSettings[$settingName] == 1;
// check enable_processing_unique_visitors_year_and_range for backwards compatibility
if (($periodLabel == 'year' || $periodLabel == 'range')
&& isset($generalSettings['enable_processing_unique_visitors_year_and_range'])
) {
$result |= $generalSettings['enable_processing_unique_visitors_year_and_range'] == 1;
}
return $result;
} | [
"public",
"static",
"function",
"isUniqueVisitorsEnabled",
"(",
"$",
"periodLabel",
")",
"{",
"$",
"generalSettings",
"=",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"General",
";",
"$",
"settingName",
"=",
"\"enable_processing_unique_visitors_$periodLabel\"",
";"... | Returns true if unique visitors should be processed for the given period type.
Unique visitor processing is controlled by the `[General] enable_processing_unique_visitors_...`
INI config options. By default, unique visitors are processed only for day/week/month periods.
@param string $periodLabel `"day"`, `"week"`, `"month"`, `"year"` or `"range"`
@return bool
@api | [
"Returns",
"true",
"if",
"unique",
"visitors",
"should",
"be",
"processed",
"for",
"the",
"given",
"period",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/SettingsPiwik.php#L332-L347 | train | Return TRUE if unique visitors are enabled for the specified period | [
30522,
2270,
10763,
3853,
2003,
19496,
4226,
11365,
27287,
8189,
23242,
1006,
1002,
2558,
20470,
2884,
1007,
1063,
1002,
11593,
18319,
3070,
2015,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2236,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Action.php | Action.record | public function record(Visitor $visitor, $idReferrerActionUrl, $idReferrerActionName)
{
$this->loadIdsFromLogActionTable();
$visitAction = array(
'idvisit' => $visitor->getVisitorColumn('idvisit'),
'idsite' => $this->request->getIdSite(),
'idvisitor' => $visitor->getVisitorColumn('idvisitor'),
'idaction_url' => $this->getIdActionUrl(),
'idaction_url_ref' => $idReferrerActionUrl,
'idaction_name_ref' => $idReferrerActionName
);
/** @var ActionDimension[] $dimensions */
$dimensions = ActionDimension::getAllDimensions();
foreach ($dimensions as $dimension) {
$value = $dimension->onNewAction($this->request, $visitor, $this);
if ($value !== false) {
if (is_float($value)) {
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
}
$visitAction[$dimension->getColumnName()] = $value;
}
}
// idaction_name is NULLable. we only set it when applicable
if ($this->isActionHasActionName()) {
$visitAction['idaction_name'] = (int)$this->getIdActionName();
}
foreach ($this->actionIdsCached as $field => $idAction) {
$visitAction[$field] = ($idAction === false) ? 0 : $idAction;
}
$customValue = $this->getCustomFloatValue();
if ($customValue !== false && $customValue !== null && $customValue !== '') {
$visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = Common::forceDotAsSeparatorForDecimalPoint($customValue);
}
$visitAction = array_merge($visitAction, $this->customFields);
$this->idLinkVisitAction = $this->getModel()->createAction($visitAction);
$visitAction['idlink_va'] = $this->idLinkVisitAction;
Common::printDebug("Inserted new action:");
$visitActionDebug = $visitAction;
$visitActionDebug['idvisitor'] = bin2hex($visitActionDebug['idvisitor']);
Common::printDebug($visitActionDebug);
} | php | public function record(Visitor $visitor, $idReferrerActionUrl, $idReferrerActionName)
{
$this->loadIdsFromLogActionTable();
$visitAction = array(
'idvisit' => $visitor->getVisitorColumn('idvisit'),
'idsite' => $this->request->getIdSite(),
'idvisitor' => $visitor->getVisitorColumn('idvisitor'),
'idaction_url' => $this->getIdActionUrl(),
'idaction_url_ref' => $idReferrerActionUrl,
'idaction_name_ref' => $idReferrerActionName
);
/** @var ActionDimension[] $dimensions */
$dimensions = ActionDimension::getAllDimensions();
foreach ($dimensions as $dimension) {
$value = $dimension->onNewAction($this->request, $visitor, $this);
if ($value !== false) {
if (is_float($value)) {
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
}
$visitAction[$dimension->getColumnName()] = $value;
}
}
// idaction_name is NULLable. we only set it when applicable
if ($this->isActionHasActionName()) {
$visitAction['idaction_name'] = (int)$this->getIdActionName();
}
foreach ($this->actionIdsCached as $field => $idAction) {
$visitAction[$field] = ($idAction === false) ? 0 : $idAction;
}
$customValue = $this->getCustomFloatValue();
if ($customValue !== false && $customValue !== null && $customValue !== '') {
$visitAction[self::DB_COLUMN_CUSTOM_FLOAT] = Common::forceDotAsSeparatorForDecimalPoint($customValue);
}
$visitAction = array_merge($visitAction, $this->customFields);
$this->idLinkVisitAction = $this->getModel()->createAction($visitAction);
$visitAction['idlink_va'] = $this->idLinkVisitAction;
Common::printDebug("Inserted new action:");
$visitActionDebug = $visitAction;
$visitActionDebug['idvisitor'] = bin2hex($visitActionDebug['idvisitor']);
Common::printDebug($visitActionDebug);
} | [
"public",
"function",
"record",
"(",
"Visitor",
"$",
"visitor",
",",
"$",
"idReferrerActionUrl",
",",
"$",
"idReferrerActionName",
")",
"{",
"$",
"this",
"->",
"loadIdsFromLogActionTable",
"(",
")",
";",
"$",
"visitAction",
"=",
"array",
"(",
"'idvisit'",
"=>"... | Records in the DB the association between the visit and this action.
@param int $idReferrerActionUrl is the ID of the last action done by the current visit.
@param $idReferrerActionName
@param Visitor $visitor | [
"Records",
"in",
"the",
"DB",
"the",
"association",
"between",
"the",
"visit",
"and",
"this",
"action",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Action.php#L358-L410 | train | Records the action data for the visitor | [
30522,
2270,
3853,
2501,
1006,
10367,
1002,
10367,
1010,
1002,
8909,
2890,
7512,
24068,
7542,
3126,
2140,
1010,
1002,
8909,
2890,
7512,
24068,
7542,
18442,
1007,
1063,
1002,
2023,
1011,
1028,
7170,
9821,
19699,
5358,
21197,
18908,
3258,
108... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DateFactory.php | DateFactory.use | public static function use($handler)
{
if (is_callable($handler) && is_object($handler)) {
return static::useCallable($handler);
} elseif (is_string($handler)) {
return static::useClass($handler);
} elseif ($handler instanceof Factory) {
return static::useFactory($handler);
}
throw new InvalidArgumentException('Invalid date creation handler. Please provide a class name, callable, or Carbon factory.');
} | php | public static function use($handler)
{
if (is_callable($handler) && is_object($handler)) {
return static::useCallable($handler);
} elseif (is_string($handler)) {
return static::useClass($handler);
} elseif ($handler instanceof Factory) {
return static::useFactory($handler);
}
throw new InvalidArgumentException('Invalid date creation handler. Please provide a class name, callable, or Carbon factory.');
} | [
"public",
"static",
"function",
"use",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"handler",
")",
"&&",
"is_object",
"(",
"$",
"handler",
")",
")",
"{",
"return",
"static",
"::",
"useCallable",
"(",
"$",
"handler",
")",
";",
"... | Use the given handler when generating dates (class name, callable, or factory).
@param mixed $handler
@throws \InvalidArgumentException | [
"Use",
"the",
"given",
"handler",
"when",
"generating",
"dates",
"(",
"class",
"name",
"callable",
"or",
"factory",
")",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/DateFactory.php#L121-L132 | train | Use the date creation handler | [
30522,
2270,
10763,
3853,
2224,
1006,
1002,
28213,
1007,
1063,
2065,
1006,
2003,
1035,
2655,
3085,
1006,
1002,
28213,
1007,
1004,
1004,
2003,
1035,
4874,
1006,
1002,
28213,
1007,
1007,
1063,
2709,
10763,
1024,
1024,
30524,
1007,
1063,
2709,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php | TemplatePathsCacheWarmer.warmUp | public function warmUp($cacheDir)
{
$filesystem = new Filesystem();
$templates = [];
foreach ($this->finder->findAllTemplates() as $template) {
$templates[$template->getLogicalName()] = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/');
}
$templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true));
$this->writeCacheFile($cacheDir.'/templates.php', sprintf("<?php return %s;\n", $templates));
} | php | public function warmUp($cacheDir)
{
$filesystem = new Filesystem();
$templates = [];
foreach ($this->finder->findAllTemplates() as $template) {
$templates[$template->getLogicalName()] = rtrim($filesystem->makePathRelative($this->locator->locate($template), $cacheDir), '/');
}
$templates = str_replace("' => '", "' => __DIR__.'/", var_export($templates, true));
$this->writeCacheFile($cacheDir.'/templates.php', sprintf("<?php return %s;\n", $templates));
} | [
"public",
"function",
"warmUp",
"(",
"$",
"cacheDir",
")",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"templates",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"finder",
"->",
"findAllTemplates",
"(",
")",
"as",
"... | Warms up the cache.
@param string $cacheDir The cache directory | [
"Warms",
"up",
"the",
"cache",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php#L43-L55 | train | Warms up the templates. php file | [
30522,
2270,
3853,
4010,
6279,
1006,
30524,
1027,
2047,
6764,
27268,
6633,
1006,
1007,
1025,
1002,
23561,
2015,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2424,
2121,
1011,
1028,
2424,
8095,
18532,
15725,
2015,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field/Select.php | Select.loadRemoteOptions | protected function loadRemoteOptions($url, $parameters = [], $options = [])
{
$ajaxOptions = [
'url' => $url.'?'.http_build_query($parameters),
];
$configs = array_merge([
'allowClear' => true,
'placeholder' => [
'id' => '',
'text' => trans('admin.choose'),
],
], $this->config);
$configs = json_encode($configs);
$configs = substr($configs, 1, strlen($configs) - 2);
$ajaxOptions = json_encode(array_merge($ajaxOptions, $options));
$this->script = <<<EOT
$.ajax($ajaxOptions).done(function(data) {
var select = $("{$this->getElementClassSelector()}");
select.select2({
data: data,
$configs
});
var value = select.data('value') + '';
if (value) {
value = value.split(',');
select.select2('val', value);
}
});
EOT;
return $this;
} | php | protected function loadRemoteOptions($url, $parameters = [], $options = [])
{
$ajaxOptions = [
'url' => $url.'?'.http_build_query($parameters),
];
$configs = array_merge([
'allowClear' => true,
'placeholder' => [
'id' => '',
'text' => trans('admin.choose'),
],
], $this->config);
$configs = json_encode($configs);
$configs = substr($configs, 1, strlen($configs) - 2);
$ajaxOptions = json_encode(array_merge($ajaxOptions, $options));
$this->script = <<<EOT
$.ajax($ajaxOptions).done(function(data) {
var select = $("{$this->getElementClassSelector()}");
select.select2({
data: data,
$configs
});
var value = select.data('value') + '';
if (value) {
value = value.split(',');
select.select2('val', value);
}
});
EOT;
return $this;
} | [
"protected",
"function",
"loadRemoteOptions",
"(",
"$",
"url",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"ajaxOptions",
"=",
"[",
"'url'",
"=>",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$"... | Load options from remote.
@param string $url
@param array $parameters
@param array $options
@return $this | [
"Load",
"options",
"from",
"remote",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/Select.php#L242-L282 | train | Load remote options | [
30522,
5123,
3853,
7170,
28578,
12184,
7361,
9285,
1006,
1002,
24471,
2140,
1010,
1002,
11709,
1027,
1031,
1033,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
18176,
7361,
9285,
1027,
1031,
1005,
24471,
2140,
1005,
1027,
1028,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Mysqli.php | Zend_Db_Adapter_Mysqli._quote | protected function _quote($value)
{
if (is_int($value) || is_float($value)) {
return $value;
}
$this->_connect();
return "'" . $this->_connection->real_escape_string($value) . "'";
} | php | protected function _quote($value)
{
if (is_int($value) || is_float($value)) {
return $value;
}
$this->_connect();
return "'" . $this->_connection->real_escape_string($value) . "'";
} | [
"protected",
"function",
"_quote",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
"||",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"retu... | Quote a raw string.
@param mixed $value Raw string
@return string Quoted string | [
"Quote",
"a",
"raw",
"string",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L104-L111 | train | Quote value for use in SQL | [
30522,
5123,
3853,
1035,
14686,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
2003,
1035,
20014,
1006,
1002,
3643,
1007,
1064,
1064,
2003,
1035,
14257,
1006,
1002,
3643,
1007,
1007,
1063,
2709,
1002,
3643,
1025,
1065,
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... |
walkor/Workerman | Worker.php | Worker.resumeAccept | public function resumeAccept()
{
// Register a listener to be notified when server socket is ready to read.
if (static::$globalEvent && true === $this->_pauseAccept && $this->_mainSocket) {
if ($this->transport !== 'udp') {
static::$globalEvent->add($this->_mainSocket, EventInterface::EV_READ, array($this, 'acceptConnection'));
} else {
static::$globalEvent->add($this->_mainSocket, EventInterface::EV_READ, array($this, 'acceptUdpConnection'));
}
$this->_pauseAccept = false;
}
} | php | public function resumeAccept()
{
// Register a listener to be notified when server socket is ready to read.
if (static::$globalEvent && true === $this->_pauseAccept && $this->_mainSocket) {
if ($this->transport !== 'udp') {
static::$globalEvent->add($this->_mainSocket, EventInterface::EV_READ, array($this, 'acceptConnection'));
} else {
static::$globalEvent->add($this->_mainSocket, EventInterface::EV_READ, array($this, 'acceptUdpConnection'));
}
$this->_pauseAccept = false;
}
} | [
"public",
"function",
"resumeAccept",
"(",
")",
"{",
"// Register a listener to be notified when server socket is ready to read.",
"if",
"(",
"static",
"::",
"$",
"globalEvent",
"&&",
"true",
"===",
"$",
"this",
"->",
"_pauseAccept",
"&&",
"$",
"this",
"->",
"_mainSoc... | Resume accept new connections.
@return void | [
"Resume",
"accept",
"new",
"connections",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L2280-L2291 | train | Resumes the accept process | [
30522,
2270,
3853,
13746,
6305,
3401,
13876,
30524,
2023,
1011,
1028,
1035,
8724,
6305,
3401,
13876,
1004,
1004,
1002,
2023,
1011,
1028,
1035,
2364,
6499,
19869,
2102,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3665,
999,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php | ValidateEnvPlaceholdersPass.process | public function process(ContainerBuilder $container)
{
$this->extensionConfig = [];
if (!class_exists(BaseNode::class) || !$extensions = $container->getExtensions()) {
return;
}
$resolvingBag = $container->getParameterBag();
if (!$resolvingBag instanceof EnvPlaceholderParameterBag) {
return;
}
$defaultBag = new ParameterBag($resolvingBag->all());
$envTypes = $resolvingBag->getProvidedTypes();
try {
foreach ($resolvingBag->getEnvPlaceholders() + $resolvingBag->getUnusedEnvPlaceholders() as $env => $placeholders) {
$values = [];
if (false === $i = strpos($env, ':')) {
$default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::$typeFixtures['string'];
$defaultType = null !== $default ? self::getType($default) : 'string';
$values[$defaultType] = $default;
} else {
$prefix = substr($env, 0, $i);
foreach ($envTypes[$prefix] ?? ['string'] as $type) {
$values[$type] = self::$typeFixtures[$type] ?? null;
}
}
foreach ($placeholders as $placeholder) {
BaseNode::setPlaceholder($placeholder, $values);
}
}
$processor = new Processor();
foreach ($extensions as $name => $extension) {
if (!$extension instanceof ConfigurationExtensionInterface || !$config = array_filter($container->getExtensionConfig($name))) {
// this extension has no semantic configuration or was not called
continue;
}
$config = $resolvingBag->resolveValue($config);
if (null === $configuration = $extension->getConfiguration($config, $container)) {
continue;
}
try {
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
} catch (TreeWithoutRootNodeException $e) {
}
}
} finally {
BaseNode::resetPlaceholders();
}
$resolvingBag->clearUnusedEnvPlaceholders();
} | php | public function process(ContainerBuilder $container)
{
$this->extensionConfig = [];
if (!class_exists(BaseNode::class) || !$extensions = $container->getExtensions()) {
return;
}
$resolvingBag = $container->getParameterBag();
if (!$resolvingBag instanceof EnvPlaceholderParameterBag) {
return;
}
$defaultBag = new ParameterBag($resolvingBag->all());
$envTypes = $resolvingBag->getProvidedTypes();
try {
foreach ($resolvingBag->getEnvPlaceholders() + $resolvingBag->getUnusedEnvPlaceholders() as $env => $placeholders) {
$values = [];
if (false === $i = strpos($env, ':')) {
$default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::$typeFixtures['string'];
$defaultType = null !== $default ? self::getType($default) : 'string';
$values[$defaultType] = $default;
} else {
$prefix = substr($env, 0, $i);
foreach ($envTypes[$prefix] ?? ['string'] as $type) {
$values[$type] = self::$typeFixtures[$type] ?? null;
}
}
foreach ($placeholders as $placeholder) {
BaseNode::setPlaceholder($placeholder, $values);
}
}
$processor = new Processor();
foreach ($extensions as $name => $extension) {
if (!$extension instanceof ConfigurationExtensionInterface || !$config = array_filter($container->getExtensionConfig($name))) {
// this extension has no semantic configuration or was not called
continue;
}
$config = $resolvingBag->resolveValue($config);
if (null === $configuration = $extension->getConfiguration($config, $container)) {
continue;
}
try {
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
} catch (TreeWithoutRootNodeException $e) {
}
}
} finally {
BaseNode::resetPlaceholders();
}
$resolvingBag->clearUnusedEnvPlaceholders();
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"this",
"->",
"extensionConfig",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"BaseNode",
"::",
"class",
")",
"||",
"!",
"$",
"extensions",
"=",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php#L36-L93 | train | Process the container builder | [
30522,
2270,
3853,
2832,
1006,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
1002,
2023,
1011,
1028,
5331,
8663,
8873,
2290,
1027,
1031,
1033,
1025,
2065,
1006,
999,
2465,
1035,
6526,
1006,
2918,
3630,
3207,
1024,
1024,
2465,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasEvents.php | HasEvents.registerObserver | protected function registerObserver($class)
{
$className = $this->resolveObserverClassName($class);
// When registering a model observer, we will spin through the possible events
// and determine if this observer has that method. If it does, we will hook
// it into the model's event system, making it convenient to watch these.
foreach ($this->getObservableEvents() as $event) {
if (method_exists($class, $event)) {
static::registerModelEvent($event, $className.'@'.$event);
}
}
} | php | protected function registerObserver($class)
{
$className = $this->resolveObserverClassName($class);
// When registering a model observer, we will spin through the possible events
// and determine if this observer has that method. If it does, we will hook
// it into the model's event system, making it convenient to watch these.
foreach ($this->getObservableEvents() as $event) {
if (method_exists($class, $event)) {
static::registerModelEvent($event, $className.'@'.$event);
}
}
} | [
"protected",
"function",
"registerObserver",
"(",
"$",
"class",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"resolveObserverClassName",
"(",
"$",
"class",
")",
";",
"// When registering a model observer, we will spin through the possible events",
"// and determine i... | Register a single observer with the model.
@param object|string $class
@return void
@throws \RuntimeException | [
"Register",
"a",
"single",
"observer",
"with",
"the",
"model",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php#L54-L66 | train | Registers an observer for the given class | [
30522,
5123,
3853,
4236,
16429,
8043,
6299,
1006,
1002,
2465,
1007,
1063,
1002,
2465,
18442,
1027,
1002,
2023,
1011,
1028,
10663,
16429,
8043,
6299,
26266,
18442,
1006,
1002,
2465,
1007,
1025,
1013,
1013,
2043,
25719,
1037,
2944,
9718,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php | SqlServerGrammar.whereDate | protected function whereDate(Builder $query, $where)
{
$value = $this->parameter($where['value']);
return 'cast('.$this->wrap($where['column']).' as date) '.$where['operator'].' '.$value;
} | php | protected function whereDate(Builder $query, $where)
{
$value = $this->parameter($where['value']);
return 'cast('.$this->wrap($where['column']).' as date) '.$where['operator'].' '.$value;
} | [
"protected",
"function",
"whereDate",
"(",
"Builder",
"$",
"query",
",",
"$",
"where",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"parameter",
"(",
"$",
"where",
"[",
"'value'",
"]",
")",
";",
"return",
"'cast('",
".",
"$",
"this",
"->",
"wrap",... | Compile a "where date" clause.
@param \Illuminate\Database\Query\Builder $query
@param array $where
@return string | [
"Compile",
"a",
"where",
"date",
"clause",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php#L99-L104 | train | Protected where date | [
30522,
5123,
3853,
2073,
13701,
1006,
12508,
1002,
23032,
1010,
1002,
2073,
1007,
1063,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
16381,
1006,
1002,
2073,
1031,
1005,
3643,
1005,
1033,
1007,
1025,
2709,
1005,
3459,
1006,
1005,
1012,
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/CronArchive/SharedSiteIds.php | SharedSiteIds.getNextSiteId | public function getNextSiteId()
{
if ($this->done) {
// we make sure we don't check again whether there are more sites to be archived as the list of
// sharedSiteIds may have been reset by now.
return null;
}
$self = $this;
$this->currentSiteId = $this->runExclusive(function () use ($self) {
$siteIds = $self->getAllSiteIdsToArchive();
if (empty($siteIds)) {
// done... no sites left to be archived
return null;
}
if (count($siteIds) > $self->numWebsitesLeftToProcess) {
// done... the number of siteIds in SharedSiteIds is larger than it was initially... therefore it must have
// been reset at some point.
return null;
}
$self->numWebsitesLeftToProcess = count($siteIds);
$nextSiteId = array_shift($siteIds);
$self->setSiteIdsToArchive($siteIds);
return $nextSiteId;
});
if (is_null($this->currentSiteId)) {
$this->done = true;
$this->numWebsitesLeftToProcess = 0;
}
return $this->currentSiteId;
} | php | public function getNextSiteId()
{
if ($this->done) {
// we make sure we don't check again whether there are more sites to be archived as the list of
// sharedSiteIds may have been reset by now.
return null;
}
$self = $this;
$this->currentSiteId = $this->runExclusive(function () use ($self) {
$siteIds = $self->getAllSiteIdsToArchive();
if (empty($siteIds)) {
// done... no sites left to be archived
return null;
}
if (count($siteIds) > $self->numWebsitesLeftToProcess) {
// done... the number of siteIds in SharedSiteIds is larger than it was initially... therefore it must have
// been reset at some point.
return null;
}
$self->numWebsitesLeftToProcess = count($siteIds);
$nextSiteId = array_shift($siteIds);
$self->setSiteIdsToArchive($siteIds);
return $nextSiteId;
});
if (is_null($this->currentSiteId)) {
$this->done = true;
$this->numWebsitesLeftToProcess = 0;
}
return $this->currentSiteId;
} | [
"public",
"function",
"getNextSiteId",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"done",
")",
"{",
"// we make sure we don't check again whether there are more sites to be archived as the list of",
"// sharedSiteIds may have been reset by now.",
"return",
"null",
";",
"}",
... | Get the next site id that needs to be processed or null if all site ids where processed.
@return int|null | [
"Get",
"the",
"next",
"site",
"id",
"that",
"needs",
"to",
"be",
"processed",
"or",
"null",
"if",
"all",
"site",
"ids",
"where",
"processed",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive/SharedSiteIds.php#L157-L196 | train | Returns the next site id to be archived | [
30522,
2270,
3853,
2131,
2638,
18413,
28032,
7416,
2094,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2589,
1007,
1063,
1013,
1013,
2057,
2191,
2469,
2057,
2123,
1005,
1056,
4638,
2153,
3251,
2045,
2024,
2062,
4573,
2000,
2022,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/DevicePlugins/Archiver.php | Archiver.aggregateMultipleReports | public function aggregateMultipleReports()
{
$dataTableRecords = array(
self::PLUGIN_RECORD_NAME,
);
$columnsAggregationOperation = null;
$this->getProcessor()->aggregateDataTableRecords(
$dataTableRecords,
$this->maximumRows,
$maximumRowsInSubDataTable = null,
$columnToSortByBeforeTruncation = null,
$columnsAggregationOperation,
$columnsToRenameAfterAggregation = null,
$countRowsRecursive = array()
);
} | php | public function aggregateMultipleReports()
{
$dataTableRecords = array(
self::PLUGIN_RECORD_NAME,
);
$columnsAggregationOperation = null;
$this->getProcessor()->aggregateDataTableRecords(
$dataTableRecords,
$this->maximumRows,
$maximumRowsInSubDataTable = null,
$columnToSortByBeforeTruncation = null,
$columnsAggregationOperation,
$columnsToRenameAfterAggregation = null,
$countRowsRecursive = array()
);
} | [
"public",
"function",
"aggregateMultipleReports",
"(",
")",
"{",
"$",
"dataTableRecords",
"=",
"array",
"(",
"self",
"::",
"PLUGIN_RECORD_NAME",
",",
")",
";",
"$",
"columnsAggregationOperation",
"=",
"null",
";",
"$",
"this",
"->",
"getProcessor",
"(",
")",
"... | Period archiving: simply sums up daily archives | [
"Period",
"archiving",
":",
"simply",
"sums",
"up",
"daily",
"archives"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DevicePlugins/Archiver.php#L39-L54 | train | Aggregate multiple reports | [
30522,
2270,
3853,
9572,
12274,
7096,
11514,
3917,
13699,
11589,
2015,
1006,
1007,
1063,
1002,
2951,
10880,
2890,
27108,
5104,
1027,
30524,
9572,
2850,
29336,
3085,
2890,
27108,
5104,
1006,
1002,
2951,
10880,
2890,
27108,
5104,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Connection/AsyncUdpConnection.php | AsyncUdpConnection.close | public function close($data = null, $raw = false)
{
if ($data !== null) {
$this->send($data, $raw);
}
Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
fclose($this->_socket);
$this->connected = false;
// Try to emit onClose callback.
if ($this->onClose) {
try {
call_user_func($this->onClose, $this);
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
$this->onConnect = $this->onMessage = $this->onClose = null;
return true;
} | php | public function close($data = null, $raw = false)
{
if ($data !== null) {
$this->send($data, $raw);
}
Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
fclose($this->_socket);
$this->connected = false;
// Try to emit onClose callback.
if ($this->onClose) {
try {
call_user_func($this->onClose, $this);
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
$this->onConnect = $this->onMessage = $this->onClose = null;
return true;
} | [
"public",
"function",
"close",
"(",
"$",
"data",
"=",
"null",
",",
"$",
"raw",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"send",
"(",
"$",
"data",
",",
"$",
"raw",
")",
";",
"}",
"Worker",
"::... | Close connection.
@param mixed $data
@param bool $raw
@return bool | [
"Close",
"connection",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/AsyncUdpConnection.php#L142-L164 | train | Close the connection | [
30522,
2270,
3853,
2485,
1006,
1002,
2951,
1027,
19701,
1010,
1002,
6315,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2951,
999,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
4604,
1006,
1002,
2951,
1010,
1002,
6315,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Session/Abstract.php | Zend_Session_Abstract._namespaceGetAll | protected static function _namespaceGetAll($namespace)
{
$currentData = (isset($_SESSION[$namespace]) && is_array($_SESSION[$namespace])) ?
$_SESSION[$namespace] : array();
$expiringData = (isset(self::$_expiringData[$namespace]) && is_array(self::$_expiringData[$namespace])) ?
self::$_expiringData[$namespace] : array();
return array_merge($currentData, $expiringData);
} | php | protected static function _namespaceGetAll($namespace)
{
$currentData = (isset($_SESSION[$namespace]) && is_array($_SESSION[$namespace])) ?
$_SESSION[$namespace] : array();
$expiringData = (isset(self::$_expiringData[$namespace]) && is_array(self::$_expiringData[$namespace])) ?
self::$_expiringData[$namespace] : array();
return array_merge($currentData, $expiringData);
} | [
"protected",
"static",
"function",
"_namespaceGetAll",
"(",
"$",
"namespace",
")",
"{",
"$",
"currentData",
"=",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"namespace",
"]",
")",
"&&",
"is_array",
"(",
"$",
"_SESSION",
"[",
"$",
"namespace",
"]",
")",... | namespaceGetAll() - Get an array containing $namespace, including expiring data.
@param string $namespace
@param string $name
@return mixed | [
"namespaceGetAll",
"()",
"-",
"Get",
"an",
"array",
"containing",
"$namespace",
"including",
"expiring",
"data",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session/Abstract.php#L177-L184 | train | Get all session data for a namespace | [
30522,
5123,
10763,
3853,
1035,
3415,
15327,
18150,
8095,
1006,
1002,
3415,
15327,
1007,
1063,
1002,
2783,
2850,
2696,
1027,
1006,
26354,
3388,
1006,
1002,
1035,
5219,
1031,
1002,
3415,
15327,
1033,
1007,
1004,
1004,
2003,
1035,
9140,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/Connections/PhpRedisConnection.php | PhpRedisConnection.transaction | public function transaction(callable $callback = null)
{
$transaction = $this->client()->multi();
return is_null($callback)
? $transaction
: tap($transaction, $callback)->exec();
} | php | public function transaction(callable $callback = null)
{
$transaction = $this->client()->multi();
return is_null($callback)
? $transaction
: tap($transaction, $callback)->exec();
} | [
"public",
"function",
"transaction",
"(",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"transaction",
"=",
"$",
"this",
"->",
"client",
"(",
")",
"->",
"multi",
"(",
")",
";",
"return",
"is_null",
"(",
"$",
"callback",
")",
"?",
"$",
"tra... | Execute commands in a transaction.
@param callable|null $callback
@return \Redis|array | [
"Execute",
"commands",
"in",
"a",
"transaction",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Connections/PhpRedisConnection.php#L313-L320 | train | Execute a multi - transaction. | [
30522,
2270,
3853,
12598,
1006,
2655,
3085,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
1002,
12598,
1027,
1002,
2023,
1011,
1028,
7396,
1006,
1007,
1011,
1028,
4800,
1006,
1007,
1025,
2709,
2003,
1035,
19701,
1006,
1002,
2655,
5963,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/PrivacyManager/PrivacyManager.php | PrivacyManager.hasReportBeenPurged | public static function hasReportBeenPurged($dataTable)
{
$strPeriod = Common::getRequestVar('period', false);
$strDate = Common::getRequestVar('date', false);
if (false !== $strPeriod
&& false !== $strDate
&& (is_null($dataTable)
|| (!empty($dataTable) && $dataTable->getRowsCount() == 0))
) {
$reportDate = self::getReportDate($strPeriod, $strDate);
if (empty($reportDate)) {
return false;
}
$reportYear = $reportDate->toString('Y');
$reportMonth = $reportDate->toString('m');
if (static::shouldReportBePurged($reportYear, $reportMonth)) {
return true;
}
}
return false;
} | php | public static function hasReportBeenPurged($dataTable)
{
$strPeriod = Common::getRequestVar('period', false);
$strDate = Common::getRequestVar('date', false);
if (false !== $strPeriod
&& false !== $strDate
&& (is_null($dataTable)
|| (!empty($dataTable) && $dataTable->getRowsCount() == 0))
) {
$reportDate = self::getReportDate($strPeriod, $strDate);
if (empty($reportDate)) {
return false;
}
$reportYear = $reportDate->toString('Y');
$reportMonth = $reportDate->toString('m');
if (static::shouldReportBePurged($reportYear, $reportMonth)) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"hasReportBeenPurged",
"(",
"$",
"dataTable",
")",
"{",
"$",
"strPeriod",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'period'",
",",
"false",
")",
";",
"$",
"strDate",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'date'",
",",... | Returns true if it is likely that the data for this report has been purged and if the
user should be told about that.
In order for this function to return true, the following must also be true:
- The data table for this report must either be empty or not have been fetched.
- The period of this report is not a multiple period.
- The date of this report must be older than the delete_reports_older_than config option.
@param DataTableInterface $dataTable
@return bool | [
"Returns",
"true",
"if",
"it",
"is",
"likely",
"that",
"the",
"data",
"for",
"this",
"report",
"has",
"been",
"purged",
"and",
"if",
"the",
"user",
"should",
"be",
"told",
"about",
"that",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/PrivacyManager.php#L103-L128 | train | Returns true if the report has been purged | [
30522,
2270,
10763,
3853,
2038,
2890,
6442,
11306,
16275,
12514,
2098,
1006,
1002,
2951,
10880,
1007,
1063,
1002,
2358,
14536,
11124,
7716,
1027,
2691,
1024,
1024,
2131,
2890,
15500,
10755,
1006,
1005,
2558,
1005,
1010,
6270,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/RouteCollection.php | RouteCollection.addResource | public function addResource(ResourceInterface $resource)
{
$key = (string) $resource;
if (!isset($this->resources[$key])) {
$this->resources[$key] = $resource;
}
} | php | public function addResource(ResourceInterface $resource)
{
$key = (string) $resource;
if (!isset($this->resources[$key])) {
$this->resources[$key] = $resource;
}
} | [
"public",
"function",
"addResource",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"resource",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resources",
"[",
"$",
"key",
"]",
")",
")",
"{",
... | Adds a resource for this collection. If the resource already exists
it is not added. | [
"Adds",
"a",
"resource",
"for",
"this",
"collection",
".",
"If",
"the",
"resource",
"already",
"exists",
"it",
"is",
"not",
"added",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/RouteCollection.php#L289-L296 | train | Add a resource to the list of resources | [
30522,
2270,
3853,
5587,
6072,
8162,
3401,
1006,
7692,
18447,
2121,
12172,
1002,
7692,
1007,
1063,
1002,
3145,
1027,
1006,
5164,
1007,
1002,
7692,
1025,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
4219,
1031,
1002,
3145,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/CombineAssets.php | CombineAssets.getDeepHashFromAssets | protected function getDeepHashFromAssets($assets)
{
$key = '';
$assetFiles = array_map(function ($file) {
return file_exists($file) ? $file : File::symbolizePath($file, null) ?: $this->localPath . $file;
}, $assets);
foreach ($assetFiles as $file) {
$filters = $this->getFilters(File::extension($file));
foreach ($filters as $filter) {
if (method_exists($filter, 'hashAsset')) {
$key .= $filter->hashAsset($file, $this->localPath);
}
}
}
return $key;
} | php | protected function getDeepHashFromAssets($assets)
{
$key = '';
$assetFiles = array_map(function ($file) {
return file_exists($file) ? $file : File::symbolizePath($file, null) ?: $this->localPath . $file;
}, $assets);
foreach ($assetFiles as $file) {
$filters = $this->getFilters(File::extension($file));
foreach ($filters as $filter) {
if (method_exists($filter, 'hashAsset')) {
$key .= $filter->hashAsset($file, $this->localPath);
}
}
}
return $key;
} | [
"protected",
"function",
"getDeepHashFromAssets",
"(",
"$",
"assets",
")",
"{",
"$",
"key",
"=",
"''",
";",
"$",
"assetFiles",
"=",
"array_map",
"(",
"function",
"(",
"$",
"file",
")",
"{",
"return",
"file_exists",
"(",
"$",
"file",
")",
"?",
"$",
"fil... | Returns a deep hash on filters that support it.
@param array $assets List of asset files.
@return void | [
"Returns",
"a",
"deep",
"hash",
"on",
"filters",
"that",
"support",
"it",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L469-L488 | train | Get deep hash from assets | [
30522,
5123,
3853,
2131,
26095,
30524,
5371,
1007,
1063,
2709,
5371,
1035,
6526,
1006,
1002,
5371,
1007,
1029,
1002,
5371,
1024,
5371,
1024,
1024,
6454,
4697,
15069,
1006,
1002,
5371,
1010,
19701,
1007,
1029,
1024,
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... |
z-song/laravel-admin | src/Extension.php | Extension.createPermission | protected static function createPermission($name, $slug, $path)
{
$permissionModel = config('admin.database.permissions_model');
$permissionModel::create([
'name' => $name,
'slug' => $slug,
'http_path' => '/'.trim($path, '/'),
]);
} | php | protected static function createPermission($name, $slug, $path)
{
$permissionModel = config('admin.database.permissions_model');
$permissionModel::create([
'name' => $name,
'slug' => $slug,
'http_path' => '/'.trim($path, '/'),
]);
} | [
"protected",
"static",
"function",
"createPermission",
"(",
"$",
"name",
",",
"$",
"slug",
",",
"$",
"path",
")",
"{",
"$",
"permissionModel",
"=",
"config",
"(",
"'admin.database.permissions_model'",
")",
";",
"$",
"permissionModel",
"::",
"create",
"(",
"[",... | Create a permission for this extension.
@param $name
@param $slug
@param $path | [
"Create",
"a",
"permission",
"for",
"this",
"extension",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Extension.php#L325-L334 | train | Create permission in the permission model | [
30522,
5123,
10763,
3853,
3443,
4842,
25481,
1006,
1002,
2171,
1010,
1002,
23667,
1010,
1002,
4130,
1007,
1063,
1002,
6656,
5302,
9247,
1027,
9530,
8873,
2290,
1006,
1005,
4748,
10020,
1012,
7809,
1012,
6656,
2015,
1035,
2944,
1005,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.resizeImage | protected function resizeImage($fullThumbnailPath, $thumbnailParams, $tempFilePath)
{
$thumbnailDir = dirname($fullThumbnailPath);
if (
!File::isDirectory($thumbnailDir)
&& File::makeDirectory($thumbnailDir, 0777, true) === false
) {
throw new SystemException('Error creating thumbnail directory');
}
$targetDimensions = $this->getTargetDimensions($thumbnailParams['width'], $thumbnailParams['height'], $tempFilePath);
$targetWidth = $targetDimensions[0];
$targetHeight = $targetDimensions[1];
Resizer::open($tempFilePath)
->resize($targetWidth, $targetHeight, [
'mode' => $thumbnailParams['mode'],
'offset' => [0, 0]
])
->save($fullThumbnailPath)
;
File::chmod($fullThumbnailPath);
} | php | protected function resizeImage($fullThumbnailPath, $thumbnailParams, $tempFilePath)
{
$thumbnailDir = dirname($fullThumbnailPath);
if (
!File::isDirectory($thumbnailDir)
&& File::makeDirectory($thumbnailDir, 0777, true) === false
) {
throw new SystemException('Error creating thumbnail directory');
}
$targetDimensions = $this->getTargetDimensions($thumbnailParams['width'], $thumbnailParams['height'], $tempFilePath);
$targetWidth = $targetDimensions[0];
$targetHeight = $targetDimensions[1];
Resizer::open($tempFilePath)
->resize($targetWidth, $targetHeight, [
'mode' => $thumbnailParams['mode'],
'offset' => [0, 0]
])
->save($fullThumbnailPath)
;
File::chmod($fullThumbnailPath);
} | [
"protected",
"function",
"resizeImage",
"(",
"$",
"fullThumbnailPath",
",",
"$",
"thumbnailParams",
",",
"$",
"tempFilePath",
")",
"{",
"$",
"thumbnailDir",
"=",
"dirname",
"(",
"$",
"fullThumbnailPath",
")",
";",
"if",
"(",
"!",
"File",
"::",
"isDirectory",
... | Resize an image
@param string $fullThumbnailPath
@param array $thumbnailParams
@param string $tempFilePath
@return void | [
"Resize",
"an",
"image"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L1376-L1400 | train | Resize image to target dimensions | [
30522,
5123,
3853,
24501,
4697,
9581,
3351,
1006,
1002,
2440,
2705,
25438,
25464,
15069,
1010,
1002,
7639,
25464,
28689,
5244,
1010,
1002,
8915,
8737,
8873,
2571,
15069,
1007,
1063,
1002,
7639,
25464,
4305,
2099,
1027,
16101,
18442,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/EventDispatcher/EventDispatcher.php | EventDispatcher.dispatch | public function dispatch($event/*, string $eventName = null*/)
{
$eventName = 1 < \func_num_args() ? \func_get_arg(1) : null;
if (\is_object($event)) {
$eventName = $eventName ?? \get_class($event);
} else {
@trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED);
$swap = $event;
$event = $eventName ?? new Event();
$eventName = $swap;
if (!$event instanceof Event) {
throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', EventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event)));
}
}
if (null !== $this->optimized && null !== $eventName) {
$listeners = $this->optimized[$eventName] ?? (empty($this->listeners[$eventName]) ? [] : $this->optimizeListeners($eventName));
} else {
$listeners = $this->getListeners($eventName);
}
if ($listeners) {
$this->callListeners($listeners, $eventName, $event);
}
return $event;
} | php | public function dispatch($event/*, string $eventName = null*/)
{
$eventName = 1 < \func_num_args() ? \func_get_arg(1) : null;
if (\is_object($event)) {
$eventName = $eventName ?? \get_class($event);
} else {
@trigger_error(sprintf('Calling the "%s::dispatch()" method with the event name as first argument is deprecated since Symfony 4.3, pass it second and provide the event object first instead.', EventDispatcherInterface::class), E_USER_DEPRECATED);
$swap = $event;
$event = $eventName ?? new Event();
$eventName = $swap;
if (!$event instanceof Event) {
throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an instance of %s, %s given.', EventDispatcherInterface::class, Event::class, \is_object($event) ? \get_class($event) : \gettype($event)));
}
}
if (null !== $this->optimized && null !== $eventName) {
$listeners = $this->optimized[$eventName] ?? (empty($this->listeners[$eventName]) ? [] : $this->optimizeListeners($eventName));
} else {
$listeners = $this->getListeners($eventName);
}
if ($listeners) {
$this->callListeners($listeners, $eventName, $event);
}
return $event;
} | [
"public",
"function",
"dispatch",
"(",
"$",
"event",
"/*, string $eventName = null*/",
")",
"{",
"$",
"eventName",
"=",
"1",
"<",
"\\",
"func_num_args",
"(",
")",
"?",
"\\",
"func_get_arg",
"(",
"1",
")",
":",
"null",
";",
"if",
"(",
"\\",
"is_object",
"... | {@inheritdoc}
@param string|null $eventName | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/EventDispatcher/EventDispatcher.php#L51-L79 | train | Dispatches an event to all listeners | [
30522,
2270,
3853,
18365,
1006,
1002,
2724,
1013,
1008,
1010,
5164,
1002,
2724,
18442,
1027,
19701,
1008,
1013,
1007,
1063,
1002,
2724,
18442,
1027,
1015,
1026,
1032,
4569,
2278,
1035,
16371,
2213,
1035,
12098,
5620,
1006,
1007,
1029,
1032,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php | FormHelper.setTheme | public function setTheme(FormView $view, $themes, $useDefaultThemes = true)
{
$this->renderer->setTheme($view, $themes, $useDefaultThemes);
} | php | public function setTheme(FormView $view, $themes, $useDefaultThemes = true)
{
$this->renderer->setTheme($view, $themes, $useDefaultThemes);
} | [
"public",
"function",
"setTheme",
"(",
"FormView",
"$",
"view",
",",
"$",
"themes",
",",
"$",
"useDefaultThemes",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"renderer",
"->",
"setTheme",
"(",
"$",
"view",
",",
"$",
"themes",
",",
"$",
"useDefaultThemes",
... | Sets a theme for a given view.
The theme format is "<Bundle>:<Controller>".
@param FormView $view A FormView instance
@param string|array $themes A theme or an array of theme
@param bool $useDefaultThemes If true, will use default themes defined in the renderer | [
"Sets",
"a",
"theme",
"for",
"a",
"given",
"view",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php#L54-L57 | train | Set the theme of the form | [
30522,
2270,
3853,
2275,
10760,
4168,
1006,
2433,
8584,
1002,
3193,
1010,
1002,
6991,
1010,
1002,
2109,
12879,
23505,
10760,
7834,
1027,
2995,
1007,
1063,
1002,
2023,
1011,
1028,
17552,
2121,
1011,
1028,
2275,
10760,
4168,
1006,
1002,
3193,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Protocol/TMultiplexedProtocol.php | TMultiplexedProtocol.writeMessageBegin | public function writeMessageBegin($name, $type, $seqid)
{
if ($type == TMessageType::CALL || $type == TMessageType::ONEWAY) {
$nameWithService = $this->serviceName_ . self::SEPARATOR . $name;
parent::writeMessageBegin($nameWithService, $type, $seqid);
} else {
parent::writeMessageBegin($name, $type, $seqid);
}
} | php | public function writeMessageBegin($name, $type, $seqid)
{
if ($type == TMessageType::CALL || $type == TMessageType::ONEWAY) {
$nameWithService = $this->serviceName_ . self::SEPARATOR . $name;
parent::writeMessageBegin($nameWithService, $type, $seqid);
} else {
parent::writeMessageBegin($name, $type, $seqid);
}
} | [
"public",
"function",
"writeMessageBegin",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"seqid",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"TMessageType",
"::",
"CALL",
"||",
"$",
"type",
"==",
"TMessageType",
"::",
"ONEWAY",
")",
"{",
"$",
"nameWithSer... | Writes the message header.
Prepends the service name to the function name, separated by <code>TMultiplexedProtocol::SEPARATOR</code>.
@param string $name Function name.
@param int $type Message type.
@param int $seqid The sequence id of this message. | [
"Writes",
"the",
"message",
"header",
".",
"Prepends",
"the",
"service",
"name",
"to",
"the",
"function",
"name",
"separated",
"by",
"<code",
">",
"TMultiplexedProtocol",
"::",
"SEPARATOR<",
"/",
"code",
">",
"."
] | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Protocol/TMultiplexedProtocol.php#L76-L84 | train | WriteMessageBegin implements the interface method. | [
30522,
2270,
3853,
4339,
7834,
3736,
3351,
4783,
11528,
1006,
1002,
2171,
1010,
1002,
2828,
1010,
1002,
7367,
14702,
2094,
1007,
1063,
2065,
1006,
1002,
2828,
1027,
1027,
1056,
7834,
3736,
18150,
18863,
1024,
1024,
2655,
1064,
1064,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/CombineAssets.php | CombineAssets.registerBundle | public function registerBundle($files, $destination = null, $extension = null)
{
if (!is_array($files)) {
$files = [$files];
}
$firstFile = array_values($files)[0];
if ($extension === null) {
$extension = File::extension($firstFile);
}
$extension = strtolower(trim($extension));
if ($destination === null) {
$file = File::name($firstFile);
$path = dirname($firstFile);
$preprocessors = array_diff(self::$cssExtensions, ['css']);
if (in_array($extension, $preprocessors)) {
$cssPath = $path.'/../css';
if (
in_array(strtolower(basename($path)), $preprocessors) &&
File::isDirectory(File::symbolizePath($cssPath))
) {
$path = $cssPath;
}
$destination = $path.'/'.$file.'.css';
}
else {
$destination = $path.'/'.$file.'-min.'.$extension;
}
}
$this->bundles[$extension][$destination] = $files;
return $this;
} | php | public function registerBundle($files, $destination = null, $extension = null)
{
if (!is_array($files)) {
$files = [$files];
}
$firstFile = array_values($files)[0];
if ($extension === null) {
$extension = File::extension($firstFile);
}
$extension = strtolower(trim($extension));
if ($destination === null) {
$file = File::name($firstFile);
$path = dirname($firstFile);
$preprocessors = array_diff(self::$cssExtensions, ['css']);
if (in_array($extension, $preprocessors)) {
$cssPath = $path.'/../css';
if (
in_array(strtolower(basename($path)), $preprocessors) &&
File::isDirectory(File::symbolizePath($cssPath))
) {
$path = $cssPath;
}
$destination = $path.'/'.$file.'.css';
}
else {
$destination = $path.'/'.$file.'-min.'.$extension;
}
}
$this->bundles[$extension][$destination] = $files;
return $this;
} | [
"public",
"function",
"registerBundle",
"(",
"$",
"files",
",",
"$",
"destination",
"=",
"null",
",",
"$",
"extension",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"files",
")",
")",
"{",
"$",
"files",
"=",
"[",
"$",
"files",
"]",
... | Registers bundle.
@param string|array $files Files to be registered to bundle
@param string $destination Destination file will be compiled to.
@param string $extension Extension name. Eg: css
@return self | [
"Registers",
"bundle",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L631-L668 | train | Registers a bundle | [
30522,
2270,
3853,
4236,
27265,
2571,
1006,
1002,
6764,
1010,
1002,
7688,
1027,
19701,
1010,
1002,
5331,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
6764,
1007,
1007,
1063,
1002,
6764,
1027,
1031,
1002,
6764,
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/Mailer/Transport/AbstractTransport.php | AbstractTransport.setMaxPerSecond | public function setMaxPerSecond(float $rate): self
{
if (0 >= $rate) {
$rate = 0;
}
$this->rate = $rate;
$this->lastSent = 0;
return $this;
} | php | public function setMaxPerSecond(float $rate): self
{
if (0 >= $rate) {
$rate = 0;
}
$this->rate = $rate;
$this->lastSent = 0;
return $this;
} | [
"public",
"function",
"setMaxPerSecond",
"(",
"float",
"$",
"rate",
")",
":",
"self",
"{",
"if",
"(",
"0",
">=",
"$",
"rate",
")",
"{",
"$",
"rate",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"rate",
"=",
"$",
"rate",
";",
"$",
"this",
"->",
"lastS... | Sets the maximum number of messages to send per second (0 to disable). | [
"Sets",
"the",
"maximum",
"number",
"of",
"messages",
"to",
"send",
"per",
"second",
"(",
"0",
"to",
"disable",
")",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mailer/Transport/AbstractTransport.php#L46-L56 | train | Set the maximum number of seconds per second | [
30522,
2270,
3853,
2275,
17848,
7347,
8586,
15422,
1006,
14257,
1002,
3446,
1007,
1024,
2969,
1063,
2065,
1006,
1014,
1028,
1027,
1002,
3446,
1007,
1063,
1002,
3446,
1027,
1014,
1025,
1065,
1002,
2023,
1011,
1028,
3446,
1027,
1002,
3446,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DebugFormatterHelper.php | DebugFormatterHelper.stop | public function stop($id, $message, $successful, $prefix = 'RES')
{
$trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
if ($successful) {
return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
}
$message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
unset($this->started[$id]['out'], $this->started[$id]['err']);
return $message;
} | php | public function stop($id, $message, $successful, $prefix = 'RES')
{
$trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
if ($successful) {
return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
}
$message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
unset($this->started[$id]['out'], $this->started[$id]['err']);
return $message;
} | [
"public",
"function",
"stop",
"(",
"$",
"id",
",",
"$",
"message",
",",
"$",
"successful",
",",
"$",
"prefix",
"=",
"'RES'",
")",
"{",
"$",
"trailingEOL",
"=",
"isset",
"(",
"$",
"this",
"->",
"started",
"[",
"$",
"id",
"]",
"[",
"'out'",
"]",
")... | Stops a formatting session.
@param string $id The id of the formatting session
@param string $message The message to display
@param bool $successful Whether to consider the result as success
@param string $prefix The prefix for the end output
@return string | [
"Stops",
"a",
"formatting",
"session",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/DebugFormatterHelper.php#L95-L108 | train | Stops the process | [
30522,
2270,
3853,
2644,
1006,
1002,
8909,
1010,
1002,
4471,
1010,
1002,
3144,
1010,
1002,
17576,
1027,
1005,
24501,
1005,
1007,
1063,
1002,
12542,
8780,
2140,
1027,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2318,
1031,
1002,
8909,
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... |
z-song/laravel-admin | src/Traits/HasAssets.php | HasAssets.js | public static function js($js = null)
{
if (!is_null($js)) {
return self::$js = array_merge(self::$js, (array) $js);
}
if (!$js = static::getMinifiedJs()) {
$js = array_merge(static::baseJs(), static::$js);
}
$js = array_filter(array_unique($js));
return view('admin::partials.js', compact('js'));
} | php | public static function js($js = null)
{
if (!is_null($js)) {
return self::$js = array_merge(self::$js, (array) $js);
}
if (!$js = static::getMinifiedJs()) {
$js = array_merge(static::baseJs(), static::$js);
}
$js = array_filter(array_unique($js));
return view('admin::partials.js', compact('js'));
} | [
"public",
"static",
"function",
"js",
"(",
"$",
"js",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"js",
")",
")",
"{",
"return",
"self",
"::",
"$",
"js",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"js",
",",
"(",
"array",
")",
... | Add js or get all js.
@param null $js
@return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"Add",
"js",
"or",
"get",
"all",
"js",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Traits/HasAssets.php#L129-L142 | train | Get js array | [
30522,
2270,
10763,
3853,
1046,
2015,
1006,
1002,
1046,
2015,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
1046,
2015,
1007,
1007,
1063,
2709,
2969,
1024,
1024,
1002,
1046,
2015,
1027,
9140,
1035,
13590,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Payment/Kernel/BaseClient.php | BaseClient.safeRequest | protected function safeRequest($endpoint, array $params, $method = 'post', array $options = [])
{
$options = array_merge([
'cert' => $this->app['config']->get('cert_path'),
'ssl_key' => $this->app['config']->get('key_path'),
], $options);
return $this->request($endpoint, $params, $method, $options);
} | php | protected function safeRequest($endpoint, array $params, $method = 'post', array $options = [])
{
$options = array_merge([
'cert' => $this->app['config']->get('cert_path'),
'ssl_key' => $this->app['config']->get('key_path'),
], $options);
return $this->request($endpoint, $params, $method, $options);
} | [
"protected",
"function",
"safeRequest",
"(",
"$",
"endpoint",
",",
"array",
"$",
"params",
",",
"$",
"method",
"=",
"'post'",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"[",
"'cert'",
"=>",
"$",
"t... | Request with SSL.
@param string $endpoint
@param array $params
@param string $method
@param array $options
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException | [
"Request",
"with",
"SSL",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Kernel/BaseClient.php#L146-L154 | train | Safe request to use SSL | [
30522,
5123,
3853,
13726,
2063,
15500,
1006,
1002,
2203,
8400,
1010,
9140,
1002,
11498,
5244,
1010,
1002,
4118,
1027,
1005,
2695,
1005,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
7047,
1027,
9140,
1035,
13590,
1006,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.makeListColumn | protected function makeListColumn($name, $config)
{
if (is_string($config)) {
$label = $config;
}
elseif (isset($config['label'])) {
$label = $config['label'];
}
else {
$label = studly_case($name);
}
/*
* Auto configure pivot relation
*/
if (starts_with($name, 'pivot[') && strpos($name, ']') !== false) {
$_name = HtmlHelper::nameToArray($name);
$relationName = array_shift($_name);
$valueFrom = array_shift($_name);
if (count($_name) > 0) {
$valueFrom .= '['.implode('][', $_name).']';
}
$config['relation'] = $relationName;
$config['valueFrom'] = $valueFrom;
$config['searchable'] = false;
}
/*
* Auto configure standard relation
*/
elseif (strpos($name, '[') !== false && strpos($name, ']') !== false) {
$config['valueFrom'] = $name;
$config['sortable'] = false;
$config['searchable'] = false;
}
$columnType = $config['type'] ?? null;
$column = new ListColumn($name, $label);
$column->displayAs($columnType, $config);
return $column;
} | php | protected function makeListColumn($name, $config)
{
if (is_string($config)) {
$label = $config;
}
elseif (isset($config['label'])) {
$label = $config['label'];
}
else {
$label = studly_case($name);
}
/*
* Auto configure pivot relation
*/
if (starts_with($name, 'pivot[') && strpos($name, ']') !== false) {
$_name = HtmlHelper::nameToArray($name);
$relationName = array_shift($_name);
$valueFrom = array_shift($_name);
if (count($_name) > 0) {
$valueFrom .= '['.implode('][', $_name).']';
}
$config['relation'] = $relationName;
$config['valueFrom'] = $valueFrom;
$config['searchable'] = false;
}
/*
* Auto configure standard relation
*/
elseif (strpos($name, '[') !== false && strpos($name, ']') !== false) {
$config['valueFrom'] = $name;
$config['sortable'] = false;
$config['searchable'] = false;
}
$columnType = $config['type'] ?? null;
$column = new ListColumn($name, $label);
$column->displayAs($columnType, $config);
return $column;
} | [
"protected",
"function",
"makeListColumn",
"(",
"$",
"name",
",",
"$",
"config",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"config",
")",
")",
"{",
"$",
"label",
"=",
"$",
"config",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"config",
"[",
"'lab... | Creates a list column object from it's name and configuration. | [
"Creates",
"a",
"list",
"column",
"object",
"from",
"it",
"s",
"name",
"and",
"configuration",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L864-L907 | train | Create ListColumn object | [
30522,
5123,
3853,
2191,
9863,
25778,
2819,
2078,
1006,
1002,
2171,
1010,
1002,
9530,
8873,
2290,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
9530,
8873,
2290,
1007,
1007,
1063,
1002,
3830,
1027,
1002,
9530,
8873,
2290,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Validator.php | Validator.addRules | public function addRules($rules)
{
// The primary purpose of this parser is to expand any "*" rules to the all
// of the explicit rules needed for the given data. For example the rule
// names.* would get expanded to names.0, names.1, etc. for this data.
$response = (new ValidationRuleParser($this->data))
->explode($rules);
$this->rules = array_merge_recursive(
$this->rules, $response->rules
);
$this->implicitAttributes = array_merge(
$this->implicitAttributes, $response->implicitAttributes
);
} | php | public function addRules($rules)
{
// The primary purpose of this parser is to expand any "*" rules to the all
// of the explicit rules needed for the given data. For example the rule
// names.* would get expanded to names.0, names.1, etc. for this data.
$response = (new ValidationRuleParser($this->data))
->explode($rules);
$this->rules = array_merge_recursive(
$this->rules, $response->rules
);
$this->implicitAttributes = array_merge(
$this->implicitAttributes, $response->implicitAttributes
);
} | [
"public",
"function",
"addRules",
"(",
"$",
"rules",
")",
"{",
"// The primary purpose of this parser is to expand any \"*\" rules to the all",
"// of the explicit rules needed for the given data. For example the rule",
"// names.* would get expanded to names.0, names.1, etc. for this data.",
... | Parse the given rules and merge them into current rules.
@param array $rules
@return void | [
"Parse",
"the",
"given",
"rules",
"and",
"merge",
"them",
"into",
"current",
"rules",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Validator.php#L834-L849 | train | Add rules to the all explicit rules needed for this data | [
30522,
2270,
3853,
5587,
6820,
4244,
1006,
1002,
3513,
1007,
1063,
1013,
1013,
1996,
3078,
3800,
1997,
2023,
11968,
8043,
2003,
2000,
7818,
2151,
1000,
1008,
1000,
3513,
2000,
1996,
2035,
1013,
1013,
1997,
1996,
13216,
3513,
2734,
2005,
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/OfficialAccount/Card/Client.php | Client.setPayCell | public function setPayCell($cardId, $isOpen = true)
{
$params = [
'card_id' => $cardId,
'is_open' => $isOpen,
];
return $this->httpPostJson('card/paycell/set', $params);
} | php | public function setPayCell($cardId, $isOpen = true)
{
$params = [
'card_id' => $cardId,
'is_open' => $isOpen,
];
return $this->httpPostJson('card/paycell/set', $params);
} | [
"public",
"function",
"setPayCell",
"(",
"$",
"cardId",
",",
"$",
"isOpen",
"=",
"true",
")",
"{",
"$",
"params",
"=",
"[",
"'card_id'",
"=>",
"$",
"cardId",
",",
"'is_open'",
"=>",
"$",
"isOpen",
",",
"]",
";",
"return",
"$",
"this",
"->",
"httpPost... | 设置微信买单接口.
设置买单的 card_id 必须已经配置了门店,否则会报错.
@param string $cardId
@param bool $isOpen
@return mixed | [
"设置微信买单接口",
".",
"设置买单的",
"card_id",
"必须已经配置了门店,否则会报错",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Card/Client.php#L304-L312 | train | Set Paycell for card | [
30522,
2270,
3853,
2275,
4502,
29297,
3363,
1006,
1002,
4003,
3593,
1010,
1002,
11163,
11837,
1027,
2995,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
4003,
1035,
8909,
1005,
1027,
1028,
1002,
4003,
3593,
1010,
1005,
2003,
1035,
2330,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.decrement | public function decrement($key, $value = 1)
{
return $this->connection()->decrby($this->prefix.$key, $value);
} | php | public function decrement($key, $value = 1)
{
return $this->connection()->decrby($this->prefix.$key, $value);
} | [
"public",
"function",
"decrement",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"(",
")",
"->",
"decrby",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Decrement the value of an item in the cache.
@param string $key
@param mixed $value
@return int | [
"Decrement",
"the",
"value",
"of",
"an",
"item",
"in",
"the",
"cache",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/RedisStore.php#L157-L160 | train | Decrement value of key | [
30522,
2270,
3853,
11703,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
3643,
1027,
1015,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4434,
1006,
1007,
1011,
1028,
11703,
15185,
2100,
1006,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
3145,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/TraceableValueResolver.php | TraceableValueResolver.resolve | public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
$method = \get_class($this->inner).'::'.__FUNCTION__;
$this->stopwatch->start($method, 'controller.argument_value_resolver');
yield from $this->inner->resolve($request, $argument);
$this->stopwatch->stop($method);
} | php | public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
$method = \get_class($this->inner).'::'.__FUNCTION__;
$this->stopwatch->start($method, 'controller.argument_value_resolver');
yield from $this->inner->resolve($request, $argument);
$this->stopwatch->stop($method);
} | [
"public",
"function",
"resolve",
"(",
"Request",
"$",
"request",
",",
"ArgumentMetadata",
"$",
"argument",
")",
":",
"iterable",
"{",
"$",
"method",
"=",
"\\",
"get_class",
"(",
"$",
"this",
"->",
"inner",
")",
".",
"'::'",
".",
"__FUNCTION__",
";",
"$",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/TraceableValueResolver.php#L53-L61 | train | Resolves the request and argument metadata to a value. | [
30522,
2270,
3853,
10663,
1006,
5227,
1002,
5227,
1010,
6685,
11368,
8447,
2696,
1002,
6685,
1007,
1024,
2009,
6906,
3468,
1063,
1002,
4118,
1027,
1032,
2131,
1035,
2465,
1006,
1002,
2023,
1011,
1028,
5110,
1007,
1012,
1005,
1024,
1024,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/helpers/Cms.php | Cms.url | public function url($path = null)
{
$routeAction = 'Cms\Classes\CmsController@run';
if (self::$actionExists === null) {
self::$actionExists = Route::getRoutes()->getByAction($routeAction) !== null;
}
if (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
if (self::$actionExists) {
return Url::action($routeAction, ['slug' => $path]);
}
return Url::to($path);
} | php | public function url($path = null)
{
$routeAction = 'Cms\Classes\CmsController@run';
if (self::$actionExists === null) {
self::$actionExists = Route::getRoutes()->getByAction($routeAction) !== null;
}
if (substr($path, 0, 1) == '/') {
$path = substr($path, 1);
}
if (self::$actionExists) {
return Url::action($routeAction, ['slug' => $path]);
}
return Url::to($path);
} | [
"public",
"function",
"url",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"routeAction",
"=",
"'Cms\\Classes\\CmsController@run'",
";",
"if",
"(",
"self",
"::",
"$",
"actionExists",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"actionExists",
"=",
"Route",... | Returns a URL in context of the Frontend | [
"Returns",
"a",
"URL",
"in",
"context",
"of",
"the",
"Frontend"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/helpers/Cms.php#L20-L37 | train | Returns the url to the requested path | [
30522,
2270,
3853,
24471,
2140,
1006,
1002,
4130,
1027,
19701,
1007,
1063,
1002,
2799,
18908,
3258,
1027,
1005,
4642,
2015,
1032,
4280,
1032,
4642,
9363,
3372,
26611,
1030,
2448,
1005,
1025,
2065,
1006,
2969,
1024,
1024,
1002,
2895,
10288,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/formwidgets/Repeater.php | Repeater.makeItemFormWidget | protected function makeItemFormWidget($index = 0, $groupCode = null)
{
$configDefinition = $this->useGroups
? $this->getGroupFormFieldConfig($groupCode)
: $this->form;
$config = $this->makeConfig($configDefinition);
$config->model = $this->model;
$config->data = $this->getLoadValueFromIndex($index);
$config->alias = $this->alias . 'Form'.$index;
$config->arrayName = $this->getFieldName().'['.$index.']';
$config->isNested = true;
$widget = $this->makeWidget('Backend\Widgets\Form', $config);
$widget->bindToController();
$this->indexMeta[$index] = [
'groupCode' => $groupCode
];
return $this->formWidgets[$index] = $widget;
} | php | protected function makeItemFormWidget($index = 0, $groupCode = null)
{
$configDefinition = $this->useGroups
? $this->getGroupFormFieldConfig($groupCode)
: $this->form;
$config = $this->makeConfig($configDefinition);
$config->model = $this->model;
$config->data = $this->getLoadValueFromIndex($index);
$config->alias = $this->alias . 'Form'.$index;
$config->arrayName = $this->getFieldName().'['.$index.']';
$config->isNested = true;
$widget = $this->makeWidget('Backend\Widgets\Form', $config);
$widget->bindToController();
$this->indexMeta[$index] = [
'groupCode' => $groupCode
];
return $this->formWidgets[$index] = $widget;
} | [
"protected",
"function",
"makeItemFormWidget",
"(",
"$",
"index",
"=",
"0",
",",
"$",
"groupCode",
"=",
"null",
")",
"{",
"$",
"configDefinition",
"=",
"$",
"this",
"->",
"useGroups",
"?",
"$",
"this",
"->",
"getGroupFormFieldConfig",
"(",
"$",
"groupCode",
... | Creates a form widget based on a field index and optional group code.
@param int $index
@param string $index
@return \Backend\Widgets\Form | [
"Creates",
"a",
"form",
"widget",
"based",
"on",
"a",
"field",
"index",
"and",
"optional",
"group",
"code",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/Repeater.php#L259-L280 | train | Make item form widget | [
30522,
5123,
3853,
2191,
4221,
2213,
14192,
9148,
24291,
1006,
1002,
5950,
1027,
1014,
1010,
1002,
2177,
16044,
1027,
19701,
1007,
1063,
1002,
9530,
8873,
2290,
3207,
16294,
22753,
1027,
1002,
2023,
1011,
1028,
2224,
17058,
2015,
1029,
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/Common/Page/Collection.php | Collection.ofType | public function ofType($type)
{
$items = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->template() === $type) {
$items[$path] = $slug;
}
}
$this->items = $items;
return $this;
} | php | public function ofType($type)
{
$items = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->template() === $type) {
$items[$path] = $slug;
}
}
$this->items = $items;
return $this;
} | [
"public",
"function",
"ofType",
"(",
"$",
"type",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"path",
"=>",
"$",
"slug",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"pages",
"->",
"get",... | Creates new collection with only pages of the specified type
@param string $type
@return Collection The collection | [
"Creates",
"new",
"collection",
"with",
"only",
"pages",
"of",
"the",
"specified",
"type"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Collection.php#L523-L537 | train | Set the pages of a certain type | [
30522,
2270,
3853,
1997,
13874,
1006,
1002,
2828,
1007,
1063,
1002,
5167,
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,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Db2.php | Zend_Db_Adapter_Db2.prepare | public function prepare($sql)
{
$this->_connect();
$stmtClass = $this->_defaultStmtClass;
if (!class_exists($stmtClass)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($stmtClass);
}
$stmt = new $stmtClass($this, $sql);
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
} | php | public function prepare($sql)
{
$this->_connect();
$stmtClass = $this->_defaultStmtClass;
if (!class_exists($stmtClass)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($stmtClass);
}
$stmt = new $stmtClass($this, $sql);
$stmt->setFetchMode($this->_fetchMode);
return $stmt;
} | [
"public",
"function",
"prepare",
"(",
"$",
"sql",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"$",
"stmtClass",
"=",
"$",
"this",
"->",
"_defaultStmtClass",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"stmtClass",
")",
")",
"{",
"// re... | Returns an SQL statement for preparation.
@param string $sql The SQL statement with placeholders.
@return Zend_Db_Statement_Db2 | [
"Returns",
"an",
"SQL",
"statement",
"for",
"preparation",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Db2.php#L230-L241 | train | Prepare statement for execution | [
30522,
2270,
3853,
7374,
1006,
1002,
29296,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1002,
2358,
20492,
26266,
1027,
1002,
2023,
1011,
1028,
1035,
12398,
3367,
20492,
26266,
1025,
2065,
1006,
999,
2465,
1035,
6526,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/API/Proxy.php | Proxy.checkMethodExists | private function checkMethodExists($className, $methodName)
{
if (!$this->isMethodAvailable($className, $methodName)) {
throw new Exception(Piwik::translate('General_ExceptionMethodNotFound', array($methodName, $className)));
}
} | php | private function checkMethodExists($className, $methodName)
{
if (!$this->isMethodAvailable($className, $methodName)) {
throw new Exception(Piwik::translate('General_ExceptionMethodNotFound', array($methodName, $className)));
}
} | [
"private",
"function",
"checkMethodExists",
"(",
"$",
"className",
",",
"$",
"methodName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isMethodAvailable",
"(",
"$",
"className",
",",
"$",
"methodName",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"... | Checks that the method exists in the class
@param string $className The class name
@param string $methodName The method name
@throws Exception If the method is not found | [
"Checks",
"that",
"the",
"method",
"exists",
"in",
"the",
"class"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/Proxy.php#L490-L495 | train | Check if a method exists in the class. | [
30522,
2797,
3853,
4638,
11368,
6806,
3207,
9048,
12837,
1006,
1002,
2465,
18442,
1010,
1002,
4118,
18442,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2003,
11368,
6806,
29045,
12502,
3085,
1006,
1002,
2465,
18442,
1010,
1002,
4118... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php | ConditionallyLoadsAttributes.whenLoaded | protected function whenLoaded($relationship, $value = null, $default = null)
{
if (func_num_args() < 3) {
$default = new MissingValue;
}
if (! $this->resource->relationLoaded($relationship)) {
return value($default);
}
if (func_num_args() === 1) {
return $this->resource->{$relationship};
}
if ($this->resource->{$relationship} === null) {
return;
}
return value($value);
} | php | protected function whenLoaded($relationship, $value = null, $default = null)
{
if (func_num_args() < 3) {
$default = new MissingValue;
}
if (! $this->resource->relationLoaded($relationship)) {
return value($default);
}
if (func_num_args() === 1) {
return $this->resource->{$relationship};
}
if ($this->resource->{$relationship} === null) {
return;
}
return value($value);
} | [
"protected",
"function",
"whenLoaded",
"(",
"$",
"relationship",
",",
"$",
"value",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"<",
"3",
")",
"{",
"$",
"default",
"=",
"new",
"MissingValue",
";",
"}... | Retrieve a relationship if it has been loaded.
@param string $relationship
@param mixed $value
@param mixed $default
@return \Illuminate\Http\Resources\MissingValue|mixed | [
"Retrieve",
"a",
"relationship",
"if",
"it",
"has",
"been",
"loaded",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Resources/ConditionallyLoadsAttributes.php#L155-L174 | train | When loaded returns the value of the relationship | [
30522,
5123,
3853,
2043,
17468,
1006,
1002,
3276,
1010,
1002,
3643,
1027,
19701,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
4569,
2278,
1035,
16371,
2213,
1035,
12098,
5620,
1006,
1007,
1026,
1017,
1007,
1063,
1002,
12398,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php | LoadConfiguration.bootstrap | public function bootstrap(Application $app)
{
$items = [];
// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
if (file_exists($cached = $app->getCachedConfigPath())) {
$items = require $cached;
$loadedFromCache = true;
}
// Next we will spin through all of the configuration files in the configuration
// directory and load each one into the repository. This will make all of the
// options available to the developer for use in various parts of this app.
$app->instance('config', $config = new Repository($items));
if (! isset($loadedFromCache)) {
$this->loadConfigurationFiles($app, $config);
}
// Finally, we will set the application's environment based on the configuration
// values that were loaded. We will pass a callback which will be used to get
// the environment in a web context where an "--env" switch is not present.
$app->detectEnvironment(function () use ($config) {
return $config->get('app.env', 'production');
});
date_default_timezone_set($config->get('app.timezone', 'UTC'));
mb_internal_encoding('UTF-8');
} | php | public function bootstrap(Application $app)
{
$items = [];
// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
if (file_exists($cached = $app->getCachedConfigPath())) {
$items = require $cached;
$loadedFromCache = true;
}
// Next we will spin through all of the configuration files in the configuration
// directory and load each one into the repository. This will make all of the
// options available to the developer for use in various parts of this app.
$app->instance('config', $config = new Repository($items));
if (! isset($loadedFromCache)) {
$this->loadConfigurationFiles($app, $config);
}
// Finally, we will set the application's environment based on the configuration
// values that were loaded. We will pass a callback which will be used to get
// the environment in a web context where an "--env" switch is not present.
$app->detectEnvironment(function () use ($config) {
return $config->get('app.env', 'production');
});
date_default_timezone_set($config->get('app.timezone', 'UTC'));
mb_internal_encoding('UTF-8');
} | [
"public",
"function",
"bootstrap",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"// First we will see if we have a cache configuration file. If we do, we'll load",
"// the configuration items from that file so that it is very quick. Otherwise",
"// we... | Bootstrap the given application.
@param \Illuminate\Contracts\Foundation\Application $app
@return void | [
"Bootstrap",
"the",
"given",
"application",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php#L20-L52 | train | Bootstraps the application. | [
30522,
2270,
3853,
6879,
6494,
2361,
1006,
4646,
1002,
10439,
1007,
1063,
1002,
5167,
1027,
1031,
1033,
1025,
1013,
1013,
2034,
2057,
2097,
2156,
2065,
2057,
2031,
1037,
17053,
9563,
5371,
1012,
2065,
2057,
2079,
1010,
2057,
1005,
2222,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TwigBundle/CacheWarmer/TemplateCacheWarmer.php | TemplateCacheWarmer.warmUp | public function warmUp($cacheDir)
{
if (null === $this->twig) {
$this->twig = $this->container->get('twig');
}
foreach ($this->iterator as $template) {
try {
$this->twig->loadTemplate($template);
} catch (Error $e) {
// problem during compilation, give up
// might be a syntax error or a non-Twig template
}
}
} | php | public function warmUp($cacheDir)
{
if (null === $this->twig) {
$this->twig = $this->container->get('twig');
}
foreach ($this->iterator as $template) {
try {
$this->twig->loadTemplate($template);
} catch (Error $e) {
// problem during compilation, give up
// might be a syntax error or a non-Twig template
}
}
} | [
"public",
"function",
"warmUp",
"(",
"$",
"cacheDir",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"twig",
")",
"{",
"$",
"this",
"->",
"twig",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'twig'",
")",
";",
"}",
"foreach",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php#L41-L55 | train | Warms up the twig template iterator | [
30522,
2270,
3853,
4010,
6279,
1006,
1002,
17053,
4305,
2099,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
1056,
16279,
1007,
1063,
1002,
2023,
1011,
1028,
1056,
16279,
1027,
1002,
2023,
1011,
1028,
11661,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Definition.php | Definition.setDecoratedService | public function setDecoratedService($id, $renamedId = null, $priority = 0)
{
if ($renamedId && $id === $renamedId) {
throw new InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
}
$this->changes['decorated_service'] = true;
if (null === $id) {
$this->decoratedService = null;
} else {
$this->decoratedService = [$id, $renamedId, (int) $priority];
}
return $this;
} | php | public function setDecoratedService($id, $renamedId = null, $priority = 0)
{
if ($renamedId && $id === $renamedId) {
throw new InvalidArgumentException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id));
}
$this->changes['decorated_service'] = true;
if (null === $id) {
$this->decoratedService = null;
} else {
$this->decoratedService = [$id, $renamedId, (int) $priority];
}
return $this;
} | [
"public",
"function",
"setDecoratedService",
"(",
"$",
"id",
",",
"$",
"renamedId",
"=",
"null",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"renamedId",
"&&",
"$",
"id",
"===",
"$",
"renamedId",
")",
"{",
"throw",
"new",
"InvalidArgument... | Sets the service that this service is decorating.
@param string|null $id The decorated service id, use null to remove decoration
@param string|null $renamedId The new decorated service id
@param int $priority The priority of decoration
@return $this
@throws InvalidArgumentException in case the decorated service id and the new decorated service id are equals | [
"Sets",
"the",
"service",
"that",
"this",
"service",
"is",
"decorating",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Definition.php#L138-L153 | train | Set the decorated service name | [
30522,
2270,
3853,
2275,
3207,
27108,
4383,
8043,
7903,
2063,
1006,
1002,
8909,
1010,
1002,
4096,
3593,
1027,
19701,
1010,
1002,
9470,
1027,
1014,
1007,
1063,
2065,
1006,
1002,
4096,
3593,
1004,
1004,
1002,
8909,
1027,
1027,
1027,
1002,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php | FormDataCollector.buildFinalFormTree | public function buildFinalFormTree(FormInterface $form, FormView $view)
{
$this->data['forms'][$form->getName()] = &$this->recursiveBuildFinalFormTree($form, $view, $this->data['forms_by_hash']);
} | php | public function buildFinalFormTree(FormInterface $form, FormView $view)
{
$this->data['forms'][$form->getName()] = &$this->recursiveBuildFinalFormTree($form, $view, $this->data['forms_by_hash']);
} | [
"public",
"function",
"buildFinalFormTree",
"(",
"FormInterface",
"$",
"form",
",",
"FormView",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'forms'",
"]",
"[",
"$",
"form",
"->",
"getName",
"(",
")",
"]",
"=",
"&",
"$",
"this",
"->",
"rec... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php#L213-L216 | train | Recursive build final form tree | [
30522,
2270,
3853,
3857,
16294,
2389,
14192,
13334,
1006,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
2433,
8584,
1002,
3193,
1007,
1063,
1002,
2023,
1011,
1028,
2951,
1031,
1005,
3596,
1005,
1033,
1031,
1002,
2433,
1011,
1028,
2131,
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... |
dompdf/dompdf | lib/html5lib/InputStream.php | HTML5_InputStream.getColumnOffset | public function getColumnOffset() {
// strrpos is weird, and the offset needs to be negative for what we
// want (i.e., the last \n before $this->char). This needs to not have
// one (to make it point to the next character, the one we want the
// position of) added to it because strrpos's behaviour includes the
// final offset byte.
$lastLine = strrpos($this->data, "\n", $this->char - 1 - strlen($this->data));
// However, for here we want the length up until the next byte to be
// processed, so add one to the current byte ($this->char).
if ($lastLine !== false) {
$findLengthOf = substr($this->data, $lastLine + 1, $this->char - 1 - $lastLine);
} else {
$findLengthOf = substr($this->data, 0, $this->char);
}
// Get the length for the string we need.
if (extension_loaded('iconv')) {
return iconv_strlen($findLengthOf, 'utf-8');
} elseif (extension_loaded('mbstring')) {
return mb_strlen($findLengthOf, 'utf-8');
} elseif (extension_loaded('xml')) {
return strlen(utf8_decode($findLengthOf));
} else {
$count = count_chars($findLengthOf);
// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
return array_sum(array_slice($count, 0, 0x80)) +
array_sum(array_slice($count, 0xC2, 0x33));
}
} | php | public function getColumnOffset() {
// strrpos is weird, and the offset needs to be negative for what we
// want (i.e., the last \n before $this->char). This needs to not have
// one (to make it point to the next character, the one we want the
// position of) added to it because strrpos's behaviour includes the
// final offset byte.
$lastLine = strrpos($this->data, "\n", $this->char - 1 - strlen($this->data));
// However, for here we want the length up until the next byte to be
// processed, so add one to the current byte ($this->char).
if ($lastLine !== false) {
$findLengthOf = substr($this->data, $lastLine + 1, $this->char - 1 - $lastLine);
} else {
$findLengthOf = substr($this->data, 0, $this->char);
}
// Get the length for the string we need.
if (extension_loaded('iconv')) {
return iconv_strlen($findLengthOf, 'utf-8');
} elseif (extension_loaded('mbstring')) {
return mb_strlen($findLengthOf, 'utf-8');
} elseif (extension_loaded('xml')) {
return strlen(utf8_decode($findLengthOf));
} else {
$count = count_chars($findLengthOf);
// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
return array_sum(array_slice($count, 0, 0x80)) +
array_sum(array_slice($count, 0xC2, 0x33));
}
} | [
"public",
"function",
"getColumnOffset",
"(",
")",
"{",
"// strrpos is weird, and the offset needs to be negative for what we",
"// want (i.e., the last \\n before $this->char). This needs to not have",
"// one (to make it point to the next character, the one we want the",
"// position of) added t... | Returns the current column of the current line that the tokenizer is at.
@return int | [
"Returns",
"the",
"current",
"column",
"of",
"the",
"current",
"line",
"that",
"the",
"tokenizer",
"is",
"at",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/InputStream.php#L185-L215 | train | Get the column offset for the current character | [
30522,
2270,
3853,
2131,
25778,
2819,
3630,
21807,
3388,
1006,
1007,
1063,
1013,
1013,
2358,
12171,
6873,
2015,
2003,
6881,
1010,
1998,
1996,
16396,
3791,
2000,
2022,
4997,
2005,
2054,
2057,
1013,
1013,
2215,
1006,
1045,
1012,
1041,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/CronArchive.php | CronArchive.run | public function run()
{
$timer = new Timer;
$this->logSection("START");
$this->logger->info("Starting Matomo reports archiving...");
$numWebsitesScheduled = $this->websites->getNumSites();
$numWebsitesArchived = 0;
$cliMulti = $this->makeCliMulti();
if ($this->maxConcurrentArchivers && $cliMulti->supportsAsync()) {
$numRunning = 0;
$processes = Process::getListOfRunningProcesses();
$instanceId = SettingsPiwik::getPiwikInstanceId();
foreach ($processes as $process) {
if (strpos($process, 'console core:archive') !== false &&
(!$instanceId
|| strpos($process, '--matomo-domain=' . $instanceId) !== false
|| strpos($process, '--matomo-domain="' . $instanceId . '"') !== false
|| strpos($process, '--matomo-domain=\'' . $instanceId . "'") !== false
|| strpos($process, '--piwik-domain=' . $instanceId) !== false
|| strpos($process, '--piwik-domain="' . $instanceId . '"') !== false
|| strpos($process, '--piwik-domain=\'' . $instanceId . "'") !== false)) {
$numRunning++;
}
}
if ($this->maxConcurrentArchivers < $numRunning) {
$this->logger->info(sprintf("Archiving will stop now because %s archivers are already running and max %s are supposed to run at once.", $numRunning, $this->maxConcurrentArchivers));
return;
} else {
$this->logger->info(sprintf("%s out of %s archivers running currently", $numRunning, $this->maxConcurrentArchivers));
}
}
do {
if ($this->isMaintenanceModeEnabled()) {
$this->logger->info("Archiving will stop now because maintenance mode is enabled");
return;
}
$idSite = $this->websites->getNextSiteId();
$numWebsitesArchived++;
if (null === $idSite) {
break;
}
if ($numWebsitesArchived > $numWebsitesScheduled) {
// this is needed because a cron:archive might run for example for 5 hours. Meanwhile 5 other
// `cron:archive` have been possibly started... this means meanwhile, within the 5 hours, the
// `list of SharedSiteIds` have been potentially emptied and filled again from the beginning.
// This means 5 hours later, even though all websites that were originally in the list have been
// finished by now, the `cron:archive` will stay active and continue processing because the list of
// siteIds to archive was resetted by another `cron:archive` command. Potentially some `cron:archive`
// will basically never end because by the time the `cron:archive` finishes, the sharedSideIds have
// been resettet. This can eventually lead to some random concurrency issues when there are like
// 40 `core:archive` active at the same time.
$this->logger->info("Stopping archiving as the initial list of websites has been processed.");
return;
}
flush();
$requestsBefore = $this->requests;
if ($idSite <= 0) {
continue;
}
$skipWebsiteForced = in_array($idSite, $this->shouldSkipSpecifiedSites);
if ($skipWebsiteForced) {
$this->logger->info("Skipped website id $idSite, found in --skip-idsites ");
$this->skipped++;
continue;
}
$shouldCheckIfArchivingIsNeeded = !$this->shouldArchiveSpecifiedSites && !$this->shouldArchiveAllSites && !$this->dateLastForced;
$hasWebsiteDayFinishedSinceLastRun = in_array($idSite, $this->websiteDayHasFinishedSinceLastRun);
$isOldReportInvalidatedForWebsite = $this->isOldReportInvalidatedForWebsite($idSite);
if ($shouldCheckIfArchivingIsNeeded) {
// if not specific sites and not all websites should be archived, we check whether we actually have
// to process the archives for this website (only if there were visits since midnight)
if (!$hasWebsiteDayFinishedSinceLastRun && !$isOldReportInvalidatedForWebsite) {
try {
if ($this->isWebsiteUsingTheTracker($idSite)) {
if(!$this->hadWebsiteTrafficSinceMidnightInTimezone($idSite)) {
$this->logger->info("Skipped website id $idSite as archiving is not needed");
$this->skippedDayNoRecentData++;
$this->skipped++;
continue;
}
} else {
$this->logger->info("- website id $idSite is not using the tracker");
}
} catch (UnexpectedWebsiteFoundException $e) {
$this->logger->info("Skipped website id $idSite, got: UnexpectedWebsiteFoundException");
continue;
}
} elseif ($hasWebsiteDayFinishedSinceLastRun) {
$this->logger->info("Day has finished for website id $idSite since last run");
} elseif ($isOldReportInvalidatedForWebsite) {
$this->logger->info("Old report was invalidated for website id $idSite");
}
}
/**
* This event is triggered before the cron archiving process starts archiving data for a single
* site.
*
* @param int $idSite The ID of the site we're archiving data for.
*/
Piwik::postEvent('CronArchive.archiveSingleSite.start', array($idSite));
$completed = $this->archiveSingleSite($idSite, $requestsBefore);
/**
* This event is triggered immediately after the cron archiving process starts archiving data for a single
* site.
*
* @param int $idSite The ID of the site we're archiving data for.
*/
Piwik::postEvent('CronArchive.archiveSingleSite.finish', array($idSite, $completed));
} while (!empty($idSite));
$this->logger->info("Done archiving!");
$this->logSection("SUMMARY");
$this->logger->info("Total visits for today across archived websites: " . $this->visitsToday);
$totalWebsites = count($this->allWebsites);
$this->skipped = $totalWebsites - $this->websitesWithVisitsSinceLastRun;
$this->logger->info("Archived today's reports for {$this->websitesWithVisitsSinceLastRun} websites");
$this->logger->info("Archived week/month/year for {$this->archivedPeriodsArchivesWebsite} websites");
$this->logger->info("Skipped {$this->skipped} websites");
$this->logger->info("- {$this->skippedDayNoRecentData} skipped because no new visit since the last script execution");
$this->logger->info("- {$this->skippedDayArchivesWebsites} skipped because existing daily reports are less than {$this->todayArchiveTimeToLive} seconds old");
$this->logger->info("- {$this->skippedPeriodsArchivesWebsite} skipped because existing week/month/year periods reports are less than {$this->processPeriodsMaximumEverySeconds} seconds old");
if($this->skippedPeriodsNoDataInPeriod) {
$this->logger->info("- {$this->skippedPeriodsNoDataInPeriod} skipped periods archiving because no visit in recent days");
}
if($this->skippedDayOnApiError) {
$this->logger->info("- {$this->skippedDayOnApiError} skipped because got an error while querying reporting API");
}
$this->logger->info("Total API requests: {$this->requests}");
//DONE: done/total, visits, wtoday, wperiods, reqs, time, errors[count]: first eg.
$percent = $this->websites->getNumSites() == 0
? ""
: " " . round($this->processed * 100 / $this->websites->getNumSites(), 0) . "%";
$this->logger->info("done: " .
$this->processed . "/" . $this->websites->getNumSites() . "" . $percent . ", " .
$this->visitsToday . " vtoday, $this->websitesWithVisitsSinceLastRun wtoday, {$this->archivedPeriodsArchivesWebsite} wperiods, " .
$this->requests . " req, " . round($timer->getTimeMs()) . " ms, " .
(empty($this->errors)
? self::NO_ERROR
: (count($this->errors) . " errors."))
);
$this->logger->info($timer->__toString());
} | php | public function run()
{
$timer = new Timer;
$this->logSection("START");
$this->logger->info("Starting Matomo reports archiving...");
$numWebsitesScheduled = $this->websites->getNumSites();
$numWebsitesArchived = 0;
$cliMulti = $this->makeCliMulti();
if ($this->maxConcurrentArchivers && $cliMulti->supportsAsync()) {
$numRunning = 0;
$processes = Process::getListOfRunningProcesses();
$instanceId = SettingsPiwik::getPiwikInstanceId();
foreach ($processes as $process) {
if (strpos($process, 'console core:archive') !== false &&
(!$instanceId
|| strpos($process, '--matomo-domain=' . $instanceId) !== false
|| strpos($process, '--matomo-domain="' . $instanceId . '"') !== false
|| strpos($process, '--matomo-domain=\'' . $instanceId . "'") !== false
|| strpos($process, '--piwik-domain=' . $instanceId) !== false
|| strpos($process, '--piwik-domain="' . $instanceId . '"') !== false
|| strpos($process, '--piwik-domain=\'' . $instanceId . "'") !== false)) {
$numRunning++;
}
}
if ($this->maxConcurrentArchivers < $numRunning) {
$this->logger->info(sprintf("Archiving will stop now because %s archivers are already running and max %s are supposed to run at once.", $numRunning, $this->maxConcurrentArchivers));
return;
} else {
$this->logger->info(sprintf("%s out of %s archivers running currently", $numRunning, $this->maxConcurrentArchivers));
}
}
do {
if ($this->isMaintenanceModeEnabled()) {
$this->logger->info("Archiving will stop now because maintenance mode is enabled");
return;
}
$idSite = $this->websites->getNextSiteId();
$numWebsitesArchived++;
if (null === $idSite) {
break;
}
if ($numWebsitesArchived > $numWebsitesScheduled) {
// this is needed because a cron:archive might run for example for 5 hours. Meanwhile 5 other
// `cron:archive` have been possibly started... this means meanwhile, within the 5 hours, the
// `list of SharedSiteIds` have been potentially emptied and filled again from the beginning.
// This means 5 hours later, even though all websites that were originally in the list have been
// finished by now, the `cron:archive` will stay active and continue processing because the list of
// siteIds to archive was resetted by another `cron:archive` command. Potentially some `cron:archive`
// will basically never end because by the time the `cron:archive` finishes, the sharedSideIds have
// been resettet. This can eventually lead to some random concurrency issues when there are like
// 40 `core:archive` active at the same time.
$this->logger->info("Stopping archiving as the initial list of websites has been processed.");
return;
}
flush();
$requestsBefore = $this->requests;
if ($idSite <= 0) {
continue;
}
$skipWebsiteForced = in_array($idSite, $this->shouldSkipSpecifiedSites);
if ($skipWebsiteForced) {
$this->logger->info("Skipped website id $idSite, found in --skip-idsites ");
$this->skipped++;
continue;
}
$shouldCheckIfArchivingIsNeeded = !$this->shouldArchiveSpecifiedSites && !$this->shouldArchiveAllSites && !$this->dateLastForced;
$hasWebsiteDayFinishedSinceLastRun = in_array($idSite, $this->websiteDayHasFinishedSinceLastRun);
$isOldReportInvalidatedForWebsite = $this->isOldReportInvalidatedForWebsite($idSite);
if ($shouldCheckIfArchivingIsNeeded) {
// if not specific sites and not all websites should be archived, we check whether we actually have
// to process the archives for this website (only if there were visits since midnight)
if (!$hasWebsiteDayFinishedSinceLastRun && !$isOldReportInvalidatedForWebsite) {
try {
if ($this->isWebsiteUsingTheTracker($idSite)) {
if(!$this->hadWebsiteTrafficSinceMidnightInTimezone($idSite)) {
$this->logger->info("Skipped website id $idSite as archiving is not needed");
$this->skippedDayNoRecentData++;
$this->skipped++;
continue;
}
} else {
$this->logger->info("- website id $idSite is not using the tracker");
}
} catch (UnexpectedWebsiteFoundException $e) {
$this->logger->info("Skipped website id $idSite, got: UnexpectedWebsiteFoundException");
continue;
}
} elseif ($hasWebsiteDayFinishedSinceLastRun) {
$this->logger->info("Day has finished for website id $idSite since last run");
} elseif ($isOldReportInvalidatedForWebsite) {
$this->logger->info("Old report was invalidated for website id $idSite");
}
}
/**
* This event is triggered before the cron archiving process starts archiving data for a single
* site.
*
* @param int $idSite The ID of the site we're archiving data for.
*/
Piwik::postEvent('CronArchive.archiveSingleSite.start', array($idSite));
$completed = $this->archiveSingleSite($idSite, $requestsBefore);
/**
* This event is triggered immediately after the cron archiving process starts archiving data for a single
* site.
*
* @param int $idSite The ID of the site we're archiving data for.
*/
Piwik::postEvent('CronArchive.archiveSingleSite.finish', array($idSite, $completed));
} while (!empty($idSite));
$this->logger->info("Done archiving!");
$this->logSection("SUMMARY");
$this->logger->info("Total visits for today across archived websites: " . $this->visitsToday);
$totalWebsites = count($this->allWebsites);
$this->skipped = $totalWebsites - $this->websitesWithVisitsSinceLastRun;
$this->logger->info("Archived today's reports for {$this->websitesWithVisitsSinceLastRun} websites");
$this->logger->info("Archived week/month/year for {$this->archivedPeriodsArchivesWebsite} websites");
$this->logger->info("Skipped {$this->skipped} websites");
$this->logger->info("- {$this->skippedDayNoRecentData} skipped because no new visit since the last script execution");
$this->logger->info("- {$this->skippedDayArchivesWebsites} skipped because existing daily reports are less than {$this->todayArchiveTimeToLive} seconds old");
$this->logger->info("- {$this->skippedPeriodsArchivesWebsite} skipped because existing week/month/year periods reports are less than {$this->processPeriodsMaximumEverySeconds} seconds old");
if($this->skippedPeriodsNoDataInPeriod) {
$this->logger->info("- {$this->skippedPeriodsNoDataInPeriod} skipped periods archiving because no visit in recent days");
}
if($this->skippedDayOnApiError) {
$this->logger->info("- {$this->skippedDayOnApiError} skipped because got an error while querying reporting API");
}
$this->logger->info("Total API requests: {$this->requests}");
//DONE: done/total, visits, wtoday, wperiods, reqs, time, errors[count]: first eg.
$percent = $this->websites->getNumSites() == 0
? ""
: " " . round($this->processed * 100 / $this->websites->getNumSites(), 0) . "%";
$this->logger->info("done: " .
$this->processed . "/" . $this->websites->getNumSites() . "" . $percent . ", " .
$this->visitsToday . " vtoday, $this->websitesWithVisitsSinceLastRun wtoday, {$this->archivedPeriodsArchivesWebsite} wperiods, " .
$this->requests . " req, " . round($timer->getTimeMs()) . " ms, " .
(empty($this->errors)
? self::NO_ERROR
: (count($this->errors) . " errors."))
);
$this->logger->info($timer->__toString());
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"timer",
"=",
"new",
"Timer",
";",
"$",
"this",
"->",
"logSection",
"(",
"\"START\"",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Starting Matomo reports archiving...\"",
")",
";",
"$",
"n... | Main function, runs archiving on all websites with new activity | [
"Main",
"function",
"runs",
"archiving",
"on",
"all",
"websites",
"with",
"new",
"activity"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L377-L543 | train | Archives all reports in the website. | [
30522,
2270,
3853,
2448,
1006,
1007,
1063,
1002,
25309,
1027,
2047,
25309,
1025,
1002,
2023,
1011,
1028,
15664,
18491,
1006,
1000,
2707,
1000,
1007,
1025,
1002,
2023,
1011,
1028,
8833,
4590,
1011,
1028,
18558,
1006,
1000,
3225,
13523,
19506... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/AudioMedium.php | AudioMedium.muted | public function muted($status = false)
{
if($status) {
$this->attributes['muted'] = true;
} else {
unset($this->attributes['muted']);
}
return $this;
} | php | public function muted($status = false)
{
if($status) {
$this->attributes['muted'] = true;
} else {
unset($this->attributes['muted']);
}
return $this;
} | [
"public",
"function",
"muted",
"(",
"$",
"status",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"status",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'muted'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"attributes",
... | Allows to set the muted attribute
@param bool $status
@return $this | [
"Allows",
"to",
"set",
"the",
"muted",
"attribute"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/AudioMedium.php#L89-L98 | train | Set muted attribute | [
30522,
2270,
3853,
22124,
1006,
1002,
3570,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
3570,
1007,
1063,
1002,
2023,
1011,
1028,
12332,
1031,
1005,
22124,
1005,
1033,
1027,
2995,
1025,
1065,
2842,
1063,
4895,
13462,
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... |
php-ai/php-ml | src/DimensionReduction/KernelPCA.php | KernelPCA.transform | public function transform(array $sample): array
{
if (!$this->fit) {
throw new InvalidOperationException('KernelPCA has not been fitted with respect to original dataset, please run KernelPCA::fit() first');
}
if (is_array($sample[0])) {
throw new InvalidArgumentException('KernelPCA::transform() accepts only one-dimensional arrays');
}
$pairs = $this->getDistancePairs($sample);
return $this->projectSample($pairs);
} | php | public function transform(array $sample): array
{
if (!$this->fit) {
throw new InvalidOperationException('KernelPCA has not been fitted with respect to original dataset, please run KernelPCA::fit() first');
}
if (is_array($sample[0])) {
throw new InvalidArgumentException('KernelPCA::transform() accepts only one-dimensional arrays');
}
$pairs = $this->getDistancePairs($sample);
return $this->projectSample($pairs);
} | [
"public",
"function",
"transform",
"(",
"array",
"$",
"sample",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fit",
")",
"{",
"throw",
"new",
"InvalidOperationException",
"(",
"'KernelPCA has not been fitted with respect to original dataset, please run K... | Transforms the given sample to a lower dimensional vector by using
the variables obtained during the last run of <code>fit</code>.
@throws InvalidArgumentException
@throws InvalidOperationException | [
"Transforms",
"the",
"given",
"sample",
"to",
"a",
"lower",
"dimensional",
"vector",
"by",
"using",
"the",
"variables",
"obtained",
"during",
"the",
"last",
"run",
"of",
"<code",
">",
"fit<",
"/",
"code",
">",
"."
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/DimensionReduction/KernelPCA.php#L103-L116 | train | KernelPCA transform - computes the distance matrix for the given sample | [
30522,
2270,
3853,
10938,
1006,
9140,
1002,
7099,
1007,
1024,
9140,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
4906,
1007,
1063,
5466,
2047,
19528,
25918,
3370,
10288,
24422,
1006,
1005,
16293,
15042,
2050,
2038,
2025,
2042,
7130,
2007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Pagination/AbstractPaginator.php | AbstractPaginator.appends | public function appends($key, $value = null)
{
if (is_null($key)) {
return $this;
}
if (is_array($key)) {
return $this->appendArray($key);
}
return $this->addQuery($key, $value);
} | php | public function appends($key, $value = null)
{
if (is_null($key)) {
return $this;
}
if (is_array($key)) {
return $this->appendArray($key);
}
return $this->addQuery($key, $value);
} | [
"public",
"function",
"appends",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"return",
... | Add a set of query string values to the paginator.
@param array|string|null $key
@param string|null $value
@return $this | [
"Add",
"a",
"set",
"of",
"query",
"string",
"values",
"to",
"the",
"paginator",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Pagination/AbstractPaginator.php#L205-L216 | train | Append a value to the query string | [
30522,
2270,
3853,
10439,
10497,
2015,
1006,
1002,
3145,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
3145,
1007,
1007,
1063,
2709,
1002,
2023,
1025,
1065,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php | TransDefaultDomainTokenParser.parse | public function parse(Token $token)
{
$expr = $this->parser->getExpressionParser()->parseExpression();
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
return new TransDefaultDomainNode($expr, $token->getLine(), $this->getTag());
} | php | public function parse(Token $token)
{
$expr = $this->parser->getExpressionParser()->parseExpression();
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
return new TransDefaultDomainNode($expr, $token->getLine(), $this->getTag());
} | [
"public",
"function",
"parse",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"expr",
"=",
"$",
"this",
"->",
"parser",
"->",
"getExpressionParser",
"(",
")",
"->",
"parseExpression",
"(",
")",
";",
"$",
"this",
"->",
"parser",
"->",
"getStream",
"(",
")",... | Parses a token and returns a node.
@return Node | [
"Parses",
"a",
"token",
"and",
"returns",
"a",
"node",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/TokenParser/TransDefaultDomainTokenParser.php#L31-L38 | train | Parse a TransDefaultDomainNode | [
30522,
2270,
3853,
11968,
3366,
1006,
19204,
1002,
19204,
1007,
1063,
1002,
4654,
18098,
1027,
1002,
2023,
1011,
1028,
11968,
8043,
1011,
1028,
2131,
10288,
20110,
3258,
19362,
8043,
1006,
1007,
1011,
1028,
11968,
19763,
2595,
20110,
3258,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php | AbstractObjectNormalizer.validateAndDenormalize | private function validateAndDenormalize(string $currentClass, string $attribute, $data, ?string $format, array $context)
{
if (null === $types = $this->getTypes($currentClass, $attribute)) {
return $data;
}
$expectedTypes = [];
foreach ($types as $type) {
if (null === $data && $type->isNullable()) {
return;
}
if ($type->isCollection() && null !== ($collectionValueType = $type->getCollectionValueType()) && Type::BUILTIN_TYPE_OBJECT === $collectionValueType->getBuiltinType()) {
$builtinType = Type::BUILTIN_TYPE_OBJECT;
$class = $collectionValueType->getClassName().'[]';
// Fix a collection that contains the only one element
// This is special to xml format only
if ('xml' === $format && !\is_int(key($data))) {
$data = [$data];
}
if (null !== $collectionKeyType = $type->getCollectionKeyType()) {
$context['key_type'] = $collectionKeyType;
}
} else {
$builtinType = $type->getBuiltinType();
$class = $type->getClassName();
}
$expectedTypes[Type::BUILTIN_TYPE_OBJECT === $builtinType && $class ? $class : $builtinType] = true;
if (Type::BUILTIN_TYPE_OBJECT === $builtinType) {
if (!$this->serializer instanceof DenormalizerInterface) {
throw new LogicException(sprintf('Cannot denormalize attribute "%s" for class "%s" because injected serializer is not a denormalizer', $attribute, $class));
}
$childContext = $this->createChildContext($context, $attribute, $format);
if ($this->serializer->supportsDenormalization($data, $class, $format, $childContext)) {
return $this->serializer->denormalize($data, $class, $format, $childContext);
}
}
// JSON only has a Number type corresponding to both int and float PHP types.
// PHP's json_encode, JavaScript's JSON.stringify, Go's json.Marshal as well as most other JSON encoders convert
// floating-point numbers like 12.0 to 12 (the decimal part is dropped when possible).
// PHP's json_decode automatically converts Numbers without a decimal part to integers.
// To circumvent this behavior, integers are converted to floats when denormalizing JSON based formats and when
// a float is expected.
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && \is_int($data) && false !== strpos($format, JsonEncoder::FORMAT)) {
return (float) $data;
}
if (('is_'.$builtinType)($data)) {
return $data;
}
}
if ($context[self::DISABLE_TYPE_ENFORCEMENT] ?? $this->defaultContext[self::DISABLE_TYPE_ENFORCEMENT] ?? false) {
return $data;
}
throw new NotNormalizableValueException(sprintf('The type of the "%s" attribute for class "%s" must be one of "%s" ("%s" given).', $attribute, $currentClass, implode('", "', array_keys($expectedTypes)), \gettype($data)));
} | php | private function validateAndDenormalize(string $currentClass, string $attribute, $data, ?string $format, array $context)
{
if (null === $types = $this->getTypes($currentClass, $attribute)) {
return $data;
}
$expectedTypes = [];
foreach ($types as $type) {
if (null === $data && $type->isNullable()) {
return;
}
if ($type->isCollection() && null !== ($collectionValueType = $type->getCollectionValueType()) && Type::BUILTIN_TYPE_OBJECT === $collectionValueType->getBuiltinType()) {
$builtinType = Type::BUILTIN_TYPE_OBJECT;
$class = $collectionValueType->getClassName().'[]';
// Fix a collection that contains the only one element
// This is special to xml format only
if ('xml' === $format && !\is_int(key($data))) {
$data = [$data];
}
if (null !== $collectionKeyType = $type->getCollectionKeyType()) {
$context['key_type'] = $collectionKeyType;
}
} else {
$builtinType = $type->getBuiltinType();
$class = $type->getClassName();
}
$expectedTypes[Type::BUILTIN_TYPE_OBJECT === $builtinType && $class ? $class : $builtinType] = true;
if (Type::BUILTIN_TYPE_OBJECT === $builtinType) {
if (!$this->serializer instanceof DenormalizerInterface) {
throw new LogicException(sprintf('Cannot denormalize attribute "%s" for class "%s" because injected serializer is not a denormalizer', $attribute, $class));
}
$childContext = $this->createChildContext($context, $attribute, $format);
if ($this->serializer->supportsDenormalization($data, $class, $format, $childContext)) {
return $this->serializer->denormalize($data, $class, $format, $childContext);
}
}
// JSON only has a Number type corresponding to both int and float PHP types.
// PHP's json_encode, JavaScript's JSON.stringify, Go's json.Marshal as well as most other JSON encoders convert
// floating-point numbers like 12.0 to 12 (the decimal part is dropped when possible).
// PHP's json_decode automatically converts Numbers without a decimal part to integers.
// To circumvent this behavior, integers are converted to floats when denormalizing JSON based formats and when
// a float is expected.
if (Type::BUILTIN_TYPE_FLOAT === $builtinType && \is_int($data) && false !== strpos($format, JsonEncoder::FORMAT)) {
return (float) $data;
}
if (('is_'.$builtinType)($data)) {
return $data;
}
}
if ($context[self::DISABLE_TYPE_ENFORCEMENT] ?? $this->defaultContext[self::DISABLE_TYPE_ENFORCEMENT] ?? false) {
return $data;
}
throw new NotNormalizableValueException(sprintf('The type of the "%s" attribute for class "%s" must be one of "%s" ("%s" given).', $attribute, $currentClass, implode('", "', array_keys($expectedTypes)), \gettype($data)));
} | [
"private",
"function",
"validateAndDenormalize",
"(",
"string",
"$",
"currentClass",
",",
"string",
"$",
"attribute",
",",
"$",
"data",
",",
"?",
"string",
"$",
"format",
",",
"array",
"$",
"context",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"types",
"="... | Validates the submitted data and denormalizes it.
@param mixed $data
@return mixed
@throws NotNormalizableValueException
@throws LogicException | [
"Validates",
"the",
"submitted",
"data",
"and",
"denormalizes",
"it",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php#L390-L453 | train | Validate and denormalize data | [
30522,
2797,
3853,
9398,
3686,
5685,
4181,
2953,
9067,
4697,
1006,
5164,
1002,
2783,
26266,
1010,
5164,
1002,
17961,
1010,
1002,
2951,
1010,
1029,
5164,
1002,
4289,
1010,
9140,
1002,
6123,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Goals/API.php | API.getItems | protected function getItems($recordName, $idSite, $period, $date, $abandonedCarts, $segment)
{
Piwik::checkUserHasViewAccess($idSite);
$recordNameFinal = $recordName;
if ($abandonedCarts) {
$recordNameFinal = Archiver::getItemRecordNameAbandonedCart($recordName);
}
$archive = Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTable($recordNameFinal);
$this->enrichItemsTableWithViewMetrics($dataTable, $recordName, $idSite, $period, $date, $segment);
// First rename the avg_price_viewed column
$renameColumn = array(self::AVG_PRICE_VIEWED => 'avg_price');
$dataTable->filter('ReplaceColumnNames', array($renameColumn));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
if ($abandonedCarts) {
$ordersColumn = 'abandoned_carts';
$dataTable->renameColumn(Metrics::INDEX_ECOMMERCE_ORDERS, $ordersColumn);
}
$dataTable->queueFilter('ColumnDelete', array('price'));
return $dataTable;
} | php | protected function getItems($recordName, $idSite, $period, $date, $abandonedCarts, $segment)
{
Piwik::checkUserHasViewAccess($idSite);
$recordNameFinal = $recordName;
if ($abandonedCarts) {
$recordNameFinal = Archiver::getItemRecordNameAbandonedCart($recordName);
}
$archive = Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTable($recordNameFinal);
$this->enrichItemsTableWithViewMetrics($dataTable, $recordName, $idSite, $period, $date, $segment);
// First rename the avg_price_viewed column
$renameColumn = array(self::AVG_PRICE_VIEWED => 'avg_price');
$dataTable->filter('ReplaceColumnNames', array($renameColumn));
$dataTable->queueFilter('ReplaceColumnNames');
$dataTable->queueFilter('ReplaceSummaryRowLabel');
if ($abandonedCarts) {
$ordersColumn = 'abandoned_carts';
$dataTable->renameColumn(Metrics::INDEX_ECOMMERCE_ORDERS, $ordersColumn);
}
$dataTable->queueFilter('ColumnDelete', array('price'));
return $dataTable;
} | [
"protected",
"function",
"getItems",
"(",
"$",
"recordName",
",",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"abandonedCarts",
",",
"$",
"segment",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"$",
... | Returns a datatable of Items SKU/name or categories and their metrics
If $abandonedCarts set to 1, will return items abandoned in carts. If set to 0, will return items ordered | [
"Returns",
"a",
"datatable",
"of",
"Items",
"SKU",
"/",
"name",
"or",
"categories",
"and",
"their",
"metrics",
"If",
"$abandonedCarts",
"set",
"to",
"1",
"will",
"return",
"items",
"abandoned",
"in",
"carts",
".",
"If",
"set",
"to",
"0",
"will",
"return",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Goals/API.php#L306-L335 | train | Get Items table | [
30522,
5123,
3853,
2131,
4221,
5244,
1006,
1002,
2501,
18442,
1010,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
4704,
10010,
3215,
1010,
1002,
6903,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php | HasRelationships.newHasOne | protected function newHasOne(Builder $query, Model $parent, $foreignKey, $localKey)
{
return new HasOne($query, $parent, $foreignKey, $localKey);
} | php | protected function newHasOne(Builder $query, Model $parent, $foreignKey, $localKey)
{
return new HasOne($query, $parent, $foreignKey, $localKey);
} | [
"protected",
"function",
"newHasOne",
"(",
"Builder",
"$",
"query",
",",
"Model",
"$",
"parent",
",",
"$",
"foreignKey",
",",
"$",
"localKey",
")",
"{",
"return",
"new",
"HasOne",
"(",
"$",
"query",
",",
"$",
"parent",
",",
"$",
"foreignKey",
",",
"$",... | Instantiate a new HasOne relationship.
@param \Illuminate\Database\Eloquent\Builder $query
@param \Illuminate\Database\Eloquent\Model $parent
@param string $foreignKey
@param string $localKey
@return \Illuminate\Database\Eloquent\Relations\HasOne | [
"Instantiate",
"a",
"new",
"HasOne",
"relationship",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php#L75-L78 | train | Creates a new HasOne | [
30522,
5123,
3853,
2047,
14949,
5643,
1006,
12508,
1002,
23032,
1010,
2944,
1002,
6687,
1010,
1002,
3097,
14839,
1010,
1002,
2334,
14839,
1007,
1063,
2709,
2047,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/UploadedFile.php | UploadedFile.storePubliclyAs | public function storePubliclyAs($path, $name, $options = [])
{
$options = $this->parseOptions($options);
$options['visibility'] = 'public';
return $this->storeAs($path, $name, $options);
} | php | public function storePubliclyAs($path, $name, $options = [])
{
$options = $this->parseOptions($options);
$options['visibility'] = 'public';
return $this->storeAs($path, $name, $options);
} | [
"public",
"function",
"storePubliclyAs",
"(",
"$",
"path",
",",
"$",
"name",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
")",
";",
"$",
"options",
"[",
"'visibility'",
"]"... | Store the uploaded file on a filesystem disk with public visibility.
@param string $path
@param string $name
@param array|string $options
@return string|false | [
"Store",
"the",
"uploaded",
"file",
"on",
"a",
"filesystem",
"disk",
"with",
"public",
"visibility",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/UploadedFile.php#L62-L69 | train | Stores the current page to the specified path and name in the public visibility of the current page. | [
30522,
2270,
3853,
3573,
14289,
16558,
2594,
2135,
3022,
1006,
1002,
4130,
1010,
1002,
2171,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
7047,
1027,
1002,
2023,
1011,
1028,
11968,
3366,
7361,
9285,
1006,
1002,
7047,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Ibm.php | Zend_Db_Adapter_Pdo_Ibm._connect | public function _connect()
{
if ($this->_connection) {
return;
}
parent::_connect();
$this->getConnection()->setAttribute(Zend_Db::ATTR_STRINGIFY_FETCHES, true);
try {
if ($this->_serverType === null) {
$server = substr($this->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3);
switch ($server) {
case 'DB2':
$this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Db2($this);
// Add DB2-specific numeric types
$this->_numericDataTypes['DECFLOAT'] = Zend_Db::FLOAT_TYPE;
$this->_numericDataTypes['DOUBLE'] = Zend_Db::FLOAT_TYPE;
$this->_numericDataTypes['NUM'] = Zend_Db::FLOAT_TYPE;
break;
case 'IDS':
$this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Ids($this);
// Add IDS-specific numeric types
$this->_numericDataTypes['SERIAL'] = Zend_Db::INT_TYPE;
$this->_numericDataTypes['SERIAL8'] = Zend_Db::BIGINT_TYPE;
$this->_numericDataTypes['INT8'] = Zend_Db::BIGINT_TYPE;
$this->_numericDataTypes['SMALLFLOAT'] = Zend_Db::FLOAT_TYPE;
$this->_numericDataTypes['MONEY'] = Zend_Db::FLOAT_TYPE;
break;
}
}
} catch (PDOException $e) {
/** @see Zend_Db_Adapter_Exception */
// require_once 'Zend/Db/Adapter/Exception.php';
$error = strpos($e->getMessage(), 'driver does not support that attribute');
if ($error) {
throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later", 0, $e);
} else {
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
}
}
} | php | public function _connect()
{
if ($this->_connection) {
return;
}
parent::_connect();
$this->getConnection()->setAttribute(Zend_Db::ATTR_STRINGIFY_FETCHES, true);
try {
if ($this->_serverType === null) {
$server = substr($this->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3);
switch ($server) {
case 'DB2':
$this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Db2($this);
// Add DB2-specific numeric types
$this->_numericDataTypes['DECFLOAT'] = Zend_Db::FLOAT_TYPE;
$this->_numericDataTypes['DOUBLE'] = Zend_Db::FLOAT_TYPE;
$this->_numericDataTypes['NUM'] = Zend_Db::FLOAT_TYPE;
break;
case 'IDS':
$this->_serverType = new Zend_Db_Adapter_Pdo_Ibm_Ids($this);
// Add IDS-specific numeric types
$this->_numericDataTypes['SERIAL'] = Zend_Db::INT_TYPE;
$this->_numericDataTypes['SERIAL8'] = Zend_Db::BIGINT_TYPE;
$this->_numericDataTypes['INT8'] = Zend_Db::BIGINT_TYPE;
$this->_numericDataTypes['SMALLFLOAT'] = Zend_Db::FLOAT_TYPE;
$this->_numericDataTypes['MONEY'] = Zend_Db::FLOAT_TYPE;
break;
}
}
} catch (PDOException $e) {
/** @see Zend_Db_Adapter_Exception */
// require_once 'Zend/Db/Adapter/Exception.php';
$error = strpos($e->getMessage(), 'driver does not support that attribute');
if ($error) {
throw new Zend_Db_Adapter_Exception("PDO_IBM driver extension is downlevel. Please use driver release version 1.2.1 or later", 0, $e);
} else {
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
}
}
} | [
"public",
"function",
"_connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_connection",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"_connect",
"(",
")",
";",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"setAttribute",
"(",
"Zend_Db",
... | Creates a PDO object and connects to the database.
The IBM data server is set.
Current options are DB2 or IDS
@todo also differentiate between z/OS and i/5
@return void
@throws Zend_Db_Adapter_Exception | [
"Creates",
"a",
"PDO",
"object",
"and",
"connects",
"to",
"the",
"database",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm.php#L96-L142 | train | Connect to the database | [
30522,
2270,
3853,
1035,
7532,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
4434,
1007,
1063,
2709,
1025,
1065,
6687,
1024,
1024,
1035,
7532,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
2131,
8663,
2638,
7542,
1006,
1007,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Controller/SessionContainer.php | HTML_QuickForm2_Controller_SessionContainer.storeOpaque | public function storeOpaque($name, $value)
{
if (!array_key_exists('opaque', $this->data)) {
$this->data['opaque'] = array();
}
$this->data['opaque'][$name] = $value;
} | php | public function storeOpaque($name, $value)
{
if (!array_key_exists('opaque', $this->data)) {
$this->data['opaque'] = array();
}
$this->data['opaque'][$name] = $value;
} | [
"public",
"function",
"storeOpaque",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'opaque'",
",",
"$",
"this",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'opaque'",
"]",
"=",
"array",
"... | Stores some user-supplied parameter alongside controller data
It is sometimes useful to pass some additional user data between pages
of the form, thus this method. It will be removed with all the other
data by {@link HTML_QuickForm2_Controller::destroySessionContainer()}
@param string Parameter name
@param string Parameter value | [
"Stores",
"some",
"user",
"-",
"supplied",
"parameter",
"alongside",
"controller",
"data"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Controller/SessionContainer.php#L175-L181 | train | Stores a value in the opaque array | [
30522,
2270,
3853,
3573,
29477,
4226,
1006,
1002,
2171,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
999,
9140,
1035,
3145,
1035,
6526,
1006,
1005,
28670,
1005,
1010,
1002,
2023,
1011,
1028,
2951,
1007,
1007,
1063,
1002,
2023,
1011,
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... |
octobercms/october | modules/cms/classes/Asset.php | Asset.getFilePath | public function getFilePath($fileName = null)
{
if ($fileName === null) {
$fileName = $this->fileName;
}
return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;
} | php | public function getFilePath($fileName = null)
{
if ($fileName === null) {
$fileName = $this->fileName;
}
return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;
} | [
"public",
"function",
"getFilePath",
"(",
"$",
"fileName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"fileName",
"===",
"null",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"fileName",
";",
"}",
"return",
"$",
"this",
"->",
"theme",
"->",
"getPath... | Returns the absolute file path.
@param string $fileName Specifies the file name to return the path to.
@return string | [
"Returns",
"the",
"absolute",
"file",
"path",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Asset.php#L282-L289 | train | Get file path | [
30522,
2270,
3853,
2131,
8873,
2571,
15069,
1006,
1002,
5371,
18442,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
5371,
18442,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
5371,
18442,
1027,
1002,
2023,
1011,
1028,
5371,
18442,
1025,
1065,
2709... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php | XmlFileLoader.getMappedClasses | public function getMappedClasses()
{
if (null === $this->classes) {
$this->classes = $this->getClassesFromXml();
}
return array_keys($this->classes);
} | php | public function getMappedClasses()
{
if (null === $this->classes) {
$this->classes = $this->getClassesFromXml();
}
return array_keys($this->classes);
} | [
"public",
"function",
"getMappedClasses",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"classes",
")",
"{",
"$",
"this",
"->",
"classes",
"=",
"$",
"this",
"->",
"getClassesFromXml",
"(",
")",
";",
"}",
"return",
"array_keys",
"(",
"$",
... | Return the names of the classes mapped in this file.
@return string[] The classes names | [
"Return",
"the",
"names",
"of",
"the",
"classes",
"mapped",
"in",
"this",
"file",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php#L99-L106 | train | Get all classes mapped in the tree | [
30522,
2270,
3853,
2131,
2863,
11469,
26266,
2229,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
4280,
1007,
1063,
1002,
2023,
1011,
1028,
4280,
1027,
1002,
2023,
1011,
1028,
2131,
26266,
2229,
19699,
5358,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ViewDataTable/Factory.php | Factory.getReport | private static function getReport($apiAction)
{
if (strpos($apiAction, '.') === false) {
return;
}
list($module, $action) = explode('.', $apiAction);
$report = ReportsProvider::factory($module, $action);
return $report;
} | php | private static function getReport($apiAction)
{
if (strpos($apiAction, '.') === false) {
return;
}
list($module, $action) = explode('.', $apiAction);
$report = ReportsProvider::factory($module, $action);
return $report;
} | [
"private",
"static",
"function",
"getReport",
"(",
"$",
"apiAction",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"apiAction",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"list",
"(",
"$",
"module",
",",
"$",
"action",
")",
"=",
"exp... | Return the report object for the given apiAction
@param $apiAction
@return null|Report | [
"Return",
"the",
"report",
"object",
"for",
"the",
"given",
"apiAction"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ViewDataTable/Factory.php#L175-L184 | train | Get the report | [
30522,
2797,
10763,
3853,
2131,
2890,
6442,
1006,
1002,
17928,
18908,
3258,
1007,
1063,
2065,
1006,
2358,
14536,
2891,
1006,
1002,
17928,
18908,
3258,
1010,
1005,
1012,
1005,
1007,
1027,
1027,
1027,
6270,
1007,
1063,
2709,
1025,
1065,
2862,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.php | Zend_Validate.isValid | public function isValid($value)
{
$this->_messages = array();
$this->_errors = array();
$result = true;
foreach ($this->_validators as $element) {
$validator = $element['instance'];
if ($validator->isValid($value)) {
continue;
}
$result = false;
$messages = $validator->getMessages();
$this->_messages = array_merge($this->_messages, $messages);
$this->_errors = array_merge($this->_errors, array_keys($messages));
if ($element['breakChainOnFailure']) {
break;
}
}
return $result;
} | php | public function isValid($value)
{
$this->_messages = array();
$this->_errors = array();
$result = true;
foreach ($this->_validators as $element) {
$validator = $element['instance'];
if ($validator->isValid($value)) {
continue;
}
$result = false;
$messages = $validator->getMessages();
$this->_messages = array_merge($this->_messages, $messages);
$this->_errors = array_merge($this->_errors, array_keys($messages));
if ($element['breakChainOnFailure']) {
break;
}
}
return $result;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_messages",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_errors",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"-... | Returns true if and only if $value passes all validations in the chain
Validators are run in the order in which they were added to the chain (FIFO).
@param mixed $value
@return boolean | [
"Returns",
"true",
"if",
"and",
"only",
"if",
"$value",
"passes",
"all",
"validations",
"in",
"the",
"chain"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate.php#L91-L110 | train | Returns true if the value is valid for all validators | [
30522,
2270,
30524,
6776,
1006,
1002,
2023,
1011,
1028,
1035,
9398,
18926,
2004,
1002,
5783,
1007,
1063,
1002,
9398,
8844,
1027,
1002,
5783,
1031,
1005,
6013,
1005,
1033,
1025,
2065,
1006,
1002,
9398,
8844,
1011,
1028,
2003,
10175,
3593,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/ModelNotFoundException.php | ModelNotFoundException.setModel | public function setModel($model, $ids = [])
{
$this->model = $model;
$this->ids = Arr::wrap($ids);
$this->message = "No query results for model [{$model}]";
if (count($this->ids) > 0) {
$this->message .= ' '.implode(', ', $this->ids);
} else {
$this->message .= '.';
}
return $this;
} | php | public function setModel($model, $ids = [])
{
$this->model = $model;
$this->ids = Arr::wrap($ids);
$this->message = "No query results for model [{$model}]";
if (count($this->ids) > 0) {
$this->message .= ' '.implode(', ', $this->ids);
} else {
$this->message .= '.';
}
return $this;
} | [
"public",
"function",
"setModel",
"(",
"$",
"model",
",",
"$",
"ids",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"model",
";",
"$",
"this",
"->",
"ids",
"=",
"Arr",
"::",
"wrap",
"(",
"$",
"ids",
")",
";",
"$",
"this",
"->... | Set the affected Eloquent model and instance ids.
@param string $model
@param int|array $ids
@return $this | [
"Set",
"the",
"affected",
"Eloquent",
"model",
"and",
"instance",
"ids",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/ModelNotFoundException.php#L31-L45 | train | Set Model and ids | [
30522,
2270,
3853,
2275,
5302,
9247,
1006,
1002,
2944,
1010,
1002,
8909,
2015,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
2944,
1027,
1002,
2944,
1025,
1002,
2023,
1011,
1028,
8909,
2015,
1027,
12098,
2099,
1024,
1024,
10236,
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/Console/Gpm/InstallCommand.php | InstallCommand.getGitRegexMatches | private function getGitRegexMatches($package)
{
if (isset($package->repository)) {
$repository = $package->repository;
} else {
return false;
}
preg_match(GIT_REGEX, $repository, $matches);
return $matches;
} | php | private function getGitRegexMatches($package)
{
if (isset($package->repository)) {
$repository = $package->repository;
} else {
return false;
}
preg_match(GIT_REGEX, $repository, $matches);
return $matches;
} | [
"private",
"function",
"getGitRegexMatches",
"(",
"$",
"package",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"package",
"->",
"repository",
")",
")",
"{",
"$",
"repository",
"=",
"$",
"package",
"->",
"repository",
";",
"}",
"else",
"{",
"return",
"false",
... | @param Package $package
@return array|bool | [
"@param",
"Package",
"$package"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/Gpm/InstallCommand.php#L420-L431 | train | Get the GIT_REGEX_MATCHES array | [
30522,
2797,
3853,
2131,
23806,
2890,
3351,
2595,
18900,
8376,
1006,
1002,
7427,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
7427,
1011,
1028,
22409,
1007,
1007,
1063,
1002,
22409,
1027,
1002,
7427,
1011,
1028,
22409,
1025,
1065,
2842,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ReplacesAttributes.php | ReplacesAttributes.replaceNotIn | protected function replaceNotIn($message, $attribute, $rule, $parameters)
{
return $this->replaceIn($message, $attribute, $rule, $parameters);
} | php | protected function replaceNotIn($message, $attribute, $rule, $parameters)
{
return $this->replaceIn($message, $attribute, $rule, $parameters);
} | [
"protected",
"function",
"replaceNotIn",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"replaceIn",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
... | Replace all place-holders for the not_in rule.
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@return string | [
"Replace",
"all",
"place",
"-",
"holders",
"for",
"the",
"not_in",
"rule",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php#L134-L137 | train | Replace all occurrences of a NOT IN rule in a phrase | [
30522,
5123,
3853,
5672,
17048,
2378,
1006,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5672,
2378,
1006,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/View/OneClickDone.php | OneClickDone.render | public function render()
{
// set response headers
@Common::stripHeader('Pragma');
@Common::stripHeader('Expires');
@Common::sendHeader('Content-Type: text/html; charset=UTF-8');
@Common::sendHeader('Cache-Control: must-revalidate');
@Common::sendHeader('X-Frame-Options: deny');
$error = htmlspecialchars($this->error, ENT_QUOTES, 'UTF-8');
$messages = htmlspecialchars(serialize($this->feedbackMessages), ENT_QUOTES, 'UTF-8');
$tokenAuth = $this->tokenAuth;
$httpsFail = (int) $this->httpsFail;
// use a heredoc instead of an external file
echo <<<END_OF_TEMPLATE
<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="noindex,nofollow">
<meta charset="utf-8">
<title></title>
</head>
<body>
<form name="myform" method="post" action="?module=CoreUpdater&action=oneClickResults">
<input type="hidden" name="token_auth" value="$tokenAuth" />
<input type="hidden" name="error" value="$error" />
<input type="hidden" name="messages" value="$messages" />
<input type="hidden" name="httpsFail" value="$httpsFail" />
<noscript>
<button type="submit">Continue</button>
</noscript>
</form>
<script type="text/javascript">
document.myform.submit();
</script>
</body>
</html>
END_OF_TEMPLATE;
} | php | public function render()
{
// set response headers
@Common::stripHeader('Pragma');
@Common::stripHeader('Expires');
@Common::sendHeader('Content-Type: text/html; charset=UTF-8');
@Common::sendHeader('Cache-Control: must-revalidate');
@Common::sendHeader('X-Frame-Options: deny');
$error = htmlspecialchars($this->error, ENT_QUOTES, 'UTF-8');
$messages = htmlspecialchars(serialize($this->feedbackMessages), ENT_QUOTES, 'UTF-8');
$tokenAuth = $this->tokenAuth;
$httpsFail = (int) $this->httpsFail;
// use a heredoc instead of an external file
echo <<<END_OF_TEMPLATE
<!DOCTYPE html>
<html>
<head>
<meta name="robots" content="noindex,nofollow">
<meta charset="utf-8">
<title></title>
</head>
<body>
<form name="myform" method="post" action="?module=CoreUpdater&action=oneClickResults">
<input type="hidden" name="token_auth" value="$tokenAuth" />
<input type="hidden" name="error" value="$error" />
<input type="hidden" name="messages" value="$messages" />
<input type="hidden" name="httpsFail" value="$httpsFail" />
<noscript>
<button type="submit">Continue</button>
</noscript>
</form>
<script type="text/javascript">
document.myform.submit();
</script>
</body>
</html>
END_OF_TEMPLATE;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"// set response headers",
"@",
"Common",
"::",
"stripHeader",
"(",
"'Pragma'",
")",
";",
"@",
"Common",
"::",
"stripHeader",
"(",
"'Expires'",
")",
";",
"@",
"Common",
"::",
"sendHeader",
"(",
"'Content-Type: tex... | Outputs the data.
@return string html | [
"Outputs",
"the",
"data",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/View/OneClickDone.php#L59-L98 | train | Render the response | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1013,
1013,
2275,
3433,
20346,
2015,
1030,
2691,
1024,
1024,
6167,
4974,
2121,
1006,
1005,
10975,
8490,
2863,
1005,
1007,
1025,
1030,
2691,
1024,
1024,
6167,
4974,
2121,
1006,
1005,
4654,
20781,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Grammars/Grammar.php | Grammar.compileDelete | public function compileDelete(Builder $query)
{
$wheres = is_array($query->wheres) ? $this->compileWheres($query) : '';
return trim("delete from {$this->wrapTable($query->from)} $wheres");
} | php | public function compileDelete(Builder $query)
{
$wheres = is_array($query->wheres) ? $this->compileWheres($query) : '';
return trim("delete from {$this->wrapTable($query->from)} $wheres");
} | [
"public",
"function",
"compileDelete",
"(",
"Builder",
"$",
"query",
")",
"{",
"$",
"wheres",
"=",
"is_array",
"(",
"$",
"query",
"->",
"wheres",
")",
"?",
"$",
"this",
"->",
"compileWheres",
"(",
"$",
"query",
")",
":",
"''",
";",
"return",
"trim",
... | Compile a delete statement into SQL.
@param \Illuminate\Database\Query\Builder $query
@return string | [
"Compile",
"a",
"delete",
"statement",
"into",
"SQL",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Grammars/Grammar.php#L958-L963 | train | Compiles a delete query into a string | [
30522,
2270,
3853,
9227,
12260,
2618,
1006,
12508,
1002,
23032,
1007,
1063,
1002,
2073,
2015,
1027,
2003,
1035,
9140,
1006,
1002,
23032,
1011,
1028,
2073,
2015,
1007,
1029,
1002,
2023,
1011,
1028,
4012,
22090,
2860,
5886,
2229,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php | HasRelationships.hasOneThrough | public function hasOneThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
{
$through = new $through;
$firstKey = $firstKey ?: $this->getForeignKey();
$secondKey = $secondKey ?: $through->getForeignKey();
return $this->newHasOneThrough(
$this->newRelatedInstance($related)->newQuery(), $this, $through,
$firstKey, $secondKey, $localKey ?: $this->getKeyName(),
$secondLocalKey ?: $through->getKeyName()
);
} | php | public function hasOneThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
{
$through = new $through;
$firstKey = $firstKey ?: $this->getForeignKey();
$secondKey = $secondKey ?: $through->getForeignKey();
return $this->newHasOneThrough(
$this->newRelatedInstance($related)->newQuery(), $this, $through,
$firstKey, $secondKey, $localKey ?: $this->getKeyName(),
$secondLocalKey ?: $through->getKeyName()
);
} | [
"public",
"function",
"hasOneThrough",
"(",
"$",
"related",
",",
"$",
"through",
",",
"$",
"firstKey",
"=",
"null",
",",
"$",
"secondKey",
"=",
"null",
",",
"$",
"localKey",
"=",
"null",
",",
"$",
"secondLocalKey",
"=",
"null",
")",
"{",
"$",
"through"... | Define a has-one-through relationship.
@param string $related
@param string $through
@param string|null $firstKey
@param string|null $secondKey
@param string|null $localKey
@param string|null $secondLocalKey
@return \Illuminate\Database\Eloquent\Relations\HasOneThrough | [
"Define",
"a",
"has",
"-",
"one",
"-",
"through",
"relationship",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php#L91-L104 | train | Return a has - one - through relationship | [
30522,
2270,
3853,
2038,
5643,
2705,
22494,
5603,
1006,
1002,
3141,
1010,
1002,
2083,
1010,
1002,
2034,
14839,
1027,
19701,
1010,
1002,
2117,
14839,
1027,
19701,
1010,
1002,
2334,
14839,
1027,
19701,
1010,
1002,
2117,
4135,
9289,
14839,
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... |
walkor/Workerman | Protocols/Frame.php | Frame.input | public static function input($buffer, TcpConnection $connection)
{
if (strlen($buffer) < 4) {
return 0;
}
$unpack_data = unpack('Ntotal_length', $buffer);
return $unpack_data['total_length'];
} | php | public static function input($buffer, TcpConnection $connection)
{
if (strlen($buffer) < 4) {
return 0;
}
$unpack_data = unpack('Ntotal_length', $buffer);
return $unpack_data['total_length'];
} | [
"public",
"static",
"function",
"input",
"(",
"$",
"buffer",
",",
"TcpConnection",
"$",
"connection",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"buffer",
")",
"<",
"4",
")",
"{",
"return",
"0",
";",
"}",
"$",
"unpack_data",
"=",
"unpack",
"(",
"'Ntota... | Check the integrity of the package.
@param string $buffer
@param TcpConnection $connection
@return int | [
"Check",
"the",
"integrity",
"of",
"the",
"package",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Frame.php#L30-L37 | train | This function is used to determine the number of bytes the server should accept. | [
30522,
2270,
10763,
3853,
7953,
1006,
1002,
17698,
1010,
22975,
15042,
18256,
7542,
1002,
4434,
1007,
1063,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
17698,
1007,
1026,
1018,
1007,
1063,
2709,
1014,
1025,
1065,
1002,
4895,
23947,
1035,
295... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Translation/ArrayLoader.php | ArrayLoader.addMessages | public function addMessages($locale, $group, array $messages, $namespace = null)
{
$namespace = $namespace ?: '*';
$this->messages[$namespace][$locale][$group] = $messages;
return $this;
} | php | public function addMessages($locale, $group, array $messages, $namespace = null)
{
$namespace = $namespace ?: '*';
$this->messages[$namespace][$locale][$group] = $messages;
return $this;
} | [
"public",
"function",
"addMessages",
"(",
"$",
"locale",
",",
"$",
"group",
",",
"array",
"$",
"messages",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"namespace",
"=",
"$",
"namespace",
"?",
":",
"'*'",
";",
"$",
"this",
"->",
"messages",
"["... | Add messages to the loader.
@param string $locale
@param string $group
@param array $messages
@param string|null $namespace
@return $this | [
"Add",
"messages",
"to",
"the",
"loader",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Translation/ArrayLoader.php#L63-L70 | train | Add messages to the namespace | [
30522,
2270,
3853,
5587,
7834,
3736,
8449,
1006,
1002,
2334,
2063,
1010,
1002,
2177,
1010,
9140,
1002,
7696,
1010,
1002,
3415,
15327,
1027,
19701,
1007,
1063,
1002,
3415,
15327,
1027,
1002,
3415,
15327,
1029,
1024,
1005,
1008,
1005,
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... |
laravel/framework | src/Illuminate/Queue/Console/ListenCommand.php | ListenCommand.gatherOptions | protected function gatherOptions()
{
return new ListenerOptions(
$this->option('env'), $this->option('delay'),
$this->option('memory'), $this->option('timeout'),
$this->option('sleep'), $this->option('tries'),
$this->option('force')
);
} | php | protected function gatherOptions()
{
return new ListenerOptions(
$this->option('env'), $this->option('delay'),
$this->option('memory'), $this->option('timeout'),
$this->option('sleep'), $this->option('tries'),
$this->option('force')
);
} | [
"protected",
"function",
"gatherOptions",
"(",
")",
"{",
"return",
"new",
"ListenerOptions",
"(",
"$",
"this",
"->",
"option",
"(",
"'env'",
")",
",",
"$",
"this",
"->",
"option",
"(",
"'delay'",
")",
",",
"$",
"this",
"->",
"option",
"(",
"'memory'",
... | Get the listener options for the command.
@return \Illuminate\Queue\ListenerOptions | [
"Get",
"the",
"listener",
"options",
"for",
"the",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Console/ListenCommand.php#L92-L100 | train | Gathers options for listener | [
30522,
5123,
3853,
8587,
7361,
9285,
1006,
1007,
1063,
2709,
2047,
19373,
7361,
9285,
1006,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
4372,
2615,
1005,
1007,
1010,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
8536,
1005,
1007,
1010,
1002,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php | CacheWarmupCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
if (!$input->getOption('no-optional-warmers')) {
$this->cacheWarmer->enableOptionalWarmers();
}
$this->cacheWarmer->warmUp($kernel->getContainer()->getParameter('kernel.cache_dir'));
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
if (!$input->getOption('no-optional-warmers')) {
$this->cacheWarmer->enableOptionalWarmers();
}
$this->cacheWarmer->warmUp($kernel->getContainer()->getParameter('kernel.cache_dir'));
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"kernel",
"=",
"$",
"this",
"->",
"ge... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php#L69-L83 | train | Warms up the cache for the current environment | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
22834,
1027,
2047,
25353,
2213,
14876,
4890,
21756,
2571,
1006,
1002,
7953,
1010,
1002,
6434,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.o_encryption | protected function o_encryption($id, $action, $options = '')
{
switch ($action) {
case 'new':
// make the new object
$this->objects[$id] = array('t' => 'encryption', 'info' => $options);
$this->arc4_objnum = $id;
break;
case 'keys':
// figure out the additional parameters required
$pad = chr(0x28) . chr(0xBF) . chr(0x4E) . chr(0x5E) . chr(0x4E) . chr(0x75) . chr(0x8A) . chr(0x41)
. chr(0x64) . chr(0x00) . chr(0x4E) . chr(0x56) . chr(0xFF) . chr(0xFA) . chr(0x01) . chr(0x08)
. chr(0x2E) . chr(0x2E) . chr(0x00) . chr(0xB6) . chr(0xD0) . chr(0x68) . chr(0x3E) . chr(0x80)
. chr(0x2F) . chr(0x0C) . chr(0xA9) . chr(0xFE) . chr(0x64) . chr(0x53) . chr(0x69) . chr(0x7A);
$info = $this->objects[$id]['info'];
$len = mb_strlen($info['owner'], '8bit');
if ($len > 32) {
$owner = substr($info['owner'], 0, 32);
} else {
if ($len < 32) {
$owner = $info['owner'] . substr($pad, 0, 32 - $len);
} else {
$owner = $info['owner'];
}
}
$len = mb_strlen($info['user'], '8bit');
if ($len > 32) {
$user = substr($info['user'], 0, 32);
} else {
if ($len < 32) {
$user = $info['user'] . substr($pad, 0, 32 - $len);
} else {
$user = $info['user'];
}
}
$tmp = $this->md5_16($owner);
$okey = substr($tmp, 0, 5);
$this->ARC4_init($okey);
$ovalue = $this->ARC4($user);
$this->objects[$id]['info']['O'] = $ovalue;
// now make the u value, phew.
$tmp = $this->md5_16(
$user . $ovalue . chr($info['p']) . chr(255) . chr(255) . chr(255) . hex2bin($this->fileIdentifier)
);
$ukey = substr($tmp, 0, 5);
$this->ARC4_init($ukey);
$this->encryptionKey = $ukey;
$this->encrypted = true;
$uvalue = $this->ARC4($pad);
$this->objects[$id]['info']['U'] = $uvalue;
// initialize the arc4 array
break;
case 'out':
$o = &$this->objects[$id];
$res = "\n$id 0 obj\n<<";
$res .= "\n/Filter /Standard";
$res .= "\n/V 1";
$res .= "\n/R 2";
$res .= "\n/O (" . $this->filterText($o['info']['O'], false, false) . ')';
$res .= "\n/U (" . $this->filterText($o['info']['U'], false, false) . ')';
// and the p-value needs to be converted to account for the twos-complement approach
$o['info']['p'] = (($o['info']['p'] ^ 255) + 1) * -1;
$res .= "\n/P " . ($o['info']['p']);
$res .= "\n>>\nendobj";
return $res;
}
return null;
} | php | protected function o_encryption($id, $action, $options = '')
{
switch ($action) {
case 'new':
// make the new object
$this->objects[$id] = array('t' => 'encryption', 'info' => $options);
$this->arc4_objnum = $id;
break;
case 'keys':
// figure out the additional parameters required
$pad = chr(0x28) . chr(0xBF) . chr(0x4E) . chr(0x5E) . chr(0x4E) . chr(0x75) . chr(0x8A) . chr(0x41)
. chr(0x64) . chr(0x00) . chr(0x4E) . chr(0x56) . chr(0xFF) . chr(0xFA) . chr(0x01) . chr(0x08)
. chr(0x2E) . chr(0x2E) . chr(0x00) . chr(0xB6) . chr(0xD0) . chr(0x68) . chr(0x3E) . chr(0x80)
. chr(0x2F) . chr(0x0C) . chr(0xA9) . chr(0xFE) . chr(0x64) . chr(0x53) . chr(0x69) . chr(0x7A);
$info = $this->objects[$id]['info'];
$len = mb_strlen($info['owner'], '8bit');
if ($len > 32) {
$owner = substr($info['owner'], 0, 32);
} else {
if ($len < 32) {
$owner = $info['owner'] . substr($pad, 0, 32 - $len);
} else {
$owner = $info['owner'];
}
}
$len = mb_strlen($info['user'], '8bit');
if ($len > 32) {
$user = substr($info['user'], 0, 32);
} else {
if ($len < 32) {
$user = $info['user'] . substr($pad, 0, 32 - $len);
} else {
$user = $info['user'];
}
}
$tmp = $this->md5_16($owner);
$okey = substr($tmp, 0, 5);
$this->ARC4_init($okey);
$ovalue = $this->ARC4($user);
$this->objects[$id]['info']['O'] = $ovalue;
// now make the u value, phew.
$tmp = $this->md5_16(
$user . $ovalue . chr($info['p']) . chr(255) . chr(255) . chr(255) . hex2bin($this->fileIdentifier)
);
$ukey = substr($tmp, 0, 5);
$this->ARC4_init($ukey);
$this->encryptionKey = $ukey;
$this->encrypted = true;
$uvalue = $this->ARC4($pad);
$this->objects[$id]['info']['U'] = $uvalue;
// initialize the arc4 array
break;
case 'out':
$o = &$this->objects[$id];
$res = "\n$id 0 obj\n<<";
$res .= "\n/Filter /Standard";
$res .= "\n/V 1";
$res .= "\n/R 2";
$res .= "\n/O (" . $this->filterText($o['info']['O'], false, false) . ')';
$res .= "\n/U (" . $this->filterText($o['info']['U'], false, false) . ')';
// and the p-value needs to be converted to account for the twos-complement approach
$o['info']['p'] = (($o['info']['p'] ^ 255) + 1) * -1;
$res .= "\n/P " . ($o['info']['p']);
$res .= "\n>>\nendobj";
return $res;
}
return null;
} | [
"protected",
"function",
"o_encryption",
"(",
"$",
"id",
",",
"$",
"action",
",",
"$",
"options",
"=",
"''",
")",
"{",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'new'",
":",
"// make the new object",
"$",
"this",
"->",
"objects",
"[",
"$",
"id",... | encryption object.
@param $id
@param $action
@param string $options
@return string|null | [
"encryption",
"object",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L2023-L2102 | train | This function is used to set the encryption method of the arc4 object | [
30522,
5123,
3853,
1051,
1035,
21999,
1006,
1002,
8909,
1010,
1002,
2895,
1010,
1002,
7047,
1027,
1005,
1005,
1007,
1063,
6942,
1006,
1002,
2895,
1007,
1063,
2553,
1005,
2047,
1005,
1024,
1013,
1013,
2191,
1996,
2047,
4874,
1002,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ImageMedium.php | ImageMedium.format | public function format($format)
{
if (!$this->image) {
$this->image();
}
$this->format = $format;
return $this;
} | php | public function format($format)
{
if (!$this->image) {
$this->image();
}
$this->format = $format;
return $this;
} | [
"public",
"function",
"format",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"image",
")",
"{",
"$",
"this",
"->",
"image",
"(",
")",
";",
"}",
"$",
"this",
"->",
"format",
"=",
"$",
"format",
";",
"return",
"$",
"this",
";"... | Sets image output format.
@param string $format
@return $this | [
"Sets",
"image",
"output",
"format",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ImageMedium.php#L444-L453 | train | Set the format of the image | [
30522,
2270,
3853,
4289,
1006,
1002,
4289,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
3746,
1007,
1063,
1002,
2023,
1011,
1028,
3746,
1006,
1007,
1025,
1065,
1002,
2023,
1011,
1028,
4289,
1027,
1002,
4289,
1025,
2709,
1002,
2023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/Cpdf.php | Cpdf.setGraphicsState | function setGraphicsState($parameters)
{
// Create a new graphics state object if necessary
if (($gstate = array_search($parameters, $this->gstates)) === false) {
$this->numObj++;
$this->o_extGState($this->numObj, 'new', $parameters);
$gstate = $this->numStates;
$this->gstates[$gstate] = $parameters;
}
$this->addContent("\n/GS$gstate gs");
} | php | function setGraphicsState($parameters)
{
// Create a new graphics state object if necessary
if (($gstate = array_search($parameters, $this->gstates)) === false) {
$this->numObj++;
$this->o_extGState($this->numObj, 'new', $parameters);
$gstate = $this->numStates;
$this->gstates[$gstate] = $parameters;
}
$this->addContent("\n/GS$gstate gs");
} | [
"function",
"setGraphicsState",
"(",
"$",
"parameters",
")",
"{",
"// Create a new graphics state object if necessary",
"if",
"(",
"(",
"$",
"gstate",
"=",
"array_search",
"(",
"$",
"parameters",
",",
"$",
"this",
"->",
"gstates",
")",
")",
"===",
"false",
")",
... | Set the graphics state for compositions
@param $parameters | [
"Set",
"the",
"graphics",
"state",
"for",
"compositions"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/Cpdf.php#L3126-L3136 | train | Set the graphics state | [
30522,
3853,
2275,
14773,
4757,
12259,
1006,
1002,
11709,
1007,
1063,
1013,
1013,
3443,
1037,
2047,
8389,
2110,
4874,
2065,
4072,
2065,
1006,
1006,
1002,
28177,
12259,
1027,
9140,
1035,
3945,
1006,
1002,
11709,
1010,
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.setAddress | protected function setAddress($address, $name = null, $property = 'to')
{
foreach ($this->addressesToArray($address, $name) as $recipient) {
$recipient = $this->normalizeRecipient($recipient);
$this->{$property}[] = [
'name' => $recipient->name ?? null,
'address' => $recipient->email,
];
}
return $this;
} | php | protected function setAddress($address, $name = null, $property = 'to')
{
foreach ($this->addressesToArray($address, $name) as $recipient) {
$recipient = $this->normalizeRecipient($recipient);
$this->{$property}[] = [
'name' => $recipient->name ?? null,
'address' => $recipient->email,
];
}
return $this;
} | [
"protected",
"function",
"setAddress",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
",",
"$",
"property",
"=",
"'to'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"addressesToArray",
"(",
"$",
"address",
",",
"$",
"name",
")",
"as",
"$",
"rec... | Set the recipients of the message.
All recipients are stored internally as [['name' => ?, 'address' => ?]]
@param object|array|string $address
@param string|null $name
@param string $property
@return $this | [
"Set",
"the",
"recipients",
"of",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailable.php#L577-L589 | train | Set To Address | [
30522,
5123,
3853,
2275,
4215,
16200,
4757,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
19701,
1010,
1002,
3200,
1027,
1005,
2000,
1005,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
11596,
3406,
2906,
30524,
1007,
1025,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
slimphp/Slim | Slim/App.php | App.process | public function process(ServerRequestInterface $request, ResponseInterface $response)
{
// Ensure basePath is set
$router = $this->container->get('router');
if (is_callable([$request->getUri(), 'getBasePath']) && is_callable([$router, 'setBasePath'])) {
$router->setBasePath($request->getUri()->getBasePath());
}
// Dispatch the Router first if the setting for this is on
if ($this->container->get('settings')['determineRouteBeforeAppMiddleware'] === true) {
// Dispatch router (note: you won't be able to alter routes after this)
$request = $this->dispatchRouterAndPrepareRoute($request, $router);
}
// Traverse middleware stack
try {
$response = $this->callMiddlewareStack($request, $response);
} catch (Exception $e) {
$response = $this->handleException($e, $request, $response);
} catch (Throwable $e) {
$response = $this->handlePhpError($e, $request, $response);
}
return $response;
} | php | public function process(ServerRequestInterface $request, ResponseInterface $response)
{
// Ensure basePath is set
$router = $this->container->get('router');
if (is_callable([$request->getUri(), 'getBasePath']) && is_callable([$router, 'setBasePath'])) {
$router->setBasePath($request->getUri()->getBasePath());
}
// Dispatch the Router first if the setting for this is on
if ($this->container->get('settings')['determineRouteBeforeAppMiddleware'] === true) {
// Dispatch router (note: you won't be able to alter routes after this)
$request = $this->dispatchRouterAndPrepareRoute($request, $router);
}
// Traverse middleware stack
try {
$response = $this->callMiddlewareStack($request, $response);
} catch (Exception $e) {
$response = $this->handleException($e, $request, $response);
} catch (Throwable $e) {
$response = $this->handlePhpError($e, $request, $response);
}
return $response;
} | [
"public",
"function",
"process",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"// Ensure basePath is set",
"$",
"router",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
";",
"if",
... | Process a request
This method traverses the application middleware stack and then returns the
resultant Response object.
@param ServerRequestInterface $request
@param ResponseInterface $response
@return ResponseInterface
@throws Exception
@throws Throwable | [
"Process",
"a",
"request"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/App.php#L376-L400 | train | Process the request and return the response | [
30522,
2270,
3853,
2832,
1006,
8241,
2890,
15500,
18447,
2121,
12172,
1002,
5227,
1010,
3433,
18447,
2121,
12172,
1002,
3433,
1007,
1063,
1013,
1013,
5676,
2918,
15069,
2003,
2275,
1002,
2799,
2099,
1027,
1002,
2023,
1011,
1028,
11661,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/Lock.php | Lock.get | public function get($callback = null)
{
$result = $this->acquire();
if ($result && is_callable($callback)) {
try {
return $callback();
} finally {
$this->release();
}
}
return $result;
} | php | public function get($callback = null)
{
$result = $this->acquire();
if ($result && is_callable($callback)) {
try {
return $callback();
} finally {
$this->release();
}
}
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"acquire",
"(",
")",
";",
"if",
"(",
"$",
"result",
"&&",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"try",
"{",
"return",
"... | Attempt to acquire the lock.
@param callable|null $callback
@return mixed | [
"Attempt",
"to",
"acquire",
"the",
"lock",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/Lock.php#L81-L94 | train | Returns the result of the callback | [
30522,
2270,
3853,
2131,
1006,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
9878,
1006,
1007,
1025,
2065,
1006,
1002,
2765,
1004,
1004,
2003,
1035,
2655,
3085,
1006,
1002,
2655,
5963,
1007,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/API/ProcessedReport.php | ProcessedReport.hideShowMetrics | private function hideShowMetrics($columns, $emptyColumns = array())
{
if (!is_array($columns)) {
return $columns;
}
// remove columns if hideColumns query parameters exist
$columnsToRemove = $this->getColumnsToRemove();
// remove columns if showColumns query parameters exist
$columnsToKeep = $this->getColumnsToKeep();
return $this->hideShowMetricsWithParams($columns, $columnsToRemove, $columnsToKeep, $emptyColumns);
} | php | private function hideShowMetrics($columns, $emptyColumns = array())
{
if (!is_array($columns)) {
return $columns;
}
// remove columns if hideColumns query parameters exist
$columnsToRemove = $this->getColumnsToRemove();
// remove columns if showColumns query parameters exist
$columnsToKeep = $this->getColumnsToKeep();
return $this->hideShowMetricsWithParams($columns, $columnsToRemove, $columnsToKeep, $emptyColumns);
} | [
"private",
"function",
"hideShowMetrics",
"(",
"$",
"columns",
",",
"$",
"emptyColumns",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"columns",
")",
")",
"{",
"return",
"$",
"columns",
";",
"}",
"// remove columns if hideColumns... | Removes column names from an array based on the values in the hideColumns,
showColumns query parameters. This is a hack that provides the ColumnDelete
filter functionality in processed reports.
@param array $columns List of metrics shown in a processed report.
@param array $emptyColumns Empty columns from the data table meta data.
@return array Filtered list of metrics. | [
"Removes",
"column",
"names",
"from",
"an",
"array",
"based",
"on",
"the",
"values",
"in",
"the",
"hideColumns",
"showColumns",
"query",
"parameters",
".",
"This",
"is",
"a",
"hack",
"that",
"provides",
"the",
"ColumnDelete",
"filter",
"functionality",
"in",
"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/ProcessedReport.php#L541-L554 | train | Hide show metrics by query parameters | [
30522,
2797,
3853,
17382,
14406,
12589,
2015,
1006,
1002,
7753,
1010,
1002,
4064,
25778,
2819,
3619,
1027,
9140,
1006,
1007,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
7753,
1007,
1007,
1063,
2709,
1002,
7753,
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/system/controllers/Updates.php | Updates.processImportantUpdates | protected function processImportantUpdates($result)
{
$hasImportantUpdates = false;
/*
* Core
*/
if (isset($result['core'])) {
$coreImportant = false;
foreach (array_get($result, 'core.updates', []) as $build => $description) {
if (strpos($description, '!!!') === false) continue;
$detailsUrl = '//octobercms.com/support/articles/release-notes';
$description = str_replace('!!!', '', $description);
$result['core']['updates'][$build] = [$description, $detailsUrl];
$coreImportant = $hasImportantUpdates = true;
}
$result['core']['isImportant'] = $coreImportant ? '1' : '0';
}
/*
* Plugins
*/
foreach (array_get($result, 'plugins', []) as $code => $plugin) {
$isImportant = false;
foreach (array_get($plugin, 'updates', []) as $version => $description) {
if (strpos($description, '!!!') === false) continue;
$isImportant = $hasImportantUpdates = true;
$detailsUrl = Backend::url('system/updates/details/'.PluginVersion::makeSlug($code).'/upgrades').'?fetch=1';
$description = str_replace('!!!', '', $description);
$result['plugins'][$code]['updates'][$version] = [$description, $detailsUrl];
}
$result['plugins'][$code]['isImportant'] = $isImportant ? '1' : '0';
}
$result['hasImportantUpdates'] = $hasImportantUpdates;
return $result;
} | php | protected function processImportantUpdates($result)
{
$hasImportantUpdates = false;
/*
* Core
*/
if (isset($result['core'])) {
$coreImportant = false;
foreach (array_get($result, 'core.updates', []) as $build => $description) {
if (strpos($description, '!!!') === false) continue;
$detailsUrl = '//octobercms.com/support/articles/release-notes';
$description = str_replace('!!!', '', $description);
$result['core']['updates'][$build] = [$description, $detailsUrl];
$coreImportant = $hasImportantUpdates = true;
}
$result['core']['isImportant'] = $coreImportant ? '1' : '0';
}
/*
* Plugins
*/
foreach (array_get($result, 'plugins', []) as $code => $plugin) {
$isImportant = false;
foreach (array_get($plugin, 'updates', []) as $version => $description) {
if (strpos($description, '!!!') === false) continue;
$isImportant = $hasImportantUpdates = true;
$detailsUrl = Backend::url('system/updates/details/'.PluginVersion::makeSlug($code).'/upgrades').'?fetch=1';
$description = str_replace('!!!', '', $description);
$result['plugins'][$code]['updates'][$version] = [$description, $detailsUrl];
}
$result['plugins'][$code]['isImportant'] = $isImportant ? '1' : '0';
}
$result['hasImportantUpdates'] = $hasImportantUpdates;
return $result;
} | [
"protected",
"function",
"processImportantUpdates",
"(",
"$",
"result",
")",
"{",
"$",
"hasImportantUpdates",
"=",
"false",
";",
"/*\n * Core\n */",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'core'",
"]",
")",
")",
"{",
"$",
"coreImportant",
... | Loops the update list and checks for actionable updates.
@param array $result
@return array | [
"Loops",
"the",
"update",
"list",
"and",
"checks",
"for",
"actionable",
"updates",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/controllers/Updates.php#L351-L394 | train | Process Important Updates | [
30522,
5123,
3853,
2832,
5714,
6442,
4630,
6279,
27122,
1006,
1002,
2765,
1007,
1063,
1002,
2038,
5714,
6442,
4630,
6279,
27122,
1027,
6270,
1025,
1013,
1008,
1008,
4563,
1008,
1013,
2065,
1006,
26354,
3388,
1006,
1002,
2765,
1031,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php | PhpDocExtractor.getShortDescription | public function getShortDescription($class, $property, array $context = [])
{
/** @var $docBlock DocBlock */
list($docBlock) = $this->getDocBlock($class, $property);
if (!$docBlock) {
return;
}
$shortDescription = $docBlock->getSummary();
if (!empty($shortDescription)) {
return $shortDescription;
}
foreach ($docBlock->getTagsByName('var') as $var) {
$varDescription = $var->getDescription()->render();
if (!empty($varDescription)) {
return $varDescription;
}
}
} | php | public function getShortDescription($class, $property, array $context = [])
{
/** @var $docBlock DocBlock */
list($docBlock) = $this->getDocBlock($class, $property);
if (!$docBlock) {
return;
}
$shortDescription = $docBlock->getSummary();
if (!empty($shortDescription)) {
return $shortDescription;
}
foreach ($docBlock->getTagsByName('var') as $var) {
$varDescription = $var->getDescription()->render();
if (!empty($varDescription)) {
return $varDescription;
}
}
} | [
"public",
"function",
"getShortDescription",
"(",
"$",
"class",
",",
"$",
"property",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"/** @var $docBlock DocBlock */",
"list",
"(",
"$",
"docBlock",
")",
"=",
"$",
"this",
"->",
"getDocBlock",
"(",
"$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php#L71-L92 | train | Returns short description of class property | [
30522,
2270,
3853,
4152,
27794,
6155,
23235,
3258,
1006,
1002,
2465,
1010,
1002,
3200,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
1002,
9986,
23467,
9986,
23467,
1008,
1013,
2862,
1006,
1002,
9986,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Exporters/CsvExporter.php | CsvExporter.export | public function export()
{
$filename = $this->getTable().'.csv';
$headers = [
'Content-Encoding' => 'UTF-8',
'Content-Type' => 'text/csv;charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"$filename\"",
];
response()->stream(function () {
$handle = fopen('php://output', 'w');
$titles = [];
$this->chunk(function ($records) use ($handle, &$titles) {
if (empty($titles)) {
$titles = $this->getHeaderRowFromRecords($records);
// Add CSV headers
fputcsv($handle, $titles);
}
foreach ($records as $record) {
fputcsv($handle, $this->getFormattedRecord($record));
}
});
// Close the output stream
fclose($handle);
}, 200, $headers)->send();
exit;
} | php | public function export()
{
$filename = $this->getTable().'.csv';
$headers = [
'Content-Encoding' => 'UTF-8',
'Content-Type' => 'text/csv;charset=UTF-8',
'Content-Disposition' => "attachment; filename=\"$filename\"",
];
response()->stream(function () {
$handle = fopen('php://output', 'w');
$titles = [];
$this->chunk(function ($records) use ($handle, &$titles) {
if (empty($titles)) {
$titles = $this->getHeaderRowFromRecords($records);
// Add CSV headers
fputcsv($handle, $titles);
}
foreach ($records as $record) {
fputcsv($handle, $this->getFormattedRecord($record));
}
});
// Close the output stream
fclose($handle);
}, 200, $headers)->send();
exit;
} | [
"public",
"function",
"export",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
".",
"'.csv'",
";",
"$",
"headers",
"=",
"[",
"'Content-Encoding'",
"=>",
"'UTF-8'",
",",
"'Content-Type'",
"=>",
"'text/csv;charset=UTF-8'",
",",
... | {@inheritdoc} | [
"{"
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Exporters/CsvExporter.php#L15-L48 | train | Export the table to CSV | [
30522,
2270,
3853,
9167,
1006,
1007,
1063,
1002,
5371,
18442,
1027,
1002,
2023,
1011,
1028,
2131,
10880,
1006,
1007,
1012,
1005,
1012,
20116,
2615,
1005,
1025,
1002,
20346,
2015,
1027,
1031,
1005,
4180,
1011,
17181,
1005,
1027,
1028,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Form.php | Form.processAutoSpan | protected function processAutoSpan($fields)
{
$prevSpan = null;
foreach ($fields as $field) {
if (strtolower($field->span) === 'auto') {
if ($prevSpan === 'left') {
$field->span = 'right';
}
else {
$field->span = 'left';
}
}
$prevSpan = $field->span;
}
} | php | protected function processAutoSpan($fields)
{
$prevSpan = null;
foreach ($fields as $field) {
if (strtolower($field->span) === 'auto') {
if ($prevSpan === 'left') {
$field->span = 'right';
}
else {
$field->span = 'left';
}
}
$prevSpan = $field->span;
}
} | [
"protected",
"function",
"processAutoSpan",
"(",
"$",
"fields",
")",
"{",
"$",
"prevSpan",
"=",
"null",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"field",
"->",
"span",
")",
"===",
"'auto'",
... | Converts fields with a span set to 'auto' as either
'left' or 'right' depending on the previous field.
@return void | [
"Converts",
"fields",
"with",
"a",
"span",
"set",
"to",
"auto",
"as",
"either",
"left",
"or",
"right",
"depending",
"on",
"the",
"previous",
"field",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L654-L670 | train | Process auto span | [
30522,
5123,
3853,
2832,
4887,
13122,
9739,
1006,
1002,
4249,
1007,
1063,
1002,
3653,
15088,
9739,
1027,
19701,
1025,
18921,
6776,
1006,
1002,
4249,
2004,
1002,
2492,
1007,
1063,
2065,
1006,
2358,
5339,
12898,
13777,
1006,
1002,
2492,
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... |
spatie/laravel-permission | src/Models/Role.php | Role.findOrCreate | public static function findOrCreate(string $name, $guardName = null): RoleContract
{
$guardName = $guardName ?? Guard::getDefaultName(static::class);
$role = static::where('name', $name)->where('guard_name', $guardName)->first();
if (! $role) {
return static::query()->create(['name' => $name, 'guard_name' => $guardName]);
}
return $role;
} | php | public static function findOrCreate(string $name, $guardName = null): RoleContract
{
$guardName = $guardName ?? Guard::getDefaultName(static::class);
$role = static::where('name', $name)->where('guard_name', $guardName)->first();
if (! $role) {
return static::query()->create(['name' => $name, 'guard_name' => $guardName]);
}
return $role;
} | [
"public",
"static",
"function",
"findOrCreate",
"(",
"string",
"$",
"name",
",",
"$",
"guardName",
"=",
"null",
")",
":",
"RoleContract",
"{",
"$",
"guardName",
"=",
"$",
"guardName",
"??",
"Guard",
"::",
"getDefaultName",
"(",
"static",
"::",
"class",
")"... | Find or create role by its name (and optionally guardName).
@param string $name
@param string|null $guardName
@return \Spatie\Permission\Contracts\Role | [
"Find",
"or",
"create",
"role",
"by",
"its",
"name",
"(",
"and",
"optionally",
"guardName",
")",
"."
] | 81dbe9d372d70c255b66a2727a235076509f8d45 | https://github.com/spatie/laravel-permission/blob/81dbe9d372d70c255b66a2727a235076509f8d45/src/Models/Role.php#L118-L129 | train | Find or create role | [
30522,
2270,
10763,
3853,
2424,
2953,
16748,
3686,
1006,
5164,
1002,
2171,
1010,
1002,
3457,
18442,
1027,
19701,
1007,
1024,
2535,
8663,
6494,
6593,
1063,
1002,
3457,
18442,
1027,
1002,
3457,
18442,
1029,
1029,
3457,
1024,
1024,
2131,
3207,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/traits/EventEmitter.php | EventEmitter.fireSystemEvent | public function fireSystemEvent($event, $params = [], $halt = true)
{
$result = [];
$shortEvent = substr($event, strpos($event, '.') + 1);
$longArgs = array_merge([$this], $params);
/*
* Local event first
*/
if ($response = $this->fireEvent($shortEvent, $params, $halt)) {
if ($halt) {
return $response;
}
$result = array_merge($result, $response);
}
/*
* Global event second
*/
if ($response = Event::fire($event, $longArgs, $halt)) {
if ($halt) {
return $response;
}
$result = array_merge($result, $response);
}
return $result;
} | php | public function fireSystemEvent($event, $params = [], $halt = true)
{
$result = [];
$shortEvent = substr($event, strpos($event, '.') + 1);
$longArgs = array_merge([$this], $params);
/*
* Local event first
*/
if ($response = $this->fireEvent($shortEvent, $params, $halt)) {
if ($halt) {
return $response;
}
$result = array_merge($result, $response);
}
/*
* Global event second
*/
if ($response = Event::fire($event, $longArgs, $halt)) {
if ($halt) {
return $response;
}
$result = array_merge($result, $response);
}
return $result;
} | [
"public",
"function",
"fireSystemEvent",
"(",
"$",
"event",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"halt",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"shortEvent",
"=",
"substr",
"(",
"$",
"event",
",",
"strpos",
"(",
"$... | Fires a combination of local and global events. The first segment is removed
from the event name locally and the local object is passed as the first
argument to the event globally. Halting is also enabled by default.
For example:
$this->fireSystemEvent('backend.list.myEvent', ['my value']);
Is equivalent to:
$this->fireEvent('list.myEvent', ['myvalue'], true);
Event::fire('backend.list.myEvent', [$this, 'myvalue'], true);
@param string $event Event name
@param array $params Event parameters
@param boolean $halt Halt after first non-null result
@return mixed | [
"Fires",
"a",
"combination",
"of",
"local",
"and",
"global",
"events",
".",
"The",
"first",
"segment",
"is",
"removed",
"from",
"the",
"event",
"name",
"locally",
"and",
"the",
"local",
"object",
"is",
"passed",
"as",
"the",
"first",
"argument",
"to",
"the... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/EventEmitter.php#L36-L67 | train | Fires system event | [
30522,
2270,
3853,
8769,
27268,
21382,
15338,
1006,
1002,
2724,
1010,
1002,
11498,
5244,
1027,
1031,
1033,
1010,
1002,
9190,
1027,
2995,
1007,
1063,
1002,
2765,
1027,
1031,
1033,
1025,
1002,
2460,
18697,
3372,
1027,
4942,
3367,
2099,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php | TextBundleWriter.writeTable | private function writeTable($file, $value, $indentation, $fallback = true)
{
if (!\is_array($value) && !$value instanceof \Traversable) {
throw new UnexpectedTypeException($value, 'array or \Traversable');
}
if (!$fallback) {
fwrite($file, ':table(nofallback)');
}
fwrite($file, "{\n");
foreach ($value as $key => $entry) {
fwrite($file, str_repeat(' ', $indentation + 1));
// escape colons, otherwise they are interpreted as resource types
if (false !== strpos($key, ':') || false !== strpos($key, ' ')) {
$key = '"'.$key.'"';
}
fwrite($file, $key);
$this->writeResource($file, $entry, $indentation + 1);
fwrite($file, "\n");
}
fprintf($file, '%s}', str_repeat(' ', $indentation));
} | php | private function writeTable($file, $value, $indentation, $fallback = true)
{
if (!\is_array($value) && !$value instanceof \Traversable) {
throw new UnexpectedTypeException($value, 'array or \Traversable');
}
if (!$fallback) {
fwrite($file, ':table(nofallback)');
}
fwrite($file, "{\n");
foreach ($value as $key => $entry) {
fwrite($file, str_repeat(' ', $indentation + 1));
// escape colons, otherwise they are interpreted as resource types
if (false !== strpos($key, ':') || false !== strpos($key, ' ')) {
$key = '"'.$key.'"';
}
fwrite($file, $key);
$this->writeResource($file, $entry, $indentation + 1);
fwrite($file, "\n");
}
fprintf($file, '%s}', str_repeat(' ', $indentation));
} | [
"private",
"function",
"writeTable",
"(",
"$",
"file",
",",
"$",
"value",
",",
"$",
"indentation",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"$",
"value",
"instanceof",
"\\",
"... | Writes a "table" node.
@param resource $file The file handle to write to
@param iterable $value The value of the node
@param int $indentation The number of levels to indent
@param bool $fallback Whether the table should be merged
with the fallback locale
@throws UnexpectedTypeException when $value is not an array and not a
\Traversable instance | [
"Writes",
"a",
"table",
"node",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php#L207-L235 | train | Write a table | [
30522,
2797,
3853,
4339,
10880,
1006,
1002,
5371,
1010,
1002,
3643,
1010,
1002,
27427,
19304,
1010,
1002,
2991,
5963,
1027,
2995,
1007,
1063,
2065,
1006,
999,
1032,
2003,
1035,
9140,
1006,
1002,
3643,
1007,
1004,
1004,
999,
1002,
3643,
60... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php | NativeSessionStorage.setOptions | public function setOptions(array $options)
{
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
return;
}
$validOptions = array_flip([
'cache_expire', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
'cookie_lifetime', 'cookie_path', 'cookie_secure', 'cookie_samesite',
'gc_divisor', 'gc_maxlifetime', 'gc_probability',
'lazy_write', 'name', 'referer_check',
'serialize_handler', 'use_strict_mode', 'use_cookies',
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
'upload_progress.freq', 'upload_progress.min_freq', 'url_rewriter.tags',
'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
]);
foreach ($options as $key => $value) {
if (isset($validOptions[$key])) {
if ('cookie_samesite' === $key && \PHP_VERSION_ID < 70300) {
// PHP < 7.3 does not support same_site cookies. We will emulate it in
// the start() method instead.
$this->emulateSameSite = $value;
continue;
}
ini_set('url_rewriter.tags' !== $key ? 'session.'.$key : $key, $value);
}
}
} | php | public function setOptions(array $options)
{
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
return;
}
$validOptions = array_flip([
'cache_expire', 'cache_limiter', 'cookie_domain', 'cookie_httponly',
'cookie_lifetime', 'cookie_path', 'cookie_secure', 'cookie_samesite',
'gc_divisor', 'gc_maxlifetime', 'gc_probability',
'lazy_write', 'name', 'referer_check',
'serialize_handler', 'use_strict_mode', 'use_cookies',
'use_only_cookies', 'use_trans_sid', 'upload_progress.enabled',
'upload_progress.cleanup', 'upload_progress.prefix', 'upload_progress.name',
'upload_progress.freq', 'upload_progress.min_freq', 'url_rewriter.tags',
'sid_length', 'sid_bits_per_character', 'trans_sid_hosts', 'trans_sid_tags',
]);
foreach ($options as $key => $value) {
if (isset($validOptions[$key])) {
if ('cookie_samesite' === $key && \PHP_VERSION_ID < 70300) {
// PHP < 7.3 does not support same_site cookies. We will emulate it in
// the start() method instead.
$this->emulateSameSite = $value;
continue;
}
ini_set('url_rewriter.tags' !== $key ? 'session.'.$key : $key, $value);
}
}
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
"||",
"\\",
"PHP_SESSION_ACTIVE",
"===",
"session_status",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"validOptions",
"=",
"array_flip",
"(",... | Sets session.* ini variables.
For convenience we omit 'session.' from the beginning of the keys.
Explicitly ignores other ini keys.
@param array $options Session ini directives [key => value]
@see http://php.net/session.configuration | [
"Sets",
"session",
".",
"*",
"ini",
"variables",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L356-L385 | train | Set the session options | [
30522,
2270,
3853,
2275,
7361,
9285,
1006,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
20346,
2015,
1035,
2741,
1006,
1007,
1064,
1064,
1032,
25718,
1035,
5219,
1035,
3161,
1027,
1027,
1027,
5219,
1035,
3570,
1006,
1007,
1007,
1063,
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... |
barryvdh/laravel-debugbar | src/Storage/FilesystemStorage.php | FilesystemStorage.save | public function save($id, $data)
{
if (!$this->files->isDirectory($this->dirname)) {
if ($this->files->makeDirectory($this->dirname, 0777, true)) {
$this->files->put($this->dirname . '.gitignore', "*\n!.gitignore\n");
} else {
throw new \Exception("Cannot create directory '$this->dirname'..");
}
}
try {
$this->files->put($this->makeFilename($id), json_encode($data));
} catch (\Exception $e) {
//TODO; error handling
}
// Randomly check if we should collect old files
if (rand(1, 100) <= $this->gc_probability) {
$this->garbageCollect();
}
} | php | public function save($id, $data)
{
if (!$this->files->isDirectory($this->dirname)) {
if ($this->files->makeDirectory($this->dirname, 0777, true)) {
$this->files->put($this->dirname . '.gitignore', "*\n!.gitignore\n");
} else {
throw new \Exception("Cannot create directory '$this->dirname'..");
}
}
try {
$this->files->put($this->makeFilename($id), json_encode($data));
} catch (\Exception $e) {
//TODO; error handling
}
// Randomly check if we should collect old files
if (rand(1, 100) <= $this->gc_probability) {
$this->garbageCollect();
}
} | [
"public",
"function",
"save",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"this",
"->",
"dirname",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"makeDirecto... | {@inheritDoc} | [
"{"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/Storage/FilesystemStorage.php#L32-L52 | train | Save the data to the cache | [
30522,
2270,
3853,
3828,
1006,
1002,
8909,
1010,
1002,
2951,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
6764,
1011,
1028,
2003,
4305,
2890,
16761,
2100,
1006,
1002,
2023,
1011,
1028,
16101,
18442,
1007,
1007,
1063,
2065,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement/Pdo.php | Zend_Db_Statement_Pdo.bindColumn | public function bindColumn($column, &$param, $type = null)
{
try {
if ($type === null) {
return $this->_stmt->bindColumn($column, $param);
} else {
return $this->_stmt->bindColumn($column, $param, $type);
}
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | php | public function bindColumn($column, &$param, $type = null)
{
try {
if ($type === null) {
return $this->_stmt->bindColumn($column, $param);
} else {
return $this->_stmt->bindColumn($column, $param, $type);
}
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"bindColumn",
"(",
"$",
"column",
",",
"&",
"$",
"param",
",",
"$",
"type",
"=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_stmt",
"->",
"bindColumn",
"(",
"... | Bind a column of the statement result set to a PHP variable.
@param string $column Name the column in the result set, either by
position or by name.
@param mixed $param Reference to the PHP variable containing the value.
@param mixed $type OPTIONAL
@return bool
@throws Zend_Db_Statement_Exception | [
"Bind",
"a",
"column",
"of",
"the",
"statement",
"result",
"set",
"to",
"a",
"PHP",
"variable",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Pdo.php#L75-L87 | train | Binds a column to a variable | [
30522,
2270,
3853,
14187,
25778,
2819,
2078,
1006,
1002,
5930,
1010,
1004,
1002,
11498,
2213,
1010,
1002,
2828,
1027,
19701,
1007,
1063,
3046,
1063,
2065,
1006,
1002,
2828,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
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/Cache/Repository.php | Repository.getSeconds | protected function getSeconds($ttl)
{
$duration = $this->parseDateInterval($ttl);
if ($duration instanceof DateTimeInterface) {
$duration = Carbon::now()->diffInRealSeconds($duration, false);
}
return (int) $duration > 0 ? $duration : 0;
} | php | protected function getSeconds($ttl)
{
$duration = $this->parseDateInterval($ttl);
if ($duration instanceof DateTimeInterface) {
$duration = Carbon::now()->diffInRealSeconds($duration, false);
}
return (int) $duration > 0 ? $duration : 0;
} | [
"protected",
"function",
"getSeconds",
"(",
"$",
"ttl",
")",
"{",
"$",
"duration",
"=",
"$",
"this",
"->",
"parseDateInterval",
"(",
"$",
"ttl",
")",
";",
"if",
"(",
"$",
"duration",
"instanceof",
"DateTimeInterface",
")",
"{",
"$",
"duration",
"=",
"Car... | Calculate the number of seconds for the given TTL.
@param \DateTimeInterface|\DateInterval|int $ttl
@return int | [
"Calculate",
"the",
"number",
"of",
"seconds",
"for",
"the",
"given",
"TTL",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/Repository.php#L616-L625 | train | Get seconds from ttl | [
30522,
5123,
3853,
4152,
8586,
15422,
2015,
1006,
1002,
23746,
2140,
1007,
1063,
1002,
9367,
1027,
1002,
2023,
1011,
1028,
11968,
6924,
3686,
18447,
2121,
10175,
1006,
1002,
23746,
2140,
1007,
1025,
2065,
1006,
1002,
9367,
6013,
11253,
3058... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Segment/SegmentExpression.php | SegmentExpression.parseTree | protected function parseTree()
{
$string = $this->string;
if (empty($string)) {
return array();
}
$tree = array();
$i = 0;
$length = strlen($string);
$isBackslash = false;
$operand = '';
while ($i <= $length) {
$char = $string[$i];
$isAND = ($char == self::AND_DELIMITER);
$isOR = ($char == self::OR_DELIMITER);
$isEnd = ($length == $i + 1);
if ($isEnd) {
if ($isBackslash && ($isAND || $isOR)) {
$operand = substr($operand, 0, -1);
}
$operand .= $char;
$tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_END, self::INDEX_OPERAND => $operand);
break;
}
if ($isAND && !$isBackslash) {
$tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_AND, self::INDEX_OPERAND => $operand);
$operand = '';
} elseif ($isOR && !$isBackslash) {
$tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_OR, self::INDEX_OPERAND => $operand);
$operand = '';
} else {
if ($isBackslash && ($isAND || $isOR)) {
$operand = substr($operand, 0, -1);
}
$operand .= $char;
}
$isBackslash = ($char == "\\");
$i++;
}
return $tree;
} | php | protected function parseTree()
{
$string = $this->string;
if (empty($string)) {
return array();
}
$tree = array();
$i = 0;
$length = strlen($string);
$isBackslash = false;
$operand = '';
while ($i <= $length) {
$char = $string[$i];
$isAND = ($char == self::AND_DELIMITER);
$isOR = ($char == self::OR_DELIMITER);
$isEnd = ($length == $i + 1);
if ($isEnd) {
if ($isBackslash && ($isAND || $isOR)) {
$operand = substr($operand, 0, -1);
}
$operand .= $char;
$tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_END, self::INDEX_OPERAND => $operand);
break;
}
if ($isAND && !$isBackslash) {
$tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_AND, self::INDEX_OPERAND => $operand);
$operand = '';
} elseif ($isOR && !$isBackslash) {
$tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_OR, self::INDEX_OPERAND => $operand);
$operand = '';
} else {
if ($isBackslash && ($isAND || $isOR)) {
$operand = substr($operand, 0, -1);
}
$operand .= $char;
}
$isBackslash = ($char == "\\");
$i++;
}
return $tree;
} | [
"protected",
"function",
"parseTree",
"(",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"string",
";",
"if",
"(",
"empty",
"(",
"$",
"string",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"tree",
"=",
"array",
"(",
")",
";",
"... | Given a filter string,
will parse it into an array where each row contains the boolean operator applied to it,
and the operand
@return array | [
"Given",
"a",
"filter",
"string",
"will",
"parse",
"it",
"into",
"an",
"array",
"where",
"each",
"row",
"contains",
"the",
"boolean",
"operator",
"applied",
"to",
"it",
"and",
"the",
"operand"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Segment/SegmentExpression.php#L390-L433 | train | Parse tree of terms | [
30522,
5123,
3853,
11968,
13462,
9910,
1006,
1007,
1063,
1002,
5164,
1027,
1002,
2023,
1011,
1028,
5164,
1025,
2065,
1006,
4064,
1006,
1002,
5164,
1007,
1007,
1063,
2709,
9140,
1006,
1007,
1025,
1065,
1002,
3392,
1027,
9140,
1006,
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... |
getgrav/grav | system/src/Grav/Common/Grav.php | Grav.process | public function process()
{
if (isset($this->initialized['process'])) {
return;
}
// Initialize Grav if needed.
$this->setup();
$this->initialized['process'] = true;
$container = new Container(
[
'configurationProcessor' => function () {
return new ConfigurationProcessor($this);
},
'loggerProcessor' => function () {
return new LoggerProcessor($this);
},
'errorsProcessor' => function () {
return new ErrorsProcessor($this);
},
'debuggerProcessor' => function () {
return new DebuggerProcessor($this);
},
'initializeProcessor' => function () {
return new InitializeProcessor($this);
},
'backupsProcessor' => function () {
return new BackupsProcessor($this);
},
'pluginsProcessor' => function () {
return new PluginsProcessor($this);
},
'themesProcessor' => function () {
return new ThemesProcessor($this);
},
'schedulerProcessor' => function () {
return new SchedulerProcessor($this);
},
'requestProcessor' => function () {
return new RequestProcessor($this);
},
'tasksProcessor' => function () {
return new TasksProcessor($this);
},
'assetsProcessor' => function () {
return new AssetsProcessor($this);
},
'twigProcessor' => function () {
return new TwigProcessor($this);
},
'pagesProcessor' => function () {
return new PagesProcessor($this);
},
'debuggerAssetsProcessor' => function () {
return new DebuggerAssetsProcessor($this);
},
'renderProcessor' => function () {
return new RenderProcessor($this);
},
]
);
$default = function (ServerRequestInterface $request) {
return new Response(404);
};
/** @var Debugger $debugger */
$debugger = $this['debugger'];
$collection = new RequestHandler($this->middleware, $default, $container);
$response = $collection->handle($this['request']);
$this->header($response);
echo $response->getBody();
$debugger->render();
register_shutdown_function([$this, 'shutdown']);
} | php | public function process()
{
if (isset($this->initialized['process'])) {
return;
}
// Initialize Grav if needed.
$this->setup();
$this->initialized['process'] = true;
$container = new Container(
[
'configurationProcessor' => function () {
return new ConfigurationProcessor($this);
},
'loggerProcessor' => function () {
return new LoggerProcessor($this);
},
'errorsProcessor' => function () {
return new ErrorsProcessor($this);
},
'debuggerProcessor' => function () {
return new DebuggerProcessor($this);
},
'initializeProcessor' => function () {
return new InitializeProcessor($this);
},
'backupsProcessor' => function () {
return new BackupsProcessor($this);
},
'pluginsProcessor' => function () {
return new PluginsProcessor($this);
},
'themesProcessor' => function () {
return new ThemesProcessor($this);
},
'schedulerProcessor' => function () {
return new SchedulerProcessor($this);
},
'requestProcessor' => function () {
return new RequestProcessor($this);
},
'tasksProcessor' => function () {
return new TasksProcessor($this);
},
'assetsProcessor' => function () {
return new AssetsProcessor($this);
},
'twigProcessor' => function () {
return new TwigProcessor($this);
},
'pagesProcessor' => function () {
return new PagesProcessor($this);
},
'debuggerAssetsProcessor' => function () {
return new DebuggerAssetsProcessor($this);
},
'renderProcessor' => function () {
return new RenderProcessor($this);
},
]
);
$default = function (ServerRequestInterface $request) {
return new Response(404);
};
/** @var Debugger $debugger */
$debugger = $this['debugger'];
$collection = new RequestHandler($this->middleware, $default, $container);
$response = $collection->handle($this['request']);
$this->header($response);
echo $response->getBody();
$debugger->render();
register_shutdown_function([$this, 'shutdown']);
} | [
"public",
"function",
"process",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"initialized",
"[",
"'process'",
"]",
")",
")",
"{",
"return",
";",
"}",
"// Initialize Grav if needed.",
"$",
"this",
"->",
"setup",
"(",
")",
";",
"$",
"this"... | Process a request | [
"Process",
"a",
"request"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Grav.php#L176-L257 | train | Processes the request and returns the response. | [
30522,
2270,
3853,
2832,
1006,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
3988,
3550,
1031,
1005,
2832,
1005,
1033,
1007,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
3988,
4697,
24665,
11431,
2065,
2734,
1012,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.