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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
slimphp/Slim | Slim/Http/Request.php | Request.getRequestTarget | public function getRequestTarget()
{
if ($this->requestTarget) {
return $this->requestTarget;
}
if ($this->uri === null) {
return '/';
}
if ($this->uri instanceof Uri) {
$basePath = $this->uri->getBasePath();
} else {
$basePath = '';
}
$path = $this->uri->getPath();
$path = $basePath . '/' . ltrim($path, '/');
$query = $this->uri->getQuery();
if ($query) {
$path .= '?' . $query;
}
$this->requestTarget = $path;
return $this->requestTarget;
} | php | public function getRequestTarget()
{
if ($this->requestTarget) {
return $this->requestTarget;
}
if ($this->uri === null) {
return '/';
}
if ($this->uri instanceof Uri) {
$basePath = $this->uri->getBasePath();
} else {
$basePath = '';
}
$path = $this->uri->getPath();
$path = $basePath . '/' . ltrim($path, '/');
$query = $this->uri->getQuery();
if ($query) {
$path .= '?' . $query;
}
$this->requestTarget = $path;
return $this->requestTarget;
} | [
"public",
"function",
"getRequestTarget",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"requestTarget",
")",
"{",
"return",
"$",
"this",
"->",
"requestTarget",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"uri",
"===",
"null",
")",
"{",
"return",
"'/'",
"... | Retrieves the message's request target.
Retrieves the message's request-target either as it will appear (for
clients), as it appeared at request (for servers), or as it was
specified for the instance (see withRequestTarget()).
In most cases, this will be the origin-form of the composed URI,
unless a value was provided to the concrete implementation (see
withRequestTarget() below).
If no URI is available, and no request-target has been specifically
provided, this method MUST return the string "/".
@return string | [
"Retrieves",
"the",
"message",
"s",
"request",
"target",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/Request.php#L478-L503 | train | Get Request Target | [
30522,
2270,
3853,
2131,
2890,
15500,
7559,
18150,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5227,
7559,
18150,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5227,
7559,
18150,
1025,
1065,
2065,
1006,
1002,
2023,
1011,
1028,
24471,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Http.php | Http.getProxyConfiguration | private static function getProxyConfiguration($url)
{
$hostname = UrlHelper::getHostFromUrl($url);
if (Url::isLocalHost($hostname)) {
return array(null, null, null, null);
}
// proxy configuration
$proxyHost = Config::getInstance()->proxy['host'];
$proxyPort = Config::getInstance()->proxy['port'];
$proxyUser = Config::getInstance()->proxy['username'];
$proxyPassword = Config::getInstance()->proxy['password'];
return array($proxyHost, $proxyPort, $proxyUser, $proxyPassword);
} | php | private static function getProxyConfiguration($url)
{
$hostname = UrlHelper::getHostFromUrl($url);
if (Url::isLocalHost($hostname)) {
return array(null, null, null, null);
}
// proxy configuration
$proxyHost = Config::getInstance()->proxy['host'];
$proxyPort = Config::getInstance()->proxy['port'];
$proxyUser = Config::getInstance()->proxy['username'];
$proxyPassword = Config::getInstance()->proxy['password'];
return array($proxyHost, $proxyPort, $proxyUser, $proxyPassword);
} | [
"private",
"static",
"function",
"getProxyConfiguration",
"(",
"$",
"url",
")",
"{",
"$",
"hostname",
"=",
"UrlHelper",
"::",
"getHostFromUrl",
"(",
"$",
"url",
")",
";",
"if",
"(",
"Url",
"::",
"isLocalHost",
"(",
"$",
"hostname",
")",
")",
"{",
"return... | Returns Proxy to use for connecting via HTTP to given URL
@param string $url
@return array | [
"Returns",
"Proxy",
"to",
"use",
"for",
"connecting",
"via",
"HTTP",
"to",
"given",
"URL"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Http.php#L893-L908 | train | Get proxy configuration | [
30522,
2797,
10763,
3853,
2131,
21572,
18037,
8663,
8873,
27390,
3370,
1006,
1002,
24471,
2140,
1007,
1063,
1002,
3677,
18442,
1027,
24471,
2140,
16001,
4842,
1024,
1024,
2131,
15006,
24475,
21716,
3126,
2140,
1006,
1002,
24471,
2140,
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/Grav.php | Grav.redirect | public function redirect($route, $code = null)
{
/** @var Uri $uri */
$uri = $this['uri'];
//Check for code in route
$regex = '/.*(\[(30[1-7])\])$/';
preg_match($regex, $route, $matches);
if ($matches) {
$route = str_replace($matches[1], '', $matches[0]);
$code = $matches[2];
}
if ($code === null) {
$code = $this['config']->get('system.pages.redirect_default_code', 302);
}
if (isset($this['session'])) {
$this['session']->close();
}
if ($uri->isExternal($route)) {
$url = $route;
} else {
$url = rtrim($uri->rootUrl(), '/') . '/';
if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
$url .= trim($route, '/'); // Remove trailing slash
} else {
$url .= ltrim($route, '/'); // Support trailing slash default routes
}
}
header("Location: {$url}", true, $code);
exit();
} | php | public function redirect($route, $code = null)
{
/** @var Uri $uri */
$uri = $this['uri'];
//Check for code in route
$regex = '/.*(\[(30[1-7])\])$/';
preg_match($regex, $route, $matches);
if ($matches) {
$route = str_replace($matches[1], '', $matches[0]);
$code = $matches[2];
}
if ($code === null) {
$code = $this['config']->get('system.pages.redirect_default_code', 302);
}
if (isset($this['session'])) {
$this['session']->close();
}
if ($uri->isExternal($route)) {
$url = $route;
} else {
$url = rtrim($uri->rootUrl(), '/') . '/';
if ($this['config']->get('system.pages.redirect_trailing_slash', true)) {
$url .= trim($route, '/'); // Remove trailing slash
} else {
$url .= ltrim($route, '/'); // Support trailing slash default routes
}
}
header("Location: {$url}", true, $code);
exit();
} | [
"public",
"function",
"redirect",
"(",
"$",
"route",
",",
"$",
"code",
"=",
"null",
")",
"{",
"/** @var Uri $uri */",
"$",
"uri",
"=",
"$",
"this",
"[",
"'uri'",
"]",
";",
"//Check for code in route",
"$",
"regex",
"=",
"'/.*(\\[(30[1-7])\\])$/'",
";",
"preg... | Redirect browser to another location.
@param string $route Internal route.
@param int $code Redirection code (30x) | [
"Redirect",
"browser",
"to",
"another",
"location",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Grav.php#L279-L314 | train | Redirects to a route | [
30522,
2270,
3853,
2417,
7442,
6593,
1006,
1002,
2799,
1010,
1002,
3642,
1027,
19701,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
24471,
2072,
1002,
24471,
2072,
1008,
1013,
1002,
24471,
2072,
1027,
1002,
2023,
1031,
1005,
24471,
2072,
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/HttpClient/CachingHttpClient.php | CachingHttpClient.stream | public function stream($responses, float $timeout = null): ResponseStreamInterface
{
if ($responses instanceof ResponseInterface) {
$responses = [$responses];
} elseif (!\is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of ResponseInterface objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
}
$mockResponses = [];
$clientResponses = [];
foreach ($responses as $response) {
if ($response instanceof MockResponse) {
$mockResponses[] = $response;
} else {
$clientResponses[] = $response;
}
}
if (!$mockResponses) {
return $this->client->stream($clientResponses, $timeout);
}
if (!$clientResponses) {
return new ResponseStream(MockResponse::stream($mockResponses, $timeout));
}
return new ResponseStream((function () use ($mockResponses, $clientResponses, $timeout) {
yield from MockResponse::stream($mockResponses, $timeout);
yield $this->client->stream($clientResponses, $timeout);
})());
} | php | public function stream($responses, float $timeout = null): ResponseStreamInterface
{
if ($responses instanceof ResponseInterface) {
$responses = [$responses];
} elseif (!\is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of ResponseInterface objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
}
$mockResponses = [];
$clientResponses = [];
foreach ($responses as $response) {
if ($response instanceof MockResponse) {
$mockResponses[] = $response;
} else {
$clientResponses[] = $response;
}
}
if (!$mockResponses) {
return $this->client->stream($clientResponses, $timeout);
}
if (!$clientResponses) {
return new ResponseStream(MockResponse::stream($mockResponses, $timeout));
}
return new ResponseStream((function () use ($mockResponses, $clientResponses, $timeout) {
yield from MockResponse::stream($mockResponses, $timeout);
yield $this->client->stream($clientResponses, $timeout);
})());
} | [
"public",
"function",
"stream",
"(",
"$",
"responses",
",",
"float",
"$",
"timeout",
"=",
"null",
")",
":",
"ResponseStreamInterface",
"{",
"if",
"(",
"$",
"responses",
"instanceof",
"ResponseInterface",
")",
"{",
"$",
"responses",
"=",
"[",
"$",
"responses"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpClient/CachingHttpClient.php#L109-L140 | train | Streams responses from the client. | [
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,
3433,
18447,
2121,
12172,
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... |
matomo-org/matomo | plugins/Live/Visitor.php | Visitor.flattenVisitorDetailsArray | public static function flattenVisitorDetailsArray($visitorDetailsArray)
{
// NOTE: if you flatten more fields from the "actionDetails" array
// ==> also update API/API.php getSuggestedValuesForSegment(), the $segmentsNeedActionsInfo array
// flatten visit custom variables
if (!empty($visitorDetailsArray['customVariables'])
&& is_array($visitorDetailsArray['customVariables'])) {
foreach ($visitorDetailsArray['customVariables'] as $thisCustomVar) {
$visitorDetailsArray = array_merge($visitorDetailsArray, $thisCustomVar);
}
unset($visitorDetailsArray['customVariables']);
}
// flatten page views custom variables
$count = 1;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
if (!empty($action['customVariables'])) {
foreach ($action['customVariables'] as $thisCustomVar) {
foreach ($thisCustomVar as $cvKey => $cvValue) {
$flattenedKeyName = $cvKey . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $cvValue;
$count++;
}
}
}
}
// Flatten Goals
$count = 1;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
if (!empty($action['goalId'])) {
$flattenedKeyName = 'visitConvertedGoalId' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['goalId'];
$count++;
}
}
// Flatten Page Titles/URLs
$count = 1;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
// API.getSuggestedValuesForSegment
$flattenForActionType = array(
'outlink' => 'outlinkUrl',
'download' => 'downloadUrl',
'event' => 'eventUrl',
'action' => 'pageUrl'
);
foreach($flattenForActionType as $actionType => $flattenedKeyPrefix) {
if (!empty($action['url'])
&& $action['type'] == $actionType) {
$flattenedKeyName = $flattenedKeyPrefix . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['url'];
}
}
$flatten = array( 'pageTitle', 'siteSearchKeyword', 'eventCategory', 'eventAction', 'eventName', 'eventValue');
foreach($flatten as $toFlatten) {
if (!empty($action[$toFlatten])) {
$flattenedKeyName = $toFlatten . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action[$toFlatten];
}
}
$count++;
}
// Entry/exit pages
$firstAction = $lastAction = false;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
if ($action['type'] == 'action') {
if (empty($firstAction)) {
$firstAction = $action;
}
$lastAction = $action;
}
}
if (!empty($firstAction['pageTitle'])) {
$visitorDetailsArray['entryPageTitle'] = $firstAction['pageTitle'];
}
if (!empty($firstAction['url'])) {
$visitorDetailsArray['entryPageUrl'] = $firstAction['url'];
}
if (!empty($lastAction['pageTitle'])) {
$visitorDetailsArray['exitPageTitle'] = $lastAction['pageTitle'];
}
if (!empty($lastAction['url'])) {
$visitorDetailsArray['exitPageUrl'] = $lastAction['url'];
}
return $visitorDetailsArray;
} | php | public static function flattenVisitorDetailsArray($visitorDetailsArray)
{
// NOTE: if you flatten more fields from the "actionDetails" array
// ==> also update API/API.php getSuggestedValuesForSegment(), the $segmentsNeedActionsInfo array
// flatten visit custom variables
if (!empty($visitorDetailsArray['customVariables'])
&& is_array($visitorDetailsArray['customVariables'])) {
foreach ($visitorDetailsArray['customVariables'] as $thisCustomVar) {
$visitorDetailsArray = array_merge($visitorDetailsArray, $thisCustomVar);
}
unset($visitorDetailsArray['customVariables']);
}
// flatten page views custom variables
$count = 1;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
if (!empty($action['customVariables'])) {
foreach ($action['customVariables'] as $thisCustomVar) {
foreach ($thisCustomVar as $cvKey => $cvValue) {
$flattenedKeyName = $cvKey . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $cvValue;
$count++;
}
}
}
}
// Flatten Goals
$count = 1;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
if (!empty($action['goalId'])) {
$flattenedKeyName = 'visitConvertedGoalId' . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['goalId'];
$count++;
}
}
// Flatten Page Titles/URLs
$count = 1;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
// API.getSuggestedValuesForSegment
$flattenForActionType = array(
'outlink' => 'outlinkUrl',
'download' => 'downloadUrl',
'event' => 'eventUrl',
'action' => 'pageUrl'
);
foreach($flattenForActionType as $actionType => $flattenedKeyPrefix) {
if (!empty($action['url'])
&& $action['type'] == $actionType) {
$flattenedKeyName = $flattenedKeyPrefix . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action['url'];
}
}
$flatten = array( 'pageTitle', 'siteSearchKeyword', 'eventCategory', 'eventAction', 'eventName', 'eventValue');
foreach($flatten as $toFlatten) {
if (!empty($action[$toFlatten])) {
$flattenedKeyName = $toFlatten . ColumnDelete::APPEND_TO_COLUMN_NAME_TO_KEEP . $count;
$visitorDetailsArray[$flattenedKeyName] = $action[$toFlatten];
}
}
$count++;
}
// Entry/exit pages
$firstAction = $lastAction = false;
foreach ($visitorDetailsArray['actionDetails'] as $action) {
if ($action['type'] == 'action') {
if (empty($firstAction)) {
$firstAction = $action;
}
$lastAction = $action;
}
}
if (!empty($firstAction['pageTitle'])) {
$visitorDetailsArray['entryPageTitle'] = $firstAction['pageTitle'];
}
if (!empty($firstAction['url'])) {
$visitorDetailsArray['entryPageUrl'] = $firstAction['url'];
}
if (!empty($lastAction['pageTitle'])) {
$visitorDetailsArray['exitPageTitle'] = $lastAction['pageTitle'];
}
if (!empty($lastAction['url'])) {
$visitorDetailsArray['exitPageUrl'] = $lastAction['url'];
}
return $visitorDetailsArray;
} | [
"public",
"static",
"function",
"flattenVisitorDetailsArray",
"(",
"$",
"visitorDetailsArray",
")",
"{",
"// NOTE: if you flatten more fields from the \"actionDetails\" array",
"// ==> also update API/API.php getSuggestedValuesForSegment(), the $segmentsNeedActionsInfo array",
"// flatte... | The &flat=1 feature is used by API.getSuggestedValuesForSegment
@param $visitorDetailsArray
@return array | [
"The",
"&flat",
"=",
"1",
"feature",
"is",
"used",
"by",
"API",
".",
"getSuggestedValuesForSegment"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Live/Visitor.php#L181-L273 | train | Flattens the visit details array | [
30522,
2270,
10763,
3853,
4257,
6528,
11365,
15660,
3207,
22081,
2906,
9447,
1006,
1002,
10367,
3207,
22081,
2906,
9447,
1007,
1063,
1013,
1013,
3602,
1024,
2065,
2017,
4257,
6528,
2062,
4249,
2013,
1996,
1000,
2895,
3207,
22081,
1000,
9140... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
slimphp/Slim | Slim/App.php | App.finalize | protected function finalize(ResponseInterface $response)
{
// stop PHP sending a Content-Type automatically
ini_set('default_mimetype', '');
$request = $this->container->get('request');
if ($this->isEmptyResponse($response) && !$this->isHeadRequest($request)) {
return $response->withoutHeader('Content-Type')->withoutHeader('Content-Length');
}
// Add Content-Length header if `addContentLengthHeader` setting is set
if (isset($this->container->get('settings')['addContentLengthHeader']) &&
$this->container->get('settings')['addContentLengthHeader'] == true) {
if (ob_get_length() > 0) {
throw new RuntimeException("Unexpected data in output buffer. " .
"Maybe you have characters before an opening <?php tag?");
}
$size = $response->getBody()->getSize();
if ($size !== null && !$response->hasHeader('Content-Length')) {
$response = $response->withHeader('Content-Length', (string) $size);
}
}
// clear the body if this is a HEAD request
if ($this->isHeadRequest($request)) {
return $response->withBody(new Body(fopen('php://temp', 'r+')));
}
return $response;
} | php | protected function finalize(ResponseInterface $response)
{
// stop PHP sending a Content-Type automatically
ini_set('default_mimetype', '');
$request = $this->container->get('request');
if ($this->isEmptyResponse($response) && !$this->isHeadRequest($request)) {
return $response->withoutHeader('Content-Type')->withoutHeader('Content-Length');
}
// Add Content-Length header if `addContentLengthHeader` setting is set
if (isset($this->container->get('settings')['addContentLengthHeader']) &&
$this->container->get('settings')['addContentLengthHeader'] == true) {
if (ob_get_length() > 0) {
throw new RuntimeException("Unexpected data in output buffer. " .
"Maybe you have characters before an opening <?php tag?");
}
$size = $response->getBody()->getSize();
if ($size !== null && !$response->hasHeader('Content-Length')) {
$response = $response->withHeader('Content-Length', (string) $size);
}
}
// clear the body if this is a HEAD request
if ($this->isHeadRequest($request)) {
return $response->withBody(new Body(fopen('php://temp', 'r+')));
}
return $response;
} | [
"protected",
"function",
"finalize",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"// stop PHP sending a Content-Type automatically",
"ini_set",
"(",
"'default_mimetype'",
",",
"''",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"container",
"->",
"get",... | Finalize response
@param ResponseInterface $response
@return ResponseInterface
@throws RuntimeException | [
"Finalize",
"response"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/App.php#L607-L636 | train | Finalize the response | [
30522,
5123,
3853,
2345,
4697,
1006,
3433,
18447,
2121,
12172,
1002,
3433,
1007,
1063,
1013,
1013,
2644,
25718,
6016,
1037,
4180,
1011,
2828,
8073,
1999,
2072,
1035,
2275,
1006,
1005,
12398,
1035,
2771,
11368,
18863,
1005,
1010,
1005,
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... |
opencart/opencart | upload/catalog/controller/event/statistics.php | ControllerEventStatistics.addReview | public function addReview(&$route, &$args, &$output) {
$this->load->model('report/statistics');
$this->model_report_statistics->addValue('review', 1);
} | php | public function addReview(&$route, &$args, &$output) {
$this->load->model('report/statistics');
$this->model_report_statistics->addValue('review', 1);
} | [
"public",
"function",
"addReview",
"(",
"&",
"$",
"route",
",",
"&",
"$",
"args",
",",
"&",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"load",
"->",
"model",
"(",
"'report/statistics'",
")",
";",
"$",
"this",
"->",
"model_report_statistics",
"->",
"ad... | catalog/model/catalog/review/addReview/after | [
"catalog",
"/",
"model",
"/",
"catalog",
"/",
"review",
"/",
"addReview",
"/",
"after"
] | e7933b56ba05aafb3655c6b490c9733cd18b5c69 | https://github.com/opencart/opencart/blob/e7933b56ba05aafb3655c6b490c9733cd18b5c69/upload/catalog/controller/event/statistics.php#L4-L8 | train | Add Review to statistics | [
30522,
2270,
3853,
5587,
2890,
8584,
1006,
1004,
1002,
2799,
1010,
1004,
1002,
30524,
1005,
1010,
1015,
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,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Transport/File.php | Zend_Mail_Transport_File._sendMail | protected function _sendMail()
{
$file = $this->_path . DIRECTORY_SEPARATOR . call_user_func($this->_callback, $this);
if (!is_writable(dirname($file))) {
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception(sprintf(
'Target directory "%s" does not exist or is not writable',
dirname($file)
));
}
$email = $this->header . $this->EOL . $this->body;
if (!file_put_contents($file, $email)) {
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('Unable to send mail');
}
} | php | protected function _sendMail()
{
$file = $this->_path . DIRECTORY_SEPARATOR . call_user_func($this->_callback, $this);
if (!is_writable(dirname($file))) {
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception(sprintf(
'Target directory "%s" does not exist or is not writable',
dirname($file)
));
}
$email = $this->header . $this->EOL . $this->body;
if (!file_put_contents($file, $email)) {
// require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('Unable to send mail');
}
} | [
"protected",
"function",
"_sendMail",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"_path",
".",
"DIRECTORY_SEPARATOR",
".",
"call_user_func",
"(",
"$",
"this",
"->",
"_callback",
",",
"$",
"this",
")",
";",
"if",
"(",
"!",
"is_writable",
"(",
"... | Saves e-mail message to a file
@return void
@throws Zend_Mail_Transport_Exception on not writable target directory
@throws Zend_Mail_Transport_Exception on file_put_contents() failure | [
"Saves",
"e",
"-",
"mail",
"message",
"to",
"a",
"file"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Transport/File.php#L104-L122 | train | Send the mail | [
30522,
5123,
3853,
1035,
4604,
21397,
1006,
1007,
1063,
1002,
5371,
1027,
1002,
30524,
1012,
2655,
1035,
5310,
1035,
4569,
2278,
1006,
1002,
2023,
1011,
1028,
1035,
2655,
5963,
1010,
1002,
2023,
1007,
1025,
2065,
1006,
999,
2003,
1035,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Adapter/ChainAdapter.php | ChainAdapter.get | public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
{
$lastItem = null;
$i = 0;
$wrap = function (CacheItem $item = null) use ($key, $callback, $beta, &$wrap, &$i, &$lastItem, &$metadata) {
$adapter = $this->adapters[$i];
if (isset($this->adapters[++$i])) {
$callback = $wrap;
$beta = INF === $beta ? INF : 0;
}
if ($adapter instanceof CacheInterface) {
$value = $adapter->get($key, $callback, $beta, $metadata);
} else {
$value = $this->doGet($adapter, $key, $callback, $beta, $metadata);
}
if (null !== $item) {
($this->syncItem)($lastItem = $lastItem ?? $item, $item);
}
return $value;
};
return $wrap();
} | php | public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
{
$lastItem = null;
$i = 0;
$wrap = function (CacheItem $item = null) use ($key, $callback, $beta, &$wrap, &$i, &$lastItem, &$metadata) {
$adapter = $this->adapters[$i];
if (isset($this->adapters[++$i])) {
$callback = $wrap;
$beta = INF === $beta ? INF : 0;
}
if ($adapter instanceof CacheInterface) {
$value = $adapter->get($key, $callback, $beta, $metadata);
} else {
$value = $this->doGet($adapter, $key, $callback, $beta, $metadata);
}
if (null !== $item) {
($this->syncItem)($lastItem = $lastItem ?? $item, $item);
}
return $value;
};
return $wrap();
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
",",
"callable",
"$",
"callback",
",",
"float",
"$",
"beta",
"=",
"null",
",",
"array",
"&",
"$",
"metadata",
"=",
"null",
")",
"{",
"$",
"lastItem",
"=",
"null",
";",
"$",
"i",
"=",
"0",
";... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Adapter/ChainAdapter.php#L90-L113 | train | Get an item from the cache | [
30522,
2270,
3853,
2131,
1006,
5164,
1002,
3145,
1010,
2655,
3085,
1002,
2655,
5963,
1010,
14257,
1002,
8247,
1027,
19701,
1010,
9140,
1004,
1002,
27425,
1027,
19701,
1007,
1063,
1002,
2197,
4221,
2213,
1027,
19701,
1025,
1002,
1045,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Updater.php | Updater.getCurrentComponentVersion | public function getCurrentComponentVersion($name)
{
try {
$currentVersion = Option::get(self::getNameInOptionTable($name));
} catch (\Exception $e) {
// mysql error 1146: table doesn't exist
if (Db::get()->isErrNo($e, '1146')) {
// case when the option table is not yet created (before 0.2.10)
$currentVersion = false;
} else {
// failed for some other reason
throw $e;
}
}
return $currentVersion;
} | php | public function getCurrentComponentVersion($name)
{
try {
$currentVersion = Option::get(self::getNameInOptionTable($name));
} catch (\Exception $e) {
// mysql error 1146: table doesn't exist
if (Db::get()->isErrNo($e, '1146')) {
// case when the option table is not yet created (before 0.2.10)
$currentVersion = false;
} else {
// failed for some other reason
throw $e;
}
}
return $currentVersion;
} | [
"public",
"function",
"getCurrentComponentVersion",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"currentVersion",
"=",
"Option",
"::",
"get",
"(",
"self",
"::",
"getNameInOptionTable",
"(",
"$",
"name",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",... | Returns the currently installed version of a Piwik component.
@param string $name The component name. Eg, a plugin name, `'core'` or dimension column name.
@return string A semantic version.
@throws \Exception | [
"Returns",
"the",
"currently",
"installed",
"version",
"of",
"a",
"Piwik",
"component",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updater.php#L171-L187 | train | Get current component version | [
30522,
2270,
3853,
2131,
10841,
14343,
3372,
9006,
29513,
3372,
27774,
1006,
1002,
2171,
1007,
1063,
3046,
1063,
1002,
2783,
27774,
1027,
5724,
1024,
1024,
2131,
1006,
2969,
1024,
1024,
2131,
18442,
5740,
16790,
10880,
1006,
1002,
2171,
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... |
octobercms/october | modules/cms/classes/Theme.php | Theme.writeConfig | public function writeConfig($values = [], $overwrite = false)
{
if (!$overwrite) {
$values = $values + (array) $this->getConfig();
}
$path = $this->getPath().'/theme.yaml';
if (!File::exists($path)) {
throw new ApplicationException('Path does not exist: '.$path);
}
$contents = Yaml::render($values);
File::put($path, $contents);
$this->configCache = $values;
} | php | public function writeConfig($values = [], $overwrite = false)
{
if (!$overwrite) {
$values = $values + (array) $this->getConfig();
}
$path = $this->getPath().'/theme.yaml';
if (!File::exists($path)) {
throw new ApplicationException('Path does not exist: '.$path);
}
$contents = Yaml::render($values);
File::put($path, $contents);
$this->configCache = $values;
} | [
"public",
"function",
"writeConfig",
"(",
"$",
"values",
"=",
"[",
"]",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"overwrite",
")",
"{",
"$",
"values",
"=",
"$",
"values",
"+",
"(",
"array",
")",
"$",
"this",
"->",
"getC... | Writes to the theme.yaml file with the supplied array values.
@param array $values Data to write
@param array $overwrite If true, undefined values are removed.
@return void | [
"Writes",
"to",
"the",
"theme",
".",
"yaml",
"file",
"with",
"the",
"supplied",
"array",
"values",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Theme.php#L444-L458 | train | Write theme. yaml | [
30522,
2270,
3853,
4339,
8663,
8873,
2290,
1006,
1002,
5300,
1027,
1031,
1033,
1010,
1002,
2058,
26373,
1027,
6270,
1007,
1063,
2065,
1006,
999,
1002,
2058,
26373,
1007,
1063,
1002,
5300,
1027,
1002,
5300,
1009,
1006,
9140,
1007,
1002,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/LoggingTranslator.php | LoggingTranslator.transChoice | public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED);
if ($this->translator instanceof TranslatorInterface) {
$trans = $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
} else {
$trans = $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
}
$this->log($id, $domain, $locale);
return $trans;
} | php | public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the trans() one instead with a "%%count%%" parameter.', __METHOD__), E_USER_DEPRECATED);
if ($this->translator instanceof TranslatorInterface) {
$trans = $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
} else {
$trans = $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
}
$this->log($id, $domain, $locale);
return $trans;
} | [
"public",
"function",
"transChoice",
"(",
"$",
"id",
",",
"$",
"number",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'The \"%s... | {@inheritdoc}
@deprecated since Symfony 4.2, use the trans() method instead with a %count% parameter | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/LoggingTranslator.php#L65-L78 | train | Translates a message with the given id | [
30522,
2270,
3853,
9099,
9905,
6610,
1006,
1002,
8909,
1010,
1002,
2193,
1010,
9140,
1002,
11709,
1027,
1031,
1033,
1010,
1002,
5884,
1027,
19701,
1010,
1002,
2334,
2063,
1027,
19701,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Debugger.php | Debugger.addException | public function addException(\Exception $e)
{
if ($this->initialized && $this->enabled()) {
$this->debugbar['exceptions']->addException($e);
}
return $this;
} | php | public function addException(\Exception $e)
{
if ($this->initialized && $this->enabled()) {
$this->debugbar['exceptions']->addException($e);
}
return $this;
} | [
"public",
"function",
"addException",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initialized",
"&&",
"$",
"this",
"->",
"enabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"debugbar",
"[",
"'exceptions'",
"]",
"->",
"add... | Dump exception into the Messages tab of the Debug Bar
@param \Exception $e
@return Debugger | [
"Dump",
"exception",
"into",
"the",
"Messages",
"tab",
"of",
"the",
"Debug",
"Bar"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Debugger.php#L325-L332 | train | Add Exception to debugbar | [
30522,
2270,
3853,
5587,
10288,
24422,
1006,
1032,
6453,
1002,
1041,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3988,
3550,
1004,
1004,
1002,
2023,
1011,
1028,
9124,
1006,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
2139,
8569,
18259,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php | Broadcaster.extractParametersFromClass | protected function extractParametersFromClass($callback)
{
$reflection = new ReflectionClass($callback);
if (! $reflection->hasMethod('join')) {
throw new Exception('Class based channel must define a "join" method.');
}
return $reflection->getMethod('join')->getParameters();
} | php | protected function extractParametersFromClass($callback)
{
$reflection = new ReflectionClass($callback);
if (! $reflection->hasMethod('join')) {
throw new Exception('Class based channel must define a "join" method.');
}
return $reflection->getMethod('join')->getParameters();
} | [
"protected",
"function",
"extractParametersFromClass",
"(",
"$",
"callback",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"callback",
")",
";",
"if",
"(",
"!",
"$",
"reflection",
"->",
"hasMethod",
"(",
"'join'",
")",
")",
"{",
"th... | Extracts the parameters out of a class channel's "join" method.
@param string $callback
@return \ReflectionParameter[]
@throws \Exception | [
"Extracts",
"the",
"parameters",
"out",
"of",
"a",
"class",
"channel",
"s",
"join",
"method",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php#L130-L139 | train | Extract the parameters from the class based channel | [
30522,
5123,
3853,
14817,
28689,
22828,
22747,
21716,
26266,
1006,
1002,
2655,
5963,
1007,
1063,
1002,
9185,
1027,
2047,
9185,
26266,
1006,
1002,
2655,
5963,
1007,
1025,
2065,
1006,
999,
1002,
9185,
1011,
1028,
2038,
11368,
6806,
2094,
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/CssSelector/Parser/Handler/NumberHandler.php | NumberHandler.handle | public function handle(Reader $reader, TokenStream $stream): bool
{
$match = $reader->findPattern($this->patterns->getNumberPattern());
if (!$match) {
return false;
}
$stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition()));
$reader->moveForward(\strlen($match[0]));
return true;
} | php | public function handle(Reader $reader, TokenStream $stream): bool
{
$match = $reader->findPattern($this->patterns->getNumberPattern());
if (!$match) {
return false;
}
$stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition()));
$reader->moveForward(\strlen($match[0]));
return true;
} | [
"public",
"function",
"handle",
"(",
"Reader",
"$",
"reader",
",",
"TokenStream",
"$",
"stream",
")",
":",
"bool",
"{",
"$",
"match",
"=",
"$",
"reader",
"->",
"findPattern",
"(",
"$",
"this",
"->",
"patterns",
"->",
"getNumberPattern",
"(",
")",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php#L41-L53 | train | Handles the number token | [
30522,
2270,
3853,
5047,
1006,
8068,
1002,
8068,
1010,
19204,
21422,
1002,
5460,
1007,
1024,
22017,
2140,
1063,
1002,
2674,
1027,
1002,
8068,
1011,
1028,
2424,
4502,
12079,
2078,
1006,
1002,
2023,
1011,
1028,
7060,
1011,
1028,
2131,
19172,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.php | HTML_QuickForm2_Renderer.registerPlugin | final public static function registerPlugin($type, $className, $includeFile = null)
{
$type = strtolower($type);
// We don't check self::$_types, since a plugin may be registered
// before renderer itself if it goes with some custom element
if (empty(self::$_pluginClasses[$type])) {
self::$_pluginClasses[$type] = array(array($className, $includeFile));
} else {
foreach (self::$_pluginClasses[$type] as $plugin) {
if (0 == strcasecmp($plugin[0], $className)) {
throw new HTML_QuickForm2_InvalidArgumentException(
"Plugin '$className' for renderer type '$type' is already registered"
);
}
}
self::$_pluginClasses[$type][] = array($className, $includeFile);
}
} | php | final public static function registerPlugin($type, $className, $includeFile = null)
{
$type = strtolower($type);
// We don't check self::$_types, since a plugin may be registered
// before renderer itself if it goes with some custom element
if (empty(self::$_pluginClasses[$type])) {
self::$_pluginClasses[$type] = array(array($className, $includeFile));
} else {
foreach (self::$_pluginClasses[$type] as $plugin) {
if (0 == strcasecmp($plugin[0], $className)) {
throw new HTML_QuickForm2_InvalidArgumentException(
"Plugin '$className' for renderer type '$type' is already registered"
);
}
}
self::$_pluginClasses[$type][] = array($className, $includeFile);
}
} | [
"final",
"public",
"static",
"function",
"registerPlugin",
"(",
"$",
"type",
",",
"$",
"className",
",",
"$",
"includeFile",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"// We don't check self::$_types, since a plugin may b... | Registers a plugin for a renderer type
@param string Renderer type name (treated case-insensitively)
@param string Plugin class name
@param string File containing the plugin class, leave empty if class already loaded
@throws HTML_QuickForm2_InvalidArgumentException if plugin is already registered | [
"Registers",
"a",
"plugin",
"for",
"a",
"renderer",
"type"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer.php#L180-L197 | train | Registers a plugin for a renderer type | [
30522,
2345,
2270,
10763,
3853,
4236,
24759,
15916,
2378,
1006,
1002,
2828,
1010,
1002,
2465,
18442,
1010,
1002,
2421,
8873,
2571,
1027,
19701,
1007,
1063,
1002,
2828,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
2828,
1007,
1025,
1013,
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... |
getgrav/grav | system/src/Grav/Common/Theme.php | Theme.mergeConfig | protected function mergeConfig(PageInterface $page, $deep = 'merge', $params = [], $type = 'themes')
{
return parent::mergeConfig($page, $deep, $params, $type);
} | php | protected function mergeConfig(PageInterface $page, $deep = 'merge', $params = [], $type = 'themes')
{
return parent::mergeConfig($page, $deep, $params, $type);
} | [
"protected",
"function",
"mergeConfig",
"(",
"PageInterface",
"$",
"page",
",",
"$",
"deep",
"=",
"'merge'",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"'themes'",
")",
"{",
"return",
"parent",
"::",
"mergeConfig",
"(",
"$",
"page",
",",... | Override the mergeConfig method to work for themes | [
"Override",
"the",
"mergeConfig",
"method",
"to",
"work",
"for",
"themes"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Theme.php#L67-L70 | train | Override mergeConfig to allow for theme config | [
30522,
5123,
3853,
13590,
8663,
8873,
2290,
1006,
3931,
18447,
2121,
12172,
1002,
3931,
1010,
1002,
2784,
1027,
1005,
13590,
1005,
1010,
1002,
11498,
5244,
1027,
1031,
1033,
1010,
1002,
2828,
1027,
1005,
6991,
1005,
1007,
1063,
2709,
6687,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Filter/Layout/Column.php | Column.removeFilterByID | public function removeFilterByID($id)
{
$this->filters = $this->filters->reject(function (AbstractFilter $filter) use ($id) {
return $filter->getId() == $id;
});
} | php | public function removeFilterByID($id)
{
$this->filters = $this->filters->reject(function (AbstractFilter $filter) use ($id) {
return $filter->getId() == $id;
});
} | [
"public",
"function",
"removeFilterByID",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"$",
"this",
"->",
"filters",
"->",
"reject",
"(",
"function",
"(",
"AbstractFilter",
"$",
"filter",
")",
"use",
"(",
"$",
"id",
")",
"{",
"return",
... | Remove filter from column by id. | [
"Remove",
"filter",
"from",
"column",
"by",
"id",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Filter/Layout/Column.php#L74-L79 | train | Remove a filter from the list of filters | [
30522,
2270,
3853,
6366,
8873,
21928,
3762,
3593,
1006,
1002,
8909,
1007,
1063,
1002,
2023,
1011,
1028,
17736,
1027,
1002,
2023,
1011,
1028,
17736,
1011,
1028,
15454,
1006,
3853,
1006,
10061,
8873,
21928,
1002,
11307,
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... |
opencart/opencart | upload/system/engine/loader.php | Loader.controller | public function controller($route, ...$args) {
// Sanitize the call
$route = preg_replace('/[^a-zA-Z0-9_\/]/', '', (string)$route);
// Keep the original trigger
$trigger = $route;
// Trigger the pre events
$result = $this->registry->get('event')->trigger('controller/' . $trigger . '/before', array(&$route, &$args));
// Make sure its only the last event that returns an output if required.
if ($result != null && !$result instanceof Exception) {
$output = $result;
} else {
$action = new Action($route);
$output = $action->execute($this->registry, $args);
}
// Trigger the post events
$result = $this->registry->get('event')->trigger('controller/' . $trigger . '/after', array(&$route, &$args, &$output));
if ($result && !$result instanceof Exception) {
$output = $result;
}
if (!$output instanceof Exception) {
return $output;
}
} | php | public function controller($route, ...$args) {
// Sanitize the call
$route = preg_replace('/[^a-zA-Z0-9_\/]/', '', (string)$route);
// Keep the original trigger
$trigger = $route;
// Trigger the pre events
$result = $this->registry->get('event')->trigger('controller/' . $trigger . '/before', array(&$route, &$args));
// Make sure its only the last event that returns an output if required.
if ($result != null && !$result instanceof Exception) {
$output = $result;
} else {
$action = new Action($route);
$output = $action->execute($this->registry, $args);
}
// Trigger the post events
$result = $this->registry->get('event')->trigger('controller/' . $trigger . '/after', array(&$route, &$args, &$output));
if ($result && !$result instanceof Exception) {
$output = $result;
}
if (!$output instanceof Exception) {
return $output;
}
} | [
"public",
"function",
"controller",
"(",
"$",
"route",
",",
"...",
"$",
"args",
")",
"{",
"// Sanitize the call",
"$",
"route",
"=",
"preg_replace",
"(",
"'/[^a-zA-Z0-9_\\/]/'",
",",
"''",
",",
"(",
"string",
")",
"$",
"route",
")",
";",
"// Keep the origina... | public function controller($route, &...$args) { | [
"public",
"function",
"controller",
"(",
"$route",
"&",
"...",
"$args",
")",
"{"
] | e7933b56ba05aafb3655c6b490c9733cd18b5c69 | https://github.com/opencart/opencart/blob/e7933b56ba05aafb3655c6b490c9733cd18b5c69/upload/system/engine/loader.php#L36-L64 | train | Executes a controller action | [
30522,
2270,
3853,
11486,
1006,
1002,
2799,
1010,
1012,
1012,
1012,
1002,
12098,
5620,
1007,
1063,
1013,
1013,
2624,
25090,
4371,
1996,
2655,
1002,
2799,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
1013,
1031,
1034,
1037,
1011,
23564,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Db/Schema/Mysql.php | Mysql.getTableCreateSql | public function getTableCreateSql($tableName)
{
$tables = DbHelper::getTablesCreateSql();
if (!isset($tables[$tableName])) {
throw new Exception("The table '$tableName' SQL creation code couldn't be found.");
}
return $tables[$tableName];
} | php | public function getTableCreateSql($tableName)
{
$tables = DbHelper::getTablesCreateSql();
if (!isset($tables[$tableName])) {
throw new Exception("The table '$tableName' SQL creation code couldn't be found.");
}
return $tables[$tableName];
} | [
"public",
"function",
"getTableCreateSql",
"(",
"$",
"tableName",
")",
"{",
"$",
"tables",
"=",
"DbHelper",
"::",
"getTablesCreateSql",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"tables",
"[",
"$",
"tableName",
"]",
")",
")",
"{",
"throw",
"new... | Get the SQL to create a specific Piwik table
@param string $tableName
@throws Exception
@return string SQL | [
"Get",
"the",
"SQL",
"to",
"create",
"a",
"specific",
"Piwik",
"table"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Schema/Mysql.php#L325-L334 | train | Returns the SQL creation code for a table. | [
30522,
2270,
3853,
2131,
10880,
16748,
8520,
4160,
2140,
1006,
1002,
2795,
18442,
1007,
1063,
1002,
7251,
1027,
16962,
16001,
4842,
1024,
1024,
2131,
10880,
11020,
29313,
2015,
4160,
2140,
1006,
1007,
1025,
2065,
1006,
999,
26354,
3388,
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.doSslHandshake | public function doSslHandshake($socket){
if (feof($socket)) {
$this->destroy();
return false;
}
$async = $this instanceof AsyncTcpConnection;
/**
* We disabled ssl3 because https://blog.qualys.com/ssllabs/2014/10/15/ssl-3-is-dead-killed-by-the-poodle-attack.
* You can enable ssl3 by the codes below.
*/
/*if($async){
$type = STREAM_CRYPTO_METHOD_SSLv2_CLIENT | STREAM_CRYPTO_METHOD_SSLv23_CLIENT | STREAM_CRYPTO_METHOD_SSLv3_CLIENT;
}else{
$type = STREAM_CRYPTO_METHOD_SSLv2_SERVER | STREAM_CRYPTO_METHOD_SSLv23_SERVER | STREAM_CRYPTO_METHOD_SSLv3_SERVER;
}*/
if($async){
$type = STREAM_CRYPTO_METHOD_SSLv2_CLIENT | STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
}else{
$type = STREAM_CRYPTO_METHOD_SSLv2_SERVER | STREAM_CRYPTO_METHOD_SSLv23_SERVER;
}
// Hidden error.
set_error_handler(function($errno, $errstr, $file){
if (!Worker::$daemonize) {
Worker::safeEcho("SSL handshake error: $errstr \n");
}
});
$ret = stream_socket_enable_crypto($socket, true, $type);
restore_error_handler();
// Negotiation has failed.
if (false === $ret) {
$this->destroy();
return false;
} elseif (0 === $ret) {
// There isn't enough data and should try again.
return false;
}
if (isset($this->onSslHandshake)) {
try {
call_user_func($this->onSslHandshake, $this);
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
return true;
} | php | public function doSslHandshake($socket){
if (feof($socket)) {
$this->destroy();
return false;
}
$async = $this instanceof AsyncTcpConnection;
/**
* We disabled ssl3 because https://blog.qualys.com/ssllabs/2014/10/15/ssl-3-is-dead-killed-by-the-poodle-attack.
* You can enable ssl3 by the codes below.
*/
/*if($async){
$type = STREAM_CRYPTO_METHOD_SSLv2_CLIENT | STREAM_CRYPTO_METHOD_SSLv23_CLIENT | STREAM_CRYPTO_METHOD_SSLv3_CLIENT;
}else{
$type = STREAM_CRYPTO_METHOD_SSLv2_SERVER | STREAM_CRYPTO_METHOD_SSLv23_SERVER | STREAM_CRYPTO_METHOD_SSLv3_SERVER;
}*/
if($async){
$type = STREAM_CRYPTO_METHOD_SSLv2_CLIENT | STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
}else{
$type = STREAM_CRYPTO_METHOD_SSLv2_SERVER | STREAM_CRYPTO_METHOD_SSLv23_SERVER;
}
// Hidden error.
set_error_handler(function($errno, $errstr, $file){
if (!Worker::$daemonize) {
Worker::safeEcho("SSL handshake error: $errstr \n");
}
});
$ret = stream_socket_enable_crypto($socket, true, $type);
restore_error_handler();
// Negotiation has failed.
if (false === $ret) {
$this->destroy();
return false;
} elseif (0 === $ret) {
// There isn't enough data and should try again.
return false;
}
if (isset($this->onSslHandshake)) {
try {
call_user_func($this->onSslHandshake, $this);
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
return true;
} | [
"public",
"function",
"doSslHandshake",
"(",
"$",
"socket",
")",
"{",
"if",
"(",
"feof",
"(",
"$",
"socket",
")",
")",
"{",
"$",
"this",
"->",
"destroy",
"(",
")",
";",
"return",
"false",
";",
"}",
"$",
"async",
"=",
"$",
"this",
"instanceof",
"Asy... | SSL handshake.
@param $socket
@return bool | [
"SSL",
"handshake",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L743-L794 | train | SSL handshake. | [
30522,
2270,
3853,
9998,
14540,
11774,
7377,
3489,
1006,
1002,
22278,
1007,
1063,
2065,
1006,
10768,
11253,
1006,
1002,
22278,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
6033,
1006,
1007,
1025,
2709,
6270,
1025,
1065,
1002,
2004,
6038,
2278,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Jobs/DatabaseJob.php | DatabaseJob.delete | public function delete()
{
parent::delete();
$this->database->deleteReserved($this->queue, $this->job->id);
} | php | public function delete()
{
parent::delete();
$this->database->deleteReserved($this->queue, $this->job->id);
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"parent",
"::",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"database",
"->",
"deleteReserved",
"(",
"$",
"this",
"->",
"queue",
",",
"$",
"this",
"->",
"job",
"->",
"id",
")",
";",
"}"
] | Delete the job from the queue.
@return void | [
"Delete",
"the",
"job",
"from",
"the",
"queue",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Jobs/DatabaseJob.php#L64-L69 | train | Delete the reserved records | [
30522,
2270,
3853,
3972,
12870,
1006,
1007,
1063,
6687,
1024,
1024,
3972,
12870,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
7809,
1011,
1028,
3972,
15141,
6810,
2099,
7178,
1006,
1002,
2023,
1011,
1028,
24240,
1010,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/LocationProvider/DefaultProvider.php | DefaultProvider.getInfo | public function getInfo()
{
$desc = Piwik::translate('UserCountry_DefaultLocationProviderDesc1') . ' '
. Piwik::translate('UserCountry_DefaultLocationProviderDesc2',
array('<strong>', '', '', '</strong>'))
. '<p><a href="https://matomo.org/faq/how-to/#faq_163" rel="noreferrer noopener" target="_blank">'
. Piwik::translate('UserCountry_HowToInstallGeoIPDatabases')
. '</a></p>';
return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc, 'order' => 1);
} | php | public function getInfo()
{
$desc = Piwik::translate('UserCountry_DefaultLocationProviderDesc1') . ' '
. Piwik::translate('UserCountry_DefaultLocationProviderDesc2',
array('<strong>', '', '', '</strong>'))
. '<p><a href="https://matomo.org/faq/how-to/#faq_163" rel="noreferrer noopener" target="_blank">'
. Piwik::translate('UserCountry_HowToInstallGeoIPDatabases')
. '</a></p>';
return array('id' => self::ID, 'title' => self::TITLE, 'description' => $desc, 'order' => 1);
} | [
"public",
"function",
"getInfo",
"(",
")",
"{",
"$",
"desc",
"=",
"Piwik",
"::",
"translate",
"(",
"'UserCountry_DefaultLocationProviderDesc1'",
")",
".",
"' '",
".",
"Piwik",
"::",
"translate",
"(",
"'UserCountry_DefaultLocationProviderDesc2'",
",",
"array",
"(",
... | Returns information about this location provider. Contains an id, title & description:
array(
'id' => 'default',
'title' => '...',
'description' => '...'
);
@return array | [
"Returns",
"information",
"about",
"this",
"location",
"provider",
".",
"Contains",
"an",
"id",
"title",
"&",
"description",
":"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/LocationProvider/DefaultProvider.php#L102-L111 | train | Returns an array with the information about the country | [
30522,
2270,
3853,
2131,
2378,
14876,
1006,
1007,
1063,
1002,
4078,
2278,
1027,
14255,
9148,
2243,
1024,
1024,
17637,
1006,
1005,
5310,
3597,
16671,
2854,
1035,
12398,
4135,
10719,
21572,
17258,
2121,
6155,
2278,
2487,
1005,
1007,
1012,
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... |
dompdf/dompdf | src/Css/Stylesheet.php | Stylesheet._parse_import | private function _parse_import($url)
{
$arr = preg_split("/[\s\n,]/", $url, -1, PREG_SPLIT_NO_EMPTY);
$url = array_shift($arr);
$accept = false;
if (count($arr) > 0) {
$acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
$acceptedmedia[] = $this->_dompdf->getOptions()->getDefaultMediaType();
// @import url media_type [media_type...]
foreach ($arr as $type) {
if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
$accept = true;
break;
}
}
} else {
// unconditional import
$accept = true;
}
if ($accept) {
// Store our current base url properties in case the new url is elsewhere
$protocol = $this->_protocol;
$host = $this->_base_host;
$path = $this->_base_path;
// $url = str_replace(array('"',"url", "(", ")"), "", $url);
// If the protocol is php, assume that we will import using file://
// $url = Helpers::build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url);
// Above does not work for subfolders and absolute urls.
// Todo: As above, do we need to replace php or file to an empty protocol for local files?
$url = $this->_image($url);
$this->load_css_file($url);
// Restore the current base url
$this->_protocol = $protocol;
$this->_base_host = $host;
$this->_base_path = $path;
}
} | php | private function _parse_import($url)
{
$arr = preg_split("/[\s\n,]/", $url, -1, PREG_SPLIT_NO_EMPTY);
$url = array_shift($arr);
$accept = false;
if (count($arr) > 0) {
$acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
$acceptedmedia[] = $this->_dompdf->getOptions()->getDefaultMediaType();
// @import url media_type [media_type...]
foreach ($arr as $type) {
if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
$accept = true;
break;
}
}
} else {
// unconditional import
$accept = true;
}
if ($accept) {
// Store our current base url properties in case the new url is elsewhere
$protocol = $this->_protocol;
$host = $this->_base_host;
$path = $this->_base_path;
// $url = str_replace(array('"',"url", "(", ")"), "", $url);
// If the protocol is php, assume that we will import using file://
// $url = Helpers::build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url);
// Above does not work for subfolders and absolute urls.
// Todo: As above, do we need to replace php or file to an empty protocol for local files?
$url = $this->_image($url);
$this->load_css_file($url);
// Restore the current base url
$this->_protocol = $protocol;
$this->_base_host = $host;
$this->_base_path = $path;
}
} | [
"private",
"function",
"_parse_import",
"(",
"$",
"url",
")",
"{",
"$",
"arr",
"=",
"preg_split",
"(",
"\"/[\\s\\n,]/\"",
",",
"$",
"url",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"$",
"url",
"=",
"array_shift",
"(",
"$",
"arr",
")",
";",
... | parse @import{} sections
@param string $url the url of the imported CSS file | [
"parse",
"@import",
"{}",
"sections"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Stylesheet.php#L1449-L1494 | train | Parse import url | [
30522,
2797,
3853,
1035,
11968,
3366,
1035,
12324,
1006,
1002,
24471,
2140,
1007,
1063,
1002,
12098,
2099,
1027,
3653,
2290,
1035,
3975,
1006,
1000,
1013,
1031,
1032,
1055,
1032,
1050,
1010,
1033,
1013,
1000,
1010,
1002,
24471,
2140,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Request.php | Request.getVisitorId | public function getVisitorId()
{
$found = false;
// If User ID is set it takes precedence
$userId = $this->getForcedUserId();
if ($userId) {
$userIdHashed = $this->getUserIdHashed($userId);
$idVisitor = $this->truncateIdAsVisitorId($userIdHashed);
Common::printDebug("Request will be recorded for this user_id = " . $userId . " (idvisitor = $idVisitor)");
$found = true;
}
// Was a Visitor ID "forced" (@see Tracking API setVisitorId()) for this request?
if (!$found) {
$idVisitor = $this->getForcedVisitorId();
if (!empty($idVisitor)) {
if (strlen($idVisitor) != Tracker::LENGTH_HEX_ID_STRING) {
throw new InvalidRequestParameterException("Visitor ID (cid) $idVisitor must be " . Tracker::LENGTH_HEX_ID_STRING . " characters long");
}
Common::printDebug("Request will be recorded for this idvisitor = " . $idVisitor);
$found = true;
}
}
// - If set to use 3rd party cookies for Visit ID, read the cookie
if (!$found) {
$useThirdPartyCookie = $this->shouldUseThirdPartyCookie();
if ($useThirdPartyCookie) {
$idVisitor = $this->getThirdPartyCookieVisitorId();
if(!empty($idVisitor)) {
$found = true;
}
}
}
// If a third party cookie was not found, we default to the first party cookie
if (!$found) {
$idVisitor = Common::getRequestVar('_id', '', 'string', $this->params);
$found = strlen($idVisitor) >= Tracker::LENGTH_HEX_ID_STRING;
}
if ($found) {
return $this->getVisitorIdAsBinary($idVisitor);
}
return false;
} | php | public function getVisitorId()
{
$found = false;
// If User ID is set it takes precedence
$userId = $this->getForcedUserId();
if ($userId) {
$userIdHashed = $this->getUserIdHashed($userId);
$idVisitor = $this->truncateIdAsVisitorId($userIdHashed);
Common::printDebug("Request will be recorded for this user_id = " . $userId . " (idvisitor = $idVisitor)");
$found = true;
}
// Was a Visitor ID "forced" (@see Tracking API setVisitorId()) for this request?
if (!$found) {
$idVisitor = $this->getForcedVisitorId();
if (!empty($idVisitor)) {
if (strlen($idVisitor) != Tracker::LENGTH_HEX_ID_STRING) {
throw new InvalidRequestParameterException("Visitor ID (cid) $idVisitor must be " . Tracker::LENGTH_HEX_ID_STRING . " characters long");
}
Common::printDebug("Request will be recorded for this idvisitor = " . $idVisitor);
$found = true;
}
}
// - If set to use 3rd party cookies for Visit ID, read the cookie
if (!$found) {
$useThirdPartyCookie = $this->shouldUseThirdPartyCookie();
if ($useThirdPartyCookie) {
$idVisitor = $this->getThirdPartyCookieVisitorId();
if(!empty($idVisitor)) {
$found = true;
}
}
}
// If a third party cookie was not found, we default to the first party cookie
if (!$found) {
$idVisitor = Common::getRequestVar('_id', '', 'string', $this->params);
$found = strlen($idVisitor) >= Tracker::LENGTH_HEX_ID_STRING;
}
if ($found) {
return $this->getVisitorIdAsBinary($idVisitor);
}
return false;
} | [
"public",
"function",
"getVisitorId",
"(",
")",
"{",
"$",
"found",
"=",
"false",
";",
"// If User ID is set it takes precedence",
"$",
"userId",
"=",
"$",
"this",
"->",
"getForcedUserId",
"(",
")",
";",
"if",
"(",
"$",
"userId",
")",
"{",
"$",
"userIdHashed"... | Returns the ID from the request in this order:
return from a given User ID,
or from a Tracking API forced Visitor ID,
or from a Visitor ID from 3rd party (optional) cookies,
or from a given Visitor Id from 1st party?
@throws Exception | [
"Returns",
"the",
"ID",
"from",
"the",
"request",
"in",
"this",
"order",
":",
"return",
"from",
"a",
"given",
"User",
"ID",
"or",
"from",
"a",
"Tracking",
"API",
"forced",
"Visitor",
"ID",
"or",
"from",
"a",
"Visitor",
"ID",
"from",
"3rd",
"party",
"("... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Request.php#L727-L774 | train | Get the visitor ID | [
30522,
2270,
3853,
2131,
11365,
15660,
3593,
1006,
1007,
1063,
1002,
2179,
1027,
6270,
1025,
1013,
1013,
2065,
5310,
8909,
2003,
2275,
2009,
3138,
23359,
1002,
5310,
3593,
1027,
1002,
2023,
1011,
1028,
2131,
14821,
17619,
11124,
2094,
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/Command/CacheClearCommand.php | CacheClearCommand.configure | protected function configure()
{
$this
->setDefinition([
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
])
->setDescription('Clears the cache')
->setHelp(<<<'EOF'
The <info>%command.name%</info> command clears the application cache for a given environment
and debug mode:
<info>php %command.full_name% --env=dev</info>
<info>php %command.full_name% --env=prod --no-debug</info>
EOF
)
;
} | php | protected function configure()
{
$this
->setDefinition([
new InputOption('no-warmup', '', InputOption::VALUE_NONE, 'Do not warm up the cache'),
new InputOption('no-optional-warmers', '', InputOption::VALUE_NONE, 'Skip optional cache warmers (faster)'),
])
->setDescription('Clears the cache')
->setHelp(<<<'EOF'
The <info>%command.name%</info> command clears the application cache for a given environment
and debug mode:
<info>php %command.full_name% --env=dev</info>
<info>php %command.full_name% --env=prod --no-debug</info>
EOF
)
;
} | [
"protected",
"function",
"configure",
"(",
")",
"{",
"$",
"this",
"->",
"setDefinition",
"(",
"[",
"new",
"InputOption",
"(",
"'no-warmup'",
",",
"''",
",",
"InputOption",
"::",
"VALUE_NONE",
",",
"'Do not warm up the cache'",
")",
",",
"new",
"InputOption",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php#L53-L70 | train | Configure the command | [
30522,
5123,
3853,
9530,
8873,
27390,
2063,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
3207,
16294,
22753,
1006,
1031,
2047,
7953,
7361,
3508,
1006,
1005,
2053,
1011,
4010,
6279,
1005,
1010,
1005,
1005,
1010,
7953,
7361,
3508,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/VersionManager.php | VersionManager.applyDatabaseComment | protected function applyDatabaseComment($code, $version, $comment)
{
Db::table('system_plugin_history')->insert([
'code' => $code,
'type' => self::HISTORY_TYPE_COMMENT,
'version' => $version,
'detail' => $comment,
'created_at' => new Carbon
]);
} | php | protected function applyDatabaseComment($code, $version, $comment)
{
Db::table('system_plugin_history')->insert([
'code' => $code,
'type' => self::HISTORY_TYPE_COMMENT,
'version' => $version,
'detail' => $comment,
'created_at' => new Carbon
]);
} | [
"protected",
"function",
"applyDatabaseComment",
"(",
"$",
"code",
",",
"$",
"version",
",",
"$",
"comment",
")",
"{",
"Db",
"::",
"table",
"(",
"'system_plugin_history'",
")",
"->",
"insert",
"(",
"[",
"'code'",
"=>",
"$",
"code",
",",
"'type'",
"=>",
"... | Registers a database update comment in the history table. | [
"Registers",
"a",
"database",
"update",
"comment",
"in",
"the",
"history",
"table",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/VersionManager.php#L361-L370 | train | Apply database comment | [
30522,
5123,
3853,
6611,
2850,
2696,
15058,
9006,
3672,
1006,
1002,
3642,
1010,
1002,
2544,
1010,
1002,
7615,
1007,
1063,
16962,
1024,
1024,
2795,
1006,
1005,
2291,
1035,
13354,
2378,
1035,
2381,
1005,
1007,
1011,
1028,
19274,
1006,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Redis/Limiters/DurationLimiter.php | DurationLimiter.block | public function block($timeout, $callback = null)
{
$starting = time();
while (! $this->acquire()) {
if (time() - $timeout >= $starting) {
throw new LimiterTimeoutException;
}
usleep(750 * 1000);
}
if (is_callable($callback)) {
$callback();
}
return true;
} | php | public function block($timeout, $callback = null)
{
$starting = time();
while (! $this->acquire()) {
if (time() - $timeout >= $starting) {
throw new LimiterTimeoutException;
}
usleep(750 * 1000);
}
if (is_callable($callback)) {
$callback();
}
return true;
} | [
"public",
"function",
"block",
"(",
"$",
"timeout",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"starting",
"=",
"time",
"(",
")",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"acquire",
"(",
")",
")",
"{",
"if",
"(",
"time",
"(",
")",
"-",... | Attempt to acquire the lock for the given number of seconds.
@param int $timeout
@param callable|null $callback
@return bool
@throws \Illuminate\Contracts\Redis\LimiterTimeoutException | [
"Attempt",
"to",
"acquire",
"the",
"lock",
"for",
"the",
"given",
"number",
"of",
"seconds",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Limiters/DurationLimiter.php#L77-L94 | train | Blocks until the thread is available. | [
30522,
2270,
3853,
3796,
1006,
1002,
2051,
5833,
1010,
1002,
2655,
5963,
1027,
19701,
1007,
1063,
1002,
3225,
1027,
2051,
1006,
1007,
1025,
2096,
1006,
999,
1002,
2023,
1011,
1028,
9878,
1006,
1007,
1007,
1063,
2065,
1006,
2051,
1006,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Work/User/TagClient.php | TagClient.tagOrUntagUsers | protected function tagOrUntagUsers(string $endpoint, int $tagId, array $userList = [], array $partyList = [])
{
$data = [
'tagid' => $tagId,
'userlist' => $userList,
'partylist' => $partyList,
];
return $this->httpPostJson($endpoint, $data);
} | php | protected function tagOrUntagUsers(string $endpoint, int $tagId, array $userList = [], array $partyList = [])
{
$data = [
'tagid' => $tagId,
'userlist' => $userList,
'partylist' => $partyList,
];
return $this->httpPostJson($endpoint, $data);
} | [
"protected",
"function",
"tagOrUntagUsers",
"(",
"string",
"$",
"endpoint",
",",
"int",
"$",
"tagId",
",",
"array",
"$",
"userList",
"=",
"[",
"]",
",",
"array",
"$",
"partyList",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"'tagid'",
"=>",
"$",
... | @param $endpoint
@param $tagId
@param array $userList
@param array $partyList
@return mixed | [
"@param",
"$endpoint",
"@param",
"$tagId",
"@param",
"array",
"$userList",
"@param",
"array",
"$partyList"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Work/User/TagClient.php#L133-L142 | train | Tag or untag users | [
30522,
5123,
3853,
6415,
2953,
16671,
8490,
20330,
2015,
1006,
5164,
1002,
2203,
8400,
1010,
20014,
1002,
6415,
3593,
1010,
9140,
1002,
5310,
9863,
1027,
1031,
1033,
1010,
9140,
1002,
2283,
9863,
1027,
1031,
1033,
1007,
1063,
1002,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.validateDimensions | public function validateDimensions($attribute, $value, $parameters)
{
if ($this->isValidFileInstance($value) && $value->getClientMimeType() === 'image/svg+xml') {
return true;
}
if (! $this->isValidFileInstance($value) || ! $sizeDetails = @getimagesize($value->getRealPath())) {
return false;
}
$this->requireParameterCount(1, $parameters, 'dimensions');
[$width, $height] = $sizeDetails;
$parameters = $this->parseNamedParameters($parameters);
if ($this->failsBasicDimensionChecks($parameters, $width, $height) ||
$this->failsRatioCheck($parameters, $width, $height)) {
return false;
}
return true;
} | php | public function validateDimensions($attribute, $value, $parameters)
{
if ($this->isValidFileInstance($value) && $value->getClientMimeType() === 'image/svg+xml') {
return true;
}
if (! $this->isValidFileInstance($value) || ! $sizeDetails = @getimagesize($value->getRealPath())) {
return false;
}
$this->requireParameterCount(1, $parameters, 'dimensions');
[$width, $height] = $sizeDetails;
$parameters = $this->parseNamedParameters($parameters);
if ($this->failsBasicDimensionChecks($parameters, $width, $height) ||
$this->failsRatioCheck($parameters, $width, $height)) {
return false;
}
return true;
} | [
"public",
"function",
"validateDimensions",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidFileInstance",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"->",
"getClientMimeType",
"(",
")",
... | Validate the dimensions of an image matches the given values.
@param string $attribute
@param mixed $value
@param array $parameters
@return bool | [
"Validate",
"the",
"dimensions",
"of",
"an",
"image",
"matches",
"the",
"given",
"values",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L496-L518 | train | Validates the dimensions of a file. | [
30522,
2270,
3853,
9398,
4383,
14428,
3619,
8496,
1006,
1002,
17961,
1010,
1002,
3643,
1010,
1002,
11709,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
10175,
3593,
8873,
19856,
12693,
3401,
1006,
1002,
3643,
1007,
1004,
1004,
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/AbstractNormalizer.php | AbstractNormalizer.isCircularReference | protected function isCircularReference($object, &$context)
{
$objectHash = spl_object_hash($object);
$circularReferenceLimit = $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->circularReferenceLimit;
if (isset($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash])) {
if ($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash] >= $circularReferenceLimit) {
unset($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash]);
return true;
}
++$context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash];
} else {
$context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash] = 1;
}
return false;
} | php | protected function isCircularReference($object, &$context)
{
$objectHash = spl_object_hash($object);
$circularReferenceLimit = $context[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT] ?? $this->circularReferenceLimit;
if (isset($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash])) {
if ($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash] >= $circularReferenceLimit) {
unset($context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash]);
return true;
}
++$context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash];
} else {
$context[self::CIRCULAR_REFERENCE_LIMIT_COUNTERS][$objectHash] = 1;
}
return false;
} | [
"protected",
"function",
"isCircularReference",
"(",
"$",
"object",
",",
"&",
"$",
"context",
")",
"{",
"$",
"objectHash",
"=",
"spl_object_hash",
"(",
"$",
"object",
")",
";",
"$",
"circularReferenceLimit",
"=",
"$",
"context",
"[",
"self",
"::",
"CIRCULAR_... | Detects if the configured circular reference limit is reached.
@param object $object
@param array $context
@return bool
@throws CircularReferenceException | [
"Detects",
"if",
"the",
"configured",
"circular",
"reference",
"limit",
"is",
"reached",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php#L283-L301 | train | Check if an object is circular reference | [
30522,
5123,
3853,
2003,
6895,
11890,
7934,
2890,
25523,
1006,
1002,
4874,
1010,
1004,
1002,
6123,
1007,
1063,
1002,
4874,
14949,
2232,
30524,
5787,
1033,
1029,
1029,
1002,
2023,
1011,
1028,
12398,
8663,
18209,
1031,
2969,
1024,
1024,
8206,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/SettingsManager.php | SettingsManager.addSettingItems | public function addSettingItems($owner, array $definitions)
{
foreach ($definitions as $code => $definition) {
$this->addSettingItem($owner, $code, $definition);
}
} | php | public function addSettingItems($owner, array $definitions)
{
foreach ($definitions as $code => $definition) {
$this->addSettingItem($owner, $code, $definition);
}
} | [
"public",
"function",
"addSettingItems",
"(",
"$",
"owner",
",",
"array",
"$",
"definitions",
")",
"{",
"foreach",
"(",
"$",
"definitions",
"as",
"$",
"code",
"=>",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"addSettingItem",
"(",
"$",
"owner",
",",... | Dynamically add an array of setting items
@param string $owner
@param array $definitions | [
"Dynamically",
"add",
"an",
"array",
"of",
"setting",
"items"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/SettingsManager.php#L239-L244 | train | Adds a setting item to the page | [
30522,
2270,
3853,
9909,
18319,
3070,
4221,
5244,
1006,
1002,
3954,
1010,
9140,
1002,
15182,
1007,
1063,
18921,
6776,
1006,
1002,
15182,
2004,
1002,
3642,
1027,
1028,
1002,
6210,
1007,
1063,
1002,
2023,
1011,
1028,
9909,
18319,
3070,
4221,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Getters.php | Getters.toArray | public function toArray()
{
if ($this->gettersVariable) {
$var = $this->gettersVariable;
return $this->{$var};
}
$properties = (array)$this;
$list = [];
foreach ($properties as $property => $value) {
if ($property[0] !== "\0") {
$list[$property] = $value;
}
}
return $list;
} | php | public function toArray()
{
if ($this->gettersVariable) {
$var = $this->gettersVariable;
return $this->{$var};
}
$properties = (array)$this;
$list = [];
foreach ($properties as $property => $value) {
if ($property[0] !== "\0") {
$list[$property] = $value;
}
}
return $list;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"gettersVariable",
")",
"{",
"$",
"var",
"=",
"$",
"this",
"->",
"gettersVariable",
";",
"return",
"$",
"this",
"->",
"{",
"$",
"var",
"}",
";",
"}",
"$",
"properties",
"... | Returns an associative array of object properties.
@return array | [
"Returns",
"an",
"associative",
"array",
"of",
"object",
"properties",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Getters.php#L143-L160 | train | Return array representation of this object | [
30522,
2270,
3853,
2000,
2906,
9447,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2131,
7747,
10755,
19210,
1007,
1063,
1002,
13075,
1027,
1002,
2023,
1011,
1028,
2131,
7747,
10755,
19210,
1025,
2709,
1002,
2023,
1011,
30524,
1014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/HttpKernel.php | HttpKernel.finishRequest | private function finishRequest(Request $request, int $type)
{
$this->dispatcher->dispatch(new FinishRequestEvent($this, $request, $type), KernelEvents::FINISH_REQUEST);
$this->requestStack->pop();
} | php | private function finishRequest(Request $request, int $type)
{
$this->dispatcher->dispatch(new FinishRequestEvent($this, $request, $type), KernelEvents::FINISH_REQUEST);
$this->requestStack->pop();
} | [
"private",
"function",
"finishRequest",
"(",
"Request",
"$",
"request",
",",
"int",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"FinishRequestEvent",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"type",
")",
... | Publishes the finish request event, then pop the request from the stack.
Note that the order of the operations is important here, otherwise
operations such as {@link RequestStack::getParentRequest()} can lead to
weird results. | [
"Publishes",
"the",
"finish",
"request",
"event",
"then",
"pop",
"the",
"request",
"from",
"the",
"stack",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpKernel.php#L204-L208 | train | Finishes the current request | [
30522,
2797,
3853,
3926,
2890,
15500,
1006,
5227,
1002,
5227,
1010,
20014,
1002,
2828,
1007,
1063,
1002,
2023,
1011,
1028,
18365,
2121,
1011,
1028,
18365,
1006,
2047,
3926,
2890,
15500,
18697,
3372,
1006,
1002,
2023,
1010,
1002,
5227,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php | InteractsWithPivotTable.getTypeSwapValue | protected function getTypeSwapValue($type, $value)
{
switch (strtolower($type)) {
case 'int':
case 'integer':
return (int) $value;
case 'real':
case 'float':
case 'double':
return (float) $value;
case 'string':
return (string) $value;
default:
return $value;
}
} | php | protected function getTypeSwapValue($type, $value)
{
switch (strtolower($type)) {
case 'int':
case 'integer':
return (int) $value;
case 'real':
case 'float':
case 'double':
return (float) $value;
case 'string':
return (string) $value;
default:
return $value;
}
} | [
"protected",
"function",
"getTypeSwapValue",
"(",
"$",
"type",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"'int'",
":",
"case",
"'integer'",
":",
"return",
"(",
"int",
")",
"$",
"value",
";",
"c... | Converts a given value to a given type value.
@param string $type
@param mixed $value
@return mixed | [
"Converts",
"a",
"given",
"value",
"to",
"a",
"given",
"type",
"value",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php#L621-L636 | train | Get the value of a type swap | [
30522,
5123,
3853,
2131,
13874,
26760,
9331,
10175,
5657,
1006,
1002,
2828,
1010,
1002,
3643,
1007,
1063,
6942,
1006,
2358,
5339,
12898,
13777,
1006,
1002,
2828,
1007,
1007,
1063,
2553,
1005,
20014,
1005,
1024,
2553,
1005,
16109,
1005,
1024... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/CmsException.php | CmsException.processTwig | protected function processTwig(Exception $exception)
{
// Must be a Twig related exception
if (!$exception instanceof Twig_Error) {
return false;
}
$this->message = $exception->getRawMessage();
$this->line = $exception->getTemplateLine();
// Find where the twig markup section begins
$offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
$this->line += $offsetArray['markup'];
// Account for line 0
$this->line--;
return true;
} | php | protected function processTwig(Exception $exception)
{
// Must be a Twig related exception
if (!$exception instanceof Twig_Error) {
return false;
}
$this->message = $exception->getRawMessage();
$this->line = $exception->getTemplateLine();
// Find where the twig markup section begins
$offsetArray = SectionParser::parseOffset($this->compoundObject->getContent());
$this->line += $offsetArray['markup'];
// Account for line 0
$this->line--;
return true;
} | [
"protected",
"function",
"processTwig",
"(",
"Exception",
"$",
"exception",
")",
"{",
"// Must be a Twig related exception",
"if",
"(",
"!",
"$",
"exception",
"instanceof",
"Twig_Error",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"message",
"=",
... | Override properties of an exception specific to the Twig section
of a CMS object.
@param \Exception $exception The exception to modify.
@return bool | [
"Override",
"properties",
"of",
"an",
"exception",
"specific",
"to",
"the",
"Twig",
"section",
"of",
"a",
"CMS",
"object",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/CmsException.php#L199-L217 | train | Process Twig related exception | [
30522,
5123,
3853,
2832,
2102,
16279,
1006,
6453,
1002,
6453,
1007,
1063,
1013,
1013,
2442,
2022,
1037,
1056,
16279,
3141,
6453,
2065,
1006,
999,
1002,
6453,
6013,
11253,
1056,
16279,
1035,
7561,
1007,
1063,
2709,
6270,
1025,
1065,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | HttpCache.fetch | protected function fetch(Request $request, $catch = false)
{
$subRequest = clone $request;
// send no head requests because we want content
if ('HEAD' === $request->getMethod()) {
$subRequest->setMethod('GET');
}
// avoid that the backend sends no content
$subRequest->headers->remove('if_modified_since');
$subRequest->headers->remove('if_none_match');
$response = $this->forward($subRequest, $catch);
if ($response->isCacheable()) {
$this->store($request, $response);
}
return $response;
} | php | protected function fetch(Request $request, $catch = false)
{
$subRequest = clone $request;
// send no head requests because we want content
if ('HEAD' === $request->getMethod()) {
$subRequest->setMethod('GET');
}
// avoid that the backend sends no content
$subRequest->headers->remove('if_modified_since');
$subRequest->headers->remove('if_none_match');
$response = $this->forward($subRequest, $catch);
if ($response->isCacheable()) {
$this->store($request, $response);
}
return $response;
} | [
"protected",
"function",
"fetch",
"(",
"Request",
"$",
"request",
",",
"$",
"catch",
"=",
"false",
")",
"{",
"$",
"subRequest",
"=",
"clone",
"$",
"request",
";",
"// send no head requests because we want content",
"if",
"(",
"'HEAD'",
"===",
"$",
"request",
"... | Unconditionally fetches a fresh response from the backend and
stores it in the cache if is cacheable.
@param Request $request A Request instance
@param bool $catch Whether to process exceptions
@return Response A Response instance | [
"Unconditionally",
"fetches",
"a",
"fresh",
"response",
"from",
"the",
"backend",
"and",
"stores",
"it",
"in",
"the",
"cache",
"if",
"is",
"cacheable",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php#L437-L457 | train | Fetch the response from the backend | [
30522,
5123,
3853,
18584,
1006,
5227,
1002,
5227,
1010,
1002,
4608,
1027,
6270,
1007,
1063,
1002,
4942,
2890,
15500,
1027,
17598,
1002,
5227,
1025,
1013,
1013,
4604,
2053,
2132,
11186,
2138,
2057,
2215,
4180,
2065,
1006,
1005,
2132,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/ViewDataTable.php | ViewDataTable.getViewDataTableId | public static function getViewDataTableId()
{
$id = static::ID;
if (empty($id)) {
$message = sprintf('ViewDataTable %s does not define an ID. Set the ID constant to fix this issue', get_called_class());
throw new \Exception($message);
}
return $id;
} | php | public static function getViewDataTableId()
{
$id = static::ID;
if (empty($id)) {
$message = sprintf('ViewDataTable %s does not define an ID. Set the ID constant to fix this issue', get_called_class());
throw new \Exception($message);
}
return $id;
} | [
"public",
"static",
"function",
"getViewDataTableId",
"(",
")",
"{",
"$",
"id",
"=",
"static",
"::",
"ID",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'ViewDataTable %s does not define an ID. Set the ID constan... | Returns the viewDataTable ID for this DataTable visualization.
Derived classes should not override this method. They should instead declare a const ID field
with the viewDataTable ID.
@throws \Exception
@return string | [
"Returns",
"the",
"viewDataTable",
"ID",
"for",
"this",
"DataTable",
"visualization",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ViewDataTable.php#L373-L383 | train | Get the viewDataTable ID | [
30522,
2270,
10763,
3853,
2131,
8584,
2850,
29336,
3085,
3593,
1006,
1007,
1063,
1002,
8909,
1027,
10763,
1024,
1024,
8909,
1025,
2065,
1006,
4064,
1006,
1002,
8909,
1007,
1007,
1063,
1002,
4471,
1027,
9043,
2546,
1006,
1005,
3193,
2850,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.remove | public function remove($name)
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
unset($this->unresolvedChildren[$name], $this->children[$name]);
return $this;
} | php | public function remove($name)
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
unset($this->unresolvedChildren[$name], $this->children[$name]);
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"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#L123-L132 | train | Removes a child form element by name | [
30522,
2270,
3853,
6366,
1006,
1002,
2171,
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,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/Access/Gate.php | Gate.raw | public function raw($ability, $arguments = [])
{
$arguments = Arr::wrap($arguments);
$user = $this->resolveUser();
// First we will call the "before" callbacks for the Gate. If any of these give
// back a non-null response, we will immediately return that result in order
// to let the developers override all checks for some authorization cases.
$result = $this->callBeforeCallbacks(
$user, $ability, $arguments
);
if (is_null($result)) {
$result = $this->callAuthCallback($user, $ability, $arguments);
}
// After calling the authorization callback, we will call the "after" callbacks
// that are registered with the Gate, which allows a developer to do logging
// if that is required for this application. Then we'll return the result.
return $this->callAfterCallbacks(
$user, $ability, $arguments, $result
);
} | php | public function raw($ability, $arguments = [])
{
$arguments = Arr::wrap($arguments);
$user = $this->resolveUser();
// First we will call the "before" callbacks for the Gate. If any of these give
// back a non-null response, we will immediately return that result in order
// to let the developers override all checks for some authorization cases.
$result = $this->callBeforeCallbacks(
$user, $ability, $arguments
);
if (is_null($result)) {
$result = $this->callAuthCallback($user, $ability, $arguments);
}
// After calling the authorization callback, we will call the "after" callbacks
// that are registered with the Gate, which allows a developer to do logging
// if that is required for this application. Then we'll return the result.
return $this->callAfterCallbacks(
$user, $ability, $arguments, $result
);
} | [
"public",
"function",
"raw",
"(",
"$",
"ability",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"arguments",
"=",
"Arr",
"::",
"wrap",
"(",
"$",
"arguments",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"resolveUser",
"(",
")",
";",
"// ... | Get the raw result from the authorization callback.
@param string $ability
@param array|mixed $arguments
@return mixed | [
"Get",
"the",
"raw",
"result",
"from",
"the",
"authorization",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Access/Gate.php#L337-L360 | train | Returns the raw result of the authorization process. | [
30522,
2270,
3853,
6315,
1006,
1002,
3754,
1010,
1002,
9918,
1027,
1031,
1033,
1007,
1063,
1002,
9918,
1027,
12098,
2099,
1024,
1024,
10236,
1006,
1002,
9918,
1007,
1025,
1002,
5310,
1027,
1002,
2023,
1011,
1028,
10663,
20330,
1006,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/SoftDeletes.php | SoftDeletes.restore | public function restore()
{
// If the restoring event does not return false, we will proceed with this
// restore operation. Otherwise, we bail out so the developer will stop
// the restore totally. We will clear the deleted timestamp and save.
if ($this->fireModelEvent('restoring') === false) {
return false;
}
$this->{$this->getDeletedAtColumn()} = null;
// Once we have saved the model, we will fire the "restored" event so this
// developer will do anything they need to after a restore operation is
// totally finished. Then we will return the result of the save call.
$this->exists = true;
$result = $this->save();
$this->fireModelEvent('restored', false);
return $result;
} | php | public function restore()
{
// If the restoring event does not return false, we will proceed with this
// restore operation. Otherwise, we bail out so the developer will stop
// the restore totally. We will clear the deleted timestamp and save.
if ($this->fireModelEvent('restoring') === false) {
return false;
}
$this->{$this->getDeletedAtColumn()} = null;
// Once we have saved the model, we will fire the "restored" event so this
// developer will do anything they need to after a restore operation is
// totally finished. Then we will return the result of the save call.
$this->exists = true;
$result = $this->save();
$this->fireModelEvent('restored', false);
return $result;
} | [
"public",
"function",
"restore",
"(",
")",
"{",
"// If the restoring event does not return false, we will proceed with this",
"// restore operation. Otherwise, we bail out so the developer will stop",
"// the restore totally. We will clear the deleted timestamp and save.",
"if",
"(",
"$",
"t... | Restore a soft-deleted model instance.
@return bool|null | [
"Restore",
"a",
"soft",
"-",
"deleted",
"model",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/SoftDeletes.php#L103-L124 | train | Restore the model | [
30522,
2270,
3853,
9239,
1006,
1007,
1063,
1013,
1013,
2065,
1996,
16487,
2724,
2515,
2025,
2709,
6270,
1010,
2057,
2097,
10838,
2007,
2023,
1013,
1013,
9239,
3169,
1012,
4728,
1010,
2057,
15358,
2041,
2061,
1996,
9722,
2097,
2644,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Mail/Message.php | Message.from | public function from($address, $name = null)
{
$this->swift->setFrom($address, $name);
return $this;
} | php | public function from($address, $name = null)
{
$this->swift->setFrom($address, $name);
return $this;
} | [
"public",
"function",
"from",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"swift",
"->",
"setFrom",
"(",
"$",
"address",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add a "from" address to the message.
@param string|array $address
@param string|null $name
@return $this | [
"Add",
"a",
"from",
"address",
"to",
"the",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Message.php#L48-L53 | train | Set From address and name of the message | [
30522,
2270,
3853,
2013,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
9170,
1011,
1028,
2275,
19699,
5358,
1006,
1002,
4769,
1010,
1002,
2171,
1007,
1025,
2709,
1002,
2023,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Abstract.php | Zend_Db_Adapter_Abstract.update | public function update($table, array $bind, $where = '')
{
/**
* Build "col = ?" pairs for the statement,
* except for Zend_Db_Expr which is treated literally.
*/
$set = array();
$i = 0;
foreach ($bind as $col => $val) {
if ($val instanceof Zend_Db_Expr) {
$val = $val->__toString();
unset($bind[$col]);
} else {
if ($this->supportsParameters('positional')) {
$val = '?';
} else {
if ($this->supportsParameters('named')) {
unset($bind[$col]);
$bind[':col'.$i] = $val;
$val = ':col'.$i;
$i++;
} else {
/** @see Zend_Db_Adapter_Exception */
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
}
}
}
$set[] = $this->quoteIdentifier($col, true) . ' = ' . $val;
}
$where = $this->_whereExpr($where);
/**
* Build the UPDATE statement
*/
$sql = "UPDATE "
. $this->quoteIdentifier($table, true)
. ' SET ' . implode(', ', $set)
. (($where) ? " WHERE $where" : '');
/**
* Execute the statement and return the number of affected rows
*/
if ($this->supportsParameters('positional')) {
$stmt = $this->query($sql, array_values($bind));
} else {
$stmt = $this->query($sql, $bind);
}
$result = $stmt->rowCount();
return $result;
} | php | public function update($table, array $bind, $where = '')
{
/**
* Build "col = ?" pairs for the statement,
* except for Zend_Db_Expr which is treated literally.
*/
$set = array();
$i = 0;
foreach ($bind as $col => $val) {
if ($val instanceof Zend_Db_Expr) {
$val = $val->__toString();
unset($bind[$col]);
} else {
if ($this->supportsParameters('positional')) {
$val = '?';
} else {
if ($this->supportsParameters('named')) {
unset($bind[$col]);
$bind[':col'.$i] = $val;
$val = ':col'.$i;
$i++;
} else {
/** @see Zend_Db_Adapter_Exception */
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
}
}
}
$set[] = $this->quoteIdentifier($col, true) . ' = ' . $val;
}
$where = $this->_whereExpr($where);
/**
* Build the UPDATE statement
*/
$sql = "UPDATE "
. $this->quoteIdentifier($table, true)
. ' SET ' . implode(', ', $set)
. (($where) ? " WHERE $where" : '');
/**
* Execute the statement and return the number of affected rows
*/
if ($this->supportsParameters('positional')) {
$stmt = $this->query($sql, array_values($bind));
} else {
$stmt = $this->query($sql, $bind);
}
$result = $stmt->rowCount();
return $result;
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"array",
"$",
"bind",
",",
"$",
"where",
"=",
"''",
")",
"{",
"/**\n * Build \"col = ?\" pairs for the statement,\n * except for Zend_Db_Expr which is treated literally.\n */",
"$",
"set",
"=",
... | Updates table rows with specified data based on a WHERE clause.
@param mixed $table The table to update.
@param array $bind Column-value pairs.
@param mixed $where UPDATE WHERE clause(s).
@return int The number of affected rows.
@throws Zend_Db_Adapter_Exception | [
"Updates",
"table",
"rows",
"with",
"specified",
"data",
"based",
"on",
"a",
"WHERE",
"clause",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Abstract.php#L589-L640 | train | Update a table | [
30522,
2270,
3853,
10651,
1006,
1002,
2795,
1010,
9140,
1002,
14187,
1010,
1002,
2073,
1027,
1005,
1005,
1007,
1063,
1013,
1008,
1008,
1008,
3857,
1000,
8902,
1027,
1029,
1000,
7689,
2005,
1996,
4861,
1010,
1008,
3272,
2005,
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... |
laravel/framework | src/Illuminate/Routing/UrlGenerator.php | UrlGenerator.setRequest | public function setRequest(Request $request)
{
$this->request = $request;
$this->cachedRoot = null;
$this->cachedScheme = null;
$this->routeGenerator = null;
} | php | public function setRequest(Request $request)
{
$this->request = $request;
$this->cachedRoot = null;
$this->cachedScheme = null;
$this->routeGenerator = null;
} | [
"public",
"function",
"setRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"this",
"->",
"cachedRoot",
"=",
"null",
";",
"$",
"this",
"->",
"cachedScheme",
"=",
"null",
";",
"$",
"this",
... | Set the current request instance.
@param \Illuminate\Http\Request $request
@return void | [
"Set",
"the",
"current",
"request",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/UrlGenerator.php#L658-L665 | train | Set the request | [
30522,
2270,
3853,
2275,
2890,
15500,
1006,
5227,
1002,
5227,
1007,
1063,
1002,
2023,
1011,
1028,
5227,
1027,
1002,
5227,
1025,
1002,
2023,
1011,
1028,
17053,
22196,
4140,
1027,
19701,
1025,
1002,
2023,
1011,
1028,
17053,
5104,
5403,
4168,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MarkdownDescriptor.php | MarkdownDescriptor.describeRouteCollection | protected function describeRouteCollection(RouteCollection $routes, array $options = [])
{
$first = true;
foreach ($routes->all() as $name => $route) {
if ($first) {
$first = false;
} else {
$this->write("\n\n");
}
$this->describeRoute($route, ['name' => $name]);
}
$this->write("\n");
} | php | protected function describeRouteCollection(RouteCollection $routes, array $options = [])
{
$first = true;
foreach ($routes->all() as $name => $route) {
if ($first) {
$first = false;
} else {
$this->write("\n\n");
}
$this->describeRoute($route, ['name' => $name]);
}
$this->write("\n");
} | [
"protected",
"function",
"describeRouteCollection",
"(",
"RouteCollection",
"$",
"routes",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"first",
"=",
"true",
";",
"foreach",
"(",
"$",
"routes",
"->",
"all",
"(",
")",
"as",
"$",
"name",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php#L34-L46 | train | Describes the routes | [
30522,
5123,
3853,
6235,
22494,
26557,
14511,
18491,
1006,
2799,
26895,
18491,
30524,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
2034,
1027,
2995,
1025,
18921,
6776,
1006,
1002,
5847,
1011,
1028,
2035,
1006,
1007,
2004,
1002,
2171,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Container/Container.php | Container.get | public function get($id)
{
try {
return $this->resolve($id);
} catch (Exception $e) {
if ($this->has($id)) {
throw $e;
}
throw new EntryNotFoundException;
}
} | php | public function get($id)
{
try {
return $this->resolve($id);
} catch (Exception $e) {
if ($this->has($id)) {
throw $e;
}
throw new EntryNotFoundException;
}
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"resolve",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",... | {@inheritdoc} | [
"{"
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L621-L632 | train | Get the entry from the cache | [
30522,
2270,
3853,
2131,
1006,
1002,
8909,
1007,
1063,
3046,
1063,
2709,
1002,
2023,
1011,
1028,
10663,
1006,
1002,
8909,
1007,
1025,
1065,
4608,
1006,
6453,
1002,
1041,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2038,
1006,
1002,
89... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Connection.php | Connection.getDoctrineColumn | public function getDoctrineColumn($table, $column)
{
$schema = $this->getDoctrineSchemaManager();
return $schema->listTableDetails($table)->getColumn($column);
} | php | public function getDoctrineColumn($table, $column)
{
$schema = $this->getDoctrineSchemaManager();
return $schema->listTableDetails($table)->getColumn($column);
} | [
"public",
"function",
"getDoctrineColumn",
"(",
"$",
"table",
",",
"$",
"column",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"getDoctrineSchemaManager",
"(",
")",
";",
"return",
"$",
"schema",
"->",
"listTableDetails",
"(",
"$",
"table",
")",
"->",
... | Get a Doctrine Schema Column instance.
@param string $table
@param string $column
@return \Doctrine\DBAL\Schema\Column | [
"Get",
"a",
"Doctrine",
"Schema",
"Column",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connection.php#L873-L878 | train | Returns the Doctrine Column Object for a table and column. | [
30522,
2270,
3853,
2131,
3527,
6593,
11467,
25778,
2819,
2078,
1006,
1002,
2795,
1010,
1002,
5930,
1007,
1063,
1002,
8040,
28433,
1027,
1002,
2023,
1011,
1028,
2131,
3527,
6593,
11467,
22842,
2863,
24805,
4590,
1006,
1007,
1025,
2709,
1002,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Actions/ArchivingHelper.php | ArchivingHelper.getCachedActionRow | private static function getCachedActionRow($idAction, $actionType)
{
$cacheLabel = self::getCachedActionRowKey($idAction, $actionType);
if (!isset(self::$cacheParsedAction[$cacheLabel])) {
// This can happen when
// - We select an entry page ID that was only seen yesterday, so wasn't selected in the first query
// - We count time spent on a page, when this page was only seen yesterday
return false;
}
return self::$cacheParsedAction[$cacheLabel];
} | php | private static function getCachedActionRow($idAction, $actionType)
{
$cacheLabel = self::getCachedActionRowKey($idAction, $actionType);
if (!isset(self::$cacheParsedAction[$cacheLabel])) {
// This can happen when
// - We select an entry page ID that was only seen yesterday, so wasn't selected in the first query
// - We count time spent on a page, when this page was only seen yesterday
return false;
}
return self::$cacheParsedAction[$cacheLabel];
} | [
"private",
"static",
"function",
"getCachedActionRow",
"(",
"$",
"idAction",
",",
"$",
"actionType",
")",
"{",
"$",
"cacheLabel",
"=",
"self",
"::",
"getCachedActionRowKey",
"(",
"$",
"idAction",
",",
"$",
"actionType",
")",
";",
"if",
"(",
"!",
"isset",
"... | Get cached action row by id & type. If $idAction is set to -1, the 'Others' row
for the specific action type will be returned.
@param int $idAction
@param int $actionType
@return Row|false | [
"Get",
"cached",
"action",
"row",
"by",
"id",
"&",
"type",
".",
"If",
"$idAction",
"is",
"set",
"to",
"-",
"1",
"the",
"Others",
"row",
"for",
"the",
"specific",
"action",
"type",
"will",
"be",
"returned",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/ArchivingHelper.php#L525-L537 | train | Get the cached action row | [
30522,
2797,
10763,
3853,
2131,
3540,
7690,
18908,
3258,
10524,
1006,
1002,
16096,
7542,
1010,
1002,
2895,
13874,
1007,
1063,
1002,
17053,
20470,
2884,
1027,
2969,
1024,
1024,
2131,
3540,
7690,
18908,
3258,
10524,
14839,
1006,
1002,
16096,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Definition.php | Definition.removeMethodCall | public function removeMethodCall($method)
{
foreach ($this->calls as $i => $call) {
if ($call[0] === $method) {
unset($this->calls[$i]);
break;
}
}
return $this;
} | php | public function removeMethodCall($method)
{
foreach ($this->calls as $i => $call) {
if ($call[0] === $method) {
unset($this->calls[$i]);
break;
}
}
return $this;
} | [
"public",
"function",
"removeMethodCall",
"(",
"$",
"method",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"calls",
"as",
"$",
"i",
"=>",
"$",
"call",
")",
"{",
"if",
"(",
"$",
"call",
"[",
"0",
"]",
"===",
"$",
"method",
")",
"{",
"unset",
"(",
... | Removes a method to call after service initialization.
@param string $method The method name to remove
@return $this | [
"Removes",
"a",
"method",
"to",
"call",
"after",
"service",
"initialization",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Definition.php#L369-L379 | train | Remove method call | [
30522,
2270,
3853,
6366,
11368,
6806,
16409,
8095,
1006,
1002,
4118,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
4455,
2004,
1002,
1045,
1027,
1028,
1002,
2655,
1007,
1063,
2065,
1006,
1002,
2655,
1031,
1014,
1033,
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/Foundation/Console/KeyGenerateCommand.php | KeyGenerateCommand.writeNewEnvironmentFileWith | protected function writeNewEnvironmentFileWith($key)
{
file_put_contents($this->laravel->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(),
'APP_KEY='.$key,
file_get_contents($this->laravel->environmentFilePath())
));
} | php | protected function writeNewEnvironmentFileWith($key)
{
file_put_contents($this->laravel->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(),
'APP_KEY='.$key,
file_get_contents($this->laravel->environmentFilePath())
));
} | [
"protected",
"function",
"writeNewEnvironmentFileWith",
"(",
"$",
"key",
")",
"{",
"file_put_contents",
"(",
"$",
"this",
"->",
"laravel",
"->",
"environmentFilePath",
"(",
")",
",",
"preg_replace",
"(",
"$",
"this",
"->",
"keyReplacementPattern",
"(",
")",
",",... | Write a new environment file with the given key.
@param string $key
@return void | [
"Write",
"a",
"new",
"environment",
"file",
"with",
"the",
"given",
"key",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/KeyGenerateCommand.php#L91-L98 | train | Write new environment file with key | [
30522,
5123,
3853,
4339,
2638,
12449,
21663,
2239,
3672,
8873,
2571,
24415,
1006,
1002,
3145,
1007,
1063,
5371,
1035,
2404,
1035,
8417,
1006,
1002,
2023,
1011,
1028,
13679,
15985,
1011,
1028,
4044,
8873,
2571,
15069,
1006,
1007,
1010,
3653,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DomCrawler/Crawler.php | Crawler.createSubCrawler | private function createSubCrawler($nodes)
{
$crawler = new static($nodes, $this->uri, $this->baseHref);
$crawler->isHtml = $this->isHtml;
$crawler->document = $this->document;
$crawler->namespaces = $this->namespaces;
$crawler->html5Parser = $this->html5Parser;
return $crawler;
} | php | private function createSubCrawler($nodes)
{
$crawler = new static($nodes, $this->uri, $this->baseHref);
$crawler->isHtml = $this->isHtml;
$crawler->document = $this->document;
$crawler->namespaces = $this->namespaces;
$crawler->html5Parser = $this->html5Parser;
return $crawler;
} | [
"private",
"function",
"createSubCrawler",
"(",
"$",
"nodes",
")",
"{",
"$",
"crawler",
"=",
"new",
"static",
"(",
"$",
"nodes",
",",
"$",
"this",
"->",
"uri",
",",
"$",
"this",
"->",
"baseHref",
")",
";",
"$",
"crawler",
"->",
"isHtml",
"=",
"$",
... | Creates a crawler for some subnodes.
@param \DOMElement|\DOMElement[]|\DOMNodeList|null $nodes
@return static | [
"Creates",
"a",
"crawler",
"for",
"some",
"subnodes",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/Crawler.php#L1214-L1223 | train | Create a sub crawler | [
30522,
2797,
3853,
9005,
12083,
26775,
10376,
3917,
1006,
1002,
14164,
1007,
1063,
1002,
13529,
2121,
1027,
2047,
10763,
1006,
1002,
14164,
1010,
1002,
2023,
1011,
1028,
24471,
2072,
1010,
1002,
2023,
1011,
1028,
2918,
28362,
2546,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/CronArchive.php | CronArchive.initWebsiteIds | public function initWebsiteIds()
{
if (count($this->shouldArchiveSpecifiedSites) > 0) {
$this->logger->info("- Will process " . count($this->shouldArchiveSpecifiedSites) . " websites (--force-idsites)");
return $this->shouldArchiveSpecifiedSites;
}
$this->findWebsiteIdsInTimezoneWithNewDay($this->allWebsites);
$this->findInvalidatedSitesToReprocess();
if ($this->shouldArchiveAllSites) {
$this->logger->info("- Will process all " . count($this->allWebsites) . " websites");
}
return $this->allWebsites;
} | php | public function initWebsiteIds()
{
if (count($this->shouldArchiveSpecifiedSites) > 0) {
$this->logger->info("- Will process " . count($this->shouldArchiveSpecifiedSites) . " websites (--force-idsites)");
return $this->shouldArchiveSpecifiedSites;
}
$this->findWebsiteIdsInTimezoneWithNewDay($this->allWebsites);
$this->findInvalidatedSitesToReprocess();
if ($this->shouldArchiveAllSites) {
$this->logger->info("- Will process all " . count($this->allWebsites) . " websites");
}
return $this->allWebsites;
} | [
"public",
"function",
"initWebsiteIds",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"shouldArchiveSpecifiedSites",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"- Will process \"",
".",
"count",
"(",
"$",
"thi... | Returns the list of sites to loop over and archive.
@return array | [
"Returns",
"the",
"list",
"of",
"sites",
"to",
"loop",
"over",
"and",
"archive",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/CronArchive.php#L1221-L1237 | train | Initialize the list of websites to be archived | [
30522,
2270,
3853,
1999,
4183,
8545,
5910,
4221,
9821,
1006,
1007,
1063,
2065,
1006,
4175,
1006,
1002,
2023,
1011,
1028,
2323,
2906,
5428,
6961,
5051,
6895,
10451,
28032,
2229,
1007,
1028,
1014,
1007,
1063,
1002,
2023,
1011,
1028,
8833,
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... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.applySearchToQuery | protected function applySearchToQuery($query, $columns, $boolean = 'and')
{
$term = $this->searchTerm;
if ($scopeMethod = $this->searchScope) {
$searchMethod = $boolean == 'and' ? 'where' : 'orWhere';
$query->$searchMethod(function ($q) use ($term, $columns, $scopeMethod) {
$q->$scopeMethod($term, $columns);
});
}
else {
$searchMethod = $boolean == 'and' ? 'searchWhere' : 'orSearchWhere';
$query->$searchMethod($term, $columns, $this->searchMode);
}
} | php | protected function applySearchToQuery($query, $columns, $boolean = 'and')
{
$term = $this->searchTerm;
if ($scopeMethod = $this->searchScope) {
$searchMethod = $boolean == 'and' ? 'where' : 'orWhere';
$query->$searchMethod(function ($q) use ($term, $columns, $scopeMethod) {
$q->$scopeMethod($term, $columns);
});
}
else {
$searchMethod = $boolean == 'and' ? 'searchWhere' : 'orSearchWhere';
$query->$searchMethod($term, $columns, $this->searchMode);
}
} | [
"protected",
"function",
"applySearchToQuery",
"(",
"$",
"query",
",",
"$",
"columns",
",",
"$",
"boolean",
"=",
"'and'",
")",
"{",
"$",
"term",
"=",
"$",
"this",
"->",
"searchTerm",
";",
"if",
"(",
"$",
"scopeMethod",
"=",
"$",
"this",
"->",
"searchSc... | Applies the search constraint to a query. | [
"Applies",
"the",
"search",
"constraint",
"to",
"a",
"query",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1438-L1452 | train | Apply search to query | [
30522,
5123,
3853,
6611,
17310,
11140,
3406,
4226,
2854,
1006,
1002,
23032,
1010,
1002,
7753,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1007,
1063,
1002,
2744,
1027,
1002,
2023,
1011,
1028,
3945,
3334,
2213,
1025,
2065,
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/Validator/Constraints/RegexValidator.php | RegexValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Regex) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Regex');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
if (null !== $constraint->normalizer) {
$value = ($constraint->normalizer)($value);
}
if ($constraint->match xor preg_match($constraint->pattern, $value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Regex::REGEX_FAILED_ERROR)
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Regex) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Regex');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
if (null !== $constraint->normalizer) {
$value = ($constraint->normalizer)($value);
}
if ($constraint->match xor preg_match($constraint->pattern, $value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Regex::REGEX_FAILED_ERROR)
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Regex",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/RegexValidator.php#L30-L56 | train | Validate the value against the constraints | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
19723,
10288,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
1035,
3415,
15... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/traits/CollapsableWidget.php | CollapsableWidget.setCollapseStatus | protected function setCollapseStatus($group, $status)
{
$statuses = $this->getCollapseStatuses();
$statuses[$group] = $status;
$this->collapseGroupStatusCache = $statuses;
$this->putSession($this->collapseSessionKey, $statuses);
} | php | protected function setCollapseStatus($group, $status)
{
$statuses = $this->getCollapseStatuses();
$statuses[$group] = $status;
$this->collapseGroupStatusCache = $statuses;
$this->putSession($this->collapseSessionKey, $statuses);
} | [
"protected",
"function",
"setCollapseStatus",
"(",
"$",
"group",
",",
"$",
"status",
")",
"{",
"$",
"statuses",
"=",
"$",
"this",
"->",
"getCollapseStatuses",
"(",
")",
";",
"$",
"statuses",
"[",
"$",
"group",
"]",
"=",
"$",
"status",
";",
"$",
"this",... | Sets a collapsed state.
@param string $group
@param string $status | [
"Sets",
"a",
"collapsed",
"state",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/traits/CollapsableWidget.php#L61-L70 | train | Set the collapse status for a group | [
30522,
5123,
3853,
2275,
26895,
9331,
8583,
29336,
2271,
1006,
1002,
2177,
1010,
1002,
3570,
1007,
1063,
1002,
3570,
2229,
1027,
1002,
2023,
1011,
1028,
2131,
26895,
9331,
8583,
29336,
25581,
1006,
1007,
1025,
1002,
3570,
2229,
1031,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/console/PluginInstall.php | PluginInstall.handle | public function handle()
{
$pluginName = $this->argument('name');
$manager = UpdateManager::instance()->setNotesOutput($this->output);
$pluginDetails = $manager->requestPluginDetails($pluginName);
$code = array_get($pluginDetails, 'code');
$hash = array_get($pluginDetails, 'hash');
$this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $code));
$manager->downloadPlugin($code, $hash, true);
$this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $code));
$manager->extractPlugin($code, $hash);
/*
* Migrate plugin
*/
$this->output->writeln(sprintf('<info>Migrating plugin...</info>', $code));
PluginManager::instance()->loadPlugins();
$manager->updatePlugin($code);
} | php | public function handle()
{
$pluginName = $this->argument('name');
$manager = UpdateManager::instance()->setNotesOutput($this->output);
$pluginDetails = $manager->requestPluginDetails($pluginName);
$code = array_get($pluginDetails, 'code');
$hash = array_get($pluginDetails, 'hash');
$this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $code));
$manager->downloadPlugin($code, $hash, true);
$this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $code));
$manager->extractPlugin($code, $hash);
/*
* Migrate plugin
*/
$this->output->writeln(sprintf('<info>Migrating plugin...</info>', $code));
PluginManager::instance()->loadPlugins();
$manager->updatePlugin($code);
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"pluginName",
"=",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
";",
"$",
"manager",
"=",
"UpdateManager",
"::",
"instance",
"(",
")",
"->",
"setNotesOutput",
"(",
"$",
"this",
"->",
"output",
"... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/console/PluginInstall.php#L35-L57 | train | Download and extract a plugin | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
13354,
23111,
14074,
1027,
1002,
2023,
1011,
1028,
6685,
1006,
1005,
2171,
1005,
1007,
1025,
1002,
3208,
1027,
10651,
24805,
4590,
1024,
1024,
6013,
1006,
1007,
1011,
1028,
2275,
20564,
5833,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Filesystem.php | Filesystem.remove | public static function remove($file, $silenceErrors = false)
{
if (!file_exists($file)) {
return;
}
$result = @unlink($file);
// Testing if the file still exist avoids race conditions
if (!$result && file_exists($file)) {
if ($silenceErrors) {
Log::warning('Failed to delete file ' . $file);
} else {
throw new \RuntimeException('Unable to delete file ' . $file);
}
}
} | php | public static function remove($file, $silenceErrors = false)
{
if (!file_exists($file)) {
return;
}
$result = @unlink($file);
// Testing if the file still exist avoids race conditions
if (!$result && file_exists($file)) {
if ($silenceErrors) {
Log::warning('Failed to delete file ' . $file);
} else {
throw new \RuntimeException('Unable to delete file ' . $file);
}
}
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"file",
",",
"$",
"silenceErrors",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"return",
";",
"}",
"$",
"result",
"=",
"@",
"unlink",
"(",
"$",
"file",
... | Remove a file.
@param string $file
@param bool $silenceErrors If true, no exception will be thrown in case removing fails. | [
"Remove",
"a",
"file",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L443-L459 | train | Remove a file from the cache | [
30522,
2270,
10763,
3853,
6366,
1006,
1002,
5371,
1010,
1002,
4223,
2121,
29165,
2015,
1027,
6270,
1007,
1063,
2065,
1006,
999,
5371,
1035,
6526,
1006,
1002,
5371,
1007,
1007,
1063,
2709,
1025,
1065,
1002,
2765,
1027,
1030,
4895,
13767,
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/Translation/Loader/YamlFileLoader.php | YamlFileLoader.loadResource | protected function loadResource($resource)
{
if (null === $this->yamlParser) {
if (!class_exists('Symfony\Component\Yaml\Parser')) {
throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.');
}
$this->yamlParser = new YamlParser();
}
try {
$messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT);
} catch (ParseException $e) {
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e);
}
return $messages;
} | php | protected function loadResource($resource)
{
if (null === $this->yamlParser) {
if (!class_exists('Symfony\Component\Yaml\Parser')) {
throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.');
}
$this->yamlParser = new YamlParser();
}
try {
$messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT);
} catch (ParseException $e) {
throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e);
}
return $messages;
} | [
"protected",
"function",
"loadResource",
"(",
"$",
"resource",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"yamlParser",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'Symfony\\Component\\Yaml\\Parser'",
")",
")",
"{",
"throw",
"new",
"LogicExce... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Loader/YamlFileLoader.php#L32-L49 | train | Load translations from a YAML file | [
30522,
5123,
3853,
7170,
6072,
8162,
3401,
1006,
1002,
7692,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
8038,
19968,
19362,
8043,
1007,
1063,
2065,
1006,
999,
2465,
1035,
6526,
1006,
1005,
25353,
2213,
14876,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/API/API.php | API.get | public function get($idSite, $period, $date, $segment = false, $columns = false)
{
Piwik::checkUserHasViewAccess($idSite);
$columns = Piwik::getArrayFromApiParameter($columns);
// build columns map for faster checks later on
$columnsMap = array();
foreach ($columns as $column) {
$columnsMap[$column] = true;
}
// find out which columns belong to which plugin
$columnsByPlugin = array();
$meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date);
foreach ($meta as $reportMeta) {
// scan all *.get reports
if ($reportMeta['action'] == 'get'
&& !isset($reportMeta['parameters'])
&& $reportMeta['module'] != 'API'
&& !empty($reportMeta['metrics'])
) {
$plugin = $reportMeta['module'];
$allMetrics = array_merge($reportMeta['metrics'], @$reportMeta['processedMetrics'] ?: array());
foreach ($allMetrics as $column => $columnTranslation) {
// a metric from this report has been requested
if (isset($columnsMap[$column])
// or by default, return all metrics
|| empty($columnsMap)
) {
$columnsByPlugin[$plugin][] = $column;
}
}
}
}
krsort($columnsByPlugin);
$mergedDataTable = false;
$params = compact('idSite', 'period', 'date', 'segment');
foreach ($columnsByPlugin as $plugin => $columns) {
// load the data
$className = Request::getClassNameAPI($plugin);
$params['columns'] = implode(',', $columns);
$dataTable = Proxy::getInstance()->call($className, 'get', $params);
$dataTable->filter(function (DataTable $table) {
$table->clearQueuedFilters();
});
// merge reports
if ($mergedDataTable === false) {
$mergedDataTable = $dataTable;
} else {
$merger = new MergeDataTables();
$merger->mergeDataTables($mergedDataTable, $dataTable);
}
}
if (!empty($columnsMap)
&& !empty($mergedDataTable)
) {
$mergedDataTable->queueFilter('ColumnDelete', array(false, array_keys($columnsMap)));
}
return $mergedDataTable;
} | php | public function get($idSite, $period, $date, $segment = false, $columns = false)
{
Piwik::checkUserHasViewAccess($idSite);
$columns = Piwik::getArrayFromApiParameter($columns);
// build columns map for faster checks later on
$columnsMap = array();
foreach ($columns as $column) {
$columnsMap[$column] = true;
}
// find out which columns belong to which plugin
$columnsByPlugin = array();
$meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date);
foreach ($meta as $reportMeta) {
// scan all *.get reports
if ($reportMeta['action'] == 'get'
&& !isset($reportMeta['parameters'])
&& $reportMeta['module'] != 'API'
&& !empty($reportMeta['metrics'])
) {
$plugin = $reportMeta['module'];
$allMetrics = array_merge($reportMeta['metrics'], @$reportMeta['processedMetrics'] ?: array());
foreach ($allMetrics as $column => $columnTranslation) {
// a metric from this report has been requested
if (isset($columnsMap[$column])
// or by default, return all metrics
|| empty($columnsMap)
) {
$columnsByPlugin[$plugin][] = $column;
}
}
}
}
krsort($columnsByPlugin);
$mergedDataTable = false;
$params = compact('idSite', 'period', 'date', 'segment');
foreach ($columnsByPlugin as $plugin => $columns) {
// load the data
$className = Request::getClassNameAPI($plugin);
$params['columns'] = implode(',', $columns);
$dataTable = Proxy::getInstance()->call($className, 'get', $params);
$dataTable->filter(function (DataTable $table) {
$table->clearQueuedFilters();
});
// merge reports
if ($mergedDataTable === false) {
$mergedDataTable = $dataTable;
} else {
$merger = new MergeDataTables();
$merger->mergeDataTables($mergedDataTable, $dataTable);
}
}
if (!empty($columnsMap)
&& !empty($mergedDataTable)
) {
$mergedDataTable->queueFilter('ColumnDelete', array(false, array_keys($columnsMap)));
}
return $mergedDataTable;
} | [
"public",
"function",
"get",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"columns",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"$",
"column... | Get a combined report of the *.get API methods. | [
"Get",
"a",
"combined",
"report",
"of",
"the",
"*",
".",
"get",
"API",
"methods",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/API.php#L392-L457 | train | Returns all metrics for a specific report. | [
30522,
2270,
3853,
2131,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1010,
1002,
7753,
1027,
6270,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
8584,
6305,
9623,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/GoalManager.php | GoalManager.triggerHookOnDimensions | private function triggerHookOnDimensions(Request $request, $dimensions, $hook, $visitor, $action, $valuesToUpdate)
{
foreach ($dimensions as $dimension) {
$value = $dimension->$hook($request, $visitor, $action, $this);
if (false !== $value) {
if (is_float($value)) {
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
}
$fieldName = $dimension->getColumnName();
$visitor->setVisitorColumn($fieldName, $value);
$valuesToUpdate[$fieldName] = $value;
}
}
return $valuesToUpdate;
} | php | private function triggerHookOnDimensions(Request $request, $dimensions, $hook, $visitor, $action, $valuesToUpdate)
{
foreach ($dimensions as $dimension) {
$value = $dimension->$hook($request, $visitor, $action, $this);
if (false !== $value) {
if (is_float($value)) {
$value = Common::forceDotAsSeparatorForDecimalPoint($value);
}
$fieldName = $dimension->getColumnName();
$visitor->setVisitorColumn($fieldName, $value);
$valuesToUpdate[$fieldName] = $value;
}
}
return $valuesToUpdate;
} | [
"private",
"function",
"triggerHookOnDimensions",
"(",
"Request",
"$",
"request",
",",
"$",
"dimensions",
",",
"$",
"hook",
",",
"$",
"visitor",
",",
"$",
"action",
",",
"$",
"valuesToUpdate",
")",
"{",
"foreach",
"(",
"$",
"dimensions",
"as",
"$",
"dimens... | @param ConversionDimension[] $dimensions
@param string $hook
@param Visitor $visitor
@param Action|null $action
@param array|null $valuesToUpdate If null, $this->visitorInfo will be updated
@return array|null The updated $valuesToUpdate or null if no $valuesToUpdate given | [
"@param",
"ConversionDimension",
"[]",
"$dimensions",
"@param",
"string",
"$hook",
"@param",
"Visitor",
"$visitor",
"@param",
"Action|null",
"$action",
"@param",
"array|null",
"$valuesToUpdate",
"If",
"null",
"$this",
"-",
">",
"visitorInfo",
"will",
"be",
"updated"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/GoalManager.php#L810-L828 | train | Trigger the hook on the dimensions | [
30522,
2797,
3853,
9495,
6806,
16366,
16089,
3549,
27466,
1006,
5227,
1002,
5227,
1010,
1002,
9646,
1010,
1002,
8103,
1010,
1002,
10367,
1010,
1002,
2895,
1010,
1002,
5300,
24826,
17299,
3686,
1007,
1063,
18921,
6776,
1006,
1002,
9646,
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 | plugins/Intl/DateTimeFormatProvider.php | DateTimeFormatProvider.getFormatPattern | public function getFormatPattern($format)
{
switch ($format) {
case self::DATETIME_FORMAT_LONG:
$pattern = $this->translator->translate('Intl_Format_DateTime_Long');
break;
case self::DATETIME_FORMAT_SHORT:
$pattern = $this->translator->translate('Intl_Format_DateTime_Short');
break;
case self::DATE_FORMAT_LONG:
$pattern = $this->translator->translate('Intl_Format_Date_Long');
break;
case self::DATE_FORMAT_DAY_MONTH:
$pattern = $this->translator->translate('Intl_Format_Date_Day_Month');
break;
case self::DATE_FORMAT_SHORT:
$pattern = $this->translator->translate('Intl_Format_Date_Short');
break;
case self::DATE_FORMAT_MONTH_SHORT:
$pattern = $this->translator->translate('Intl_Format_Month_Short');
break;
case self::DATE_FORMAT_MONTH_LONG:
$pattern = $this->translator->translate('Intl_Format_Month_Long');
break;
case self::DATE_FORMAT_YEAR:
$pattern = $this->translator->translate('Intl_Format_Year');
break;
case self::TIME_FORMAT:
$pattern = $this->translator->translate('Intl_Format_Time');
break;
default:
$pattern = $format;
}
if (strpos($pattern, '{time}') !== false) {
$pattern = str_replace('{time}', $this->getTimeFormat(), $pattern);
}
return $pattern;
} | php | public function getFormatPattern($format)
{
switch ($format) {
case self::DATETIME_FORMAT_LONG:
$pattern = $this->translator->translate('Intl_Format_DateTime_Long');
break;
case self::DATETIME_FORMAT_SHORT:
$pattern = $this->translator->translate('Intl_Format_DateTime_Short');
break;
case self::DATE_FORMAT_LONG:
$pattern = $this->translator->translate('Intl_Format_Date_Long');
break;
case self::DATE_FORMAT_DAY_MONTH:
$pattern = $this->translator->translate('Intl_Format_Date_Day_Month');
break;
case self::DATE_FORMAT_SHORT:
$pattern = $this->translator->translate('Intl_Format_Date_Short');
break;
case self::DATE_FORMAT_MONTH_SHORT:
$pattern = $this->translator->translate('Intl_Format_Month_Short');
break;
case self::DATE_FORMAT_MONTH_LONG:
$pattern = $this->translator->translate('Intl_Format_Month_Long');
break;
case self::DATE_FORMAT_YEAR:
$pattern = $this->translator->translate('Intl_Format_Year');
break;
case self::TIME_FORMAT:
$pattern = $this->translator->translate('Intl_Format_Time');
break;
default:
$pattern = $format;
}
if (strpos($pattern, '{time}') !== false) {
$pattern = str_replace('{time}', $this->getTimeFormat(), $pattern);
}
return $pattern;
} | [
"public",
"function",
"getFormatPattern",
"(",
"$",
"format",
")",
"{",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"self",
"::",
"DATETIME_FORMAT_LONG",
":",
"$",
"pattern",
"=",
"$",
"this",
"->",
"translator",
"->",
"translate",
"(",
"'Intl_Format_Dat... | Returns the format pattern for the given format type
@param int $format one of the format constants
@return string | [
"Returns",
"the",
"format",
"pattern",
"for",
"the",
"given",
"format",
"type"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Intl/DateTimeFormatProvider.php#L38-L87 | train | Return the pattern of the format | [
30522,
2270,
3853,
2131,
14192,
4017,
4502,
12079,
2078,
1006,
1002,
4289,
1007,
1063,
6942,
1006,
1002,
4289,
1007,
1063,
2553,
2969,
1024,
1024,
3058,
7292,
1035,
4289,
1035,
2146,
1024,
1002,
5418,
1027,
1002,
2023,
1011,
1028,
11403,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FilterScope.php | FilterScope.getId | public function getId($suffix = null)
{
$id = 'scope';
$id .= '-'.$this->scopeName;
if ($suffix) {
$id .= '-'.$suffix;
}
if ($this->idPrefix) {
$id = $this->idPrefix . '-' . $id;
}
return HtmlHelper::nameToId($id);
} | php | public function getId($suffix = null)
{
$id = 'scope';
$id .= '-'.$this->scopeName;
if ($suffix) {
$id .= '-'.$suffix;
}
if ($this->idPrefix) {
$id = $this->idPrefix . '-' . $id;
}
return HtmlHelper::nameToId($id);
} | [
"public",
"function",
"getId",
"(",
"$",
"suffix",
"=",
"null",
")",
"{",
"$",
"id",
"=",
"'scope'",
";",
"$",
"id",
".=",
"'-'",
".",
"$",
"this",
"->",
"scopeName",
";",
"if",
"(",
"$",
"suffix",
")",
"{",
"$",
"id",
".=",
"'-'",
".",
"$",
... | Returns a value suitable for the scope id property. | [
"Returns",
"a",
"value",
"suitable",
"for",
"the",
"scope",
"id",
"property",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FilterScope.php#L149-L163 | train | Returns the id of the scope | [
30522,
2270,
3853,
2131,
3593,
1006,
1002,
16809,
1027,
19701,
1007,
1063,
1002,
8909,
1027,
1005,
9531,
1005,
1025,
1002,
8909,
1012,
1027,
1005,
1011,
1005,
1012,
1002,
2023,
1011,
1028,
9531,
18442,
1025,
2065,
1006,
1002,
16809,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/ExampleTracker/Columns/ExampleConversionDimension.php | ExampleConversionDimension.onEcommerceOrderConversion | public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
if ($visitor->isVisitorKnown()) {
return 1;
}
return 0;
} | php | public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
if ($visitor->isVisitorKnown()) {
return 1;
}
return 0;
} | [
"public",
"function",
"onEcommerceOrderConversion",
"(",
"Request",
"$",
"request",
",",
"Visitor",
"$",
"visitor",
",",
"$",
"action",
",",
"GoalManager",
"$",
"goalManager",
")",
"{",
"if",
"(",
"$",
"visitor",
"->",
"isVisitorKnown",
"(",
")",
")",
"{",
... | This event is triggered when an ecommerce order is converted. In this example we would store a "0" in case it
was the visitors first action or "1" otherwise.
Return boolean false if you do not want to change the value in some cases. If you do not want to perform any
action on an ecommerce order at all it is recommended to just remove this method.
@param Request $request
@param Visitor $visitor
@param Action|null $action
@param GoalManager $goalManager
@return mixed|false | [
"This",
"event",
"is",
"triggered",
"when",
"an",
"ecommerce",
"order",
"is",
"converted",
".",
"In",
"this",
"example",
"we",
"would",
"store",
"a",
"0",
"in",
"case",
"it",
"was",
"the",
"visitors",
"first",
"action",
"or",
"1",
"otherwise",
".",
"Retu... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/ExampleTracker/Columns/ExampleConversionDimension.php#L81-L88 | train | This method is called when an ecommerce order conversion is triggered. | [
30522,
2270,
3853,
2028,
9006,
5017,
3401,
8551,
2121,
8663,
27774,
1006,
5227,
1002,
5227,
1010,
10367,
1002,
10367,
1010,
1002,
2895,
1010,
3125,
24805,
4590,
1002,
3125,
24805,
4590,
1007,
1063,
2065,
1006,
1002,
10367,
1011,
1028,
2003,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
php-ai/php-ml | src/Math/Statistic/Correlation.php | Correlation.pearson | public static function pearson(array $x, array $y): float
{
if (count($x) !== count($y)) {
throw new InvalidArgumentException('Size of given arrays does not match');
}
$count = count($x);
$meanX = Mean::arithmetic($x);
$meanY = Mean::arithmetic($y);
$axb = 0;
$a2 = 0;
$b2 = 0;
for ($i = 0; $i < $count; ++$i) {
$a = $x[$i] - $meanX;
$b = $y[$i] - $meanY;
$axb += ($a * $b);
$a2 += $a ** 2;
$b2 += $b ** 2;
}
return $axb / ($a2 * $b2) ** .5;
} | php | public static function pearson(array $x, array $y): float
{
if (count($x) !== count($y)) {
throw new InvalidArgumentException('Size of given arrays does not match');
}
$count = count($x);
$meanX = Mean::arithmetic($x);
$meanY = Mean::arithmetic($y);
$axb = 0;
$a2 = 0;
$b2 = 0;
for ($i = 0; $i < $count; ++$i) {
$a = $x[$i] - $meanX;
$b = $y[$i] - $meanY;
$axb += ($a * $b);
$a2 += $a ** 2;
$b2 += $b ** 2;
}
return $axb / ($a2 * $b2) ** .5;
} | [
"public",
"static",
"function",
"pearson",
"(",
"array",
"$",
"x",
",",
"array",
"$",
"y",
")",
":",
"float",
"{",
"if",
"(",
"count",
"(",
"$",
"x",
")",
"!==",
"count",
"(",
"$",
"y",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"("... | @param int[]|float[] $x
@param int[]|float[] $y
@throws InvalidArgumentException | [
"@param",
"int",
"[]",
"|float",
"[]",
"$x",
"@param",
"int",
"[]",
"|float",
"[]",
"$y"
] | f6aa1a59b0525b8fca3d2786d661ab3e70904016 | https://github.com/php-ai/php-ml/blob/f6aa1a59b0525b8fca3d2786d661ab3e70904016/src/Math/Statistic/Correlation.php#L17-L40 | train | Returns the pearson probability of given x and y | [
30522,
2270,
10763,
3853,
12874,
1006,
9140,
1002,
1060,
1010,
9140,
1002,
1061,
1007,
1024,
14257,
1063,
2065,
1006,
4175,
1006,
1002,
1060,
1007,
999,
1027,
1027,
4175,
1006,
1002,
1061,
1007,
1007,
1063,
5466,
2047,
19528,
2906,
22850,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Cache/Backend/Sqlite.php | Zend_Cache_Backend_Sqlite._checkStructureVersion | private function _checkStructureVersion()
{
$result = $this->_query("SELECT num FROM version");
if (!$result) return false;
$row = @sqlite_fetch_array($result);
if (!$row) {
return false;
}
if (((int) $row['num']) != 1) {
// old cache structure
$this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped');
return false;
}
return true;
} | php | private function _checkStructureVersion()
{
$result = $this->_query("SELECT num FROM version");
if (!$result) return false;
$row = @sqlite_fetch_array($result);
if (!$row) {
return false;
}
if (((int) $row['num']) != 1) {
// old cache structure
$this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped');
return false;
}
return true;
} | [
"private",
"function",
"_checkStructureVersion",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_query",
"(",
"\"SELECT num FROM version\"",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"return",
"false",
";",
"$",
"row",
"=",
"@",
"sqlite_fetch_a... | Check if the database structure is ok (with the good version)
@return boolean True if ok | [
"Check",
"if",
"the",
"database",
"structure",
"is",
"ok",
"(",
"with",
"the",
"good",
"version",
")"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Backend/Sqlite.php#L581-L595 | train | Check cache structure version | [
30522,
2797,
3853,
1035,
14148,
18300,
5397,
27774,
1006,
1007,
1063,
1002,
2765,
1027,
1002,
2023,
1011,
1028,
1035,
23032,
1006,
1000,
7276,
16371,
2213,
2013,
2544,
1000,
1007,
1025,
2065,
1006,
999,
1002,
2765,
1007,
2709,
6270,
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... |
octobercms/october | modules/system/classes/PluginManager.php | PluginManager.loadPlugins | public function loadPlugins()
{
$this->plugins = [];
/**
* Locate all plugins and binds them to the container
*/
foreach ($this->getPluginNamespaces() as $namespace => $path) {
$this->loadPlugin($namespace, $path);
}
return $this->plugins;
} | php | public function loadPlugins()
{
$this->plugins = [];
/**
* Locate all plugins and binds them to the container
*/
foreach ($this->getPluginNamespaces() as $namespace => $path) {
$this->loadPlugin($namespace, $path);
}
return $this->plugins;
} | [
"public",
"function",
"loadPlugins",
"(",
")",
"{",
"$",
"this",
"->",
"plugins",
"=",
"[",
"]",
";",
"/**\n * Locate all plugins and binds them to the container\n */",
"foreach",
"(",
"$",
"this",
"->",
"getPluginNamespaces",
"(",
")",
"as",
"$",
"n... | Finds all available plugins and loads them in to the $plugins array.
@return array | [
"Finds",
"all",
"available",
"plugins",
"and",
"loads",
"them",
"in",
"to",
"the",
"$plugins",
"array",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/PluginManager.php#L100-L112 | train | Load all plugins | [
30522,
2270,
3853,
7170,
24759,
15916,
7076,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
13354,
7076,
1027,
1031,
1033,
1025,
1013,
1008,
1008,
1008,
12453,
2035,
13354,
7076,
1998,
20817,
2068,
2000,
1996,
11661,
1008,
1013,
18921,
6776,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/SettingsPiwik.php | SettingsPiwik.checkPiwikServerWorking | public static function checkPiwikServerWorking($piwikServerUrl, $acceptInvalidSSLCertificates = false)
{
// Now testing if the webserver is running
try {
$fetched = Http::sendHttpRequestBy('curl',
$piwikServerUrl,
$timeout = 45,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSSLCertificates
);
} catch (Exception $e) {
$fetched = "ERROR fetching: " . $e->getMessage();
}
// this will match when Piwik not installed yet, or favicon not customised
$expectedStringAlt = 'plugins/CoreHome/images/favicon.png';
// this will match when Piwik is installed and favicon has been customised
$expectedString = 'misc/user/';
// see checkPiwikIsNotInstalled()
$expectedStringAlreadyInstalled = 'piwik-is-already-installed';
$expectedStringNotFound = strpos($fetched, $expectedString) === false
&& strpos($fetched, $expectedStringAlt) === false
&& strpos($fetched, $expectedStringAlreadyInstalled) === false;
$hasError = false !== strpos($fetched, PAGE_TITLE_WHEN_ERROR);
if ($hasError || $expectedStringNotFound) {
throw new Exception("\nMatomo should be running at: "
. $piwikServerUrl
. " but this URL returned an unexpected response: '"
. $fetched . "'\n\n");
}
} | php | public static function checkPiwikServerWorking($piwikServerUrl, $acceptInvalidSSLCertificates = false)
{
// Now testing if the webserver is running
try {
$fetched = Http::sendHttpRequestBy('curl',
$piwikServerUrl,
$timeout = 45,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSSLCertificates
);
} catch (Exception $e) {
$fetched = "ERROR fetching: " . $e->getMessage();
}
// this will match when Piwik not installed yet, or favicon not customised
$expectedStringAlt = 'plugins/CoreHome/images/favicon.png';
// this will match when Piwik is installed and favicon has been customised
$expectedString = 'misc/user/';
// see checkPiwikIsNotInstalled()
$expectedStringAlreadyInstalled = 'piwik-is-already-installed';
$expectedStringNotFound = strpos($fetched, $expectedString) === false
&& strpos($fetched, $expectedStringAlt) === false
&& strpos($fetched, $expectedStringAlreadyInstalled) === false;
$hasError = false !== strpos($fetched, PAGE_TITLE_WHEN_ERROR);
if ($hasError || $expectedStringNotFound) {
throw new Exception("\nMatomo should be running at: "
. $piwikServerUrl
. " but this URL returned an unexpected response: '"
. $fetched . "'\n\n");
}
} | [
"public",
"static",
"function",
"checkPiwikServerWorking",
"(",
"$",
"piwikServerUrl",
",",
"$",
"acceptInvalidSSLCertificates",
"=",
"false",
")",
"{",
"// Now testing if the webserver is running",
"try",
"{",
"$",
"fetched",
"=",
"Http",
"::",
"sendHttpRequestBy",
"("... | Returns true if the Piwik server appears to be working.
If the Piwik server is in an error state (eg. some directories are not writable and Piwik displays error message),
or if the Piwik server is "offline",
this will return false..
@param $piwikServerUrl
@param bool $acceptInvalidSSLCertificates
@throws Exception
@return bool | [
"Returns",
"true",
"if",
"the",
"Piwik",
"server",
"appears",
"to",
"be",
"working",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/SettingsPiwik.php#L373-L411 | train | Checks if the Matomo server is working | [
30522,
2270,
10763,
3853,
4638,
8197,
9148,
5705,
2121,
6299,
21398,
1006,
1002,
14255,
9148,
5705,
2121,
6299,
3126,
2140,
1010,
1002,
5138,
2378,
10175,
9821,
14540,
17119,
3775,
8873,
16280,
2015,
1027,
6270,
1007,
1063,
1013,
1013,
2085... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/ListColumn.php | ListColumn.getValueFromData | public function getValueFromData($data, $default = null)
{
$columnName = $this->valueFrom ?: $this->columnName;
return $this->getColumnNameFromData($columnName, $data, $default);
} | php | public function getValueFromData($data, $default = null)
{
$columnName = $this->valueFrom ?: $this->columnName;
return $this->getColumnNameFromData($columnName, $data, $default);
} | [
"public",
"function",
"getValueFromData",
"(",
"$",
"data",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"columnName",
"=",
"$",
"this",
"->",
"valueFrom",
"?",
":",
"$",
"this",
"->",
"columnName",
";",
"return",
"$",
"this",
"->",
"getColumnNameFro... | Returns this columns value from a supplied data set, which can be
an array or a model or another generic collection.
@param mixed $data
@param mixed $default
@return mixed | [
"Returns",
"this",
"columns",
"value",
"from",
"a",
"supplied",
"data",
"set",
"which",
"can",
"be",
"an",
"array",
"or",
"a",
"model",
"or",
"another",
"generic",
"collection",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/ListColumn.php#L221-L225 | train | Get the value from the data. | [
30522,
2270,
3853,
2131,
10175,
5657,
19699,
5358,
2850,
2696,
1006,
1002,
2951,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
1002,
5930,
18442,
1027,
1002,
2023,
1011,
1028,
3643,
19699,
30524,
1010,
1002,
12398,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/controllers/Users.php | Users.update_onRestore | public function update_onRestore($recordId)
{
$this->formFindModelObject($recordId)->restore();
Flash::success(Lang::get('backend::lang.form.restore_success', ['name' => Lang::get('backend::lang.user.name')]));
return Redirect::refresh();
} | php | public function update_onRestore($recordId)
{
$this->formFindModelObject($recordId)->restore();
Flash::success(Lang::get('backend::lang.form.restore_success', ['name' => Lang::get('backend::lang.user.name')]));
return Redirect::refresh();
} | [
"public",
"function",
"update_onRestore",
"(",
"$",
"recordId",
")",
"{",
"$",
"this",
"->",
"formFindModelObject",
"(",
"$",
"recordId",
")",
"->",
"restore",
"(",
")",
";",
"Flash",
"::",
"success",
"(",
"Lang",
"::",
"get",
"(",
"'backend::lang.form.resto... | Handle restoring users | [
"Handle",
"restoring",
"users"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/controllers/Users.php#L124-L131 | train | Update record after restore | [
30522,
2270,
3853,
10651,
1035,
2006,
28533,
5686,
1006,
1002,
2501,
3593,
1007,
1063,
1002,
2023,
1011,
1028,
2433,
16294,
22117,
10244,
4135,
2497,
20614,
1006,
1002,
2501,
3593,
1007,
1011,
1028,
9239,
1006,
1007,
1025,
5956,
1024,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php | ResponseHeaderBag.remove | public function remove($key)
{
$uniqueKey = str_replace('_', '-', strtolower($key));
unset($this->headerNames[$uniqueKey]);
if ('set-cookie' === $uniqueKey) {
$this->cookies = [];
return;
}
parent::remove($key);
if ('cache-control' === $uniqueKey) {
$this->computedCacheControl = [];
}
if ('date' === $uniqueKey) {
$this->initDate();
}
} | php | public function remove($key)
{
$uniqueKey = str_replace('_', '-', strtolower($key));
unset($this->headerNames[$uniqueKey]);
if ('set-cookie' === $uniqueKey) {
$this->cookies = [];
return;
}
parent::remove($key);
if ('cache-control' === $uniqueKey) {
$this->computedCacheControl = [];
}
if ('date' === $uniqueKey) {
$this->initDate();
}
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"uniqueKey",
"=",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"strtolower",
"(",
"$",
"key",
")",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"headerNames",
"[",
"$",
"uniqueKey",
"]",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php#L135-L155 | train | Remove a header from the header array | [
30522,
2270,
3853,
6366,
1006,
1002,
3145,
1007,
1063,
1002,
4310,
14839,
1027,
2358,
2099,
1035,
5672,
1006,
1005,
1035,
1005,
1010,
1005,
1011,
1005,
1010,
2358,
5339,
12898,
13777,
1006,
1002,
3145,
1007,
1007,
1025,
4895,
13462,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/FormatsMessages.php | FormatsMessages.callClassBasedReplacer | protected function callClassBasedReplacer($callback, $message, $attribute, $rule, $parameters, $validator)
{
[$class, $method] = Str::parseCallback($callback, 'replace');
return call_user_func_array([$this->container->make($class), $method], array_slice(func_get_args(), 1));
} | php | protected function callClassBasedReplacer($callback, $message, $attribute, $rule, $parameters, $validator)
{
[$class, $method] = Str::parseCallback($callback, 'replace');
return call_user_func_array([$this->container->make($class), $method], array_slice(func_get_args(), 1));
} | [
"protected",
"function",
"callClassBasedReplacer",
"(",
"$",
"callback",
",",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"parameters",
",",
"$",
"validator",
")",
"{",
"[",
"$",
"class",
",",
"$",
"method",
"]",
"=",
"Str",
"::"... | Call a class based validator message replacer.
@param string $callback
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@param \Illuminate\Validation\Validator $validator
@return string | [
"Call",
"a",
"class",
"based",
"validator",
"message",
"replacer",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/FormatsMessages.php#L378-L383 | train | Call a class - based replacer. | [
30522,
5123,
3853,
2655,
26266,
15058,
16200,
24759,
10732,
2099,
1006,
1002,
2655,
5963,
1010,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
1010,
1002,
9398,
8844,
1007,
1063,
1031,
1002,
2465,
1010,
1002,
4118,
1033... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/BrowserKit/Client.php | Client.getInternalResponse | public function getInternalResponse()
{
if (null === $this->internalResponse) {
@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->internalResponse;
} | php | public function getInternalResponse()
{
if (null === $this->internalResponse) {
@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->internalResponse;
} | [
"public",
"function",
"getInternalResponse",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"internalResponse",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'Calling the \"%s()\" method before the \"request()\" one is deprecated since Symfony 4.1 and w... | Returns the current BrowserKit Response instance.
@return Response A BrowserKit Response instance | [
"Returns",
"the",
"current",
"BrowserKit",
"Response",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/BrowserKit/Client.php#L216-L224 | train | Returns the internal response | [
30522,
2270,
3853,
2131,
18447,
11795,
2389,
6072,
26029,
3366,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
4722,
6072,
26029,
3366,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
4214,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail/Part.php | Zend_Mail_Part.headerExists | public function headerExists($name)
{
$name = strtolower($name);
if(isset($this->_headers[$name])) {
return true;
} else {
return false;
}
} | php | public function headerExists($name)
{
$name = strtolower($name);
if(isset($this->_headers[$name])) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"headerExists",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_headers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}"... | Check wheater the Mail part has a specific header.
@param string $name
@return boolean | [
"Check",
"wheater",
"the",
"Mail",
"part",
"has",
"a",
"specific",
"header",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Part.php#L375-L383 | train | Checks if a header exists | [
30522,
2270,
3853,
20346,
10288,
5130,
1006,
1002,
2171,
1007,
1063,
1002,
2171,
1027,
2358,
5339,
12898,
13777,
1006,
1002,
2171,
1007,
1025,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
1035,
20346,
2015,
1031,
1002,
2171,
1033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Rule.php | HTML_QuickForm2_Rule.setOwnerError | protected function setOwnerError()
{
if (strlen($this->getMessage()) && !$this->owner->getError()) {
$this->owner->setError($this->getMessage());
}
} | php | protected function setOwnerError()
{
if (strlen($this->getMessage()) && !$this->owner->getError()) {
$this->owner->setError($this->getMessage());
}
} | [
"protected",
"function",
"setOwnerError",
"(",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"getMessage",
"(",
")",
")",
"&&",
"!",
"$",
"this",
"->",
"owner",
"->",
"getError",
"(",
")",
")",
"{",
"$",
"this",
"->",
"owner",
"->",
"setEr... | Sets the error message on the owner element | [
"Sets",
"the",
"error",
"message",
"on",
"the",
"owner",
"element"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule.php#L273-L278 | train | Protected setOwnerError - Set Error | [
30522,
5123,
3853,
2275,
12384,
7869,
18933,
2099,
1006,
1007,
1063,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
2023,
1011,
1028,
2131,
7834,
3736,
3351,
1006,
1007,
1007,
1004,
1004,
999,
1002,
2023,
1011,
1028,
3954,
1011,
1028,
2131,
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/Intl/Collator/Collator.php | Collator.asort | public function asort(&$array, $sortFlag = self::SORT_REGULAR)
{
$intlToPlainFlagMap = [
self::SORT_REGULAR => \SORT_REGULAR,
self::SORT_NUMERIC => \SORT_NUMERIC,
self::SORT_STRING => \SORT_STRING,
];
$plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR;
return asort($array, $plainSortFlag);
} | php | public function asort(&$array, $sortFlag = self::SORT_REGULAR)
{
$intlToPlainFlagMap = [
self::SORT_REGULAR => \SORT_REGULAR,
self::SORT_NUMERIC => \SORT_NUMERIC,
self::SORT_STRING => \SORT_STRING,
];
$plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR;
return asort($array, $plainSortFlag);
} | [
"public",
"function",
"asort",
"(",
"&",
"$",
"array",
",",
"$",
"sortFlag",
"=",
"self",
"::",
"SORT_REGULAR",
")",
"{",
"$",
"intlToPlainFlagMap",
"=",
"[",
"self",
"::",
"SORT_REGULAR",
"=>",
"\\",
"SORT_REGULAR",
",",
"self",
"::",
"SORT_NUMERIC",
"=>"... | Sort array maintaining index association.
@param array &$array Input array
@param int $sortFlag Flags for sorting, can be one of the following:
Collator::SORT_REGULAR - compare items normally (don't change types)
Collator::SORT_NUMERIC - compare items numerically
Collator::SORT_STRING - compare items as strings
@return bool True on success or false on failure | [
"Sort",
"array",
"maintaining",
"index",
"association",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Collator/Collator.php#L109-L120 | train | Sort array by sort flag | [
30522,
2270,
3853,
2004,
11589,
1006,
1004,
1002,
9140,
1010,
1002,
4066,
10258,
8490,
1027,
2969,
1024,
1024,
4066,
1035,
3180,
1007,
1063,
1002,
20014,
23223,
24759,
8113,
10258,
8490,
2863,
2361,
1027,
1031,
2969,
1024,
1024,
4066,
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/Debug/ErrorHandler.php | ErrorHandler.setExceptionHandler | public function setExceptionHandler(callable $handler = null)
{
$prev = $this->exceptionHandler;
$this->exceptionHandler = $handler;
return $prev;
} | php | public function setExceptionHandler(callable $handler = null)
{
$prev = $this->exceptionHandler;
$this->exceptionHandler = $handler;
return $prev;
} | [
"public",
"function",
"setExceptionHandler",
"(",
"callable",
"$",
"handler",
"=",
"null",
")",
"{",
"$",
"prev",
"=",
"$",
"this",
"->",
"exceptionHandler",
";",
"$",
"this",
"->",
"exceptionHandler",
"=",
"$",
"handler",
";",
"return",
"$",
"prev",
";",
... | Sets a user exception handler.
@param callable $handler A handler that will be called on Exception
@return callable|null The previous exception handler | [
"Sets",
"a",
"user",
"exception",
"handler",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Debug/ErrorHandler.php#L264-L270 | train | Set exception handler | [
30522,
2270,
3853,
2275,
10288,
24422,
11774,
3917,
1006,
2655,
3085,
1002,
28213,
1027,
19701,
1007,
1063,
1002,
3653,
2615,
1027,
1002,
2023,
1011,
1028,
6453,
11774,
3917,
1025,
1002,
2023,
1011,
1028,
6453,
11774,
3917,
1027,
1002,
2821... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dompdf/dompdf | src/Css/AttributeTranslator.php | AttributeTranslator._resolve_target | static protected function _resolve_target(\DOMNode $node, $target, $value)
{
if ($target[0] === "!") {
// Function call
$func = "_" . mb_substr($target, 1);
return self::$func($node, $value);
}
return $value ? sprintf($target, $value) : "";
} | php | static protected function _resolve_target(\DOMNode $node, $target, $value)
{
if ($target[0] === "!") {
// Function call
$func = "_" . mb_substr($target, 1);
return self::$func($node, $value);
}
return $value ? sprintf($target, $value) : "";
} | [
"static",
"protected",
"function",
"_resolve_target",
"(",
"\\",
"DOMNode",
"$",
"node",
",",
"$",
"target",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"target",
"[",
"0",
"]",
"===",
"\"!\"",
")",
"{",
"// Function call",
"$",
"func",
"=",
"\"_\"",
... | @param \DOMNode $node
@param string $target
@param string $value
@return string | [
"@param",
"\\",
"DOMNode",
"$node",
"@param",
"string",
"$target",
"@param",
"string",
"$value"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/AttributeTranslator.php#L262-L272 | train | Resolve target string | [
30522,
10763,
5123,
3853,
1035,
10663,
1035,
4539,
1006,
1032,
14383,
3630,
3207,
1002,
13045,
1010,
1002,
4539,
1010,
1002,
3643,
1007,
1063,
2065,
1006,
1002,
4539,
1031,
1014,
1033,
1027,
1027,
1027,
1000,
999,
1000,
1007,
1063,
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... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.lastModified | public function lastModified($modified = null)
{
if ($modified && $modified > $this->last_modified) {
$this->last_modified = $modified;
}
return $this->last_modified;
} | php | public function lastModified($modified = null)
{
if ($modified && $modified > $this->last_modified) {
$this->last_modified = $modified;
}
return $this->last_modified;
} | [
"public",
"function",
"lastModified",
"(",
"$",
"modified",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"modified",
"&&",
"$",
"modified",
">",
"$",
"this",
"->",
"last_modified",
")",
"{",
"$",
"this",
"->",
"last_modified",
"=",
"$",
"modified",
";",
"}",... | Get or set last modification time.
@param int $modified
@return int|null | [
"Get",
"or",
"set",
"last",
"modification",
"time",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L265-L272 | train | Get Last Modified | [
30522,
2270,
3853,
2197,
5302,
4305,
10451,
1006,
1002,
6310,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
6310,
1004,
1004,
1002,
6310,
1028,
1002,
2023,
1011,
1028,
2197,
1035,
6310,
1007,
1063,
1002,
2023,
1011,
1028,
2197,
1035,
6310,
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.disableOutput | public function disableOutput()
{
if ($this->isRunning()) {
throw new RuntimeException('Disabling output while the process is running is not possible.');
}
if (null !== $this->idleTimeout) {
throw new LogicException('Output can not be disabled while an idle timeout is set.');
}
$this->outputDisabled = true;
return $this;
} | php | public function disableOutput()
{
if ($this->isRunning()) {
throw new RuntimeException('Disabling output while the process is running is not possible.');
}
if (null !== $this->idleTimeout) {
throw new LogicException('Output can not be disabled while an idle timeout is set.');
}
$this->outputDisabled = true;
return $this;
} | [
"public",
"function",
"disableOutput",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRunning",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Disabling output while the process is running is not possible.'",
")",
";",
"}",
"if",
"(",
"null",
"!... | Disables fetching output and error output from the underlying process.
@return $this
@throws RuntimeException In case the process is already running
@throws LogicException if an idle timeout is set | [
"Disables",
"fetching",
"output",
"and",
"error",
"output",
"from",
"the",
"underlying",
"process",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Process.php#L513-L525 | train | Disables output. | [
30522,
2270,
3853,
4487,
19150,
5833,
18780,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
15532,
5582,
1006,
1007,
1007,
1063,
5466,
2047,
2448,
7292,
10288,
24422,
1006,
1005,
4487,
3736,
9709,
6434,
2096,
1996,
2832,
2003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/CoreAdminHome/API.php | API.getTrackingFailures | public function getTrackingFailures()
{
if (Piwik::hasUserSuperUserAccess()) {
$failures = $this->trackingFailures->getAllFailures();
} else {
Piwik::checkUserHasSomeAdminAccess();
$idSites = Access::getInstance()->getSitesIdWithAdminAccess();
Piwik::checkUserHasAdminAccess($idSites);
$failures = $this->trackingFailures->getFailuresForSites($idSites);
}
return $failures;
} | php | public function getTrackingFailures()
{
if (Piwik::hasUserSuperUserAccess()) {
$failures = $this->trackingFailures->getAllFailures();
} else {
Piwik::checkUserHasSomeAdminAccess();
$idSites = Access::getInstance()->getSitesIdWithAdminAccess();
Piwik::checkUserHasAdminAccess($idSites);
$failures = $this->trackingFailures->getFailuresForSites($idSites);
}
return $failures;
} | [
"public",
"function",
"getTrackingFailures",
"(",
")",
"{",
"if",
"(",
"Piwik",
"::",
"hasUserSuperUserAccess",
"(",
")",
")",
"{",
"$",
"failures",
"=",
"$",
"this",
"->",
"trackingFailures",
"->",
"getAllFailures",
"(",
")",
";",
"}",
"else",
"{",
"Piwik... | Get all tracking failures. A user retrieves only tracking failures for sites with at least admin access.
A super user will also retrieve failed requests for sites that don't exist.
@return array | [
"Get",
"all",
"tracking",
"failures",
".",
"A",
"user",
"retrieves",
"only",
"tracking",
"failures",
"for",
"sites",
"with",
"at",
"least",
"admin",
"access",
".",
"A",
"super",
"user",
"will",
"also",
"retrieve",
"failed",
"requests",
"for",
"sites",
"that"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreAdminHome/API.php#L224-L237 | train | Returns the list of tracking failures for all sites | [
30522,
2270,
3853,
2131,
6494,
23177,
7011,
4014,
14900,
1006,
1007,
1063,
2065,
1006,
14255,
9148,
2243,
1024,
1024,
2038,
20330,
6342,
4842,
20330,
6305,
9623,
2015,
1006,
1007,
1007,
1063,
1002,
15428,
1027,
1002,
2023,
1011,
1028,
9651,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Container/Container.php | Container.alias | public function alias($abstract, $alias)
{
if ($alias === $abstract) {
throw new LogicException("[{$abstract}] is aliased to itself.");
}
$this->aliases[$alias] = $abstract;
$this->abstractAliases[$abstract][] = $alias;
} | php | public function alias($abstract, $alias)
{
if ($alias === $abstract) {
throw new LogicException("[{$abstract}] is aliased to itself.");
}
$this->aliases[$alias] = $abstract;
$this->abstractAliases[$abstract][] = $alias;
} | [
"public",
"function",
"alias",
"(",
"$",
"abstract",
",",
"$",
"alias",
")",
"{",
"if",
"(",
"$",
"alias",
"===",
"$",
"abstract",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"[{$abstract}] is aliased to itself.\"",
")",
";",
"}",
"$",
"this",
"->",... | Alias a type to a different name.
@param string $abstract
@param string $alias
@return void
@throws \LogicException | [
"Alias",
"a",
"type",
"to",
"a",
"different",
"name",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Container/Container.php#L484-L493 | train | Alias an abstract name with an alias name. | [
30522,
2270,
3853,
14593,
1006,
1002,
10061,
1010,
1002,
14593,
1007,
1063,
2065,
1006,
1002,
14593,
1027,
1027,
1027,
1002,
10061,
1007,
1063,
30524,
2023,
1011,
1028,
10061,
22786,
8583,
1031,
1002,
10061,
1033,
1031,
1033,
1027,
1002,
14... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/OptionsResolver/OptionsResolver.php | OptionsResolver.setAllowedTypes | public function setAllowedTypes($option, $allowedTypes)
{
if ($this->locked) {
throw new AccessException('Allowed types cannot be set from a lazy option or normalizer.');
}
if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
}
$this->allowedTypes[$option] = (array) $allowedTypes;
// Make sure the option is processed
unset($this->resolved[$option]);
return $this;
} | php | public function setAllowedTypes($option, $allowedTypes)
{
if ($this->locked) {
throw new AccessException('Allowed types cannot be set from a lazy option or normalizer.');
}
if (!isset($this->defined[$option])) {
throw new UndefinedOptionsException(sprintf('The option "%s" does not exist. Defined options are: "%s".', $option, implode('", "', array_keys($this->defined))));
}
$this->allowedTypes[$option] = (array) $allowedTypes;
// Make sure the option is processed
unset($this->resolved[$option]);
return $this;
} | [
"public",
"function",
"setAllowedTypes",
"(",
"$",
"option",
",",
"$",
"allowedTypes",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"AccessException",
"(",
"'Allowed types cannot be set from a lazy option or normalizer.'",
")",
";",
... | Sets allowed types for an option.
Any type for which a corresponding is_<type>() function exists is
acceptable. Additionally, fully-qualified class or interface names may
be passed.
@param string $option The option name
@param string|string[] $allowedTypes One or more accepted types
@return $this
@throws UndefinedOptionsException If the option is undefined
@throws AccessException If called from a lazy option or normalizer | [
"Sets",
"allowed",
"types",
"for",
"an",
"option",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/OptionsResolver/OptionsResolver.php#L647-L663 | train | Sets allowed types for an option | [
30522,
2270,
3853,
2275,
8095,
15096,
13874,
2015,
1006,
1002,
5724,
1010,
1002,
3039,
13874,
2015,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5299,
1007,
1063,
5466,
2047,
3229,
10288,
24422,
1006,
1005,
3039,
4127,
3685,
2022,
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... |
matomo-org/matomo | core/Filesystem.php | Filesystem.globr | public static function globr($sDir, $sPattern, $nFlags = null)
{
if (($aFiles = \_glob("$sDir/$sPattern", $nFlags)) == false) {
$aFiles = array();
}
if (($aDirs = \_glob("$sDir/*", GLOB_ONLYDIR)) != false) {
foreach ($aDirs as $sSubDir) {
if (is_link($sSubDir)) {
continue;
}
$aSubFiles = self::globr($sSubDir, $sPattern, $nFlags);
$aFiles = array_merge($aFiles, $aSubFiles);
}
}
sort($aFiles);
return $aFiles;
} | php | public static function globr($sDir, $sPattern, $nFlags = null)
{
if (($aFiles = \_glob("$sDir/$sPattern", $nFlags)) == false) {
$aFiles = array();
}
if (($aDirs = \_glob("$sDir/*", GLOB_ONLYDIR)) != false) {
foreach ($aDirs as $sSubDir) {
if (is_link($sSubDir)) {
continue;
}
$aSubFiles = self::globr($sSubDir, $sPattern, $nFlags);
$aFiles = array_merge($aFiles, $aSubFiles);
}
}
sort($aFiles);
return $aFiles;
} | [
"public",
"static",
"function",
"globr",
"(",
"$",
"sDir",
",",
"$",
"sPattern",
",",
"$",
"nFlags",
"=",
"null",
")",
"{",
"if",
"(",
"(",
"$",
"aFiles",
"=",
"\\",
"_glob",
"(",
"\"$sDir/$sPattern\"",
",",
"$",
"nFlags",
")",
")",
"==",
"false",
... | Recursively find pathnames that match a pattern.
See {@link http://php.net/manual/en/function.glob.php glob} for more info.
@param string $sDir directory The directory to glob in.
@param string $sPattern pattern The pattern to match paths against.
@param int $nFlags `glob()` . See {@link http://php.net/manual/en/function.glob.php glob()}.
@return array The list of paths that match the pattern.
@api | [
"Recursively",
"find",
"pathnames",
"that",
"match",
"a",
"pattern",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Filesystem.php#L179-L196 | train | Globr - Find all files matching a pattern | [
30522,
2270,
10763,
3853,
1043,
4135,
19892,
30524,
1006,
1006,
1002,
28697,
4244,
1027,
1032,
1035,
1043,
4135,
2497,
1006,
1000,
1002,
17371,
4313,
1013,
1002,
14690,
16451,
1000,
1010,
1002,
5088,
26454,
1007,
1007,
1027,
1027,
6270,
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... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.routeAliases | public function routeAliases($var = null)
{
if ($var !== null) {
$this->routes['aliases'] = (array)$var;
}
if (!empty($this->routes) && isset($this->routes['aliases'])) {
return $this->routes['aliases'];
}
return [];
} | php | public function routeAliases($var = null)
{
if ($var !== null) {
$this->routes['aliases'] = (array)$var;
}
if (!empty($this->routes) && isset($this->routes['aliases'])) {
return $this->routes['aliases'];
}
return [];
} | [
"public",
"function",
"routeAliases",
"(",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"var",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"'aliases'",
"]",
"=",
"(",
"array",
")",
"$",
"var",
";",
"}",
"if",
"(",
"!",
"emp... | Gets the route aliases for the page based on page headers.
@param array $var list of route aliases
@return array The route aliases for the Page. | [
"Gets",
"the",
"route",
"aliases",
"for",
"the",
"page",
"based",
"on",
"page",
"headers",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L1961-L1972 | train | Return all aliases | [
30522,
2270,
3853,
2799,
22786,
8583,
1006,
1002,
13075,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
13075,
999,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
5847,
1031,
1005,
14593,
2229,
1005,
1033,
1027,
1006,
9140,
1007,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Piwik.php | Piwik.checkObjectTypeIs | public static function checkObjectTypeIs($o, $types)
{
foreach ($types as $type) {
if ($o instanceof $type) {
return;
}
}
$oType = is_object($o) ? get_class($o) : gettype($o);
throw new Exception("Invalid variable type '$oType', expected one of following: " . implode(', ', $types));
} | php | public static function checkObjectTypeIs($o, $types)
{
foreach ($types as $type) {
if ($o instanceof $type) {
return;
}
}
$oType = is_object($o) ? get_class($o) : gettype($o);
throw new Exception("Invalid variable type '$oType', expected one of following: " . implode(', ', $types));
} | [
"public",
"static",
"function",
"checkObjectTypeIs",
"(",
"$",
"o",
",",
"$",
"types",
")",
"{",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"o",
"instanceof",
"$",
"type",
")",
"{",
"return",
";",
"}",
"}",
"$",
"o... | Utility function that checks if an object type is in a set of types.
@param mixed $o
@param array $types List of class names that $o is expected to be one of.
@throws Exception if $o is not an instance of the types contained in $types. | [
"Utility",
"function",
"that",
"checks",
"if",
"an",
"object",
"type",
"is",
"in",
"a",
"set",
"of",
"types",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Piwik.php#L691-L701 | train | Check if object type is one of the given types | [
30522,
2270,
10763,
3853,
4638,
16429,
20614,
13874,
2483,
1006,
1002,
1051,
1010,
1002,
4127,
1007,
1063,
18921,
6776,
1006,
1002,
4127,
2004,
1002,
2828,
1007,
1063,
2065,
1006,
1002,
1051,
6013,
11253,
1002,
2828,
1007,
1063,
2709,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Constraints/CountryValidator.php | CountryValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Country) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Country');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
if (!class_exists(Regions::class)) {
throw new LogicException('The "symfony/intl" component is required to use the Country constraint.');
}
$value = (string) $value;
if (!Regions::exists($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Country::NO_SUCH_COUNTRY_ERROR)
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Country) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Country');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
if (!class_exists(Regions::class)) {
throw new LogicException('The "symfony/intl" component is required to use the Country constraint.');
}
$value = (string) $value;
if (!Regions::exists($value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Country::NO_SUCH_COUNTRY_ERROR)
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Country",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/CountryValidator.php#L31-L57 | train | Checks if the provided value is a valid Country value | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
2406,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
1035,
3415,
15327,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Process/Pipes/WindowsPipes.php | WindowsPipes.readAndWrite | public function readAndWrite($blocking, $close = false)
{
$this->unblock();
$w = $this->write();
$read = $r = $e = [];
if ($blocking) {
if ($w) {
@stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
} elseif ($this->fileHandles) {
usleep(Process::TIMEOUT_PRECISION * 1E6);
}
}
foreach ($this->fileHandles as $type => $fileHandle) {
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
if (isset($data[0])) {
$this->readBytes[$type] += \strlen($data);
$read[$type] = $data;
}
if ($close) {
ftruncate($fileHandle, 0);
fclose($fileHandle);
flock($this->lockHandles[$type], LOCK_UN);
fclose($this->lockHandles[$type]);
unset($this->fileHandles[$type], $this->lockHandles[$type]);
}
}
return $read;
} | php | public function readAndWrite($blocking, $close = false)
{
$this->unblock();
$w = $this->write();
$read = $r = $e = [];
if ($blocking) {
if ($w) {
@stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
} elseif ($this->fileHandles) {
usleep(Process::TIMEOUT_PRECISION * 1E6);
}
}
foreach ($this->fileHandles as $type => $fileHandle) {
$data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
if (isset($data[0])) {
$this->readBytes[$type] += \strlen($data);
$read[$type] = $data;
}
if ($close) {
ftruncate($fileHandle, 0);
fclose($fileHandle);
flock($this->lockHandles[$type], LOCK_UN);
fclose($this->lockHandles[$type]);
unset($this->fileHandles[$type], $this->lockHandles[$type]);
}
}
return $read;
} | [
"public",
"function",
"readAndWrite",
"(",
"$",
"blocking",
",",
"$",
"close",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"unblock",
"(",
")",
";",
"$",
"w",
"=",
"$",
"this",
"->",
"write",
"(",
")",
";",
"$",
"read",
"=",
"$",
"r",
"=",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Process/Pipes/WindowsPipes.php#L129-L159 | train | Reads and writes the file | [
30522,
2270,
3853,
3191,
5685,
26373,
1006,
1002,
10851,
1010,
1002,
2485,
1027,
6270,
1007,
1063,
1002,
2023,
1011,
1028,
4895,
23467,
1006,
1007,
1025,
1002,
1059,
1027,
1002,
2023,
1011,
1028,
4339,
1006,
1007,
1025,
1002,
3191,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php | ConsoleHandler.write | protected function write(array $record)
{
// at this point we've determined for sure that we want to output the record, so use the output's own verbosity
$this->output->write((string) $record['formatted'], false, $this->output->getVerbosity());
} | php | protected function write(array $record)
{
// at this point we've determined for sure that we want to output the record, so use the output's own verbosity
$this->output->write((string) $record['formatted'], false, $this->output->getVerbosity());
} | [
"protected",
"function",
"write",
"(",
"array",
"$",
"record",
")",
"{",
"// at this point we've determined for sure that we want to output the record, so use the output's own verbosity",
"$",
"this",
"->",
"output",
"->",
"write",
"(",
"(",
"string",
")",
"$",
"record",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php#L146-L150 | train | Write a record to the output | [
30522,
5123,
3853,
4339,
1006,
9140,
1002,
2501,
1007,
1063,
1013,
1013,
2012,
2023,
2391,
2057,
1005,
2310,
4340,
2005,
2469,
2008,
2057,
2215,
2000,
6434,
1996,
2501,
1010,
2061,
2224,
1996,
6434,
1005,
1055,
2219,
12034,
25949,
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 | core/ArchiveProcessor/PluginsArchiver.php | PluginsArchiver.doesAnyPluginArchiveWithoutVisits | public static function doesAnyPluginArchiveWithoutVisits()
{
$archivers = static::getPluginArchivers();
foreach ($archivers as $pluginName => $archiverClass) {
if ($archiverClass::shouldRunEvenWhenNoVisits()) {
return true;
}
}
return false;
} | php | public static function doesAnyPluginArchiveWithoutVisits()
{
$archivers = static::getPluginArchivers();
foreach ($archivers as $pluginName => $archiverClass) {
if ($archiverClass::shouldRunEvenWhenNoVisits()) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"doesAnyPluginArchiveWithoutVisits",
"(",
")",
"{",
"$",
"archivers",
"=",
"static",
"::",
"getPluginArchivers",
"(",
")",
";",
"foreach",
"(",
"$",
"archivers",
"as",
"$",
"pluginName",
"=>",
"$",
"archiverClass",
")",
"{",
"if... | Returns if any plugin archiver archives without visits | [
"Returns",
"if",
"any",
"plugin",
"archiver",
"archives",
"without",
"visits"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor/PluginsArchiver.php#L199-L210 | train | Returns true if any plugin archiver class should run even when no visits | [
30522,
2270,
10763,
3853,
2515,
19092,
24759,
15916,
3981,
11140,
3512,
24415,
5833,
11365,
12762,
1006,
1007,
1063,
1002,
8756,
2869,
1027,
10763,
1024,
1024,
2131,
24759,
15916,
3981,
11140,
16402,
2015,
1006,
1007,
1025,
18921,
6776,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Console/Command.php | Command.context | protected function context()
{
return collect($this->option())->only([
'ansi',
'no-ansi',
'no-interaction',
'quiet',
'verbose',
])->filter()->mapWithKeys(function ($value, $key) {
return ["--{$key}" => $value];
})->all();
} | php | protected function context()
{
return collect($this->option())->only([
'ansi',
'no-ansi',
'no-interaction',
'quiet',
'verbose',
])->filter()->mapWithKeys(function ($value, $key) {
return ["--{$key}" => $value];
})->all();
} | [
"protected",
"function",
"context",
"(",
")",
"{",
"return",
"collect",
"(",
"$",
"this",
"->",
"option",
"(",
")",
")",
"->",
"only",
"(",
"[",
"'ansi'",
",",
"'no-ansi'",
",",
"'no-interaction'",
",",
"'quiet'",
",",
"'verbose'",
",",
"]",
")",
"->",... | Get all of the context passed to the command.
@return array | [
"Get",
"all",
"of",
"the",
"context",
"passed",
"to",
"the",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Command.php#L238-L249 | train | Get context options | [
30522,
5123,
3853,
6123,
1006,
1007,
1063,
2709,
8145,
1006,
1002,
2023,
1011,
1028,
5724,
1006,
1007,
1007,
1011,
1028,
2069,
1006,
1031,
1005,
2019,
5332,
1005,
1010,
1005,
2053,
1011,
2019,
5332,
1005,
1010,
1005,
2053,
1011,
8290,
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... |
octobercms/october | modules/backend/classes/WidgetManager.php | WidgetManager.listFormWidgets | public function listFormWidgets()
{
if ($this->formWidgets === null) {
$this->formWidgets = [];
/*
* Load module widgets
*/
foreach ($this->formWidgetCallbacks as $callback) {
$callback($this);
}
/*
* Load plugin widgets
*/
$plugins = $this->pluginManager->getPlugins();
foreach ($plugins as $plugin) {
if (!is_array($widgets = $plugin->registerFormWidgets())) {
continue;
}
foreach ($widgets as $className => $widgetInfo) {
$this->registerFormWidget($className, $widgetInfo);
}
}
}
return $this->formWidgets;
} | php | public function listFormWidgets()
{
if ($this->formWidgets === null) {
$this->formWidgets = [];
/*
* Load module widgets
*/
foreach ($this->formWidgetCallbacks as $callback) {
$callback($this);
}
/*
* Load plugin widgets
*/
$plugins = $this->pluginManager->getPlugins();
foreach ($plugins as $plugin) {
if (!is_array($widgets = $plugin->registerFormWidgets())) {
continue;
}
foreach ($widgets as $className => $widgetInfo) {
$this->registerFormWidget($className, $widgetInfo);
}
}
}
return $this->formWidgets;
} | [
"public",
"function",
"listFormWidgets",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formWidgets",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"formWidgets",
"=",
"[",
"]",
";",
"/*\n * Load module widgets\n */",
"foreach",
"(",
"$",
... | Returns a list of registered form widgets.
@return array Array keys are class names. | [
"Returns",
"a",
"list",
"of",
"registered",
"form",
"widgets",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/WidgetManager.php#L63-L92 | train | Returns an array of all form widgets | [
30522,
2270,
3853,
2862,
14192,
9148,
28682,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2433,
9148,
28682,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
2433,
9148,
28682,
1027,
1031,
1033,
1025,
1013,
1008,
1008,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Controller.php | Controller.setDate | protected function setDate(Date $date)
{
$this->date = $date;
$this->strDate = $date->toString();
} | php | protected function setDate(Date $date)
{
$this->date = $date;
$this->strDate = $date->toString();
} | [
"protected",
"function",
"setDate",
"(",
"Date",
"$",
"date",
")",
"{",
"$",
"this",
"->",
"date",
"=",
"$",
"date",
";",
"$",
"this",
"->",
"strDate",
"=",
"$",
"date",
"->",
"toString",
"(",
")",
";",
"}"
] | Sets the date to be used by all other methods in the controller.
If the date has to be modified, this method should be called just after
construction.
@param Date $date The new Date.
@return void
@api | [
"Sets",
"the",
"date",
"to",
"be",
"used",
"by",
"all",
"other",
"methods",
"in",
"the",
"controller",
".",
"If",
"the",
"date",
"has",
"to",
"be",
"modified",
"this",
"method",
"should",
"be",
"called",
"just",
"after",
"construction",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Controller.php#L180-L184 | train | Set the date of the page | [
30522,
5123,
3853,
2275,
13701,
1006,
3058,
1002,
3058,
1007,
1063,
1002,
2023,
1011,
1028,
3058,
1027,
1002,
3058,
1025,
1002,
2023,
1011,
1028,
2358,
13639,
2618,
1027,
1002,
3058,
1011,
1028,
2000,
3367,
4892,
1006,
1007,
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... |
matomo-org/matomo | libs/Zend/Mail/Part.php | Zend_Mail_Part.getHeaders | public function getHeaders()
{
if ($this->_headers === null) {
if (!$this->_mail) {
$this->_headers = array();
} else {
$part = $this->_mail->getRawHeader($this->_messageNum);
Zend_Mime_Decode::splitMessage($part, $this->_headers, $null);
}
}
return $this->_headers;
} | php | public function getHeaders()
{
if ($this->_headers === null) {
if (!$this->_mail) {
$this->_headers = array();
} else {
$part = $this->_mail->getRawHeader($this->_messageNum);
Zend_Mime_Decode::splitMessage($part, $this->_headers, $null);
}
}
return $this->_headers;
} | [
"public",
"function",
"getHeaders",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_headers",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_mail",
")",
"{",
"$",
"this",
"->",
"_headers",
"=",
"array",
"(",
")",
";",
"}",
"else",
... | Get all headers
The returned headers are as saved internally. All names are lowercased. The value is a string or an array
if a header with the same name occurs more than once.
@return array headers as array(name => value) | [
"Get",
"all",
"headers"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Part.php#L307-L319 | train | Returns the message headers | [
30522,
2270,
3853,
2131,
4974,
2545,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
20346,
2015,
1027,
1027,
1027,
19701,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
5653,
1007,
1063,
1002,
2023,
1011,
1028,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/ArchiveProcessor.php | ArchiveProcessor.areColumnsNotAlreadyRenamed | public function areColumnsNotAlreadyRenamed($table)
{
$period = $table->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX);
return !$period || $period->getLabel() === 'day';
} | php | public function areColumnsNotAlreadyRenamed($table)
{
$period = $table->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX);
return !$period || $period->getLabel() === 'day';
} | [
"public",
"function",
"areColumnsNotAlreadyRenamed",
"(",
"$",
"table",
")",
"{",
"$",
"period",
"=",
"$",
"table",
"->",
"getMetadata",
"(",
"DataTableFactory",
"::",
"TABLE_METADATA_PERIOD_INDEX",
")",
";",
"return",
"!",
"$",
"period",
"||",
"$",
"period",
... | Note: public only for use in closure in PHP 5.3.
@param $table
@return \Piwik\Period | [
"Note",
":",
"public",
"only",
"for",
"use",
"in",
"closure",
"in",
"PHP",
"5",
".",
"3",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ArchiveProcessor.php#L395-L400 | train | Returns true if columns are not already renamed. | [
30522,
2270,
3853,
2024,
25778,
2819,
3619,
17048,
2389,
16416,
5149,
7389,
14074,
2094,
1006,
1002,
2795,
1007,
1063,
1002,
2558,
1027,
1002,
2795,
1011,
1028,
2131,
11368,
8447,
2696,
1006,
2951,
10880,
21450,
1024,
1024,
2795,
1035,
2742... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Schema/Blueprint.php | Blueprint.addImpliedCommands | protected function addImpliedCommands(Grammar $grammar)
{
if (count($this->getAddedColumns()) > 0 && ! $this->creating()) {
array_unshift($this->commands, $this->createCommand('add'));
}
if (count($this->getChangedColumns()) > 0 && ! $this->creating()) {
array_unshift($this->commands, $this->createCommand('change'));
}
$this->addFluentIndexes();
$this->addFluentCommands($grammar);
} | php | protected function addImpliedCommands(Grammar $grammar)
{
if (count($this->getAddedColumns()) > 0 && ! $this->creating()) {
array_unshift($this->commands, $this->createCommand('add'));
}
if (count($this->getChangedColumns()) > 0 && ! $this->creating()) {
array_unshift($this->commands, $this->createCommand('change'));
}
$this->addFluentIndexes();
$this->addFluentCommands($grammar);
} | [
"protected",
"function",
"addImpliedCommands",
"(",
"Grammar",
"$",
"grammar",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"getAddedColumns",
"(",
")",
")",
">",
"0",
"&&",
"!",
"$",
"this",
"->",
"creating",
"(",
")",
")",
"{",
"array_unshif... | Add the commands that are implied by the blueprint's state.
@param \Illuminate\Database\Schema\Grammars\Grammar $grammar
@return void | [
"Add",
"the",
"commands",
"that",
"are",
"implied",
"by",
"the",
"blueprint",
"s",
"state",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Schema/Blueprint.php#L176-L189 | train | Add all the subcommands that are currently implemented by the current language | [
30522,
5123,
3853,
5587,
5714,
24759,
6340,
9006,
2386,
5104,
1006,
8035,
30524,
1035,
4895,
6182,
6199,
1006,
1002,
2023,
1011,
1028,
10954,
1010,
1002,
2023,
1011,
1028,
3443,
9006,
2386,
2094,
1006,
1005,
5587,
1005,
1007,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Config/Writer/Array.php | Zend_Config_Writer_Array.render | public function render()
{
$data = $this->_config->toArray();
$sectionName = $this->_config->getSectionName();
if (is_string($sectionName)) {
$data = array($sectionName => $data);
}
$arrayString = "<?php\n"
. "return " . var_export($data, true) . ";\n";
return $arrayString;
} | php | public function render()
{
$data = $this->_config->toArray();
$sectionName = $this->_config->getSectionName();
if (is_string($sectionName)) {
$data = array($sectionName => $data);
}
$arrayString = "<?php\n"
. "return " . var_export($data, true) . ";\n";
return $arrayString;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_config",
"->",
"toArray",
"(",
")",
";",
"$",
"sectionName",
"=",
"$",
"this",
"->",
"_config",
"->",
"getSectionName",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
... | Render a Zend_Config into a PHP Array config string.
@since 1.10
@return string | [
"Render",
"a",
"Zend_Config",
"into",
"a",
"PHP",
"Array",
"config",
"string",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer/Array.php#L41-L54 | train | Render the array of data to php code | [
30522,
2270,
3853,
17552,
1006,
1007,
1063,
1002,
2951,
1027,
1002,
2023,
1011,
1028,
1035,
9530,
8873,
2290,
1011,
1028,
2000,
2906,
9447,
1006,
1007,
1025,
1002,
2930,
18442,
1027,
1002,
2023,
1011,
1028,
1035,
9530,
8873,
2290,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Abstract.php | Zend_Db_Adapter_Pdo_Abstract.setFetchMode | public function setFetchMode($mode)
{
//check for PDO extension
if (!extension_loaded('pdo')) {
/**
* @see Zend_Db_Adapter_Exception
*/
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
}
switch ($mode) {
case PDO::FETCH_LAZY:
case PDO::FETCH_ASSOC:
case PDO::FETCH_NUM:
case PDO::FETCH_BOTH:
case PDO::FETCH_NAMED:
case PDO::FETCH_OBJ:
$this->_fetchMode = $mode;
break;
default:
/**
* @see Zend_Db_Adapter_Exception
*/
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("Invalid fetch mode '$mode' specified");
break;
}
} | php | public function setFetchMode($mode)
{
//check for PDO extension
if (!extension_loaded('pdo')) {
/**
* @see Zend_Db_Adapter_Exception
*/
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
}
switch ($mode) {
case PDO::FETCH_LAZY:
case PDO::FETCH_ASSOC:
case PDO::FETCH_NUM:
case PDO::FETCH_BOTH:
case PDO::FETCH_NAMED:
case PDO::FETCH_OBJ:
$this->_fetchMode = $mode;
break;
default:
/**
* @see Zend_Db_Adapter_Exception
*/
// require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception("Invalid fetch mode '$mode' specified");
break;
}
} | [
"public",
"function",
"setFetchMode",
"(",
"$",
"mode",
")",
"{",
"//check for PDO extension",
"if",
"(",
"!",
"extension_loaded",
"(",
"'pdo'",
")",
")",
"{",
"/**\n * @see Zend_Db_Adapter_Exception\n */",
"// require_once 'Zend/Db/Adapter/Exception.php... | Set the PDO fetch mode.
@todo Support FETCH_CLASS and FETCH_INTO.
@param int $mode A PDO fetch mode.
@return void
@throws Zend_Db_Adapter_Exception | [
"Set",
"the",
"PDO",
"fetch",
"mode",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Abstract.php#L334-L361 | train | Set the fetch mode | [
30522,
2270,
3853,
2275,
7959,
10649,
5302,
3207,
1006,
1002,
5549,
1007,
1063,
1013,
1013,
4638,
2005,
22851,
2080,
5331,
2065,
1006,
999,
5331,
1035,
8209,
1006,
1005,
22851,
2080,
1005,
1007,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
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/User/DataUser/UserCollection.php | UserCollection.load | public function load($username): UserInterface
{
$grav = Grav::instance();
/** @var UniformResourceLocator $locator */
$locator = $grav['locator'];
// force lowercase of username
$username = mb_strtolower($username);
$filename = 'account://' . $username . YAML_EXT;
$path = $locator->findResource($filename) ?: $locator->findResource($filename, true, true);
$file = CompiledYamlFile::instance($path);
$content = (array)$file->content() + ['username' => $username, 'state' => 'enabled'];
$userClass = $this->className;
$callable = function() {
$blueprints = new Blueprints;
return $blueprints->get('user/account');
};
/** @var UserInterface $user */
$user = new $userClass($content, $callable);
$user->file($file);
return $user;
} | php | public function load($username): UserInterface
{
$grav = Grav::instance();
/** @var UniformResourceLocator $locator */
$locator = $grav['locator'];
// force lowercase of username
$username = mb_strtolower($username);
$filename = 'account://' . $username . YAML_EXT;
$path = $locator->findResource($filename) ?: $locator->findResource($filename, true, true);
$file = CompiledYamlFile::instance($path);
$content = (array)$file->content() + ['username' => $username, 'state' => 'enabled'];
$userClass = $this->className;
$callable = function() {
$blueprints = new Blueprints;
return $blueprints->get('user/account');
};
/** @var UserInterface $user */
$user = new $userClass($content, $callable);
$user->file($file);
return $user;
} | [
"public",
"function",
"load",
"(",
"$",
"username",
")",
":",
"UserInterface",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"/** @var UniformResourceLocator $locator */",
"$",
"locator",
"=",
"$",
"grav",
"[",
"'locator'",
"]",
";",
"// fo... | Load user account.
Always creates user object. To check if user exists, use $this->exists().
@param string $username
@return UserInterface | [
"Load",
"user",
"account",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/DataUser/UserCollection.php#L42-L68 | train | Load user account | [
30522,
2270,
3853,
7170,
1006,
1002,
5310,
18442,
1007,
1024,
5310,
18447,
2121,
12172,
1063,
1002,
24665,
11431,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1025,
1013,
1008,
1008,
1030,
13075,
6375,
6072,
8162,
29109,
24755,
4263,
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/Validator/Constraints/LengthValidator.php | LengthValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Length) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Length');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$stringValue = (string) $value;
if (null !== $constraint->normalizer) {
$stringValue = ($constraint->normalizer)($stringValue);
}
if (!$invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset)) {
$length = mb_strlen($stringValue, $constraint->charset);
}
if ($invalidCharset) {
$this->context->buildViolation($constraint->charsetMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ charset }}', $constraint->charset)
->setInvalidValue($value)
->setCode(Length::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
if (null !== $constraint->max && $length > $constraint->max) {
$this->context->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->maxMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ limit }}', $constraint->max)
->setInvalidValue($value)
->setPlural((int) $constraint->max)
->setCode(Length::TOO_LONG_ERROR)
->addViolation();
return;
}
if (null !== $constraint->min && $length < $constraint->min) {
$this->context->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->minMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ limit }}', $constraint->min)
->setInvalidValue($value)
->setPlural((int) $constraint->min)
->setCode(Length::TOO_SHORT_ERROR)
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Length) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Length');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$stringValue = (string) $value;
if (null !== $constraint->normalizer) {
$stringValue = ($constraint->normalizer)($stringValue);
}
if (!$invalidCharset = !@mb_check_encoding($stringValue, $constraint->charset)) {
$length = mb_strlen($stringValue, $constraint->charset);
}
if ($invalidCharset) {
$this->context->buildViolation($constraint->charsetMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ charset }}', $constraint->charset)
->setInvalidValue($value)
->setCode(Length::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
if (null !== $constraint->max && $length > $constraint->max) {
$this->context->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->maxMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ limit }}', $constraint->max)
->setInvalidValue($value)
->setPlural((int) $constraint->max)
->setCode(Length::TOO_LONG_ERROR)
->addViolation();
return;
}
if (null !== $constraint->min && $length < $constraint->min) {
$this->context->buildViolation($constraint->min == $constraint->max ? $constraint->exactMessage : $constraint->minMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ limit }}', $constraint->min)
->setInvalidValue($value)
->setPlural((int) $constraint->min)
->setCode(Length::TOO_SHORT_ERROR)
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Length",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/LengthValidator.php#L27-L83 | train | Validate the length constraint | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
3091,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
1035,
3415,
15327,
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 | libs/Zend/Validate/Abstract.php | Zend_Validate_Abstract.setMessages | public function setMessages(array $messages)
{
foreach ($messages as $key => $message) {
$this->setMessage($message, $key);
}
return $this;
} | php | public function setMessages(array $messages)
{
foreach ($messages as $key => $message) {
$this->setMessage($message, $key);
}
return $this;
} | [
"public",
"function",
"setMessages",
"(",
"array",
"$",
"messages",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"key",
"=>",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"setMessage",
"(",
"$",
"message",
",",
"$",
"key",
")",
";",
"}",
"... | Sets validation failure message templates given as an array, where the array keys are the message keys,
and the array values are the message template strings.
@param array $messages
@return Zend_Validate_Abstract | [
"Sets",
"validation",
"failure",
"message",
"templates",
"given",
"as",
"an",
"array",
"where",
"the",
"array",
"keys",
"are",
"the",
"message",
"keys",
"and",
"the",
"array",
"values",
"are",
"the",
"message",
"template",
"strings",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/Abstract.php#L167-L173 | train | setMessages - Set messages to the message array | [
30522,
2270,
3853,
2275,
7834,
3736,
8449,
1006,
9140,
1002,
7696,
1007,
1063,
18921,
6776,
1006,
1002,
7696,
2004,
1002,
3145,
1027,
1028,
1002,
4471,
1007,
1063,
1002,
2023,
1011,
1028,
2275,
7834,
3736,
3351,
1006,
1002,
4471,
1010,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.