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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
laravel/framework | src/Illuminate/View/Compilers/BladeCompiler.php | BladeCompiler.getOpenAndClosingPhpTokens | protected function getOpenAndClosingPhpTokens($contents)
{
return collect(token_get_all($contents))
->pluck($tokenNumber = 0)
->filter(function ($token) {
return in_array($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG]);
});
} | php | protected function getOpenAndClosingPhpTokens($contents)
{
return collect(token_get_all($contents))
->pluck($tokenNumber = 0)
->filter(function ($token) {
return in_array($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG]);
});
} | [
"protected",
"function",
"getOpenAndClosingPhpTokens",
"(",
"$",
"contents",
")",
"{",
"return",
"collect",
"(",
"token_get_all",
"(",
"$",
"contents",
")",
")",
"->",
"pluck",
"(",
"$",
"tokenNumber",
"=",
"0",
")",
"->",
"filter",
"(",
"function",
"(",
"... | Get the open and closing PHP tag tokens from the given string.
@param string $contents
@return \Illuminate\Support\Collection | [
"Get",
"the",
"open",
"and",
"closing",
"PHP",
"tag",
"tokens",
"from",
"the",
"given",
"string",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Compilers/BladeCompiler.php#L151-L158 | train | Get all php tokens from the given string | [
30522,
5123,
3853,
2131,
26915,
5685,
20464,
18606,
8458,
13876,
11045,
3619,
1006,
1002,
8417,
1007,
1063,
2709,
8145,
1006,
19204,
1035,
2131,
1035,
2035,
1006,
1002,
8417,
1007,
1007,
1011,
1028,
20228,
12722,
1006,
1002,
19204,
19172,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PHPMailer/PHPMailer | src/SMTP.php | SMTP.recordLastTransactionID | protected function recordLastTransactionID()
{
$reply = $this->getLastReply();
if (empty($reply)) {
$this->last_smtp_transaction_id = null;
} else {
$this->last_smtp_transaction_id = false;
foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
$this->last_smtp_transaction_id = trim($matches[1]);
break;
}
}
}
return $this->last_smtp_transaction_id;
} | php | protected function recordLastTransactionID()
{
$reply = $this->getLastReply();
if (empty($reply)) {
$this->last_smtp_transaction_id = null;
} else {
$this->last_smtp_transaction_id = false;
foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
$this->last_smtp_transaction_id = trim($matches[1]);
break;
}
}
}
return $this->last_smtp_transaction_id;
} | [
"protected",
"function",
"recordLastTransactionID",
"(",
")",
"{",
"$",
"reply",
"=",
"$",
"this",
"->",
"getLastReply",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"reply",
")",
")",
"{",
"$",
"this",
"->",
"last_smtp_transaction_id",
"=",
"null",
";",... | Extract and return the ID of the last SMTP transaction based on
a list of patterns provided in SMTP::$smtp_transaction_id_patterns.
Relies on the host providing the ID in response to a DATA command.
If no reply has been received yet, it will return null.
If no pattern was matched, it will return false.
@return bool|null|string | [
"Extract",
"and",
"return",
"the",
"ID",
"of",
"the",
"last",
"SMTP",
"transaction",
"based",
"on",
"a",
"list",
"of",
"patterns",
"provided",
"in",
"SMTP",
"::",
"$smtp_transaction_id_patterns",
".",
"Relies",
"on",
"the",
"host",
"providing",
"the",
"ID",
... | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/SMTP.php#L1315-L1332 | train | Get Last Smtp Transaction ID | [
30522,
5123,
3853,
2501,
8523,
4779,
5521,
3736,
7542,
3593,
1006,
1007,
1063,
1002,
7514,
1027,
1002,
2023,
1011,
1028,
2131,
8523,
7913,
22086,
1006,
1007,
1025,
2065,
1006,
4064,
1006,
1002,
7514,
1007,
1007,
1063,
1002,
2023,
1011,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Cache.php | Cache.purgeOldCache | public function purgeOldCache()
{
$cache_dir = dirname($this->cache_dir);
$current = basename($this->cache_dir);
$count = 0;
foreach (new \DirectoryIterator($cache_dir) as $file) {
$dir = $file->getBasename();
if ($dir === $current || $file->isDot() || $file->isFile()) {
continue;
}
Folder::delete($file->getPathname());
$count++;
}
return $count;
} | php | public function purgeOldCache()
{
$cache_dir = dirname($this->cache_dir);
$current = basename($this->cache_dir);
$count = 0;
foreach (new \DirectoryIterator($cache_dir) as $file) {
$dir = $file->getBasename();
if ($dir === $current || $file->isDot() || $file->isFile()) {
continue;
}
Folder::delete($file->getPathname());
$count++;
}
return $count;
} | [
"public",
"function",
"purgeOldCache",
"(",
")",
"{",
"$",
"cache_dir",
"=",
"dirname",
"(",
"$",
"this",
"->",
"cache_dir",
")",
";",
"$",
"current",
"=",
"basename",
"(",
"$",
"this",
"->",
"cache_dir",
")",
";",
"$",
"count",
"=",
"0",
";",
"forea... | Deletes the old out of date file-based caches
@return int | [
"Deletes",
"the",
"old",
"out",
"of",
"date",
"file",
"-",
"based",
"caches"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Cache.php#L171-L188 | train | Purge old cache | [
30522,
2270,
3853,
24694,
11614,
3540,
5403,
1006,
1007,
1063,
1002,
17053,
1035,
16101,
1027,
16101,
18442,
1006,
1002,
2023,
1011,
1028,
17053,
1035,
16101,
1007,
1025,
1002,
2783,
1027,
2918,
18442,
1006,
1002,
2023,
1011,
1028,
17053,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/Model.php | Model.getSitesWithVisits | public function getSitesWithVisits($time, $now)
{
$sites = Db::fetchAll("
SELECT idsite FROM " . $this->table . " s
WHERE EXISTS (
SELECT 1
FROM " . Common::prefixTable('log_visit') . " v
WHERE v.idsite = s.idsite
AND visit_last_action_time > ?
AND visit_last_action_time <= ?
LIMIT 1)
", array($time, $now));
return $sites;
} | php | public function getSitesWithVisits($time, $now)
{
$sites = Db::fetchAll("
SELECT idsite FROM " . $this->table . " s
WHERE EXISTS (
SELECT 1
FROM " . Common::prefixTable('log_visit') . " v
WHERE v.idsite = s.idsite
AND visit_last_action_time > ?
AND visit_last_action_time <= ?
LIMIT 1)
", array($time, $now));
return $sites;
} | [
"public",
"function",
"getSitesWithVisits",
"(",
"$",
"time",
",",
"$",
"now",
")",
"{",
"$",
"sites",
"=",
"Db",
"::",
"fetchAll",
"(",
"\"\n SELECT idsite FROM \"",
".",
"$",
"this",
"->",
"table",
".",
"\" s\n WHERE EXISTS (\n ... | Returns the list of the website IDs that received some visits since the specified timestamp.
@param string $time
@param string $now
@return array The list of website IDs | [
"Returns",
"the",
"list",
"of",
"the",
"website",
"IDs",
"that",
"received",
"some",
"visits",
"since",
"the",
"specified",
"timestamp",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/Model.php#L90-L104 | train | Get all the sites with visits | [
30522,
2270,
3853,
4152,
7616,
24415,
11365,
12762,
1006,
1002,
2051,
1010,
1002,
2085,
1007,
1063,
1002,
4573,
1027,
16962,
1024,
1024,
18584,
8095,
1006,
1000,
7276,
8909,
28032,
2063,
2013,
1000,
1012,
1002,
2023,
1011,
1028,
2795,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/FilesystemAdapter.php | FilesystemAdapter.download | public function download($path, $name = null, array $headers = [])
{
return $this->response($path, $name, $headers, 'attachment');
} | php | public function download($path, $name = null, array $headers = [])
{
return $this->response($path, $name, $headers, 'attachment');
} | [
"public",
"function",
"download",
"(",
"$",
"path",
",",
"$",
"name",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"response",
"(",
"$",
"path",
",",
"$",
"name",
",",
"$",
"headers",
",",
"'att... | Create a streamed download response for a given file.
@param string $path
@param string|null $name
@param array|null $headers
@return \Symfony\Component\HttpFoundation\StreamedResponse | [
"Create",
"a",
"streamed",
"download",
"response",
"for",
"a",
"given",
"file",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/FilesystemAdapter.php#L166-L169 | train | Download a file to the browser | [
30522,
2270,
3853,
8816,
1006,
1002,
4130,
1010,
1002,
2171,
1027,
19701,
1010,
9140,
1002,
20346,
2015,
1027,
1031,
1033,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
3433,
1006,
1002,
4130,
1010,
1002,
2171,
1010,
1002,
20346,
2015,
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/Cache/Traits/PdoTrait.php | PdoTrait.doSave | protected function doSave(array $values, $lifetime)
{
if (!$values = $this->marshaller->marshall($values, $failed)) {
return $failed;
}
$conn = $this->getConnection();
$driver = $this->driver;
$insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)";
switch (true) {
case 'mysql' === $driver:
$sql = $insertSql." ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)";
break;
case 'oci' === $driver:
// DUAL is Oracle specific dummy table
$sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ".
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
"WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?";
break;
case 'sqlsrv' === $driver && version_compare($this->getServerVersion(), '10', '>='):
// MERGE is only available since SQL Server 2008 and must be terminated by semicolon
// It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
$sql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ".
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
"WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;";
break;
case 'sqlite' === $driver:
$sql = 'INSERT OR REPLACE'.substr($insertSql, 6);
break;
case 'pgsql' === $driver && version_compare($this->getServerVersion(), '9.5', '>='):
$sql = $insertSql." ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)";
break;
default:
$driver = null;
$sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id";
break;
}
$now = time();
$lifetime = $lifetime ?: null;
try {
$stmt = $conn->prepare($sql);
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt = $conn->prepare($sql);
}
if ('sqlsrv' === $driver || 'oci' === $driver) {
$stmt->bindParam(1, $id);
$stmt->bindParam(2, $id);
$stmt->bindParam(3, $data, \PDO::PARAM_LOB);
$stmt->bindValue(4, $lifetime, \PDO::PARAM_INT);
$stmt->bindValue(5, $now, \PDO::PARAM_INT);
$stmt->bindParam(6, $data, \PDO::PARAM_LOB);
$stmt->bindValue(7, $lifetime, \PDO::PARAM_INT);
$stmt->bindValue(8, $now, \PDO::PARAM_INT);
} else {
$stmt->bindParam(':id', $id);
$stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
$stmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT);
$stmt->bindValue(':time', $now, \PDO::PARAM_INT);
}
if (null === $driver) {
$insertStmt = $conn->prepare($insertSql);
$insertStmt->bindParam(':id', $id);
$insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
$insertStmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT);
$insertStmt->bindValue(':time', $now, \PDO::PARAM_INT);
}
foreach ($values as $id => $data) {
try {
$stmt->execute();
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt->execute();
}
if (null === $driver && !$stmt->rowCount()) {
try {
$insertStmt->execute();
} catch (DBALException $e) {
} catch (\PDOException $e) {
// A concurrent write won, let it be
}
}
}
return $failed;
} | php | protected function doSave(array $values, $lifetime)
{
if (!$values = $this->marshaller->marshall($values, $failed)) {
return $failed;
}
$conn = $this->getConnection();
$driver = $this->driver;
$insertSql = "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (:id, :data, :lifetime, :time)";
switch (true) {
case 'mysql' === $driver:
$sql = $insertSql." ON DUPLICATE KEY UPDATE $this->dataCol = VALUES($this->dataCol), $this->lifetimeCol = VALUES($this->lifetimeCol), $this->timeCol = VALUES($this->timeCol)";
break;
case 'oci' === $driver:
// DUAL is Oracle specific dummy table
$sql = "MERGE INTO $this->table USING DUAL ON ($this->idCol = ?) ".
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
"WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?";
break;
case 'sqlsrv' === $driver && version_compare($this->getServerVersion(), '10', '>='):
// MERGE is only available since SQL Server 2008 and must be terminated by semicolon
// It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
$sql = "MERGE INTO $this->table WITH (HOLDLOCK) USING (SELECT 1 AS dummy) AS src ON ($this->idCol = ?) ".
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->lifetimeCol, $this->timeCol) VALUES (?, ?, ?, ?) ".
"WHEN MATCHED THEN UPDATE SET $this->dataCol = ?, $this->lifetimeCol = ?, $this->timeCol = ?;";
break;
case 'sqlite' === $driver:
$sql = 'INSERT OR REPLACE'.substr($insertSql, 6);
break;
case 'pgsql' === $driver && version_compare($this->getServerVersion(), '9.5', '>='):
$sql = $insertSql." ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->lifetimeCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->lifetimeCol, EXCLUDED.$this->timeCol)";
break;
default:
$driver = null;
$sql = "UPDATE $this->table SET $this->dataCol = :data, $this->lifetimeCol = :lifetime, $this->timeCol = :time WHERE $this->idCol = :id";
break;
}
$now = time();
$lifetime = $lifetime ?: null;
try {
$stmt = $conn->prepare($sql);
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt = $conn->prepare($sql);
}
if ('sqlsrv' === $driver || 'oci' === $driver) {
$stmt->bindParam(1, $id);
$stmt->bindParam(2, $id);
$stmt->bindParam(3, $data, \PDO::PARAM_LOB);
$stmt->bindValue(4, $lifetime, \PDO::PARAM_INT);
$stmt->bindValue(5, $now, \PDO::PARAM_INT);
$stmt->bindParam(6, $data, \PDO::PARAM_LOB);
$stmt->bindValue(7, $lifetime, \PDO::PARAM_INT);
$stmt->bindValue(8, $now, \PDO::PARAM_INT);
} else {
$stmt->bindParam(':id', $id);
$stmt->bindParam(':data', $data, \PDO::PARAM_LOB);
$stmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT);
$stmt->bindValue(':time', $now, \PDO::PARAM_INT);
}
if (null === $driver) {
$insertStmt = $conn->prepare($insertSql);
$insertStmt->bindParam(':id', $id);
$insertStmt->bindParam(':data', $data, \PDO::PARAM_LOB);
$insertStmt->bindValue(':lifetime', $lifetime, \PDO::PARAM_INT);
$insertStmt->bindValue(':time', $now, \PDO::PARAM_INT);
}
foreach ($values as $id => $data) {
try {
$stmt->execute();
} catch (TableNotFoundException $e) {
if (!$conn->isTransactionActive() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt->execute();
}
if (null === $driver && !$stmt->rowCount()) {
try {
$insertStmt->execute();
} catch (DBALException $e) {
} catch (\PDOException $e) {
// A concurrent write won, let it be
}
}
}
return $failed;
} | [
"protected",
"function",
"doSave",
"(",
"array",
"$",
"values",
",",
"$",
"lifetime",
")",
"{",
"if",
"(",
"!",
"$",
"values",
"=",
"$",
"this",
"->",
"marshaller",
"->",
"marshall",
"(",
"$",
"values",
",",
"$",
"failed",
")",
")",
"{",
"return",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/PdoTrait.php#L271-L365 | train | Save data into database | [
30522,
5123,
3853,
9998,
10696,
1006,
9140,
1002,
5300,
1010,
1002,
6480,
1007,
1063,
2065,
1006,
999,
1002,
5300,
1027,
1002,
2023,
1011,
1028,
5832,
2121,
1011,
1028,
5832,
1006,
1002,
5300,
1010,
1002,
3478,
1007,
1007,
1063,
2709,
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/Form/Field/Map.php | Map.getAssets | public static function getAssets()
{
switch (config('admin.map_provider')) {
case 'tencent':
$js = '//map.qq.com/api/js?v=2.exp&key='.env('TENCENT_MAP_API_KEY');
break;
case 'google':
$js = '//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key='.env('GOOGLE_API_KEY');
break;
case 'yandex':
$js = '//api-maps.yandex.ru/2.1/?lang=ru_RU';
break;
default:
$js = '//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key='.env('GOOGLE_API_KEY');
}
return compact('js');
} | php | public static function getAssets()
{
switch (config('admin.map_provider')) {
case 'tencent':
$js = '//map.qq.com/api/js?v=2.exp&key='.env('TENCENT_MAP_API_KEY');
break;
case 'google':
$js = '//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key='.env('GOOGLE_API_KEY');
break;
case 'yandex':
$js = '//api-maps.yandex.ru/2.1/?lang=ru_RU';
break;
default:
$js = '//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key='.env('GOOGLE_API_KEY');
}
return compact('js');
} | [
"public",
"static",
"function",
"getAssets",
"(",
")",
"{",
"switch",
"(",
"config",
"(",
"'admin.map_provider'",
")",
")",
"{",
"case",
"'tencent'",
":",
"$",
"js",
"=",
"'//map.qq.com/api/js?v=2.exp&key='",
".",
"env",
"(",
"'TENCENT_MAP_API_KEY'",
")",
";",
... | Get assets required by this field.
@return array | [
"Get",
"assets",
"required",
"by",
"this",
"field",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/Map.php#L21-L38 | train | Get assets from the map provider | [
30522,
2270,
10763,
3853,
2131,
27241,
3215,
1006,
1007,
1063,
6942,
1006,
9530,
8873,
2290,
1006,
1005,
4748,
10020,
1012,
4949,
1035,
10802,
1005,
1007,
1007,
1063,
2553,
1005,
2702,
13013,
1005,
1024,
1002,
1046,
2015,
1027,
1005,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Auth/AuthenticatesUsers.php | AuthenticatesUsers.attemptLogin | protected function attemptLogin(Request $request)
{
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
} | php | protected function attemptLogin(Request $request)
{
return $this->guard()->attempt(
$this->credentials($request), $request->filled('remember')
);
} | [
"protected",
"function",
"attemptLogin",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"$",
"this",
"->",
"guard",
"(",
")",
"->",
"attempt",
"(",
"$",
"this",
"->",
"credentials",
"(",
"$",
"request",
")",
",",
"$",
"request",
"->",
"filled",
"(... | Attempt to log the user into the application.
@param \Illuminate\Http\Request $request
@return bool | [
"Attempt",
"to",
"log",
"the",
"user",
"into",
"the",
"application",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php#L78-L83 | train | Attempts to login using the guard. | [
30522,
5123,
3853,
3535,
21197,
2378,
1006,
5227,
1002,
5227,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
3457,
1006,
1007,
1011,
1028,
3535,
1006,
1002,
2023,
1011,
1028,
22496,
1006,
1002,
5227,
1007,
1010,
1002,
5227,
1011,
1028,
3561,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/DevicesDetection/API.php | API.getOsVersions | public function getOsVersions($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
$segments = array('operatingSystemCode', 'operatingSystemVersion');
$dataTable->filter('AddSegmentByLabel', array($segments, Archiver::BROWSER_SEPARATOR));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogo'));
// use GroupBy filter to avoid duplicate rows if old (UserSettings) and new (DevicesDetection) reports were combined
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOsFullName'));
return $dataTable;
} | php | public function getOsVersions($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
$segments = array('operatingSystemCode', 'operatingSystemVersion');
$dataTable->filter('AddSegmentByLabel', array($segments, Archiver::BROWSER_SEPARATOR));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogo'));
// use GroupBy filter to avoid duplicate rows if old (UserSettings) and new (DevicesDetection) reports were combined
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOsFullName'));
return $dataTable;
} | [
"public",
"function",
"getOsVersions",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
")",
"{",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getDataTable",
"(",
"'DevicesDetection_osVersions'",
",",
"$",
"idSite"... | Gets datatable displaying number of visits by OS version (eg. Android 4.0, Windows 7)
@param int $idSite
@param string $period
@param string $date
@param bool|string $segment
@return DataTable | [
"Gets",
"datatable",
"displaying",
"number",
"of",
"visits",
"by",
"OS",
"version",
"(",
"eg",
".",
"Android",
"4",
".",
"0",
"Windows",
"7",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DevicesDetection/API.php#L216-L226 | train | Get OS versions | [
30522,
2270,
3853,
2131,
2891,
27774,
2015,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1007,
1063,
1002,
2951,
10880,
1027,
1002,
2023,
1011,
1028,
2131,
2850,
29336,
3085,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Console/Gpm/UninstallCommand.php | UninstallCommand.checkDestination | private function checkDestination($slug, $package)
{
$questionHelper = $this->getHelper('question');
$exists = $this->packageExists($slug, $package);
if ($exists == Installer::IS_LINK) {
$this->output->write("\x0D");
$this->output->writeln(' |- Checking destination... <yellow>symbolic link</yellow>');
if ($this->all_yes) {
$this->output->writeln(" | '- <yellow>Skipped automatically.</yellow>");
return false;
}
$question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ",
false);
$answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question);
if (!$answer) {
$this->output->writeln(" | '- <red>You decided not to delete the symlink automatically.</red>");
return false;
}
}
$this->output->write("\x0D");
$this->output->writeln(' |- Checking destination... <green>ok</green>');
return true;
} | php | private function checkDestination($slug, $package)
{
$questionHelper = $this->getHelper('question');
$exists = $this->packageExists($slug, $package);
if ($exists == Installer::IS_LINK) {
$this->output->write("\x0D");
$this->output->writeln(' |- Checking destination... <yellow>symbolic link</yellow>');
if ($this->all_yes) {
$this->output->writeln(" | '- <yellow>Skipped automatically.</yellow>");
return false;
}
$question = new ConfirmationQuestion(" | '- Destination has been detected as symlink, delete symbolic link first? [y|N] ",
false);
$answer = $this->all_yes ? true : $questionHelper->ask($this->input, $this->output, $question);
if (!$answer) {
$this->output->writeln(" | '- <red>You decided not to delete the symlink automatically.</red>");
return false;
}
}
$this->output->write("\x0D");
$this->output->writeln(' |- Checking destination... <green>ok</green>');
return true;
} | [
"private",
"function",
"checkDestination",
"(",
"$",
"slug",
",",
"$",
"package",
")",
"{",
"$",
"questionHelper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"$",
"exists",
"=",
"$",
"this",
"->",
"packageExists",
"(",
"$",
"slug",... | @param string $slug
@param Package $package
@return bool | [
"@param",
"string",
"$slug",
"@param",
"Package",
"$package"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/Gpm/UninstallCommand.php#L249-L280 | train | Check if the destination of the package is a symlink | [
30522,
2797,
3853,
4638,
6155,
13770,
3508,
1006,
1002,
23667,
1010,
1002,
7427,
1007,
1063,
1002,
3160,
16001,
4842,
1027,
1002,
2023,
1011,
1028,
2131,
16001,
4842,
1006,
1005,
3160,
1005,
1007,
1025,
1002,
6526,
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... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php | PdoSessionHandler.buildDsnFromUrl | private function buildDsnFromUrl($dsnOrUrl)
{
// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
$url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $dsnOrUrl);
$params = parse_url($url);
if (false === $params) {
return $dsnOrUrl; // If the URL is not valid, let's assume it might be a DSN already.
}
$params = array_map('rawurldecode', $params);
// Override the default username and password. Values passed through options will still win over these in the constructor.
if (isset($params['user'])) {
$this->username = $params['user'];
}
if (isset($params['pass'])) {
$this->password = $params['pass'];
}
if (!isset($params['scheme'])) {
throw new \InvalidArgumentException('URLs without scheme are not supported to configure the PdoSessionHandler');
}
$driverAliasMap = [
'mssql' => 'sqlsrv',
'mysql2' => 'mysql', // Amazon RDS, for some weird reason
'postgres' => 'pgsql',
'postgresql' => 'pgsql',
'sqlite3' => 'sqlite',
];
$driver = isset($driverAliasMap[$params['scheme']]) ? $driverAliasMap[$params['scheme']] : $params['scheme'];
// Doctrine DBAL supports passing its internal pdo_* driver names directly too (allowing both dashes and underscores). This allows supporting the same here.
if (0 === strpos($driver, 'pdo_') || 0 === strpos($driver, 'pdo-')) {
$driver = substr($driver, 4);
}
switch ($driver) {
case 'mysql':
case 'pgsql':
$dsn = $driver.':';
if (isset($params['host']) && '' !== $params['host']) {
$dsn .= 'host='.$params['host'].';';
}
if (isset($params['port']) && '' !== $params['port']) {
$dsn .= 'port='.$params['port'].';';
}
if (isset($params['path'])) {
$dbName = substr($params['path'], 1); // Remove the leading slash
$dsn .= 'dbname='.$dbName.';';
}
return $dsn;
case 'sqlite':
return 'sqlite:'.substr($params['path'], 1);
case 'sqlsrv':
$dsn = 'sqlsrv:server=';
if (isset($params['host'])) {
$dsn .= $params['host'];
}
if (isset($params['port']) && '' !== $params['port']) {
$dsn .= ','.$params['port'];
}
if (isset($params['path'])) {
$dbName = substr($params['path'], 1); // Remove the leading slash
$dsn .= ';Database='.$dbName;
}
return $dsn;
default:
throw new \InvalidArgumentException(sprintf('The scheme "%s" is not supported by the PdoSessionHandler URL configuration. Pass a PDO DSN directly.', $params['scheme']));
}
} | php | private function buildDsnFromUrl($dsnOrUrl)
{
// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
$url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $dsnOrUrl);
$params = parse_url($url);
if (false === $params) {
return $dsnOrUrl; // If the URL is not valid, let's assume it might be a DSN already.
}
$params = array_map('rawurldecode', $params);
// Override the default username and password. Values passed through options will still win over these in the constructor.
if (isset($params['user'])) {
$this->username = $params['user'];
}
if (isset($params['pass'])) {
$this->password = $params['pass'];
}
if (!isset($params['scheme'])) {
throw new \InvalidArgumentException('URLs without scheme are not supported to configure the PdoSessionHandler');
}
$driverAliasMap = [
'mssql' => 'sqlsrv',
'mysql2' => 'mysql', // Amazon RDS, for some weird reason
'postgres' => 'pgsql',
'postgresql' => 'pgsql',
'sqlite3' => 'sqlite',
];
$driver = isset($driverAliasMap[$params['scheme']]) ? $driverAliasMap[$params['scheme']] : $params['scheme'];
// Doctrine DBAL supports passing its internal pdo_* driver names directly too (allowing both dashes and underscores). This allows supporting the same here.
if (0 === strpos($driver, 'pdo_') || 0 === strpos($driver, 'pdo-')) {
$driver = substr($driver, 4);
}
switch ($driver) {
case 'mysql':
case 'pgsql':
$dsn = $driver.':';
if (isset($params['host']) && '' !== $params['host']) {
$dsn .= 'host='.$params['host'].';';
}
if (isset($params['port']) && '' !== $params['port']) {
$dsn .= 'port='.$params['port'].';';
}
if (isset($params['path'])) {
$dbName = substr($params['path'], 1); // Remove the leading slash
$dsn .= 'dbname='.$dbName.';';
}
return $dsn;
case 'sqlite':
return 'sqlite:'.substr($params['path'], 1);
case 'sqlsrv':
$dsn = 'sqlsrv:server=';
if (isset($params['host'])) {
$dsn .= $params['host'];
}
if (isset($params['port']) && '' !== $params['port']) {
$dsn .= ','.$params['port'];
}
if (isset($params['path'])) {
$dbName = substr($params['path'], 1); // Remove the leading slash
$dsn .= ';Database='.$dbName;
}
return $dsn;
default:
throw new \InvalidArgumentException(sprintf('The scheme "%s" is not supported by the PdoSessionHandler URL configuration. Pass a PDO DSN directly.', $params['scheme']));
}
} | [
"private",
"function",
"buildDsnFromUrl",
"(",
"$",
"dsnOrUrl",
")",
"{",
"// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid",
"$",
"url",
"=",
"preg_replace",
"(",
"'#^((?:pdo_)?sqlite3?):///#'",
",",
"'$1://localhost/'",
",",
"$",
"d... | Builds a PDO DSN from a URL-like connection string.
@param string $dsnOrUrl
@return string
@todo implement missing support for oci DSN (which look totally different from other PDO ones) | [
"Builds",
"a",
"PDO",
"DSN",
"from",
"a",
"URL",
"-",
"like",
"connection",
"string",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php#L445-L530 | train | Builds the DSN from a URL | [
30522,
2797,
3853,
3857,
5104,
2078,
19699,
5358,
3126,
2140,
1006,
1002,
16233,
12131,
3126,
2140,
1007,
1063,
1013,
1013,
1006,
22851,
2080,
1035,
1007,
1029,
29296,
4221,
2509,
1029,
1024,
1013,
1013,
1013,
1012,
1012,
1012,
1027,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Protocols/Websocket.php | Websocket.decode | public static function decode($buffer, ConnectionInterface $connection)
{
$masks = $data = $decoded = '';
$len = ord($buffer[1]) & 127;
if ($len === 126) {
$masks = substr($buffer, 4, 4);
$data = substr($buffer, 8);
} else {
if ($len === 127) {
$masks = substr($buffer, 10, 4);
$data = substr($buffer, 14);
} else {
$masks = substr($buffer, 2, 4);
$data = substr($buffer, 6);
}
}
for ($index = 0; $index < strlen($data); $index++) {
$decoded .= $data[$index] ^ $masks[$index % 4];
}
if ($connection->websocketCurrentFrameLength) {
$connection->websocketDataBuffer .= $decoded;
return $connection->websocketDataBuffer;
} else {
if ($connection->websocketDataBuffer !== '') {
$decoded = $connection->websocketDataBuffer . $decoded;
$connection->websocketDataBuffer = '';
}
return $decoded;
}
} | php | public static function decode($buffer, ConnectionInterface $connection)
{
$masks = $data = $decoded = '';
$len = ord($buffer[1]) & 127;
if ($len === 126) {
$masks = substr($buffer, 4, 4);
$data = substr($buffer, 8);
} else {
if ($len === 127) {
$masks = substr($buffer, 10, 4);
$data = substr($buffer, 14);
} else {
$masks = substr($buffer, 2, 4);
$data = substr($buffer, 6);
}
}
for ($index = 0; $index < strlen($data); $index++) {
$decoded .= $data[$index] ^ $masks[$index % 4];
}
if ($connection->websocketCurrentFrameLength) {
$connection->websocketDataBuffer .= $decoded;
return $connection->websocketDataBuffer;
} else {
if ($connection->websocketDataBuffer !== '') {
$decoded = $connection->websocketDataBuffer . $decoded;
$connection->websocketDataBuffer = '';
}
return $decoded;
}
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"buffer",
",",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"$",
"masks",
"=",
"$",
"data",
"=",
"$",
"decoded",
"=",
"''",
";",
"$",
"len",
"=",
"ord",
"(",
"$",
"buffer",
"[",
"1",
"]",
"... | Websocket decode.
@param string $buffer
@param ConnectionInterface $connection
@return string | [
"Websocket",
"decode",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Websocket.php#L305-L334 | train | Decodes the data received from the server into a string | [
30522,
2270,
10763,
3853,
21933,
3207,
1006,
1002,
17698,
1010,
4434,
18447,
2121,
12172,
1002,
4434,
1007,
1063,
1002,
15806,
1027,
1002,
2951,
1027,
1002,
21933,
5732,
1027,
1005,
1005,
1025,
1002,
18798,
1027,
2030,
2094,
1006,
1002,
176... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ServiceValueResolver.php | ServiceValueResolver.resolve | public function resolve(Request $request, ArgumentMetadata $argument)
{
if (\is_array($controller = $request->attributes->get('_controller'))) {
$controller = $controller[0].'::'.$controller[1];
}
if ('\\' === $controller[0]) {
$controller = ltrim($controller, '\\');
}
if (!$this->container->has($controller)) {
$i = strrpos($controller, ':');
$controller = substr($controller, 0, $i).strtolower(substr($controller, $i));
}
try {
yield $this->container->get($controller)->get($argument->getName());
} catch (RuntimeException $e) {
$what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller);
$message = preg_replace('/service "\.service_locator\.[^"]++"/', $what, $e->getMessage());
if ($e->getMessage() === $message) {
$message = sprintf('Cannot resolve %s: %s', $what, $message);
}
$r = new \ReflectionProperty($e, 'message');
$r->setAccessible(true);
$r->setValue($e, $message);
throw $e;
}
} | php | public function resolve(Request $request, ArgumentMetadata $argument)
{
if (\is_array($controller = $request->attributes->get('_controller'))) {
$controller = $controller[0].'::'.$controller[1];
}
if ('\\' === $controller[0]) {
$controller = ltrim($controller, '\\');
}
if (!$this->container->has($controller)) {
$i = strrpos($controller, ':');
$controller = substr($controller, 0, $i).strtolower(substr($controller, $i));
}
try {
yield $this->container->get($controller)->get($argument->getName());
} catch (RuntimeException $e) {
$what = sprintf('argument $%s of "%s()"', $argument->getName(), $controller);
$message = preg_replace('/service "\.service_locator\.[^"]++"/', $what, $e->getMessage());
if ($e->getMessage() === $message) {
$message = sprintf('Cannot resolve %s: %s', $what, $message);
}
$r = new \ReflectionProperty($e, 'message');
$r->setAccessible(true);
$r->setValue($e, $message);
throw $e;
}
} | [
"public",
"function",
"resolve",
"(",
"Request",
"$",
"request",
",",
"ArgumentMetadata",
"$",
"argument",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"controller",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_controller'",
")",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Controller/ArgumentResolver/ServiceValueResolver.php#L61-L92 | train | Resolves the service locator | [
30522,
2270,
3853,
10663,
1006,
5227,
1002,
5227,
1010,
6685,
11368,
8447,
2696,
1002,
6685,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
9140,
1006,
1002,
11486,
1027,
1002,
5227,
1011,
1028,
12332,
1011,
1028,
2131,
1006,
1005,
1035,
11486,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Sequence.php | Sequence.getNextId | public function getNextId()
{
$sql = 'UPDATE ' . $this->table . ' SET value = LAST_INSERT_ID(value + 1) WHERE name = ?';
$result = $this->db->query($sql, array($this->name));
$rowCount = $result->rowCount();
if (1 !== $rowCount) {
throw new Exception("Sequence '" . $this->name . "' not found.");
}
$createdId = $this->db->lastInsertId();
return (int) $createdId;
} | php | public function getNextId()
{
$sql = 'UPDATE ' . $this->table . ' SET value = LAST_INSERT_ID(value + 1) WHERE name = ?';
$result = $this->db->query($sql, array($this->name));
$rowCount = $result->rowCount();
if (1 !== $rowCount) {
throw new Exception("Sequence '" . $this->name . "' not found.");
}
$createdId = $this->db->lastInsertId();
return (int) $createdId;
} | [
"public",
"function",
"getNextId",
"(",
")",
"{",
"$",
"sql",
"=",
"'UPDATE '",
".",
"$",
"this",
"->",
"table",
".",
"' SET value = LAST_INSERT_ID(value + 1) WHERE name = ?'",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"$",
"sql",... | Get / allocate / reserve a new id for the current sequence. Important: Getting the next id will fail in case
no such sequence exists. Make sure to create one if needed, see {@link create()}.
@return int
@throws Exception | [
"Get",
"/",
"allocate",
"/",
"reserve",
"a",
"new",
"id",
"for",
"the",
"current",
"sequence",
".",
"Important",
":",
"Getting",
"the",
"next",
"id",
"will",
"fail",
"in",
"case",
"no",
"such",
"sequence",
"exists",
".",
"Make",
"sure",
"to",
"create",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Sequence.php#L91-L105 | train | Get next sequence id | [
30522,
2270,
3853,
2131,
2638,
18413,
3593,
1006,
1007,
1063,
1002,
29296,
1027,
1005,
10651,
1005,
1012,
1002,
2023,
1011,
1028,
2795,
1012,
1005,
2275,
3643,
1027,
2197,
1035,
19274,
1035,
8909,
1006,
3643,
1009,
1015,
1007,
2073,
2171,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | lib/html5lib/TreeBuilder.php | HTML5_TreeBuilder.printStack | private function printStack() {
$names = array();
foreach ($this->stack as $i => $element) {
$names[] = $element->tagName;
}
echo " -> stack [" . implode(', ', $names) . "]\n";
} | php | private function printStack() {
$names = array();
foreach ($this->stack as $i => $element) {
$names[] = $element->tagName;
}
echo " -> stack [" . implode(', ', $names) . "]\n";
} | [
"private",
"function",
"printStack",
"(",
")",
"{",
"$",
"names",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"stack",
"as",
"$",
"i",
"=>",
"$",
"element",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"element",
"->",
"tagName... | For debugging, prints the stack | [
"For",
"debugging",
"prints",
"the",
"stack"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/lib/html5lib/TreeBuilder.php#L3733-L3739 | train | Print the stack | [
30522,
2797,
3853,
11204,
2696,
3600,
1006,
1007,
1063,
1002,
3415,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
9991,
2004,
1002,
1045,
1027,
1028,
1002,
5783,
1007,
1063,
1002,
3415,
1031,
1033,
1027,
1002,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php | EntityUserProvider.loadUserByUsername | public function loadUserByUsername($username)
{
$repository = $this->getRepository();
if (null !== $this->property) {
$user = $repository->findOneBy([$this->property => $username]);
} else {
if (!$repository instanceof UserLoaderInterface) {
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository)));
}
$user = $repository->loadUserByUsername($username);
}
if (null === $user) {
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
}
return $user;
} | php | public function loadUserByUsername($username)
{
$repository = $this->getRepository();
if (null !== $this->property) {
$user = $repository->findOneBy([$this->property => $username]);
} else {
if (!$repository instanceof UserLoaderInterface) {
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository)));
}
$user = $repository->loadUserByUsername($username);
}
if (null === $user) {
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
}
return $user;
} | [
"public",
"function",
"loadUserByUsername",
"(",
"$",
"username",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"property",
")",
"{",
"$",
"user",
"=",
"$",
"repository... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php#L47-L65 | train | Load user by username | [
30522,
2270,
3853,
7170,
20330,
3762,
20330,
18442,
1006,
1002,
5310,
18442,
1007,
1063,
1002,
22409,
1027,
1002,
2023,
1011,
1028,
2131,
2890,
6873,
28307,
2100,
1006,
1007,
1025,
2065,
1006,
19701,
999,
1027,
1027,
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... |
matomo-org/matomo | libs/Zend/Session/SaveHandler/DbTable.php | Zend_Session_SaveHandler_DbTable._setup | protected function _setup()
{
parent::_setup();
$this->_setupPrimaryAssignment();
$this->setLifetime($this->_lifetime);
$this->_checkRequiredColumns();
} | php | protected function _setup()
{
parent::_setup();
$this->_setupPrimaryAssignment();
$this->setLifetime($this->_lifetime);
$this->_checkRequiredColumns();
} | [
"protected",
"function",
"_setup",
"(",
")",
"{",
"parent",
"::",
"_setup",
"(",
")",
";",
"$",
"this",
"->",
"_setupPrimaryAssignment",
"(",
")",
";",
"$",
"this",
"->",
"setLifetime",
"(",
"$",
"this",
"->",
"_lifetime",
")",
";",
"$",
"this",
"->",
... | Calls other protected methods for individual setup tasks and requirement checks
@return void | [
"Calls",
"other",
"protected",
"methods",
"for",
"individual",
"setup",
"tasks",
"and",
"requirement",
"checks"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session/SaveHandler/DbTable.php#L401-L409 | train | Setup the lifetime and check required columns | [
30522,
5123,
3853,
1035,
16437,
1006,
1007,
1063,
30524,
1006,
1002,
2023,
1011,
1028,
1035,
6480,
1007,
1025,
1002,
2023,
1011,
1028,
1035,
4638,
2890,
15549,
5596,
25778,
2819,
3619,
1006,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Http/Router.php | Router.filterUrl | public function filterUrl($url)
{
$path = parse_url($url, PHP_URL_PATH);
if (strpos($path, 'index.php/') !== false) {
return preg_replace('#index\.php/([^\?]*)#', 'index.php', $url, 1);
}
return null;
} | php | public function filterUrl($url)
{
$path = parse_url($url, PHP_URL_PATH);
if (strpos($path, 'index.php/') !== false) {
return preg_replace('#index\.php/([^\?]*)#', 'index.php', $url, 1);
}
return null;
} | [
"public",
"function",
"filterUrl",
"(",
"$",
"url",
")",
"{",
"$",
"path",
"=",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_PATH",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'index.php/'",
")",
"!==",
"false",
")",
"{",
"return",
"preg_re... | Filters some malformed URL by suggesting to redirect them.
E.g. /index.php/.html?... can be interpreted as HTML by old browsers
even though the Content-Type says JSON.
@link https://github.com/piwik/piwik/issues/6156
@param string $url The URL to filter.
@return string|null If not null, then the application should redirect to that URL. | [
"Filters",
"some",
"malformed",
"URL",
"by",
"suggesting",
"to",
"redirect",
"them",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Http/Router.php#L29-L38 | train | Filter the url to remove index. php from the url | [
30522,
2270,
3853,
11307,
3126,
2140,
1006,
1002,
24471,
2140,
1007,
1063,
1002,
4130,
1027,
11968,
3366,
1035,
24471,
2140,
1006,
1002,
24471,
2140,
1010,
25718,
1035,
24471,
2140,
1035,
4130,
1007,
1025,
2065,
1006,
2358,
14536,
2891,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Console/ControllerMakeCommand.php | ControllerMakeCommand.buildParentReplacements | protected function buildParentReplacements()
{
$parentModelClass = $this->parseModel($this->option('parent'));
if (! class_exists($parentModelClass)) {
if ($this->confirm("A {$parentModelClass} model does not exist. Do you want to generate it?", true)) {
$this->call('make:model', ['name' => $parentModelClass]);
}
}
return [
'ParentDummyFullModelClass' => $parentModelClass,
'ParentDummyModelClass' => class_basename($parentModelClass),
'ParentDummyModelVariable' => lcfirst(class_basename($parentModelClass)),
];
} | php | protected function buildParentReplacements()
{
$parentModelClass = $this->parseModel($this->option('parent'));
if (! class_exists($parentModelClass)) {
if ($this->confirm("A {$parentModelClass} model does not exist. Do you want to generate it?", true)) {
$this->call('make:model', ['name' => $parentModelClass]);
}
}
return [
'ParentDummyFullModelClass' => $parentModelClass,
'ParentDummyModelClass' => class_basename($parentModelClass),
'ParentDummyModelVariable' => lcfirst(class_basename($parentModelClass)),
];
} | [
"protected",
"function",
"buildParentReplacements",
"(",
")",
"{",
"$",
"parentModelClass",
"=",
"$",
"this",
"->",
"parseModel",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"parentModelClass",
... | Build the replacements for a parent controller.
@return array | [
"Build",
"the",
"replacements",
"for",
"a",
"parent",
"controller",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Console/ControllerMakeCommand.php#L108-L123 | train | Build parent replacement array | [
30522,
5123,
3853,
3857,
19362,
4765,
2890,
24759,
10732,
8163,
1006,
1007,
1063,
1002,
6687,
5302,
9247,
26266,
1027,
1002,
2023,
1011,
1028,
11968,
3366,
5302,
9247,
1006,
1002,
2023,
1011,
1028,
5724,
1006,
1005,
6687,
1005,
1007,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php | FormTypeCsrfExtension.finishView | public function finishView(FormView $view, FormInterface $form, array $options)
{
if ($options['csrf_protection'] && !$view->parent && $options['compound']) {
$factory = $form->getConfig()->getFormFactory();
$tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: \get_class($form->getConfig()->getType()->getInnerType()));
$data = (string) $options['csrf_token_manager']->getToken($tokenId);
$csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, [
'block_prefix' => 'csrf_token',
'mapped' => false,
]);
$view->children[$options['csrf_field_name']] = $csrfForm->createView($view);
}
} | php | public function finishView(FormView $view, FormInterface $form, array $options)
{
if ($options['csrf_protection'] && !$view->parent && $options['compound']) {
$factory = $form->getConfig()->getFormFactory();
$tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: \get_class($form->getConfig()->getType()->getInnerType()));
$data = (string) $options['csrf_token_manager']->getToken($tokenId);
$csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, [
'block_prefix' => 'csrf_token',
'mapped' => false,
]);
$view->children[$options['csrf_field_name']] = $csrfForm->createView($view);
}
} | [
"public",
"function",
"finishView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'csrf_protection'",
"]",
"&&",
"!",
"$",
"view",
"->",
"parent",
"&&",
"$",
"o... | Adds a CSRF field to the root form view.
@param FormView $view The form view
@param FormInterface $form The form
@param array $options The options | [
"Adds",
"a",
"CSRF",
"field",
"to",
"the",
"root",
"form",
"view",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php#L86-L100 | train | Finishes the form view. | [
30522,
2270,
3853,
3926,
8584,
1006,
2433,
8584,
1002,
3193,
1010,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
1002,
7047,
1031,
1005,
20116,
12881,
1035,
3860,
1005,
1033,
1004,
1004,
999,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Writable/Maildir.php | Zend_Mail_Storage_Writable_Maildir.createFolder | public function createFolder($name, $parentFolder = null)
{
if ($parentFolder instanceof Zend_Mail_Storage_Folder) {
$folder = $parentFolder->getGlobalName() . $this->_delim . $name;
} else if ($parentFolder != null) {
$folder = rtrim($parentFolder, $this->_delim) . $this->_delim . $name;
} else {
$folder = $name;
}
$folder = trim($folder, $this->_delim);
// first we check if we try to create a folder that does exist
$exists = null;
try {
$exists = $this->getFolders($folder);
} catch (Zend_Mail_Exception $e) {
// ok
}
if ($exists) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('folder already exists');
}
if (strpos($folder, $this->_delim . $this->_delim) !== false) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('invalid name - folder parts may not be empty');
}
if (strpos($folder, 'INBOX' . $this->_delim) === 0) {
$folder = substr($folder, 6);
}
$fulldir = $this->_rootdir . '.' . $folder;
// check if we got tricked and would create a dir outside of the rootdir or not as direct child
if (strpos($folder, DIRECTORY_SEPARATOR) !== false || strpos($folder, '/') !== false
|| dirname($fulldir) . DIRECTORY_SEPARATOR != $this->_rootdir) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('invalid name - no directory seprator allowed in folder name');
}
// has a parent folder?
$parent = null;
if (strpos($folder, $this->_delim)) {
// let's see if the parent folder exists
$parent = substr($folder, 0, strrpos($folder, $this->_delim));
try {
$this->getFolders($parent);
} catch (Zend_Mail_Exception $e) {
// does not - create parent folder
$this->createFolder($parent);
}
}
if (!@mkdir($fulldir) || !@mkdir($fulldir . DIRECTORY_SEPARATOR . 'cur')) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('error while creating new folder, may be created incompletly');
}
mkdir($fulldir . DIRECTORY_SEPARATOR . 'new');
mkdir($fulldir . DIRECTORY_SEPARATOR . 'tmp');
$localName = $parent ? substr($folder, strlen($parent) + 1) : $folder;
$this->getFolders($parent)->$localName = new Zend_Mail_Storage_Folder($localName, $folder, true);
return $fulldir;
} | php | public function createFolder($name, $parentFolder = null)
{
if ($parentFolder instanceof Zend_Mail_Storage_Folder) {
$folder = $parentFolder->getGlobalName() . $this->_delim . $name;
} else if ($parentFolder != null) {
$folder = rtrim($parentFolder, $this->_delim) . $this->_delim . $name;
} else {
$folder = $name;
}
$folder = trim($folder, $this->_delim);
// first we check if we try to create a folder that does exist
$exists = null;
try {
$exists = $this->getFolders($folder);
} catch (Zend_Mail_Exception $e) {
// ok
}
if ($exists) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('folder already exists');
}
if (strpos($folder, $this->_delim . $this->_delim) !== false) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('invalid name - folder parts may not be empty');
}
if (strpos($folder, 'INBOX' . $this->_delim) === 0) {
$folder = substr($folder, 6);
}
$fulldir = $this->_rootdir . '.' . $folder;
// check if we got tricked and would create a dir outside of the rootdir or not as direct child
if (strpos($folder, DIRECTORY_SEPARATOR) !== false || strpos($folder, '/') !== false
|| dirname($fulldir) . DIRECTORY_SEPARATOR != $this->_rootdir) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('invalid name - no directory seprator allowed in folder name');
}
// has a parent folder?
$parent = null;
if (strpos($folder, $this->_delim)) {
// let's see if the parent folder exists
$parent = substr($folder, 0, strrpos($folder, $this->_delim));
try {
$this->getFolders($parent);
} catch (Zend_Mail_Exception $e) {
// does not - create parent folder
$this->createFolder($parent);
}
}
if (!@mkdir($fulldir) || !@mkdir($fulldir . DIRECTORY_SEPARATOR . 'cur')) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('error while creating new folder, may be created incompletly');
}
mkdir($fulldir . DIRECTORY_SEPARATOR . 'new');
mkdir($fulldir . DIRECTORY_SEPARATOR . 'tmp');
$localName = $parent ? substr($folder, strlen($parent) + 1) : $folder;
$this->getFolders($parent)->$localName = new Zend_Mail_Storage_Folder($localName, $folder, true);
return $fulldir;
} | [
"public",
"function",
"createFolder",
"(",
"$",
"name",
",",
"$",
"parentFolder",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parentFolder",
"instanceof",
"Zend_Mail_Storage_Folder",
")",
"{",
"$",
"folder",
"=",
"$",
"parentFolder",
"->",
"getGlobalName",
"(",
... | create a new folder
This method also creates parent folders if necessary. Some mail storages may restrict, which folder
may be used as parent or which chars may be used in the folder name
@param string $name global name of folder, local name if $parentFolder is set
@param string|Zend_Mail_Storage_Folder $parentFolder parent folder for new folder, else root folder is parent
@return string only used internally (new created maildir)
@throws Zend_Mail_Storage_Exception | [
"create",
"a",
"new",
"folder"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Writable/Maildir.php#L134-L213 | train | Create a new folder | [
30522,
2270,
3853,
3443,
10371,
2121,
1006,
1002,
2171,
1010,
1002,
6687,
10371,
2121,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
6687,
10371,
2121,
6013,
11253,
16729,
2094,
1035,
5653,
1035,
5527,
1035,
19622,
1007,
1063,
1002,
19622,
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... |
z-song/laravel-admin | src/Grid/Model.php | Model.getConstraints | public function getConstraints()
{
if ($this->relation instanceof HasMany) {
return [
$this->relation->getForeignKeyName() => $this->relation->getParentKey(),
];
}
return false;
} | php | public function getConstraints()
{
if ($this->relation instanceof HasMany) {
return [
$this->relation->getForeignKeyName() => $this->relation->getParentKey(),
];
}
return false;
} | [
"public",
"function",
"getConstraints",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"relation",
"instanceof",
"HasMany",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"relation",
"->",
"getForeignKeyName",
"(",
")",
"=>",
"$",
"this",
"->",
"relation",
"-... | Get constraints.
@return array|bool | [
"Get",
"constraints",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Model.php#L259-L268 | train | Get constraints for this relation | [
30522,
2270,
3853,
2131,
8663,
20528,
18447,
2015,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
7189,
6013,
11253,
2038,
2386,
2100,
1007,
1063,
2709,
1031,
1002,
2023,
1011,
1028,
7189,
1011,
1028,
2131,
29278,
7416,
16206,
14839,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ResolveBindingsPass.php | ResolveBindingsPass.processValue | protected function processValue($value, $isRoot = false)
{
if ($value instanceof TypedReference && $value->getType() === (string) $value) {
// Already checked
$bindings = $this->container->getDefinition($this->currentId)->getBindings();
if (isset($bindings[$value->getType()])) {
return $this->getBindingValue($bindings[$value->getType()]);
}
return parent::processValue($value, $isRoot);
}
if (!$value instanceof Definition || !$bindings = $value->getBindings()) {
return parent::processValue($value, $isRoot);
}
foreach ($bindings as $key => $binding) {
list($bindingValue, $bindingId, $used, $bindingType, $file) = $binding->getValues();
if ($used) {
$this->usedBindings[$bindingId] = true;
unset($this->unusedBindings[$bindingId]);
} elseif (!isset($this->usedBindings[$bindingId])) {
$this->unusedBindings[$bindingId] = [$key, $this->currentId, $bindingType, $file];
}
if (preg_match('/^(?:(?:array|bool|float|int|string) )?\$/', $key)) {
continue;
}
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition) {
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, an instance of %s or an instance of %s, %s given.', $key, $this->currentId, Reference::class, Definition::class, \gettype($bindingValue)));
}
}
if ($value->isAbstract()) {
return parent::processValue($value, $isRoot);
}
$calls = $value->getMethodCalls();
try {
if ($constructor = $this->getConstructor($value, false)) {
$calls[] = [$constructor, $value->getArguments()];
}
} catch (RuntimeException $e) {
$this->errorMessages[] = $e->getMessage();
$this->container->getDefinition($this->currentId)->addError($e->getMessage());
return parent::processValue($value, $isRoot);
}
foreach ($calls as $i => $call) {
list($method, $arguments) = $call;
if ($method instanceof \ReflectionFunctionAbstract) {
$reflectionMethod = $method;
} else {
try {
$reflectionMethod = $this->getReflectionMethod($value, $method);
} catch (RuntimeException $e) {
if ($value->getFactory()) {
continue;
}
throw $e;
}
}
foreach ($reflectionMethod->getParameters() as $key => $parameter) {
if (\array_key_exists($key, $arguments) && '' !== $arguments[$key]) {
continue;
}
$typeHint = ProxyHelper::getTypeHint($reflectionMethod, $parameter);
if (\array_key_exists($k = ltrim($typeHint, '\\').' $'.$parameter->name, $bindings)) {
$arguments[$key] = $this->getBindingValue($bindings[$k]);
continue;
}
if (\array_key_exists('$'.$parameter->name, $bindings)) {
$arguments[$key] = $this->getBindingValue($bindings['$'.$parameter->name]);
continue;
}
if (!$typeHint || '\\' !== $typeHint[0] || !isset($bindings[$typeHint = substr($typeHint, 1)])) {
continue;
}
$arguments[$key] = $this->getBindingValue($bindings[$typeHint]);
}
if ($arguments !== $call[1]) {
ksort($arguments);
$calls[$i][1] = $arguments;
}
}
if ($constructor) {
list(, $arguments) = array_pop($calls);
if ($arguments !== $value->getArguments()) {
$value->setArguments($arguments);
}
}
if ($calls !== $value->getMethodCalls()) {
$value->setMethodCalls($calls);
}
return parent::processValue($value, $isRoot);
} | php | protected function processValue($value, $isRoot = false)
{
if ($value instanceof TypedReference && $value->getType() === (string) $value) {
// Already checked
$bindings = $this->container->getDefinition($this->currentId)->getBindings();
if (isset($bindings[$value->getType()])) {
return $this->getBindingValue($bindings[$value->getType()]);
}
return parent::processValue($value, $isRoot);
}
if (!$value instanceof Definition || !$bindings = $value->getBindings()) {
return parent::processValue($value, $isRoot);
}
foreach ($bindings as $key => $binding) {
list($bindingValue, $bindingId, $used, $bindingType, $file) = $binding->getValues();
if ($used) {
$this->usedBindings[$bindingId] = true;
unset($this->unusedBindings[$bindingId]);
} elseif (!isset($this->usedBindings[$bindingId])) {
$this->unusedBindings[$bindingId] = [$key, $this->currentId, $bindingType, $file];
}
if (preg_match('/^(?:(?:array|bool|float|int|string) )?\$/', $key)) {
continue;
}
if (null !== $bindingValue && !$bindingValue instanceof Reference && !$bindingValue instanceof Definition) {
throw new InvalidArgumentException(sprintf('Invalid value for binding key "%s" for service "%s": expected null, an instance of %s or an instance of %s, %s given.', $key, $this->currentId, Reference::class, Definition::class, \gettype($bindingValue)));
}
}
if ($value->isAbstract()) {
return parent::processValue($value, $isRoot);
}
$calls = $value->getMethodCalls();
try {
if ($constructor = $this->getConstructor($value, false)) {
$calls[] = [$constructor, $value->getArguments()];
}
} catch (RuntimeException $e) {
$this->errorMessages[] = $e->getMessage();
$this->container->getDefinition($this->currentId)->addError($e->getMessage());
return parent::processValue($value, $isRoot);
}
foreach ($calls as $i => $call) {
list($method, $arguments) = $call;
if ($method instanceof \ReflectionFunctionAbstract) {
$reflectionMethod = $method;
} else {
try {
$reflectionMethod = $this->getReflectionMethod($value, $method);
} catch (RuntimeException $e) {
if ($value->getFactory()) {
continue;
}
throw $e;
}
}
foreach ($reflectionMethod->getParameters() as $key => $parameter) {
if (\array_key_exists($key, $arguments) && '' !== $arguments[$key]) {
continue;
}
$typeHint = ProxyHelper::getTypeHint($reflectionMethod, $parameter);
if (\array_key_exists($k = ltrim($typeHint, '\\').' $'.$parameter->name, $bindings)) {
$arguments[$key] = $this->getBindingValue($bindings[$k]);
continue;
}
if (\array_key_exists('$'.$parameter->name, $bindings)) {
$arguments[$key] = $this->getBindingValue($bindings['$'.$parameter->name]);
continue;
}
if (!$typeHint || '\\' !== $typeHint[0] || !isset($bindings[$typeHint = substr($typeHint, 1)])) {
continue;
}
$arguments[$key] = $this->getBindingValue($bindings[$typeHint]);
}
if ($arguments !== $call[1]) {
ksort($arguments);
$calls[$i][1] = $arguments;
}
}
if ($constructor) {
list(, $arguments) = array_pop($calls);
if ($arguments !== $value->getArguments()) {
$value->setArguments($arguments);
}
}
if ($calls !== $value->getMethodCalls()) {
$value->setMethodCalls($calls);
}
return parent::processValue($value, $isRoot);
} | [
"protected",
"function",
"processValue",
"(",
"$",
"value",
",",
"$",
"isRoot",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"TypedReference",
"&&",
"$",
"value",
"->",
"getType",
"(",
")",
"===",
"(",
"string",
")",
"$",
"value",
")"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php#L93-L206 | train | Process the value of the binding | [
30522,
5123,
3853,
2832,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
2003,
3217,
4140,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
3643,
6013,
11253,
21189,
2890,
25523,
1004,
1004,
1002,
3643,
1011,
1028,
2131,
13874,
1006,
1007,
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 | libs/HTML/QuickForm2/Rule.php | HTML_QuickForm2_Rule.or_ | public function or_(HTML_QuickForm2_Rule $next)
{
if ($next instanceof HTML_QuickForm2_Rule_Required) {
throw new HTML_QuickForm2_InvalidArgumentException(
'or_(): Cannot add a "required" rule'
);
}
$this->chainedRules[] = array($next);
return $this;
} | php | public function or_(HTML_QuickForm2_Rule $next)
{
if ($next instanceof HTML_QuickForm2_Rule_Required) {
throw new HTML_QuickForm2_InvalidArgumentException(
'or_(): Cannot add a "required" rule'
);
}
$this->chainedRules[] = array($next);
return $this;
} | [
"public",
"function",
"or_",
"(",
"HTML_QuickForm2_Rule",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"next",
"instanceof",
"HTML_QuickForm2_Rule_Required",
")",
"{",
"throw",
"new",
"HTML_QuickForm2_InvalidArgumentException",
"(",
"'or_(): Cannot add a \"required\" rule'",
")... | Adds a rule to the chain with an "or" operator
Evaluation is short-circuited, next rule will not be evaluated if the
previous one returns true. The method is named this way because "or" is
a reserved word in PHP.
@param HTML_QuickForm2_Rule
@return HTML_QuickForm2_Rule first rule in the chain (i.e. $this)
@throws HTML_QuickForm2_InvalidArgumentException when trying to add
a "required" rule to the chain | [
"Adds",
"a",
"rule",
"to",
"the",
"chain",
"with",
"an",
"or",
"operator"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule.php#L225-L234 | train | Adds a rule to the chain of rules and returns the current one | [
30522,
2270,
3853,
2030,
1035,
1006,
16129,
1035,
4248,
14192,
2475,
1035,
3627,
1002,
2279,
1007,
1063,
2065,
1006,
1002,
2279,
6013,
11253,
16129,
1035,
4248,
14192,
2475,
1035,
3627,
1035,
3223,
1007,
1063,
5466,
2047,
16129,
1035,
4248,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ColorPicker.php | ColorPicker.prepareVars | public function prepareVars()
{
$this->vars['name'] = $this->getFieldName();
$this->vars['value'] = $value = $this->getLoadValue();
$this->vars['availableColors'] = $availableColors = $this->getAvailableColors();
$this->vars['allowEmpty'] = $this->allowEmpty;
$this->vars['showAlpha'] = $this->showAlpha;
$this->vars['isCustomColor'] = !in_array($value, $availableColors);
} | php | public function prepareVars()
{
$this->vars['name'] = $this->getFieldName();
$this->vars['value'] = $value = $this->getLoadValue();
$this->vars['availableColors'] = $availableColors = $this->getAvailableColors();
$this->vars['allowEmpty'] = $this->allowEmpty;
$this->vars['showAlpha'] = $this->showAlpha;
$this->vars['isCustomColor'] = !in_array($value, $availableColors);
} | [
"public",
"function",
"prepareVars",
"(",
")",
"{",
"$",
"this",
"->",
"vars",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"getFieldName",
"(",
")",
";",
"$",
"this",
"->",
"vars",
"[",
"'value'",
"]",
"=",
"$",
"value",
"=",
"$",
"this",
"->",
"... | Prepares the list data | [
"Prepares",
"the",
"list",
"data"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/ColorPicker.php#L79-L87 | train | Prepare the vars for the page | [
30522,
2270,
3853,
7374,
10755,
2015,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
13075,
2015,
1031,
1005,
2171,
1005,
1033,
1027,
1002,
2023,
1011,
1028,
2131,
3790,
18442,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
13075,
2015,
1031,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php | InteractsWithPivotTable.formatAttachRecord | protected function formatAttachRecord($key, $value, $attributes, $hasTimestamps)
{
[$id, $attributes] = $this->extractAttachIdAndAttributes($key, $value, $attributes);
return array_merge(
$this->baseAttachRecord($id, $hasTimestamps), $this->castAttributes($attributes)
);
} | php | protected function formatAttachRecord($key, $value, $attributes, $hasTimestamps)
{
[$id, $attributes] = $this->extractAttachIdAndAttributes($key, $value, $attributes);
return array_merge(
$this->baseAttachRecord($id, $hasTimestamps), $this->castAttributes($attributes)
);
} | [
"protected",
"function",
"formatAttachRecord",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"attributes",
",",
"$",
"hasTimestamps",
")",
"{",
"[",
"$",
"id",
",",
"$",
"attributes",
"]",
"=",
"$",
"this",
"->",
"extractAttachIdAndAttributes",
"(",
"$",
... | Create a full attachment record payload.
@param int $key
@param mixed $value
@param array $attributes
@param bool $hasTimestamps
@return array | [
"Create",
"a",
"full",
"attachment",
"record",
"payload",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php#L307-L314 | train | Format the attach record into a single array | [
30522,
5123,
3853,
4289,
19321,
6776,
2890,
27108,
2094,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
1002,
12332,
1010,
1002,
2038,
7292,
9153,
25370,
1007,
1063,
1031,
1002,
8909,
1010,
1002,
12332,
1033,
1027,
1002,
2023,
1011,
1028,
14817,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Lock/Store/ZookeeperStore.php | ZookeeperStore.delete | public function delete(Key $key)
{
if (!$this->exists($key)) {
return;
}
$resource = $this->getKeyResource($key);
try {
$this->zookeeper->delete($resource);
} catch (\ZookeeperException $exception) {
// For Zookeeper Ephemeral Nodes, the node will be deleted upon session death. But, if we want to unlock
// the lock before proceeding further in the session, the client should be aware of this
throw new LockReleasingException($exception);
}
} | php | public function delete(Key $key)
{
if (!$this->exists($key)) {
return;
}
$resource = $this->getKeyResource($key);
try {
$this->zookeeper->delete($resource);
} catch (\ZookeeperException $exception) {
// For Zookeeper Ephemeral Nodes, the node will be deleted upon session death. But, if we want to unlock
// the lock before proceeding further in the session, the client should be aware of this
throw new LockReleasingException($exception);
}
} | [
"public",
"function",
"delete",
"(",
"Key",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"key",
")",
")",
"{",
"return",
";",
"}",
"$",
"resource",
"=",
"$",
"this",
"->",
"getKeyResource",
"(",
"$",
"key",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Lock/Store/ZookeeperStore.php#L53-L66 | train | Delete a node | [
30522,
2270,
3853,
3972,
12870,
1006,
3145,
1002,
3145,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
6526,
1006,
1002,
3145,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
7692,
1027,
1002,
2023,
1011,
1028,
2131,
14839,
6072,
8162,
34... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/QueryException.php | QueryException.formatMessage | protected function formatMessage($sql, $bindings, $previous)
{
return $previous->getMessage().' (SQL: '.Str::replaceArray('?', $bindings, $sql).')';
} | php | protected function formatMessage($sql, $bindings, $previous)
{
return $previous->getMessage().' (SQL: '.Str::replaceArray('?', $bindings, $sql).')';
} | [
"protected",
"function",
"formatMessage",
"(",
"$",
"sql",
",",
"$",
"bindings",
",",
"$",
"previous",
")",
"{",
"return",
"$",
"previous",
"->",
"getMessage",
"(",
")",
".",
"' (SQL: '",
".",
"Str",
"::",
"replaceArray",
"(",
"'?'",
",",
"$",
"bindings"... | Format the SQL error message.
@param string $sql
@param array $bindings
@param \Exception $previous
@return string | [
"Format",
"the",
"SQL",
"error",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/QueryException.php#L54-L57 | train | Format SQL and bindings for debugging purposes | [
30522,
5123,
3853,
4289,
7834,
3736,
3351,
1006,
1002,
29296,
1010,
1002,
8031,
2015,
1010,
1002,
3025,
1007,
1063,
2709,
1002,
3025,
1011,
1028,
30524,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/PCA.php | PCA.fit | public function fit(array $data): array
{
$n = count($data[0]);
$data = $this->normalize($data, $n);
$covMatrix = Covariance::covarianceMatrix($data, array_fill(0, $n, 0));
$this->eigenDecomposition($covMatrix);
$this->fit = true;
return $this->reduce($data);
} | php | public function fit(array $data): array
{
$n = count($data[0]);
$data = $this->normalize($data, $n);
$covMatrix = Covariance::covarianceMatrix($data, array_fill(0, $n, 0));
$this->eigenDecomposition($covMatrix);
$this->fit = true;
return $this->reduce($data);
} | [
"public",
"function",
"fit",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"n",
"=",
"count",
"(",
"$",
"data",
"[",
"0",
"]",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"data",
",",
"$",
"n",
")",
";",
... | Takes a data and returns a lower dimensional version
of this data while preserving $totalVariance or $numFeatures. <br>
$data is an n-by-m matrix and returned array is
n-by-k matrix where k <= m | [
"Takes",
"a",
"data",
"and",
"returns",
"a",
"lower",
"dimensional",
"version",
"of",
"this",
"data",
"while",
"preserving",
"$totalVariance",
"or",
"$numFeatures",
".",
"<br",
">",
"$data",
"is",
"an",
"n",
"-",
"by",
"-",
"m",
"matrix",
"and",
"returned"... | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/DimensionReduction/PCA.php#L66-L79 | train | Fit the algorithm to a single array of terms | [
30522,
2270,
3853,
4906,
1006,
9140,
1002,
2951,
1007,
1024,
9140,
1063,
1002,
1050,
1027,
4175,
1006,
1002,
2951,
1031,
1014,
1033,
1007,
1025,
1002,
2951,
1027,
1002,
2023,
1011,
1028,
3671,
4697,
1006,
1002,
2951,
1010,
1002,
1050,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Router.php | Router.group | public function group(array $attributes, $routes)
{
$this->updateGroupStack($attributes);
// Once we have updated the group stack, we'll load the provided routes and
// merge in the group's attributes when the routes are created. After we
// have created the routes, we will pop the attributes off the stack.
$this->loadRoutes($routes);
array_pop($this->groupStack);
} | php | public function group(array $attributes, $routes)
{
$this->updateGroupStack($attributes);
// Once we have updated the group stack, we'll load the provided routes and
// merge in the group's attributes when the routes are created. After we
// have created the routes, we will pop the attributes off the stack.
$this->loadRoutes($routes);
array_pop($this->groupStack);
} | [
"public",
"function",
"group",
"(",
"array",
"$",
"attributes",
",",
"$",
"routes",
")",
"{",
"$",
"this",
"->",
"updateGroupStack",
"(",
"$",
"attributes",
")",
";",
"// Once we have updated the group stack, we'll load the provided routes and",
"// merge in the group's a... | Create a route group with shared attributes.
@param array $attributes
@param \Closure|string $routes
@return void | [
"Create",
"a",
"route",
"group",
"with",
"shared",
"attributes",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Router.php#L366-L376 | train | Group the attributes and routes into the group stack. | [
30522,
2270,
3853,
2177,
1006,
9140,
1002,
12332,
1010,
1002,
5847,
1007,
1063,
1002,
2023,
1011,
1028,
10651,
17058,
9153,
3600,
1006,
1002,
12332,
1007,
1025,
1013,
1013,
2320,
2057,
2031,
7172,
1996,
2177,
9991,
1010,
2057,
1005,
2222,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/Type/FileType.php | FileType.factorizeSizes | private function factorizeSizes($size, $limit)
{
$coef = self::MIB_BYTES;
$coefFactor = self::KIB_BYTES;
$limitAsString = (string) ($limit / $coef);
// Restrict the limit to 2 decimals (without rounding! we
// need the precise value)
while (self::moreDecimalsThan($limitAsString, 2)) {
$coef /= $coefFactor;
$limitAsString = (string) ($limit / $coef);
}
// Convert size to the same measure, but round to 2 decimals
$sizeAsString = (string) round($size / $coef, 2);
// If the size and limit produce the same string output
// (due to rounding), reduce the coefficient
while ($sizeAsString === $limitAsString) {
$coef /= $coefFactor;
$limitAsString = (string) ($limit / $coef);
$sizeAsString = (string) round($size / $coef, 2);
}
return [$limitAsString, self::$suffixes[$coef]];
} | php | private function factorizeSizes($size, $limit)
{
$coef = self::MIB_BYTES;
$coefFactor = self::KIB_BYTES;
$limitAsString = (string) ($limit / $coef);
// Restrict the limit to 2 decimals (without rounding! we
// need the precise value)
while (self::moreDecimalsThan($limitAsString, 2)) {
$coef /= $coefFactor;
$limitAsString = (string) ($limit / $coef);
}
// Convert size to the same measure, but round to 2 decimals
$sizeAsString = (string) round($size / $coef, 2);
// If the size and limit produce the same string output
// (due to rounding), reduce the coefficient
while ($sizeAsString === $limitAsString) {
$coef /= $coefFactor;
$limitAsString = (string) ($limit / $coef);
$sizeAsString = (string) round($size / $coef, 2);
}
return [$limitAsString, self::$suffixes[$coef]];
} | [
"private",
"function",
"factorizeSizes",
"(",
"$",
"size",
",",
"$",
"limit",
")",
"{",
"$",
"coef",
"=",
"self",
"::",
"MIB_BYTES",
";",
"$",
"coefFactor",
"=",
"self",
"::",
"KIB_BYTES",
";",
"$",
"limitAsString",
"=",
"(",
"string",
")",
"(",
"$",
... | Converts the limit to the smallest possible number
(i.e. try "MB", then "kB", then "bytes").
This method should be kept in sync with Symfony\Component\Validator\Constraints\FileValidator::factorizeSizes(). | [
"Converts",
"the",
"limit",
"to",
"the",
"smallest",
"possible",
"number",
"(",
"i",
".",
"e",
".",
"try",
"MB",
"then",
"kB",
"then",
"bytes",
")",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/FileType.php#L213-L239 | train | Factorizes the size and limit to the correct size | [
30522,
2797,
3853,
5387,
10057,
10057,
1006,
1002,
2946,
1010,
1002,
5787,
1007,
1063,
1002,
24873,
2546,
1027,
2969,
1024,
1024,
2771,
2497,
1035,
27507,
1025,
1002,
24873,
20961,
16761,
1027,
2969,
1024,
1024,
11382,
2497,
1035,
27507,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Protocol/Abstract.php | Zend_Mail_Protocol_Abstract._receive | protected function _receive($timeout = null)
{
if (!is_resource($this->_socket)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
}
// Adapters may wish to supply per-commend timeouts according to appropriate RFC
if ($timeout !== null) {
$this->_setStreamTimeout($timeout);
}
// Retrieve response
$reponse = fgets($this->_socket, 1024);
// Save request to internal log
$this->_addLog($reponse);
// Check meta data to ensure connection is still valid
$info = stream_get_meta_data($this->_socket);
if (!empty($info['timed_out'])) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception($this->_host . ' has timed out');
}
if ($reponse === false) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not read from ' . $this->_host);
}
return $reponse;
} | php | protected function _receive($timeout = null)
{
if (!is_resource($this->_socket)) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
}
// Adapters may wish to supply per-commend timeouts according to appropriate RFC
if ($timeout !== null) {
$this->_setStreamTimeout($timeout);
}
// Retrieve response
$reponse = fgets($this->_socket, 1024);
// Save request to internal log
$this->_addLog($reponse);
// Check meta data to ensure connection is still valid
$info = stream_get_meta_data($this->_socket);
if (!empty($info['timed_out'])) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception($this->_host . ' has timed out');
}
if ($reponse === false) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('Could not read from ' . $this->_host);
}
return $reponse;
} | [
"protected",
"function",
"_receive",
"(",
"$",
"timeout",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_socket",
")",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protoc... | Get a line from the stream.
@var integer $timeout Per-request timeout value if applicable
@throws Zend_Mail_Protocol_Exception
@return string | [
"Get",
"a",
"line",
"from",
"the",
"stream",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Abstract.php#L348-L389 | train | Receive response from the server | [
30522,
5123,
3853,
1035,
4374,
1006,
1002,
2051,
5833,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2003,
1035,
7692,
1006,
1002,
2023,
1011,
1028,
1035,
22278,
1007,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2156,
16729,
2094,
1035,
5653,
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/HTML/QuickForm2/Renderer/Array.php | HTML_QuickForm2_Renderer_Array.setStyleForId | public function setStyleForId($idOrStyles, $style = null)
{
if (is_array($idOrStyles)) {
$this->styles = array_merge($this->styles, $idOrStyles);
} else {
$this->styles[$idOrStyles] = $style;
}
return $this;
} | php | public function setStyleForId($idOrStyles, $style = null)
{
if (is_array($idOrStyles)) {
$this->styles = array_merge($this->styles, $idOrStyles);
} else {
$this->styles[$idOrStyles] = $style;
}
return $this;
} | [
"public",
"function",
"setStyleForId",
"(",
"$",
"idOrStyles",
",",
"$",
"style",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"idOrStyles",
")",
")",
"{",
"$",
"this",
"->",
"styles",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"styles",
... | Sets a style for element rendering
"Style" is some information that is opaque to Array Renderer but may be
of use to e.g. template engine that receives the resultant array.
@param string|array Element id or array ('element id' => 'style')
@param sting Element style if $idOrStyles is not an array
@return HTML_QuickForm2_Renderer_Array | [
"Sets",
"a",
"style",
"for",
"element",
"rendering"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Array.php#L290-L298 | train | Set Style for Id or Styles | [
30522,
2270,
3853,
4520,
27983,
29278,
3593,
1006,
1002,
8909,
5668,
27983,
2015,
1010,
1002,
2806,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
8909,
5668,
27983,
2015,
1007,
1007,
1063,
1002,
30524,
1027,
1002,
2806,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Mime/Decode.php | Zend_Mime_Decode.splitHeaderField | public static function splitHeaderField($field, $wantedPart = null, $firstName = 0)
{
$wantedPart = strtolower($wantedPart);
$firstName = strtolower($firstName);
// special case - a bit optimized
if ($firstName === $wantedPart) {
$field = strtok($field, ';');
return $field[0] == '"' ? substr($field, 1, -1) : $field;
}
$field = $firstName . '=' . $field;
if (!preg_match_all('%([^=\s]+)\s*=\s*("[^"]+"|[^;]+)(;\s*|$)%', $field, $matches)) {
throw new Zend_Exception('not a valid header field');
}
if ($wantedPart) {
foreach ($matches[1] as $key => $name) {
if (strcasecmp($name, $wantedPart)) {
continue;
}
if ($matches[2][$key][0] != '"') {
return $matches[2][$key];
}
return substr($matches[2][$key], 1, -1);
}
return null;
}
$split = array();
foreach ($matches[1] as $key => $name) {
$name = strtolower($name);
if ($matches[2][$key][0] == '"') {
$split[$name] = substr($matches[2][$key], 1, -1);
} else {
$split[$name] = $matches[2][$key];
}
}
return $split;
} | php | public static function splitHeaderField($field, $wantedPart = null, $firstName = 0)
{
$wantedPart = strtolower($wantedPart);
$firstName = strtolower($firstName);
// special case - a bit optimized
if ($firstName === $wantedPart) {
$field = strtok($field, ';');
return $field[0] == '"' ? substr($field, 1, -1) : $field;
}
$field = $firstName . '=' . $field;
if (!preg_match_all('%([^=\s]+)\s*=\s*("[^"]+"|[^;]+)(;\s*|$)%', $field, $matches)) {
throw new Zend_Exception('not a valid header field');
}
if ($wantedPart) {
foreach ($matches[1] as $key => $name) {
if (strcasecmp($name, $wantedPart)) {
continue;
}
if ($matches[2][$key][0] != '"') {
return $matches[2][$key];
}
return substr($matches[2][$key], 1, -1);
}
return null;
}
$split = array();
foreach ($matches[1] as $key => $name) {
$name = strtolower($name);
if ($matches[2][$key][0] == '"') {
$split[$name] = substr($matches[2][$key], 1, -1);
} else {
$split[$name] = $matches[2][$key];
}
}
return $split;
} | [
"public",
"static",
"function",
"splitHeaderField",
"(",
"$",
"field",
",",
"$",
"wantedPart",
"=",
"null",
",",
"$",
"firstName",
"=",
"0",
")",
"{",
"$",
"wantedPart",
"=",
"strtolower",
"(",
"$",
"wantedPart",
")",
";",
"$",
"firstName",
"=",
"strtolo... | split a header field like content type in its different parts
@param string $type header field
@param string $wantedPart the wanted part, else an array with all parts is returned
@param string $firstName key name for the first part
@return string|array wanted part or all parts as array($firstName => firstPart, partname => value)
@throws Zend_Exception | [
"split",
"a",
"header",
"field",
"like",
"content",
"type",
"in",
"its",
"different",
"parts"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime/Decode.php#L190-L230 | train | Split header field | [
30522,
2270,
10763,
3853,
3975,
4974,
2121,
3790,
1006,
1002,
2492,
1010,
1002,
2359,
19362,
2102,
1027,
19701,
1010,
1002,
2034,
18442,
1027,
1014,
1007,
1063,
1002,
2359,
19362,
2102,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
2359,
1936... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/IpUtils.php | IpUtils.checkIp6 | public static function checkIp6($requestIp, $ip)
{
$cacheKey = $requestIp.'-'.$ip;
if (isset(self::$checkedIps[$cacheKey])) {
return self::$checkedIps[$cacheKey];
}
if (!((\extension_loaded('sockets') && \defined('AF_INET6')) || @inet_pton('::1'))) {
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
}
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
if ('0' === $netmask) {
return (bool) unpack('n*', @inet_pton($address));
}
if ($netmask < 1 || $netmask > 128) {
return self::$checkedIps[$cacheKey] = false;
}
} else {
$address = $ip;
$netmask = 128;
}
$bytesAddr = unpack('n*', @inet_pton($address));
$bytesTest = unpack('n*', @inet_pton($requestIp));
if (!$bytesAddr || !$bytesTest) {
return self::$checkedIps[$cacheKey] = false;
}
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) {
$left = $netmask - 16 * ($i - 1);
$left = ($left <= 16) ? $left : 16;
$mask = ~(0xffff >> $left) & 0xffff;
if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) {
return self::$checkedIps[$cacheKey] = false;
}
}
return self::$checkedIps[$cacheKey] = true;
} | php | public static function checkIp6($requestIp, $ip)
{
$cacheKey = $requestIp.'-'.$ip;
if (isset(self::$checkedIps[$cacheKey])) {
return self::$checkedIps[$cacheKey];
}
if (!((\extension_loaded('sockets') && \defined('AF_INET6')) || @inet_pton('::1'))) {
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
}
if (false !== strpos($ip, '/')) {
list($address, $netmask) = explode('/', $ip, 2);
if ('0' === $netmask) {
return (bool) unpack('n*', @inet_pton($address));
}
if ($netmask < 1 || $netmask > 128) {
return self::$checkedIps[$cacheKey] = false;
}
} else {
$address = $ip;
$netmask = 128;
}
$bytesAddr = unpack('n*', @inet_pton($address));
$bytesTest = unpack('n*', @inet_pton($requestIp));
if (!$bytesAddr || !$bytesTest) {
return self::$checkedIps[$cacheKey] = false;
}
for ($i = 1, $ceil = ceil($netmask / 16); $i <= $ceil; ++$i) {
$left = $netmask - 16 * ($i - 1);
$left = ($left <= 16) ? $left : 16;
$mask = ~(0xffff >> $left) & 0xffff;
if (($bytesAddr[$i] & $mask) != ($bytesTest[$i] & $mask)) {
return self::$checkedIps[$cacheKey] = false;
}
}
return self::$checkedIps[$cacheKey] = true;
} | [
"public",
"static",
"function",
"checkIp6",
"(",
"$",
"requestIp",
",",
"$",
"ip",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"requestIp",
".",
"'-'",
".",
"$",
"ip",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"checkedIps",
"[",
"$",
"cacheKey",
"]... | Compares two IPv6 addresses.
In case a subnet is given, it checks if it contains the request IP.
@author David Soria Parra <dsp at php dot net>
@see https://github.com/dsp/v6tools
@param string $requestIp IPv6 address to check
@param string $ip IPv6 address or subnet in CIDR notation
@return bool Whether the IP is valid
@throws \RuntimeException When IPV6 support is not enabled | [
"Compares",
"two",
"IPv6",
"addresses",
".",
"In",
"case",
"a",
"subnet",
"is",
"given",
"it",
"checks",
"if",
"it",
"contains",
"the",
"request",
"IP",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/IpUtils.php#L112-L155 | train | Check if the request is on IPv6 | [
30522,
2270,
10763,
3853,
4638,
11514,
2575,
1006,
1002,
5227,
11514,
1010,
1002,
12997,
1007,
1063,
1002,
17053,
14839,
1027,
1002,
5227,
11514,
1012,
1005,
1011,
1005,
1012,
1002,
12997,
1025,
2065,
1006,
26354,
3388,
1006,
2969,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Debug/ErrorHandler.php | ErrorHandler.traceAt | public function traceAt($levels, $replace = false)
{
$prev = $this->tracedErrors;
$this->tracedErrors = (int) $levels;
if (!$replace) {
$this->tracedErrors |= $prev;
}
return $prev;
} | php | public function traceAt($levels, $replace = false)
{
$prev = $this->tracedErrors;
$this->tracedErrors = (int) $levels;
if (!$replace) {
$this->tracedErrors |= $prev;
}
return $prev;
} | [
"public",
"function",
"traceAt",
"(",
"$",
"levels",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"$",
"prev",
"=",
"$",
"this",
"->",
"tracedErrors",
";",
"$",
"this",
"->",
"tracedErrors",
"=",
"(",
"int",
")",
"$",
"levels",
";",
"if",
"(",
"!",... | Sets the PHP error levels for which the stack trace is preserved.
@param int $levels A bit field of E_* constants for traced errors
@param bool $replace Replace or amend the previous value
@return int The previous value | [
"Sets",
"the",
"PHP",
"error",
"levels",
"for",
"which",
"the",
"stack",
"trace",
"is",
"preserved",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Debug/ErrorHandler.php#L319-L328 | train | Trace at a level | [
30522,
2270,
3853,
7637,
4017,
1006,
1002,
3798,
1010,
1002,
5672,
1027,
6270,
1007,
1063,
1002,
3653,
2615,
1027,
1002,
2023,
1011,
1028,
9551,
2121,
29165,
2015,
1025,
1002,
2023,
1011,
1028,
9551,
2121,
29165,
2015,
1027,
1006,
20014,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Annotations/Controller.php | Controller.addAnnotation | public function addAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// the date used is for the annotation manager HTML that gets echo'd. we
// use this date for the new annotation, unless it is a date range, in
// which case we use the first date of the range.
$date = Common::getRequestVar('date');
if (strpos($date, ',') !== false) {
$date = reset(explode(',', $date));
}
// add the annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.add", array('date' => $date));
$managerDate = Common::getRequestVar('managerDate', false);
$managerPeriod = Common::getRequestVar('managerPeriod', false);
return $this->getAnnotationManager($fetch = true, $managerDate, $managerPeriod);
}
} | php | public function addAnnotation()
{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$this->checkTokenInUrl();
// the date used is for the annotation manager HTML that gets echo'd. we
// use this date for the new annotation, unless it is a date range, in
// which case we use the first date of the range.
$date = Common::getRequestVar('date');
if (strpos($date, ',') !== false) {
$date = reset(explode(',', $date));
}
// add the annotation. NOTE: permissions checked in API method
Request::processRequest("Annotations.add", array('date' => $date));
$managerDate = Common::getRequestVar('managerDate', false);
$managerPeriod = Common::getRequestVar('managerPeriod', false);
return $this->getAnnotationManager($fetch = true, $managerDate, $managerPeriod);
}
} | [
"public",
"function",
"addAnnotation",
"(",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"POST\"",
")",
"{",
"$",
"this",
"->",
"checkTokenInUrl",
"(",
")",
";",
"// the date used is for the annotation manager HTML that gets echo'd. we"... | Controller action that adds a new annotation for a site and returns new
annotation manager HTML for the site and date range.
Query Param Input:
- idSite: The ID of the site to add an annotation to.
- date: The date for the new annotation.
- note: The text of the annotation.
- starred: Either 1 or 0, whether the annotation should be starred or not.
Defaults to 0.
- managerDate: The date for the annotation manager. If a range is given, the start
date is used for the new annotation.
- managerPeriod: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
- lastN: For rendering the annotation manager. @see self::getAnnotationManager
for more info.
Output:
- @see self::getAnnotationManager | [
"Controller",
"action",
"that",
"adds",
"a",
"new",
"annotation",
"for",
"a",
"site",
"and",
"returns",
"new",
"annotation",
"manager",
"HTML",
"for",
"the",
"site",
"and",
"date",
"range",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/Controller.php#L140-L160 | train | add an annotation to the list of available annotations | [
30522,
2270,
3853,
5587,
11639,
17287,
3508,
1006,
1007,
1063,
2065,
1006,
1002,
1035,
8241,
1031,
1000,
5227,
1035,
4118,
1000,
1033,
1027,
1027,
1000,
2695,
1000,
1007,
1063,
1002,
2023,
1011,
1028,
4638,
18715,
18595,
11231,
12190,
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/Routing/RouteCollection.php | RouteCollection.addLookups | protected function addLookups($route)
{
// If the route has a name, we will add it to the name look-up table so that we
// will quickly be able to find any route associate with a name and not have
// to iterate through every route every time we need to perform a look-up.
if ($name = $route->getName()) {
$this->nameList[$name] = $route;
}
// When the route is routing to a controller we will also store the action that
// is used by the route. This will let us reverse route to controllers while
// processing a request and easily generate URLs to the given controllers.
$action = $route->getAction();
if (isset($action['controller'])) {
$this->addToActionList($action, $route);
}
} | php | protected function addLookups($route)
{
// If the route has a name, we will add it to the name look-up table so that we
// will quickly be able to find any route associate with a name and not have
// to iterate through every route every time we need to perform a look-up.
if ($name = $route->getName()) {
$this->nameList[$name] = $route;
}
// When the route is routing to a controller we will also store the action that
// is used by the route. This will let us reverse route to controllers while
// processing a request and easily generate URLs to the given controllers.
$action = $route->getAction();
if (isset($action['controller'])) {
$this->addToActionList($action, $route);
}
} | [
"protected",
"function",
"addLookups",
"(",
"$",
"route",
")",
"{",
"// If the route has a name, we will add it to the name look-up table so that we",
"// will quickly be able to find any route associate with a name and not have",
"// to iterate through every route every time we need to perform ... | Add the route to any look-up tables if necessary.
@param \Illuminate\Routing\Route $route
@return void | [
"Add",
"the",
"route",
"to",
"any",
"look",
"-",
"up",
"tables",
"if",
"necessary",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/RouteCollection.php#L82-L99 | train | Add lookups to the name and action list | [
30522,
5123,
3853,
5587,
4135,
21940,
4523,
1006,
1002,
2799,
1007,
1063,
1013,
1013,
2065,
1996,
2799,
2038,
1037,
2171,
1010,
2057,
2097,
5587,
2009,
2000,
1996,
2171,
2298,
1011,
2039,
2795,
2061,
2008,
2057,
1013,
1013,
2097,
2855,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Assets.php | Assets.addJs | public function addJs($asset)
{
return $this->addType(Assets::JS_COLLECTION, Assets::JS_TYPE, $asset, $this->unifyLegacyArguments(\func_get_args(), Assets::JS_TYPE));
} | php | public function addJs($asset)
{
return $this->addType(Assets::JS_COLLECTION, Assets::JS_TYPE, $asset, $this->unifyLegacyArguments(\func_get_args(), Assets::JS_TYPE));
} | [
"public",
"function",
"addJs",
"(",
"$",
"asset",
")",
"{",
"return",
"$",
"this",
"->",
"addType",
"(",
"Assets",
"::",
"JS_COLLECTION",
",",
"Assets",
"::",
"JS_TYPE",
",",
"$",
"asset",
",",
"$",
"this",
"->",
"unifyLegacyArguments",
"(",
"\\",
"func_... | Add a JS asset or a collection of assets.
@return $this | [
"Add",
"a",
"JS",
"asset",
"or",
"a",
"collection",
"of",
"assets",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Assets.php#L233-L236 | train | Adds a JS asset to the page | [
30522,
2270,
3853,
5587,
22578,
1006,
1002,
11412,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5587,
13874,
1006,
7045,
1024,
1024,
1046,
2015,
1035,
3074,
1010,
7045,
1024,
1024,
1046,
2015,
1035,
2828,
1010,
1002,
11412,
1010,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php | GuardAuthenticatorHandler.authenticateUserAndHandleSuccess | public function authenticateUserAndHandleSuccess(UserInterface $user, Request $request, AuthenticatorInterface $authenticator, string $providerKey): ?Response
{
// create an authenticated token for the User
$token = $authenticator->createAuthenticatedToken($user, $providerKey);
// authenticate this in the system
$this->authenticateWithToken($token, $request, $providerKey);
// return the success metric
return $this->handleAuthenticationSuccess($token, $request, $authenticator, $providerKey);
} | php | public function authenticateUserAndHandleSuccess(UserInterface $user, Request $request, AuthenticatorInterface $authenticator, string $providerKey): ?Response
{
// create an authenticated token for the User
$token = $authenticator->createAuthenticatedToken($user, $providerKey);
// authenticate this in the system
$this->authenticateWithToken($token, $request, $providerKey);
// return the success metric
return $this->handleAuthenticationSuccess($token, $request, $authenticator, $providerKey);
} | [
"public",
"function",
"authenticateUserAndHandleSuccess",
"(",
"UserInterface",
"$",
"user",
",",
"Request",
"$",
"request",
",",
"AuthenticatorInterface",
"$",
"authenticator",
",",
"string",
"$",
"providerKey",
")",
":",
"?",
"Response",
"{",
"// create an authentic... | Convenience method for authenticating the user and returning the
Response *if any* for success. | [
"Convenience",
"method",
"for",
"authenticating",
"the",
"user",
"and",
"returning",
"the",
"Response",
"*",
"if",
"any",
"*",
"for",
"success",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php#L88-L97 | train | authenticate the user and return the success metric | [
30522,
2270,
3853,
14469,
3686,
20330,
5685,
11774,
4244,
14194,
9623,
2015,
1006,
5310,
18447,
2121,
12172,
1002,
5310,
1010,
5227,
1002,
5227,
1010,
14469,
8844,
18447,
2121,
12172,
1002,
14469,
8844,
1010,
5164,
1002,
10802,
14839,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Profiler.php | Profiler.setupProfilerXHProf | public static function setupProfilerXHProf($mainRun = false, $setupDuringTracking = false)
{
if (!$setupDuringTracking
&& SettingsServer::isTrackerApiRequest()
) {
// do not profile Tracker
return;
}
if (self::$isXhprofSetup) {
return;
}
$hasXhprof = function_exists('xhprof_enable');
$hasTidewaysXhprof = function_exists('tideways_xhprof_enable');
if (!$hasXhprof && !$hasTidewaysXhprof) {
$xhProfPath = PIWIK_INCLUDE_PATH . '/vendor/facebook/xhprof/extension/modules/xhprof.so';
throw new Exception("Cannot find xhprof_enable, make sure to 1) install xhprof: run 'composer install --dev' and build the extension, and 2) add 'extension=$xhProfPath' to your php.ini.");
}
$outputDir = ini_get("xhprof.output_dir");
if (!$outputDir && $hasTidewaysXhprof) {
$outputDir = sys_get_temp_dir();
}
if (empty($outputDir)) {
throw new Exception("The profiler output dir is not set. Add 'xhprof.output_dir=...' to your php.ini.");
}
if (!is_writable($outputDir)) {
throw new Exception("The profiler output dir '" . ini_get("xhprof.output_dir") . "' should exist and be writable.");
}
if (!function_exists('xhprof_error')) {
function xhprof_error($out)
{
echo substr($out, 0, 300) . '...';
}
}
$currentGitBranch = SettingsPiwik::getCurrentGitBranch();
$profilerNamespace = "piwik";
if ($currentGitBranch != 'master') {
$profilerNamespace .= "-" . $currentGitBranch;
}
if ($mainRun) {
self::setProfilingRunIds(array());
}
if (function_exists('xhprof_enable')) {
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
} elseif (function_exists('tideways_xhprof_enable')) {
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_CPU);
}
register_shutdown_function(function () use ($profilerNamespace, $mainRun, $outputDir) {
if (function_exists('xhprof_disable')) {
$xhprofData = xhprof_disable();
$xhprofRuns = new XHProfRuns_Default();
$runId = $xhprofRuns->save_run($xhprofData, $profilerNamespace);
} elseif (function_exists('tideways_xhprof_disable')) {
$xhprofData = tideways_xhprof_disable();
$runId = uniqid();
file_put_contents(
$outputDir . DIRECTORY_SEPARATOR . $runId . '.' . $profilerNamespace . '.xhprof',
serialize($xhprofData)
);
}
if (empty($runId)) {
die('could not write profiler run');
}
$runs = Profiler::getProfilingRunIds();
array_unshift($runs, $runId);
if ($mainRun) {
Profiler::aggregateXhprofRuns($runs, $profilerNamespace, $saveTo = $runId);
$baseUrlStored = SettingsPiwik::getPiwikUrl();
$out = "\n\n";
$baseUrl = "http://" . @$_SERVER['HTTP_HOST'] . "/" . @$_SERVER['REQUEST_URI'];
if (strlen($baseUrlStored) > strlen($baseUrl)) {
$baseUrl = $baseUrlStored;
}
$baseUrl = $baseUrlStored . "vendor/facebook/xhprof/xhprof_html/?source=$profilerNamespace&run=$runId";
$out .= "Profiler report is available at:\n";
$out .= "<a href='$baseUrl'>$baseUrl</a>";
$out .= "\n\n";
if (Development::isEnabled()) {
$out .= "WARNING: Development mode is enabled. Many runtime optimizations are not applied in development mode. ";
$out .= "Unless you intend to profile Matomo in development mode, your profile may not be accurate.";
$out .= "\n\n";
}
echo $out;
} else {
Profiler::setProfilingRunIds($runs);
}
});
self::$isXhprofSetup = true;
} | php | public static function setupProfilerXHProf($mainRun = false, $setupDuringTracking = false)
{
if (!$setupDuringTracking
&& SettingsServer::isTrackerApiRequest()
) {
// do not profile Tracker
return;
}
if (self::$isXhprofSetup) {
return;
}
$hasXhprof = function_exists('xhprof_enable');
$hasTidewaysXhprof = function_exists('tideways_xhprof_enable');
if (!$hasXhprof && !$hasTidewaysXhprof) {
$xhProfPath = PIWIK_INCLUDE_PATH . '/vendor/facebook/xhprof/extension/modules/xhprof.so';
throw new Exception("Cannot find xhprof_enable, make sure to 1) install xhprof: run 'composer install --dev' and build the extension, and 2) add 'extension=$xhProfPath' to your php.ini.");
}
$outputDir = ini_get("xhprof.output_dir");
if (!$outputDir && $hasTidewaysXhprof) {
$outputDir = sys_get_temp_dir();
}
if (empty($outputDir)) {
throw new Exception("The profiler output dir is not set. Add 'xhprof.output_dir=...' to your php.ini.");
}
if (!is_writable($outputDir)) {
throw new Exception("The profiler output dir '" . ini_get("xhprof.output_dir") . "' should exist and be writable.");
}
if (!function_exists('xhprof_error')) {
function xhprof_error($out)
{
echo substr($out, 0, 300) . '...';
}
}
$currentGitBranch = SettingsPiwik::getCurrentGitBranch();
$profilerNamespace = "piwik";
if ($currentGitBranch != 'master') {
$profilerNamespace .= "-" . $currentGitBranch;
}
if ($mainRun) {
self::setProfilingRunIds(array());
}
if (function_exists('xhprof_enable')) {
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
} elseif (function_exists('tideways_xhprof_enable')) {
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_CPU);
}
register_shutdown_function(function () use ($profilerNamespace, $mainRun, $outputDir) {
if (function_exists('xhprof_disable')) {
$xhprofData = xhprof_disable();
$xhprofRuns = new XHProfRuns_Default();
$runId = $xhprofRuns->save_run($xhprofData, $profilerNamespace);
} elseif (function_exists('tideways_xhprof_disable')) {
$xhprofData = tideways_xhprof_disable();
$runId = uniqid();
file_put_contents(
$outputDir . DIRECTORY_SEPARATOR . $runId . '.' . $profilerNamespace . '.xhprof',
serialize($xhprofData)
);
}
if (empty($runId)) {
die('could not write profiler run');
}
$runs = Profiler::getProfilingRunIds();
array_unshift($runs, $runId);
if ($mainRun) {
Profiler::aggregateXhprofRuns($runs, $profilerNamespace, $saveTo = $runId);
$baseUrlStored = SettingsPiwik::getPiwikUrl();
$out = "\n\n";
$baseUrl = "http://" . @$_SERVER['HTTP_HOST'] . "/" . @$_SERVER['REQUEST_URI'];
if (strlen($baseUrlStored) > strlen($baseUrl)) {
$baseUrl = $baseUrlStored;
}
$baseUrl = $baseUrlStored . "vendor/facebook/xhprof/xhprof_html/?source=$profilerNamespace&run=$runId";
$out .= "Profiler report is available at:\n";
$out .= "<a href='$baseUrl'>$baseUrl</a>";
$out .= "\n\n";
if (Development::isEnabled()) {
$out .= "WARNING: Development mode is enabled. Many runtime optimizations are not applied in development mode. ";
$out .= "Unless you intend to profile Matomo in development mode, your profile may not be accurate.";
$out .= "\n\n";
}
echo $out;
} else {
Profiler::setProfilingRunIds($runs);
}
});
self::$isXhprofSetup = true;
} | [
"public",
"static",
"function",
"setupProfilerXHProf",
"(",
"$",
"mainRun",
"=",
"false",
",",
"$",
"setupDuringTracking",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"setupDuringTracking",
"&&",
"SettingsServer",
"::",
"isTrackerApiRequest",
"(",
")",
")",
"... | Initializes Profiling via XHProf.
See: https://github.com/piwik/piwik/blob/master/tests/README.xhprof.md | [
"Initializes",
"Profiling",
"via",
"XHProf",
".",
"See",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"piwik",
"/",
"piwik",
"/",
"blob",
"/",
"master",
"/",
"tests",
"/",
"README",
".",
"xhprof",
".",
"md"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Profiler.php#L199-L305 | train | Setup XHProf profiler | [
30522,
2270,
10763,
3853,
16437,
21572,
8873,
30524,
16437,
24979,
2075,
6494,
23177,
1004,
1004,
10906,
8043,
6299,
1024,
1024,
21541,
22648,
5484,
9331,
7442,
15500,
1006,
1007,
1007,
1063,
1013,
1013,
2079,
2025,
6337,
27080,
2709,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/Card/JssdkClient.php | JssdkClient.getTicket | public function getTicket(bool $refresh = false, string $type = 'wx_card'): array
{
return parent::getTicket($refresh, $type);
} | php | public function getTicket(bool $refresh = false, string $type = 'wx_card'): array
{
return parent::getTicket($refresh, $type);
} | [
"public",
"function",
"getTicket",
"(",
"bool",
"$",
"refresh",
"=",
"false",
",",
"string",
"$",
"type",
"=",
"'wx_card'",
")",
":",
"array",
"{",
"return",
"parent",
"::",
"getTicket",
"(",
"$",
"refresh",
",",
"$",
"type",
")",
";",
"}"
] | @param bool $refresh
@param string $type
@return array
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
@throws \Psr\SimpleCache\InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\RuntimeException | [
"@param",
"bool",
"$refresh",
"@param",
"string",
"$type"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/Card/JssdkClient.php#L35-L38 | train | Get ticket from the page | [
30522,
2270,
3853,
2131,
26348,
3388,
1006,
22017,
2140,
1002,
25416,
21898,
1027,
6270,
1010,
5164,
1002,
2828,
1027,
1005,
1059,
2595,
1035,
4003,
1005,
1007,
1024,
9140,
1063,
2709,
6687,
1024,
1024,
2131,
26348,
3388,
1006,
1002,
25416,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/View/Engines/EngineResolver.php | EngineResolver.register | public function register($engine, Closure $resolver)
{
unset($this->resolved[$engine]);
$this->resolvers[$engine] = $resolver;
} | php | public function register($engine, Closure $resolver)
{
unset($this->resolved[$engine]);
$this->resolvers[$engine] = $resolver;
} | [
"public",
"function",
"register",
"(",
"$",
"engine",
",",
"Closure",
"$",
"resolver",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"resolved",
"[",
"$",
"engine",
"]",
")",
";",
"$",
"this",
"->",
"resolvers",
"[",
"$",
"engine",
"]",
"=",
"$",
"res... | Register a new engine resolver.
The engine string typically corresponds to a file extension.
@param string $engine
@param \Closure $resolver
@return void | [
"Register",
"a",
"new",
"engine",
"resolver",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Engines/EngineResolver.php#L33-L38 | train | Register a new engine with the Resolver | [
30522,
2270,
3853,
4236,
1006,
1002,
3194,
1010,
8503,
1002,
10663,
2099,
1007,
1063,
4895,
13462,
1006,
1002,
2023,
1011,
1028,
10395,
1031,
1002,
3194,
1033,
1007,
1025,
1002,
2023,
1011,
1028,
10663,
2869,
1031,
1002,
3194,
1033,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Plugin.php | Plugin.mergeArrays | private function mergeArrays($deep, $array1, $array2)
{
if ($deep === 'merge') {
return Utils::arrayMergeRecursiveUnique($array1, $array2);
}
if ($deep === true) {
return array_replace_recursive($array1, $array2);
}
return array_merge($array1, $array2);
} | php | private function mergeArrays($deep, $array1, $array2)
{
if ($deep === 'merge') {
return Utils::arrayMergeRecursiveUnique($array1, $array2);
}
if ($deep === true) {
return array_replace_recursive($array1, $array2);
}
return array_merge($array1, $array2);
} | [
"private",
"function",
"mergeArrays",
"(",
"$",
"deep",
",",
"$",
"array1",
",",
"$",
"array2",
")",
"{",
"if",
"(",
"$",
"deep",
"===",
"'merge'",
")",
"{",
"return",
"Utils",
"::",
"arrayMergeRecursiveUnique",
"(",
"$",
"array1",
",",
"$",
"array2",
... | Merge arrays based on deepness
@param string|bool $deep
@param array $array1
@param array $array2
@return array | [
"Merge",
"arrays",
"based",
"on",
"deepness"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Plugin.php#L313-L323 | train | Merge arrays with the same depth | [
30522,
2797,
3853,
13590,
2906,
9447,
2015,
1006,
1002,
2784,
1010,
1002,
9140,
2487,
1010,
1002,
9140,
2475,
1007,
1063,
2065,
1006,
1002,
2784,
1027,
1027,
1027,
1005,
13590,
1005,
1007,
1063,
2709,
21183,
12146,
1024,
1024,
9140,
5017,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Failed/DatabaseFailedJobProvider.php | DatabaseFailedJobProvider.log | public function log($connection, $queue, $payload, $exception)
{
$failed_at = Date::now();
$exception = (string) $exception;
return $this->getTable()->insertGetId(compact(
'connection', 'queue', 'payload', 'exception', 'failed_at'
));
} | php | public function log($connection, $queue, $payload, $exception)
{
$failed_at = Date::now();
$exception = (string) $exception;
return $this->getTable()->insertGetId(compact(
'connection', 'queue', 'payload', 'exception', 'failed_at'
));
} | [
"public",
"function",
"log",
"(",
"$",
"connection",
",",
"$",
"queue",
",",
"$",
"payload",
",",
"$",
"exception",
")",
"{",
"$",
"failed_at",
"=",
"Date",
"::",
"now",
"(",
")",
";",
"$",
"exception",
"=",
"(",
"string",
")",
"$",
"exception",
";... | Log a failed job into storage.
@param string $connection
@param string $queue
@param string $payload
@param \Exception $exception
@return int|null | [
"Log",
"a",
"failed",
"job",
"into",
"storage",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php#L55-L64 | train | Log a failure | [
30522,
2270,
3853,
8833,
1006,
1002,
4434,
1010,
1002,
24240,
1010,
1002,
18093,
1010,
1002,
6453,
1007,
1063,
1002,
3478,
1035,
2012,
1027,
3058,
1024,
1024,
2085,
1006,
1007,
1025,
1002,
6453,
1027,
1006,
5164,
1007,
1002,
6453,
1025,
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... |
php-ai/php-ml | src/Helper/Optimizer/GD.php | GD.gradient | protected function gradient(array $theta): array
{
$costs = [];
$gradient = [];
$totalPenalty = 0;
if ($this->gradientCb === null) {
throw new InvalidOperationException('Gradient callback is not defined');
}
foreach ($this->samples as $index => $sample) {
$target = $this->targets[$index];
$result = ($this->gradientCb)($theta, $sample, $target);
[$cost, $grad, $penalty] = array_pad($result, 3, 0);
$costs[] = $cost;
$gradient[] = $grad;
$totalPenalty += $penalty;
}
$totalPenalty /= $this->sampleCount;
return [$costs, $gradient, $totalPenalty];
} | php | protected function gradient(array $theta): array
{
$costs = [];
$gradient = [];
$totalPenalty = 0;
if ($this->gradientCb === null) {
throw new InvalidOperationException('Gradient callback is not defined');
}
foreach ($this->samples as $index => $sample) {
$target = $this->targets[$index];
$result = ($this->gradientCb)($theta, $sample, $target);
[$cost, $grad, $penalty] = array_pad($result, 3, 0);
$costs[] = $cost;
$gradient[] = $grad;
$totalPenalty += $penalty;
}
$totalPenalty /= $this->sampleCount;
return [$costs, $gradient, $totalPenalty];
} | [
"protected",
"function",
"gradient",
"(",
"array",
"$",
"theta",
")",
":",
"array",
"{",
"$",
"costs",
"=",
"[",
"]",
";",
"$",
"gradient",
"=",
"[",
"]",
";",
"$",
"totalPenalty",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"gradientCb",
"===",
... | Calculates gradient, cost function and penalty term for each sample
then returns them as an array of values | [
"Calculates",
"gradient",
"cost",
"function",
"and",
"penalty",
"term",
"for",
"each",
"sample",
"then",
"returns",
"them",
"as",
"an",
"array",
"of",
"values"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Helper/Optimizer/GD.php#L57-L81 | train | Return gradient for each sample | [
30522,
5123,
3853,
17978,
1006,
9140,
1002,
23963,
1007,
1024,
9140,
1063,
1002,
5366,
1027,
1031,
1033,
1025,
1002,
17978,
1027,
1031,
1033,
1025,
1002,
2561,
11837,
2389,
3723,
1027,
1014,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
17978,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.baseCss | public static function baseCss($css = null)
{
if (!is_null($css)) {
return static::$baseCss = $css;
}
$skin = config('admin.skin', 'skin-blue-light');
array_unshift(static::$baseCss, "vendor/laravel-admin/AdminLTE/dist/css/skins/{$skin}.min.css");
return static::$baseCss;
} | php | public static function baseCss($css = null)
{
if (!is_null($css)) {
return static::$baseCss = $css;
}
$skin = config('admin.skin', 'skin-blue-light');
array_unshift(static::$baseCss, "vendor/laravel-admin/AdminLTE/dist/css/skins/{$skin}.min.css");
return static::$baseCss;
} | [
"public",
"static",
"function",
"baseCss",
"(",
"$",
"css",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"css",
")",
")",
"{",
"return",
"static",
"::",
"$",
"baseCss",
"=",
"$",
"css",
";",
"}",
"$",
"skin",
"=",
"config",
"(",
... | @param null $css
@return array|null | [
"@param",
"null",
"$css"
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Traits/HasAssets.php#L109-L120 | train | Get base css file | [
30522,
2270,
10763,
3853,
2918,
6169,
2015,
1006,
1002,
20116,
2015,
1027,
19701,
1007,
1063,
2065,
1006,
999,
2003,
1035,
19701,
1006,
1002,
20116,
2015,
1007,
1007,
1063,
2709,
10763,
1024,
1024,
1002,
2918,
6169,
2015,
1027,
1002,
20116,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Storage/Maildir.php | Zend_Mail_Storage_Maildir._getFileData | protected function _getFileData($id, $field = null)
{
if (!isset($this->_files[$id - 1])) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('id does not exist');
}
if (!$field) {
return $this->_files[$id - 1];
}
if (!isset($this->_files[$id - 1][$field])) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('field does not exist');
}
return $this->_files[$id - 1][$field];
} | php | protected function _getFileData($id, $field = null)
{
if (!isset($this->_files[$id - 1])) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('id does not exist');
}
if (!$field) {
return $this->_files[$id - 1];
}
if (!isset($this->_files[$id - 1][$field])) {
/**
* @see Zend_Mail_Storage_Exception
*/
// require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('field does not exist');
}
return $this->_files[$id - 1][$field];
} | [
"protected",
"function",
"_getFileData",
"(",
"$",
"id",
",",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_files",
"[",
"$",
"id",
"-",
"1",
"]",
")",
")",
"{",
"/**\n * @see Zend_Mail_Storage_Except... | Get one or all fields from file structure. Also checks if message is valid
@param int $id message number
@param string|null $field wanted field
@return string|array wanted field or all fields as array
@throws Zend_Mail_Storage_Exception | [
"Get",
"one",
"or",
"all",
"fields",
"from",
"file",
"structure",
".",
"Also",
"checks",
"if",
"message",
"is",
"valid"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Storage/Maildir.php#L119-L142 | train | Get file data | [
30522,
5123,
3853,
1035,
2131,
8873,
3709,
6790,
1006,
1002,
8909,
1010,
1002,
2492,
1027,
19701,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
30524,
5653,
1035,
5527,
1035,
6453,
1008,
1013,
1013,
1013,
5478,
1035,
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... |
octobercms/october | modules/backend/widgets/Search.php | Search.render | public function render()
{
$this->prepareVars();
if ($this->partial) {
return $this->controller->makePartial($this->partial);
}
return $this->makePartial('search');
} | php | public function render()
{
$this->prepareVars();
if ($this->partial) {
return $this->controller->makePartial($this->partial);
}
return $this->makePartial('search');
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"prepareVars",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"partial",
")",
"{",
"return",
"$",
"this",
"->",
"controller",
"->",
"makePartial",
"(",
"$",
"this",
"->",
"partial",
")",... | Renders the widget. | [
"Renders",
"the",
"widget",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Search.php#L95-L104 | train | Render the partial | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
7374,
10755,
2015,
1006,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
7704,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
11486,
1011,
1028,
2191,
19362,
20925,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Row.php | Row.sumRow | public function sumRow(Row $rowToSum, $enableCopyMetadata = true, $aggregationOperations = false)
{
foreach ($rowToSum as $columnToSumName => $columnToSumValue) {
if (!$this->isSummableColumn($columnToSumName)) {
continue;
}
$thisColumnValue = $this->getColumn($columnToSumName);
$operation = 'sum';
if (is_array($aggregationOperations) && isset($aggregationOperations[$columnToSumName])) {
if (is_string($aggregationOperations[$columnToSumName])) {
$operation = strtolower($aggregationOperations[$columnToSumName]);
} elseif (is_callable($aggregationOperations[$columnToSumName])) {
$operation = $aggregationOperations[$columnToSumName];
}
}
// max_actions is a core metric that is generated in ArchiveProcess_Day. Therefore, it can be
// present in any data table and is not part of the $aggregationOperations mechanism.
if ($columnToSumName == Metrics::INDEX_MAX_ACTIONS) {
$operation = 'max';
}
if (empty($operation)) {
throw new Exception("Unknown aggregation operation for column $columnToSumName.");
}
$newValue = $this->getColumnValuesMerged($operation, $thisColumnValue, $columnToSumValue, $this, $rowToSum, $columnToSumName);
$this->setColumn($columnToSumName, $newValue);
}
if ($enableCopyMetadata) {
$this->sumRowMetadata($rowToSum, $aggregationOperations);
}
} | php | public function sumRow(Row $rowToSum, $enableCopyMetadata = true, $aggregationOperations = false)
{
foreach ($rowToSum as $columnToSumName => $columnToSumValue) {
if (!$this->isSummableColumn($columnToSumName)) {
continue;
}
$thisColumnValue = $this->getColumn($columnToSumName);
$operation = 'sum';
if (is_array($aggregationOperations) && isset($aggregationOperations[$columnToSumName])) {
if (is_string($aggregationOperations[$columnToSumName])) {
$operation = strtolower($aggregationOperations[$columnToSumName]);
} elseif (is_callable($aggregationOperations[$columnToSumName])) {
$operation = $aggregationOperations[$columnToSumName];
}
}
// max_actions is a core metric that is generated in ArchiveProcess_Day. Therefore, it can be
// present in any data table and is not part of the $aggregationOperations mechanism.
if ($columnToSumName == Metrics::INDEX_MAX_ACTIONS) {
$operation = 'max';
}
if (empty($operation)) {
throw new Exception("Unknown aggregation operation for column $columnToSumName.");
}
$newValue = $this->getColumnValuesMerged($operation, $thisColumnValue, $columnToSumValue, $this, $rowToSum, $columnToSumName);
$this->setColumn($columnToSumName, $newValue);
}
if ($enableCopyMetadata) {
$this->sumRowMetadata($rowToSum, $aggregationOperations);
}
} | [
"public",
"function",
"sumRow",
"(",
"Row",
"$",
"rowToSum",
",",
"$",
"enableCopyMetadata",
"=",
"true",
",",
"$",
"aggregationOperations",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"rowToSum",
"as",
"$",
"columnToSumName",
"=>",
"$",
"columnToSumValue",
... | Sums the given `$rowToSum` columns values to the existing row column values.
Only the int or float values will be summed. Label columns will be ignored
even if they have a numeric value.
Columns in `$rowToSum` that don't exist in `$this` are added to `$this`.
@param \Piwik\DataTable\Row $rowToSum The row to sum to this row.
@param bool $enableCopyMetadata Whether metadata should be copied or not.
@param array|bool $aggregationOperations for columns that should not be summed, determine which
aggregation should be used (min, max). format:
`array('column name' => 'function name')`
@throws Exception | [
"Sums",
"the",
"given",
"$rowToSum",
"columns",
"values",
"to",
"the",
"existing",
"row",
"column",
"values",
".",
"Only",
"the",
"int",
"or",
"float",
"values",
"will",
"be",
"summed",
".",
"Label",
"columns",
"will",
"be",
"ignored",
"even",
"if",
"they"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L454-L489 | train | Sums a row of data into the current row. | [
30522,
2270,
3853,
7680,
10524,
1006,
5216,
1002,
5216,
13122,
2819,
1010,
1002,
9585,
3597,
7685,
11368,
8447,
2696,
1027,
2995,
1010,
1002,
28041,
25918,
10708,
1027,
6270,
1007,
1063,
18921,
6776,
1006,
1002,
5216,
13122,
2819,
2004,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/LanguagesManager/TranslationWriter/Validate/CoreTranslations.php | CoreTranslations.isValid | public function isValid($translations)
{
$this->message = null;
if (empty($translations['General']['Locale'])) {
$this->message = self::ERRORSTATE_LOCALEREQUIRED;
return false;
}
if (empty($translations['General']['TranslatorName'])) {
$this->message = self::ERRORSTATE_TRANSLATORINFOREQUIRED;
return false;
}
/** @var LanguageDataProvider $languageDataProvider */
$languageDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\LanguageDataProvider');
/** @var RegionDataProvider $regionDataProvider */
$regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$allLanguages = $languageDataProvider->getLanguageList();
$allCountries = $regionDataProvider->getCountryList();
if ('eo.UTF-8' === $translations['General']['Locale']) {
return true;
}
if (!preg_match('/^([a-z]{2})_([A-Z]{2})\.UTF-8$/', $translations['General']['Locale'], $matches)) {
$this->message = self::ERRORSTATE_LOCALEINVALID;
return false;
} else if (!array_key_exists($matches[1], $allLanguages)) {
$this->message = self::ERRORSTATE_LOCALEINVALIDLANGUAGE;
return false;
} else if (!array_key_exists(strtolower($matches[2]), $allCountries)) {
$this->message = self::ERRORSTATE_LOCALEINVALIDCOUNTRY;
return false;
}
return true;
} | php | public function isValid($translations)
{
$this->message = null;
if (empty($translations['General']['Locale'])) {
$this->message = self::ERRORSTATE_LOCALEREQUIRED;
return false;
}
if (empty($translations['General']['TranslatorName'])) {
$this->message = self::ERRORSTATE_TRANSLATORINFOREQUIRED;
return false;
}
/** @var LanguageDataProvider $languageDataProvider */
$languageDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\LanguageDataProvider');
/** @var RegionDataProvider $regionDataProvider */
$regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$allLanguages = $languageDataProvider->getLanguageList();
$allCountries = $regionDataProvider->getCountryList();
if ('eo.UTF-8' === $translations['General']['Locale']) {
return true;
}
if (!preg_match('/^([a-z]{2})_([A-Z]{2})\.UTF-8$/', $translations['General']['Locale'], $matches)) {
$this->message = self::ERRORSTATE_LOCALEINVALID;
return false;
} else if (!array_key_exists($matches[1], $allLanguages)) {
$this->message = self::ERRORSTATE_LOCALEINVALIDLANGUAGE;
return false;
} else if (!array_key_exists(strtolower($matches[2]), $allCountries)) {
$this->message = self::ERRORSTATE_LOCALEINVALIDCOUNTRY;
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"translations",
")",
"{",
"$",
"this",
"->",
"message",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"translations",
"[",
"'General'",
"]",
"[",
"'Locale'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"message... | Validates the given translations
* There need to be more than 250 translations present
* Locale and TranslatorName needs to be set in plugin General
* Locale must be valid (format, language & country)
@param array $translations
@return boolean | [
"Validates",
"the",
"given",
"translations",
"*",
"There",
"need",
"to",
"be",
"more",
"than",
"250",
"translations",
"present",
"*",
"Locale",
"and",
"TranslatorName",
"needs",
"to",
"be",
"set",
"in",
"plugin",
"General",
"*",
"Locale",
"must",
"be",
"vali... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/TranslationWriter/Validate/CoreTranslations.php#L49-L87 | train | Check if the translation array is valid | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
1002,
11913,
1007,
1063,
1002,
2023,
1011,
1028,
4471,
1027,
19701,
1025,
2065,
1006,
4064,
1006,
1002,
11913,
1031,
1005,
2236,
1005,
1033,
1031,
1005,
2334,
2063,
1005,
1033,
1007,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/Extension.php | Extension.displayBlock | public function displayBlock($name, $default = null)
{
if (($result = Block::placeholder($name)) === null) {
return $default;
}
if ($event = Event::fire('cms.block.render', [$name, $result], true))
$result = $event;
$result = str_replace('<!-- X_OCTOBER_DEFAULT_BLOCK_CONTENT -->', trim($default), $result);
return $result;
} | php | public function displayBlock($name, $default = null)
{
if (($result = Block::placeholder($name)) === null) {
return $default;
}
if ($event = Event::fire('cms.block.render', [$name, $result], true))
$result = $event;
$result = str_replace('<!-- X_OCTOBER_DEFAULT_BLOCK_CONTENT -->', trim($default), $result);
return $result;
} | [
"public",
"function",
"displayBlock",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"result",
"=",
"Block",
"::",
"placeholder",
"(",
"$",
"name",
")",
")",
"===",
"null",
")",
"{",
"return",
"$",
"default",
";"... | Returns a layout block contents and removes the block.
@param string $name Specifies the block name
@param string $default The default placeholder contents.
@return mixed Returns the block contents string or null of the block doesn't exist | [
"Returns",
"a",
"layout",
"block",
"contents",
"and",
"removes",
"the",
"block",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/Extension.php#L190-L201 | train | Returns the block content | [
30522,
2270,
3853,
4653,
23467,
1006,
1002,
2171,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
1006,
1002,
2765,
1027,
3796,
1024,
1024,
2173,
14528,
1006,
1002,
2171,
1007,
1007,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
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/Relations/HasOneOrMany.php | HasOneOrMany.addConstraints | public function addConstraints()
{
if (static::$constraints) {
$this->query->where($this->foreignKey, '=', $this->getParentKey());
$this->query->whereNotNull($this->foreignKey);
}
} | php | public function addConstraints()
{
if (static::$constraints) {
$this->query->where($this->foreignKey, '=', $this->getParentKey());
$this->query->whereNotNull($this->foreignKey);
}
} | [
"public",
"function",
"addConstraints",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"constraints",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"where",
"(",
"$",
"this",
"->",
"foreignKey",
",",
"'='",
",",
"$",
"this",
"->",
"getParentKey",
"(",
... | Set the base constraints on the relation query.
@return void | [
"Set",
"the",
"base",
"constraints",
"on",
"the",
"relation",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php#L67-L74 | train | Add constraints to the query | [
30522,
2270,
3853,
5587,
8663,
20528,
18447,
2015,
1006,
1007,
1063,
2065,
1006,
10763,
1024,
1024,
1002,
14679,
1007,
1063,
1002,
2023,
1011,
1028,
23032,
1011,
1028,
2073,
1006,
1002,
2023,
1011,
1028,
3097,
14839,
1010,
1005,
1027,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataAccess/RawLogDao.php | RawLogDao.deleteConversionItems | public function deleteConversionItems($visitIds)
{
$sql = "DELETE FROM `" . Common::prefixTable('log_conversion_item') . "` WHERE idvisit IN "
. $this->getInFieldExpressionWithInts($visitIds);
$statement = Db::query($sql);
return $statement->rowCount();
} | php | public function deleteConversionItems($visitIds)
{
$sql = "DELETE FROM `" . Common::prefixTable('log_conversion_item') . "` WHERE idvisit IN "
. $this->getInFieldExpressionWithInts($visitIds);
$statement = Db::query($sql);
return $statement->rowCount();
} | [
"public",
"function",
"deleteConversionItems",
"(",
"$",
"visitIds",
")",
"{",
"$",
"sql",
"=",
"\"DELETE FROM `\"",
".",
"Common",
"::",
"prefixTable",
"(",
"'log_conversion_item'",
")",
".",
"\"` WHERE idvisit IN \"",
".",
"$",
"this",
"->",
"getInFieldExpressionW... | Deletes conversion items for the supplied visit IDs from log_conversion_item.
@param int[] $visitIds
@return int The number of deleted rows. | [
"Deletes",
"conversion",
"items",
"for",
"the",
"supplied",
"visit",
"IDs",
"from",
"log_conversion_item",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/RawLogDao.php#L145-L152 | train | Delete conversion items | [
30522,
2270,
3853,
3972,
12870,
8663,
27774,
4221,
5244,
1006,
1002,
3942,
9821,
1007,
1063,
1002,
29296,
1027,
1000,
3972,
12870,
2013,
1036,
1000,
1012,
2691,
1024,
1024,
17576,
10880,
1006,
1005,
8833,
1035,
7584,
1035,
8875,
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... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.lang | protected function lang($key)
{
if (count($this->language) < 1) {
$this->setLanguage('en'); // set the default language
}
if (array_key_exists($key, $this->language)) {
if ('smtp_connect_failed' == $key) {
//Include a link to troubleshooting docs on SMTP connection failure
//this is by far the biggest cause of support questions
//but it's usually not PHPMailer's fault.
return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
}
return $this->language[$key];
}
//Return the key as a fallback
return $key;
} | php | protected function lang($key)
{
if (count($this->language) < 1) {
$this->setLanguage('en'); // set the default language
}
if (array_key_exists($key, $this->language)) {
if ('smtp_connect_failed' == $key) {
//Include a link to troubleshooting docs on SMTP connection failure
//this is by far the biggest cause of support questions
//but it's usually not PHPMailer's fault.
return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
}
return $this->language[$key];
}
//Return the key as a fallback
return $key;
} | [
"protected",
"function",
"lang",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"language",
")",
"<",
"1",
")",
"{",
"$",
"this",
"->",
"setLanguage",
"(",
"'en'",
")",
";",
"// set the default language",
"}",
"if",
"(",
"arra... | Get an error message in the current language.
@param string $key
@return string | [
"Get",
"an",
"error",
"message",
"in",
"the",
"current",
"language",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L3694-L3713 | train | Return the language code | [
30522,
5123,
3853,
11374,
1006,
1002,
3145,
1007,
1063,
2065,
1006,
4175,
1006,
1002,
2023,
1011,
1028,
2653,
1007,
1026,
1015,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
25023,
6692,
3351,
1006,
1005,
4372,
1005,
1007,
1025,
1013,
1013,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/ResponseFactory.php | ResponseFactory.jsonp | public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0)
{
return $this->json($data, $status, $headers, $options)->setCallback($callback);
} | php | public function jsonp($callback, $data = [], $status = 200, array $headers = [], $options = 0)
{
return $this->json($data, $status, $headers, $options)->setCallback($callback);
} | [
"public",
"function",
"jsonp",
"(",
"$",
"callback",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"status",
"=",
"200",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"json",
"("... | Create a new JSONP response instance.
@param string $callback
@param mixed $data
@param int $status
@param array $headers
@param int $options
@return \Illuminate\Http\JsonResponse | [
"Create",
"a",
"new",
"JSONP",
"response",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/ResponseFactory.php#L108-L111 | train | JSONP Response Set Callback | [
30522,
2270,
3853,
1046,
3385,
2361,
1006,
1002,
2655,
5963,
1010,
1002,
2951,
1027,
1031,
1033,
1010,
1002,
3570,
1027,
3263,
1010,
9140,
1002,
20346,
2015,
1027,
1031,
1033,
1010,
1002,
7047,
1027,
1014,
1007,
1063,
2709,
1002,
2023,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php | RedisSessionHandler.doDestroy | protected function doDestroy($sessionId): bool
{
$this->redis->del($this->prefix.$sessionId);
return true;
} | php | protected function doDestroy($sessionId): bool
{
$this->redis->del($this->prefix.$sessionId);
return true;
} | [
"protected",
"function",
"doDestroy",
"(",
"$",
"sessionId",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"redis",
"->",
"del",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"sessionId",
")",
";",
"return",
"true",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/RedisSessionHandler.php#L84-L89 | train | Destroy session. | [
30522,
5123,
3853,
26489,
4355,
13238,
1006,
1002,
5219,
3593,
1007,
1024,
22017,
2140,
1063,
1002,
2023,
1011,
1028,
2417,
2483,
1011,
1028,
3972,
1006,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
5219,
3593,
1007,
1025,
2709,
2995,
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 | plugins/Login/SessionInitializer.php | SessionInitializer.processSuccessfulSession | protected function processSuccessfulSession(AuthResult $authResult, $rememberMe)
{
$cookie = $this->getAuthCookie($rememberMe);
$cookie->set('login', $authResult->getIdentity());
$cookie->set('token_auth', $this->getHashTokenAuth($authResult->getIdentity(), $authResult->getTokenAuth()));
$cookie->setSecure(ProxyHttp::isHttps());
$cookie->setHttpOnly(true);
$cookie->save();
return $cookie;
} | php | protected function processSuccessfulSession(AuthResult $authResult, $rememberMe)
{
$cookie = $this->getAuthCookie($rememberMe);
$cookie->set('login', $authResult->getIdentity());
$cookie->set('token_auth', $this->getHashTokenAuth($authResult->getIdentity(), $authResult->getTokenAuth()));
$cookie->setSecure(ProxyHttp::isHttps());
$cookie->setHttpOnly(true);
$cookie->save();
return $cookie;
} | [
"protected",
"function",
"processSuccessfulSession",
"(",
"AuthResult",
"$",
"authResult",
",",
"$",
"rememberMe",
")",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"getAuthCookie",
"(",
"$",
"rememberMe",
")",
";",
"$",
"cookie",
"->",
"set",
"(",
"'login'",... | Executed when the session was successfully authenticated.
@param AuthResult $authResult The successful authentication result.
@param bool $rememberMe Whether the authenticated session should be remembered after
the browser is closed or not. | [
"Executed",
"when",
"the",
"session",
"was",
"successfully",
"authenticated",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/SessionInitializer.php#L182-L192 | train | Process successful session | [
30522,
5123,
3853,
2832,
6342,
9468,
7971,
3993,
8583,
10992,
1006,
8740,
2705,
6072,
11314,
1002,
8740,
2705,
6072,
11314,
1010,
1002,
3342,
4168,
1007,
1063,
1002,
17387,
1027,
1002,
2023,
1011,
1028,
2131,
4887,
2705,
3597,
23212,
2063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/DataCollectorTranslator.php | DataCollectorTranslator.getFallbackLocales | public function getFallbackLocales()
{
if ($this->translator instanceof Translator || method_exists($this->translator, 'getFallbackLocales')) {
return $this->translator->getFallbackLocales();
}
return [];
} | php | public function getFallbackLocales()
{
if ($this->translator instanceof Translator || method_exists($this->translator, 'getFallbackLocales')) {
return $this->translator->getFallbackLocales();
}
return [];
} | [
"public",
"function",
"getFallbackLocales",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"translator",
"instanceof",
"Translator",
"||",
"method_exists",
"(",
"$",
"this",
"->",
"translator",
",",
"'getFallbackLocales'",
")",
")",
"{",
"return",
"$",
"this",
... | Gets the fallback locales.
@return array The fallback locales | [
"Gets",
"the",
"fallback",
"locales",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/DataCollectorTranslator.php#L119-L126 | train | Get fallback locales | [
30522,
2270,
3853,
2131,
13976,
5963,
4135,
9289,
2229,
1006,
1007,
30524,
1010,
1005,
2131,
13976,
5963,
4135,
9289,
2229,
1005,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
11403,
1011,
1028,
2131,
13976,
5963,
4135,
9289,
2229,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.makeTableRow | protected function makeTableRow($key, $variable)
{
$this->zebra = $this->zebra ? 0 : 1;
$css = $this->getDataCss($variable);
$output = [];
$output[] = '<tr>';
$output[] = '<td style="'.$css.';cursor:pointer" onclick="'.$this->evalToggleDumpOnClick().'">'.$this->evalKeyLabel($key).'</td>';
$output[] = '<td style="'.$css.'">'.$this->evalVarLabel($variable).'</td>';
$output[] = '<td style="'.$css.'">'.$this->evalVarDesc($variable, $key).'</td>';
$output[] = '</tr>';
$output[] = '<tr>';
$output[] = '<td colspan="3">'.$this->evalVarDump($variable).'</td>';
$output[] = '</tr>';
return implode(PHP_EOL, $output);
} | php | protected function makeTableRow($key, $variable)
{
$this->zebra = $this->zebra ? 0 : 1;
$css = $this->getDataCss($variable);
$output = [];
$output[] = '<tr>';
$output[] = '<td style="'.$css.';cursor:pointer" onclick="'.$this->evalToggleDumpOnClick().'">'.$this->evalKeyLabel($key).'</td>';
$output[] = '<td style="'.$css.'">'.$this->evalVarLabel($variable).'</td>';
$output[] = '<td style="'.$css.'">'.$this->evalVarDesc($variable, $key).'</td>';
$output[] = '</tr>';
$output[] = '<tr>';
$output[] = '<td colspan="3">'.$this->evalVarDump($variable).'</td>';
$output[] = '</tr>';
return implode(PHP_EOL, $output);
} | [
"protected",
"function",
"makeTableRow",
"(",
"$",
"key",
",",
"$",
"variable",
")",
"{",
"$",
"this",
"->",
"zebra",
"=",
"$",
"this",
"->",
"zebra",
"?",
"0",
":",
"1",
";",
"$",
"css",
"=",
"$",
"this",
"->",
"getDataCss",
"(",
"$",
"variable",
... | Builds the HTML used for each table row.
@param mixed $key
@param mixed $variable
@return string | [
"Builds",
"the",
"HTML",
"used",
"for",
"each",
"table",
"row",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L208-L222 | train | Make table row | [
30522,
5123,
3853,
2191,
10880,
10524,
1006,
1002,
3145,
1010,
1002,
8023,
1007,
1063,
1002,
2023,
1011,
1028,
29145,
1027,
1002,
2023,
1011,
1028,
29145,
1029,
1014,
1024,
1015,
1025,
1002,
20116,
2015,
1027,
1002,
2023,
1011,
1028,
2131,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Config/Definition/ArrayNode.php | ArrayNode.mergeValues | protected function mergeValues($leftSide, $rightSide)
{
if (false === $rightSide) {
// if this is still false after the last config has been merged the
// finalization pass will take care of removing this key entirely
return false;
}
if (false === $leftSide || !$this->performDeepMerging) {
return $rightSide;
}
foreach ($rightSide as $k => $v) {
// no conflict
if (!\array_key_exists($k, $leftSide)) {
if (!$this->allowNewKeys) {
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath()));
$ex->setPath($this->getPath());
throw $ex;
}
$leftSide[$k] = $v;
continue;
}
if (!isset($this->children[$k])) {
throw new \RuntimeException('merge() expects a normalized config array.');
}
$leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v);
}
return $leftSide;
} | php | protected function mergeValues($leftSide, $rightSide)
{
if (false === $rightSide) {
// if this is still false after the last config has been merged the
// finalization pass will take care of removing this key entirely
return false;
}
if (false === $leftSide || !$this->performDeepMerging) {
return $rightSide;
}
foreach ($rightSide as $k => $v) {
// no conflict
if (!\array_key_exists($k, $leftSide)) {
if (!$this->allowNewKeys) {
$ex = new InvalidConfigurationException(sprintf('You are not allowed to define new elements for path "%s". Please define all elements for this path in one config file. If you are trying to overwrite an element, make sure you redefine it with the same name.', $this->getPath()));
$ex->setPath($this->getPath());
throw $ex;
}
$leftSide[$k] = $v;
continue;
}
if (!isset($this->children[$k])) {
throw new \RuntimeException('merge() expects a normalized config array.');
}
$leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v);
}
return $leftSide;
} | [
"protected",
"function",
"mergeValues",
"(",
"$",
"leftSide",
",",
"$",
"rightSide",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"rightSide",
")",
"{",
"// if this is still false after the last config has been merged the",
"// finalization pass will take care of removing this k... | Merges values together.
@param mixed $leftSide The left side to merge
@param mixed $rightSide The right side to merge
@return mixed The merged values
@throws InvalidConfigurationException
@throws \RuntimeException | [
"Merges",
"values",
"together",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/ArrayNode.php#L372-L406 | train | Merge values of the left side and right side config array | [
30522,
5123,
3853,
13590,
10175,
15808,
1006,
1002,
2187,
7363,
1010,
1002,
2916,
5178,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
1002,
2916,
5178,
1007,
1063,
1013,
1013,
2065,
2023,
2003,
2145,
6270,
2044,
1996,
2197,
9530,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Uri.php | Uri.buildUrl | public static function buildUrl($parsed_url)
{
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . ':' : '';
$authority = isset($parsed_url['host']) ? '//' : '';
$host = $parsed_url['host'] ?? '';
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
$user = $parsed_url['user'] ?? '';
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
$pass = ($user || $pass) ? "{$pass}@" : '';
$path = $parsed_url['path'] ?? '';
$path = !empty($parsed_url['params']) ? rtrim($path, '/') . static::buildParams($parsed_url['params']) : $path;
$query = !empty($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
return "{$scheme}{$authority}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}";
} | php | public static function buildUrl($parsed_url)
{
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . ':' : '';
$authority = isset($parsed_url['host']) ? '//' : '';
$host = $parsed_url['host'] ?? '';
$port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
$user = $parsed_url['user'] ?? '';
$pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
$pass = ($user || $pass) ? "{$pass}@" : '';
$path = $parsed_url['path'] ?? '';
$path = !empty($parsed_url['params']) ? rtrim($path, '/') . static::buildParams($parsed_url['params']) : $path;
$query = !empty($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
$fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
return "{$scheme}{$authority}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}";
} | [
"public",
"static",
"function",
"buildUrl",
"(",
"$",
"parsed_url",
")",
"{",
"$",
"scheme",
"=",
"isset",
"(",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
")",
"?",
"$",
"parsed_url",
"[",
"'scheme'",
"]",
".",
"':'",
":",
"''",
";",
"$",
"authority",
... | The opposite of built-in PHP method parse_url()
@param array $parsed_url
@return string | [
"The",
"opposite",
"of",
"built",
"-",
"in",
"PHP",
"method",
"parse_url",
"()"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L697-L712 | train | Builds the URL string | [
30522,
2270,
10763,
3853,
3857,
3126,
2140,
1006,
1002,
11968,
6924,
1035,
24471,
2140,
1007,
1063,
1002,
5679,
1027,
26354,
3388,
1006,
1002,
11968,
6924,
1035,
24471,
2140,
1031,
1005,
5679,
1005,
1033,
1007,
1029,
1002,
11968,
6924,
1035... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/RedisStore.php | RedisStore.put | public function put($key, $value, $seconds)
{
return (bool) $this->connection()->setex(
$this->prefix.$key, (int) max(1, $seconds), $this->serialize($value)
);
} | php | public function put($key, $value, $seconds)
{
return (bool) $this->connection()->setex(
$this->prefix.$key, (int) max(1, $seconds), $this->serialize($value)
);
} | [
"public",
"function",
"put",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"seconds",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"connection",
"(",
")",
"->",
"setex",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"key",
",",
"(",
"... | Store an item in the cache for a given number of seconds.
@param string $key
@param mixed $value
@param int $seconds
@return bool | [
"Store",
"an",
"item",
"in",
"the",
"cache",
"for",
"a",
"given",
"number",
"of",
"seconds",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/RedisStore.php#L90-L95 | train | Put a value into cache. | [
30522,
2270,
3853,
2404,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
1002,
3823,
1007,
1063,
2709,
1006,
22017,
2140,
1007,
1002,
2023,
1011,
1028,
4434,
1006,
1007,
1011,
1028,
2275,
10288,
1006,
1002,
2023,
1011,
1028,
17576,
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... |
symfony/symfony | src/Symfony/Component/Config/Definition/PrototypedArrayNode.php | PrototypedArrayNode.finalizeValue | protected function finalizeValue($value)
{
if (false === $value) {
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)));
}
foreach ($value as $k => $v) {
$prototype = $this->getPrototypeForChild($k);
try {
$value[$k] = $prototype->finalize($v);
} catch (UnsetKeyException $e) {
unset($value[$k]);
}
}
if (\count($value) < $this->minNumberOfElements) {
$ex = new InvalidConfigurationException(sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements));
$ex->setPath($this->getPath());
throw $ex;
}
return $value;
} | php | protected function finalizeValue($value)
{
if (false === $value) {
throw new UnsetKeyException(sprintf('Unsetting key for path "%s", value: %s', $this->getPath(), json_encode($value)));
}
foreach ($value as $k => $v) {
$prototype = $this->getPrototypeForChild($k);
try {
$value[$k] = $prototype->finalize($v);
} catch (UnsetKeyException $e) {
unset($value[$k]);
}
}
if (\count($value) < $this->minNumberOfElements) {
$ex = new InvalidConfigurationException(sprintf('The path "%s" should have at least %d element(s) defined.', $this->getPath(), $this->minNumberOfElements));
$ex->setPath($this->getPath());
throw $ex;
}
return $value;
} | [
"protected",
"function",
"finalizeValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"value",
")",
"{",
"throw",
"new",
"UnsetKeyException",
"(",
"sprintf",
"(",
"'Unsetting key for path \"%s\", value: %s'",
",",
"$",
"this",
"->",
"getPath",
... | Finalizes the value of this node.
@param mixed $value
@return mixed The finalized value
@throws UnsetKeyException
@throws InvalidConfigurationException if the node doesn't have enough children | [
"Finalizes",
"the",
"value",
"of",
"this",
"node",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php#L185-L208 | train | Finalize value by setting all child elements to their final values | [
30522,
5123,
3853,
2345,
4697,
10175,
5657,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
1002,
3643,
1007,
1063,
5466,
2047,
4895,
13462,
14839,
10288,
24422,
1006,
9043,
2546,
1006,
1005,
4895,
21678,
2075,
3145,
2005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/thrift | lib/php/lib/Transport/TCurlClient.php | TCurlClient.readAll | public function readAll($len)
{
$data = $this->read($len);
if (TStringFuncFactory::create()->strlen($data) !== $len) {
throw new TTransportException('TCurlClient could not read '.$len.' bytes');
}
return $data;
} | php | public function readAll($len)
{
$data = $this->read($len);
if (TStringFuncFactory::create()->strlen($data) !== $len) {
throw new TTransportException('TCurlClient could not read '.$len.' bytes');
}
return $data;
} | [
"public",
"function",
"readAll",
"(",
"$",
"len",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"len",
")",
";",
"if",
"(",
"TStringFuncFactory",
"::",
"create",
"(",
")",
"->",
"strlen",
"(",
"$",
"data",
")",
"!==",
"$",
"len... | Guarantees that the full amount of data is read. Since TCurlClient gets entire payload at
once, parent readAll cannot be used.
@return string The data, of exact length
@throws TTransportException if cannot read data | [
"Guarantees",
"that",
"the",
"full",
"amount",
"of",
"data",
"is",
"read",
".",
"Since",
"TCurlClient",
"gets",
"entire",
"payload",
"at",
"once",
"parent",
"readAll",
"cannot",
"be",
"used",
"."
] | acdd4226c210336e9e15eb812e5932a645fcd5ce | https://github.com/apache/thrift/blob/acdd4226c210336e9e15eb812e5932a645fcd5ce/lib/php/lib/Transport/TCurlClient.php#L179-L188 | train | read all bytes from the stream | [
30522,
2270,
3853,
3191,
8095,
1006,
1002,
18798,
1007,
1063,
1002,
2951,
1027,
1002,
2023,
1011,
1028,
3191,
1006,
1002,
18798,
1007,
1025,
2065,
1006,
24529,
18886,
3070,
11263,
12273,
21450,
1024,
1024,
3443,
1006,
1007,
1011,
1028,
2358... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Catalogue/AbstractOperation.php | AbstractOperation.getDomains | public function getDomains()
{
if (null === $this->domains) {
$this->domains = array_values(array_unique(array_merge($this->source->getDomains(), $this->target->getDomains())));
}
return $this->domains;
} | php | public function getDomains()
{
if (null === $this->domains) {
$this->domains = array_values(array_unique(array_merge($this->source->getDomains(), $this->target->getDomains())));
}
return $this->domains;
} | [
"public",
"function",
"getDomains",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"domains",
")",
"{",
"$",
"this",
"->",
"domains",
"=",
"array_values",
"(",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"source",
"->",
"ge... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Catalogue/AbstractOperation.php#L79-L86 | train | Get domains from source and target | [
30522,
2270,
3853,
2131,
9527,
28247,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
13100,
1007,
1063,
1002,
2023,
1011,
1028,
13100,
1027,
9140,
1035,
5300,
1006,
9140,
1035,
4310,
1006,
9140,
30524,
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/Schema/Blueprint.php | Blueprint.timestampsTz | public function timestampsTz($precision = 0)
{
$this->timestampTz('created_at', $precision)->nullable();
$this->timestampTz('updated_at', $precision)->nullable();
} | php | public function timestampsTz($precision = 0)
{
$this->timestampTz('created_at', $precision)->nullable();
$this->timestampTz('updated_at', $precision)->nullable();
} | [
"public",
"function",
"timestampsTz",
"(",
"$",
"precision",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"timestampTz",
"(",
"'created_at'",
",",
"$",
"precision",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"this",
"->",
"timestampTz",
"(",
"'updated_at'",
",... | Add creation and update timestampTz columns to the table.
@param int $precision
@return void | [
"Add",
"creation",
"and",
"update",
"timestampTz",
"columns",
"to",
"the",
"table",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Blueprint.php#L1008-L1013 | train | Create the created and updated timestamps TZ | [
30522,
2270,
3853,
2335,
15464,
4523,
5753,
1006,
1002,
11718,
1027,
1014,
1007,
1063,
1002,
2023,
1011,
1028,
2335,
15464,
13876,
2480,
1006,
1005,
2580,
1035,
2012,
1005,
1010,
1002,
11718,
1007,
1011,
1028,
19701,
3085,
1006,
1007,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php | TimezoneType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
if ('datetimezone' === $options['input']) {
$builder->addModelTransformer(new DateTimeZoneToStringTransformer($options['multiple']));
} elseif ('intltimezone' === $options['input']) {
$builder->addModelTransformer(new IntlTimeZoneToStringTransformer($options['multiple']));
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
if ('datetimezone' === $options['input']) {
$builder->addModelTransformer(new DateTimeZoneToStringTransformer($options['multiple']));
} elseif ('intltimezone' === $options['input']) {
$builder->addModelTransformer(new IntlTimeZoneToStringTransformer($options['multiple']));
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"'datetimezone'",
"===",
"$",
"options",
"[",
"'input'",
"]",
")",
"{",
"$",
"builder",
"->",
"addModelTransformer",
"(",
"new"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php#L28-L35 | train | Adds the model transformers to the form builder. | [
30522,
2270,
3853,
3857,
14192,
1006,
2433,
8569,
23891,
6657,
3334,
12172,
1002,
12508,
1010,
9140,
1002,
7047,
1007,
1063,
2065,
1006,
1005,
3058,
7292,
15975,
1005,
1027,
1027,
1027,
1002,
7047,
1031,
1005,
7953,
1005,
1033,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/User/DataUser/User.php | User.save | public function save()
{
/** @var CompiledYamlFile $file */
$file = $this->file();
if (!$file || !$file->filename()) {
user_error(__CLASS__ . ': calling \$user = new ' . __CLASS__ . "() is deprecated since Grav 1.6, use \$grav['accounts']->load(\$username) or \$grav['accounts']->load('') instead", E_USER_DEPRECATED);
}
if ($file) {
$username = $this->get('username');
if (!$file->filename()) {
$locator = Grav::instance()['locator'];
$file->filename($locator->findResource('account://' . mb_strtolower($username) . YAML_EXT, true, true));
}
// if plain text password, hash it and remove plain text
$password = $this->get('password');
if ($password) {
$this->set('hashed_password', Authentication::create($password));
$this->undef('password');
}
$data = $this->items;
unset($data['username'], $data['authenticated'], $data['authorized']);
$file->save($data);
}
} | php | public function save()
{
/** @var CompiledYamlFile $file */
$file = $this->file();
if (!$file || !$file->filename()) {
user_error(__CLASS__ . ': calling \$user = new ' . __CLASS__ . "() is deprecated since Grav 1.6, use \$grav['accounts']->load(\$username) or \$grav['accounts']->load('') instead", E_USER_DEPRECATED);
}
if ($file) {
$username = $this->get('username');
if (!$file->filename()) {
$locator = Grav::instance()['locator'];
$file->filename($locator->findResource('account://' . mb_strtolower($username) . YAML_EXT, true, true));
}
// if plain text password, hash it and remove plain text
$password = $this->get('password');
if ($password) {
$this->set('hashed_password', Authentication::create($password));
$this->undef('password');
}
$data = $this->items;
unset($data['username'], $data['authenticated'], $data['authorized']);
$file->save($data);
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"/** @var CompiledYamlFile $file */",
"$",
"file",
"=",
"$",
"this",
"->",
"file",
"(",
")",
";",
"if",
"(",
"!",
"$",
"file",
"||",
"!",
"$",
"file",
"->",
"filename",
"(",
")",
")",
"{",
"user_error",
"(... | Save user without the username | [
"Save",
"user",
"without",
"the",
"username"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/DataUser/User.php#L104-L132 | train | Save the user into the YAML file | [
30522,
2270,
3853,
3828,
1006,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
9227,
14852,
10270,
9463,
1002,
5371,
1008,
1013,
1002,
5371,
1027,
1002,
2023,
1011,
1028,
5371,
1006,
1007,
1025,
2065,
1006,
999,
1002,
5371,
1064,
1064,
999,
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/HttpClient/Response/CurlResponse.php | CurlResponse.perform | private static function perform(CurlClientState $multi, array &$responses = null): void
{
if (self::$performing) {
return;
}
try {
self::$performing = true;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($multi->handle, $active));
while ($info = curl_multi_info_read($multi->handle)) {
$multi->handlesActivity[(int) $info['handle']][] = null;
$multi->handlesActivity[(int) $info['handle']][] = \in_array($info['result'], [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || (\CURLE_WRITE_ERROR === $info['result'] && 'destruct' === @curl_getinfo($info['handle'], CURLINFO_PRIVATE)) ? null : new TransportException(curl_error($info['handle']));
}
} finally {
self::$performing = false;
}
} | php | private static function perform(CurlClientState $multi, array &$responses = null): void
{
if (self::$performing) {
return;
}
try {
self::$performing = true;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($multi->handle, $active));
while ($info = curl_multi_info_read($multi->handle)) {
$multi->handlesActivity[(int) $info['handle']][] = null;
$multi->handlesActivity[(int) $info['handle']][] = \in_array($info['result'], [\CURLE_OK, \CURLE_TOO_MANY_REDIRECTS], true) || (\CURLE_WRITE_ERROR === $info['result'] && 'destruct' === @curl_getinfo($info['handle'], CURLINFO_PRIVATE)) ? null : new TransportException(curl_error($info['handle']));
}
} finally {
self::$performing = false;
}
} | [
"private",
"static",
"function",
"perform",
"(",
"CurlClientState",
"$",
"multi",
",",
"array",
"&",
"$",
"responses",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"self",
"::",
"$",
"performing",
")",
"{",
"return",
";",
"}",
"try",
"{",
"self",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/Response/CurlResponse.php#L236-L253 | train | Perform the curl_multi_exec | [
30522,
2797,
10763,
3853,
4685,
1006,
15390,
20464,
11638,
9153,
2618,
1002,
4800,
1010,
9140,
1004,
1002,
10960,
1027,
19701,
1007,
1024,
11675,
1063,
2065,
1006,
2969,
1024,
1024,
1002,
4488,
1007,
1063,
2709,
1025,
1065,
3046,
1063,
2969... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.endsWith | public static function endsWith($haystack, $needle, $case_sensitive = true)
{
$status = false;
$compare_func = $case_sensitive ? 'mb_strrpos' : 'mb_strripos';
foreach ((array)$needle as $each_needle) {
$expectedPosition = mb_strlen($haystack) - mb_strlen($each_needle);
$status = $each_needle === '' || $compare_func($haystack, $each_needle, 0) === $expectedPosition;
if ($status) {
break;
}
}
return $status;
} | php | public static function endsWith($haystack, $needle, $case_sensitive = true)
{
$status = false;
$compare_func = $case_sensitive ? 'mb_strrpos' : 'mb_strripos';
foreach ((array)$needle as $each_needle) {
$expectedPosition = mb_strlen($haystack) - mb_strlen($each_needle);
$status = $each_needle === '' || $compare_func($haystack, $each_needle, 0) === $expectedPosition;
if ($status) {
break;
}
}
return $status;
} | [
"public",
"static",
"function",
"endsWith",
"(",
"$",
"haystack",
",",
"$",
"needle",
",",
"$",
"case_sensitive",
"=",
"true",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"compare_func",
"=",
"$",
"case_sensitive",
"?",
"'mb_strrpos'",
":",
"'mb_strri... | Check if the $haystack string ends with the substring $needle
@param string $haystack
@param string|string[] $needle
@param bool $case_sensitive
@return bool | [
"Check",
"if",
"the",
"$haystack",
"string",
"ends",
"with",
"the",
"substring",
"$needle"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L117-L132 | train | Check if string ends with needle | [
30522,
2270,
10763,
3853,
4515,
24415,
1006,
1002,
29051,
2696,
3600,
1010,
1002,
12201,
1010,
1002,
2553,
1035,
7591,
1027,
2995,
1007,
1063,
1002,
3570,
1027,
6270,
1025,
1002,
12826,
1035,
4569,
2278,
1027,
1002,
2553,
1035,
7591,
1029,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Output/ConsoleSectionOutput.php | ConsoleSectionOutput.popStreamContentUntilCurrentSection | private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0): string
{
$numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection;
$erasedContent = [];
foreach ($this->sections as $section) {
if ($section === $this) {
break;
}
$numberOfLinesToClear += $section->lines;
$erasedContent[] = $section->getContent();
}
if ($numberOfLinesToClear > 0) {
// move cursor up n lines
parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
// erase to end of screen
parent::doWrite("\x1b[0J", false);
}
return implode('', array_reverse($erasedContent));
} | php | private function popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection = 0): string
{
$numberOfLinesToClear = $numberOfLinesToClearFromCurrentSection;
$erasedContent = [];
foreach ($this->sections as $section) {
if ($section === $this) {
break;
}
$numberOfLinesToClear += $section->lines;
$erasedContent[] = $section->getContent();
}
if ($numberOfLinesToClear > 0) {
// move cursor up n lines
parent::doWrite(sprintf("\x1b[%dA", $numberOfLinesToClear), false);
// erase to end of screen
parent::doWrite("\x1b[0J", false);
}
return implode('', array_reverse($erasedContent));
} | [
"private",
"function",
"popStreamContentUntilCurrentSection",
"(",
"int",
"$",
"numberOfLinesToClearFromCurrentSection",
"=",
"0",
")",
":",
"string",
"{",
"$",
"numberOfLinesToClear",
"=",
"$",
"numberOfLinesToClearFromCurrentSection",
";",
"$",
"erasedContent",
"=",
"["... | At initial stage, cursor is at the end of stream output. This method makes cursor crawl upwards until it hits
current section. Then it erases content it crawled through. Optionally, it erases part of current section too. | [
"At",
"initial",
"stage",
"cursor",
"is",
"at",
"the",
"end",
"of",
"stream",
"output",
".",
"This",
"method",
"makes",
"cursor",
"crawl",
"upwards",
"until",
"it",
"hits",
"current",
"section",
".",
"Then",
"it",
"erases",
"content",
"it",
"crawled",
"thr... | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Output/ConsoleSectionOutput.php#L113-L135 | train | Pop stream content until current section | [
30522,
2797,
3853,
16949,
25379,
8663,
6528,
8525,
16778,
15472,
29264,
29015,
1006,
20014,
1002,
2193,
11253,
12735,
3406,
14321,
2906,
19699,
5358,
10841,
14343,
7666,
18491,
1027,
1014,
1007,
1024,
5164,
1063,
1002,
2193,
11253,
12735,
340... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
guzzle/guzzle | src/Exception/RequestException.php | RequestException.create | public static function create(
RequestInterface $request,
ResponseInterface $response = null,
\Exception $previous = null,
array $ctx = []
) {
if (!$response) {
return new self(
'Error completing request',
$request,
null,
$previous,
$ctx
);
}
$level = (int) floor($response->getStatusCode() / 100);
if ($level === 4) {
$label = 'Client error';
$className = ClientException::class;
} elseif ($level === 5) {
$label = 'Server error';
$className = ServerException::class;
} else {
$label = 'Unsuccessful request';
$className = __CLASS__;
}
$uri = $request->getUri();
$uri = static::obfuscateUri($uri);
// Client Error: `GET /` resulted in a `404 Not Found` response:
// <html> ... (truncated)
$message = sprintf(
'%s: `%s %s` resulted in a `%s %s` response',
$label,
$request->getMethod(),
$uri,
$response->getStatusCode(),
$response->getReasonPhrase()
);
$summary = static::getResponseBodySummary($response);
if ($summary !== null) {
$message .= ":\n{$summary}\n";
}
return new $className($message, $request, $response, $previous, $ctx);
} | php | public static function create(
RequestInterface $request,
ResponseInterface $response = null,
\Exception $previous = null,
array $ctx = []
) {
if (!$response) {
return new self(
'Error completing request',
$request,
null,
$previous,
$ctx
);
}
$level = (int) floor($response->getStatusCode() / 100);
if ($level === 4) {
$label = 'Client error';
$className = ClientException::class;
} elseif ($level === 5) {
$label = 'Server error';
$className = ServerException::class;
} else {
$label = 'Unsuccessful request';
$className = __CLASS__;
}
$uri = $request->getUri();
$uri = static::obfuscateUri($uri);
// Client Error: `GET /` resulted in a `404 Not Found` response:
// <html> ... (truncated)
$message = sprintf(
'%s: `%s %s` resulted in a `%s %s` response',
$label,
$request->getMethod(),
$uri,
$response->getStatusCode(),
$response->getReasonPhrase()
);
$summary = static::getResponseBodySummary($response);
if ($summary !== null) {
$message .= ":\n{$summary}\n";
}
return new $className($message, $request, $response, $previous, $ctx);
} | [
"public",
"static",
"function",
"create",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
"=",
"null",
",",
"\\",
"Exception",
"$",
"previous",
"=",
"null",
",",
"array",
"$",
"ctx",
"=",
"[",
"]",
")",
"{",
"if",
"(",... | Factory method to create a new exception with a normalized error message
@param RequestInterface $request Request
@param ResponseInterface $response Response received
@param \Exception $previous Previous exception
@param array $ctx Optional handler context.
@return self | [
"Factory",
"method",
"to",
"create",
"a",
"new",
"exception",
"with",
"a",
"normalized",
"error",
"message"
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Exception/RequestException.php#L65-L114 | train | Create a new exception based on the response of the HTTP request | [
30522,
2270,
10763,
3853,
3443,
1006,
5227,
18447,
2121,
12172,
1002,
5227,
1010,
3433,
18447,
2121,
12172,
1002,
3433,
1027,
19701,
1010,
1032,
6453,
1002,
3025,
1027,
19701,
1010,
9140,
1002,
14931,
2595,
1027,
1031,
1033,
1007,
1063,
206... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/Repository.php | Repository.getMultiple | public function getMultiple($keys, $default = null)
{
if (is_null($default)) {
return $this->many($keys);
}
foreach ($keys as $key) {
if (! isset($default[$key])) {
$default[$key] = null;
}
}
return $this->many($default);
} | php | public function getMultiple($keys, $default = null)
{
if (is_null($default)) {
return $this->many($keys);
}
foreach ($keys as $key) {
if (! isset($default[$key])) {
$default[$key] = null;
}
}
return $this->many($default);
} | [
"public",
"function",
"getMultiple",
"(",
"$",
"keys",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"default",
")",
")",
"{",
"return",
"$",
"this",
"->",
"many",
"(",
"$",
"keys",
")",
";",
"}",
"foreach",
"(",
"$"... | {@inheritdoc} | [
"{"
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/Repository.php#L135-L148 | train | Get many items | [
30522,
2270,
3853,
2131,
12274,
7096,
11514,
2571,
1006,
1002,
6309,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
12398,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2116,
1006,
1002,
6309,
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/helpers/Backend.php | Backend.skinAsset | public function skinAsset($path = null)
{
$skinPath = Skin::getActive()->getPath($path, true);
return Url::asset($skinPath);
} | php | public function skinAsset($path = null)
{
$skinPath = Skin::getActive()->getPath($path, true);
return Url::asset($skinPath);
} | [
"public",
"function",
"skinAsset",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"skinPath",
"=",
"Skin",
"::",
"getActive",
"(",
")",
"->",
"getPath",
"(",
"$",
"path",
",",
"true",
")",
";",
"return",
"Url",
"::",
"asset",
"(",
"$",
"skinPath",
"... | Returns a URL in context of the active Backend skin | [
"Returns",
"a",
"URL",
"in",
"context",
"of",
"the",
"active",
"Backend",
"skin"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/helpers/Backend.php#L56-L60 | train | Get Skin Asset | [
30522,
2270,
3853,
3096,
27241,
2102,
1006,
1002,
4130,
1027,
19701,
1007,
1063,
1002,
3096,
15069,
1027,
3096,
1024,
1024,
2131,
19620,
1006,
1007,
1011,
1028,
2131,
15069,
1006,
1002,
4130,
1010,
2995,
1007,
1025,
2709,
24471,
2140,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php | AbstractToken.__serialize | public function __serialize(): array
{
return [$this->user, $this->authenticated, $this->roles, $this->attributes, $this->roleNames];
} | php | public function __serialize(): array
{
return [$this->user, $this->authenticated, $this->roles, $this->attributes, $this->roleNames];
} | [
"public",
"function",
"__serialize",
"(",
")",
":",
"array",
"{",
"return",
"[",
"$",
"this",
"->",
"user",
",",
"$",
"this",
"->",
"authenticated",
",",
"$",
"this",
"->",
"roles",
",",
"$",
"this",
"->",
"attributes",
",",
"$",
"this",
"->",
"roleN... | Returns all the necessary state of the object for serialization purposes.
There is no need to serialize any entry, they should be returned as-is.
If you extend this method, keep in mind you MUST guarantee parent data is present in the state.
Here is an example of how to extend this method:
<code>
public function __serialize(): array
{
return [$this->childAttribute, parent::__serialize()];
}
</code>
@see __unserialize() | [
"Returns",
"all",
"the",
"necessary",
"state",
"of",
"the",
"object",
"for",
"serialization",
"purposes",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php#L160-L163 | train | Serialize the object into an array | [
30522,
2270,
3853,
1035,
1035,
7642,
4697,
1006,
1007,
1024,
9140,
1063,
2709,
1031,
1002,
2023,
1011,
1028,
5310,
1010,
1002,
2023,
1011,
1028,
14469,
4383,
1010,
1002,
2023,
1011,
1028,
4395,
1010,
1002,
2023,
1011,
1028,
12332,
1010,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Jobs/RedisJob.php | RedisJob.release | public function release($delay = 0)
{
parent::release($delay);
$this->redis->deleteAndRelease($this->queue, $this, $delay);
} | php | public function release($delay = 0)
{
parent::release($delay);
$this->redis->deleteAndRelease($this->queue, $this, $delay);
} | [
"public",
"function",
"release",
"(",
"$",
"delay",
"=",
"0",
")",
"{",
"parent",
"::",
"release",
"(",
"$",
"delay",
")",
";",
"$",
"this",
"->",
"redis",
"->",
"deleteAndRelease",
"(",
"$",
"this",
"->",
"queue",
",",
"$",
"this",
",",
"$",
"dela... | Release the job back into the queue.
@param int $delay
@return void | [
"Release",
"the",
"job",
"back",
"into",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Jobs/RedisJob.php#L93-L98 | train | Release the current cache | [
30522,
2270,
3853,
2713,
1006,
1002,
8536,
1027,
1014,
1007,
1063,
6687,
1024,
1024,
2713,
1006,
1002,
8536,
1007,
1025,
1002,
2023,
1011,
1028,
2417,
2483,
1011,
1028,
3972,
12870,
5685,
16570,
19500,
1006,
1002,
2023,
1011,
1028,
24240,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HttpClient/Chunk/ErrorChunk.php | ErrorChunk.getContent | public function getContent(): string
{
$this->didThrow = true;
throw new TransportException($this->errorMessage, 0, $this->error);
} | php | public function getContent(): string
{
$this->didThrow = true;
throw new TransportException($this->errorMessage, 0, $this->error);
} | [
"public",
"function",
"getContent",
"(",
")",
":",
"string",
"{",
"$",
"this",
"->",
"didThrow",
"=",
"true",
";",
"throw",
"new",
"TransportException",
"(",
"$",
"this",
"->",
"errorMessage",
",",
"0",
",",
"$",
"this",
"->",
"error",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php#L71-L75 | train | Get content of the page | [
30522,
2270,
3853,
2131,
8663,
6528,
2102,
1006,
1007,
1024,
5164,
1063,
1002,
2023,
1011,
1028,
2106,
2705,
10524,
1027,
2995,
1025,
5466,
2047,
3665,
10288,
24422,
1006,
1002,
2023,
1011,
1028,
7561,
7834,
3736,
3351,
1010,
1014,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Archive.php | Archive.getRequestedPlugins | private function getRequestedPlugins($archiveNames)
{
$result = array();
foreach ($archiveNames as $name) {
$result[] = self::getPluginForReport($name);
}
return array_unique($result);
} | php | private function getRequestedPlugins($archiveNames)
{
$result = array();
foreach ($archiveNames as $name) {
$result[] = self::getPluginForReport($name);
}
return array_unique($result);
} | [
"private",
"function",
"getRequestedPlugins",
"(",
"$",
"archiveNames",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"archiveNames",
"as",
"$",
"name",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"self",
"::",
"getPluginForRepor... | Returns the list of plugins that archive the given reports.
@param array $archiveNames
@return array | [
"Returns",
"the",
"list",
"of",
"plugins",
"that",
"archive",
"the",
"given",
"reports",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive.php#L386-L395 | train | Returns the list of plugins that were requested. | [
30522,
2797,
3853,
2131,
2890,
15500,
2098,
24759,
15916,
7076,
1006,
1002,
8756,
18442,
2015,
1007,
1063,
30524,
8756,
18442,
2015,
2004,
1002,
2171,
1007,
1063,
1002,
2765,
1031,
1033,
1027,
2969,
1024,
1024,
2131,
24759,
15916,
2378,
292... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Stopwatch/Section.php | Section.stopEvent | public function stopEvent($name)
{
if (!isset($this->events[$name])) {
throw new \LogicException(sprintf('Event "%s" is not started.', $name));
}
return $this->events[$name]->stop();
} | php | public function stopEvent($name)
{
if (!isset($this->events[$name])) {
throw new \LogicException(sprintf('Event "%s" is not started.', $name));
}
return $this->events[$name]->stop();
} | [
"public",
"function",
"stopEvent",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Event \"%s\" is not started.'",... | Stops an event.
@param string $name The event name
@return StopwatchEvent The event
@throws \LogicException When the event has not been started | [
"Stops",
"an",
"event",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Stopwatch/Section.php#L148-L155 | train | Stops an event | [
30522,
2270,
3853,
2644,
18697,
3372,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2824,
1031,
1002,
2171,
1033,
1007,
1007,
1063,
5466,
2047,
1032,
7961,
10288,
24422,
1006,
9043,
2546,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/formwidgets/FileUpload.php | FileUpload.onSaveAttachmentConfig | public function onSaveAttachmentConfig()
{
try {
$fileModel = $this->getRelationModel();
if (($fileId = post('file_id')) && ($file = $fileModel::find($fileId))) {
$file->title = post('title');
$file->description = post('description');
$file->save();
return ['displayName' => $file->title ?: $file->file_name];
}
throw new ApplicationException('Unable to find file, it may no longer exist');
}
catch (Exception $ex) {
return json_encode(['error' => $ex->getMessage()]);
}
} | php | public function onSaveAttachmentConfig()
{
try {
$fileModel = $this->getRelationModel();
if (($fileId = post('file_id')) && ($file = $fileModel::find($fileId))) {
$file->title = post('title');
$file->description = post('description');
$file->save();
return ['displayName' => $file->title ?: $file->file_name];
}
throw new ApplicationException('Unable to find file, it may no longer exist');
}
catch (Exception $ex) {
return json_encode(['error' => $ex->getMessage()]);
}
} | [
"public",
"function",
"onSaveAttachmentConfig",
"(",
")",
"{",
"try",
"{",
"$",
"fileModel",
"=",
"$",
"this",
"->",
"getRelationModel",
"(",
")",
";",
"if",
"(",
"(",
"$",
"fileId",
"=",
"post",
"(",
"'file_id'",
")",
")",
"&&",
"(",
"$",
"file",
"=... | Commit the changes of the attachment configuration form. | [
"Commit",
"the",
"changes",
"of",
"the",
"attachment",
"configuration",
"form",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/FileUpload.php#L323-L340 | train | Save attachment config | [
30522,
2270,
3853,
2006,
3736,
3726,
19321,
6776,
3672,
8663,
8873,
2290,
1006,
1007,
1063,
3046,
1063,
1002,
5371,
5302,
9247,
1027,
1002,
2023,
1011,
1028,
2131,
16570,
3370,
5302,
9247,
1006,
1007,
1025,
2065,
1006,
1006,
1002,
5371,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/PrivacyManager/LogDataPurger.php | LogDataPurger.getDeleteTableLogTables | public static function getDeleteTableLogTables()
{
$provider = StaticContainer::get('Piwik\Plugin\LogTablesProvider');
$result = array();
foreach ($provider->getAllLogTables() as $logTable) {
if ($logTable->getColumnToJoinOnIdVisit()) {
$result[] = Common::prefixTable($logTable->getName());
}
}
if (Db::isLockPrivilegeGranted()) {
$result[] = Common::prefixTable('log_action');
}
return $result;
} | php | public static function getDeleteTableLogTables()
{
$provider = StaticContainer::get('Piwik\Plugin\LogTablesProvider');
$result = array();
foreach ($provider->getAllLogTables() as $logTable) {
if ($logTable->getColumnToJoinOnIdVisit()) {
$result[] = Common::prefixTable($logTable->getName());
}
}
if (Db::isLockPrivilegeGranted()) {
$result[] = Common::prefixTable('log_action');
}
return $result;
} | [
"public",
"static",
"function",
"getDeleteTableLogTables",
"(",
")",
"{",
"$",
"provider",
"=",
"StaticContainer",
"::",
"get",
"(",
"'Piwik\\Plugin\\LogTablesProvider'",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"provider",
"-... | let's hardcode, since these are not dynamically created tables | [
"let",
"s",
"hardcode",
"since",
"these",
"are",
"not",
"dynamically",
"created",
"tables"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/LogDataPurger.php#L172-L189 | train | Returns an array of tables that should be deleted. | [
30522,
2270,
10763,
3853,
2131,
9247,
12870,
10880,
21197,
10880,
2015,
1006,
1007,
1063,
1002,
10802,
1027,
10763,
8663,
18249,
2121,
1024,
1024,
2131,
1006,
1005,
14255,
9148,
2243,
1032,
13354,
2378,
1032,
8833,
10880,
13102,
12298,
18688,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php | TwigTokenParserStyle.parse | public function parse(Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
list ($file, $group, $priority, $attributes) = $this->parseArguments($token);
$content = null;
if (!$file) {
$content = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(Token::BLOCK_END_TYPE);
}
return new TwigNodeStyle($content, $file, $group, $priority, $attributes, $lineno, $this->getTag());
} | php | public function parse(Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
list ($file, $group, $priority, $attributes) = $this->parseArguments($token);
$content = null;
if (!$file) {
$content = $this->parser->subparse([$this, 'decideBlockEnd'], true);
$stream->expect(Token::BLOCK_END_TYPE);
}
return new TwigNodeStyle($content, $file, $group, $priority, $attributes, $lineno, $this->getTag());
} | [
"public",
"function",
"parse",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"lineno",
"=",
"$",
"token",
"->",
"getLine",
"(",
")",
";",
"$",
"stream",
"=",
"$",
"this",
"->",
"parser",
"->",
"getStream",
"(",
")",
";",
"list",
"(",
"$",
"file",
",... | Parses a token and returns a node.
@param Token $token A Twig_Token instance
@return Node A Twig_Node instance | [
"Parses",
"a",
"token",
"and",
"returns",
"a",
"node",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TokenParser/TwigTokenParserStyle.php#L35-L49 | train | Parse a Twig token and return a TwigNodeStyle object | [
30522,
2270,
3853,
11968,
3366,
1006,
19204,
1002,
19204,
1007,
1063,
1002,
17517,
2080,
1027,
1002,
19204,
1011,
1028,
2131,
4179,
1006,
1007,
1025,
1002,
5460,
1027,
1002,
2023,
1011,
1028,
11968,
8043,
1011,
1028,
4152,
25379,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.whereIn | public function whereIn($column, $values, $boolean = 'and', $not = false)
{
$type = $not ? 'NotIn' : 'In';
// If the value is a query builder instance we will assume the developer wants to
// look for any values that exists within this given query. So we will add the
// query accordingly so that this query is properly executed when it is run.
if ($values instanceof self ||
$values instanceof EloquentBuilder ||
$values instanceof Closure) {
[$query, $bindings] = $this->createSub($values);
$values = [new Expression($query)];
$this->addBinding($bindings, 'where');
}
// Next, if the value is Arrayable we need to cast it to its raw array form so we
// have the underlying array value instead of an Arrayable object which is not
// able to be added as a binding, etc. We will then add to the wheres array.
if ($values instanceof Arrayable) {
$values = $values->toArray();
}
$this->wheres[] = compact('type', 'column', 'values', 'boolean');
// Finally we'll add a binding for each values unless that value is an expression
// in which case we will just skip over it since it will be the query as a raw
// string and not as a parameterized place-holder to be replaced by the PDO.
$this->addBinding($this->cleanBindings($values), 'where');
return $this;
} | php | public function whereIn($column, $values, $boolean = 'and', $not = false)
{
$type = $not ? 'NotIn' : 'In';
// If the value is a query builder instance we will assume the developer wants to
// look for any values that exists within this given query. So we will add the
// query accordingly so that this query is properly executed when it is run.
if ($values instanceof self ||
$values instanceof EloquentBuilder ||
$values instanceof Closure) {
[$query, $bindings] = $this->createSub($values);
$values = [new Expression($query)];
$this->addBinding($bindings, 'where');
}
// Next, if the value is Arrayable we need to cast it to its raw array form so we
// have the underlying array value instead of an Arrayable object which is not
// able to be added as a binding, etc. We will then add to the wheres array.
if ($values instanceof Arrayable) {
$values = $values->toArray();
}
$this->wheres[] = compact('type', 'column', 'values', 'boolean');
// Finally we'll add a binding for each values unless that value is an expression
// in which case we will just skip over it since it will be the query as a raw
// string and not as a parameterized place-holder to be replaced by the PDO.
$this->addBinding($this->cleanBindings($values), 'where');
return $this;
} | [
"public",
"function",
"whereIn",
"(",
"$",
"column",
",",
"$",
"values",
",",
"$",
"boolean",
"=",
"'and'",
",",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"type",
"=",
"$",
"not",
"?",
"'NotIn'",
":",
"'In'",
";",
"// If the value is a query builder insta... | Add a "where in" clause to the query.
@param string $column
@param mixed $values
@param string $boolean
@param bool $not
@return $this | [
"Add",
"a",
"where",
"in",
"clause",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L841-L873 | train | Add a where in clause to the current query | [
30522,
2270,
3853,
16726,
1006,
1002,
5930,
1010,
1002,
5300,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1010,
1002,
2025,
1027,
6270,
1007,
1063,
1002,
2828,
1027,
1002,
2025,
1029,
1005,
2025,
2378,
1005,
1024,
1005,
1999,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/ComponentPartial.php | ComponentPartial.find | public function find($fileName)
{
$fileName = $this->validateFileName($fileName);
$filePath = $this->getFilePath($fileName);
if (!File::isFile($filePath)) {
return null;
}
if (($content = @File::get($filePath)) === false) {
return null;
}
$this->fileName = $fileName;
$this->mtime = File::lastModified($filePath);
$this->content = $content;
return $this;
} | php | public function find($fileName)
{
$fileName = $this->validateFileName($fileName);
$filePath = $this->getFilePath($fileName);
if (!File::isFile($filePath)) {
return null;
}
if (($content = @File::get($filePath)) === false) {
return null;
}
$this->fileName = $fileName;
$this->mtime = File::lastModified($filePath);
$this->content = $content;
return $this;
} | [
"public",
"function",
"find",
"(",
"$",
"fileName",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"validateFileName",
"(",
"$",
"fileName",
")",
";",
"$",
"filePath",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"fileName",
")",
";",
"if",
"... | Find a single template by its file name.
@param string $fileName
@return mixed|static | [
"Find",
"a",
"single",
"template",
"by",
"its",
"file",
"name",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/ComponentPartial.php#L119-L137 | train | Find a file in the current directory | [
30522,
2270,
3853,
2424,
1006,
1002,
5371,
18442,
1007,
1063,
1002,
5371,
18442,
1027,
1002,
2023,
1011,
1028,
9398,
3686,
8873,
20844,
4168,
1006,
1002,
5371,
18442,
1007,
1025,
1002,
5371,
15069,
1027,
1002,
2023,
1011,
1028,
2131,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php | SqlServerGrammar.wrapTable | public function wrapTable($table)
{
if ($table instanceof Blueprint && $table->temporary) {
$this->setTablePrefix('#');
}
return parent::wrapTable($table);
} | php | public function wrapTable($table)
{
if ($table instanceof Blueprint && $table->temporary) {
$this->setTablePrefix('#');
}
return parent::wrapTable($table);
} | [
"public",
"function",
"wrapTable",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"instanceof",
"Blueprint",
"&&",
"$",
"table",
"->",
"temporary",
")",
"{",
"$",
"this",
"->",
"setTablePrefix",
"(",
"'#'",
")",
";",
"}",
"return",
"parent",
"::... | Wrap a table in keyword identifiers.
@param \Illuminate\Database\Query\Expression|string $table
@return string | [
"Wrap",
"a",
"table",
"in",
"keyword",
"identifiers",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php#L819-L826 | train | Wrap table in a temporary table | [
30522,
2270,
3853,
10236,
10880,
1006,
1002,
2795,
1007,
1063,
2065,
1006,
1002,
2795,
6013,
11253,
2630,
16550,
1004,
1004,
1002,
2795,
1011,
1028,
5741,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
10880,
28139,
8873,
2595,
1006,
1005,
1001,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormField.php | FormField.options | public function options($value = null)
{
if ($value === null) {
if (is_array($this->options)) {
return $this->options;
}
elseif (is_callable($this->options)) {
$callable = $this->options;
return $callable();
}
return [];
}
$this->options = $value;
return $this;
} | php | public function options($value = null)
{
if ($value === null) {
if (is_array($this->options)) {
return $this->options;
}
elseif (is_callable($this->options)) {
$callable = $this->options;
return $callable();
}
return [];
}
$this->options = $value;
return $this;
} | [
"public",
"function",
"options",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"options",
")",
")",
"{",
"return",
"$",
"this",
"->",
"options",
";",
"}"... | Sets field options, for dropdowns, radio lists and checkbox lists.
@param array $value
@return self | [
"Sets",
"field",
"options",
"for",
"dropdowns",
"radio",
"lists",
"and",
"checkbox",
"lists",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L224-L241 | train | Set or get the options | [
30522,
2270,
3853,
7047,
1006,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
3643,
1027,
1027,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2023,
1011,
1028,
7047,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Node.php | HTML_QuickForm2_Node.validate | protected function validate()
{
foreach ($this->rules as $rule) {
if (strlen($this->error)) {
break;
}
if ($rule[1] & HTML_QuickForm2_Rule::RUNAT_SERVER) {
$rule[0]->validate();
}
}
return !strlen($this->error);
} | php | protected function validate()
{
foreach ($this->rules as $rule) {
if (strlen($this->error)) {
break;
}
if ($rule[1] & HTML_QuickForm2_Rule::RUNAT_SERVER) {
$rule[0]->validate();
}
}
return !strlen($this->error);
} | [
"protected",
"function",
"validate",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"error",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"$",
"rule",
"[",
"1... | Performs the server-side validation
@return boolean Whether the element is valid | [
"Performs",
"the",
"server",
"-",
"side",
"validation"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Node.php#L585-L596 | train | Validate the form | [
30522,
5123,
3853,
9398,
3686,
1006,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
3513,
2004,
1002,
3627,
1007,
1063,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
2023,
1011,
30524,
1063,
3338,
1025,
1065,
2065,
1006,
1002,
3627,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/CustomVariables/Archiver.php | Archiver.removeVisitsMetricsFromActionsAggregate | protected function removeVisitsMetricsFromActionsAggregate()
{
$dataArray = & $this->dataArray->getDataArray();
foreach ($dataArray as $key => &$row) {
if (!self::isReservedKey($key)
&& DataArray::isRowActions($row)
) {
unset($row[Metrics::INDEX_NB_UNIQ_VISITORS]);
unset($row[Metrics::INDEX_NB_VISITS]);
unset($row[Metrics::INDEX_NB_USERS]);
}
}
} | php | protected function removeVisitsMetricsFromActionsAggregate()
{
$dataArray = & $this->dataArray->getDataArray();
foreach ($dataArray as $key => &$row) {
if (!self::isReservedKey($key)
&& DataArray::isRowActions($row)
) {
unset($row[Metrics::INDEX_NB_UNIQ_VISITORS]);
unset($row[Metrics::INDEX_NB_VISITS]);
unset($row[Metrics::INDEX_NB_USERS]);
}
}
} | [
"protected",
"function",
"removeVisitsMetricsFromActionsAggregate",
"(",
")",
"{",
"$",
"dataArray",
"=",
"&",
"$",
"this",
"->",
"dataArray",
"->",
"getDataArray",
"(",
")",
";",
"foreach",
"(",
"$",
"dataArray",
"as",
"$",
"key",
"=>",
"&",
"$",
"row",
"... | Delete Visit, Unique Visitor and Users metric from 'page' scope custom variables.
- Custom variables of 'visit' scope: it is expected that these ones have the "visit" column set.
- Custom variables of 'page' scope: we cannot process "Visits" count for these.
Why?
"Actions" column is processed with a SELECT count(*).
A same visit can set the same custom variable of 'page' scope multiple times.
We cannot sum the values of count(*) as it would be incorrect.
The way we could process "Visits" Metric for 'page' scope variable is to issue a count(Distinct *) or so,
but it is no implemented yet (this would likely be very slow for high traffic sites). | [
"Delete",
"Visit",
"Unique",
"Visitor",
"and",
"Users",
"metric",
"from",
"page",
"scope",
"custom",
"variables",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CustomVariables/Archiver.php#L261-L273 | train | Remove visits metrics from actions aggregate | [
30522,
5123,
3853,
6366,
11365,
12762,
12589,
22747,
21716,
18908,
8496,
8490,
17603,
5867,
1006,
1007,
1063,
1002,
2951,
2906,
9447,
1027,
1004,
1002,
2023,
1011,
1028,
2951,
2906,
9447,
1011,
1028,
2131,
2850,
2696,
2906,
9447,
1006,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Mailer.php | Mailer.send | public function send($view, array $data = [], $callback = null)
{
if ($view instanceof MailableContract) {
return $this->sendMailable($view);
}
// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
[$view, $plain, $raw] = $this->parseView($view);
$data['message'] = $message = $this->createMessage();
// Once we have retrieved the view content for the e-mail we will set the body
// of this message using the HTML type, which will provide a simple wrapper
// to creating view based emails that are able to receive arrays of data.
call_user_func($callback, $message);
$this->addContent($message, $view, $plain, $raw, $data);
// If a global "to" address has been set, we will set that address on the mail
// message. This is primarily useful during local development in which each
// message should be delivered into a single mail address for inspection.
if (isset($this->to['address'])) {
$this->setGlobalToAndRemoveCcAndBcc($message);
}
// Next we will determine if the message should be sent. We give the developer
// one final chance to stop this message and then we will send it to all of
// its recipients. We will then fire the sent event for the sent message.
$swiftMessage = $message->getSwiftMessage();
if ($this->shouldSendMessage($swiftMessage, $data)) {
$this->sendSwiftMessage($swiftMessage);
$this->dispatchSentEvent($message, $data);
}
} | php | public function send($view, array $data = [], $callback = null)
{
if ($view instanceof MailableContract) {
return $this->sendMailable($view);
}
// First we need to parse the view, which could either be a string or an array
// containing both an HTML and plain text versions of the view which should
// be used when sending an e-mail. We will extract both of them out here.
[$view, $plain, $raw] = $this->parseView($view);
$data['message'] = $message = $this->createMessage();
// Once we have retrieved the view content for the e-mail we will set the body
// of this message using the HTML type, which will provide a simple wrapper
// to creating view based emails that are able to receive arrays of data.
call_user_func($callback, $message);
$this->addContent($message, $view, $plain, $raw, $data);
// If a global "to" address has been set, we will set that address on the mail
// message. This is primarily useful during local development in which each
// message should be delivered into a single mail address for inspection.
if (isset($this->to['address'])) {
$this->setGlobalToAndRemoveCcAndBcc($message);
}
// Next we will determine if the message should be sent. We give the developer
// one final chance to stop this message and then we will send it to all of
// its recipients. We will then fire the sent event for the sent message.
$swiftMessage = $message->getSwiftMessage();
if ($this->shouldSendMessage($swiftMessage, $data)) {
$this->sendSwiftMessage($swiftMessage);
$this->dispatchSentEvent($message, $data);
}
} | [
"public",
"function",
"send",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"view",
"instanceof",
"MailableContract",
")",
"{",
"return",
"$",
"this",
"->",
"sendMailable",
"(... | Send a new message using a view.
@param string|array|\Illuminate\Contracts\Mail\Mailable $view
@param array $data
@param \Closure|string $callback
@return void | [
"Send",
"a",
"new",
"message",
"using",
"a",
"view",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailer.php#L226-L263 | train | Sends an e - mail | [
30522,
2270,
3853,
4604,
1006,
1002,
3193,
1010,
9140,
1002,
2951,
1027,
1031,
1033,
1010,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
3193,
6013,
11253,
5653,
3085,
8663,
6494,
6593,
1007,
1063,
2709,
1002,
2023,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/FormatsMessages.php | FormatsMessages.replaceInputPlaceholder | protected function replaceInputPlaceholder($message, $attribute)
{
$actualValue = $this->getValue($attribute);
if (is_scalar($actualValue) || is_null($actualValue)) {
$message = str_replace(':input', $actualValue, $message);
}
return $message;
} | php | protected function replaceInputPlaceholder($message, $attribute)
{
$actualValue = $this->getValue($attribute);
if (is_scalar($actualValue) || is_null($actualValue)) {
$message = str_replace(':input', $actualValue, $message);
}
return $message;
} | [
"protected",
"function",
"replaceInputPlaceholder",
"(",
"$",
"message",
",",
"$",
"attribute",
")",
"{",
"$",
"actualValue",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"is_scalar",
"(",
"$",
"actualValue",
")",
"||",
... | Replace the :input placeholder in the given message.
@param string $message
@param string $attribute
@return string | [
"Replace",
"the",
":",
"input",
"placeholder",
"in",
"the",
"given",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/FormatsMessages.php#L293-L302 | train | Replace input placeholder with actual value | [
30522,
5123,
3853,
5672,
2378,
18780,
24759,
10732,
14528,
1006,
1002,
4471,
1010,
1002,
17961,
1007,
1063,
1002,
5025,
10175,
5657,
1027,
1002,
2023,
1011,
1028,
2131,
10175,
5657,
1006,
1002,
17961,
1007,
1025,
2065,
1006,
2003,
1035,
267... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ArgvInput.php | ArgvInput.parseShortOptionSet | private function parseShortOptionSet($name)
{
$len = \strlen($name);
for ($i = 0; $i < $len; ++$i) {
if (!$this->definition->hasShortcut($name[$i])) {
$encoding = mb_detect_encoding($name, null, true);
throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
}
$option = $this->definition->getOptionForShortcut($name[$i]);
if ($option->acceptValue()) {
$this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
break;
} else {
$this->addLongOption($option->getName(), null);
}
}
} | php | private function parseShortOptionSet($name)
{
$len = \strlen($name);
for ($i = 0; $i < $len; ++$i) {
if (!$this->definition->hasShortcut($name[$i])) {
$encoding = mb_detect_encoding($name, null, true);
throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
}
$option = $this->definition->getOptionForShortcut($name[$i]);
if ($option->acceptValue()) {
$this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
break;
} else {
$this->addLongOption($option->getName(), null);
}
}
} | [
"private",
"function",
"parseShortOptionSet",
"(",
"$",
"name",
")",
"{",
"$",
"len",
"=",
"\\",
"strlen",
"(",
"$",
"name",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"len",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
... | Parses a short option set.
@param string $name The current token
@throws RuntimeException When option given doesn't exist | [
"Parses",
"a",
"short",
"option",
"set",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Input/ArgvInput.php#L119-L137 | train | Parse Short Option Set | [
30522,
2797,
3853,
11968,
8583,
27794,
7361,
9285,
3388,
1006,
1002,
2171,
1007,
1063,
1002,
18798,
1027,
1032,
2358,
20927,
2078,
1006,
1002,
2171,
1007,
1025,
2005,
1006,
1002,
1045,
1027,
1014,
1025,
1002,
1045,
1026,
1002,
18798,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Mapping/ClassMetadata.php | ClassMetadata.mergeConstraints | public function mergeConstraints(self $source)
{
if ($source->isGroupSequenceProvider()) {
$this->setGroupSequenceProvider(true);
}
foreach ($source->getConstraints() as $constraint) {
$this->addConstraint(clone $constraint);
}
foreach ($source->getConstrainedProperties() as $property) {
foreach ($source->getPropertyMetadata($property) as $member) {
$member = clone $member;
foreach ($member->getConstraints() as $constraint) {
if (\in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) {
$member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
}
$constraint->addImplicitGroupName($this->getDefaultGroup());
}
$this->addPropertyMetadata($member);
if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
$property = $member->getPropertyName();
if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
$this->properties[$property] = $member;
} elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
$this->getters[$property] = $member;
}
}
}
}
} | php | public function mergeConstraints(self $source)
{
if ($source->isGroupSequenceProvider()) {
$this->setGroupSequenceProvider(true);
}
foreach ($source->getConstraints() as $constraint) {
$this->addConstraint(clone $constraint);
}
foreach ($source->getConstrainedProperties() as $property) {
foreach ($source->getPropertyMetadata($property) as $member) {
$member = clone $member;
foreach ($member->getConstraints() as $constraint) {
if (\in_array($constraint::DEFAULT_GROUP, $constraint->groups, true)) {
$member->constraintsByGroup[$this->getDefaultGroup()][] = $constraint;
}
$constraint->addImplicitGroupName($this->getDefaultGroup());
}
$this->addPropertyMetadata($member);
if ($member instanceof MemberMetadata && !$member->isPrivate($this->name)) {
$property = $member->getPropertyName();
if ($member instanceof PropertyMetadata && !isset($this->properties[$property])) {
$this->properties[$property] = $member;
} elseif ($member instanceof GetterMetadata && !isset($this->getters[$property])) {
$this->getters[$property] = $member;
}
}
}
}
} | [
"public",
"function",
"mergeConstraints",
"(",
"self",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"->",
"isGroupSequenceProvider",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setGroupSequenceProvider",
"(",
"true",
")",
";",
"}",
"foreach",
"(",
"$",
... | Merges the constraints of the given metadata into this object. | [
"Merges",
"the",
"constraints",
"of",
"the",
"given",
"metadata",
"into",
"this",
"object",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Mapping/ClassMetadata.php#L327-L362 | train | Merge constraints from source to this one | [
30522,
2270,
3853,
13590,
8663,
20528,
18447,
2015,
1006,
2969,
1002,
3120,
1007,
1063,
2065,
1006,
1002,
3120,
1011,
1028,
2003,
17058,
3366,
4226,
5897,
21572,
17258,
2121,
1006,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
17058,
3366... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Notifications/NotificationSender.php | NotificationSender.queueNotification | protected function queueNotification($notifiables, $notification)
{
$notifiables = $this->formatNotifiables($notifiables);
$original = clone $notification;
foreach ($notifiables as $notifiable) {
$notificationId = Str::uuid()->toString();
foreach ((array) $original->via($notifiable) as $channel) {
$notification = clone $original;
$notification->id = $notificationId;
if (! is_null($this->locale)) {
$notification->locale = $this->locale;
}
$this->bus->dispatch(
(new SendQueuedNotifications($notifiable, $notification, [$channel]))
->onConnection($notification->connection)
->onQueue($notification->queue)
->delay($notification->delay)
);
}
}
} | php | protected function queueNotification($notifiables, $notification)
{
$notifiables = $this->formatNotifiables($notifiables);
$original = clone $notification;
foreach ($notifiables as $notifiable) {
$notificationId = Str::uuid()->toString();
foreach ((array) $original->via($notifiable) as $channel) {
$notification = clone $original;
$notification->id = $notificationId;
if (! is_null($this->locale)) {
$notification->locale = $this->locale;
}
$this->bus->dispatch(
(new SendQueuedNotifications($notifiable, $notification, [$channel]))
->onConnection($notification->connection)
->onQueue($notification->queue)
->delay($notification->delay)
);
}
}
} | [
"protected",
"function",
"queueNotification",
"(",
"$",
"notifiables",
",",
"$",
"notification",
")",
"{",
"$",
"notifiables",
"=",
"$",
"this",
"->",
"formatNotifiables",
"(",
"$",
"notifiables",
")",
";",
"$",
"original",
"=",
"clone",
"$",
"notification",
... | Queue the given notification instances.
@param mixed $notifiables
@param array[\Illuminate\Notifications\Channels\Notification] $notification
@return void | [
"Queue",
"the",
"given",
"notification",
"instances",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Notifications/NotificationSender.php#L173-L199 | train | Queue Notification for all notifiables | [
30522,
5123,
3853,
24240,
17048,
9031,
1006,
1002,
2025,
10128,
19210,
2015,
1010,
1002,
26828,
1007,
1063,
1002,
2025,
10128,
19210,
2015,
1027,
1002,
2023,
1011,
1028,
4289,
17048,
10128,
19210,
2015,
1006,
1002,
2025,
10128,
19210,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Extractor/PhpExtractor.php | PhpExtractor.parseTokens | protected function parseTokens($tokens, MessageCatalogue $catalog)
{
$tokenIterator = new \ArrayIterator($tokens);
for ($key = 0; $key < $tokenIterator->count(); ++$key) {
foreach ($this->sequences as $sequence) {
$message = '';
$domain = 'messages';
$tokenIterator->seek($key);
foreach ($sequence as $sequenceKey => $item) {
$this->seekToNextRelevantToken($tokenIterator);
if ($this->normalizeToken($tokenIterator->current()) === $item) {
$tokenIterator->next();
continue;
} elseif (self::MESSAGE_TOKEN === $item) {
$message = $this->getValue($tokenIterator);
if (\count($sequence) === ($sequenceKey + 1)) {
break;
}
} elseif (self::METHOD_ARGUMENTS_TOKEN === $item) {
$this->skipMethodArgument($tokenIterator);
} elseif (self::DOMAIN_TOKEN === $item) {
$domainToken = $this->getValue($tokenIterator);
if ('' !== $domainToken) {
$domain = $domainToken;
}
break;
} else {
break;
}
}
if ($message) {
$catalog->set($message, $this->prefix.$message, $domain);
break;
}
}
}
} | php | protected function parseTokens($tokens, MessageCatalogue $catalog)
{
$tokenIterator = new \ArrayIterator($tokens);
for ($key = 0; $key < $tokenIterator->count(); ++$key) {
foreach ($this->sequences as $sequence) {
$message = '';
$domain = 'messages';
$tokenIterator->seek($key);
foreach ($sequence as $sequenceKey => $item) {
$this->seekToNextRelevantToken($tokenIterator);
if ($this->normalizeToken($tokenIterator->current()) === $item) {
$tokenIterator->next();
continue;
} elseif (self::MESSAGE_TOKEN === $item) {
$message = $this->getValue($tokenIterator);
if (\count($sequence) === ($sequenceKey + 1)) {
break;
}
} elseif (self::METHOD_ARGUMENTS_TOKEN === $item) {
$this->skipMethodArgument($tokenIterator);
} elseif (self::DOMAIN_TOKEN === $item) {
$domainToken = $this->getValue($tokenIterator);
if ('' !== $domainToken) {
$domain = $domainToken;
}
break;
} else {
break;
}
}
if ($message) {
$catalog->set($message, $this->prefix.$message, $domain);
break;
}
}
}
} | [
"protected",
"function",
"parseTokens",
"(",
"$",
"tokens",
",",
"MessageCatalogue",
"$",
"catalog",
")",
"{",
"$",
"tokenIterator",
"=",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"tokens",
")",
";",
"for",
"(",
"$",
"key",
"=",
"0",
";",
"$",
"key",
"<"... | Extracts trans message from PHP tokens.
@param array $tokens
@param MessageCatalogue $catalog | [
"Extracts",
"trans",
"message",
"from",
"PHP",
"tokens",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Extractor/PhpExtractor.php#L201-L243 | train | Parse the tokens and add them to the MessageCatalogue | [
30522,
5123,
3853,
11968,
13462,
11045,
3619,
1006,
1002,
19204,
2015,
1010,
4471,
11266,
23067,
9077,
1002,
12105,
1007,
1063,
1002,
19204,
21646,
8844,
1027,
2047,
1032,
9140,
21646,
8844,
1006,
1002,
19204,
2015,
1007,
1025,
2005,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/behaviors/FormController.php | FormController.getLang | protected function getLang($name, $default = null, $extras = [])
{
$name = $this->getConfig($name, $default);
$vars = [
'name' => Lang::get($this->getConfig('name', 'backend::lang.model.name'))
];
$vars = array_merge($vars, $extras);
return Lang::get($name, $vars);
} | php | protected function getLang($name, $default = null, $extras = [])
{
$name = $this->getConfig($name, $default);
$vars = [
'name' => Lang::get($this->getConfig('name', 'backend::lang.model.name'))
];
$vars = array_merge($vars, $extras);
return Lang::get($name, $vars);
} | [
"protected",
"function",
"getLang",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
",",
"$",
"extras",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"$",
"name",
",",
"$",
"default",
")",
";",
"$",
"vars",
... | Parses in some default variables to a language string defined in config.
@param string $name Configuration property containing the language string
@param string $default A default language string to use if the config is not found
@param array $extras Any extra params to include in the language string variables
@return string The translated string. | [
"Parses",
"in",
"some",
"default",
"variables",
"to",
"a",
"language",
"string",
"defined",
"in",
"config",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/FormController.php#L519-L527 | train | Get lang from config | [
30522,
5123,
3853,
2131,
30524,
1028,
11374,
1024,
1024,
2131,
1006,
1002,
2023,
1011,
1028,
2131,
8663,
8873,
2290,
1006,
1005,
2171,
1005,
1010,
1005,
2067,
10497,
1024,
1024,
11374,
1012,
2944,
1012,
2171,
1005,
1007,
1007,
1033,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Message.php | Message.addAddresses | protected function addAddresses($address, $name, $type)
{
if (is_array($address)) {
$this->swift->{"set{$type}"}($address, $name);
} else {
$this->swift->{"add{$type}"}($address, $name);
}
return $this;
} | php | protected function addAddresses($address, $name, $type)
{
if (is_array($address)) {
$this->swift->{"set{$type}"}($address, $name);
} else {
$this->swift->{"add{$type}"}($address, $name);
}
return $this;
} | [
"protected",
"function",
"addAddresses",
"(",
"$",
"address",
",",
"$",
"name",
",",
"$",
"type",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"address",
")",
")",
"{",
"$",
"this",
"->",
"swift",
"->",
"{",
"\"set{$type}\"",
"}",
"(",
"$",
"address",
... | Add a recipient to the message.
@param string|array $address
@param string $name
@param string $type
@return $this | [
"Add",
"a",
"recipient",
"to",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Message.php#L159-L168 | train | Add addresses to the message | [
30522,
5123,
3853,
5587,
4215,
16200,
11393,
2015,
1006,
1002,
4769,
1010,
1002,
2171,
1010,
1002,
2828,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
4769,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
9170,
1011,
1028,
1063,
1000,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Goals/DataTable/Filter/AppendNameToColumnNames.php | AppendNameToColumnNames.filter | public function filter($table)
{
if (!isset($this->nameToAppend) || '' === $this->nameToAppend || false === $this->nameToAppend) {
return;
}
foreach ($table->getRows() as $row) {
$columns = $row->getColumns();
foreach ($columns as $column => $value) {
$row->deleteColumn($column);
$row->setColumn($column . $this->nameToAppend, $value);
}
$this->filterSubTable($row);
}
} | php | public function filter($table)
{
if (!isset($this->nameToAppend) || '' === $this->nameToAppend || false === $this->nameToAppend) {
return;
}
foreach ($table->getRows() as $row) {
$columns = $row->getColumns();
foreach ($columns as $column => $value) {
$row->deleteColumn($column);
$row->setColumn($column . $this->nameToAppend, $value);
}
$this->filterSubTable($row);
}
} | [
"public",
"function",
"filter",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nameToAppend",
")",
"||",
"''",
"===",
"$",
"this",
"->",
"nameToAppend",
"||",
"false",
"===",
"$",
"this",
"->",
"nameToAppend",
")",
"{"... | See {@link ReplaceColumnNames}.
@param DataTable $table | [
"See",
"{",
"@link",
"ReplaceColumnNames",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Goals/DataTable/Filter/AppendNameToColumnNames.php#L40-L56 | train | Filter the table and append the nameToAppend property to all columns of the table | [
30522,
2270,
3853,
11307,
1006,
1002,
2795,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2171,
3406,
29098,
10497,
1007,
1064,
1064,
1005,
1005,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
2171,
3406,
29098,
10497,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Adapter/Psr16Adapter.php | Psr16Adapter.doFetch | protected function doFetch(array $ids)
{
foreach ($this->pool->getMultiple($ids, $this->miss) as $key => $value) {
if ($this->miss !== $value) {
yield $key => $value;
}
}
} | php | protected function doFetch(array $ids)
{
foreach ($this->pool->getMultiple($ids, $this->miss) as $key => $value) {
if ($this->miss !== $value) {
yield $key => $value;
}
}
} | [
"protected",
"function",
"doFetch",
"(",
"array",
"$",
"ids",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"pool",
"->",
"getMultiple",
"(",
"$",
"ids",
",",
"$",
"this",
"->",
"miss",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php#L41-L48 | train | Do fetch. | [
30522,
5123,
3853,
2079,
7959,
10649,
1006,
9140,
1002,
8909,
2015,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
4770,
1011,
1028,
2131,
12274,
7096,
11514,
2571,
1006,
1002,
8909,
2015,
1010,
1002,
2023,
1011,
1028,
3335,
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/Table.php | Table.prepareColumnsArray | protected function prepareColumnsArray()
{
$result = [];
foreach ($this->columns as $key=>$data) {
$data['key'] = $key;
if (isset($data['title']))
$data['title'] = trans($data['title']);
if (isset($data['options'])) {
foreach ($data['options'] as &$option)
$option = trans($option);
}
if (isset($data['validation'])) {
foreach ($data['validation'] as &$validation) {
if (isset($validation['message'])) {
$validation['message'] = trans($validation['message']);
}
}
}
$result[] = $data;
}
return $result;
} | php | protected function prepareColumnsArray()
{
$result = [];
foreach ($this->columns as $key=>$data) {
$data['key'] = $key;
if (isset($data['title']))
$data['title'] = trans($data['title']);
if (isset($data['options'])) {
foreach ($data['options'] as &$option)
$option = trans($option);
}
if (isset($data['validation'])) {
foreach ($data['validation'] as &$validation) {
if (isset($validation['message'])) {
$validation['message'] = trans($validation['message']);
}
}
}
$result[] = $data;
}
return $result;
} | [
"protected",
"function",
"prepareColumnsArray",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"$",
"data",
"[",
"'key'",
"]",
"=",
"$",
"key",
";",
"... | Converts the columns associative array to a regular array and translates column headers and drop-down options.
Working with regular arrays is much faster in JavaScript.
References:
- http://www.smashingmagazine.com/2012/11/05/writing-fast-memory-efficient-javascript/
- http://jsperf.com/performance-of-array-vs-object/3 | [
"Converts",
"the",
"columns",
"associative",
"array",
"to",
"a",
"regular",
"array",
"and",
"translates",
"column",
"headers",
"and",
"drop",
"-",
"down",
"options",
".",
"Working",
"with",
"regular",
"arrays",
"is",
"much",
"faster",
"in",
"JavaScript",
".",
... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Table.php#L164-L191 | train | Prepares columns array | [
30522,
5123,
3853,
7374,
25778,
2819,
3619,
2906,
9447,
1006,
1007,
1063,
1002,
2765,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
7753,
2004,
1002,
3145,
1027,
1028,
1002,
2951,
1007,
1063,
1002,
2951,
1031,
1005,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.