repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matomo-org/matomo | core/Menu/MenuAbstract.php | MenuAbstract.buildMenu | private function buildMenu()
{
foreach ($this->menuEntries as $menuEntry) {
$this->buildMenuItem($menuEntry[0], $menuEntry[1], $menuEntry[2], $menuEntry[3], $menuEntry[4], $menuEntry[5], $menuEntry[6]);
}
} | php | private function buildMenu()
{
foreach ($this->menuEntries as $menuEntry) {
$this->buildMenuItem($menuEntry[0], $menuEntry[1], $menuEntry[2], $menuEntry[3], $menuEntry[4], $menuEntry[5], $menuEntry[6]);
}
} | [
"private",
"function",
"buildMenu",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"menuEntries",
"as",
"$",
"menuEntry",
")",
"{",
"$",
"this",
"->",
"buildMenuItem",
"(",
"$",
"menuEntry",
"[",
"0",
"]",
",",
"$",
"menuEntry",
"[",
"1",
"]",
","... | Builds the menu from the $this->menuEntries variable. | [
"Builds",
"the",
"menu",
"from",
"the",
"$this",
"-",
">",
"menuEntries",
"variable",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Menu/MenuAbstract.php#L190-L195 | train | Build menu entries | [
30522,
2797,
3853,
3857,
3549,
2226,
1006,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
12183,
4765,
5134,
2004,
1002,
12183,
4765,
2854,
1007,
1063,
1002,
2023,
1011,
1028,
3857,
3549,
14663,
6633,
1006,
1002,
12183,
4765,
2854,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.addPropertyConstraints | public function addPropertyConstraints($property, array $constraints)
{
foreach ($constraints as $constraint) {
$this->addPropertyConstraint($property, $constraint);
}
return $this;
} | php | public function addPropertyConstraints($property, array $constraints)
{
foreach ($constraints as $constraint) {
$this->addPropertyConstraint($property, $constraint);
}
return $this;
} | [
"public",
"function",
"addPropertyConstraints",
"(",
"$",
"property",
",",
"array",
"$",
"constraints",
")",
"{",
"foreach",
"(",
"$",
"constraints",
"as",
"$",
"constraint",
")",
"{",
"$",
"this",
"->",
"addPropertyConstraint",
"(",
"$",
"property",
",",
"$... | @param string $property
@param Constraint[] $constraints
@return $this | [
"@param",
"string",
"$property",
"@param",
"Constraint",
"[]",
"$constraints"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Mapping/ClassMetadata.php#L234-L241 | train | Add a property constraints | [
30522,
2270,
3853,
5587,
21572,
4842,
3723,
8663,
20528,
18447,
2015,
1006,
1002,
3200,
1010,
9140,
1002,
14679,
1007,
1063,
18921,
6776,
1006,
1002,
14679,
2004,
1002,
27142,
1007,
1063,
1002,
2023,
1011,
1028,
5587,
21572,
4842,
3723,
866... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/WebsiteMeasurable/Settings/Urls.php | Urls.checkAtLeastOneUrl | public function checkAtLeastOneUrl($urls)
{
$urls = $this->cleanParameterUrls($urls);
if (!is_array($urls)
|| count($urls) == 0
) {
throw new Exception(Piwik::translate('SitesManager_ExceptionNoUrl'));
}
} | php | public function checkAtLeastOneUrl($urls)
{
$urls = $this->cleanParameterUrls($urls);
if (!is_array($urls)
|| count($urls) == 0
) {
throw new Exception(Piwik::translate('SitesManager_ExceptionNoUrl'));
}
} | [
"public",
"function",
"checkAtLeastOneUrl",
"(",
"$",
"urls",
")",
"{",
"$",
"urls",
"=",
"$",
"this",
"->",
"cleanParameterUrls",
"(",
"$",
"urls",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"urls",
")",
"||",
"count",
"(",
"$",
"urls",
")",
... | Checks that the array has at least one element
@param array $urls
@throws Exception | [
"Checks",
"that",
"the",
"array",
"has",
"at",
"least",
"one",
"element"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/WebsiteMeasurable/Settings/Urls.php#L67-L76 | train | Check if at least one url is available. | [
30522,
2270,
3853,
4638,
4017,
19738,
9221,
3126,
2140,
1006,
1002,
24471,
4877,
1007,
1063,
1002,
24471,
4877,
1027,
1002,
2023,
1011,
1028,
4550,
28689,
22828,
3126,
4877,
1006,
1002,
24471,
4877,
1007,
1025,
2065,
1006,
999,
2003,
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... |
matomo-org/matomo | plugins/UserCountry/Controller.php | Controller.downloadMissingGeoIpDb | public function downloadMissingGeoIpDb()
{
$this->dieIfGeolocationAdminIsDisabled();
Piwik::checkUserHasSuperUserAccess();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
$this->checkTokenInUrl();
Json::sendHeaderJSON();
// based on the database type (provided by the 'key' query param) determine the
// url & output file name
$key = Common::getRequestVar('key', null, 'string');
if ($this->isGeoIp2Enabled()) {
$url = GeoIP2AutoUpdater::getConfiguredUrl($key);
$ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);
$filename = GeoIp2::$dbNames[$key][0] . '.' . $ext;
$outputPath = GeoIp2::getPathForGeoIpDatabase($filename);
} else {
$url = GeoIPAutoUpdater::getConfiguredUrl($key);
$ext = GeoIPAutoUpdater::getGeoIPUrlExtension($url);
$filename = GeoIp::$dbNames[$key][0] . '.' . $ext;
if (substr($filename, 0, 15) == 'GeoLiteCity.dat') {
$filename = 'GeoIPCity.dat' . substr($filename, 15);
}
$outputPath = GeoIp::getPathForGeoIpDatabase($filename);
}
// download part of the file
$result = Http::downloadChunk(
$url, $outputPath, Common::getRequestVar('continue', true, 'int'));
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
if ($this->isGeoIp2Enabled()) {
GeoIP2AutoUpdater::unzipDownloadedFile($outputPath, $key, $unlink = true);
} else {
GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
}
$info = $this->getNextMissingDbUrlInfo();
if ($info !== false) {
return json_encode($info);
}
}
return json_encode($result);
} catch (Exception $ex) {
return json_encode(array('error' => $ex->getMessage()));
}
}
} | php | public function downloadMissingGeoIpDb()
{
$this->dieIfGeolocationAdminIsDisabled();
Piwik::checkUserHasSuperUserAccess();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
try {
$this->checkTokenInUrl();
Json::sendHeaderJSON();
// based on the database type (provided by the 'key' query param) determine the
// url & output file name
$key = Common::getRequestVar('key', null, 'string');
if ($this->isGeoIp2Enabled()) {
$url = GeoIP2AutoUpdater::getConfiguredUrl($key);
$ext = GeoIP2AutoUpdater::getGeoIPUrlExtension($url);
$filename = GeoIp2::$dbNames[$key][0] . '.' . $ext;
$outputPath = GeoIp2::getPathForGeoIpDatabase($filename);
} else {
$url = GeoIPAutoUpdater::getConfiguredUrl($key);
$ext = GeoIPAutoUpdater::getGeoIPUrlExtension($url);
$filename = GeoIp::$dbNames[$key][0] . '.' . $ext;
if (substr($filename, 0, 15) == 'GeoLiteCity.dat') {
$filename = 'GeoIPCity.dat' . substr($filename, 15);
}
$outputPath = GeoIp::getPathForGeoIpDatabase($filename);
}
// download part of the file
$result = Http::downloadChunk(
$url, $outputPath, Common::getRequestVar('continue', true, 'int'));
// if the file is done
if ($result['current_size'] >= $result['expected_file_size']) {
if ($this->isGeoIp2Enabled()) {
GeoIP2AutoUpdater::unzipDownloadedFile($outputPath, $key, $unlink = true);
} else {
GeoIPAutoUpdater::unzipDownloadedFile($outputPath, $unlink = true);
}
$info = $this->getNextMissingDbUrlInfo();
if ($info !== false) {
return json_encode($info);
}
}
return json_encode($result);
} catch (Exception $ex) {
return json_encode(array('error' => $ex->getMessage()));
}
}
} | [
"public",
"function",
"downloadMissingGeoIpDb",
"(",
")",
"{",
"$",
"this",
"->",
"dieIfGeolocationAdminIsDisabled",
"(",
")",
";",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"P... | Starts or continues a download for a missing GeoIP database. A database is missing if
it has an update URL configured, but the actual database is not available in the misc
directory.
Input:
'url' - The URL to download the database from.
'continue' - 1 if we're continuing a download, 0 if we're starting one.
Output:
'error' - If an error occurs this describes the error.
'to_download' - The URL of a missing database that should be downloaded next (if any).
'to_download_label' - The label to use w/ the progress bar that describes what we're
downloading.
'current_size' - Size of the current file on disk.
'expected_file_size' - Size of the completely downloaded file. | [
"Starts",
"or",
"continues",
"a",
"download",
"for",
"a",
"missing",
"GeoIP",
"database",
".",
"A",
"database",
"is",
"missing",
"if",
"it",
"has",
"an",
"update",
"URL",
"configured",
"but",
"the",
"actual",
"database",
"is",
"not",
"available",
"in",
"th... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/Controller.php#L331-L384 | train | Downloads the missing GeoLite City database | [
30522,
2270,
3853,
8816,
15630,
7741,
3351,
10448,
17299,
2497,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
3280,
10128,
3351,
12898,
10719,
4215,
25300,
16150,
14268,
23242,
1006,
1007,
1025,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Loader/YamlFileLoader.php | YamlFileLoader.parseImport | protected function parseImport(RouteCollection $collection, array $config, $path, $file)
{
$type = isset($config['type']) ? $config['type'] : null;
$prefix = isset($config['prefix']) ? $config['prefix'] : '';
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
$options = isset($config['options']) ? $config['options'] : [];
$host = isset($config['host']) ? $config['host'] : null;
$condition = isset($config['condition']) ? $config['condition'] : null;
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
$methods = isset($config['methods']) ? $config['methods'] : null;
$trailingSlashOnRoot = $config['trailing_slash_on_root'] ?? true;
if (isset($config['controller'])) {
$defaults['_controller'] = $config['controller'];
}
if (isset($config['locale'])) {
$defaults['_locale'] = $config['locale'];
}
if (isset($config['format'])) {
$defaults['_format'] = $config['format'];
}
if (isset($config['utf8'])) {
$options['utf8'] = $config['utf8'];
}
$this->setCurrentDir(\dirname($path));
$imported = $this->import($config['resource'], $type, false, $file);
if (!\is_array($imported)) {
$imported = [$imported];
}
foreach ($imported as $subCollection) {
/* @var $subCollection RouteCollection */
if (!\is_array($prefix)) {
$subCollection->addPrefix($prefix);
if (!$trailingSlashOnRoot) {
$rootPath = (new Route(trim(trim($prefix), '/').'/'))->getPath();
foreach ($subCollection->all() as $route) {
if ($route->getPath() === $rootPath) {
$route->setPath(rtrim($rootPath, '/'));
}
}
}
} else {
foreach ($prefix as $locale => $localePrefix) {
$prefix[$locale] = trim(trim($localePrefix), '/');
}
foreach ($subCollection->all() as $name => $route) {
if (null === $locale = $route->getDefault('_locale')) {
$subCollection->remove($name);
foreach ($prefix as $locale => $localePrefix) {
$localizedRoute = clone $route;
$localizedRoute->setDefault('_locale', $locale);
$localizedRoute->setDefault('_canonical_route', $name);
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
$subCollection->add($name.'.'.$locale, $localizedRoute);
}
} elseif (!isset($prefix[$locale])) {
throw new \InvalidArgumentException(sprintf('Route "%s" with locale "%s" is missing a corresponding prefix when imported in "%s".', $name, $locale, $file));
} else {
$route->setPath($prefix[$locale].(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
$subCollection->add($name, $route);
}
}
}
if (null !== $host) {
$subCollection->setHost($host);
}
if (null !== $condition) {
$subCollection->setCondition($condition);
}
if (null !== $schemes) {
$subCollection->setSchemes($schemes);
}
if (null !== $methods) {
$subCollection->setMethods($methods);
}
$subCollection->addDefaults($defaults);
$subCollection->addRequirements($requirements);
$subCollection->addOptions($options);
if (isset($config['name_prefix'])) {
$subCollection->addNamePrefix($config['name_prefix']);
}
$collection->addCollection($subCollection);
}
} | php | protected function parseImport(RouteCollection $collection, array $config, $path, $file)
{
$type = isset($config['type']) ? $config['type'] : null;
$prefix = isset($config['prefix']) ? $config['prefix'] : '';
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
$options = isset($config['options']) ? $config['options'] : [];
$host = isset($config['host']) ? $config['host'] : null;
$condition = isset($config['condition']) ? $config['condition'] : null;
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
$methods = isset($config['methods']) ? $config['methods'] : null;
$trailingSlashOnRoot = $config['trailing_slash_on_root'] ?? true;
if (isset($config['controller'])) {
$defaults['_controller'] = $config['controller'];
}
if (isset($config['locale'])) {
$defaults['_locale'] = $config['locale'];
}
if (isset($config['format'])) {
$defaults['_format'] = $config['format'];
}
if (isset($config['utf8'])) {
$options['utf8'] = $config['utf8'];
}
$this->setCurrentDir(\dirname($path));
$imported = $this->import($config['resource'], $type, false, $file);
if (!\is_array($imported)) {
$imported = [$imported];
}
foreach ($imported as $subCollection) {
/* @var $subCollection RouteCollection */
if (!\is_array($prefix)) {
$subCollection->addPrefix($prefix);
if (!$trailingSlashOnRoot) {
$rootPath = (new Route(trim(trim($prefix), '/').'/'))->getPath();
foreach ($subCollection->all() as $route) {
if ($route->getPath() === $rootPath) {
$route->setPath(rtrim($rootPath, '/'));
}
}
}
} else {
foreach ($prefix as $locale => $localePrefix) {
$prefix[$locale] = trim(trim($localePrefix), '/');
}
foreach ($subCollection->all() as $name => $route) {
if (null === $locale = $route->getDefault('_locale')) {
$subCollection->remove($name);
foreach ($prefix as $locale => $localePrefix) {
$localizedRoute = clone $route;
$localizedRoute->setDefault('_locale', $locale);
$localizedRoute->setDefault('_canonical_route', $name);
$localizedRoute->setPath($localePrefix.(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
$subCollection->add($name.'.'.$locale, $localizedRoute);
}
} elseif (!isset($prefix[$locale])) {
throw new \InvalidArgumentException(sprintf('Route "%s" with locale "%s" is missing a corresponding prefix when imported in "%s".', $name, $locale, $file));
} else {
$route->setPath($prefix[$locale].(!$trailingSlashOnRoot && '/' === $route->getPath() ? '' : $route->getPath()));
$subCollection->add($name, $route);
}
}
}
if (null !== $host) {
$subCollection->setHost($host);
}
if (null !== $condition) {
$subCollection->setCondition($condition);
}
if (null !== $schemes) {
$subCollection->setSchemes($schemes);
}
if (null !== $methods) {
$subCollection->setMethods($methods);
}
$subCollection->addDefaults($defaults);
$subCollection->addRequirements($requirements);
$subCollection->addOptions($options);
if (isset($config['name_prefix'])) {
$subCollection->addNamePrefix($config['name_prefix']);
}
$collection->addCollection($subCollection);
}
} | [
"protected",
"function",
"parseImport",
"(",
"RouteCollection",
"$",
"collection",
",",
"array",
"$",
"config",
",",
"$",
"path",
",",
"$",
"file",
")",
"{",
"$",
"type",
"=",
"isset",
"(",
"$",
"config",
"[",
"'type'",
"]",
")",
"?",
"$",
"config",
... | Parses an import and adds the routes in the resource to the RouteCollection.
@param RouteCollection $collection A RouteCollection instance
@param array $config Route definition
@param string $path Full path of the YAML file being processed
@param string $file Loaded file name | [
"Parses",
"an",
"import",
"and",
"adds",
"the",
"routes",
"in",
"the",
"resource",
"to",
"the",
"RouteCollection",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Loader/YamlFileLoader.php#L162-L253 | train | Parse import route | [
30522,
5123,
3853,
11968,
20240,
8737,
11589,
1006,
2799,
26895,
18491,
1002,
3074,
1010,
9140,
1002,
9530,
8873,
2290,
1010,
1002,
4130,
1010,
1002,
5371,
1007,
1063,
1002,
2828,
1027,
26354,
3388,
1006,
1002,
9530,
8873,
2290,
1031,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Form.php | Form.viewToNorm | private function viewToNorm($value)
{
if (!$transformers = $this->config->getViewTransformers()) {
return '' === $value ? null : $value;
}
try {
for ($i = \count($transformers) - 1; $i >= 0; --$i) {
$value = $transformers[$i]->reverseTransform($value);
}
} catch (TransformationFailedException $exception) {
throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters());
}
return $value;
} | php | private function viewToNorm($value)
{
if (!$transformers = $this->config->getViewTransformers()) {
return '' === $value ? null : $value;
}
try {
for ($i = \count($transformers) - 1; $i >= 0; --$i) {
$value = $transformers[$i]->reverseTransform($value);
}
} catch (TransformationFailedException $exception) {
throw new TransformationFailedException('Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), $exception->getCode(), $exception, $exception->getInvalidMessage(), $exception->getInvalidMessageParameters());
}
return $value;
} | [
"private",
"function",
"viewToNorm",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"transformers",
"=",
"$",
"this",
"->",
"config",
"->",
"getViewTransformers",
"(",
")",
")",
"{",
"return",
"''",
"===",
"$",
"value",
"?",
"null",
":",
"$",
"val... | Reverse transforms a value if a view transformer is set.
@param string $value The value to reverse transform
@return mixed
@throws TransformationFailedException If the submitted value cannot be transformed to "normalized" format | [
"Reverse",
"transforms",
"a",
"value",
"if",
"a",
"view",
"transformer",
"is",
"set",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Form.php#L1129-L1144 | train | Reverse transforms the value if a view transformer is set. | [
30522,
2797,
3853,
3193,
2669,
2953,
2213,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
999,
1002,
19081,
1027,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1011,
1028,
2131,
8584,
6494,
3619,
14192,
2545,
1006,
1007,
1007,
1063,
2709,
1005,
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/Intl/DateFormatter/IntlDateFormatter.php | IntlDateFormatter.getDefaultPattern | protected function getDefaultPattern()
{
$patternParts = [];
if (self::NONE !== $this->datetype) {
$patternParts[] = $this->defaultDateFormats[$this->datetype];
}
if (self::NONE !== $this->timetype) {
$patternParts[] = $this->defaultTimeFormats[$this->timetype];
}
return implode(', ', $patternParts);
} | php | protected function getDefaultPattern()
{
$patternParts = [];
if (self::NONE !== $this->datetype) {
$patternParts[] = $this->defaultDateFormats[$this->datetype];
}
if (self::NONE !== $this->timetype) {
$patternParts[] = $this->defaultTimeFormats[$this->timetype];
}
return implode(', ', $patternParts);
} | [
"protected",
"function",
"getDefaultPattern",
"(",
")",
"{",
"$",
"patternParts",
"=",
"[",
"]",
";",
"if",
"(",
"self",
"::",
"NONE",
"!==",
"$",
"this",
"->",
"datetype",
")",
"{",
"$",
"patternParts",
"[",
"]",
"=",
"$",
"this",
"->",
"defaultDateFo... | Returns a pattern string based in the datetype and timetype values.
@return string | [
"Returns",
"a",
"pattern",
"string",
"based",
"in",
"the",
"datetype",
"and",
"timetype",
"values",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php#L601-L612 | train | Returns the default pattern for the date format | [
30522,
5123,
3853,
2131,
3207,
7011,
11314,
4502,
12079,
2078,
1006,
1007,
1063,
1002,
5418,
26950,
1027,
1031,
1033,
1025,
2065,
1006,
2969,
1024,
1024,
3904,
999,
1027,
1027,
1002,
2023,
1011,
1028,
3058,
13874,
1007,
1063,
1002,
5418,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ReverseContainer.php | ReverseContainer.getId | public function getId($service): ?string
{
if ($this->serviceContainer === $service) {
return 'service_container';
}
if (null === $id = ($this->getServiceId)($service)) {
return null;
}
if ($this->serviceContainer->has($id) || $this->reversibleLocator->has($id)) {
return $id;
}
return null;
} | php | public function getId($service): ?string
{
if ($this->serviceContainer === $service) {
return 'service_container';
}
if (null === $id = ($this->getServiceId)($service)) {
return null;
}
if ($this->serviceContainer->has($id) || $this->reversibleLocator->has($id)) {
return $id;
}
return null;
} | [
"public",
"function",
"getId",
"(",
"$",
"service",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"serviceContainer",
"===",
"$",
"service",
")",
"{",
"return",
"'service_container'",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"id",
"=",
... | Returns the id of the passed object when it exists as a service.
To be reversible, services need to be either public or be tagged with "container.reversible".
@param object $service | [
"Returns",
"the",
"id",
"of",
"the",
"passed",
"object",
"when",
"it",
"exists",
"as",
"a",
"service",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/ReverseContainer.php#L46-L61 | train | Get the id of a service | [
30522,
2270,
3853,
2131,
3593,
1006,
1002,
2326,
1007,
1024,
1029,
5164,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2326,
8663,
18249,
2121,
1027,
1027,
1027,
1002,
2326,
1007,
1063,
2709,
1005,
2326,
1035,
11661,
1005,
1025,
1065,
2065,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Request.php | Request.getBasePath | public function getBasePath()
{
if (null === $this->basePath) {
$this->basePath = $this->prepareBasePath();
}
return $this->basePath;
} | php | public function getBasePath()
{
if (null === $this->basePath) {
$this->basePath = $this->prepareBasePath();
}
return $this->basePath;
} | [
"public",
"function",
"getBasePath",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"basePath",
")",
"{",
"$",
"this",
"->",
"basePath",
"=",
"$",
"this",
"->",
"prepareBasePath",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"basePat... | Returns the root path from which this request is executed.
Suppose that an index.php file instantiates this request object:
* http://localhost/index.php returns an empty string
* http://localhost/index.php/page returns an empty string
* http://localhost/web/index.php returns '/web'
* http://localhost/we%20b/index.php returns '/we%20b'
@return string The raw path (i.e. not urldecoded) | [
"Returns",
"the",
"root",
"path",
"from",
"which",
"this",
"request",
"is",
"executed",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Request.php#L852-L859 | train | Get Base Path | [
30522,
2270,
3853,
2131,
15058,
15069,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
2918,
15069,
1007,
1063,
1002,
2023,
1011,
1028,
2918,
15069,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Work/User/TagClient.php | TagClient.create | public function create(string $tagName, int $tagId = null)
{
$params = [
'tagname' => $tagName,
'tagid' => $tagId,
];
return $this->httpPostJson('cgi-bin/tag/create', $params);
} | php | public function create(string $tagName, int $tagId = null)
{
$params = [
'tagname' => $tagName,
'tagid' => $tagId,
];
return $this->httpPostJson('cgi-bin/tag/create', $params);
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"tagName",
",",
"int",
"$",
"tagId",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"[",
"'tagname'",
"=>",
"$",
"tagName",
",",
"'tagid'",
"=>",
"$",
"tagId",
",",
"]",
";",
"return",
"$",
"this",
"-... | Create tag.
@param string $tagName
@param int|null $tagId
@return mixed | [
"Create",
"tag",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Work/User/TagClient.php#L31-L39 | train | Create a new tag | [
30522,
2270,
3853,
3443,
1006,
5164,
1002,
6415,
18442,
1010,
20014,
1002,
6415,
3593,
1027,
19701,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
6415,
30524,
22578,
2239,
1006,
1005,
1039,
5856,
1011,
8026,
1013,
6415,
1013,
3443,
1005,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Ibm.php | Zend_Db_Adapter_Pdo_Ibm.limit | public function limit($sql, $count, $offset = 0)
{
$this->_connect();
return $this->_serverType->limit($sql, $count, $offset);
} | php | public function limit($sql, $count, $offset = 0)
{
$this->_connect();
return $this->_serverType->limit($sql, $count, $offset);
} | [
"public",
"function",
"limit",
"(",
"$",
"sql",
",",
"$",
"count",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"return",
"$",
"this",
"->",
"_serverType",
"->",
"limit",
"(",
"$",
"sql",
",",
"$",
"count"... | Adds an adapter-specific LIMIT clause to the SELECT statement.
@param string $sql
@param integer $count
@param integer $offset OPTIONAL
@return string | [
"Adds",
"an",
"adapter",
"-",
"specific",
"LIMIT",
"clause",
"to",
"the",
"SELECT",
"statement",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Ibm.php#L280-L284 | train | Limit the number of records in the server | [
30522,
2270,
3853,
5787,
1006,
1002,
29296,
1010,
1002,
4175,
1010,
1002,
16396,
1027,
1014,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
2709,
1002,
2023,
1011,
1028,
1035,
8241,
13874,
1011,
1028,
5787,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Twig/Extension/CodeExtension.php | CodeExtension.formatFile | public function formatFile($file, $line, $text = null)
{
$file = trim($file);
if (null === $text) {
$text = $file;
if (null !== $rel = $this->getFileRelative($text)) {
$rel = explode('/', $rel, 2);
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->projectDir, $rel[0], '/'.($rel[1] ?? ''));
}
}
if (0 < $line) {
$text .= ' at line '.$line;
}
if (false !== $link = $this->getFileLink($file, $line)) {
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset), $text);
}
return $text;
} | php | public function formatFile($file, $line, $text = null)
{
$file = trim($file);
if (null === $text) {
$text = $file;
if (null !== $rel = $this->getFileRelative($text)) {
$rel = explode('/', $rel, 2);
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->projectDir, $rel[0], '/'.($rel[1] ?? ''));
}
}
if (0 < $line) {
$text .= ' at line '.$line;
}
if (false !== $link = $this->getFileLink($file, $line)) {
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_COMPAT | ENT_SUBSTITUTE, $this->charset), $text);
}
return $text;
} | [
"public",
"function",
"formatFile",
"(",
"$",
"file",
",",
"$",
"line",
",",
"$",
"text",
"=",
"null",
")",
"{",
"$",
"file",
"=",
"trim",
"(",
"$",
"file",
")",
";",
"if",
"(",
"null",
"===",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"$",
"fi... | Formats a file path.
@param string $file An absolute file path
@param int $line The line number
@param string $text Use this text for the link rather than the file path
@return string | [
"Formats",
"a",
"file",
"path",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/Extension/CodeExtension.php#L174-L195 | train | Format a file | [
30522,
2270,
3853,
4289,
8873,
2571,
1006,
1002,
5371,
1010,
1002,
2240,
1010,
1002,
3793,
1027,
19701,
1007,
1063,
1002,
5371,
1027,
12241,
1006,
1002,
5371,
1007,
1025,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
3793,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php | GetSetMethodNormalizer.setAttributeValue | protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = [])
{
$setter = 'set'.ucfirst($attribute);
$key = \get_class($object).':'.$setter;
if (!isset(self::$setterAccessibleCache[$key])) {
self::$setterAccessibleCache[$key] = \is_callable([$object, $setter]) && !(new \ReflectionMethod($object, $setter))->isStatic();
}
if (self::$setterAccessibleCache[$key]) {
$object->$setter($value);
}
} | php | protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = [])
{
$setter = 'set'.ucfirst($attribute);
$key = \get_class($object).':'.$setter;
if (!isset(self::$setterAccessibleCache[$key])) {
self::$setterAccessibleCache[$key] = \is_callable([$object, $setter]) && !(new \ReflectionMethod($object, $setter))->isStatic();
}
if (self::$setterAccessibleCache[$key]) {
$object->$setter($value);
}
} | [
"protected",
"function",
"setAttributeValue",
"(",
"$",
"object",
",",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"setter",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php#L147-L159 | train | Set the value of an attribute on an object | [
30522,
5123,
3853,
2275,
19321,
3089,
8569,
2618,
10175,
5657,
1006,
1002,
4874,
1010,
1002,
17961,
1010,
1002,
3643,
1010,
1002,
4289,
1027,
19701,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
1002,
2275,
3334,
1027,
1005,
2275,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/DatabaseStore.php | DatabaseStore.incrementOrDecrement | protected function incrementOrDecrement($key, $value, Closure $callback)
{
return $this->connection->transaction(function () use ($key, $value, $callback) {
$prefixed = $this->prefix.$key;
$cache = $this->table()->where('key', $prefixed)
->lockForUpdate()->first();
// If there is no value in the cache, we will return false here. Otherwise the
// value will be decrypted and we will proceed with this function to either
// increment or decrement this value based on the given action callbacks.
if (is_null($cache)) {
return false;
}
$cache = is_array($cache) ? (object) $cache : $cache;
$current = $this->unserialize($cache->value);
// Here we'll call this callback function that was given to the function which
// is used to either increment or decrement the function. We use a callback
// so we do not have to recreate all this logic in each of the functions.
$new = $callback((int) $current, $value);
if (! is_numeric($current)) {
return false;
}
// Here we will update the values in the table. We will also encrypt the value
// since database cache values are encrypted by default with secure storage
// that can't be easily read. We will return the new value after storing.
$this->table()->where('key', $prefixed)->update([
'value' => $this->serialize($new),
]);
return $new;
});
} | php | protected function incrementOrDecrement($key, $value, Closure $callback)
{
return $this->connection->transaction(function () use ($key, $value, $callback) {
$prefixed = $this->prefix.$key;
$cache = $this->table()->where('key', $prefixed)
->lockForUpdate()->first();
// If there is no value in the cache, we will return false here. Otherwise the
// value will be decrypted and we will proceed with this function to either
// increment or decrement this value based on the given action callbacks.
if (is_null($cache)) {
return false;
}
$cache = is_array($cache) ? (object) $cache : $cache;
$current = $this->unserialize($cache->value);
// Here we'll call this callback function that was given to the function which
// is used to either increment or decrement the function. We use a callback
// so we do not have to recreate all this logic in each of the functions.
$new = $callback((int) $current, $value);
if (! is_numeric($current)) {
return false;
}
// Here we will update the values in the table. We will also encrypt the value
// since database cache values are encrypted by default with secure storage
// that can't be easily read. We will return the new value after storing.
$this->table()->where('key', $prefixed)->update([
'value' => $this->serialize($new),
]);
return $new;
});
} | [
"protected",
"function",
"incrementOrDecrement",
"(",
"$",
"key",
",",
"$",
"value",
",",
"Closure",
"$",
"callback",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"key",
",",
"$",
... | Increment or decrement an item in the cache.
@param string $key
@param mixed $value
@param \Closure $callback
@return int|bool | [
"Increment",
"or",
"decrement",
"an",
"item",
"in",
"the",
"cache",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/DatabaseStore.php#L147-L184 | train | Increments or decrements the value of the cache | [
30522,
5123,
3853,
4297,
28578,
4765,
8551,
8586,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
8503,
1002,
2655,
5963,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4434,
1011,
1028,
12598,
1006,
3853,
1006,
1007,
2224,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Log/Logger.php | Logger.log | public function log($level, $message, array $context = [])
{
if (!isset(self::$levels[$level])) {
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
}
if (self::$levels[$level] < $this->minLevelIndex) {
return;
}
$formatter = $this->formatter;
fwrite($this->handle, $formatter($level, $message, $context));
} | php | public function log($level, $message, array $context = [])
{
if (!isset(self::$levels[$level])) {
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
}
if (self::$levels[$level] < $this->minLevelIndex) {
return;
}
$formatter = $this->formatter;
fwrite($this->handle, $formatter($level, $message, $context));
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"levels",
"[",
"$",
"level",
"]",
")",
")",
"{",
"throw",
"new",
"Inval... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Log/Logger.php#L69-L81 | train | Write a message to the log file | [
30522,
2270,
3853,
8833,
1006,
1002,
2504,
1010,
1002,
4471,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
2969,
1024,
1024,
1002,
3798,
1031,
30524,
1065,
2065,
1006,
2969,
1024,
1024,
1002,
37... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Piwik.php | Piwik.exitWithErrorMessage | public static function exitWithErrorMessage($message)
{
Common::sendHeader('Content-Type: text/html; charset=utf-8');
$message = str_replace("\n", "<br/>", $message);
$output = "<html><body>".
"<style>a{color:red;}</style>\n" .
"<div style='color:red;font-size:120%; width:100%;margin: 30px;'>" .
" <div style='width: 50px; float: left;'><img src='plugins/Morpheus/images/error_medium.png' /></div>" .
" <div style='margin-left: 70px; min-width: 950px;'>" .
$message .
" </div>" .
" </div>" .
"</div>".
"</body></html>";
print($output);
exit;
} | php | public static function exitWithErrorMessage($message)
{
Common::sendHeader('Content-Type: text/html; charset=utf-8');
$message = str_replace("\n", "<br/>", $message);
$output = "<html><body>".
"<style>a{color:red;}</style>\n" .
"<div style='color:red;font-size:120%; width:100%;margin: 30px;'>" .
" <div style='width: 50px; float: left;'><img src='plugins/Morpheus/images/error_medium.png' /></div>" .
" <div style='margin-left: 70px; min-width: 950px;'>" .
$message .
" </div>" .
" </div>" .
"</div>".
"</body></html>";
print($output);
exit;
} | [
"public",
"static",
"function",
"exitWithErrorMessage",
"(",
"$",
"message",
")",
"{",
"Common",
"::",
"sendHeader",
"(",
"'Content-Type: text/html; charset=utf-8'",
")",
";",
"$",
"message",
"=",
"str_replace",
"(",
"\"\\n\"",
",",
"\"<br/>\"",
",",
"$",
"message... | Display the message in a nice red font with a nice icon
... and dies
@param string $message | [
"Display",
"the",
"message",
"in",
"a",
"nice",
"red",
"font",
"with",
"a",
"nice",
"icon",
"...",
"and",
"dies"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L76-L94 | train | Exit with error message | [
30522,
2270,
10763,
3853,
6164,
24415,
2121,
29165,
7834,
3736,
3351,
1006,
1002,
4471,
1007,
1063,
2691,
1024,
1024,
4604,
4974,
2121,
1006,
1005,
4180,
1011,
2828,
1024,
3793,
1013,
16129,
1025,
25869,
13462,
1027,
21183,
2546,
1011,
1022... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/SwitchUserToken.php | SwitchUserToken.__unserialize | public function __unserialize(array $data): void
{
[$this->originalToken, $parentData] = $data;
parent::__unserialize($parentData);
} | php | public function __unserialize(array $data): void
{
[$this->originalToken, $parentData] = $data;
parent::__unserialize($parentData);
} | [
"public",
"function",
"__unserialize",
"(",
"array",
"$",
"data",
")",
":",
"void",
"{",
"[",
"$",
"this",
"->",
"originalToken",
",",
"$",
"parentData",
"]",
"=",
"$",
"data",
";",
"parent",
"::",
"__unserialize",
"(",
"$",
"parentData",
")",
";",
"}"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php#L55-L59 | train | Unserialize the data array | [
30522,
2270,
3853,
1035,
1035,
4895,
8043,
4818,
4697,
1006,
9140,
1002,
2951,
1007,
1024,
11675,
1063,
1031,
1002,
2023,
1011,
1028,
2434,
18715,
2368,
1010,
1002,
6687,
2850,
2696,
1033,
1027,
1002,
2951,
1025,
6687,
1024,
1024,
1035,
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/Http/Resources/Json/ResourceResponse.php | ResourceResponse.wrap | protected function wrap($data, $with = [], $additional = [])
{
if ($data instanceof Collection) {
$data = $data->all();
}
if ($this->haveDefaultWrapperAndDataIsUnwrapped($data)) {
$data = [$this->wrapper() => $data];
} elseif ($this->haveAdditionalInformationAndDataIsUnwrapped($data, $with, $additional)) {
$data = [($this->wrapper() ?? 'data') => $data];
}
return array_merge_recursive($data, $with, $additional);
} | php | protected function wrap($data, $with = [], $additional = [])
{
if ($data instanceof Collection) {
$data = $data->all();
}
if ($this->haveDefaultWrapperAndDataIsUnwrapped($data)) {
$data = [$this->wrapper() => $data];
} elseif ($this->haveAdditionalInformationAndDataIsUnwrapped($data, $with, $additional)) {
$data = [($this->wrapper() ?? 'data') => $data];
}
return array_merge_recursive($data, $with, $additional);
} | [
"protected",
"function",
"wrap",
"(",
"$",
"data",
",",
"$",
"with",
"=",
"[",
"]",
",",
"$",
"additional",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Collection",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"->",
"all",
"(",
... | Wrap the given data if necessary.
@param array $data
@param array $with
@param array $additional
@return array | [
"Wrap",
"the",
"given",
"data",
"if",
"necessary",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Resources/Json/ResourceResponse.php#L59-L72 | train | Wrap data with the wrapper | [
30522,
5123,
3853,
10236,
1006,
1002,
2951,
1010,
1002,
2007,
1027,
1031,
1033,
1010,
1002,
3176,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
2951,
6013,
11253,
3074,
1007,
1063,
1002,
2951,
1027,
1002,
2951,
1011,
1028,
2035,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Process/Process.php | Process.getOutput | public function getOutput()
{
$this->readPipesForOutput(__FUNCTION__);
if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
return '';
}
return $ret;
} | php | public function getOutput()
{
$this->readPipesForOutput(__FUNCTION__);
if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
return '';
}
return $ret;
} | [
"public",
"function",
"getOutput",
"(",
")",
"{",
"$",
"this",
"->",
"readPipesForOutput",
"(",
"__FUNCTION__",
")",
";",
"if",
"(",
"false",
"===",
"$",
"ret",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"stdout",
",",
"-",
"1",
",",
"0",
")",... | Returns the current output of the process (STDOUT).
@return string The process output
@throws LogicException in case the output has been disabled
@throws LogicException In case the process is not started | [
"Returns",
"the",
"current",
"output",
"of",
"the",
"process",
"(",
"STDOUT",
")",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L563-L572 | train | Get the output of the command | [
30522,
2270,
3853,
2131,
5833,
18780,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
3191,
24548,
22747,
14604,
4904,
18780,
1006,
1035,
1035,
3853,
1035,
1035,
1007,
1025,
2065,
1006,
6270,
1027,
1027,
1027,
1002,
2128,
2102,
1027,
5460,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php | AddAnnotatedClassesToCachePass.expandClasses | private function expandClasses(array $patterns, array $classes)
{
$expanded = [];
// Explicit classes declared in the patterns are returned directly
foreach ($patterns as $key => $pattern) {
if ('\\' !== substr($pattern, -1) && false === strpos($pattern, '*')) {
unset($patterns[$key]);
$expanded[] = ltrim($pattern, '\\');
}
}
// Match patterns with the classes list
$regexps = $this->patternsToRegexps($patterns);
foreach ($classes as $class) {
$class = ltrim($class, '\\');
if ($this->matchAnyRegexps($class, $regexps)) {
$expanded[] = $class;
}
}
return array_unique($expanded);
} | php | private function expandClasses(array $patterns, array $classes)
{
$expanded = [];
// Explicit classes declared in the patterns are returned directly
foreach ($patterns as $key => $pattern) {
if ('\\' !== substr($pattern, -1) && false === strpos($pattern, '*')) {
unset($patterns[$key]);
$expanded[] = ltrim($pattern, '\\');
}
}
// Match patterns with the classes list
$regexps = $this->patternsToRegexps($patterns);
foreach ($classes as $class) {
$class = ltrim($class, '\\');
if ($this->matchAnyRegexps($class, $regexps)) {
$expanded[] = $class;
}
}
return array_unique($expanded);
} | [
"private",
"function",
"expandClasses",
"(",
"array",
"$",
"patterns",
",",
"array",
"$",
"classes",
")",
"{",
"$",
"expanded",
"=",
"[",
"]",
";",
"// Explicit classes declared in the patterns are returned directly",
"foreach",
"(",
"$",
"patterns",
"as",
"$",
"k... | Expands the given class patterns using a list of existing classes.
@param array $patterns The class patterns to expand
@param array $classes The existing classes to match against the patterns
@return array A list of classes derived from the patterns | [
"Expands",
"the",
"given",
"class",
"patterns",
"using",
"a",
"list",
"of",
"existing",
"classes",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php#L60-L84 | train | Expands the class names of the patterns and the classes list | [
30522,
2797,
3853,
7818,
26266,
2229,
1006,
9140,
1002,
7060,
1010,
9140,
1002,
4280,
1007,
1063,
1002,
4423,
1027,
1031,
1033,
1025,
1013,
1013,
13216,
4280,
4161,
1999,
1996,
7060,
2024,
2513,
3495,
18921,
6776,
1006,
1002,
7060,
2004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Visualization/Sparkline.php | Sparkline.setHeight | public function setHeight($height) {
if (!is_numeric($height) || $height <= 0) {
return;
}
if ($height > self::MAX_HEIGHT) {
$this->_height = self::MAX_HEIGHT;
} else {
$this->_height = (int)$height;
}
} | php | public function setHeight($height) {
if (!is_numeric($height) || $height <= 0) {
return;
}
if ($height > self::MAX_HEIGHT) {
$this->_height = self::MAX_HEIGHT;
} else {
$this->_height = (int)$height;
}
} | [
"public",
"function",
"setHeight",
"(",
"$",
"height",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"height",
")",
"||",
"$",
"height",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"height",
">",
"self",
"::",
"MAX_HEIGHT",
")",
... | Sets the height of the sparkline
@param int $height | [
"Sets",
"the",
"height",
"of",
"the",
"sparkline"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Visualization/Sparkline.php#L139-L148 | train | Set height of the image | [
30522,
2270,
3853,
6662,
7416,
13900,
1006,
1002,
4578,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16371,
25531,
1006,
1002,
4578,
1007,
1064,
1064,
1002,
4578,
1026,
1027,
1014,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
1002,
4578,
1028,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.resetPages | public function resetPages($pages_dir)
{
$this->recurse($pages_dir);
$this->buildRoutes();
// cache if needed
if ($this->grav['config']->get('system.cache.enabled')) {
/** @var Cache $cache */
$cache = $this->grav['cache'];
/** @var Taxonomy $taxonomy */
$taxonomy = $this->grav['taxonomy'];
// save pages, routes, taxonomy, and sort to cache
$cache->save($this->pages_cache_id, [$this->instances, $this->routes, $this->children, $taxonomy->taxonomy(), $this->sort]);
}
} | php | public function resetPages($pages_dir)
{
$this->recurse($pages_dir);
$this->buildRoutes();
// cache if needed
if ($this->grav['config']->get('system.cache.enabled')) {
/** @var Cache $cache */
$cache = $this->grav['cache'];
/** @var Taxonomy $taxonomy */
$taxonomy = $this->grav['taxonomy'];
// save pages, routes, taxonomy, and sort to cache
$cache->save($this->pages_cache_id, [$this->instances, $this->routes, $this->children, $taxonomy->taxonomy(), $this->sort]);
}
} | [
"public",
"function",
"resetPages",
"(",
"$",
"pages_dir",
")",
"{",
"$",
"this",
"->",
"recurse",
"(",
"$",
"pages_dir",
")",
";",
"$",
"this",
"->",
"buildRoutes",
"(",
")",
";",
"// cache if needed",
"if",
"(",
"$",
"this",
"->",
"grav",
"[",
"'conf... | Accessible method to manually reset the pages cache
@param string $pages_dir | [
"Accessible",
"method",
"to",
"manually",
"reset",
"the",
"pages",
"cache"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L1002-L1017 | train | Recurse through pages and build routes and save to cache | [
30522,
2270,
3853,
25141,
13704,
2015,
1006,
1002,
5530,
1035,
16101,
1007,
1063,
1002,
2023,
1011,
1028,
28667,
28393,
1006,
1002,
5530,
1035,
16101,
1007,
1025,
1002,
2023,
1011,
1028,
3857,
22494,
4570,
1006,
1007,
1025,
1013,
1013,
1705... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Formatter/MessageFormatter.php | MessageFormatter.choiceFormat | public function choiceFormat($message, $number, $locale, array $parameters = [])
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the format() one instead with a %%count%% parameter.', __METHOD__), E_USER_DEPRECATED);
$parameters = ['%count%' => $number] + $parameters;
if ($this->translator instanceof TranslatorInterface) {
return $this->format($message, $locale, $parameters);
}
return $this->format($this->translator->transChoice($message, $number, [], null, $locale), $locale, $parameters);
} | php | public function choiceFormat($message, $number, $locale, array $parameters = [])
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the format() one instead with a %%count%% parameter.', __METHOD__), E_USER_DEPRECATED);
$parameters = ['%count%' => $number] + $parameters;
if ($this->translator instanceof TranslatorInterface) {
return $this->format($message, $locale, $parameters);
}
return $this->format($this->translator->transChoice($message, $number, [], null, $locale), $locale, $parameters);
} | [
"public",
"function",
"choiceFormat",
"(",
"$",
"message",
",",
"$",
"number",
",",
"$",
"locale",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'The \"%s()\" method is deprecated since Symfony 4.2, use the f... | {@inheritdoc}
@deprecated since Symfony 4.2, use format() with a %count% parameter instead | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Formatter/MessageFormatter.php#L67-L78 | train | Formats a message with the given number in the given locale. | [
30522,
2270,
3853,
3601,
14192,
4017,
1006,
1002,
4471,
1010,
1002,
2193,
1010,
1002,
2334,
2063,
1010,
9140,
1002,
11709,
1027,
1031,
1033,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
1996,
1000,
1003,
1055,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Process/Process.php | Process.isTtySupported | public static function isTtySupported(): bool
{
static $isTtySupported;
if (null === $isTtySupported) {
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
}
return $isTtySupported;
} | php | public static function isTtySupported(): bool
{
static $isTtySupported;
if (null === $isTtySupported) {
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file', '/dev/tty', 'r'], ['file', '/dev/tty', 'w'], ['file', '/dev/tty', 'w']], $pipes);
}
return $isTtySupported;
} | [
"public",
"static",
"function",
"isTtySupported",
"(",
")",
":",
"bool",
"{",
"static",
"$",
"isTtySupported",
";",
"if",
"(",
"null",
"===",
"$",
"isTtySupported",
")",
"{",
"$",
"isTtySupported",
"=",
"(",
"bool",
")",
"@",
"proc_open",
"(",
"'echo 1 >/d... | Returns whether TTY is supported on the current operating system. | [
"Returns",
"whether",
"TTY",
"is",
"supported",
"on",
"the",
"current",
"operating",
"system",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L1249-L1258 | train | Is the terminal supported? | [
30522,
2270,
10763,
3853,
21541,
3723,
6342,
9397,
15613,
1006,
1007,
1024,
22017,
2140,
1063,
10763,
1002,
21541,
3723,
6342,
9397,
15613,
1025,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
21541,
3723,
6342,
9397,
15613,
1007,
1063,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php | EntryManager.update | public function update(Entry $entry)
{
$con = $this->getConnectionResource();
if (!@ldap_modify($con, $entry->getDn(), $entry->getAttributes())) {
throw new LdapException(sprintf('Could not update entry "%s": %s.', $entry->getDn(), ldap_error($con)));
}
} | php | public function update(Entry $entry)
{
$con = $this->getConnectionResource();
if (!@ldap_modify($con, $entry->getDn(), $entry->getAttributes())) {
throw new LdapException(sprintf('Could not update entry "%s": %s.', $entry->getDn(), ldap_error($con)));
}
} | [
"public",
"function",
"update",
"(",
"Entry",
"$",
"entry",
")",
"{",
"$",
"con",
"=",
"$",
"this",
"->",
"getConnectionResource",
"(",
")",
";",
"if",
"(",
"!",
"@",
"ldap_modify",
"(",
"$",
"con",
",",
"$",
"entry",
"->",
"getDn",
"(",
")",
",",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php#L50-L57 | train | Update an entry | [
30522,
2270,
3853,
10651,
1006,
4443,
1002,
4443,
1007,
1063,
1002,
9530,
1027,
1002,
2023,
1011,
1028,
2131,
8663,
2638,
7542,
6072,
8162,
3401,
1006,
1007,
1025,
2065,
1006,
999,
1030,
25510,
9331,
1035,
19933,
1006,
1002,
9530,
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... |
symfony/symfony | src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php | DoctrineOrmTypeGuesser.guessPattern | public function guessPattern($class, $property)
{
$ret = $this->getMetadata($class);
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
if (\in_array($ret[0]->getTypeOfField($property), [Type::DECIMAL, Type::FLOAT])) {
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
}
}
} | php | public function guessPattern($class, $property)
{
$ret = $this->getMetadata($class);
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
if (\in_array($ret[0]->getTypeOfField($property), [Type::DECIMAL, Type::FLOAT])) {
return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
}
}
} | [
"public",
"function",
"guessPattern",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"ret",
"&&",
"isset",
"(",
"$",
"ret",
"[",
"0",
"]",
"->",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php#L154-L162 | train | Guesses the pattern for a property of a class. | [
30522,
2270,
3853,
3984,
4502,
12079,
2078,
1006,
1002,
2465,
1010,
1002,
3200,
1007,
1063,
1002,
2128,
2102,
1027,
1002,
2023,
1011,
1028,
2131,
11368,
8447,
2696,
1006,
1002,
2465,
1007,
1025,
2065,
1006,
1002,
2128,
2102,
1004,
1004,
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... |
symfony/symfony | src/Symfony/Component/Console/Output/StreamOutput.php | StreamOutput.doWrite | protected function doWrite($message, $newline)
{
if ($newline) {
$message .= PHP_EOL;
}
if (false === @fwrite($this->stream, $message)) {
// should never happen
throw new RuntimeException('Unable to write output.');
}
fflush($this->stream);
} | php | protected function doWrite($message, $newline)
{
if ($newline) {
$message .= PHP_EOL;
}
if (false === @fwrite($this->stream, $message)) {
// should never happen
throw new RuntimeException('Unable to write output.');
}
fflush($this->stream);
} | [
"protected",
"function",
"doWrite",
"(",
"$",
"message",
",",
"$",
"newline",
")",
"{",
"if",
"(",
"$",
"newline",
")",
"{",
"$",
"message",
".=",
"PHP_EOL",
";",
"}",
"if",
"(",
"false",
"===",
"@",
"fwrite",
"(",
"$",
"this",
"->",
"stream",
",",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Output/StreamOutput.php#L71-L83 | train | Write a message to the output stream | [
30522,
5123,
3853,
23268,
17625,
1006,
1002,
4471,
1010,
1002,
2047,
4179,
1007,
1063,
2065,
1006,
1002,
2047,
4179,
1007,
1063,
1002,
4471,
1012,
1027,
25718,
1035,
1041,
4747,
1025,
1065,
2065,
1006,
6270,
1027,
1027,
1027,
1030,
1042,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ResolveTaggedIteratorArgumentPass.php | ResolveTaggedIteratorArgumentPass.processValue | protected function processValue($value, $isRoot = false)
{
if (!$value instanceof TaggedIteratorArgument) {
return parent::processValue($value, $isRoot);
}
$value->setValues($this->findAndSortTaggedServices($value, $this->container));
return $value;
} | php | protected function processValue($value, $isRoot = false)
{
if (!$value instanceof TaggedIteratorArgument) {
return parent::processValue($value, $isRoot);
}
$value->setValues($this->findAndSortTaggedServices($value, $this->container));
return $value;
} | [
"protected",
"function",
"processValue",
"(",
"$",
"value",
",",
"$",
"isRoot",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"TaggedIteratorArgument",
")",
"{",
"return",
"parent",
"::",
"processValue",
"(",
"$",
"value",
",",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/ResolveTaggedIteratorArgumentPass.php#L28-L37 | train | Process value of type TaggedIteratorArgument | [
30522,
5123,
3853,
2832,
10175,
5657,
1006,
1002,
3643,
1010,
1002,
2003,
3217,
4140,
1027,
6270,
1007,
1063,
2065,
1006,
999,
1002,
3643,
6013,
11253,
26610,
21646,
8844,
2906,
22850,
4765,
1007,
1063,
2709,
6687,
1024,
1024,
2832,
10175,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select.joinFull | public function joinFull($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
{
return $this->_join(self::FULL_JOIN, $name, $cond, $cols, $schema);
} | php | public function joinFull($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
{
return $this->_join(self::FULL_JOIN, $name, $cond, $cols, $schema);
} | [
"public",
"function",
"joinFull",
"(",
"$",
"name",
",",
"$",
"cond",
",",
"$",
"cols",
"=",
"self",
"::",
"SQL_WILDCARD",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_join",
"(",
"self",
"::",
"FULL_JOIN",
",",
"$",
"n... | Add a FULL OUTER JOIN table and colums to the query.
A full outer join is like combining a left outer join
and a right outer join. All rows from both tables are
included, paired with each other on the same row of the
result set if they satisfy the join condition, and otherwise
paired with NULLs in place of columns from the other table.
The $name and $cols parameters follow the same logic
as described in the from() method.
@param array|string|Zend_Db_Expr $name The table name.
@param string $cond Join on this condition.
@param array|string $cols The columns to select from the joined table.
@param string $schema The database name to specify, if any.
@return Zend_Db_Select This Zend_Db_Select object. | [
"Add",
"a",
"FULL",
"OUTER",
"JOIN",
"table",
"and",
"colums",
"to",
"the",
"query",
".",
"A",
"full",
"outer",
"join",
"is",
"like",
"combining",
"a",
"left",
"outer",
"join",
"and",
"a",
"right",
"outer",
"join",
".",
"All",
"rows",
"from",
"both",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L399-L402 | train | Join a table with a full join | [
30522,
2270,
3853,
3693,
3993,
2140,
1006,
1002,
2171,
1010,
1002,
9530,
2094,
1010,
1002,
8902,
2015,
1027,
2969,
1024,
1024,
29296,
1035,
3748,
11522,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/controllers/Settings.php | Settings.formRender | public function formRender($options = [])
{
if (!$this->formWidget) {
throw new ApplicationException(Lang::get('backend::lang.form.behavior_not_ready'));
}
return $this->formWidget->render($options);
} | php | public function formRender($options = [])
{
if (!$this->formWidget) {
throw new ApplicationException(Lang::get('backend::lang.form.behavior_not_ready'));
}
return $this->formWidget->render($options);
} | [
"public",
"function",
"formRender",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"formWidget",
")",
"{",
"throw",
"new",
"ApplicationException",
"(",
"Lang",
"::",
"get",
"(",
"'backend::lang.form.behavior_not_ready'",
")"... | Render the form. | [
"Render",
"the",
"form",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/controllers/Settings.php#L133-L140 | train | Render the form | [
30522,
2270,
3853,
2433,
7389,
4063,
1006,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2433,
9148,
24291,
1007,
1063,
5466,
2047,
4646,
10288,
24422,
1006,
11374,
1024,
1024,
2131,
1006,
1005,
2067,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php | QueriesRelationships.has | public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
{
if (strpos($relation, '.') !== false) {
return $this->hasNested($relation, $operator, $count, $boolean, $callback);
}
$relation = $this->getRelationWithoutConstraints($relation);
if ($relation instanceof MorphTo) {
throw new RuntimeException('has() and whereHas() do not support MorphTo relationships.');
}
// If we only need to check for the existence of the relation, then we can optimize
// the subquery to only run a "where exists" clause instead of this full "count"
// clause. This will make these queries run much faster compared with a count.
$method = $this->canUseExistsForExistenceCheck($operator, $count)
? 'getRelationExistenceQuery'
: 'getRelationExistenceCountQuery';
$hasQuery = $relation->{$method}(
$relation->getRelated()->newQueryWithoutRelationships(), $this
);
// Next we will call any given callback as an "anonymous" scope so they can get the
// proper logical grouping of the where clauses if needed by this Eloquent query
// builder. Then, we will be ready to finalize and return this query instance.
if ($callback) {
$hasQuery->callScope($callback);
}
return $this->addHasWhere(
$hasQuery, $relation, $operator, $count, $boolean
);
} | php | public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
{
if (strpos($relation, '.') !== false) {
return $this->hasNested($relation, $operator, $count, $boolean, $callback);
}
$relation = $this->getRelationWithoutConstraints($relation);
if ($relation instanceof MorphTo) {
throw new RuntimeException('has() and whereHas() do not support MorphTo relationships.');
}
// If we only need to check for the existence of the relation, then we can optimize
// the subquery to only run a "where exists" clause instead of this full "count"
// clause. This will make these queries run much faster compared with a count.
$method = $this->canUseExistsForExistenceCheck($operator, $count)
? 'getRelationExistenceQuery'
: 'getRelationExistenceCountQuery';
$hasQuery = $relation->{$method}(
$relation->getRelated()->newQueryWithoutRelationships(), $this
);
// Next we will call any given callback as an "anonymous" scope so they can get the
// proper logical grouping of the where clauses if needed by this Eloquent query
// builder. Then, we will be ready to finalize and return this query instance.
if ($callback) {
$hasQuery->callScope($callback);
}
return $this->addHasWhere(
$hasQuery, $relation, $operator, $count, $boolean
);
} | [
"public",
"function",
"has",
"(",
"$",
"relation",
",",
"$",
"operator",
"=",
"'>='",
",",
"$",
"count",
"=",
"1",
",",
"$",
"boolean",
"=",
"'and'",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"relation",... | Add a relationship count / exists condition to the query.
@param string $relation
@param string $operator
@param int $count
@param string $boolean
@param \Closure|null $callback
@return \Illuminate\Database\Eloquent\Builder|static | [
"Add",
"a",
"relationship",
"count",
"/",
"exists",
"condition",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php#L26-L59 | train | Adds a has clause to the query. | [
30522,
2270,
3853,
2038,
1006,
1002,
7189,
1010,
1002,
6872,
1027,
1005,
1028,
1027,
1005,
1010,
1002,
4175,
1027,
1015,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1010,
8503,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php | HIncludeFragmentRenderer.render | public function render($uri, Request $request, array $options = [])
{
if ($uri instanceof ControllerReference) {
if (null === $this->signer) {
throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
}
// we need to sign the absolute URI, but want to return the path only.
$uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), \strlen($request->getSchemeAndHttpHost()));
}
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
$uri = str_replace('&', '&', $uri);
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
if (null !== $this->templating && $template && $this->templateExists($template)) {
$content = $this->templating->render($template);
} else {
$content = $template;
}
$attributes = isset($options['attributes']) && \is_array($options['attributes']) ? $options['attributes'] : [];
if (isset($options['id']) && $options['id']) {
$attributes['id'] = $options['id'];
}
$renderedAttributes = '';
if (\count($attributes) > 0) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
foreach ($attributes as $attribute => $value) {
$renderedAttributes .= sprintf(
' %s="%s"',
htmlspecialchars($attribute, $flags, $this->charset, false),
htmlspecialchars($value, $flags, $this->charset, false)
);
}
}
return new Response(sprintf('<hx:include src="%s"%s>%s</hx:include>', $uri, $renderedAttributes, $content));
} | php | public function render($uri, Request $request, array $options = [])
{
if ($uri instanceof ControllerReference) {
if (null === $this->signer) {
throw new \LogicException('You must use a proper URI when using the Hinclude rendering strategy or set a URL signer.');
}
// we need to sign the absolute URI, but want to return the path only.
$uri = substr($this->signer->sign($this->generateFragmentUri($uri, $request, true)), \strlen($request->getSchemeAndHttpHost()));
}
// We need to replace ampersands in the URI with the encoded form in order to return valid html/xml content.
$uri = str_replace('&', '&', $uri);
$template = isset($options['default']) ? $options['default'] : $this->globalDefaultTemplate;
if (null !== $this->templating && $template && $this->templateExists($template)) {
$content = $this->templating->render($template);
} else {
$content = $template;
}
$attributes = isset($options['attributes']) && \is_array($options['attributes']) ? $options['attributes'] : [];
if (isset($options['id']) && $options['id']) {
$attributes['id'] = $options['id'];
}
$renderedAttributes = '';
if (\count($attributes) > 0) {
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
foreach ($attributes as $attribute => $value) {
$renderedAttributes .= sprintf(
' %s="%s"',
htmlspecialchars($attribute, $flags, $this->charset, false),
htmlspecialchars($value, $flags, $this->charset, false)
);
}
}
return new Response(sprintf('<hx:include src="%s"%s>%s</hx:include>', $uri, $renderedAttributes, $content));
} | [
"public",
"function",
"render",
"(",
"$",
"uri",
",",
"Request",
"$",
"request",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"uri",
"instanceof",
"ControllerReference",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",... | {@inheritdoc}
Additional available options:
* default: The default content (it can be a template name or the content)
* id: An optional hx:include tag id attribute
* attributes: An optional array of hx:include tag attributes | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php#L88-L126 | train | Render the Hinclude | [
30522,
2270,
3853,
17552,
1006,
1002,
24471,
2072,
1010,
5227,
1002,
5227,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2065,
1006,
1002,
24471,
2072,
6013,
11253,
11486,
2890,
25523,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Events/Dispatcher.php | Dispatcher.setupWildcardListen | protected function setupWildcardListen($event, $listener)
{
$this->wildcards[$event][] = $this->makeListener($listener, true);
$this->wildcardsCache = [];
} | php | protected function setupWildcardListen($event, $listener)
{
$this->wildcards[$event][] = $this->makeListener($listener, true);
$this->wildcardsCache = [];
} | [
"protected",
"function",
"setupWildcardListen",
"(",
"$",
"event",
",",
"$",
"listener",
")",
"{",
"$",
"this",
"->",
"wildcards",
"[",
"$",
"event",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"makeListener",
"(",
"$",
"listener",
",",
"true",
")",
";",
... | Setup a wildcard listener callback.
@param string $event
@param mixed $listener
@return void | [
"Setup",
"a",
"wildcard",
"listener",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Events/Dispatcher.php#L89-L94 | train | Setup wildcard listener | [
30522,
5123,
3853,
16437,
29602,
16409,
4232,
9863,
2368,
1006,
1002,
2724,
1010,
1002,
19373,
1007,
1063,
1002,
2023,
1011,
1028,
3748,
17965,
1031,
1002,
2724,
1033,
1031,
1033,
1027,
1002,
2023,
1011,
1028,
2191,
9863,
24454,
1006,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/FilesystemManager.php | FilesystemManager.cloud | public function cloud()
{
$name = $this->getDefaultCloudDriver();
return $this->disks[$name] = $this->get($name);
} | php | public function cloud()
{
$name = $this->getDefaultCloudDriver();
return $this->disks[$name] = $this->get($name);
} | [
"public",
"function",
"cloud",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getDefaultCloudDriver",
"(",
")",
";",
"return",
"$",
"this",
"->",
"disks",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
";",
"}"... | Get a default cloud filesystem instance.
@return \Illuminate\Contracts\Filesystem\Filesystem | [
"Get",
"a",
"default",
"cloud",
"filesystem",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/FilesystemManager.php#L88-L93 | train | Return the cloud disk | [
30522,
2270,
3853,
6112,
1006,
1007,
1063,
1002,
2171,
1027,
1002,
2023,
1011,
1028,
2131,
3207,
7011,
11314,
20464,
19224,
23663,
2099,
1006,
1007,
1025,
2709,
1002,
2023,
1011,
1028,
23999,
1031,
1002,
2171,
1033,
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/DependencyInjection/Loader/Configurator/Traits/BindTrait.php | BindTrait.bind | final public function bind($nameOrFqcn, $valueOrRef)
{
$valueOrRef = static::processValue($valueOrRef, true);
if (!preg_match('/^(?:(?:array|bool|float|int|string)[ \t]*+)?\$/', $nameOrFqcn) && !$valueOrRef instanceof Reference) {
throw new InvalidArgumentException(sprintf('Invalid binding for service "%s": named arguments must start with a "$", and FQCN must map to references. Neither applies to binding "%s".', $this->id, $nameOrFqcn));
}
$bindings = $this->definition->getBindings();
$type = $this instanceof DefaultsConfigurator ? BoundArgument::DEFAULTS_BINDING : ($this instanceof InstanceofConfigurator ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING);
$bindings[$nameOrFqcn] = new BoundArgument($valueOrRef, true, $type, $this->path ?? null);
$this->definition->setBindings($bindings);
return $this;
} | php | final public function bind($nameOrFqcn, $valueOrRef)
{
$valueOrRef = static::processValue($valueOrRef, true);
if (!preg_match('/^(?:(?:array|bool|float|int|string)[ \t]*+)?\$/', $nameOrFqcn) && !$valueOrRef instanceof Reference) {
throw new InvalidArgumentException(sprintf('Invalid binding for service "%s": named arguments must start with a "$", and FQCN must map to references. Neither applies to binding "%s".', $this->id, $nameOrFqcn));
}
$bindings = $this->definition->getBindings();
$type = $this instanceof DefaultsConfigurator ? BoundArgument::DEFAULTS_BINDING : ($this instanceof InstanceofConfigurator ? BoundArgument::INSTANCEOF_BINDING : BoundArgument::SERVICE_BINDING);
$bindings[$nameOrFqcn] = new BoundArgument($valueOrRef, true, $type, $this->path ?? null);
$this->definition->setBindings($bindings);
return $this;
} | [
"final",
"public",
"function",
"bind",
"(",
"$",
"nameOrFqcn",
",",
"$",
"valueOrRef",
")",
"{",
"$",
"valueOrRef",
"=",
"static",
"::",
"processValue",
"(",
"$",
"valueOrRef",
",",
"true",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^(?:(?:array|bool|... | Sets bindings.
Bindings map $named or FQCN arguments to values that should be
injected in the matching parameters (of the constructor, of methods
called and of controller actions).
@param string $nameOrFqcn A parameter name with its "$" prefix, or a FQCN
@param mixed $valueOrRef The value or reference to bind
@return $this | [
"Sets",
"bindings",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/BindTrait.php#L34-L46 | train | Binds a named argument to the service | [
30522,
2345,
2270,
3853,
14187,
1006,
1002,
2171,
16347,
4160,
2278,
2078,
1010,
1002,
3643,
2953,
2890,
2546,
1007,
1063,
1002,
3643,
2953,
2890,
2546,
1027,
10763,
1024,
1024,
2832,
10175,
5657,
1006,
1002,
3643,
2953,
2890,
2546,
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/Routing/UrlGenerator.php | UrlGenerator.toRoute | protected function toRoute($route, $parameters, $absolute)
{
return $this->routeUrl()->to(
$route, $this->formatParameters($parameters), $absolute
);
} | php | protected function toRoute($route, $parameters, $absolute)
{
return $this->routeUrl()->to(
$route, $this->formatParameters($parameters), $absolute
);
} | [
"protected",
"function",
"toRoute",
"(",
"$",
"route",
",",
"$",
"parameters",
",",
"$",
"absolute",
")",
"{",
"return",
"$",
"this",
"->",
"routeUrl",
"(",
")",
"->",
"to",
"(",
"$",
"route",
",",
"$",
"this",
"->",
"formatParameters",
"(",
"$",
"pa... | Get the URL for a given route instance.
@param \Illuminate\Routing\Route $route
@param mixed $parameters
@param bool $absolute
@return string
@throws \Illuminate\Routing\Exceptions\UrlGenerationException | [
"Get",
"the",
"URL",
"for",
"a",
"given",
"route",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/UrlGenerator.php#L401-L406 | train | Generate a URL to route with parameters and absolute | [
30522,
5123,
3853,
23790,
10421,
1006,
1002,
2799,
1010,
1002,
11709,
1010,
1002,
7619,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2799,
3126,
2140,
1006,
1007,
1011,
1028,
2000,
1006,
1002,
2799,
1010,
1002,
2023,
1011,
1028,
4289,
28689,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Medium/ImageMedium.php | ImageMedium.reset | public function reset()
{
parent::reset();
if ($this->image) {
$this->image();
$this->medium_querystring = [];
$this->filter();
$this->clearAlternatives();
}
$this->format = 'guess';
$this->quality = $this->default_quality;
$this->debug_watermarked = false;
return $this;
} | php | public function reset()
{
parent::reset();
if ($this->image) {
$this->image();
$this->medium_querystring = [];
$this->filter();
$this->clearAlternatives();
}
$this->format = 'guess';
$this->quality = $this->default_quality;
$this->debug_watermarked = false;
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"parent",
"::",
"reset",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"image",
")",
"{",
"$",
"this",
"->",
"image",
"(",
")",
";",
"$",
"this",
"->",
"medium_querystring",
"=",
"[",
"]",
";",
"$",
... | Reset image.
@return $this | [
"Reset",
"image",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ImageMedium.php#L359-L376 | train | Reset the current localization | [
30522,
2270,
3853,
25141,
1006,
1007,
1063,
6687,
1024,
1024,
25141,
1006,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
3746,
1007,
1063,
1002,
2023,
1011,
1028,
3746,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
5396,
1035,
23032,
3367,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php | CachePoolClearCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$pools = [];
$clearers = [];
foreach ($input->getArgument('pools') as $id) {
if ($this->poolClearer->hasPool($id)) {
$pools[$id] = $id;
} else {
$pool = $kernel->getContainer()->get($id);
if ($pool instanceof CacheItemPoolInterface) {
$pools[$id] = $pool;
} elseif ($pool instanceof Psr6CacheClearer) {
$clearers[$id] = $pool;
} else {
throw new InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
}
}
}
foreach ($clearers as $id => $clearer) {
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
$clearer->clear($kernel->getContainer()->getParameter('kernel.cache_dir'));
}
foreach ($pools as $id => $pool) {
$io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
if ($pool instanceof CacheItemPoolInterface) {
$pool->clear();
} else {
$this->poolClearer->clearPool($id);
}
}
$io->success('Cache was successfully cleared.');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$kernel = $this->getApplication()->getKernel();
$pools = [];
$clearers = [];
foreach ($input->getArgument('pools') as $id) {
if ($this->poolClearer->hasPool($id)) {
$pools[$id] = $id;
} else {
$pool = $kernel->getContainer()->get($id);
if ($pool instanceof CacheItemPoolInterface) {
$pools[$id] = $pool;
} elseif ($pool instanceof Psr6CacheClearer) {
$clearers[$id] = $pool;
} else {
throw new InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
}
}
}
foreach ($clearers as $id => $clearer) {
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
$clearer->clear($kernel->getContainer()->getParameter('kernel.cache_dir'));
}
foreach ($pools as $id => $pool) {
$io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
if ($pool instanceof CacheItemPoolInterface) {
$pool->clear();
} else {
$this->poolClearer->clearPool($id);
}
}
$io->success('Cache was successfully cleared.');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"kernel",
"=",
"$",
"this",
"->",
"ge... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php#L63-L102 | train | Clear cache. | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
22834,
1027,
2047,
25353,
2213,
14876,
4890,
21756,
2571,
1006,
1002,
7953,
1010,
1002,
6434,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form/Field/File.php | File.uploadAndDeleteOriginal | protected function uploadAndDeleteOriginal(UploadedFile $file)
{
$this->renameIfExists($file);
$path = null;
if (!is_null($this->storage_permission)) {
$path = $this->storage->putFileAs($this->getDirectory(), $file, $this->name, $this->storage_permission);
} else {
$path = $this->storage->putFileAs($this->getDirectory(), $file, $this->name);
}
$this->destroy();
return $path;
} | php | protected function uploadAndDeleteOriginal(UploadedFile $file)
{
$this->renameIfExists($file);
$path = null;
if (!is_null($this->storage_permission)) {
$path = $this->storage->putFileAs($this->getDirectory(), $file, $this->name, $this->storage_permission);
} else {
$path = $this->storage->putFileAs($this->getDirectory(), $file, $this->name);
}
$this->destroy();
return $path;
} | [
"protected",
"function",
"uploadAndDeleteOriginal",
"(",
"UploadedFile",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"renameIfExists",
"(",
"$",
"file",
")",
";",
"$",
"path",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"storage_pe... | Upload file and delete original file.
@param UploadedFile $file
@return mixed | [
"Upload",
"file",
"and",
"delete",
"original",
"file",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Field/File.php#L121-L136 | train | Upload and Delete original file | [
30522,
5123,
30524,
19701,
1006,
1002,
2023,
1011,
1028,
5527,
1035,
6656,
1007,
1007,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
5527,
1011,
1028,
2404,
8873,
19738,
2015,
1006,
1002,
2023,
1011,
1028,
2131,
4305,
2890,
16761,
2100,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OfficialAccount/CustomerService/Messenger.php | Messenger.send | public function send()
{
if (empty($this->message)) {
throw new RuntimeException('No message to send.');
}
if ($this->message instanceof RawMessage) {
$message = json_decode($this->message->get('content'), true);
} else {
$prepends = [
'touser' => $this->to,
];
if ($this->account) {
$prepends['customservice'] = ['kf_account' => $this->account];
}
$message = $this->message->transformForJsonRequest($prepends);
}
return $this->client->send($message);
} | php | public function send()
{
if (empty($this->message)) {
throw new RuntimeException('No message to send.');
}
if ($this->message instanceof RawMessage) {
$message = json_decode($this->message->get('content'), true);
} else {
$prepends = [
'touser' => $this->to,
];
if ($this->account) {
$prepends['customservice'] = ['kf_account' => $this->account];
}
$message = $this->message->transformForJsonRequest($prepends);
}
return $this->client->send($message);
} | [
"public",
"function",
"send",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No message to send.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"message",
"instanceof",
"... | Send the message.
@return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
@throws RuntimeException | [
"Send",
"the",
"message",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OfficialAccount/CustomerService/Messenger.php#L127-L146 | train | Send the message to the user | [
30522,
2270,
3853,
4604,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
4471,
1007,
1007,
1063,
5466,
2047,
2448,
7292,
10288,
24422,
1006,
1005,
2053,
4471,
2000,
4604,
1012,
1005,
1007,
1025,
1065,
2065,
1006,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Mysql.php | Zend_Db_Adapter_Pdo_Mysql.describeTable | public function describeTable($tableName, $schemaName = null)
{
// @todo use INFORMATION_SCHEMA someday when MySQL's
// implementation has reasonably good performance and
// the version with this improvement is in wide use.
if ($schemaName) {
$sql = 'DESCRIBE ' . $this->quoteIdentifier("$schemaName.$tableName", true);
} else {
$sql = 'DESCRIBE ' . $this->quoteIdentifier($tableName, true);
}
$stmt = $this->query($sql);
// Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$field = 0;
$type = 1;
$null = 2;
$key = 3;
$default = 4;
$extra = 5;
$desc = array();
$i = 1;
$p = 1;
foreach ($result as $row) {
list($length, $scale, $precision, $unsigned, $primary, $primaryPosition, $identity)
= array(null, null, null, null, false, null, false);
if (preg_match('/unsigned/', $row[$type])) {
$unsigned = true;
}
if (preg_match('/^((?:var)?char)\((\d+)\)/', $row[$type], $matches)) {
$row[$type] = $matches[1];
$length = $matches[2];
} else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row[$type], $matches)) {
$row[$type] = 'decimal';
$precision = $matches[1];
$scale = $matches[2];
} else if (preg_match('/^float\((\d+),(\d+)\)/', $row[$type], $matches)) {
$row[$type] = 'float';
$precision = $matches[1];
$scale = $matches[2];
} else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row[$type], $matches)) {
$row[$type] = $matches[1];
// The optional argument of a MySQL int type is not precision
// or length; it is only a hint for display width.
}
if (strtoupper($row[$key]) == 'PRI') {
$primary = true;
$primaryPosition = $p;
if ($row[$extra] == 'auto_increment') {
$identity = true;
} else {
$identity = false;
}
++$p;
}
$desc[$this->foldCase($row[$field])] = array(
'SCHEMA_NAME' => null, // @todo
'TABLE_NAME' => $this->foldCase($tableName),
'COLUMN_NAME' => $this->foldCase($row[$field]),
'COLUMN_POSITION' => $i,
'DATA_TYPE' => $row[$type],
'DEFAULT' => $row[$default],
'NULLABLE' => (bool) ($row[$null] == 'YES'),
'LENGTH' => $length,
'SCALE' => $scale,
'PRECISION' => $precision,
'UNSIGNED' => $unsigned,
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
++$i;
}
return $desc;
} | php | public function describeTable($tableName, $schemaName = null)
{
// @todo use INFORMATION_SCHEMA someday when MySQL's
// implementation has reasonably good performance and
// the version with this improvement is in wide use.
if ($schemaName) {
$sql = 'DESCRIBE ' . $this->quoteIdentifier("$schemaName.$tableName", true);
} else {
$sql = 'DESCRIBE ' . $this->quoteIdentifier($tableName, true);
}
$stmt = $this->query($sql);
// Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$field = 0;
$type = 1;
$null = 2;
$key = 3;
$default = 4;
$extra = 5;
$desc = array();
$i = 1;
$p = 1;
foreach ($result as $row) {
list($length, $scale, $precision, $unsigned, $primary, $primaryPosition, $identity)
= array(null, null, null, null, false, null, false);
if (preg_match('/unsigned/', $row[$type])) {
$unsigned = true;
}
if (preg_match('/^((?:var)?char)\((\d+)\)/', $row[$type], $matches)) {
$row[$type] = $matches[1];
$length = $matches[2];
} else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row[$type], $matches)) {
$row[$type] = 'decimal';
$precision = $matches[1];
$scale = $matches[2];
} else if (preg_match('/^float\((\d+),(\d+)\)/', $row[$type], $matches)) {
$row[$type] = 'float';
$precision = $matches[1];
$scale = $matches[2];
} else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row[$type], $matches)) {
$row[$type] = $matches[1];
// The optional argument of a MySQL int type is not precision
// or length; it is only a hint for display width.
}
if (strtoupper($row[$key]) == 'PRI') {
$primary = true;
$primaryPosition = $p;
if ($row[$extra] == 'auto_increment') {
$identity = true;
} else {
$identity = false;
}
++$p;
}
$desc[$this->foldCase($row[$field])] = array(
'SCHEMA_NAME' => null, // @todo
'TABLE_NAME' => $this->foldCase($tableName),
'COLUMN_NAME' => $this->foldCase($row[$field]),
'COLUMN_POSITION' => $i,
'DATA_TYPE' => $row[$type],
'DEFAULT' => $row[$default],
'NULLABLE' => (bool) ($row[$null] == 'YES'),
'LENGTH' => $length,
'SCALE' => $scale,
'PRECISION' => $precision,
'UNSIGNED' => $unsigned,
'PRIMARY' => $primary,
'PRIMARY_POSITION' => $primaryPosition,
'IDENTITY' => $identity
);
++$i;
}
return $desc;
} | [
"public",
"function",
"describeTable",
"(",
"$",
"tableName",
",",
"$",
"schemaName",
"=",
"null",
")",
"{",
"// @todo use INFORMATION_SCHEMA someday when MySQL's",
"// implementation has reasonably good performance and",
"// the version with this improvement is in wide use.",
"if",... | Returns the column descriptions for a table.
The return value is an associative array keyed by the column name,
as returned by the RDBMS.
The value of each array element is an associative array
with the following keys:
SCHEMA_NAME => string; name of database or schema
TABLE_NAME => string;
COLUMN_NAME => string; column name
COLUMN_POSITION => number; ordinal position of column in table
DATA_TYPE => string; SQL datatype name of column
DEFAULT => string; default expression of column, null if none
NULLABLE => boolean; true if column can have nulls
LENGTH => number; length of CHAR/VARCHAR
SCALE => number; scale of NUMERIC/DECIMAL
PRECISION => number; precision of NUMERIC/DECIMAL
UNSIGNED => boolean; unsigned property of an integer type
PRIMARY => boolean; true if column is part of the primary key
PRIMARY_POSITION => integer; position of column in primary key
IDENTITY => integer; true if column is auto-generated with unique values
@param string $tableName
@param string $schemaName OPTIONAL
@return array | [
"Returns",
"the",
"column",
"descriptions",
"for",
"a",
"table",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Mysql.php#L158-L235 | train | Describe table. | [
30522,
2270,
3853,
6235,
10880,
1006,
1002,
2795,
18442,
1010,
1002,
8040,
28433,
18442,
1027,
19701,
1007,
1063,
1013,
1013,
1030,
28681,
2080,
2224,
2592,
1035,
8040,
28433,
13834,
2043,
2026,
2015,
4160,
2140,
1005,
1055,
1013,
1013,
737... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php | TwigDataCollector.lateCollect | public function lateCollect()
{
$this->data['profile'] = serialize($this->profile);
$this->data['template_paths'] = [];
if (null === $this->twig) {
return;
}
$templateFinder = function (Profile $profile) use (&$templateFinder) {
if ($profile->isTemplate()) {
try {
$template = $this->twig->load($name = $profile->getName());
} catch (LoaderError $e) {
$template = null;
}
if (null !== $template && '' !== $path = $template->getSourceContext()->getPath()) {
$this->data['template_paths'][$name] = $path;
}
}
foreach ($profile as $p) {
$templateFinder($p);
}
};
$templateFinder($this->profile);
} | php | public function lateCollect()
{
$this->data['profile'] = serialize($this->profile);
$this->data['template_paths'] = [];
if (null === $this->twig) {
return;
}
$templateFinder = function (Profile $profile) use (&$templateFinder) {
if ($profile->isTemplate()) {
try {
$template = $this->twig->load($name = $profile->getName());
} catch (LoaderError $e) {
$template = null;
}
if (null !== $template && '' !== $path = $template->getSourceContext()->getPath()) {
$this->data['template_paths'][$name] = $path;
}
}
foreach ($profile as $p) {
$templateFinder($p);
}
};
$templateFinder($this->profile);
} | [
"public",
"function",
"lateCollect",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'profile'",
"]",
"=",
"serialize",
"(",
"$",
"this",
"->",
"profile",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'template_paths'",
"]",
"=",
"[",
"]",
";",
"if",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php#L61-L88 | train | This method is used to late collect the profile and template paths. | [
30522,
2270,
3853,
2397,
26895,
22471,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2951,
30524,
1063,
2709,
1025,
1065,
1002,
23561,
23695,
1027,
3853,
1006,
6337,
1002,
6337,
1007,
2224,
1006,
1004,
1002,
23561,
23695,
1007,
1063,
2065,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/traits/UrlMaker.php | UrlMaker.getUrlPageName | public function getUrlPageName()
{
if (static::$urlPageName !== null) {
return static::$urlPageName;
}
/*
* Cache
*/
$key = 'urlMaker'.$this->urlComponentName.crc32(get_class($this));
$cached = Cache::get($key, false);
if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
$filePath = array_get($cached, 'path');
$mtime = array_get($cached, 'mtime');
if (!File::isFile($filePath) || ($mtime != File::lastModified($filePath))) {
$cached = false;
}
}
if ($cached !== false) {
return static::$urlPageName = array_get($cached, 'fileName');
}
/*
* Fallback
*/
$page = null;
$useProperty = property_exists($this, 'urlComponentProperty');
if ($useProperty) {
$page = Page::whereComponent($this->urlComponentName, $this->urlComponentProperty, '1')->first();
}
if (!$useProperty || !$page) {
$page = Page::withComponent($this->urlComponentName)->first();
}
if (!$page) {
throw new ApplicationException(sprintf(
'Unable to a find a primary component "%s" for generating a URL in %s.',
$this->urlComponentName,
get_class($this)
));
}
$baseFileName = $page->getBaseFileName();
$filePath = $page->getFilePath();
$cached = [
'path' => $filePath,
'fileName' => $baseFileName,
'mtime' => @File::lastModified($filePath)
];
Cache::put($key, serialize($cached), Config::get('cms.parsedPageCacheTTL', 1440));
return static::$urlPageName = $baseFileName;
} | php | public function getUrlPageName()
{
if (static::$urlPageName !== null) {
return static::$urlPageName;
}
/*
* Cache
*/
$key = 'urlMaker'.$this->urlComponentName.crc32(get_class($this));
$cached = Cache::get($key, false);
if ($cached !== false && ($cached = @unserialize($cached)) !== false) {
$filePath = array_get($cached, 'path');
$mtime = array_get($cached, 'mtime');
if (!File::isFile($filePath) || ($mtime != File::lastModified($filePath))) {
$cached = false;
}
}
if ($cached !== false) {
return static::$urlPageName = array_get($cached, 'fileName');
}
/*
* Fallback
*/
$page = null;
$useProperty = property_exists($this, 'urlComponentProperty');
if ($useProperty) {
$page = Page::whereComponent($this->urlComponentName, $this->urlComponentProperty, '1')->first();
}
if (!$useProperty || !$page) {
$page = Page::withComponent($this->urlComponentName)->first();
}
if (!$page) {
throw new ApplicationException(sprintf(
'Unable to a find a primary component "%s" for generating a URL in %s.',
$this->urlComponentName,
get_class($this)
));
}
$baseFileName = $page->getBaseFileName();
$filePath = $page->getFilePath();
$cached = [
'path' => $filePath,
'fileName' => $baseFileName,
'mtime' => @File::lastModified($filePath)
];
Cache::put($key, serialize($cached), Config::get('cms.parsedPageCacheTTL', 1440));
return static::$urlPageName = $baseFileName;
} | [
"public",
"function",
"getUrlPageName",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"urlPageName",
"!==",
"null",
")",
"{",
"return",
"static",
"::",
"$",
"urlPageName",
";",
"}",
"/*\n * Cache\n */",
"$",
"key",
"=",
"'urlMaker'",
".",
"$... | Locates the page name where the detected component is found. This method
uses the Cache service to improve performance.
@return string | [
"Locates",
"the",
"page",
"name",
"where",
"the",
"detected",
"component",
"is",
"found",
".",
"This",
"method",
"uses",
"the",
"Cache",
"service",
"to",
"improve",
"performance",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/traits/UrlMaker.php#L138-L196 | train | Get the page name of the primary page | [
30522,
2270,
3853,
2131,
3126,
14277,
4270,
18442,
1006,
1007,
1063,
2065,
1006,
10763,
1024,
1024,
1002,
24471,
14277,
4270,
18442,
999,
1027,
1027,
19701,
1007,
1063,
2709,
10763,
1024,
1024,
1002,
24471,
14277,
4270,
18442,
1025,
1065,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/formwidgets/TagList.php | TagList.hydrateRelationSaveValue | protected function hydrateRelationSaveValue($names)
{
if (!$names) {
return $names;
}
$relationModel = $this->getRelationModel();
$existingTags = $relationModel
->whereIn($this->nameFrom, $names)
->lists($this->nameFrom, $relationModel->getKeyName())
;
$newTags = $this->customTags ? array_diff($names, $existingTags) : [];
foreach ($newTags as $newTag) {
$newModel = $relationModel::create([$this->nameFrom => $newTag]);
$existingTags[$newModel->getKey()] = $newTag;
}
return array_keys($existingTags);
} | php | protected function hydrateRelationSaveValue($names)
{
if (!$names) {
return $names;
}
$relationModel = $this->getRelationModel();
$existingTags = $relationModel
->whereIn($this->nameFrom, $names)
->lists($this->nameFrom, $relationModel->getKeyName())
;
$newTags = $this->customTags ? array_diff($names, $existingTags) : [];
foreach ($newTags as $newTag) {
$newModel = $relationModel::create([$this->nameFrom => $newTag]);
$existingTags[$newModel->getKey()] = $newTag;
}
return array_keys($existingTags);
} | [
"protected",
"function",
"hydrateRelationSaveValue",
"(",
"$",
"names",
")",
"{",
"if",
"(",
"!",
"$",
"names",
")",
"{",
"return",
"$",
"names",
";",
"}",
"$",
"relationModel",
"=",
"$",
"this",
"->",
"getRelationModel",
"(",
")",
";",
"$",
"existingTag... | Returns an array suitable for saving against a relation (array of keys).
This method also creates non-existent tags.
@return array | [
"Returns",
"an",
"array",
"suitable",
"for",
"saving",
"against",
"a",
"relation",
"(",
"array",
"of",
"keys",
")",
".",
"This",
"method",
"also",
"creates",
"non",
"-",
"existent",
"tags",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/formwidgets/TagList.php#L124-L144 | train | Hydrate RelationSaveValue Hydrates relations | [
30522,
5123,
3853,
26018,
3334,
10581,
9285,
10696,
10175,
5657,
1006,
1002,
3415,
1007,
1063,
2065,
1006,
999,
1002,
3415,
1007,
1063,
2709,
1002,
3415,
1025,
1065,
1002,
7189,
5302,
9247,
1027,
1002,
2023,
1011,
1028,
2131,
16570,
3370,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php | RedirectController.redirectAction | public function redirectAction(Request $request, string $route, bool $permanent = false, $ignoreAttributes = false, bool $keepRequestMethod = false, bool $keepQueryParams = false): Response
{
if ('' == $route) {
throw new HttpException($permanent ? 410 : 404);
}
$attributes = [];
if (false === $ignoreAttributes || \is_array($ignoreAttributes)) {
$attributes = $request->attributes->get('_route_params');
$attributes = $keepQueryParams ? array_merge($request->query->all(), $attributes) : $attributes;
unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes'], $attributes['keepRequestMethod'], $attributes['keepQueryParams']);
if ($ignoreAttributes) {
$attributes = array_diff_key($attributes, array_flip($ignoreAttributes));
}
}
if ($keepRequestMethod) {
$statusCode = $permanent ? 308 : 307;
} else {
$statusCode = $permanent ? 301 : 302;
}
return new RedirectResponse($this->router->generate($route, $attributes, UrlGeneratorInterface::ABSOLUTE_URL), $statusCode);
} | php | public function redirectAction(Request $request, string $route, bool $permanent = false, $ignoreAttributes = false, bool $keepRequestMethod = false, bool $keepQueryParams = false): Response
{
if ('' == $route) {
throw new HttpException($permanent ? 410 : 404);
}
$attributes = [];
if (false === $ignoreAttributes || \is_array($ignoreAttributes)) {
$attributes = $request->attributes->get('_route_params');
$attributes = $keepQueryParams ? array_merge($request->query->all(), $attributes) : $attributes;
unset($attributes['route'], $attributes['permanent'], $attributes['ignoreAttributes'], $attributes['keepRequestMethod'], $attributes['keepQueryParams']);
if ($ignoreAttributes) {
$attributes = array_diff_key($attributes, array_flip($ignoreAttributes));
}
}
if ($keepRequestMethod) {
$statusCode = $permanent ? 308 : 307;
} else {
$statusCode = $permanent ? 301 : 302;
}
return new RedirectResponse($this->router->generate($route, $attributes, UrlGeneratorInterface::ABSOLUTE_URL), $statusCode);
} | [
"public",
"function",
"redirectAction",
"(",
"Request",
"$",
"request",
",",
"string",
"$",
"route",
",",
"bool",
"$",
"permanent",
"=",
"false",
",",
"$",
"ignoreAttributes",
"=",
"false",
",",
"bool",
"$",
"keepRequestMethod",
"=",
"false",
",",
"bool",
... | Redirects to another route with the given name.
The response status code is 302 if the permanent parameter is false (default),
and 301 if the redirection is permanent.
In case the route name is empty, the status code will be 404 when permanent is false
and 410 otherwise.
@param Request $request The request instance
@param string $route The route name to redirect to
@param bool $permanent Whether the redirection is permanent
@param bool|array $ignoreAttributes Whether to ignore attributes or an array of attributes to ignore
@param bool $keepRequestMethod Whether redirect action should keep HTTP request method
@throws HttpException In case the route name is empty | [
"Redirects",
"to",
"another",
"route",
"with",
"the",
"given",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php#L57-L80 | train | Redirects to a route | [
30522,
2270,
3853,
2417,
7442,
25572,
7542,
1006,
5227,
1002,
5227,
1010,
5164,
1002,
2799,
1010,
22017,
2140,
1002,
4568,
1027,
6270,
1010,
1002,
8568,
19321,
3089,
8569,
4570,
1027,
6270,
1010,
22017,
2140,
1002,
2562,
2890,
15500,
11368,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/models/File.php | File.getPublicPath | public function getPublicPath()
{
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
if ($this->isPublic()) {
$uploadsPath .= '/public';
}
else {
$uploadsPath .= '/protected';
}
return Url::asset($uploadsPath) . '/';
} | php | public function getPublicPath()
{
$uploadsPath = Config::get('cms.storage.uploads.path', '/storage/app/uploads');
if ($this->isPublic()) {
$uploadsPath .= '/public';
}
else {
$uploadsPath .= '/protected';
}
return Url::asset($uploadsPath) . '/';
} | [
"public",
"function",
"getPublicPath",
"(",
")",
"{",
"$",
"uploadsPath",
"=",
"Config",
"::",
"get",
"(",
"'cms.storage.uploads.path'",
",",
"'/storage/app/uploads'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"uploadsPath"... | Define the public address for the storage path. | [
"Define",
"the",
"public",
"address",
"for",
"the",
"storage",
"path",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/models/File.php#L68-L80 | train | Get public path | [
30522,
2270,
3853,
2131,
14289,
16558,
2594,
15069,
1006,
1007,
1063,
1002,
2039,
11066,
13102,
8988,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
1006,
1005,
4642,
2015,
1012,
5527,
1012,
2039,
11066,
2015,
1012,
4130,
1005,
1010,
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... |
symfony/symfony | src/Symfony/Component/Form/Form.php | Form.clearErrors | public function clearErrors(bool $deep = false): self
{
$this->errors = [];
if ($deep) {
// Clear errors from children
foreach ($this as $child) {
if ($child instanceof ClearableErrorsInterface) {
$child->clearErrors(true);
}
}
}
return $this;
} | php | public function clearErrors(bool $deep = false): self
{
$this->errors = [];
if ($deep) {
// Clear errors from children
foreach ($this as $child) {
if ($child instanceof ClearableErrorsInterface) {
$child->clearErrors(true);
}
}
}
return $this;
} | [
"public",
"function",
"clearErrors",
"(",
"bool",
"$",
"deep",
"=",
"false",
")",
":",
"self",
"{",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"deep",
")",
"{",
"// Clear errors from children",
"foreach",
"(",
"$",
"this",
"as",
... | {@inheritdoc}
@return $this | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Form.php#L808-L822 | train | Clear errors from this node | [
30522,
2270,
3853,
24509,
29165,
2015,
1006,
22017,
2140,
1002,
2784,
1027,
6270,
1007,
1024,
2969,
1063,
1002,
2023,
1011,
1028,
10697,
1027,
1031,
1033,
1025,
2065,
1006,
1002,
2784,
1007,
1063,
1013,
1013,
3154,
10697,
2013,
2336,
18921,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Kernel.php | Kernel.dumpContainer | protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
{
// cache the container
$dumper = new PhpDumper($container);
if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) {
$dumper->setProxyDumper(new ProxyDumper());
}
$content = $dumper->dump([
'class' => $class,
'base_class' => $baseClass,
'file' => $cache->getPath(),
'as_files' => true,
'debug' => $this->debug,
'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(),
]);
$rootCode = array_pop($content);
$dir = \dirname($cache->getPath()).'/';
$fs = new Filesystem();
foreach ($content as $file => $code) {
$fs->dumpFile($dir.$file, $code);
@chmod($dir.$file, 0666 & ~umask());
}
$legacyFile = \dirname($dir.$file).'.legacy';
if (file_exists($legacyFile)) {
@unlink($legacyFile);
}
$cache->write($rootCode, $container->getResources());
} | php | protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
{
// cache the container
$dumper = new PhpDumper($container);
if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) {
$dumper->setProxyDumper(new ProxyDumper());
}
$content = $dumper->dump([
'class' => $class,
'base_class' => $baseClass,
'file' => $cache->getPath(),
'as_files' => true,
'debug' => $this->debug,
'build_time' => $container->hasParameter('kernel.container_build_time') ? $container->getParameter('kernel.container_build_time') : time(),
]);
$rootCode = array_pop($content);
$dir = \dirname($cache->getPath()).'/';
$fs = new Filesystem();
foreach ($content as $file => $code) {
$fs->dumpFile($dir.$file, $code);
@chmod($dir.$file, 0666 & ~umask());
}
$legacyFile = \dirname($dir.$file).'.legacy';
if (file_exists($legacyFile)) {
@unlink($legacyFile);
}
$cache->write($rootCode, $container->getResources());
} | [
"protected",
"function",
"dumpContainer",
"(",
"ConfigCache",
"$",
"cache",
",",
"ContainerBuilder",
"$",
"container",
",",
"$",
"class",
",",
"$",
"baseClass",
")",
"{",
"// cache the container",
"$",
"dumper",
"=",
"new",
"PhpDumper",
"(",
"$",
"container",
... | Dumps the service container to PHP code in the cache.
@param ConfigCache $cache The config cache
@param ContainerBuilder $container The service container
@param string $class The name of the class to generate
@param string $baseClass The name of the container's base class | [
"Dumps",
"the",
"service",
"container",
"to",
"PHP",
"code",
"in",
"the",
"cache",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Kernel.php#L727-L759 | train | Dump the container | [
30522,
5123,
3853,
15653,
8663,
18249,
2121,
1006,
9530,
8873,
18195,
15395,
1002,
17053,
1010,
11661,
8569,
23891,
2099,
1002,
11661,
1010,
1002,
2465,
1010,
1002,
2918,
26266,
1007,
1063,
1013,
1013,
17053,
1996,
11661,
1002,
15653,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FormBuilder.php | FormBuilder.getForm | public function getForm()
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
$this->resolveChildren();
$form = new Form($this->getFormConfig());
foreach ($this->children as $child) {
// Automatic initialization is only supported on root forms
$form->add($child->setAutoInitialize(false)->getForm());
}
if ($this->getAutoInitialize()) {
// Automatically initialize the form if it is configured so
$form->initialize();
}
return $form;
} | php | public function getForm()
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
$this->resolveChildren();
$form = new Form($this->getFormConfig());
foreach ($this->children as $child) {
// Automatic initialization is only supported on root forms
$form->add($child->setAutoInitialize(false)->getForm());
}
if ($this->getAutoInitialize()) {
// Automatically initialize the form if it is configured so
$form->initialize();
}
return $form;
} | [
"public",
"function",
"getForm",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'",
")",
";",
"}"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormBuilder.php#L189-L210 | train | Returns the form | [
30522,
2270,
3853,
2131,
14192,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5299,
1007,
1063,
5466,
2047,
2919,
11368,
6806,
16409,
24164,
2595,
24422,
1006,
1005,
2433,
8569,
23891,
2099,
4725,
3685,
2022,
11570,
4902,
2320,
1996... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Mysqli.php | Zend_Db_Adapter_Mysqli._commit | protected function _commit()
{
$this->_connect();
$this->_connection->commit();
$this->_connection->autocommit(true);
} | php | protected function _commit()
{
$this->_connect();
$this->_connection->commit();
$this->_connection->autocommit(true);
} | [
"protected",
"function",
"_commit",
"(",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"$",
"this",
"->",
"_connection",
"->",
"commit",
"(",
")",
";",
"$",
"this",
"->",
"_connection",
"->",
"autocommit",
"(",
"true",
")",
";",
"}"
] | Commit a transaction.
@return void | [
"Commit",
"a",
"transaction",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L465-L470 | train | Commits the current transaction | [
30522,
5123,
3853,
1035,
10797,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
1035,
4434,
1011,
1028,
10797,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
1035,
4434,
1011,
1028,
8285,
9006,
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/API/API.php | API.getAvailableMeasurableTypes | public function getAvailableMeasurableTypes()
{
Piwik::checkUserHasSomeViewAccess();
$typeManager = new TypeManager();
$types = $typeManager->getAllTypes();
$available = array();
foreach ($types as $type) {
$measurableSettings = $this->settingsProvider->getAllMeasurableSettings($idSite = 0, $type->getId());
$settingsMetadata = new SettingsMetadata();
$available[] = array(
'id' => $type->getId(),
'name' => Piwik::translate($type->getName()),
'description' => Piwik::translate($type->getDescription()),
'howToSetupUrl' => $type->getHowToSetupUrl(),
'settings' => $settingsMetadata->formatSettings($measurableSettings)
);
}
return $available;
} | php | public function getAvailableMeasurableTypes()
{
Piwik::checkUserHasSomeViewAccess();
$typeManager = new TypeManager();
$types = $typeManager->getAllTypes();
$available = array();
foreach ($types as $type) {
$measurableSettings = $this->settingsProvider->getAllMeasurableSettings($idSite = 0, $type->getId());
$settingsMetadata = new SettingsMetadata();
$available[] = array(
'id' => $type->getId(),
'name' => Piwik::translate($type->getName()),
'description' => Piwik::translate($type->getDescription()),
'howToSetupUrl' => $type->getHowToSetupUrl(),
'settings' => $settingsMetadata->formatSettings($measurableSettings)
);
}
return $available;
} | [
"public",
"function",
"getAvailableMeasurableTypes",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeViewAccess",
"(",
")",
";",
"$",
"typeManager",
"=",
"new",
"TypeManager",
"(",
")",
";",
"$",
"types",
"=",
"$",
"typeManager",
"->",
"getAllTypes",
"(",
")",
... | Returns all available measurable types.
Marked as deprecated so it won't appear in API page. It won't be a public API for now.
@deprecated
@return array | [
"Returns",
"all",
"available",
"measurable",
"types",
".",
"Marked",
"as",
"deprecated",
"so",
"it",
"won",
"t",
"appear",
"in",
"API",
"page",
".",
"It",
"won",
"t",
"be",
"a",
"public",
"API",
"for",
"now",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/API.php#L159-L182 | train | Returns all available measurable types | [
30522,
2270,
3853,
2131,
12462,
11733,
3468,
4168,
28329,
13874,
2015,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
8584,
6305,
9623,
2015,
1006,
1007,
1025,
1002,
2828,
24805,
4590,
1027,
2047,
2828,
24805,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Filter/BeautifyRangeLabels.php | BeautifyRangeLabels.beautify | public function beautify($value)
{
// if there's more than one element, handle as a range w/ an upper bound
if (strpos($value, "-") !== false) {
// get the range
sscanf($value, "%d - %d", $lowerBound, $upperBound);
// if the lower bound is the same as the upper bound make sure the singular label
// is used
if ($lowerBound == $upperBound) {
return $this->getSingleUnitLabel($value, $lowerBound);
} else {
return $this->getRangeLabel($value, $lowerBound, $upperBound);
}
} // if there's one element, handle as a range w/ no upper bound
else {
// get the lower bound
sscanf($value, "%d", $lowerBound);
if ($lowerBound !== null) {
$plusEncoded = urlencode('+');
$plusLen = strlen($plusEncoded);
$len = strlen($value);
// if the label doesn't end with a '+', append it
if ($len < $plusLen || substr($value, $len - $plusLen) != $plusEncoded) {
$value .= $plusEncoded;
}
return $this->getUnboundedLabel($value, $lowerBound);
} else {
// if no lower bound can be found, this isn't a valid range. in this case
// we assume its a translation key and try to translate it.
return Piwik::translate(trim($value));
}
}
} | php | public function beautify($value)
{
// if there's more than one element, handle as a range w/ an upper bound
if (strpos($value, "-") !== false) {
// get the range
sscanf($value, "%d - %d", $lowerBound, $upperBound);
// if the lower bound is the same as the upper bound make sure the singular label
// is used
if ($lowerBound == $upperBound) {
return $this->getSingleUnitLabel($value, $lowerBound);
} else {
return $this->getRangeLabel($value, $lowerBound, $upperBound);
}
} // if there's one element, handle as a range w/ no upper bound
else {
// get the lower bound
sscanf($value, "%d", $lowerBound);
if ($lowerBound !== null) {
$plusEncoded = urlencode('+');
$plusLen = strlen($plusEncoded);
$len = strlen($value);
// if the label doesn't end with a '+', append it
if ($len < $plusLen || substr($value, $len - $plusLen) != $plusEncoded) {
$value .= $plusEncoded;
}
return $this->getUnboundedLabel($value, $lowerBound);
} else {
// if no lower bound can be found, this isn't a valid range. in this case
// we assume its a translation key and try to translate it.
return Piwik::translate(trim($value));
}
}
} | [
"public",
"function",
"beautify",
"(",
"$",
"value",
")",
"{",
"// if there's more than one element, handle as a range w/ an upper bound",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"\"-\"",
")",
"!==",
"false",
")",
"{",
"// get the range",
"sscanf",
"(",
"$",
... | Beautifies a range label and returns the pretty result. See {@link BeautifyRangeLabels}.
@param string $value The range string. This must be in either a '$min-$max' format
a '$min+' format.
@return string The pretty range label. | [
"Beautifies",
"a",
"range",
"label",
"and",
"returns",
"the",
"pretty",
"result",
".",
"See",
"{",
"@link",
"BeautifyRangeLabels",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/BeautifyRangeLabels.php#L78-L114 | train | Returns the value of the field as a string | [
30522,
2270,
3853,
17935,
27351,
1006,
1002,
3643,
1007,
1063,
1013,
1013,
2065,
2045,
1005,
1055,
2062,
2084,
2028,
5783,
1010,
5047,
2004,
1037,
2846,
1059,
1013,
2019,
3356,
5391,
2065,
1006,
2358,
14536,
2891,
1006,
1002,
3643,
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/Simple/TraceableCache.php | TraceableCache.prune | public function prune()
{
if (!$this->pool instanceof PruneableInterface) {
return false;
}
$event = $this->start(__FUNCTION__);
try {
return $event->result = $this->pool->prune();
} finally {
$event->end = microtime(true);
}
} | php | public function prune()
{
if (!$this->pool instanceof PruneableInterface) {
return false;
}
$event = $this->start(__FUNCTION__);
try {
return $event->result = $this->pool->prune();
} finally {
$event->end = microtime(true);
}
} | [
"public",
"function",
"prune",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"pool",
"instanceof",
"PruneableInterface",
")",
"{",
"return",
"false",
";",
"}",
"$",
"event",
"=",
"$",
"this",
"->",
"start",
"(",
"__FUNCTION__",
")",
";",
"try",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Simple/TraceableCache.php#L187-L198 | train | Prune the cache | [
30522,
2270,
3853,
10975,
9816,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
4770,
6013,
11253,
10975,
9816,
3085,
18447,
2121,
12172,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
2724,
1027,
1002,
2023,
1011,
1028,
2707,
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... |
getgrav/grav | system/src/Grav/Framework/Collection/AbstractIndexCollection.php | AbstractIndexCollection.set | public function set($key, $value)
{
if (!$this->isAllowedElement($value)) {
throw new \InvalidArgumentException('Invalid argument $value');
}
if ($key !== $value->getKey()) {
$value->setKey($key);
}
$this->entries[$key] = $this->getElementMeta($value);
} | php | public function set($key, $value)
{
if (!$this->isAllowedElement($value)) {
throw new \InvalidArgumentException('Invalid argument $value');
}
if ($key !== $value->getKey()) {
$value->setKey($key);
}
$this->entries[$key] = $this->getElementMeta($value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isAllowedElement",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid argument $value'",
")",
"... | {@inheritDoc} | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Collection/AbstractIndexCollection.php#L243-L254 | train | Set an element in the array | [
30522,
2270,
3853,
2275,
1006,
1002,
3145,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
18061,
7174,
15557,
12260,
3672,
1006,
1002,
3643,
1007,
1007,
1063,
5466,
2047,
1032,
19528,
2906,
22850,
15781,
2595,
24422,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/CronArchive.php | CronArchive.getTimezonesHavingNewDaySinceLastRun | private function getTimezonesHavingNewDaySinceLastRun()
{
$timestamp = $this->lastSuccessRunTimestamp;
$uniqueTimezones = APISitesManager::getInstance()->getUniqueSiteTimezones();
$timezoneToProcess = array();
foreach ($uniqueTimezones as &$timezone) {
$processedDateInTz = Date::factory((int)$timestamp, $timezone);
$currentDateInTz = Date::factory('now', $timezone);
if ($processedDateInTz->toString() != $currentDateInTz->toString()) {
$timezoneToProcess[] = $timezone;
}
}
return $timezoneToProcess;
} | php | private function getTimezonesHavingNewDaySinceLastRun()
{
$timestamp = $this->lastSuccessRunTimestamp;
$uniqueTimezones = APISitesManager::getInstance()->getUniqueSiteTimezones();
$timezoneToProcess = array();
foreach ($uniqueTimezones as &$timezone) {
$processedDateInTz = Date::factory((int)$timestamp, $timezone);
$currentDateInTz = Date::factory('now', $timezone);
if ($processedDateInTz->toString() != $currentDateInTz->toString()) {
$timezoneToProcess[] = $timezone;
}
}
return $timezoneToProcess;
} | [
"private",
"function",
"getTimezonesHavingNewDaySinceLastRun",
"(",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"lastSuccessRunTimestamp",
";",
"$",
"uniqueTimezones",
"=",
"APISitesManager",
"::",
"getInstance",
"(",
")",
"->",
"getUniqueSiteTimezones",
"(",
... | Returns the list of timezones where the specified timestamp in that timezone
is on a different day than today in that timezone.
@return array | [
"Returns",
"the",
"list",
"of",
"timezones",
"where",
"the",
"specified",
"timestamp",
"in",
"that",
"timezone",
"is",
"on",
"a",
"different",
"day",
"than",
"today",
"in",
"that",
"timezone",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L1311-L1325 | train | Returns the list of time zones where a new day was processed since the last run. | [
30522,
2797,
3853,
2131,
7292,
15975,
7377,
6455,
2638,
21724,
22916,
2378,
29109,
14083,
15532,
1006,
1007,
1063,
1002,
2335,
15464,
2361,
1027,
1002,
2023,
1011,
1028,
16180,
14194,
9623,
21338,
16671,
14428,
9153,
8737,
1025,
1002,
4310,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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 | database/migrations/2016_01_04_173148_create_admin_tables.php | CreateAdminTables.up | public function up()
{
Schema::create(config('admin.database.users_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('username', 190)->unique();
$table->string('password', 60);
$table->string('name');
$table->string('avatar')->nullable();
$table->string('remember_token', 100)->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.roles_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->timestamps();
});
Schema::create(config('admin.database.permissions_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->string('http_method')->nullable();
$table->text('http_path')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.menu_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_id')->default(0);
$table->integer('order')->default(0);
$table->string('title', 50);
$table->string('icon', 50);
$table->string('uri', 50)->nullable();
$table->string('permission')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.role_users_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('user_id');
$table->index(['role_id', 'user_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_permissions_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('permission_id');
$table->index(['role_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.user_permissions_table'), function (Blueprint $table) {
$table->integer('user_id');
$table->integer('permission_id');
$table->index(['user_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_menu_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('menu_id');
$table->index(['role_id', 'menu_id']);
$table->timestamps();
});
Schema::create(config('admin.database.operation_log_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('path');
$table->string('method', 10);
$table->string('ip');
$table->text('input');
$table->index('user_id');
$table->timestamps();
});
} | php | public function up()
{
Schema::create(config('admin.database.users_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('username', 190)->unique();
$table->string('password', 60);
$table->string('name');
$table->string('avatar')->nullable();
$table->string('remember_token', 100)->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.roles_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->timestamps();
});
Schema::create(config('admin.database.permissions_table'), function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50)->unique();
$table->string('slug', 50)->unique();
$table->string('http_method')->nullable();
$table->text('http_path')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.menu_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_id')->default(0);
$table->integer('order')->default(0);
$table->string('title', 50);
$table->string('icon', 50);
$table->string('uri', 50)->nullable();
$table->string('permission')->nullable();
$table->timestamps();
});
Schema::create(config('admin.database.role_users_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('user_id');
$table->index(['role_id', 'user_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_permissions_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('permission_id');
$table->index(['role_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.user_permissions_table'), function (Blueprint $table) {
$table->integer('user_id');
$table->integer('permission_id');
$table->index(['user_id', 'permission_id']);
$table->timestamps();
});
Schema::create(config('admin.database.role_menu_table'), function (Blueprint $table) {
$table->integer('role_id');
$table->integer('menu_id');
$table->index(['role_id', 'menu_id']);
$table->timestamps();
});
Schema::create(config('admin.database.operation_log_table'), function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('path');
$table->string('method', 10);
$table->string('ip');
$table->text('input');
$table->index('user_id');
$table->timestamps();
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"config",
"(",
"'admin.database.users_table'",
")",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table"... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/database/migrations/2016_01_04_173148_create_admin_tables.php#L22-L100 | train | Upgrades the schema | [
30522,
2270,
3853,
2039,
1006,
1007,
1063,
8040,
28433,
1024,
1024,
3443,
1006,
9530,
8873,
2290,
1006,
1005,
4748,
10020,
1012,
7809,
1012,
5198,
1035,
2795,
1005,
1007,
1010,
3853,
1006,
2630,
16550,
1002,
2795,
1007,
1063,
1002,
2795,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ConsoleCommand.php | ConsoleCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$this->serve();
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupConsole($input, $output);
$this->serve();
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"setupConsole",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"this",
"->",
"serve",
"(",
")",
";",
"}"... | @param InputInterface $input
@param OutputInterface $output
@return int|null|void | [
"@param",
"InputInterface",
"$input",
"@param",
"OutputInterface",
"$output"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/ConsoleCommand.php#L27-L31 | train | Execute the command | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
2023,
1011,
1028,
16437,
8663,
19454,
2063,
1006,
1002,
7953,
1010,
1002,
6434,
1007,
1025,
1002,
2023,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/OptimizeClearCommand.php | OptimizeClearCommand.handle | public function handle()
{
$this->call('view:clear');
$this->call('cache:clear');
$this->call('route:clear');
$this->call('config:clear');
$this->call('clear-compiled');
$this->info('Caches cleared successfully!');
} | php | public function handle()
{
$this->call('view:clear');
$this->call('cache:clear');
$this->call('route:clear');
$this->call('config:clear');
$this->call('clear-compiled');
$this->info('Caches cleared successfully!');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'view:clear'",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'cache:clear'",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'route:clear'",
")",
";",
"$",
"this",
"->",
"call",
... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/OptimizeClearCommand.php#L28-L37 | train | Clear all caches | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2655,
1006,
1005,
3193,
1024,
3154,
1005,
1007,
1025,
1002,
2023,
1011,
1028,
2655,
1006,
1005,
17053,
1024,
3154,
1005,
1007,
1025,
1002,
2023,
1011,
1028,
2655,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Filesystem/Folder.php | Folder.all | public static function all($path, array $params = [])
{
if ($path === false) {
throw new \RuntimeException("Path doesn't exist.");
}
$compare = isset($params['compare']) ? 'get' . $params['compare'] : null;
$pattern = $params['pattern'] ?? null;
$filters = $params['filters'] ?? null;
$recursive = $params['recursive'] ?? true;
$levels = $params['levels'] ?? -1;
$key = isset($params['key']) ? 'get' . $params['key'] : null;
$value = 'get' . ($params['value'] ?? ($recursive ? 'SubPathname' : 'Filename'));
$folders = $params['folders'] ?? true;
$files = $params['files'] ?? true;
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
if ($recursive) {
$flags = \RecursiveDirectoryIterator::SKIP_DOTS + \FilesystemIterator::UNIX_PATHS
+ \FilesystemIterator::CURRENT_AS_SELF + \FilesystemIterator::FOLLOW_SYMLINKS;
if ($locator->isStream($path)) {
$directory = $locator->getRecursiveIterator($path, $flags);
} else {
$directory = new \RecursiveDirectoryIterator($path, $flags);
}
$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
$iterator->setMaxDepth(max($levels, -1));
} else {
if ($locator->isStream($path)) {
$iterator = $locator->getIterator($path);
} else {
$iterator = new \FilesystemIterator($path);
}
}
$results = [];
/** @var \RecursiveDirectoryIterator $file */
foreach ($iterator as $file) {
// Ignore hidden files.
if (strpos($file->getFilename(), '.') === 0) {
continue;
}
if (!$folders && $file->isDir()) {
continue;
}
if (!$files && $file->isFile()) {
continue;
}
if ($compare && $pattern && !preg_match($pattern, $file->{$compare}())) {
continue;
}
$fileKey = $key ? $file->{$key}() : null;
$filePath = $file->{$value}();
if ($filters) {
if (isset($filters['key'])) {
$pre = !empty($filters['pre-key']) ? $filters['pre-key'] : '';
$fileKey = $pre . preg_replace($filters['key'], '', $fileKey);
}
if (isset($filters['value'])) {
$filter = $filters['value'];
if (is_callable($filter)) {
$filePath = $filter($file);
} else {
$filePath = preg_replace($filter, '', $filePath);
}
}
}
if ($fileKey !== null) {
$results[$fileKey] = $filePath;
} else {
$results[] = $filePath;
}
}
return $results;
} | php | public static function all($path, array $params = [])
{
if ($path === false) {
throw new \RuntimeException("Path doesn't exist.");
}
$compare = isset($params['compare']) ? 'get' . $params['compare'] : null;
$pattern = $params['pattern'] ?? null;
$filters = $params['filters'] ?? null;
$recursive = $params['recursive'] ?? true;
$levels = $params['levels'] ?? -1;
$key = isset($params['key']) ? 'get' . $params['key'] : null;
$value = 'get' . ($params['value'] ?? ($recursive ? 'SubPathname' : 'Filename'));
$folders = $params['folders'] ?? true;
$files = $params['files'] ?? true;
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
if ($recursive) {
$flags = \RecursiveDirectoryIterator::SKIP_DOTS + \FilesystemIterator::UNIX_PATHS
+ \FilesystemIterator::CURRENT_AS_SELF + \FilesystemIterator::FOLLOW_SYMLINKS;
if ($locator->isStream($path)) {
$directory = $locator->getRecursiveIterator($path, $flags);
} else {
$directory = new \RecursiveDirectoryIterator($path, $flags);
}
$iterator = new \RecursiveIteratorIterator($directory, \RecursiveIteratorIterator::SELF_FIRST);
$iterator->setMaxDepth(max($levels, -1));
} else {
if ($locator->isStream($path)) {
$iterator = $locator->getIterator($path);
} else {
$iterator = new \FilesystemIterator($path);
}
}
$results = [];
/** @var \RecursiveDirectoryIterator $file */
foreach ($iterator as $file) {
// Ignore hidden files.
if (strpos($file->getFilename(), '.') === 0) {
continue;
}
if (!$folders && $file->isDir()) {
continue;
}
if (!$files && $file->isFile()) {
continue;
}
if ($compare && $pattern && !preg_match($pattern, $file->{$compare}())) {
continue;
}
$fileKey = $key ? $file->{$key}() : null;
$filePath = $file->{$value}();
if ($filters) {
if (isset($filters['key'])) {
$pre = !empty($filters['pre-key']) ? $filters['pre-key'] : '';
$fileKey = $pre . preg_replace($filters['key'], '', $fileKey);
}
if (isset($filters['value'])) {
$filter = $filters['value'];
if (is_callable($filter)) {
$filePath = $filter($file);
} else {
$filePath = preg_replace($filter, '', $filePath);
}
}
}
if ($fileKey !== null) {
$results[$fileKey] = $filePath;
} else {
$results[] = $filePath;
}
}
return $results;
} | [
"public",
"static",
"function",
"all",
"(",
"$",
"path",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Path doesn't exist.\"",
")",
";",
"}",
... | Return recursive list of all files and directories under given path.
@param string $path
@param array $params
@return array
@throws \RuntimeException | [
"Return",
"recursive",
"list",
"of",
"all",
"files",
"and",
"directories",
"under",
"given",
"path",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Filesystem/Folder.php#L197-L275 | train | Get all files and folders from a path | [
30522,
2270,
10763,
3853,
2035,
1006,
1002,
4130,
1010,
9140,
1002,
11498,
5244,
1027,
1031,
1033,
30524,
1056,
4839,
1012,
1000,
1007,
1025,
1065,
1002,
12826,
1027,
26354,
3388,
1006,
1002,
11498,
5244,
1031,
1005,
12826,
1005,
1033,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Uri.php | Uri.baseIncludingLanguage | public function baseIncludingLanguage()
{
$grav = Grav::instance();
/** @var Pages $pages */
$pages = $grav['pages'];
return $pages->baseUrl(null, false);
} | php | public function baseIncludingLanguage()
{
$grav = Grav::instance();
/** @var Pages $pages */
$pages = $grav['pages'];
return $pages->baseUrl(null, false);
} | [
"public",
"function",
"baseIncludingLanguage",
"(",
")",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"/** @var Pages $pages */",
"$",
"pages",
"=",
"$",
"grav",
"[",
"'pages'",
"]",
";",
"return",
"$",
"pages",
"->",
"baseUrl",
"(",
"... | Return the base relative URL including the language prefix
or the base relative url if multi-language is not enabled
@return String The base of the URI | [
"Return",
"the",
"base",
"relative",
"URL",
"including",
"the",
"language",
"prefix",
"or",
"the",
"base",
"relative",
"url",
"if",
"multi",
"-",
"language",
"is",
"not",
"enabled"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L511-L519 | train | Get base including language | [
30522,
2270,
3853,
2918,
2378,
20464,
24539,
25023,
6692,
3351,
1006,
1007,
1063,
1002,
24665,
11431,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1025,
1013,
1008,
1008,
1030,
13075,
5530,
1002,
5530,
1008,
1013,
1002,
5530,
1027,
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... |
guzzle/guzzle | src/Handler/EasyHandle.php | EasyHandle.createResponse | public function createResponse()
{
if (empty($this->headers)) {
throw new \RuntimeException('No headers have been received');
}
// HTTP-version SP status-code SP reason-phrase
$startLine = explode(' ', array_shift($this->headers), 3);
$headers = \GuzzleHttp\headers_from_lines($this->headers);
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
if (!empty($this->options['decode_content'])
&& isset($normalizedKeys['content-encoding'])
) {
$headers['x-encoded-content-encoding']
= $headers[$normalizedKeys['content-encoding']];
unset($headers[$normalizedKeys['content-encoding']]);
if (isset($normalizedKeys['content-length'])) {
$headers['x-encoded-content-length']
= $headers[$normalizedKeys['content-length']];
$bodyLength = (int) $this->sink->getSize();
if ($bodyLength) {
$headers[$normalizedKeys['content-length']] = $bodyLength;
} else {
unset($headers[$normalizedKeys['content-length']]);
}
}
}
// Attach a response to the easy handle with the parsed headers.
$this->response = new Response(
$startLine[1],
$headers,
$this->sink,
substr($startLine[0], 5),
isset($startLine[2]) ? (string) $startLine[2] : null
);
} | php | public function createResponse()
{
if (empty($this->headers)) {
throw new \RuntimeException('No headers have been received');
}
// HTTP-version SP status-code SP reason-phrase
$startLine = explode(' ', array_shift($this->headers), 3);
$headers = \GuzzleHttp\headers_from_lines($this->headers);
$normalizedKeys = \GuzzleHttp\normalize_header_keys($headers);
if (!empty($this->options['decode_content'])
&& isset($normalizedKeys['content-encoding'])
) {
$headers['x-encoded-content-encoding']
= $headers[$normalizedKeys['content-encoding']];
unset($headers[$normalizedKeys['content-encoding']]);
if (isset($normalizedKeys['content-length'])) {
$headers['x-encoded-content-length']
= $headers[$normalizedKeys['content-length']];
$bodyLength = (int) $this->sink->getSize();
if ($bodyLength) {
$headers[$normalizedKeys['content-length']] = $bodyLength;
} else {
unset($headers[$normalizedKeys['content-length']]);
}
}
}
// Attach a response to the easy handle with the parsed headers.
$this->response = new Response(
$startLine[1],
$headers,
$this->sink,
substr($startLine[0], 5),
isset($startLine[2]) ? (string) $startLine[2] : null
);
} | [
"public",
"function",
"createResponse",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No headers have been received'",
")",
";",
"}",
"// HTTP-version SP status-code SP reason-... | Attach a response to the easy handle based on the received headers.
@throws \RuntimeException if no headers have been received. | [
"Attach",
"a",
"response",
"to",
"the",
"easy",
"handle",
"based",
"on",
"the",
"received",
"headers",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Handler/EasyHandle.php#L45-L83 | train | Create a response object from the headers received by the client | [
30522,
2270,
3853,
3443,
6072,
26029,
3366,
1006,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
20346,
2015,
1007,
1007,
1063,
5466,
2047,
1032,
2448,
7292,
10288,
24422,
1006,
1005,
2053,
20346,
2015,
2031,
2042,
2363,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormTabs.php | FormTabs.removeField | public function removeField($name)
{
foreach ($this->fields as $tab => $fields) {
foreach ($fields as $fieldName => $field) {
if ($fieldName == $name) {
unset($this->fields[$tab][$fieldName]);
/*
* Remove empty tabs from collection
*/
if (!count($this->fields[$tab])) {
unset($this->fields[$tab]);
}
return true;
}
}
}
return false;
} | php | public function removeField($name)
{
foreach ($this->fields as $tab => $fields) {
foreach ($fields as $fieldName => $field) {
if ($fieldName == $name) {
unset($this->fields[$tab][$fieldName]);
/*
* Remove empty tabs from collection
*/
if (!count($this->fields[$tab])) {
unset($this->fields[$tab]);
}
return true;
}
}
}
return false;
} | [
"public",
"function",
"removeField",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"tab",
"=>",
"$",
"fields",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"field",
")",
"{",
"if"... | Remove a field from all tabs by name.
@param string $name
@return boolean | [
"Remove",
"a",
"field",
"from",
"all",
"tabs",
"by",
"name",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormTabs.php#L131-L151 | train | Removes a field from the fields collection | [
30522,
2270,
3853,
6366,
3790,
1006,
1002,
2171,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
4249,
2004,
1002,
21628,
1027,
1028,
1002,
4249,
1007,
1063,
18921,
6776,
1006,
1002,
4249,
2004,
1002,
2492,
18442,
1027,
1028,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php | ProfilerController.toolbarAction | public function toolbarAction(Request $request, $token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
}
if ($request->hasSession() && ($session = $request->getSession()) && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
if ('empty' === $token || null === $token) {
return new Response('', 200, ['Content-Type' => 'text/html']);
}
$this->profiler->disable();
if (!$profile = $this->profiler->loadProfile($token)) {
return new Response('', 404, ['Content-Type' => 'text/html']);
}
$url = null;
try {
$url = $this->generator->generate('_profiler', ['token' => $token]);
} catch (\Exception $e) {
// the profiler is not enabled
}
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', [
'request' => $request,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getNames($profile),
'profiler_url' => $url,
'token' => $token,
'profiler_markup_version' => 2, // 1 = original toolbar, 2 = Symfony 2.8+ toolbar
]);
} | php | public function toolbarAction(Request $request, $token)
{
if (null === $this->profiler) {
throw new NotFoundHttpException('The profiler must be enabled.');
}
if ($request->hasSession() && ($session = $request->getSession()) && $session->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
if ('empty' === $token || null === $token) {
return new Response('', 200, ['Content-Type' => 'text/html']);
}
$this->profiler->disable();
if (!$profile = $this->profiler->loadProfile($token)) {
return new Response('', 404, ['Content-Type' => 'text/html']);
}
$url = null;
try {
$url = $this->generator->generate('_profiler', ['token' => $token]);
} catch (\Exception $e) {
// the profiler is not enabled
}
return $this->renderWithCspNonces($request, '@WebProfiler/Profiler/toolbar.html.twig', [
'request' => $request,
'profile' => $profile,
'templates' => $this->getTemplateManager()->getNames($profile),
'profiler_url' => $url,
'token' => $token,
'profiler_markup_version' => 2, // 1 = original toolbar, 2 = Symfony 2.8+ toolbar
]);
} | [
"public",
"function",
"toolbarAction",
"(",
"Request",
"$",
"request",
",",
"$",
"token",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"profiler",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The profiler must be enabled.'",
")",
";",
... | Renders the Web Debug Toolbar.
@param Request $request The current HTTP Request
@param string $token The profiler token
@return Response A Response instance
@throws NotFoundHttpException | [
"Renders",
"the",
"Web",
"Debug",
"Toolbar",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php#L118-L154 | train | Renders the profiler toolbar | [
30522,
2270,
3853,
6994,
20709,
7542,
1006,
5227,
1002,
5227,
1010,
1002,
19204,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
6337,
2099,
1007,
1063,
5466,
2047,
2025,
14876,
8630,
11039,
25856,
10288,
24422,
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... |
walkor/Workerman | Connection/TcpConnection.php | TcpConnection.baseWrite | public function baseWrite()
{
set_error_handler(function(){});
if ($this->transport === 'ssl') {
$len = fwrite($this->_socket, $this->_sendBuffer, 8192);
} else {
$len = fwrite($this->_socket, $this->_sendBuffer);
}
restore_error_handler();
if ($len === strlen($this->_sendBuffer)) {
$this->bytesWritten += $len;
Worker::$globalEvent->del($this->_socket, EventInterface::EV_WRITE);
$this->_sendBuffer = '';
// Try to emit onBufferDrain callback when the send buffer becomes empty.
if ($this->onBufferDrain) {
try {
call_user_func($this->onBufferDrain, $this);
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
if ($this->_status === self::STATUS_CLOSING) {
$this->destroy();
}
return true;
}
if ($len > 0) {
$this->bytesWritten += $len;
$this->_sendBuffer = substr($this->_sendBuffer, $len);
} else {
self::$statistics['send_fail']++;
$this->destroy();
}
} | php | public function baseWrite()
{
set_error_handler(function(){});
if ($this->transport === 'ssl') {
$len = fwrite($this->_socket, $this->_sendBuffer, 8192);
} else {
$len = fwrite($this->_socket, $this->_sendBuffer);
}
restore_error_handler();
if ($len === strlen($this->_sendBuffer)) {
$this->bytesWritten += $len;
Worker::$globalEvent->del($this->_socket, EventInterface::EV_WRITE);
$this->_sendBuffer = '';
// Try to emit onBufferDrain callback when the send buffer becomes empty.
if ($this->onBufferDrain) {
try {
call_user_func($this->onBufferDrain, $this);
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
if ($this->_status === self::STATUS_CLOSING) {
$this->destroy();
}
return true;
}
if ($len > 0) {
$this->bytesWritten += $len;
$this->_sendBuffer = substr($this->_sendBuffer, $len);
} else {
self::$statistics['send_fail']++;
$this->destroy();
}
} | [
"public",
"function",
"baseWrite",
"(",
")",
"{",
"set_error_handler",
"(",
"function",
"(",
")",
"{",
"}",
")",
";",
"if",
"(",
"$",
"this",
"->",
"transport",
"===",
"'ssl'",
")",
"{",
"$",
"len",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"_socket",
... | Base write handler.
@return void|bool | [
"Base",
"write",
"handler",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L698-L735 | train | Base write method. | [
30522,
2270,
3853,
2918,
26373,
1006,
1007,
1063,
2275,
1035,
7561,
1035,
28213,
1006,
3853,
1006,
1007,
1063,
1065,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
3665,
1027,
1027,
1027,
1005,
7020,
2140,
1005,
1007,
1063,
1002,
18798,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement/Oracle.php | Zend_Db_Statement_Oracle.errorCode | public function errorCode()
{
if (!$this->_stmt) {
return false;
}
$error = oci_error($this->_stmt);
if (!$error) {
return false;
}
return $error['code'];
} | php | public function errorCode()
{
if (!$this->_stmt) {
return false;
}
$error = oci_error($this->_stmt);
if (!$error) {
return false;
}
return $error['code'];
} | [
"public",
"function",
"errorCode",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_stmt",
")",
"{",
"return",
"false",
";",
"}",
"$",
"error",
"=",
"oci_error",
"(",
"$",
"this",
"->",
"_stmt",
")",
";",
"if",
"(",
"!",
"$",
"error",
")",
"... | Retrieves the error code, if any, associated with the last operation on
the statement handle.
@return string error code. | [
"Retrieves",
"the",
"error",
"code",
"if",
"any",
"associated",
"with",
"the",
"last",
"operation",
"on",
"the",
"statement",
"handle",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Oracle.php#L173-L186 | train | Get the error code of the last statement | [
30522,
2270,
3853,
7561,
16044,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
7561,
1027,
1051,
6895,
1035,
7561,
1006,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Notification/Manager.php | Manager.cancelAllNonPersistent | public static function cancelAllNonPersistent()
{
foreach (static::getAllNotifications() as $id => $notification) {
if (Notification::TYPE_PERSISTENT != $notification->type) {
static::removeNotification($id);
}
}
} | php | public static function cancelAllNonPersistent()
{
foreach (static::getAllNotifications() as $id => $notification) {
if (Notification::TYPE_PERSISTENT != $notification->type) {
static::removeNotification($id);
}
}
} | [
"public",
"static",
"function",
"cancelAllNonPersistent",
"(",
")",
"{",
"foreach",
"(",
"static",
"::",
"getAllNotifications",
"(",
")",
"as",
"$",
"id",
"=>",
"$",
"notification",
")",
"{",
"if",
"(",
"Notification",
"::",
"TYPE_PERSISTENT",
"!=",
"$",
"no... | Removes all temporary notifications.
Call this method after the notifications have been
displayed to make sure temporary notifications won't be displayed twice. | [
"Removes",
"all",
"temporary",
"notifications",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Notification/Manager.php#L67-L74 | train | Cancel all notifications that are not persistent | [
30522,
2270,
10763,
3853,
17542,
8095,
8540,
7347,
27870,
3372,
1006,
1007,
1063,
18921,
6776,
1006,
10763,
30524,
1006,
1002,
8909,
1007,
1025,
1065,
1065,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/BrowserKit/Client.php | Client.getResponse | public function getResponse()
{
if (null === $this->response) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
return $this->response;
} | php | public function getResponse()
{
if (null === $this->response) {
@trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
// throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
}
return $this->response;
} | [
"public",
"function",
"getResponse",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"response",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'Calling the \"%s()\" method before the \"request()\" one is deprecated since Symfony 4.1 and will throw an exc... | Returns the current origin response instance.
The origin response is the response instance that is returned
by the code that handles requests.
@return object A response instance
@see doRequest() | [
"Returns",
"the",
"current",
"origin",
"response",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/Client.php#L236-L244 | train | Returns the response object | [
30522,
2270,
3853,
2131,
6072,
26029,
3366,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
3433,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
4214,
1996,
1000,
1003,
1055,
1006,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | HttpCache.pass | protected function pass(Request $request, $catch = false)
{
$this->record($request, 'pass');
return $this->forward($request, $catch);
} | php | protected function pass(Request $request, $catch = false)
{
$this->record($request, 'pass');
return $this->forward($request, $catch);
} | [
"protected",
"function",
"pass",
"(",
"Request",
"$",
"request",
",",
"$",
"catch",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"record",
"(",
"$",
"request",
",",
"'pass'",
")",
";",
"return",
"$",
"this",
"->",
"forward",
"(",
"$",
"request",
",",
... | Forwards the Request to the backend without storing the Response in the cache.
@param Request $request A Request instance
@param bool $catch Whether to process exceptions
@return Response A Response instance | [
"Forwards",
"the",
"Request",
"to",
"the",
"backend",
"without",
"storing",
"the",
"Response",
"in",
"the",
"cache",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php#L264-L269 | train | Forward to the next page of content | [
30522,
5123,
3853,
3413,
1006,
5227,
1002,
5227,
1010,
1002,
4608,
1027,
6270,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DBStats/Reports/Base.php | Base.setIndividualSummaryFooterMessage | protected function setIndividualSummaryFooterMessage(ViewDataTable $view)
{
$lastGenerated = self::getDateOfLastCachingRun();
if ($lastGenerated !== false) {
$view->config->show_footer_message = Piwik::translate('Mobile_LastUpdated', $lastGenerated);
}
} | php | protected function setIndividualSummaryFooterMessage(ViewDataTable $view)
{
$lastGenerated = self::getDateOfLastCachingRun();
if ($lastGenerated !== false) {
$view->config->show_footer_message = Piwik::translate('Mobile_LastUpdated', $lastGenerated);
}
} | [
"protected",
"function",
"setIndividualSummaryFooterMessage",
"(",
"ViewDataTable",
"$",
"view",
")",
"{",
"$",
"lastGenerated",
"=",
"self",
"::",
"getDateOfLastCachingRun",
"(",
")",
";",
"if",
"(",
"$",
"lastGenerated",
"!==",
"false",
")",
"{",
"$",
"view",
... | Sets the footer message for the Individual...Summary reports. | [
"Sets",
"the",
"footer",
"message",
"for",
"the",
"Individual",
"...",
"Summary",
"reports",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/DBStats/Reports/Base.php#L147-L153 | train | Set Individual Summary footer message | [
30522,
5123,
3853,
2275,
22254,
12848,
3593,
8787,
17421,
7849,
2100,
13064,
2121,
7834,
3736,
3351,
1006,
3193,
2850,
29336,
3085,
1002,
3193,
1007,
1063,
1002,
2197,
6914,
16848,
1027,
2969,
1024,
1024,
2131,
13701,
11253,
8523,
13535,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Kernel.php | Kernel.getName | public function getName(/* $triggerDeprecation = true */)
{
if (0 === \func_num_args() || func_get_arg(0)) {
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
if (null === $this->name) {
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
if (ctype_digit($this->name[0])) {
$this->name = '_'.$this->name;
}
}
return $this->name;
} | php | public function getName(/* $triggerDeprecation = true */)
{
if (0 === \func_num_args() || func_get_arg(0)) {
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
}
if (null === $this->name) {
$this->name = preg_replace('/[^a-zA-Z0-9_]+/', '', basename($this->rootDir));
if (ctype_digit($this->name[0])) {
$this->name = '_'.$this->name;
}
}
return $this->name;
} | [
"public",
"function",
"getName",
"(",
"/* $triggerDeprecation = true */",
")",
"{",
"if",
"(",
"0",
"===",
"\\",
"func_num_args",
"(",
")",
"||",
"func_get_arg",
"(",
"0",
")",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'The \"%s()\" method is depreca... | {@inheritdoc}
@deprecated since Symfony 4.2 | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Kernel.php#L286-L300 | train | Returns the name of the current language | [
30522,
2270,
3853,
2131,
18442,
1006,
1013,
1008,
1002,
9495,
3207,
28139,
10719,
1027,
2995,
1008,
1013,
1007,
1063,
2065,
1006,
1014,
1027,
1027,
1027,
1032,
4569,
2278,
1035,
16371,
2213,
1035,
12098,
5620,
1006,
1007,
1064,
1064,
4569,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/Storage/FolderStorage.php | FolderStorage.buildIndex | protected function buildIndex(): array
{
$path = $this->getStoragePath();
if (!file_exists($path)) {
return [];
}
if ($this->prefixed) {
$list = $this->buildPrefixedIndexFromFilesystem($path);
} else {
$list = $this->buildIndexFromFilesystem($path);
}
ksort($list, SORT_NATURAL);
return $list;
} | php | protected function buildIndex(): array
{
$path = $this->getStoragePath();
if (!file_exists($path)) {
return [];
}
if ($this->prefixed) {
$list = $this->buildPrefixedIndexFromFilesystem($path);
} else {
$list = $this->buildIndexFromFilesystem($path);
}
ksort($list, SORT_NATURAL);
return $list;
} | [
"protected",
"function",
"buildIndex",
"(",
")",
":",
"array",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getStoragePath",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$"... | Returns list of all stored keys in [key => timestamp] pairs.
@return array | [
"Returns",
"list",
"of",
"all",
"stored",
"keys",
"in",
"[",
"key",
"=",
">",
"timestamp",
"]",
"pairs",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/Storage/FolderStorage.php#L371-L387 | train | Build the index from the filesystem | [
30522,
5123,
3853,
3857,
22254,
10288,
1006,
1007,
1024,
9140,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
4152,
4263,
4270,
15069,
1006,
1007,
1025,
2065,
1006,
999,
5371,
1035,
6526,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
1031,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Form.php | Form.prepareInsert | protected function prepareInsert($inserts)
{
if ($this->isHasOneRelation($inserts)) {
$inserts = Arr::dot($inserts);
}
foreach ($inserts as $column => $value) {
if (is_null($field = $this->getFieldByColumn($column))) {
unset($inserts[$column]);
continue;
}
$inserts[$column] = $field->prepare($value);
}
$prepared = [];
foreach ($inserts as $key => $value) {
Arr::set($prepared, $key, $value);
}
return $prepared;
} | php | protected function prepareInsert($inserts)
{
if ($this->isHasOneRelation($inserts)) {
$inserts = Arr::dot($inserts);
}
foreach ($inserts as $column => $value) {
if (is_null($field = $this->getFieldByColumn($column))) {
unset($inserts[$column]);
continue;
}
$inserts[$column] = $field->prepare($value);
}
$prepared = [];
foreach ($inserts as $key => $value) {
Arr::set($prepared, $key, $value);
}
return $prepared;
} | [
"protected",
"function",
"prepareInsert",
"(",
"$",
"inserts",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isHasOneRelation",
"(",
"$",
"inserts",
")",
")",
"{",
"$",
"inserts",
"=",
"Arr",
"::",
"dot",
"(",
"$",
"inserts",
")",
";",
"}",
"foreach",
"("... | Prepare input data for insert.
@param $inserts
@return array | [
"Prepare",
"input",
"data",
"for",
"insert",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form.php#L923-L945 | train | Prepare insert values | [
30522,
5123,
3853,
7374,
7076,
8743,
1006,
1002,
19274,
2015,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
14949,
5643,
16570,
3370,
1006,
1002,
19274,
2015,
1007,
1007,
1063,
1002,
19274,
2015,
1027,
12098,
2099,
1024,
1024,
11089... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DependencyInjection/AbstractDoctrineExtension.php | AbstractDoctrineExtension.assertValidMappingConfiguration | protected function assertValidMappingConfiguration(array $mappingConfig, $objectManagerName)
{
if (!$mappingConfig['type'] || !$mappingConfig['dir'] || !$mappingConfig['prefix']) {
throw new \InvalidArgumentException(sprintf('Mapping definitions for Doctrine manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName));
}
if (!is_dir($mappingConfig['dir'])) {
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
}
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'annotation', 'php', 'staticphp'])) {
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
'You can register them by adding a new driver to the '.
'"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')
));
}
} | php | protected function assertValidMappingConfiguration(array $mappingConfig, $objectManagerName)
{
if (!$mappingConfig['type'] || !$mappingConfig['dir'] || !$mappingConfig['prefix']) {
throw new \InvalidArgumentException(sprintf('Mapping definitions for Doctrine manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName));
}
if (!is_dir($mappingConfig['dir'])) {
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
}
if (!\in_array($mappingConfig['type'], ['xml', 'yml', 'annotation', 'php', 'staticphp'])) {
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
'You can register them by adding a new driver to the '.
'"%s" service definition.', $this->getObjectManagerElementName($objectManagerName.'_metadata_driver')
));
}
} | [
"protected",
"function",
"assertValidMappingConfiguration",
"(",
"array",
"$",
"mappingConfig",
",",
"$",
"objectManagerName",
")",
"{",
"if",
"(",
"!",
"$",
"mappingConfig",
"[",
"'type'",
"]",
"||",
"!",
"$",
"mappingConfig",
"[",
"'dir'",
"]",
"||",
"!",
... | Assertion if the specified mapping information is valid.
@param array $mappingConfig
@param string $objectManagerName
@throws \InvalidArgumentException | [
"Assertion",
"if",
"the",
"specified",
"mapping",
"information",
"is",
"valid",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php#L233-L250 | train | Assert that the mapping configuration is valid. | [
30522,
5123,
3853,
20865,
10175,
3593,
2863,
14853,
8663,
8873,
27390,
3370,
1006,
9140,
1002,
12375,
8663,
8873,
2290,
1010,
1002,
4874,
24805,
4590,
18442,
1007,
1063,
2065,
1006,
999,
1002,
12375,
8663,
8873,
2290,
1031,
1005,
2828,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php | PassConfig.addPass | public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
{
$property = $type.'Passes';
if (!isset($this->$property)) {
throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
}
$passes = &$this->$property;
if (!isset($passes[$priority])) {
$passes[$priority] = [];
}
$passes[$priority][] = $pass;
} | php | public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION, int $priority = 0)
{
$property = $type.'Passes';
if (!isset($this->$property)) {
throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
}
$passes = &$this->$property;
if (!isset($passes[$priority])) {
$passes[$priority] = [];
}
$passes[$priority][] = $pass;
} | [
"public",
"function",
"addPass",
"(",
"CompilerPassInterface",
"$",
"pass",
",",
"$",
"type",
"=",
"self",
"::",
"TYPE_BEFORE_OPTIMIZATION",
",",
"int",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"property",
"=",
"$",
"type",
".",
"'Passes'",
";",
"if",
"... | Adds a pass.
@param CompilerPassInterface $pass A Compiler pass
@param string $type The pass type
@param int $priority Used to sort the passes
@throws InvalidArgumentException when a pass type doesn't exist | [
"Adds",
"a",
"pass",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php#L119-L132 | train | Adds a pass to the list of passes | [
30522,
2270,
3853,
5587,
15194,
1006,
21624,
15194,
18447,
2121,
12172,
1002,
3413,
1010,
1002,
2828,
1027,
2969,
1024,
1024,
2828,
1035,
2077,
1035,
20600,
1010,
20014,
1002,
9470,
1027,
1014,
1007,
1063,
1002,
3200,
1027,
1002,
2828,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Report.php | Report.getProcessedMetrics | public function getProcessedMetrics()
{
if (!is_array($this->processedMetrics)) {
return $this->processedMetrics;
}
return $this->getMetricTranslations($this->processedMetrics);
} | php | public function getProcessedMetrics()
{
if (!is_array($this->processedMetrics)) {
return $this->processedMetrics;
}
return $this->getMetricTranslations($this->processedMetrics);
} | [
"public",
"function",
"getProcessedMetrics",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"processedMetrics",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processedMetrics",
";",
"}",
"return",
"$",
"this",
"->",
"getMetricTranslations"... | Returns an array of supported processed metrics and their corresponding translations. Eg
`array('nb_visits' => 'Visits')`. By default the given {@link $processedMetrics} are used and their
corresponding translations are looked up automatically. If a metric is not translated, you should add the
default metric translation for this metric using the {@hook Metrics.getDefaultMetricTranslations} event. If you
want to overwrite any default metric translation you should overwrite this method, call this parent method to
get all default translations and overwrite any custom metric translations.
@return array|mixed
@api | [
"Returns",
"an",
"array",
"of",
"supported",
"processed",
"metrics",
"and",
"their",
"corresponding",
"translations",
".",
"Eg",
"array",
"(",
"nb_visits",
"=",
">",
"Visits",
")",
".",
"By",
"default",
"the",
"given",
"{"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Report.php#L436-L443 | train | Get processed metrics | [
30522,
2270,
3853,
2131,
21572,
9623,
6924,
12589,
2015,
1006,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
2023,
1011,
1028,
13995,
12589,
2015,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
13995,
12589,
2015,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php | Hour1200Transformer.normalizeHour | public function normalizeHour(int $hour, string $marker = null): int
{
if ('PM' === $marker) {
$hour += 12;
}
return $hour;
} | php | public function normalizeHour(int $hour, string $marker = null): int
{
if ('PM' === $marker) {
$hour += 12;
}
return $hour;
} | [
"public",
"function",
"normalizeHour",
"(",
"int",
"$",
"hour",
",",
"string",
"$",
"marker",
"=",
"null",
")",
":",
"int",
"{",
"if",
"(",
"'PM'",
"===",
"$",
"marker",
")",
"{",
"$",
"hour",
"+=",
"12",
";",
"}",
"return",
"$",
"hour",
";",
"}"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php#L37-L44 | train | Normalize hour value | [
30522,
2270,
3853,
3671,
4697,
6806,
3126,
1006,
20014,
1002,
3178,
1010,
5164,
1002,
12115,
1027,
19701,
1007,
1024,
20014,
1063,
2065,
1006,
1005,
7610,
1005,
1027,
1027,
1027,
1002,
12115,
1007,
1063,
1002,
3178,
1009,
1027,
2260,
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 | core/DataArray.php | DataArray.sumMetrics | public function sumMetrics($label, $row)
{
foreach ($row as $columnName => $columnValue) {
if (empty($columnValue)) {
continue;
}
if (empty($this->data[$label][$columnName])) {
$this->data[$label][$columnName] = 0;
}
if (!is_numeric($columnValue)) {
throw new Exception("DataArray->sumMetricsPivot expects rows of numeric values, non numeric found: " . var_export($columnValue, true) . " for column $columnName");
}
$this->data[$label][$columnName] += $columnValue;
}
} | php | public function sumMetrics($label, $row)
{
foreach ($row as $columnName => $columnValue) {
if (empty($columnValue)) {
continue;
}
if (empty($this->data[$label][$columnName])) {
$this->data[$label][$columnName] = 0;
}
if (!is_numeric($columnValue)) {
throw new Exception("DataArray->sumMetricsPivot expects rows of numeric values, non numeric found: " . var_export($columnValue, true) . " for column $columnName");
}
$this->data[$label][$columnName] += $columnValue;
}
} | [
"public",
"function",
"sumMetrics",
"(",
"$",
"label",
",",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"row",
"as",
"$",
"columnName",
"=>",
"$",
"columnValue",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"columnValue",
")",
")",
"{",
"continue",
";",
... | Generic function that will sum all columns of the given row, at the specified label's row.
@param $label
@param $row
@throws Exception if the the data row contains non numeric values | [
"Generic",
"function",
"that",
"will",
"sum",
"all",
"columns",
"of",
"the",
"given",
"row",
"at",
"the",
"specified",
"label",
"s",
"row",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataArray.php#L308-L322 | train | Sums all columns of a row of data | [
30522,
2270,
3853,
7680,
12589,
2015,
1006,
1002,
3830,
1010,
1002,
5216,
1007,
1063,
18921,
6776,
1006,
1002,
5216,
2004,
1002,
5930,
18442,
1027,
1028,
1002,
5930,
10175,
5657,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
5930,
10175,
5657,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Pipeline/Pipeline.php | Pipeline.then | public function then(Closure $destination)
{
$pipeline = array_reduce(
array_reverse($this->pipes), $this->carry(), $this->prepareDestination($destination)
);
return $pipeline($this->passable);
} | php | public function then(Closure $destination)
{
$pipeline = array_reduce(
array_reverse($this->pipes), $this->carry(), $this->prepareDestination($destination)
);
return $pipeline($this->passable);
} | [
"public",
"function",
"then",
"(",
"Closure",
"$",
"destination",
")",
"{",
"$",
"pipeline",
"=",
"array_reduce",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"pipes",
")",
",",
"$",
"this",
"->",
"carry",
"(",
")",
",",
"$",
"this",
"->",
"prepareDes... | Run the pipeline with a final destination callback.
@param \Closure $destination
@return mixed | [
"Run",
"the",
"pipeline",
"with",
"a",
"final",
"destination",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Pipeline/Pipeline.php#L98-L105 | train | Passes the pipeline to the destination and passes the result to the next pipeline. | [
30522,
2270,
3853,
2059,
1006,
8503,
1002,
7688,
1007,
1063,
1002,
13117,
1027,
9140,
1035,
5547,
1006,
9140,
1035,
7901,
1006,
30524,
1002,
13117,
1006,
1002,
2023,
1011,
1028,
3413,
3085,
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... |
symfony/symfony | src/Symfony/Component/HttpClient/CurlHttpClient.php | CurlHttpClient.stream | public function stream($responses, float $timeout = null): ResponseStreamInterface
{
if ($responses instanceof CurlResponse) {
$responses = [$responses];
} elseif (!\is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
}
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
return new ResponseStream(CurlResponse::stream($responses, $timeout));
} | php | public function stream($responses, float $timeout = null): ResponseStreamInterface
{
if ($responses instanceof CurlResponse) {
$responses = [$responses];
} elseif (!\is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
}
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
return new ResponseStream(CurlResponse::stream($responses, $timeout));
} | [
"public",
"function",
"stream",
"(",
"$",
"responses",
",",
"float",
"$",
"timeout",
"=",
"null",
")",
":",
"ResponseStreamInterface",
"{",
"if",
"(",
"$",
"responses",
"instanceof",
"CurlResponse",
")",
"{",
"$",
"responses",
"=",
"[",
"$",
"responses",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/CurlHttpClient.php#L280-L291 | train | Returns a stream of CurlResponse objects. | [
30522,
2270,
3853,
5460,
1006,
1002,
10960,
1010,
14257,
1002,
2051,
5833,
1027,
19701,
1007,
1024,
10960,
25379,
18447,
2121,
12172,
1063,
2065,
1006,
1002,
10960,
6013,
11253,
15390,
6072,
26029,
3366,
1007,
1063,
1002,
10960,
1027,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php | FullTransformer.buildCharsMatch | protected function buildCharsMatch($specialChars)
{
$specialCharsArray = str_split($specialChars);
$specialCharsMatch = implode('|', array_map(function ($char) {
return $char.'+';
}, $specialCharsArray));
return $specialCharsMatch;
} | php | protected function buildCharsMatch($specialChars)
{
$specialCharsArray = str_split($specialChars);
$specialCharsMatch = implode('|', array_map(function ($char) {
return $char.'+';
}, $specialCharsArray));
return $specialCharsMatch;
} | [
"protected",
"function",
"buildCharsMatch",
"(",
"$",
"specialChars",
")",
"{",
"$",
"specialCharsArray",
"=",
"str_split",
"(",
"$",
"specialChars",
")",
";",
"$",
"specialCharsMatch",
"=",
"implode",
"(",
"'|'",
",",
"array_map",
"(",
"function",
"(",
"$",
... | Builds a chars match regular expression.
@param string $specialChars A string of chars to build the regular expression
@return string The chars match regular expression | [
"Builds",
"a",
"chars",
"match",
"regular",
"expression",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php#L239-L248 | train | Build the special chars match | [
30522,
5123,
3853,
3857,
7507,
2869,
18900,
2818,
1006,
1002,
2569,
7507,
2869,
1007,
1063,
1002,
2569,
7507,
22381,
11335,
2100,
1027,
2358,
2099,
1035,
3975,
1006,
1002,
2569,
7507,
2869,
1007,
1025,
1002,
2569,
7507,
2869,
18900,
2818,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Builder.php | Builder.table | public function table($table, Closure $callback)
{
$this->build($this->createBlueprint($table, $callback));
} | php | public function table($table, Closure $callback)
{
$this->build($this->createBlueprint($table, $callback));
} | [
"public",
"function",
"table",
"(",
"$",
"table",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"build",
"(",
"$",
"this",
"->",
"createBlueprint",
"(",
"$",
"table",
",",
"$",
"callback",
")",
")",
";",
"}"
] | Modify a table on the schema.
@param string $table
@param \Closure $callback
@return void | [
"Modify",
"a",
"table",
"on",
"the",
"schema",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Builder.php#L149-L152 | train | Create the blueprint and build the tree | [
30522,
2270,
3853,
2795,
1006,
1002,
2795,
1010,
8503,
1002,
2655,
5963,
1007,
1063,
1002,
2023,
1011,
1028,
3857,
1006,
30524,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db/Adapter/Mysqli.php | Mysqli.exec | public function exec($sqlQuery)
{
$rc = mysqli_query($this->_connection, $sqlQuery);
$rowsAffected = mysqli_affected_rows($this->_connection);
if (!is_bool($rc)) {
mysqli_free_result($rc);
}
return $rowsAffected;
} | php | public function exec($sqlQuery)
{
$rc = mysqli_query($this->_connection, $sqlQuery);
$rowsAffected = mysqli_affected_rows($this->_connection);
if (!is_bool($rc)) {
mysqli_free_result($rc);
}
return $rowsAffected;
} | [
"public",
"function",
"exec",
"(",
"$",
"sqlQuery",
")",
"{",
"$",
"rc",
"=",
"mysqli_query",
"(",
"$",
"this",
"->",
"_connection",
",",
"$",
"sqlQuery",
")",
";",
"$",
"rowsAffected",
"=",
"mysqli_affected_rows",
"(",
"$",
"this",
"->",
"_connection",
... | Execute unprepared SQL query and throw away the result
Workaround some SQL statements not compatible with prepare().
See http://framework.zend.com/issues/browse/ZF-1398
@param string $sqlQuery
@return int Number of rows affected (SELECT/INSERT/UPDATE/DELETE) | [
"Execute",
"unprepared",
"SQL",
"query",
"and",
"throw",
"away",
"the",
"result"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Adapter/Mysqli.php#L207-L215 | train | Executes a query and returns the number of affected rows | [
30522,
2270,
3853,
4654,
8586,
1006,
1002,
29296,
4226,
2854,
1007,
1063,
1002,
22110,
1027,
2026,
2015,
4160,
3669,
1035,
23032,
1006,
1002,
2023,
1011,
1028,
1035,
4434,
1010,
1002,
29296,
4226,
2854,
1007,
1025,
1002,
10281,
10354,
25969... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Finder/Iterator/SizeRangeFilterIterator.php | SizeRangeFilterIterator.accept | public function accept()
{
$fileinfo = $this->current();
if (!$fileinfo->isFile()) {
return true;
}
$filesize = $fileinfo->getSize();
foreach ($this->comparators as $compare) {
if (!$compare->test($filesize)) {
return false;
}
}
return true;
} | php | public function accept()
{
$fileinfo = $this->current();
if (!$fileinfo->isFile()) {
return true;
}
$filesize = $fileinfo->getSize();
foreach ($this->comparators as $compare) {
if (!$compare->test($filesize)) {
return false;
}
}
return true;
} | [
"public",
"function",
"accept",
"(",
")",
"{",
"$",
"fileinfo",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"$",
"fileinfo",
"->",
"isFile",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"filesize",
"=",
"$",
"fileinf... | Filters the iterator values.
@return bool true if the value should be kept, false otherwise | [
"Filters",
"the",
"iterator",
"values",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php#L41-L56 | train | Accept a file | [
30522,
2270,
3853,
5138,
1006,
1007,
1063,
1002,
5371,
2378,
14876,
1027,
1002,
2023,
1011,
1028,
2783,
1006,
1007,
1025,
2065,
1006,
999,
1002,
5371,
2378,
14876,
1011,
1028,
2003,
8873,
2571,
1006,
1007,
1007,
1063,
2709,
2995,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/View/Engines/EngineResolver.php | EngineResolver.resolve | public function resolve($engine)
{
if (isset($this->resolved[$engine])) {
return $this->resolved[$engine];
}
if (isset($this->resolvers[$engine])) {
return $this->resolved[$engine] = call_user_func($this->resolvers[$engine]);
}
throw new InvalidArgumentException("Engine [{$engine}] not found.");
} | php | public function resolve($engine)
{
if (isset($this->resolved[$engine])) {
return $this->resolved[$engine];
}
if (isset($this->resolvers[$engine])) {
return $this->resolved[$engine] = call_user_func($this->resolvers[$engine]);
}
throw new InvalidArgumentException("Engine [{$engine}] not found.");
} | [
"public",
"function",
"resolve",
"(",
"$",
"engine",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"resolved",
"[",
"$",
"engine",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"resolved",
"[",
"$",
"engine",
"]",
";",
"}",
"if",
"(",
... | Resolve an engine instance by name.
@param string $engine
@return \Illuminate\Contracts\View\Engine
@throws \InvalidArgumentException | [
"Resolve",
"an",
"engine",
"instance",
"by",
"name",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/View/Engines/EngineResolver.php#L48-L59 | train | Resolve the engine | [
30522,
2270,
3853,
10663,
1006,
1002,
3194,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
10395,
1031,
1002,
3194,
1033,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
10395,
1031,
1002,
3194,
1033,
1025,
1065,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Kernel/Traits/HasHttpRequests.php | HasHttpRequests.getGuzzleHandler | protected function getGuzzleHandler()
{
if (property_exists($this, 'app') && isset($this->app['guzzle_handler']) && is_string($this->app['guzzle_handler'])) {
$handler = $this->app['guzzle_handler'];
return new $handler();
}
return \GuzzleHttp\choose_handler();
} | php | protected function getGuzzleHandler()
{
if (property_exists($this, 'app') && isset($this->app['guzzle_handler']) && is_string($this->app['guzzle_handler'])) {
$handler = $this->app['guzzle_handler'];
return new $handler();
}
return \GuzzleHttp\choose_handler();
} | [
"protected",
"function",
"getGuzzleHandler",
"(",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"'app'",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"app",
"[",
"'guzzle_handler'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"this",
"->",
"... | Get guzzle handler.
@return callable | [
"Get",
"guzzle",
"handler",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/Traits/HasHttpRequests.php#L219-L228 | train | Get Guzzle handler | [
30522,
5123,
3853,
2131,
12193,
17644,
11774,
3917,
1006,
1007,
1063,
2065,
1006,
3200,
1035,
6526,
1006,
1002,
2023,
1010,
1005,
10439,
1005,
1007,
1004,
1004,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
19739,
17644,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db.php | Db.getDbLock | public static function getDbLock($lockName, $maxRetries = 30)
{
if (strlen($lockName) > 64) {
throw new \Exception('DB lock name has to be 64 characters or less for MySQL 5.7 compatibility.');
}
/*
* the server (e.g., shared hosting) may have a low wait timeout
* so instead of a single GET_LOCK() with a 30 second timeout,
* we use a 1 second timeout and loop, to avoid losing our MySQL
* connection
*/
$sql = 'SELECT GET_LOCK(?, 1)';
$db = self::get();
while ($maxRetries > 0) {
$result = $db->fetchOne($sql, array($lockName));
if ($result == '1') {
return true;
}
$maxRetries--;
}
return false;
} | php | public static function getDbLock($lockName, $maxRetries = 30)
{
if (strlen($lockName) > 64) {
throw new \Exception('DB lock name has to be 64 characters or less for MySQL 5.7 compatibility.');
}
/*
* the server (e.g., shared hosting) may have a low wait timeout
* so instead of a single GET_LOCK() with a 30 second timeout,
* we use a 1 second timeout and loop, to avoid losing our MySQL
* connection
*/
$sql = 'SELECT GET_LOCK(?, 1)';
$db = self::get();
while ($maxRetries > 0) {
$result = $db->fetchOne($sql, array($lockName));
if ($result == '1') {
return true;
}
$maxRetries--;
}
return false;
} | [
"public",
"static",
"function",
"getDbLock",
"(",
"$",
"lockName",
",",
"$",
"maxRetries",
"=",
"30",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"lockName",
")",
">",
"64",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'DB lock name has to be 64 charact... | Attempts to get a named lock. This function uses a timeout of 1s, but will
retry a set number of times.
@param string $lockName The lock name.
@param int $maxRetries The max number of times to retry.
@return bool `true` if the lock was obtained, `false` if otherwise.
@throws \Exception if Lock name is too long | [
"Attempts",
"to",
"get",
"a",
"named",
"lock",
".",
"This",
"function",
"uses",
"a",
"timeout",
"of",
"1s",
"but",
"will",
"retry",
"a",
"set",
"number",
"of",
"times",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db.php#L651-L676 | train | Get DB lock | [
30522,
2270,
10763,
3853,
2131,
18939,
7878,
1006,
1002,
5843,
18442,
1010,
1002,
4098,
13465,
5134,
1027,
2382,
1007,
1063,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
5843,
18442,
1007,
1028,
4185,
1007,
1063,
5466,
2047,
1032,
6453,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php | TextDescriptor.describeContainerTags | protected function describeContainerTags(ContainerBuilder $builder, array $options = [])
{
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
if ($showHidden) {
$options['output']->title('Symfony Container Hidden Tags');
} else {
$options['output']->title('Symfony Container Tags');
}
foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) {
$options['output']->section(sprintf('"%s" tag', $tag));
$options['output']->listing(array_keys($definitions));
}
} | php | protected function describeContainerTags(ContainerBuilder $builder, array $options = [])
{
$showHidden = isset($options['show_hidden']) && $options['show_hidden'];
if ($showHidden) {
$options['output']->title('Symfony Container Hidden Tags');
} else {
$options['output']->title('Symfony Container Tags');
}
foreach ($this->findDefinitionsByTag($builder, $showHidden) as $tag => $definitions) {
$options['output']->section(sprintf('"%s" tag', $tag));
$options['output']->listing(array_keys($definitions));
}
} | [
"protected",
"function",
"describeContainerTags",
"(",
"ContainerBuilder",
"$",
"builder",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"showHidden",
"=",
"isset",
"(",
"$",
"options",
"[",
"'show_hidden'",
"]",
")",
"&&",
"$",
"options",
"[... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php#L133-L147 | train | Describes the container tags | [
30522,
5123,
3853,
6235,
8663,
18249,
8743,
26454,
1006,
11661,
8569,
23891,
2099,
1002,
12508,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
2265,
27511,
4181,
1027,
26354,
3388,
1006,
1002,
7047,
1031,
1005,
2265,
1035,
5023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Smarty.php | HTML_QuickForm2_Renderer_Smarty.linkToLevelAbove | private function linkToLevelAbove(&$top, $elements, $inGroup = false)
{
$key = $this->options['key_id'] ? 'id' : 'name';
foreach($elements as &$elem) {
$top_key = $elem[$key];
// If in a group, convert something like inGrp[F4grp][F4_1] to F4_1
// Don't do if key_id as the value is a straight id.
if( !$this->options['key_id'] && $inGroup && $top_key != '') {
if(!(preg_match("/\[?([\w_]+)\]?$/i", $top_key, $match)))
throw new HTML_QuickForm2_InvalidArgumentException(
"linkToLevelAbove can't obtain the name from '$top_key'");
$top_key = $match[1];
}
// Radio buttons: several elements with the same name, make an array
if(isset($elem['type']) && $elem['type'] == 'radio') {
if( ! isset($top[$top_key]))
$top[$top_key] = array('id' => $top_key, 'type' => 'radio', 'elements' => array(0));
$top[$top_key][$elem['id']] = &$elem;
} else // Normal field, just link into the level above.
if( ! isset($top[$top_key]))
$top[$top_key] = &$elem; // Link into the level above
// If we have a group link its fields up to this level:
if(isset($elem['elements']['0']))
$this->linkToLevelAbove($elem, $elem['elements'], true);
// Link errors to the top level:
if(isset($elem['error']) && isset($this->array[$elem['error']]))
$this->array['errors'][$top_key] = $this->array[$elem['error']];
}
} | php | private function linkToLevelAbove(&$top, $elements, $inGroup = false)
{
$key = $this->options['key_id'] ? 'id' : 'name';
foreach($elements as &$elem) {
$top_key = $elem[$key];
// If in a group, convert something like inGrp[F4grp][F4_1] to F4_1
// Don't do if key_id as the value is a straight id.
if( !$this->options['key_id'] && $inGroup && $top_key != '') {
if(!(preg_match("/\[?([\w_]+)\]?$/i", $top_key, $match)))
throw new HTML_QuickForm2_InvalidArgumentException(
"linkToLevelAbove can't obtain the name from '$top_key'");
$top_key = $match[1];
}
// Radio buttons: several elements with the same name, make an array
if(isset($elem['type']) && $elem['type'] == 'radio') {
if( ! isset($top[$top_key]))
$top[$top_key] = array('id' => $top_key, 'type' => 'radio', 'elements' => array(0));
$top[$top_key][$elem['id']] = &$elem;
} else // Normal field, just link into the level above.
if( ! isset($top[$top_key]))
$top[$top_key] = &$elem; // Link into the level above
// If we have a group link its fields up to this level:
if(isset($elem['elements']['0']))
$this->linkToLevelAbove($elem, $elem['elements'], true);
// Link errors to the top level:
if(isset($elem['error']) && isset($this->array[$elem['error']]))
$this->array['errors'][$top_key] = $this->array[$elem['error']];
}
} | [
"private",
"function",
"linkToLevelAbove",
"(",
"&",
"$",
"top",
",",
"$",
"elements",
",",
"$",
"inGroup",
"=",
"false",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"options",
"[",
"'key_id'",
"]",
"?",
"'id'",
":",
"'name'",
";",
"foreach",
"(",
... | Key is 'name' or 'id'. | [
"Key",
"is",
"name",
"or",
"id",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Smarty.php#L256-L289 | train | Link the elements up to the level above | [
30522,
2797,
3853,
4957,
3406,
30524,
2004,
1004,
1002,
3449,
6633,
1007,
1063,
1002,
2327,
1035,
3145,
1027,
1002,
3449,
6633,
1031,
1002,
3145,
1033,
1025,
1013,
1013,
2065,
1999,
1037,
2177,
1010,
10463,
2242,
2066,
13749,
14536,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Protocol/Smtp.php | Zend_Mail_Protocol_Smtp.data | public function data($data)
{
// Ensure recipients have been set
if ($this->_rcpt !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No recipient forward path has been supplied');
}
$this->_send('DATA');
$this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2
foreach (explode(Zend_Mime::LINEEND, $data) as $line) {
if (strpos($line, '.') === 0) {
// Escape lines prefixed with a '.'
$line = '.' . $line;
}
$this->_send($line);
}
$this->_send('.');
$this->_expect(250, 600); // Timeout set for 10 minutes as per RFC 2821 4.5.3.2
$this->_data = true;
} | php | public function data($data)
{
// Ensure recipients have been set
if ($this->_rcpt !== true) {
/**
* @see Zend_Mail_Protocol_Exception
*/
// require_once 'Zend/Mail/Protocol/Exception.php';
throw new Zend_Mail_Protocol_Exception('No recipient forward path has been supplied');
}
$this->_send('DATA');
$this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2
foreach (explode(Zend_Mime::LINEEND, $data) as $line) {
if (strpos($line, '.') === 0) {
// Escape lines prefixed with a '.'
$line = '.' . $line;
}
$this->_send($line);
}
$this->_send('.');
$this->_expect(250, 600); // Timeout set for 10 minutes as per RFC 2821 4.5.3.2
$this->_data = true;
} | [
"public",
"function",
"data",
"(",
"$",
"data",
")",
"{",
"// Ensure recipients have been set",
"if",
"(",
"$",
"this",
"->",
"_rcpt",
"!==",
"true",
")",
"{",
"/**\n * @see Zend_Mail_Protocol_Exception\n */",
"// require_once 'Zend/Mail/Protocol/Excep... | Issues DATA command
@param string $data
@throws Zend_Mail_Protocol_Exception
@return void | [
"Issues",
"DATA",
"command"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp.php#L301-L326 | train | Send data to the server | [
30522,
2270,
3853,
2951,
1006,
1002,
2951,
1007,
1063,
1013,
1013,
5676,
15991,
2031,
2042,
2275,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
22110,
13876,
999,
1027,
1027,
2995,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2156,
16729,
2094,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Kernel/AccessToken.php | AccessToken.applyToRequest | public function applyToRequest(RequestInterface $request, array $requestOptions = []): RequestInterface
{
parse_str($request->getUri()->getQuery(), $query);
$query = http_build_query(array_merge($this->getQuery(), $query));
return $request->withUri($request->getUri()->withQuery($query));
} | php | public function applyToRequest(RequestInterface $request, array $requestOptions = []): RequestInterface
{
parse_str($request->getUri()->getQuery(), $query);
$query = http_build_query(array_merge($this->getQuery(), $query));
return $request->withUri($request->getUri()->withQuery($query));
} | [
"public",
"function",
"applyToRequest",
"(",
"RequestInterface",
"$",
"request",
",",
"array",
"$",
"requestOptions",
"=",
"[",
"]",
")",
":",
"RequestInterface",
"{",
"parse_str",
"(",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getQuery",
"(",
")",
... | @param \Psr\Http\Message\RequestInterface $request
@param array $requestOptions
@return \Psr\Http\Message\RequestInterface
@throws \EasyWeChat\Kernel\Exceptions\HttpException
@throws \Psr\SimpleCache\InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
@throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\RuntimeException | [
"@param",
"\\",
"Psr",
"\\",
"Http",
"\\",
"Message",
"\\",
"RequestInterface",
"$request",
"@param",
"array",
"$requestOptions"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/AccessToken.php#L198-L205 | train | Apply the current query to the request | [
30522,
2270,
3853,
6611,
19277,
15500,
1006,
5227,
18447,
2121,
12172,
1002,
5227,
1010,
9140,
1002,
5227,
7361,
9285,
1027,
1031,
1033,
1007,
1024,
5227,
18447,
2121,
12172,
1063,
11968,
3366,
1035,
2358,
2099,
1006,
1002,
5227,
1011,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php | NumberFormatter.formatCurrency | public function formatCurrency($value, $currency)
{
if (self::DECIMAL == $this->style) {
return $this->format($value);
}
$symbol = Currencies::getSymbol($currency, 'en');
$fractionDigits = Currencies::getFractionDigits($currency);
$value = $this->roundCurrency($value, $currency);
$negative = false;
if (0 > $value) {
$negative = true;
$value *= -1;
}
$value = $this->formatNumber($value, $fractionDigits);
// There's a non-breaking space after the currency code (i.e. CRC 100), but not if the currency has a symbol (i.e. £100).
$ret = $symbol.(mb_strlen($symbol, 'UTF-8') > 2 ? "\xc2\xa0" : '').$value;
return $negative ? '-'.$ret : $ret;
} | php | public function formatCurrency($value, $currency)
{
if (self::DECIMAL == $this->style) {
return $this->format($value);
}
$symbol = Currencies::getSymbol($currency, 'en');
$fractionDigits = Currencies::getFractionDigits($currency);
$value = $this->roundCurrency($value, $currency);
$negative = false;
if (0 > $value) {
$negative = true;
$value *= -1;
}
$value = $this->formatNumber($value, $fractionDigits);
// There's a non-breaking space after the currency code (i.e. CRC 100), but not if the currency has a symbol (i.e. £100).
$ret = $symbol.(mb_strlen($symbol, 'UTF-8') > 2 ? "\xc2\xa0" : '').$value;
return $negative ? '-'.$ret : $ret;
} | [
"public",
"function",
"formatCurrency",
"(",
"$",
"value",
",",
"$",
"currency",
")",
"{",
"if",
"(",
"self",
"::",
"DECIMAL",
"==",
"$",
"this",
"->",
"style",
")",
"{",
"return",
"$",
"this",
"->",
"format",
"(",
"$",
"value",
")",
";",
"}",
"$",... | Format a currency value.
@param float $value The numeric currency value
@param string $currency The 3-letter ISO 4217 currency code indicating the currency to use
@return string The formatted currency value
@see http://www.php.net/manual/en/numberformatter.formatcurrency.php
@see https://en.wikipedia.org/wiki/ISO_4217#Active_codes | [
"Format",
"a",
"currency",
"value",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php#L315-L338 | train | Formats the value with the currency symbol | [
30522,
2270,
3853,
4289,
10841,
14343,
9407,
1006,
1002,
3643,
1010,
1002,
9598,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
26066,
1027,
1027,
1002,
2023,
1011,
1028,
2806,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4289,
1006,
1002,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/VarDumper/Cloner/Data.php | Data.dumpChildren | private function dumpChildren($dumper, $parentCursor, &$refs, $children, $hashCut, $hashType, $dumpKeys)
{
$cursor = clone $parentCursor;
++$cursor->depth;
$cursor->hashType = $hashType;
$cursor->hashIndex = 0;
$cursor->hashLength = \count($children);
$cursor->hashCut = $hashCut;
foreach ($children as $key => $child) {
$cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key);
$cursor->hashKey = $dumpKeys ? $key : null;
$this->dumpItem($dumper, $cursor, $refs, $child);
if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) {
$parentCursor->stop = true;
return $hashCut >= 0 ? $hashCut + $cursor->hashLength - $cursor->hashIndex : $hashCut;
}
}
return $hashCut;
} | php | private function dumpChildren($dumper, $parentCursor, &$refs, $children, $hashCut, $hashType, $dumpKeys)
{
$cursor = clone $parentCursor;
++$cursor->depth;
$cursor->hashType = $hashType;
$cursor->hashIndex = 0;
$cursor->hashLength = \count($children);
$cursor->hashCut = $hashCut;
foreach ($children as $key => $child) {
$cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key);
$cursor->hashKey = $dumpKeys ? $key : null;
$this->dumpItem($dumper, $cursor, $refs, $child);
if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) {
$parentCursor->stop = true;
return $hashCut >= 0 ? $hashCut + $cursor->hashLength - $cursor->hashIndex : $hashCut;
}
}
return $hashCut;
} | [
"private",
"function",
"dumpChildren",
"(",
"$",
"dumper",
",",
"$",
"parentCursor",
",",
"&",
"$",
"refs",
",",
"$",
"children",
",",
"$",
"hashCut",
",",
"$",
"hashType",
",",
"$",
"dumpKeys",
")",
"{",
"$",
"cursor",
"=",
"clone",
"$",
"parentCursor... | Dumps children of hash structures.
@param DumperInterface $dumper
@param Cursor $parentCursor The cursor of the parent hash
@param array &$refs A map of all references discovered while dumping
@param array $children The children to dump
@param int $hashCut The number of items removed from the original hash
@param string $hashType A Cursor::HASH_* const
@param bool $dumpKeys Whether keys should be dumped or not
@return int The final number of removed items | [
"Dumps",
"children",
"of",
"hash",
"structures",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Cloner/Data.php#L384-L404 | train | Dump children of the tree | [
30522,
2797,
3853,
15653,
19339,
7389,
1006,
1002,
15653,
2121,
1010,
1002,
6687,
10841,
25301,
2099,
1010,
1004,
1002,
25416,
30524,
12690,
1010,
1002,
23325,
13874,
1010,
1002,
15653,
14839,
2015,
1007,
1063,
1002,
12731,
25301,
2099,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Goals/API.php | API.deleteGoal | public function deleteGoal($idSite, $idGoal)
{
Piwik::checkUserHasWriteAccess($idSite);
$this->getModel()->deleteGoal($idSite, $idGoal);
$this->getModel()->deleteGoalConversions($idSite, $idGoal);
$this->getGoalsInfoStaticCache()->delete(self::getCacheId($idSite));
Cache::regenerateCacheWebsiteAttributes($idSite);
} | php | public function deleteGoal($idSite, $idGoal)
{
Piwik::checkUserHasWriteAccess($idSite);
$this->getModel()->deleteGoal($idSite, $idGoal);
$this->getModel()->deleteGoalConversions($idSite, $idGoal);
$this->getGoalsInfoStaticCache()->delete(self::getCacheId($idSite));
Cache::regenerateCacheWebsiteAttributes($idSite);
} | [
"public",
"function",
"deleteGoal",
"(",
"$",
"idSite",
",",
"$",
"idGoal",
")",
"{",
"Piwik",
"::",
"checkUserHasWriteAccess",
"(",
"$",
"idSite",
")",
";",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"deleteGoal",
"(",
"$",
"idSite",
",",
"$",
"id... | Soft deletes a given Goal.
Stats data in the archives will still be recorded, but not displayed.
@param int $idSite
@param int $idGoal
@return void | [
"Soft",
"deletes",
"a",
"given",
"Goal",
".",
"Stats",
"data",
"in",
"the",
"archives",
"will",
"still",
"be",
"recorded",
"but",
"not",
"displayed",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Goals/API.php#L290-L300 | train | Delete a goal from the main model and the cache | [
30522,
2270,
3853,
3972,
12870,
3995,
2389,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
8909,
3995,
2389,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
26373,
6305,
9623,
2015,
1006,
1002,
8909,
28032,
2063,
1007,
1025,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.metadata | public function metadata($var = null)
{
if ($var !== null) {
$this->metadata = (array)$var;
}
// if not metadata yet, process it.
if (null === $this->metadata) {
$header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible'];
$this->metadata = [];
$metadata = [];
// Set the Generator tag
$metadata['generator'] = 'GravCMS';
// Get initial metadata for the page
$metadata = array_merge($metadata, Grav::instance()['config']->get('site.metadata'));
if (isset($this->header->metadata)) {
// Merge any site.metadata settings in with page metadata
$metadata = array_merge($metadata, $this->header->metadata);
}
// Build an array of meta objects..
foreach ((array)$metadata as $key => $value) {
// Lowercase the key
$key = strtolower($key);
// If this is a property type metadata: "og", "twitter", "facebook" etc
// Backward compatibility for nested arrays in metas
if (is_array($value)) {
foreach ($value as $property => $prop_value) {
$prop_key = $key . ':' . $property;
$this->metadata[$prop_key] = [
'name' => $prop_key,
'property' => $prop_key,
'content' => htmlspecialchars($prop_value, ENT_QUOTES, 'UTF-8')
];
}
} else {
// If it this is a standard meta data type
if ($value) {
if (\in_array($key, $header_tag_http_equivs, true)) {
$this->metadata[$key] = [
'http_equiv' => $key,
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
];
} elseif ($key === 'charset') {
$this->metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')];
} else {
// if it's a social metadata with separator, render as property
$separator = strpos($key, ':');
$hasSeparator = $separator && $separator < strlen($key) - 1;
$entry = [
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
];
if ($hasSeparator && !Utils::startsWith($key, 'twitter')) {
$entry['property'] = $key;
} else {
$entry['name'] = $key;
}
$this->metadata[$key] = $entry;
}
}
}
}
}
return $this->metadata;
} | php | public function metadata($var = null)
{
if ($var !== null) {
$this->metadata = (array)$var;
}
// if not metadata yet, process it.
if (null === $this->metadata) {
$header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible'];
$this->metadata = [];
$metadata = [];
// Set the Generator tag
$metadata['generator'] = 'GravCMS';
// Get initial metadata for the page
$metadata = array_merge($metadata, Grav::instance()['config']->get('site.metadata'));
if (isset($this->header->metadata)) {
// Merge any site.metadata settings in with page metadata
$metadata = array_merge($metadata, $this->header->metadata);
}
// Build an array of meta objects..
foreach ((array)$metadata as $key => $value) {
// Lowercase the key
$key = strtolower($key);
// If this is a property type metadata: "og", "twitter", "facebook" etc
// Backward compatibility for nested arrays in metas
if (is_array($value)) {
foreach ($value as $property => $prop_value) {
$prop_key = $key . ':' . $property;
$this->metadata[$prop_key] = [
'name' => $prop_key,
'property' => $prop_key,
'content' => htmlspecialchars($prop_value, ENT_QUOTES, 'UTF-8')
];
}
} else {
// If it this is a standard meta data type
if ($value) {
if (\in_array($key, $header_tag_http_equivs, true)) {
$this->metadata[$key] = [
'http_equiv' => $key,
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
];
} elseif ($key === 'charset') {
$this->metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')];
} else {
// if it's a social metadata with separator, render as property
$separator = strpos($key, ':');
$hasSeparator = $separator && $separator < strlen($key) - 1;
$entry = [
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
];
if ($hasSeparator && !Utils::startsWith($key, 'twitter')) {
$entry['property'] = $key;
} else {
$entry['name'] = $key;
}
$this->metadata[$key] = $entry;
}
}
}
}
}
return $this->metadata;
} | [
"public",
"function",
"metadata",
"(",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"var",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"metadata",
"=",
"(",
"array",
")",
"$",
"var",
";",
"}",
"// if not metadata yet, process it.",
"if",
"(",
"... | Function to merge page metadata tags and build an array of Metadata objects
that can then be rendered in the page.
@param array $var an Array of metadata values to set
@return array an Array of metadata values for the page | [
"Function",
"to",
"merge",
"page",
"metadata",
"tags",
"and",
"build",
"an",
"array",
"of",
"Metadata",
"objects",
"that",
"can",
"then",
"be",
"rendered",
"in",
"the",
"page",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L1672-L1743 | train | Method to set the page metadata | [
30522,
2270,
3853,
27425,
1006,
1002,
13075,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
13075,
999,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
27425,
1027,
1006,
9140,
1007,
1002,
13075,
1025,
1065,
1013,
1013,
2065,
2025,
27425... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OpenWork/Corp/Client.php | Client.getManagers | public function getManagers(string $authCorpId, string $agentId)
{
$params = [
'auth_corpid' => $authCorpId,
'agentid' => $agentId,
];
return $this->httpPostJson('cgi-bin/service/get_admin_lis', $params);
} | php | public function getManagers(string $authCorpId, string $agentId)
{
$params = [
'auth_corpid' => $authCorpId,
'agentid' => $agentId,
];
return $this->httpPostJson('cgi-bin/service/get_admin_lis', $params);
} | [
"public",
"function",
"getManagers",
"(",
"string",
"$",
"authCorpId",
",",
"string",
"$",
"agentId",
")",
"{",
"$",
"params",
"=",
"[",
"'auth_corpid'",
"=>",
"$",
"authCorpId",
",",
"'agentid'",
"=>",
"$",
"agentId",
",",
"]",
";",
"return",
"$",
"this... | 获取应用的管理员列表.
@param string $authCorpId
@param string $agentId
@return mixed
@throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException | [
"获取应用的管理员列表",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenWork/Corp/Client.php#L143-L151 | train | Get all the managers for a specific auth_corpId and agentId | [
30522,
2270,
3853,
2131,
24805,
15776,
1006,
5164,
1002,
8740,
2705,
24586,
3593,
1010,
5164,
1002,
4005,
3593,
1007,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
8740,
2705,
1035,
13058,
3593,
1005,
1027,
1028,
1002,
8740,
2705,
24586,
3593,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php | ContainerControllerResolver.instantiateController | protected function instantiateController($class)
{
if ($this->container->has($class)) {
return $this->container->get($class);
}
try {
return parent::instantiateController($class);
} catch (\Error $e) {
}
$this->throwExceptionIfControllerWasRemoved($class, $e);
if ($e instanceof \ArgumentCountError) {
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define such a service?', $class), 0, $e);
}
throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class', $class), 0, $e);
} | php | protected function instantiateController($class)
{
if ($this->container->has($class)) {
return $this->container->get($class);
}
try {
return parent::instantiateController($class);
} catch (\Error $e) {
}
$this->throwExceptionIfControllerWasRemoved($class, $e);
if ($e instanceof \ArgumentCountError) {
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define such a service?', $class), 0, $e);
}
throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class', $class), 0, $e);
} | [
"protected",
"function",
"instantiateController",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"class",
")",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"class",
")",
";... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php#L48-L66 | train | Instantiates a controller | [
30522,
5123,
3853,
7107,
13143,
8663,
13181,
10820,
1006,
1002,
2465,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11661,
1011,
1028,
2038,
1006,
1002,
2465,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
11661,
1011,
1028,
2131,
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/system/ServiceProvider.php | ServiceProvider.registerSingletons | protected function registerSingletons()
{
App::singleton('cms.helper', function () {
return new \Cms\Helpers\Cms;
});
App::singleton('backend.helper', function () {
return new \Backend\Helpers\Backend;
});
App::singleton('backend.menu', function () {
return \Backend\Classes\NavigationManager::instance();
});
App::singleton('backend.auth', function () {
return \Backend\Classes\AuthManager::instance();
});
} | php | protected function registerSingletons()
{
App::singleton('cms.helper', function () {
return new \Cms\Helpers\Cms;
});
App::singleton('backend.helper', function () {
return new \Backend\Helpers\Backend;
});
App::singleton('backend.menu', function () {
return \Backend\Classes\NavigationManager::instance();
});
App::singleton('backend.auth', function () {
return \Backend\Classes\AuthManager::instance();
});
} | [
"protected",
"function",
"registerSingletons",
"(",
")",
"{",
"App",
"::",
"singleton",
"(",
"'cms.helper'",
",",
"function",
"(",
")",
"{",
"return",
"new",
"\\",
"Cms",
"\\",
"Helpers",
"\\",
"Cms",
";",
"}",
")",
";",
"App",
"::",
"singleton",
"(",
... | Register singletons | [
"Register",
"singletons"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L104-L121 | train | Registers the framework s singletons | [
30522,
5123,
3853,
18687,
2075,
19263,
2015,
1006,
1007,
1063,
10439,
1024,
1024,
28159,
1006,
1005,
4642,
2015,
1012,
2393,
2121,
1005,
1010,
3853,
1006,
1007,
1063,
2709,
2047,
1032,
4642,
2015,
1032,
2393,
2545,
1032,
4642,
2015,
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/OpenWork/SuiteAuth/SuiteTicket.php | SuiteTicket.setTicket | public function setTicket(string $ticket)
{
$this->getCache()->set($this->getCacheKey(), $ticket, 1800);
if (!$this->getCache()->has($this->getCacheKey())) {
throw new RuntimeException('Failed to cache suite ticket.');
}
return $this;
} | php | public function setTicket(string $ticket)
{
$this->getCache()->set($this->getCacheKey(), $ticket, 1800);
if (!$this->getCache()->has($this->getCacheKey())) {
throw new RuntimeException('Failed to cache suite ticket.');
}
return $this;
} | [
"public",
"function",
"setTicket",
"(",
"string",
"$",
"ticket",
")",
"{",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
",",
"$",
"ticket",
",",
"1800",
")",
";",
"if",
"(",
"!",
"$",
"thi... | @param string $ticket
@return $this
@throws \Psr\SimpleCache\InvalidArgumentException
@throws \EasyWeChat\Kernel\Exceptions\RuntimeException | [
"@param",
"string",
"$ticket"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenWork/SuiteAuth/SuiteTicket.php#L50-L59 | train | Set suite ticket | [
30522,
2270,
3853,
2275,
26348,
3388,
1006,
5164,
1002,
7281,
1007,
1063,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
1006,
1007,
1011,
1028,
2275,
1006,
1002,
2023,
1011,
1028,
2131,
3540,
5403,
14839,
1006,
1007,
1010,
1002,
7281,
1010,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Updater.php | Updater.getComponentUpdates | public function getComponentUpdates()
{
$componentsToCheck = array(
'core' => Version::VERSION
);
$manager = \Piwik\Plugin\Manager::getInstance();
$plugins = $manager->getLoadedPlugins();
foreach ($plugins as $pluginName => $plugin) {
if ($manager->isPluginInstalled($pluginName)) {
$componentsToCheck[$pluginName] = $plugin->getVersion();
}
}
$columnsVersions = $this->columnsUpdater->getAllVersions($this);
foreach ($columnsVersions as $component => $version) {
$componentsToCheck[$component] = $version;
}
$componentsWithUpdateFile = $this->getComponentsWithUpdateFile($componentsToCheck);
if (count($componentsWithUpdateFile) == 0) {
$this->columnsUpdater->onNoUpdateAvailable($columnsVersions);
return null;
}
return $componentsWithUpdateFile;
} | php | public function getComponentUpdates()
{
$componentsToCheck = array(
'core' => Version::VERSION
);
$manager = \Piwik\Plugin\Manager::getInstance();
$plugins = $manager->getLoadedPlugins();
foreach ($plugins as $pluginName => $plugin) {
if ($manager->isPluginInstalled($pluginName)) {
$componentsToCheck[$pluginName] = $plugin->getVersion();
}
}
$columnsVersions = $this->columnsUpdater->getAllVersions($this);
foreach ($columnsVersions as $component => $version) {
$componentsToCheck[$component] = $version;
}
$componentsWithUpdateFile = $this->getComponentsWithUpdateFile($componentsToCheck);
if (count($componentsWithUpdateFile) == 0) {
$this->columnsUpdater->onNoUpdateAvailable($columnsVersions);
return null;
}
return $componentsWithUpdateFile;
} | [
"public",
"function",
"getComponentUpdates",
"(",
")",
"{",
"$",
"componentsToCheck",
"=",
"array",
"(",
"'core'",
"=>",
"Version",
"::",
"VERSION",
")",
";",
"$",
"manager",
"=",
"\\",
"Piwik",
"\\",
"Plugin",
"\\",
"Manager",
"::",
"getInstance",
"(",
")... | Returns any updates that should occur for core and all plugins that are both loaded and
installed. Also includes updates required for dimensions.
@return string[]|null Returns the result of `getComponentsWithUpdateFile()`. | [
"Returns",
"any",
"updates",
"that",
"should",
"occur",
"for",
"core",
"and",
"all",
"plugins",
"that",
"are",
"both",
"loaded",
"and",
"installed",
".",
"Also",
"includes",
"updates",
"required",
"for",
"dimensions",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater.php#L517-L545 | train | Returns an array of all installed components and their updates. | [
30522,
2270,
3853,
2131,
9006,
29513,
3372,
6279,
27122,
1006,
1007,
1063,
1002,
6177,
3406,
5403,
3600,
1027,
9140,
1006,
1005,
4563,
1005,
1027,
1028,
2544,
1024,
1024,
2544,
1007,
1025,
1002,
3208,
1027,
1032,
14255,
9148,
2243,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/LanguagesManager/TranslationWriter/Filter/ByBaseTranslations.php | ByBaseTranslations.filter | public function filter($translations)
{
$cleanedTranslations = array();
foreach ($translations as $pluginName => $pluginTranslations) {
if (empty($this->baseTranslations[$pluginName])) {
$this->filteredData[$pluginName] = $pluginTranslations;
continue;
}
foreach ($pluginTranslations as $key => $translation) {
if (isset($this->baseTranslations[$pluginName][$key])) {
$cleanedTranslations[$pluginName][$key] = $translation;
}
}
if (!empty($cleanedTranslations[$pluginName])) {
$diff = array_diff($translations[$pluginName], $cleanedTranslations[$pluginName]);
} else {
$diff = $translations[$pluginName];
}
if (!empty($diff)) {
$this->filteredData[$pluginName] = $diff;
}
}
return $cleanedTranslations;
} | php | public function filter($translations)
{
$cleanedTranslations = array();
foreach ($translations as $pluginName => $pluginTranslations) {
if (empty($this->baseTranslations[$pluginName])) {
$this->filteredData[$pluginName] = $pluginTranslations;
continue;
}
foreach ($pluginTranslations as $key => $translation) {
if (isset($this->baseTranslations[$pluginName][$key])) {
$cleanedTranslations[$pluginName][$key] = $translation;
}
}
if (!empty($cleanedTranslations[$pluginName])) {
$diff = array_diff($translations[$pluginName], $cleanedTranslations[$pluginName]);
} else {
$diff = $translations[$pluginName];
}
if (!empty($diff)) {
$this->filteredData[$pluginName] = $diff;
}
}
return $cleanedTranslations;
} | [
"public",
"function",
"filter",
"(",
"$",
"translations",
")",
"{",
"$",
"cleanedTranslations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"translations",
"as",
"$",
"pluginName",
"=>",
"$",
"pluginTranslations",
")",
"{",
"if",
"(",
"empty",
"(",
... | Removes all translations that aren't present in the base translations set in constructor
@param array $translations
@return array filtered translations | [
"Removes",
"all",
"translations",
"that",
"aren",
"t",
"present",
"in",
"the",
"base",
"translations",
"set",
"in",
"constructor"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/TranslationWriter/Filter/ByBaseTranslations.php#L33-L61 | train | Filter translations array | [
30522,
2270,
3853,
11307,
1006,
1002,
11913,
1007,
1063,
1002,
12176,
6494,
3619,
13490,
2015,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
11913,
2004,
1002,
13354,
23111,
14074,
1027,
1028,
1002,
13354,
18447,
5521,
14540,
10708,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.