repo stringclasses 21 values | path stringlengths 10 105 | func_name stringlengths 6 64 | original_string stringlengths 105 15.6k | language stringclasses 1 value | code stringlengths 105 15.6k | code_tokens listlengths 29 2.15k | docstring stringlengths 11 2.85k | docstring_tokens listlengths 1 290 | sha stringclasses 21 values | url stringlengths 100 194 | partition stringclasses 1 value | summary stringlengths 8 319 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getgrav/grav | system/src/Grav/Common/Twig/TwigExtension.php | TwigExtension.fieldNameFilter | public function fieldNameFilter($str)
{
$path = explode('.', rtrim($str, '.'));
return array_shift($path) . ($path ? '[' . implode('][', $path) . ']' : '');
} | php | public function fieldNameFilter($str)
{
$path = explode('.', rtrim($str, '.'));
return array_shift($path) . ($path ? '[' . implode('][', $path) . ']' : '');
} | [
"public",
"function",
"fieldNameFilter",
"(",
"$",
"str",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'.'",
",",
"rtrim",
"(",
"$",
"str",
",",
"'.'",
")",
")",
";",
"return",
"array_shift",
"(",
"$",
"path",
")",
".",
"(",
"$",
"path",
"?",
"'[... | Filters field name by changing dot notation into array notation.
@param string $str
@return string | [
"Filters",
"field",
"name",
"by",
"changing",
"dot",
"notation",
"into",
"array",
"notation",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/TwigExtension.php#L214-L219 | train | Filter field name to avoid problems with the field name in the parent class | [
30522,
2270,
3853,
2492,
18442,
8873,
21928,
1006,
1002,
2358,
2099,
1007,
1063,
1002,
4130,
1027,
15044,
1006,
1005,
1012,
1005,
1010,
19387,
20026,
1006,
1002,
2358,
2099,
1010,
1005,
1012,
1005,
1007,
1007,
1025,
2709,
9140,
1035,
5670,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php | XmlFileLoader.getArgumentsAsPhp | private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase = true, $isChildDefinition = false)
{
$arguments = [];
foreach ($this->getChildren($node, $name) as $arg) {
if ($arg->hasAttribute('name')) {
$arg->setAttribute('key', $arg->getAttribute('name'));
}
// this is used by ChildDefinition to overwrite a specific
// argument of the parent definition
if ($arg->hasAttribute('index')) {
$key = ($isChildDefinition ? 'index_' : '').$arg->getAttribute('index');
} elseif (!$arg->hasAttribute('key')) {
// Append an empty argument, then fetch its key to overwrite it later
$arguments[] = null;
$keys = array_keys($arguments);
$key = array_pop($keys);
} else {
$key = $arg->getAttribute('key');
}
$onInvalid = $arg->getAttribute('on-invalid');
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
if ('ignore' == $onInvalid) {
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
} elseif ('ignore_uninitialized' == $onInvalid) {
$invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE;
} elseif ('null' == $onInvalid) {
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
}
switch ($arg->getAttribute('type')) {
case 'service':
if ('' === $arg->getAttribute('id')) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file));
}
$arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior);
break;
case 'expression':
if (!class_exists(Expression::class)) {
throw new \LogicException(sprintf('The type="expression" attribute cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'));
}
$arguments[$key] = new Expression($arg->nodeValue);
break;
case 'collection':
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, $file, false);
break;
case 'iterator':
$arg = $this->getArgumentsAsPhp($arg, $name, $file, false);
try {
$arguments[$key] = new IteratorArgument($arg);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="iterator" only accepts collections of type="service" references in "%s".', $name, $file));
}
break;
case 'service_locator':
$arg = $this->getArgumentsAsPhp($arg, $name, $file, false);
try {
$arguments[$key] = new ServiceLocatorArgument($arg);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service_locator" only accepts maps of type="service" references in "%s".', $name, $file));
}
break;
case 'tagged':
case 'tagged_locator':
$type = $arg->getAttribute('type');
$forLocator = 'tagged_locator' === $type;
if (!$arg->getAttribute('tag')) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="%s" has no or empty "tag" attribute in "%s".', $name, $type, $file));
}
$arguments[$key] = new TaggedIteratorArgument($arg->getAttribute('tag'), $arg->getAttribute('index-by') ?: null, $arg->getAttribute('default-index-method') ?: null, $forLocator);
if ($forLocator) {
$arguments[$key] = new ServiceLocatorArgument($arguments[$key]);
}
break;
case 'binary':
if (false === $value = base64_decode($arg->nodeValue)) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="binary" is not a valid base64 encoded string.', $name));
}
$arguments[$key] = $value;
break;
case 'string':
$arguments[$key] = $arg->nodeValue;
break;
case 'constant':
$arguments[$key] = \constant(trim($arg->nodeValue));
break;
default:
$arguments[$key] = XmlUtils::phpize($arg->nodeValue);
}
}
return $arguments;
} | php | private function getArgumentsAsPhp(\DOMElement $node, $name, $file, $lowercase = true, $isChildDefinition = false)
{
$arguments = [];
foreach ($this->getChildren($node, $name) as $arg) {
if ($arg->hasAttribute('name')) {
$arg->setAttribute('key', $arg->getAttribute('name'));
}
// this is used by ChildDefinition to overwrite a specific
// argument of the parent definition
if ($arg->hasAttribute('index')) {
$key = ($isChildDefinition ? 'index_' : '').$arg->getAttribute('index');
} elseif (!$arg->hasAttribute('key')) {
// Append an empty argument, then fetch its key to overwrite it later
$arguments[] = null;
$keys = array_keys($arguments);
$key = array_pop($keys);
} else {
$key = $arg->getAttribute('key');
}
$onInvalid = $arg->getAttribute('on-invalid');
$invalidBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
if ('ignore' == $onInvalid) {
$invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
} elseif ('ignore_uninitialized' == $onInvalid) {
$invalidBehavior = ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE;
} elseif ('null' == $onInvalid) {
$invalidBehavior = ContainerInterface::NULL_ON_INVALID_REFERENCE;
}
switch ($arg->getAttribute('type')) {
case 'service':
if ('' === $arg->getAttribute('id')) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service" has no or empty "id" attribute in "%s".', $name, $file));
}
$arguments[$key] = new Reference($arg->getAttribute('id'), $invalidBehavior);
break;
case 'expression':
if (!class_exists(Expression::class)) {
throw new \LogicException(sprintf('The type="expression" attribute cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'));
}
$arguments[$key] = new Expression($arg->nodeValue);
break;
case 'collection':
$arguments[$key] = $this->getArgumentsAsPhp($arg, $name, $file, false);
break;
case 'iterator':
$arg = $this->getArgumentsAsPhp($arg, $name, $file, false);
try {
$arguments[$key] = new IteratorArgument($arg);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="iterator" only accepts collections of type="service" references in "%s".', $name, $file));
}
break;
case 'service_locator':
$arg = $this->getArgumentsAsPhp($arg, $name, $file, false);
try {
$arguments[$key] = new ServiceLocatorArgument($arg);
} catch (InvalidArgumentException $e) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="service_locator" only accepts maps of type="service" references in "%s".', $name, $file));
}
break;
case 'tagged':
case 'tagged_locator':
$type = $arg->getAttribute('type');
$forLocator = 'tagged_locator' === $type;
if (!$arg->getAttribute('tag')) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="%s" has no or empty "tag" attribute in "%s".', $name, $type, $file));
}
$arguments[$key] = new TaggedIteratorArgument($arg->getAttribute('tag'), $arg->getAttribute('index-by') ?: null, $arg->getAttribute('default-index-method') ?: null, $forLocator);
if ($forLocator) {
$arguments[$key] = new ServiceLocatorArgument($arguments[$key]);
}
break;
case 'binary':
if (false === $value = base64_decode($arg->nodeValue)) {
throw new InvalidArgumentException(sprintf('Tag "<%s>" with type="binary" is not a valid base64 encoded string.', $name));
}
$arguments[$key] = $value;
break;
case 'string':
$arguments[$key] = $arg->nodeValue;
break;
case 'constant':
$arguments[$key] = \constant(trim($arg->nodeValue));
break;
default:
$arguments[$key] = XmlUtils::phpize($arg->nodeValue);
}
}
return $arguments;
} | [
"private",
"function",
"getArgumentsAsPhp",
"(",
"\\",
"DOMElement",
"$",
"node",
",",
"$",
"name",
",",
"$",
"file",
",",
"$",
"lowercase",
"=",
"true",
",",
"$",
"isChildDefinition",
"=",
"false",
")",
"{",
"$",
"arguments",
"=",
"[",
"]",
";",
"fore... | Returns arguments as valid php types.
@param \DOMElement $node
@param string $name
@param string $file
@param bool $lowercase
@return mixed | [
"Returns",
"arguments",
"as",
"valid",
"php",
"types",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php#L482-L580 | train | Returns the arguments as PHP objects | [
30522,
2797,
3853,
2131,
2906,
22850,
11187,
3022,
8458,
2361,
1006,
1032,
8514,
16930,
4765,
1002,
13045,
1010,
1002,
2171,
1010,
1002,
5371,
1010,
1002,
2896,
18382,
1027,
2995,
1010,
1002,
2003,
19339,
3207,
16294,
22753,
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... |
symfony/symfony | src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php | TemplateCacheCacheWarmer.findTemplatesInFolder | private function findTemplatesInFolder($namespace, $dir)
{
if (!is_dir($dir)) {
return [];
}
$templates = [];
$finder = new Finder();
foreach ($finder->files()->followLinks()->in($dir) as $file) {
$name = $file->getRelativePathname();
$templates[] = $namespace ? sprintf('@%s/%s', $namespace, $name) : $name;
}
return $templates;
} | php | private function findTemplatesInFolder($namespace, $dir)
{
if (!is_dir($dir)) {
return [];
}
$templates = [];
$finder = new Finder();
foreach ($finder->files()->followLinks()->in($dir) as $file) {
$name = $file->getRelativePathname();
$templates[] = $namespace ? sprintf('@%s/%s', $namespace, $name) : $name;
}
return $templates;
} | [
"private",
"function",
"findTemplatesInFolder",
"(",
"$",
"namespace",
",",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"templates",
"=",
"[",
"]",
";",
"$",
"finder",
"=",
"n... | Find templates in the given directory.
@param string $namespace The namespace for these templates
@param string $dir The folder where to look for templates
@return array An array of templates | [
"Find",
"templates",
"in",
"the",
"given",
"directory",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php#L107-L122 | train | Find all templates in a given folder | [
30522,
2797,
3853,
2424,
18532,
15725,
11493,
10371,
2121,
1006,
1002,
3415,
15327,
1010,
1002,
16101,
1007,
1063,
2065,
1006,
999,
2003,
1035,
16101,
1006,
1002,
16101,
1007,
1007,
1063,
30524,
1025,
1002,
2424,
2121,
1027,
2047,
2424,
212... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Dumper/QtFileDumper.php | QtFileDumper.formatCatalogue | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
{
$dom = new \DOMDocument('1.0', 'utf-8');
$dom->formatOutput = true;
$ts = $dom->appendChild($dom->createElement('TS'));
$context = $ts->appendChild($dom->createElement('context'));
$context->appendChild($dom->createElement('name', $domain));
foreach ($messages->all($domain) as $source => $target) {
$message = $context->appendChild($dom->createElement('message'));
$metadata = $messages->getMetadata($source, $domain);
if (isset($metadata['sources'])) {
foreach ((array) $metadata['sources'] as $location) {
$loc = explode(':', $location, 2);
$location = $message->appendChild($dom->createElement('location'));
$location->setAttribute('filename', $loc[0]);
if (isset($loc[1])) {
$location->setAttribute('line', $loc[1]);
}
}
}
$message->appendChild($dom->createElement('source', $source));
$message->appendChild($dom->createElement('translation', $target));
}
return $dom->saveXML();
} | php | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
{
$dom = new \DOMDocument('1.0', 'utf-8');
$dom->formatOutput = true;
$ts = $dom->appendChild($dom->createElement('TS'));
$context = $ts->appendChild($dom->createElement('context'));
$context->appendChild($dom->createElement('name', $domain));
foreach ($messages->all($domain) as $source => $target) {
$message = $context->appendChild($dom->createElement('message'));
$metadata = $messages->getMetadata($source, $domain);
if (isset($metadata['sources'])) {
foreach ((array) $metadata['sources'] as $location) {
$loc = explode(':', $location, 2);
$location = $message->appendChild($dom->createElement('location'));
$location->setAttribute('filename', $loc[0]);
if (isset($loc[1])) {
$location->setAttribute('line', $loc[1]);
}
}
}
$message->appendChild($dom->createElement('source', $source));
$message->appendChild($dom->createElement('translation', $target));
}
return $dom->saveXML();
} | [
"public",
"function",
"formatCatalogue",
"(",
"MessageCatalogue",
"$",
"messages",
",",
"$",
"domain",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"dom",
"=",
"new",
"\\",
"DOMDocument",
"(",
"'1.0'",
",",
"'utf-8'",
")",
";",
"$",
"dom... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Dumper/QtFileDumper.php#L26-L52 | train | Formats a MessageCatalogue into XML | [
30522,
2270,
3853,
4289,
11266,
23067,
9077,
1006,
4471,
11266,
23067,
9077,
1002,
7696,
1010,
1002,
5884,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
14383,
1027,
2047,
1032,
14383,
3527,
24894,
4765,
1006,
1005,
1015,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/Storage/FolderStorage.php | FolderStorage.getStoragePath | public function getStoragePath(string $key = null): string
{
if (null === $key) {
$path = $this->dataFolder;
} else {
$path = sprintf($this->dataPattern, $this->dataFolder, $key, substr($key, 0, 2));
}
return $path;
} | php | public function getStoragePath(string $key = null): string
{
if (null === $key) {
$path = $this->dataFolder;
} else {
$path = sprintf($this->dataPattern, $this->dataFolder, $key, substr($key, 0, 2));
}
return $path;
} | [
"public",
"function",
"getStoragePath",
"(",
"string",
"$",
"key",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"dataFolder",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"... | {@inheritdoc}
@see FlexStorageInterface::getStoragePath() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/Storage/FolderStorage.php#L214-L223 | train | Get the path to the data file | [
30522,
2270,
3853,
4152,
4263,
4270,
15069,
1006,
5164,
1002,
3145,
1027,
19701,
1007,
1024,
5164,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
3145,
1007,
1063,
1002,
4130,
1027,
1002,
2023,
1011,
1028,
2951,
10371,
2121,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/Factory.php | Factory.make | public static function make($name, array $config)
{
$namespace = Kernel\Support\Str::studly($name);
$application = "\\EasyWeChat\\{$namespace}\\Application";
return new $application($config);
} | php | public static function make($name, array $config)
{
$namespace = Kernel\Support\Str::studly($name);
$application = "\\EasyWeChat\\{$namespace}\\Application";
return new $application($config);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"$",
"namespace",
"=",
"Kernel",
"\\",
"Support",
"\\",
"Str",
"::",
"studly",
"(",
"$",
"name",
")",
";",
"$",
"application",
"=",
"\"\\\\EasyWeChat\\\\{$na... | @param string $name
@param array $config
@return \EasyWeChat\Kernel\ServiceContainer | [
"@param",
"string",
"$name",
"@param",
"array",
"$config"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Factory.php#L33-L39 | train | Create a new instance of the current class | [
30522,
2270,
10763,
3853,
2191,
1006,
1002,
2171,
1010,
9140,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
3415,
15327,
1027,
16293,
1032,
2490,
1032,
2358,
2099,
1024,
1024,
16054,
2135,
1006,
1002,
2171,
1007,
1025,
1002,
4646,
1027,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/DebugExtension.php | DebugExtension.evalArrDesc | protected function evalArrDesc($variable)
{
$output = [];
foreach ($variable as $key => $value) {
$output[] = '<abbr title="'.e(gettype($value)).'">'.$key.'</abbr>';
}
return implode(', ', $output);
} | php | protected function evalArrDesc($variable)
{
$output = [];
foreach ($variable as $key => $value) {
$output[] = '<abbr title="'.e(gettype($value)).'">'.$key.'</abbr>';
}
return implode(', ', $output);
} | [
"protected",
"function",
"evalArrDesc",
"(",
"$",
"variable",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"variable",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"'<abbr title=\"'",
".",
"e",
... | Evaluate an array type for description
@param array $variable
@return string | [
"Evaluate",
"an",
"array",
"type",
"for",
"description"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/DebugExtension.php#L386-L394 | train | Evaluate array description | [
30522,
5123,
3853,
9345,
8017,
26371,
2278,
1006,
1002,
8023,
1007,
1063,
1002,
6434,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
8023,
2004,
1002,
3145,
1027,
1028,
1002,
3643,
1007,
1063,
1002,
6434,
1031,
1033,
1027,
1005,
1026,
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/Table/Abstract.php | Zend_Db_Table_Abstract._setupMetadata | protected function _setupMetadata()
{
if ($this->metadataCacheInClass() && (count($this->_metadata) > 0)) {
return true;
}
// Assume that metadata will be loaded from cache
$isMetadataFromCache = true;
// If $this has no metadata cache but the class has a default metadata cache
if (null === $this->_metadataCache && null !== self::$_defaultMetadataCache) {
// Make $this use the default metadata cache of the class
$this->_setMetadataCache(self::$_defaultMetadataCache);
}
// If $this has a metadata cache
if (null !== $this->_metadataCache) {
// Define the cache identifier where the metadata are saved
//get db configuration
$dbConfig = $this->_db->getConfig();
$port = isset($dbConfig['options']['port'])
? ':'.$dbConfig['options']['port']
: (isset($dbConfig['port'])
? ':'.$dbConfig['port']
: null);
$host = isset($dbConfig['options']['host'])
? ':'.$dbConfig['options']['host']
: (isset($dbConfig['host'])
? ':'.$dbConfig['host']
: null);
// Define the cache identifier where the metadata are saved
$cacheId = md5( // port:host/dbname:schema.table (based on availabilty)
$port . $host . '/'. $dbConfig['dbname'] . ':'
. $this->_schema. '.' . $this->_name
);
}
// If $this has no metadata cache or metadata cache misses
if (null === $this->_metadataCache || !($metadata = $this->_metadataCache->load($cacheId))) {
// Metadata are not loaded from cache
$isMetadataFromCache = false;
// Fetch metadata from the adapter's describeTable() method
$metadata = $this->_db->describeTable($this->_name, $this->_schema);
// If $this has a metadata cache, then cache the metadata
if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) {
trigger_error('Failed saving metadata to metadataCache', E_USER_NOTICE);
}
}
// Assign the metadata to $this
$this->_metadata = $metadata;
// Return whether the metadata were loaded from cache
return $isMetadataFromCache;
} | php | protected function _setupMetadata()
{
if ($this->metadataCacheInClass() && (count($this->_metadata) > 0)) {
return true;
}
// Assume that metadata will be loaded from cache
$isMetadataFromCache = true;
// If $this has no metadata cache but the class has a default metadata cache
if (null === $this->_metadataCache && null !== self::$_defaultMetadataCache) {
// Make $this use the default metadata cache of the class
$this->_setMetadataCache(self::$_defaultMetadataCache);
}
// If $this has a metadata cache
if (null !== $this->_metadataCache) {
// Define the cache identifier where the metadata are saved
//get db configuration
$dbConfig = $this->_db->getConfig();
$port = isset($dbConfig['options']['port'])
? ':'.$dbConfig['options']['port']
: (isset($dbConfig['port'])
? ':'.$dbConfig['port']
: null);
$host = isset($dbConfig['options']['host'])
? ':'.$dbConfig['options']['host']
: (isset($dbConfig['host'])
? ':'.$dbConfig['host']
: null);
// Define the cache identifier where the metadata are saved
$cacheId = md5( // port:host/dbname:schema.table (based on availabilty)
$port . $host . '/'. $dbConfig['dbname'] . ':'
. $this->_schema. '.' . $this->_name
);
}
// If $this has no metadata cache or metadata cache misses
if (null === $this->_metadataCache || !($metadata = $this->_metadataCache->load($cacheId))) {
// Metadata are not loaded from cache
$isMetadataFromCache = false;
// Fetch metadata from the adapter's describeTable() method
$metadata = $this->_db->describeTable($this->_name, $this->_schema);
// If $this has a metadata cache, then cache the metadata
if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) {
trigger_error('Failed saving metadata to metadataCache', E_USER_NOTICE);
}
}
// Assign the metadata to $this
$this->_metadata = $metadata;
// Return whether the metadata were loaded from cache
return $isMetadataFromCache;
} | [
"protected",
"function",
"_setupMetadata",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"metadataCacheInClass",
"(",
")",
"&&",
"(",
"count",
"(",
"$",
"this",
"->",
"_metadata",
")",
">",
"0",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Assume that... | Initializes metadata.
If metadata cannot be loaded from cache, adapter's describeTable() method is called to discover metadata
information. Returns true if and only if the metadata are loaded from cache.
@return boolean
@throws Zend_Db_Table_Exception | [
"Initializes",
"metadata",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Abstract.php#L789-L847 | train | Setup the metadata of the class | [
30522,
5123,
3853,
1035,
16437,
11368,
8447,
2696,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
27425,
3540,
5403,
2378,
26266,
1006,
1007,
1004,
1004,
1006,
4175,
1006,
1002,
2023,
1011,
1028,
1035,
27425,
1007,
1028,
1014,
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/Concerns/HasAttributes.php | HasAttributes.append | public function append($attributes)
{
$this->appends = array_unique(
array_merge($this->appends, is_string($attributes) ? func_get_args() : $attributes)
);
return $this;
} | php | public function append($attributes)
{
$this->appends = array_unique(
array_merge($this->appends, is_string($attributes) ? func_get_args() : $attributes)
);
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"attributes",
")",
"{",
"$",
"this",
"->",
"appends",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"appends",
",",
"is_string",
"(",
"$",
"attributes",
")",
"?",
"func_get_args",
"(",
")",
":"... | Append attributes to query when building a query.
@param array|string $attributes
@return $this | [
"Append",
"attributes",
"to",
"query",
"when",
"building",
"a",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php#L1182-L1189 | train | Append attributes to the list of attributes to append to the list of attributes to append to the list | [
30522,
2270,
3853,
10439,
10497,
1006,
1002,
12332,
1007,
1063,
1002,
2023,
1011,
1028,
10439,
10497,
2015,
1027,
9140,
1035,
4310,
1006,
9140,
1035,
13590,
1006,
1002,
2023,
1011,
1028,
10439,
10497,
2015,
1010,
2003,
1035,
5164,
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... |
octobercms/october | modules/system/classes/MailManager.php | MailManager.addContentToMailer | public function addContentToMailer($message, $code, $data, $plainOnly = false)
{
if (isset($this->templateCache[$code])) {
$template = $this->templateCache[$code];
}
else {
$this->templateCache[$code] = $template = MailTemplate::findOrMakeTemplate($code);
}
if (!$template) {
return false;
}
$this->addContentToMailerInternal($message, $template, $data, $plainOnly);
return true;
} | php | public function addContentToMailer($message, $code, $data, $plainOnly = false)
{
if (isset($this->templateCache[$code])) {
$template = $this->templateCache[$code];
}
else {
$this->templateCache[$code] = $template = MailTemplate::findOrMakeTemplate($code);
}
if (!$template) {
return false;
}
$this->addContentToMailerInternal($message, $template, $data, $plainOnly);
return true;
} | [
"public",
"function",
"addContentToMailer",
"(",
"$",
"message",
",",
"$",
"code",
",",
"$",
"data",
",",
"$",
"plainOnly",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"templateCache",
"[",
"$",
"code",
"]",
")",
")",
"{",
"... | This function hijacks the `addContent` method of the `October\Rain\Mail\Mailer`
class, using the `mailer.beforeAddContent` event.
@param \Illuminate\Mail\Message $message
@param string $code
@param array $data
@param bool $plainOnly Add only plain text content to the message
@return bool | [
"This",
"function",
"hijacks",
"the",
"addContent",
"method",
"of",
"the",
"October",
"\\",
"Rain",
"\\",
"Mail",
"\\",
"Mailer",
"class",
"using",
"the",
"mailer",
".",
"beforeAddContent",
"event",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MailManager.php#L83-L99 | train | Add Content To Mailer | [
30522,
2270,
3853,
5587,
30524,
23561,
3540,
5403,
1031,
1002,
3642,
1033,
1007,
1007,
1063,
1002,
23561,
1027,
1002,
2023,
1011,
1028,
23561,
3540,
5403,
1031,
1002,
3642,
1033,
1025,
1065,
2842,
1063,
1002,
2023,
1011,
1028,
23561,
3540,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php | NodeDefinition.getNode | public function getNode($forceRootNode = false)
{
if ($forceRootNode) {
$this->parent = null;
}
if (null !== $this->normalization) {
$this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
}
if (null !== $this->validation) {
$this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
}
$node = $this->createNode();
$node->setAttributes($this->attributes);
return $node;
} | php | public function getNode($forceRootNode = false)
{
if ($forceRootNode) {
$this->parent = null;
}
if (null !== $this->normalization) {
$this->normalization->before = ExprBuilder::buildExpressions($this->normalization->before);
}
if (null !== $this->validation) {
$this->validation->rules = ExprBuilder::buildExpressions($this->validation->rules);
}
$node = $this->createNode();
$node->setAttributes($this->attributes);
return $node;
} | [
"public",
"function",
"getNode",
"(",
"$",
"forceRootNode",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"forceRootNode",
")",
"{",
"$",
"this",
"->",
"parent",
"=",
"null",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"normalization",
")",
"{",... | Creates the node.
@param bool $forceRootNode Whether to force this node as the root node
@return NodeInterface | [
"Creates",
"the",
"node",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php#L115-L133 | train | Returns the node | [
30522,
2270,
3853,
2131,
3630,
3207,
1006,
1002,
2486,
3217,
4140,
3630,
3207,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2486,
3217,
4140,
3630,
3207,
1007,
1063,
1002,
2023,
1011,
1028,
6687,
1027,
19701,
1025,
1065,
2065,
1006,
19701,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.getTypes | public static function getTypes()
{
if (!self::$types) {
$grav = Grav::instance();
$scanBlueprintsAndTemplates = function () use ($grav) {
// Scan blueprints
$event = new Event();
$event->types = self::$types;
$grav->fireEvent('onGetPageBlueprints', $event);
self::$types->scanBlueprints('theme://blueprints/');
// Scan templates
$event = new Event();
$event->types = self::$types;
$grav->fireEvent('onGetPageTemplates', $event);
self::$types->scanTemplates('theme://templates/');
};
if ($grav['config']->get('system.cache.enabled')) {
/** @var Cache $cache */
$cache = $grav['cache'];
// Use cached types if possible.
$types_cache_id = md5('types');
self::$types = $cache->fetch($types_cache_id);
if (!self::$types) {
self::$types = new Types();
$scanBlueprintsAndTemplates();
$cache->save($types_cache_id, self::$types);
}
} else {
self::$types = new Types();
$scanBlueprintsAndTemplates();
}
// Register custom paths to the locator.
$locator = $grav['locator'];
foreach (self::$types as $type => $paths) {
foreach ($paths as $k => $path) {
if (strpos($path, 'blueprints://') === 0) {
unset($paths[$k]);
}
}
if ($paths) {
$locator->addPath('blueprints', "pages/$type.yaml", $paths);
}
}
}
return self::$types;
} | php | public static function getTypes()
{
if (!self::$types) {
$grav = Grav::instance();
$scanBlueprintsAndTemplates = function () use ($grav) {
// Scan blueprints
$event = new Event();
$event->types = self::$types;
$grav->fireEvent('onGetPageBlueprints', $event);
self::$types->scanBlueprints('theme://blueprints/');
// Scan templates
$event = new Event();
$event->types = self::$types;
$grav->fireEvent('onGetPageTemplates', $event);
self::$types->scanTemplates('theme://templates/');
};
if ($grav['config']->get('system.cache.enabled')) {
/** @var Cache $cache */
$cache = $grav['cache'];
// Use cached types if possible.
$types_cache_id = md5('types');
self::$types = $cache->fetch($types_cache_id);
if (!self::$types) {
self::$types = new Types();
$scanBlueprintsAndTemplates();
$cache->save($types_cache_id, self::$types);
}
} else {
self::$types = new Types();
$scanBlueprintsAndTemplates();
}
// Register custom paths to the locator.
$locator = $grav['locator'];
foreach (self::$types as $type => $paths) {
foreach ($paths as $k => $path) {
if (strpos($path, 'blueprints://') === 0) {
unset($paths[$k]);
}
}
if ($paths) {
$locator->addPath('blueprints', "pages/$type.yaml", $paths);
}
}
}
return self::$types;
} | [
"public",
"static",
"function",
"getTypes",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"types",
")",
"{",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"$",
"scanBlueprintsAndTemplates",
"=",
"function",
"(",
")",
"use",
"(",
"$",... | Get available page types.
@return Types | [
"Get",
"available",
"page",
"types",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L735-L790 | train | Get types of all pages | [
30522,
2270,
10763,
3853,
2131,
13874,
2015,
1006,
1007,
1063,
2065,
1006,
999,
2969,
1024,
1024,
1002,
4127,
1007,
1063,
1002,
24665,
11431,
1027,
24665,
11431,
1024,
1024,
6013,
1006,
1007,
1025,
1002,
13594,
16558,
5657,
16550,
8791,
119... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FormConfigBuilder.php | FormConfigBuilder.addModelTransformer | public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false)
{
if ($this->locked) {
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
if ($forceAppend) {
$this->modelTransformers[] = $modelTransformer;
} else {
array_unshift($this->modelTransformers, $modelTransformer);
}
return $this;
} | php | public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false)
{
if ($this->locked) {
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
if ($forceAppend) {
$this->modelTransformers[] = $modelTransformer;
} else {
array_unshift($this->modelTransformers, $modelTransformer);
}
return $this;
} | [
"public",
"function",
"addModelTransformer",
"(",
"DataTransformerInterface",
"$",
"modelTransformer",
",",
"$",
"forceAppend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'FormConfigBui... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormConfigBuilder.php#L195-L208 | train | Adds a Data Transformer to the list of model transformers | [
30522,
2270,
3853,
5587,
5302,
9247,
6494,
3619,
14192,
2121,
1006,
2951,
6494,
3619,
14192,
23282,
3334,
12172,
1002,
2944,
6494,
3619,
14192,
2121,
1010,
1002,
2486,
29098,
10497,
1027,
6270,
1007,
1063,
2065,
1006,
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... |
dompdf/dompdf | src/Frame.php | Frame.prepend_child | public function prepend_child(Frame $child, $update_node = true)
{
if ($update_node) {
$this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null);
}
// Remove the child from its parent
if ($child->_parent) {
$child->_parent->remove_child($child, false);
}
$child->_parent = $this;
$child->_prev_sibling = null;
// Handle the first child
if (!$this->_first_child) {
$this->_first_child = $child;
$this->_last_child = $child;
$child->_next_sibling = null;
} else {
$this->_first_child->_prev_sibling = $child;
$child->_next_sibling = $this->_first_child;
$this->_first_child = $child;
}
} | php | public function prepend_child(Frame $child, $update_node = true)
{
if ($update_node) {
$this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null);
}
// Remove the child from its parent
if ($child->_parent) {
$child->_parent->remove_child($child, false);
}
$child->_parent = $this;
$child->_prev_sibling = null;
// Handle the first child
if (!$this->_first_child) {
$this->_first_child = $child;
$this->_last_child = $child;
$child->_next_sibling = null;
} else {
$this->_first_child->_prev_sibling = $child;
$child->_next_sibling = $this->_first_child;
$this->_first_child = $child;
}
} | [
"public",
"function",
"prepend_child",
"(",
"Frame",
"$",
"child",
",",
"$",
"update_node",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"update_node",
")",
"{",
"$",
"this",
"->",
"_node",
"->",
"insertBefore",
"(",
"$",
"child",
"->",
"_node",
",",
"$",
... | Inserts a new child at the beginning of the Frame
@param $child Frame The new Frame to insert
@param $update_node boolean Whether or not to update the DOM | [
"Inserts",
"a",
"new",
"child",
"at",
"the",
"beginning",
"of",
"the",
"Frame"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Frame.php#L921-L945 | train | Prepend a child frame | [
30522,
2270,
3853,
17463,
10497,
1035,
2775,
1006,
4853,
1002,
2775,
1010,
1002,
10651,
1035,
13045,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
10651,
1035,
13045,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
13045,
1011,
1028,
19274,
4783,
292... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/models/ThemeLog.php | ThemeLog.bindEventsToModel | public static function bindEventsToModel(HalcyonModel $template)
{
$template->bindEvent('model.beforeDelete', function () use ($template) {
self::add($template, self::TYPE_DELETE);
});
$template->bindEvent('model.beforeSave', function () use ($template) {
self::add($template, $template->exists ? self::TYPE_UPDATE : self::TYPE_CREATE);
});
} | php | public static function bindEventsToModel(HalcyonModel $template)
{
$template->bindEvent('model.beforeDelete', function () use ($template) {
self::add($template, self::TYPE_DELETE);
});
$template->bindEvent('model.beforeSave', function () use ($template) {
self::add($template, $template->exists ? self::TYPE_UPDATE : self::TYPE_CREATE);
});
} | [
"public",
"static",
"function",
"bindEventsToModel",
"(",
"HalcyonModel",
"$",
"template",
")",
"{",
"$",
"template",
"->",
"bindEvent",
"(",
"'model.beforeDelete'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"template",
")",
"{",
"self",
"::",
"add",
"(",
... | Adds observers to the model for logging purposes. | [
"Adds",
"observers",
"to",
"the",
"model",
"for",
"logging",
"purposes",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/models/ThemeLog.php#L40-L49 | train | Binds events to the model | [
30522,
2270,
10763,
3853,
14187,
18697,
7666,
20389,
10244,
2140,
1006,
11085,
5666,
2239,
5302,
9247,
1002,
23561,
1007,
1063,
1002,
23561,
1011,
1028,
14187,
18697,
3372,
1006,
1005,
2944,
1012,
2077,
9247,
12870,
1005,
1010,
3853,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/User/FlexUser/UserIndex.php | UserIndex.find | public function find($query, $fields = ['username', 'email']): UserInterface
{
foreach ((array)$fields as $field) {
if ($field === 'key') {
$user = $this->get($query);
} elseif ($field === 'storage_key') {
$user = $this->withKeyField('storage_key')->get($query);
} elseif ($field === 'flex_key') {
$user = $this->withKeyField('flex_key')->get($query);
} elseif ($field === 'email') {
$user = $this->withKeyField('email')->get($query);
} elseif ($field === 'username') {
$user = $this->get(mb_strtolower($query));
} else {
$user = $this->__call('find', [$query, $field]);
}
if ($user) {
return $user;
}
}
return $this->load('');
} | php | public function find($query, $fields = ['username', 'email']): UserInterface
{
foreach ((array)$fields as $field) {
if ($field === 'key') {
$user = $this->get($query);
} elseif ($field === 'storage_key') {
$user = $this->withKeyField('storage_key')->get($query);
} elseif ($field === 'flex_key') {
$user = $this->withKeyField('flex_key')->get($query);
} elseif ($field === 'email') {
$user = $this->withKeyField('email')->get($query);
} elseif ($field === 'username') {
$user = $this->get(mb_strtolower($query));
} else {
$user = $this->__call('find', [$query, $field]);
}
if ($user) {
return $user;
}
}
return $this->load('');
} | [
"public",
"function",
"find",
"(",
"$",
"query",
",",
"$",
"fields",
"=",
"[",
"'username'",
",",
"'email'",
"]",
")",
":",
"UserInterface",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field... | Find a user by username, email, etc
@param string $query the query to search for
@param array $fields the fields to search
@return User | [
"Find",
"a",
"user",
"by",
"username",
"email",
"etc"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/FlexUser/UserIndex.php#L79-L101 | train | Finds a user by username or email | [
30522,
2270,
3853,
2424,
1006,
1002,
23032,
1010,
1002,
4249,
1027,
1031,
1005,
5310,
18442,
1005,
1010,
1005,
10373,
1005,
1033,
1007,
1024,
5310,
18447,
2121,
12172,
1063,
18921,
6776,
1006,
1006,
9140,
1007,
1002,
4249,
2004,
1002,
2492,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/BelongsToMany.php | BelongsToMany.withPivotValue | public function withPivotValue($column, $value = null)
{
if (is_array($column)) {
foreach ($column as $name => $value) {
$this->withPivotValue($name, $value);
}
return $this;
}
if (is_null($value)) {
throw new InvalidArgumentException('The provided value may not be null.');
}
$this->pivotValues[] = compact('column', 'value');
return $this->wherePivot($column, '=', $value);
} | php | public function withPivotValue($column, $value = null)
{
if (is_array($column)) {
foreach ($column as $name => $value) {
$this->withPivotValue($name, $value);
}
return $this;
}
if (is_null($value)) {
throw new InvalidArgumentException('The provided value may not be null.');
}
$this->pivotValues[] = compact('column', 'value');
return $this->wherePivot($column, '=', $value);
} | [
"public",
"function",
"withPivotValue",
"(",
"$",
"column",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"column",
")",
")",
"{",
"foreach",
"(",
"$",
"column",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"... | Set a where clause for a pivot table column.
In addition, new pivot records will receive this value.
@param string|array $column
@param mixed $value
@return $this | [
"Set",
"a",
"where",
"clause",
"for",
"a",
"pivot",
"table",
"column",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L397-L414 | train | Set the value of a pivot column | [
30522,
2270,
3853,
2007,
8197,
22994,
10175,
5657,
1006,
1002,
5930,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
5930,
1007,
1007,
1063,
18921,
6776,
1006,
1002,
5930,
2004,
1002,
2171,
1027,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Model.php | Model.incrementOrDecrementAttributeValue | protected function incrementOrDecrementAttributeValue($column, $amount, $extra, $method)
{
$this->{$column} = $this->{$column} + ($method === 'increment' ? $amount : $amount * -1);
$this->forceFill($extra);
$this->syncOriginalAttribute($column);
} | php | protected function incrementOrDecrementAttributeValue($column, $amount, $extra, $method)
{
$this->{$column} = $this->{$column} + ($method === 'increment' ? $amount : $amount * -1);
$this->forceFill($extra);
$this->syncOriginalAttribute($column);
} | [
"protected",
"function",
"incrementOrDecrementAttributeValue",
"(",
"$",
"column",
",",
"$",
"amount",
",",
"$",
"extra",
",",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"column",
"}",
"=",
"$",
"this",
"->",
"{",
"$",
"column",
"}",
"+",
... | Increment the underlying attribute value and sync with original.
@param string $column
@param float|int $amount
@param array $extra
@param string $method
@return void | [
"Increment",
"the",
"underlying",
"attribute",
"value",
"and",
"sync",
"with",
"original",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Model.php#L581-L588 | train | Increment or Decrement attribute value | [
30522,
5123,
3853,
4297,
28578,
4765,
8551,
8586,
28578,
4765,
19321,
3089,
8569,
2618,
10175,
5657,
1006,
1002,
5930,
1010,
1002,
3815,
1010,
1002,
4469,
1010,
1002,
4118,
1007,
1063,
1002,
2023,
1011,
1028,
1063,
1002,
5930,
30524,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/Common2.php | HTML_Common2.addClass | public function addClass($class)
{
if (!is_array($class)) {
$class = preg_split('/\s+/', $class, null, PREG_SPLIT_NO_EMPTY);
}
$curClass = preg_split('/\s+/', $this->getAttribute('class'),
null, PREG_SPLIT_NO_EMPTY);
foreach ($class as $c) {
if (!in_array($c, $curClass)) {
$curClass[] = $c;
}
}
$this->setAttribute('class', implode(' ', $curClass));
return $this;
} | php | public function addClass($class)
{
if (!is_array($class)) {
$class = preg_split('/\s+/', $class, null, PREG_SPLIT_NO_EMPTY);
}
$curClass = preg_split('/\s+/', $this->getAttribute('class'),
null, PREG_SPLIT_NO_EMPTY);
foreach ($class as $c) {
if (!in_array($c, $curClass)) {
$curClass[] = $c;
}
}
$this->setAttribute('class', implode(' ', $curClass));
return $this;
} | [
"public",
"function",
"addClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"preg_split",
"(",
"'/\\s+/'",
",",
"$",
"class",
",",
"null",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"}",
... | Adds the given CSS class(es) to the element
@param string|array Class name, multiple class names separated by
whitespace, array of class names
@return HTML_Common2 | [
"Adds",
"the",
"given",
"CSS",
"class",
"(",
"es",
")",
"to",
"the",
"element"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/Common2.php#L419-L434 | train | Add a class to the element | [
30522,
2270,
3853,
5587,
26266,
1006,
1002,
2465,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
2465,
1007,
1007,
1063,
1002,
2465,
1027,
3653,
2290,
1035,
3975,
1006,
1005,
1013,
1032,
1055,
1009,
1013,
1005,
1010,
1002,
246... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php | LoadConfiguration.bootstrap | public function bootstrap(Application $app)
{
$items = [];
// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
if (file_exists($cached = $app->getCachedConfigPath())) {
$items = require $cached;
$loadedFromCache = true;
}
// Next we will spin through all of the configuration files in the configuration
// directory and load each one into the repository. This will make all of the
// options available to the developer for use in various parts of this app.
$app->instance('config', $config = new Repository($items));
if (! isset($loadedFromCache)) {
$this->loadConfigurationFiles($app, $config);
}
// Finally, we will set the application's environment based on the configuration
// values that were loaded. We will pass a callback which will be used to get
// the environment in a web context where an "--env" switch is not present.
$app->detectEnvironment(function () use ($config) {
return $config->get('app.env', 'production');
});
date_default_timezone_set($config->get('app.timezone', 'UTC'));
mb_internal_encoding('UTF-8');
} | php | public function bootstrap(Application $app)
{
$items = [];
// First we will see if we have a cache configuration file. If we do, we'll load
// the configuration items from that file so that it is very quick. Otherwise
// we will need to spin through every configuration file and load them all.
if (file_exists($cached = $app->getCachedConfigPath())) {
$items = require $cached;
$loadedFromCache = true;
}
// Next we will spin through all of the configuration files in the configuration
// directory and load each one into the repository. This will make all of the
// options available to the developer for use in various parts of this app.
$app->instance('config', $config = new Repository($items));
if (! isset($loadedFromCache)) {
$this->loadConfigurationFiles($app, $config);
}
// Finally, we will set the application's environment based on the configuration
// values that were loaded. We will pass a callback which will be used to get
// the environment in a web context where an "--env" switch is not present.
$app->detectEnvironment(function () use ($config) {
return $config->get('app.env', 'production');
});
date_default_timezone_set($config->get('app.timezone', 'UTC'));
mb_internal_encoding('UTF-8');
} | [
"public",
"function",
"bootstrap",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"// First we will see if we have a cache configuration file. If we do, we'll load",
"// the configuration items from that file so that it is very quick. Otherwise",
"// we... | Bootstrap the given application.
@param \Illuminate\Contracts\Foundation\Application $app
@return void | [
"Bootstrap",
"the",
"given",
"application",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php#L20-L52 | train | Bootstraps the application. | [
30522,
2270,
3853,
6879,
6494,
2361,
1006,
4646,
1002,
10439,
1007,
1063,
1002,
5167,
1027,
1031,
1033,
1025,
1013,
1013,
2034,
2057,
2097,
2156,
2065,
2057,
2031,
1037,
17053,
9563,
5371,
1012,
2065,
2057,
2079,
1010,
2057,
1005,
2222,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Translation/MessageSelector.php | MessageSelector.choose | public function choose($line, $number, $locale)
{
$segments = explode('|', $line);
if (($value = $this->extract($segments, $number)) !== null) {
return trim($value);
}
$segments = $this->stripConditions($segments);
$pluralIndex = $this->getPluralIndex($locale, $number);
if (count($segments) === 1 || ! isset($segments[$pluralIndex])) {
return $segments[0];
}
return $segments[$pluralIndex];
} | php | public function choose($line, $number, $locale)
{
$segments = explode('|', $line);
if (($value = $this->extract($segments, $number)) !== null) {
return trim($value);
}
$segments = $this->stripConditions($segments);
$pluralIndex = $this->getPluralIndex($locale, $number);
if (count($segments) === 1 || ! isset($segments[$pluralIndex])) {
return $segments[0];
}
return $segments[$pluralIndex];
} | [
"public",
"function",
"choose",
"(",
"$",
"line",
",",
"$",
"number",
",",
"$",
"locale",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"'|'",
",",
"$",
"line",
")",
";",
"if",
"(",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"extract",
"(",
"... | Select a proper translation string based on the given number.
@param string $line
@param int $number
@param string $locale
@return mixed | [
"Select",
"a",
"proper",
"translation",
"string",
"based",
"on",
"the",
"given",
"number",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Translation/MessageSelector.php#L17-L34 | train | Returns the value of the language | [
30522,
2270,
3853,
5454,
1006,
1002,
2240,
1010,
1002,
2193,
1010,
1002,
2334,
2063,
1007,
1063,
1002,
9214,
1027,
15044,
1006,
1005,
1064,
1005,
1010,
1002,
2240,
1007,
1025,
2065,
1006,
1006,
1002,
3643,
1027,
1002,
2023,
1011,
1028,
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... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.whereJsonContains | public function whereJsonContains($column, $value, $boolean = 'and', $not = false)
{
$type = 'JsonContains';
$this->wheres[] = compact('type', 'column', 'value', 'boolean', 'not');
if (! $value instanceof Expression) {
$this->addBinding($this->grammar->prepareBindingForJsonContains($value));
}
return $this;
} | php | public function whereJsonContains($column, $value, $boolean = 'and', $not = false)
{
$type = 'JsonContains';
$this->wheres[] = compact('type', 'column', 'value', 'boolean', 'not');
if (! $value instanceof Expression) {
$this->addBinding($this->grammar->prepareBindingForJsonContains($value));
}
return $this;
} | [
"public",
"function",
"whereJsonContains",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"boolean",
"=",
"'and'",
",",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"type",
"=",
"'JsonContains'",
";",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
"compac... | Add a "where JSON contains" clause to the query.
@param string $column
@param mixed $value
@param string $boolean
@param bool $not
@return $this | [
"Add",
"a",
"where",
"JSON",
"contains",
"clause",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L1515-L1526 | train | Add a where JSON contains clause to the query. | [
30522,
2270,
3853,
2073,
22578,
2239,
8663,
18249,
2015,
1006,
1002,
5930,
1010,
1002,
3643,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1010,
1002,
2025,
1027,
6270,
1007,
1063,
1002,
2828,
1027,
1005,
1046,
3385,
8663,
18249,
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... |
dompdf/dompdf | src/Adapter/GD.php | GD._allocate_color | private function _allocate_color($color)
{
$a = isset($color["alpha"]) ? $color["alpha"] : 1;
if (isset($color["c"])) {
$color = Helpers::cmyk_to_rgb($color);
}
list($r, $g, $b) = $color;
$r *= 255;
$g *= 255;
$b *= 255;
$a = 127 - ($a * 127);
// Clip values
$r = $r > 255 ? 255 : $r;
$g = $g > 255 ? 255 : $g;
$b = $b > 255 ? 255 : $b;
$a = $a > 127 ? 127 : $a;
$r = $r < 0 ? 0 : $r;
$g = $g < 0 ? 0 : $g;
$b = $b < 0 ? 0 : $b;
$a = $a < 0 ? 0 : $a;
$key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a);
if (isset($this->_colors[$key])) {
return $this->_colors[$key];
}
if ($a != 0) {
$this->_colors[$key] = imagecolorallocatealpha($this->get_image(), $r, $g, $b, $a);
} else {
$this->_colors[$key] = imagecolorallocate($this->get_image(), $r, $g, $b);
}
return $this->_colors[$key];
} | php | private function _allocate_color($color)
{
$a = isset($color["alpha"]) ? $color["alpha"] : 1;
if (isset($color["c"])) {
$color = Helpers::cmyk_to_rgb($color);
}
list($r, $g, $b) = $color;
$r *= 255;
$g *= 255;
$b *= 255;
$a = 127 - ($a * 127);
// Clip values
$r = $r > 255 ? 255 : $r;
$g = $g > 255 ? 255 : $g;
$b = $b > 255 ? 255 : $b;
$a = $a > 127 ? 127 : $a;
$r = $r < 0 ? 0 : $r;
$g = $g < 0 ? 0 : $g;
$b = $b < 0 ? 0 : $b;
$a = $a < 0 ? 0 : $a;
$key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a);
if (isset($this->_colors[$key])) {
return $this->_colors[$key];
}
if ($a != 0) {
$this->_colors[$key] = imagecolorallocatealpha($this->get_image(), $r, $g, $b, $a);
} else {
$this->_colors[$key] = imagecolorallocate($this->get_image(), $r, $g, $b);
}
return $this->_colors[$key];
} | [
"private",
"function",
"_allocate_color",
"(",
"$",
"color",
")",
"{",
"$",
"a",
"=",
"isset",
"(",
"$",
"color",
"[",
"\"alpha\"",
"]",
")",
"?",
"$",
"color",
"[",
"\"alpha\"",
"]",
":",
"1",
";",
"if",
"(",
"isset",
"(",
"$",
"color",
"[",
"\"... | Allocate a new color. Allocate with GD as needed and store
previously allocated colors in $this->_colors.
@param array $color The new current color
@return int The allocated color | [
"Allocate",
"a",
"new",
"color",
".",
"Allocate",
"with",
"GD",
"as",
"needed",
"and",
"store",
"previously",
"allocated",
"colors",
"in",
"$this",
"-",
">",
"_colors",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Adapter/GD.php#L281-L320 | train | Allocate color from color array | [
30522,
2797,
3853,
1035,
2035,
24755,
2618,
1035,
3609,
1006,
1002,
3609,
1007,
1063,
1002,
1037,
1027,
26354,
3388,
1006,
1002,
3609,
1031,
1000,
6541,
1000,
1033,
1007,
1029,
1002,
3609,
1031,
1000,
6541,
1000,
1033,
1024,
1015,
1025,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/helpers/DateTime.php | DateTime.makeCarbon | public static function makeCarbon($value, $throwException = true)
{
if ($value instanceof Carbon) {
// Do nothing
}
elseif ($value instanceof PhpDateTime) {
$value = Carbon::instance($value);
}
elseif (is_numeric($value)) {
$value = Carbon::createFromTimestamp($value);
}
elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value)) {
$value = Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
}
else {
try {
$value = Carbon::parse($value);
} catch (Exception $ex) {}
}
if (!$value instanceof Carbon && $throwException) {
throw new InvalidArgumentException('Invalid date value supplied to DateTime helper.');
}
return $value;
} | php | public static function makeCarbon($value, $throwException = true)
{
if ($value instanceof Carbon) {
// Do nothing
}
elseif ($value instanceof PhpDateTime) {
$value = Carbon::instance($value);
}
elseif (is_numeric($value)) {
$value = Carbon::createFromTimestamp($value);
}
elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value)) {
$value = Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
}
else {
try {
$value = Carbon::parse($value);
} catch (Exception $ex) {}
}
if (!$value instanceof Carbon && $throwException) {
throw new InvalidArgumentException('Invalid date value supplied to DateTime helper.');
}
return $value;
} | [
"public",
"static",
"function",
"makeCarbon",
"(",
"$",
"value",
",",
"$",
"throwException",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Carbon",
")",
"{",
"// Do nothing",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"PhpDateTime",
"... | Converts mixed inputs to a Carbon object.
@return Carbon\Carbon | [
"Converts",
"mixed",
"inputs",
"to",
"a",
"Carbon",
"object",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/helpers/DateTime.php#L54-L79 | train | Converts a value to a Carbon instance | [
30522,
2270,
10763,
3853,
2191,
26190,
1006,
1002,
3643,
1010,
1002,
5466,
10288,
24422,
1027,
2995,
1007,
1063,
2065,
1006,
1002,
3643,
6013,
11253,
6351,
1007,
1063,
1013,
1013,
2079,
2498,
1065,
2842,
10128,
1006,
1002,
3643,
6013,
11253... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/TypeValidator.php | TypeValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Type) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Type');
}
if (null === $value) {
return;
}
$type = strtolower($constraint->type);
$type = 'boolean' == $type ? 'bool' : $constraint->type;
$isFunction = 'is_'.$type;
$ctypeFunction = 'ctype_'.$type;
if (\function_exists($isFunction) && $isFunction($value)) {
return;
} elseif (\function_exists($ctypeFunction) && $ctypeFunction($value)) {
return;
} elseif ($value instanceof $constraint->type) {
return;
}
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setParameter('{{ type }}', $constraint->type)
->setCode(Type::INVALID_TYPE_ERROR)
->addViolation();
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Type) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Type');
}
if (null === $value) {
return;
}
$type = strtolower($constraint->type);
$type = 'boolean' == $type ? 'bool' : $constraint->type;
$isFunction = 'is_'.$type;
$ctypeFunction = 'ctype_'.$type;
if (\function_exists($isFunction) && $isFunction($value)) {
return;
} elseif (\function_exists($ctypeFunction) && $ctypeFunction($value)) {
return;
} elseif ($value instanceof $constraint->type) {
return;
}
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setParameter('{{ type }}', $constraint->type)
->setCode(Type::INVALID_TYPE_ERROR)
->addViolation();
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Type",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/TypeValidator.php#L26-L54 | train | Checks if the value is of the type type | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
2828,
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... |
z-song/laravel-admin | src/Auth/Database/HasPermissions.php | HasPermissions.boot | protected static function boot()
{
parent::boot();
static::deleting(function ($model) {
$model->roles()->detach();
$model->permissions()->detach();
});
} | php | protected static function boot()
{
parent::boot();
static::deleting(function ($model) {
$model->roles()->detach();
$model->permissions()->detach();
});
} | [
"protected",
"static",
"function",
"boot",
"(",
")",
"{",
"parent",
"::",
"boot",
"(",
")",
";",
"static",
"::",
"deleting",
"(",
"function",
"(",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"roles",
"(",
")",
"->",
"detach",
"(",
")",
";",
"$",
... | Detach models from the relationship.
@return void | [
"Detach",
"models",
"from",
"the",
"relationship",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Auth/Database/HasPermissions.php#L109-L118 | train | Boots the model. | [
30522,
5123,
10763,
3853,
9573,
1006,
1007,
1063,
6687,
1024,
1024,
9573,
1006,
1007,
1025,
10763,
1024,
1024,
3972,
20624,
3070,
1006,
3853,
1006,
1002,
2944,
1007,
1063,
1002,
2944,
1011,
1028,
4395,
1006,
1007,
1011,
1028,
20010,
6776,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php | PlaintextPasswordEncoder.isPasswordValid | public function isPasswordValid($encoded, $raw, $salt)
{
if ($this->isPasswordTooLong($raw)) {
return false;
}
$pass2 = $this->mergePasswordAndSalt($raw, $salt);
if (!$this->ignorePasswordCase) {
return $this->comparePasswords($encoded, $pass2);
}
return $this->comparePasswords(strtolower($encoded), strtolower($pass2));
} | php | public function isPasswordValid($encoded, $raw, $salt)
{
if ($this->isPasswordTooLong($raw)) {
return false;
}
$pass2 = $this->mergePasswordAndSalt($raw, $salt);
if (!$this->ignorePasswordCase) {
return $this->comparePasswords($encoded, $pass2);
}
return $this->comparePasswords(strtolower($encoded), strtolower($pass2));
} | [
"public",
"function",
"isPasswordValid",
"(",
"$",
"encoded",
",",
"$",
"raw",
",",
"$",
"salt",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPasswordTooLong",
"(",
"$",
"raw",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pass2",
"=",
"$",
"this... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php#L48-L61 | train | Check if a password is valid | [
30522,
2270,
3853,
2003,
15194,
18351,
10175,
3593,
1006,
1002,
12359,
1010,
1002,
6315,
1010,
1002,
5474,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
15194,
18351,
3406,
12898,
3070,
1006,
1002,
6315,
1007,
1007,
1063,
2709,
6270... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.createAnonymousUser | public function createAnonymousUser()
{
$now = Date::factory('now')->getDatetime();
// The anonymous user is the user that is assigned by default
// note that the token_auth value is anonymous, which is assigned by default as well in the Login plugin
$db = $this->getDb();
$db->query("INSERT IGNORE INTO " . Common::prefixTable("user") . "
VALUES ( 'anonymous', '', 'anonymous', 'anonymous@example.org', '', 'anonymous', 0, '$now', '$now' );");
} | php | public function createAnonymousUser()
{
$now = Date::factory('now')->getDatetime();
// The anonymous user is the user that is assigned by default
// note that the token_auth value is anonymous, which is assigned by default as well in the Login plugin
$db = $this->getDb();
$db->query("INSERT IGNORE INTO " . Common::prefixTable("user") . "
VALUES ( 'anonymous', '', 'anonymous', 'anonymous@example.org', '', 'anonymous', 0, '$now', '$now' );");
} | [
"public",
"function",
"createAnonymousUser",
"(",
")",
"{",
"$",
"now",
"=",
"Date",
"::",
"factory",
"(",
"'now'",
")",
"->",
"getDatetime",
"(",
")",
";",
"// The anonymous user is the user that is assigned by default",
"// note that the token_auth value is anonymous, whi... | Creates an entry in the User table for the "anonymous" user. | [
"Creates",
"an",
"entry",
"in",
"the",
"User",
"table",
"for",
"the",
"anonymous",
"user",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Db/Schema/Mysql.php#L496-L505 | train | create anonymous user | [
30522,
2270,
3853,
3443,
6761,
4890,
27711,
20330,
1006,
1007,
1063,
1002,
2085,
1027,
3058,
1024,
1024,
4713,
1006,
1005,
2085,
1005,
1007,
1011,
1028,
2131,
13701,
7292,
1006,
1007,
1025,
1013,
1013,
1996,
10812,
5310,
2003,
1996,
5310,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable/Row.php | Row.getSubtable | public function getSubtable()
{
if ($this->isSubtableLoaded) {
try {
return Manager::getInstance()->getTable($this->subtableId);
} catch (TableNotFoundException $e) {
// edge case
}
}
return false;
} | php | public function getSubtable()
{
if ($this->isSubtableLoaded) {
try {
return Manager::getInstance()->getTable($this->subtableId);
} catch (TableNotFoundException $e) {
// edge case
}
}
return false;
} | [
"public",
"function",
"getSubtable",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSubtableLoaded",
")",
"{",
"try",
"{",
"return",
"Manager",
"::",
"getInstance",
"(",
")",
"->",
"getTable",
"(",
"$",
"this",
"->",
"subtableId",
")",
";",
"}",
"catc... | Returns the associated subtable, if one exists. Returns `false` if none exists.
@return DataTable|bool | [
"Returns",
"the",
"associated",
"subtable",
"if",
"one",
"exists",
".",
"Returns",
"false",
"if",
"none",
"exists",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L252-L262 | train | Get Subtable - Returns the subtable if it exists | [
30522,
2270,
3853,
4152,
12083,
10880,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
26354,
12083,
10880,
17468,
1007,
1063,
3046,
1063,
2709,
3208,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2131,
10880,
1006,
1002,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/MemcachedStore.php | MemcachedStore.add | public function add($key, $value, $seconds)
{
return $this->memcached->add(
$this->prefix.$key, $value, $this->calculateExpiration($seconds)
);
} | php | public function add($key, $value, $seconds)
{
return $this->memcached->add(
$this->prefix.$key, $value, $this->calculateExpiration($seconds)
);
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"seconds",
")",
"{",
"return",
"$",
"this",
"->",
"memcached",
"->",
"add",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"key",
",",
"$",
"value",
",",
"$",
"this",
"->",
... | Store an item in the cache if the key doesn't exist.
@param string $key
@param mixed $value
@param int $seconds
@return bool | [
"Store",
"an",
"item",
"in",
"the",
"cache",
"if",
"the",
"key",
"doesn",
"t",
"exist",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/MemcachedStore.php#L138-L143 | train | Add an entry to the cache. | [
30522,
2270,
3853,
5587,
1006,
1002,
3145,
1010,
1002,
3643,
1010,
1002,
3823,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2033,
12458,
15395,
2094,
1011,
1028,
5587,
1006,
1002,
2023,
1011,
1028,
17576,
1012,
1002,
3145,
1010,
1002,
3643,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php | CompiledUrlGeneratorDumper.generateDeclaredRoutes | private function generateDeclaredRoutes(): string
{
$routes = '';
foreach ($this->getCompiledRoutes() as $name => $properties) {
$routes .= sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
}
return $routes;
} | php | private function generateDeclaredRoutes(): string
{
$routes = '';
foreach ($this->getCompiledRoutes() as $name => $properties) {
$routes .= sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
}
return $routes;
} | [
"private",
"function",
"generateDeclaredRoutes",
"(",
")",
":",
"string",
"{",
"$",
"routes",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCompiledRoutes",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"properties",
")",
"{",
"$",
"routes",
".=",
"... | Generates PHP code representing an array of defined routes
together with the routes properties (e.g. requirements). | [
"Generates",
"PHP",
"code",
"representing",
"an",
"array",
"of",
"defined",
"routes",
"together",
"with",
"the",
"routes",
"properties",
"(",
"e",
".",
"g",
".",
"requirements",
")",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Generator/Dumper/CompiledUrlGeneratorDumper.php#L64-L72 | train | Generate declared routes | [
30522,
2797,
3853,
7013,
8586,
8017,
2098,
22494,
4570,
1006,
1007,
1024,
5164,
1063,
1002,
5847,
1027,
1005,
1005,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
9006,
22090,
22196,
10421,
2015,
1006,
1007,
2004,
1002,
2171,
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/Support/Collection.php | Collection.diffAssocUsing | public function diffAssocUsing($items, callable $callback)
{
return new static(array_diff_uassoc($this->items, $this->getArrayableItems($items), $callback));
} | php | public function diffAssocUsing($items, callable $callback)
{
return new static(array_diff_uassoc($this->items, $this->getArrayableItems($items), $callback));
} | [
"public",
"function",
"diffAssocUsing",
"(",
"$",
"items",
",",
"callable",
"$",
"callback",
")",
"{",
"return",
"new",
"static",
"(",
"array_diff_uassoc",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"this",
"->",
"getArrayableItems",
"(",
"$",
"items",
")"... | Get the items in the collection whose keys and values are not present in the given items.
@param mixed $items
@param callable $callback
@return static | [
"Get",
"the",
"items",
"in",
"the",
"collection",
"whose",
"keys",
"and",
"values",
"are",
"not",
"present",
"in",
"the",
"given",
"items",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Collection.php#L380-L383 | train | Get the items in the array that are not present in the array using the items passed as argument. | [
30522,
2270,
3853,
4487,
20961,
24137,
7874,
2075,
1006,
1002,
5167,
1010,
2655,
3085,
1002,
2655,
5963,
1007,
1063,
2709,
2047,
10763,
1006,
9140,
1035,
4487,
4246,
1035,
25423,
24137,
2278,
1006,
1002,
2023,
1011,
1028,
5167,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Login/Controller.php | Controller.confirmResetPassword | public function confirmResetPassword()
{
$errorMessage = null;
$login = Common::getRequestVar('login', '');
$resetToken = Common::getRequestVar('resetToken', '');
try {
$this->passwordResetter->confirmNewPassword($login, $resetToken);
} catch (Exception $ex) {
Log::debug($ex);
$errorMessage = $ex->getMessage();
}
if (is_null($errorMessage)) { // if success, show login w/ success message
return $this->resetPasswordSuccess();
} else {
// show login page w/ error. this will keep the token in the URL
return $this->login($errorMessage);
}
} | php | public function confirmResetPassword()
{
$errorMessage = null;
$login = Common::getRequestVar('login', '');
$resetToken = Common::getRequestVar('resetToken', '');
try {
$this->passwordResetter->confirmNewPassword($login, $resetToken);
} catch (Exception $ex) {
Log::debug($ex);
$errorMessage = $ex->getMessage();
}
if (is_null($errorMessage)) { // if success, show login w/ success message
return $this->resetPasswordSuccess();
} else {
// show login page w/ error. this will keep the token in the URL
return $this->login($errorMessage);
}
} | [
"public",
"function",
"confirmResetPassword",
"(",
")",
"{",
"$",
"errorMessage",
"=",
"null",
";",
"$",
"login",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'login'",
",",
"''",
")",
";",
"$",
"resetToken",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'res... | Password reset confirmation action. Finishes the password reset process.
Users visit this action from a link supplied in an email. | [
"Password",
"reset",
"confirmation",
"action",
".",
"Finishes",
"the",
"password",
"reset",
"process",
".",
"Users",
"visit",
"this",
"action",
"from",
"a",
"link",
"supplied",
"in",
"an",
"email",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/Controller.php#L422-L443 | train | confirm reset password | [
30522,
2270,
3853,
12210,
6072,
3388,
15194,
18351,
1006,
1007,
1063,
1002,
7561,
7834,
3736,
3351,
1027,
19701,
1025,
1002,
8833,
2378,
1027,
2691,
1024,
1024,
2131,
2890,
15500,
10755,
1006,
1005,
8833,
2378,
1005,
1010,
1005,
1005,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php | SessionTokenStorage.getToken | public function getToken($tokenId)
{
if (!$this->session->isStarted()) {
$this->session->start();
}
if (!$this->session->has($this->namespace.'/'.$tokenId)) {
throw new TokenNotFoundException('The CSRF token with ID '.$tokenId.' does not exist.');
}
return (string) $this->session->get($this->namespace.'/'.$tokenId);
} | php | public function getToken($tokenId)
{
if (!$this->session->isStarted()) {
$this->session->start();
}
if (!$this->session->has($this->namespace.'/'.$tokenId)) {
throw new TokenNotFoundException('The CSRF token with ID '.$tokenId.' does not exist.');
}
return (string) $this->session->get($this->namespace.'/'.$tokenId);
} | [
"public",
"function",
"getToken",
"(",
"$",
"tokenId",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"session",
"->",
"isStarted",
"(",
")",
")",
"{",
"$",
"this",
"->",
"session",
"->",
"start",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php#L47-L58 | train | Get the CSRF token from the session | [
30522,
2270,
3853,
2131,
18715,
2368,
1006,
1002,
19204,
3593,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
5219,
1011,
1028,
26354,
7559,
3064,
1006,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
5219,
1011,
1028,
2707,
1006,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/DataTable.php | DataTable.getColumn | public function getColumn($name)
{
$columnValues = array();
foreach ($this->getRows() as $row) {
$columnValues[] = $row->getColumn($name);
}
return $columnValues;
} | php | public function getColumn($name)
{
$columnValues = array();
foreach ($this->getRows() as $row) {
$columnValues[] = $row->getColumn($name);
}
return $columnValues;
} | [
"public",
"function",
"getColumn",
"(",
"$",
"name",
")",
"{",
"$",
"columnValues",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRows",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"columnValues",
"[",
"]",
"=",
"$",
"row",
"... | Returns an array containing all column values for the requested column.
@param string $name The column name.
@return array The array of column values. | [
"Returns",
"an",
"array",
"containing",
"all",
"column",
"values",
"for",
"the",
"requested",
"column",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L920-L927 | train | Get column values | [
30522,
2270,
3853,
2131,
25778,
2819,
2078,
1006,
1002,
2171,
1007,
1063,
1002,
5930,
10175,
15808,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2131,
10524,
2015,
1006,
1007,
2004,
1002,
5216,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/CombineAssets.php | CombineAssets.getCache | protected function getCache($cacheKey)
{
$cacheKey = 'combiner.'.$cacheKey;
if (!Cache::has($cacheKey)) {
return false;
}
return @unserialize(@base64_decode(Cache::get($cacheKey)));
} | php | protected function getCache($cacheKey)
{
$cacheKey = 'combiner.'.$cacheKey;
if (!Cache::has($cacheKey)) {
return false;
}
return @unserialize(@base64_decode(Cache::get($cacheKey)));
} | [
"protected",
"function",
"getCache",
"(",
"$",
"cacheKey",
")",
"{",
"$",
"cacheKey",
"=",
"'combiner.'",
".",
"$",
"cacheKey",
";",
"if",
"(",
"!",
"Cache",
"::",
"has",
"(",
"$",
"cacheKey",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"@"... | Look up information about a cache identifier.
@param string $cacheKey Cache identifier
@return array Cache information | [
"Look",
"up",
"information",
"about",
"a",
"cache",
"identifier",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/CombineAssets.php#L780-L789 | train | Get the cached value of a key | [
30522,
5123,
3853,
2131,
3540,
5403,
1006,
1002,
17053,
14839,
1007,
1063,
1002,
17053,
14839,
1027,
1005,
11506,
2099,
1012,
1005,
1012,
1002,
17053,
14839,
1025,
2065,
1006,
999,
17053,
1024,
1024,
2038,
1006,
1002,
17053,
14839,
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... |
getgrav/grav | system/src/Grav/Common/Uri.php | Uri.rootUrl | public function rootUrl($include_host = false)
{
if ($include_host) {
return $this->root;
}
return str_replace($this->base, '', $this->root);
} | php | public function rootUrl($include_host = false)
{
if ($include_host) {
return $this->root;
}
return str_replace($this->base, '', $this->root);
} | [
"public",
"function",
"rootUrl",
"(",
"$",
"include_host",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"include_host",
")",
"{",
"return",
"$",
"this",
"->",
"root",
";",
"}",
"return",
"str_replace",
"(",
"$",
"this",
"->",
"base",
",",
"''",
",",
"$",
... | Return root URL to the site.
@param bool $include_host Include hostname.
@return mixed | [
"Return",
"root",
"URL",
"to",
"the",
"site",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L528-L535 | train | Return the root URL | [
30522,
2270,
3853,
7117,
3126,
2140,
1006,
1002,
2421,
1035,
3677,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2421,
1035,
3677,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
7117,
1025,
1065,
2709,
2358,
2099,
1035,
5672,
1006,
1002,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Mail.php | Zend_Mail.setReplyTo | public function setReplyTo($email, $name = null)
{
if (null !== $this->_replyTo) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Reply-To Header set twice');
}
$email = $this->_filterEmail($email);
$name = $this->_filterName($name);
$this->_replyTo = $email;
$this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true);
return $this;
} | php | public function setReplyTo($email, $name = null)
{
if (null !== $this->_replyTo) {
/**
* @see Zend_Mail_Exception
*/
// require_once 'Zend/Mail/Exception.php';
throw new Zend_Mail_Exception('Reply-To Header set twice');
}
$email = $this->_filterEmail($email);
$name = $this->_filterName($name);
$this->_replyTo = $email;
$this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true);
return $this;
} | [
"public",
"function",
"setReplyTo",
"(",
"$",
"email",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"_replyTo",
")",
"{",
"/**\n * @see Zend_Mail_Exception\n */",
"// require_once 'Zend/Mail/Exception.ph... | Set Reply-To Header
@param string $email
@param string $name
@return Zend_Mail
@throws Zend_Mail_Exception if called more than one time | [
"Set",
"Reply",
"-",
"To",
"Header"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L699-L715 | train | Set Reply - To | [
30522,
2270,
3853,
2275,
2890,
22086,
3406,
1006,
1002,
10373,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
1035,
7514,
3406,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2156,
16729,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/VarExporter/Internal/Exporter.php | Exporter.prepare | public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount, &$valuesAreStatic)
{
$refs = $values;
foreach ($values as $k => $value) {
if (\is_resource($value)) {
throw new NotInstantiableTypeException(\get_resource_type($value).' resource');
}
$refs[$k] = $objectsPool;
if ($isRef = !$valueIsStatic = $values[$k] !== $objectsPool) {
$values[$k] = &$value; // Break hard references to make $values completely
unset($value); // independent from the original structure
$refs[$k] = $value = $values[$k];
if ($value instanceof Reference && 0 > $value->id) {
$valuesAreStatic = false;
++$value->count;
continue;
}
$refsPool[] = [&$refs[$k], $value, &$value];
$refs[$k] = $values[$k] = new Reference(-\count($refsPool), $value);
}
if (\is_array($value)) {
if ($value) {
$value = self::prepare($value, $objectsPool, $refsPool, $objectsCount, $valueIsStatic);
}
goto handle_value;
} elseif (!\is_object($value) && !$value instanceof \__PHP_Incomplete_Class) {
goto handle_value;
}
$valueIsStatic = false;
if (isset($objectsPool[$value])) {
++$objectsCount;
$value = new Reference($objectsPool[$value][0]);
goto handle_value;
}
$class = \get_class($value);
$reflector = Registry::$reflectors[$class] ?? Registry::getClassReflector($class);
if ($reflector->hasMethod('__serialize')) {
if (!$reflector->getMethod('__serialize')->isPublic()) {
throw new \Error(sprintf('Call to %s method %s::__serialize()', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class));
}
if (!\is_array($properties = $value->__serialize())) {
throw new \Typerror($class.'::__serialize() must return an array');
}
goto prepare_value;
}
$properties = [];
$sleep = null;
$arrayValue = (array) $value;
$proto = Registry::$prototypes[$class];
if (($value instanceof \ArrayIterator || $value instanceof \ArrayObject) && null !== $proto) {
// ArrayIterator and ArrayObject need special care because their "flags"
// option changes the behavior of the (array) casting operator.
$properties = self::getArrayObjectProperties($value, $arrayValue, $proto);
// populates Registry::$prototypes[$class] with a new instance
Registry::getClassReflector($class, Registry::$instantiableWithoutConstructor[$class], Registry::$cloneable[$class]);
} elseif ($value instanceof \SplObjectStorage && Registry::$cloneable[$class] && null !== $proto) {
// By implementing Serializable, SplObjectStorage breaks
// internal references; let's deal with it on our own.
foreach (clone $value as $v) {
$properties[] = $v;
$properties[] = $value[$v];
}
$properties = ['SplObjectStorage' => ["\0" => $properties]];
} elseif ($value instanceof \Serializable || $value instanceof \__PHP_Incomplete_Class) {
++$objectsCount;
$objectsPool[$value] = [$id = \count($objectsPool), serialize($value), [], 0];
$value = new Reference($id);
goto handle_value;
}
if (\method_exists($class, '__sleep')) {
if (!\is_array($sleep = $value->__sleep())) {
trigger_error('serialize(): __sleep should return an array only containing the names of instance-variables to serialize', E_USER_NOTICE);
$value = null;
goto handle_value;
}
foreach ($sleep as $name) {
if (\property_exists($value, $name) && !$reflector->hasProperty($name)) {
$arrayValue[$name] = $value->$name;
}
}
$sleep = array_flip($sleep);
}
$proto = (array) $proto;
foreach ($arrayValue as $name => $v) {
$i = 0;
$n = (string) $name;
if ('' === $n || "\0" !== $n[0]) {
$c = 'stdClass';
} elseif ('*' === $n[1]) {
$n = substr($n, 3);
$c = $reflector->getProperty($n)->class;
if ('Error' === $c) {
$c = 'TypeError';
} elseif ('Exception' === $c) {
$c = 'ErrorException';
}
} else {
$i = strpos($n, "\0", 2);
$c = substr($n, 1, $i - 1);
$n = substr($n, 1 + $i);
}
if (null !== $sleep) {
if (!isset($sleep[$n]) || ($i && $c !== $class)) {
continue;
}
$sleep[$n] = false;
}
if (!\array_key_exists($name, $proto) || $proto[$name] !== $v) {
$properties[$c][$n] = $v;
}
}
if ($sleep) {
foreach ($sleep as $n => $v) {
if (false !== $v) {
trigger_error(sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $n), E_USER_NOTICE);
}
}
}
prepare_value:
$objectsPool[$value] = [$id = \count($objectsPool)];
$properties = self::prepare($properties, $objectsPool, $refsPool, $objectsCount, $valueIsStatic);
++$objectsCount;
$objectsPool[$value] = [$id, $class, $properties, \method_exists($class, '__unserialize') ? -$objectsCount : (\method_exists($class, '__wakeup') ? $objectsCount : 0)];
$value = new Reference($id);
handle_value:
if ($isRef) {
unset($value); // Break the hard reference created above
} elseif (!$valueIsStatic) {
$values[$k] = $value;
}
$valuesAreStatic = $valueIsStatic && $valuesAreStatic;
}
return $values;
} | php | public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount, &$valuesAreStatic)
{
$refs = $values;
foreach ($values as $k => $value) {
if (\is_resource($value)) {
throw new NotInstantiableTypeException(\get_resource_type($value).' resource');
}
$refs[$k] = $objectsPool;
if ($isRef = !$valueIsStatic = $values[$k] !== $objectsPool) {
$values[$k] = &$value; // Break hard references to make $values completely
unset($value); // independent from the original structure
$refs[$k] = $value = $values[$k];
if ($value instanceof Reference && 0 > $value->id) {
$valuesAreStatic = false;
++$value->count;
continue;
}
$refsPool[] = [&$refs[$k], $value, &$value];
$refs[$k] = $values[$k] = new Reference(-\count($refsPool), $value);
}
if (\is_array($value)) {
if ($value) {
$value = self::prepare($value, $objectsPool, $refsPool, $objectsCount, $valueIsStatic);
}
goto handle_value;
} elseif (!\is_object($value) && !$value instanceof \__PHP_Incomplete_Class) {
goto handle_value;
}
$valueIsStatic = false;
if (isset($objectsPool[$value])) {
++$objectsCount;
$value = new Reference($objectsPool[$value][0]);
goto handle_value;
}
$class = \get_class($value);
$reflector = Registry::$reflectors[$class] ?? Registry::getClassReflector($class);
if ($reflector->hasMethod('__serialize')) {
if (!$reflector->getMethod('__serialize')->isPublic()) {
throw new \Error(sprintf('Call to %s method %s::__serialize()', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class));
}
if (!\is_array($properties = $value->__serialize())) {
throw new \Typerror($class.'::__serialize() must return an array');
}
goto prepare_value;
}
$properties = [];
$sleep = null;
$arrayValue = (array) $value;
$proto = Registry::$prototypes[$class];
if (($value instanceof \ArrayIterator || $value instanceof \ArrayObject) && null !== $proto) {
// ArrayIterator and ArrayObject need special care because their "flags"
// option changes the behavior of the (array) casting operator.
$properties = self::getArrayObjectProperties($value, $arrayValue, $proto);
// populates Registry::$prototypes[$class] with a new instance
Registry::getClassReflector($class, Registry::$instantiableWithoutConstructor[$class], Registry::$cloneable[$class]);
} elseif ($value instanceof \SplObjectStorage && Registry::$cloneable[$class] && null !== $proto) {
// By implementing Serializable, SplObjectStorage breaks
// internal references; let's deal with it on our own.
foreach (clone $value as $v) {
$properties[] = $v;
$properties[] = $value[$v];
}
$properties = ['SplObjectStorage' => ["\0" => $properties]];
} elseif ($value instanceof \Serializable || $value instanceof \__PHP_Incomplete_Class) {
++$objectsCount;
$objectsPool[$value] = [$id = \count($objectsPool), serialize($value), [], 0];
$value = new Reference($id);
goto handle_value;
}
if (\method_exists($class, '__sleep')) {
if (!\is_array($sleep = $value->__sleep())) {
trigger_error('serialize(): __sleep should return an array only containing the names of instance-variables to serialize', E_USER_NOTICE);
$value = null;
goto handle_value;
}
foreach ($sleep as $name) {
if (\property_exists($value, $name) && !$reflector->hasProperty($name)) {
$arrayValue[$name] = $value->$name;
}
}
$sleep = array_flip($sleep);
}
$proto = (array) $proto;
foreach ($arrayValue as $name => $v) {
$i = 0;
$n = (string) $name;
if ('' === $n || "\0" !== $n[0]) {
$c = 'stdClass';
} elseif ('*' === $n[1]) {
$n = substr($n, 3);
$c = $reflector->getProperty($n)->class;
if ('Error' === $c) {
$c = 'TypeError';
} elseif ('Exception' === $c) {
$c = 'ErrorException';
}
} else {
$i = strpos($n, "\0", 2);
$c = substr($n, 1, $i - 1);
$n = substr($n, 1 + $i);
}
if (null !== $sleep) {
if (!isset($sleep[$n]) || ($i && $c !== $class)) {
continue;
}
$sleep[$n] = false;
}
if (!\array_key_exists($name, $proto) || $proto[$name] !== $v) {
$properties[$c][$n] = $v;
}
}
if ($sleep) {
foreach ($sleep as $n => $v) {
if (false !== $v) {
trigger_error(sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $n), E_USER_NOTICE);
}
}
}
prepare_value:
$objectsPool[$value] = [$id = \count($objectsPool)];
$properties = self::prepare($properties, $objectsPool, $refsPool, $objectsCount, $valueIsStatic);
++$objectsCount;
$objectsPool[$value] = [$id, $class, $properties, \method_exists($class, '__unserialize') ? -$objectsCount : (\method_exists($class, '__wakeup') ? $objectsCount : 0)];
$value = new Reference($id);
handle_value:
if ($isRef) {
unset($value); // Break the hard reference created above
} elseif (!$valueIsStatic) {
$values[$k] = $value;
}
$valuesAreStatic = $valueIsStatic && $valuesAreStatic;
}
return $values;
} | [
"public",
"static",
"function",
"prepare",
"(",
"$",
"values",
",",
"$",
"objectsPool",
",",
"&",
"$",
"refsPool",
",",
"&",
"$",
"objectsCount",
",",
"&",
"$",
"valuesAreStatic",
")",
"{",
"$",
"refs",
"=",
"$",
"values",
";",
"foreach",
"(",
"$",
"... | Prepares an array of values for VarExporter.
For performance this method is public and has no type-hints.
@param array &$values
@param \SplObjectStorage $objectsPool
@param array &$refsPool
@param int &$objectsCount
@param bool &$valuesAreStatic
@return int
@throws NotInstantiableTypeException When a value cannot be serialized | [
"Prepares",
"an",
"array",
"of",
"values",
"for",
"VarExporter",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarExporter/Internal/Exporter.php#L38-L188 | train | Prepare the values | [
30522,
2270,
10763,
3853,
7374,
1006,
1002,
5300,
1010,
1002,
5200,
16869,
1010,
1004,
1002,
25416,
13102,
13669,
1010,
1004,
1002,
5200,
3597,
16671,
1010,
1004,
1002,
5300,
17933,
29336,
2594,
1007,
1063,
1002,
25416,
2015,
1027,
1002,
53... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AcceptHeader.php | AcceptHeader.get | public function get($value)
{
return $this->items[$value] ?? $this->items[explode('/', $value)[0].'/*'] ?? $this->items['*/*'] ?? $this->items['*'] ?? null;
} | php | public function get($value)
{
return $this->items[$value] ?? $this->items[explode('/', $value)[0].'/*'] ?? $this->items['*/*'] ?? $this->items['*'] ?? null;
} | [
"public",
"function",
"get",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"value",
"]",
"??",
"$",
"this",
"->",
"items",
"[",
"explode",
"(",
"'/'",
",",
"$",
"value",
")",
"[",
"0",
"]",
".",
"'/*'",
"]",
"??",... | Returns given value's item, if exists.
@param string $value
@return AcceptHeaderItem|null | [
"Returns",
"given",
"value",
"s",
"item",
"if",
"exists",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/AcceptHeader.php#L97-L100 | train | Get a page from the page tree | [
30522,
2270,
3853,
2131,
1006,
1002,
3643,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5167,
1031,
1002,
3643,
1033,
1029,
1029,
1002,
2023,
1011,
1028,
5167,
1031,
15044,
1006,
1005,
1013,
1005,
1010,
1002,
3643,
1007,
1031,
1014,
1033,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Command/DebugCommand.php | DebugCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
if (null === $class = $input->getArgument('class')) {
$object = null;
$options['core_types'] = $this->getCoreTypes();
$options['service_types'] = array_values(array_diff($this->types, $options['core_types']));
if ($input->getOption('show-deprecated')) {
$options['core_types'] = $this->filterTypesByDeprecated($options['core_types']);
$options['service_types'] = $this->filterTypesByDeprecated($options['service_types']);
}
$options['extensions'] = $this->extensions;
$options['guessers'] = $this->guessers;
foreach ($options as $k => $list) {
sort($options[$k]);
}
} else {
if (!class_exists($class) || !is_subclass_of($class, FormTypeInterface::class)) {
$class = $this->getFqcnTypeClass($input, $io, $class);
}
$resolvedType = $this->formRegistry->getType($class);
if ($option = $input->getArgument('option')) {
$object = $resolvedType->getOptionsResolver();
if (!$object->isDefined($option)) {
$message = sprintf('Option "%s" is not defined in "%s".', $option, \get_class($resolvedType->getInnerType()));
if ($alternatives = $this->findAlternatives($option, $object->getDefinedOptions())) {
if (1 === \count($alternatives)) {
$message .= "\n\nDid you mean this?\n ";
} else {
$message .= "\n\nDid you mean one of these?\n ";
}
$message .= implode("\n ", $alternatives);
}
throw new InvalidArgumentException($message);
}
$options['type'] = $resolvedType->getInnerType();
$options['option'] = $option;
} else {
$object = $resolvedType;
}
}
$helper = new DescriptorHelper($this->fileLinkFormatter);
$options['format'] = $input->getOption('format');
$options['show_deprecated'] = $input->getOption('show-deprecated');
$helper->describe($io, $object, $options);
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
if (null === $class = $input->getArgument('class')) {
$object = null;
$options['core_types'] = $this->getCoreTypes();
$options['service_types'] = array_values(array_diff($this->types, $options['core_types']));
if ($input->getOption('show-deprecated')) {
$options['core_types'] = $this->filterTypesByDeprecated($options['core_types']);
$options['service_types'] = $this->filterTypesByDeprecated($options['service_types']);
}
$options['extensions'] = $this->extensions;
$options['guessers'] = $this->guessers;
foreach ($options as $k => $list) {
sort($options[$k]);
}
} else {
if (!class_exists($class) || !is_subclass_of($class, FormTypeInterface::class)) {
$class = $this->getFqcnTypeClass($input, $io, $class);
}
$resolvedType = $this->formRegistry->getType($class);
if ($option = $input->getArgument('option')) {
$object = $resolvedType->getOptionsResolver();
if (!$object->isDefined($option)) {
$message = sprintf('Option "%s" is not defined in "%s".', $option, \get_class($resolvedType->getInnerType()));
if ($alternatives = $this->findAlternatives($option, $object->getDefinedOptions())) {
if (1 === \count($alternatives)) {
$message .= "\n\nDid you mean this?\n ";
} else {
$message .= "\n\nDid you mean one of these?\n ";
}
$message .= implode("\n ", $alternatives);
}
throw new InvalidArgumentException($message);
}
$options['type'] = $resolvedType->getInnerType();
$options['option'] = $option;
} else {
$object = $resolvedType;
}
}
$helper = new DescriptorHelper($this->fileLinkFormatter);
$options['format'] = $input->getOption('format');
$options['show_deprecated'] = $input->getOption('show-deprecated');
$helper->describe($io, $object, $options);
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"if",
"(",
"null",
"===",
"$",
"class",
"=... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Command/DebugCommand.php#L103-L155 | train | Execute the type command | [
30522,
5123,
3853,
15389,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
22834,
1027,
2047,
25353,
2213,
14876,
4890,
21756,
2571,
1006,
1002,
7953,
1010,
1002,
6434,
1007,
1025,
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... |
matomo-org/matomo | plugins/CoreConsole/Commands/CoreArchiver.php | CoreArchiver.makeArchiver | public static function makeArchiver($url, InputInterface $input)
{
$archiver = new CronArchive();
$archiver->disableScheduledTasks = $input->getOption('disable-scheduled-tasks');
$archiver->acceptInvalidSSLCertificate = $input->getOption("accept-invalid-ssl-certificate");
$archiver->shouldArchiveAllSites = (bool) $input->getOption("force-all-websites");
$archiver->shouldStartProfiler = (bool) $input->getOption("xhprof");
$archiver->shouldArchiveSpecifiedSites = self::getSitesListOption($input, "force-idsites");
$archiver->shouldSkipSpecifiedSites = self::getSitesListOption($input, "skip-idsites");
$archiver->forceTimeoutPeriod = $input->getOption("force-timeout-for-periods");
$archiver->shouldArchiveAllPeriodsSince = $input->getOption("force-all-periods");
$archiver->restrictToDateRange = $input->getOption("force-date-range");
$archiver->phpCliConfigurationOptions = $input->getOption("php-cli-options");
$restrictToPeriods = $input->getOption("force-periods");
$restrictToPeriods = explode(',', $restrictToPeriods);
$archiver->restrictToPeriods = array_map('trim', $restrictToPeriods);
$archiver->dateLastForced = $input->getOption('force-date-last-n');
$archiver->concurrentRequestsPerWebsite = $input->getOption('concurrent-requests-per-website');
$archiver->maxConcurrentArchivers = $input->getOption('concurrent-archivers');
$archiver->disableSegmentsArchiving = $input->getOption('skip-all-segments');
$segmentIds = $input->getOption('force-idsegments');
$segmentIds = explode(',', $segmentIds);
$segmentIds = array_map('trim', $segmentIds);
$archiver->setSegmentsToForceFromSegmentIds($segmentIds);
$archiver->setUrlToPiwik($url);
return $archiver;
} | php | public static function makeArchiver($url, InputInterface $input)
{
$archiver = new CronArchive();
$archiver->disableScheduledTasks = $input->getOption('disable-scheduled-tasks');
$archiver->acceptInvalidSSLCertificate = $input->getOption("accept-invalid-ssl-certificate");
$archiver->shouldArchiveAllSites = (bool) $input->getOption("force-all-websites");
$archiver->shouldStartProfiler = (bool) $input->getOption("xhprof");
$archiver->shouldArchiveSpecifiedSites = self::getSitesListOption($input, "force-idsites");
$archiver->shouldSkipSpecifiedSites = self::getSitesListOption($input, "skip-idsites");
$archiver->forceTimeoutPeriod = $input->getOption("force-timeout-for-periods");
$archiver->shouldArchiveAllPeriodsSince = $input->getOption("force-all-periods");
$archiver->restrictToDateRange = $input->getOption("force-date-range");
$archiver->phpCliConfigurationOptions = $input->getOption("php-cli-options");
$restrictToPeriods = $input->getOption("force-periods");
$restrictToPeriods = explode(',', $restrictToPeriods);
$archiver->restrictToPeriods = array_map('trim', $restrictToPeriods);
$archiver->dateLastForced = $input->getOption('force-date-last-n');
$archiver->concurrentRequestsPerWebsite = $input->getOption('concurrent-requests-per-website');
$archiver->maxConcurrentArchivers = $input->getOption('concurrent-archivers');
$archiver->disableSegmentsArchiving = $input->getOption('skip-all-segments');
$segmentIds = $input->getOption('force-idsegments');
$segmentIds = explode(',', $segmentIds);
$segmentIds = array_map('trim', $segmentIds);
$archiver->setSegmentsToForceFromSegmentIds($segmentIds);
$archiver->setUrlToPiwik($url);
return $archiver;
} | [
"public",
"static",
"function",
"makeArchiver",
"(",
"$",
"url",
",",
"InputInterface",
"$",
"input",
")",
"{",
"$",
"archiver",
"=",
"new",
"CronArchive",
"(",
")",
";",
"$",
"archiver",
"->",
"disableScheduledTasks",
"=",
"$",
"input",
"->",
"getOption",
... | also used by another console command | [
"also",
"used",
"by",
"another",
"console",
"command"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreConsole/Commands/CoreArchiver.php#L31-L64 | train | Creates an archiver for the given URL and Input | [
30522,
2270,
10763,
3853,
2191,
2906,
5428,
6299,
1006,
1002,
24471,
2140,
1010,
7953,
18447,
2121,
12172,
1002,
7953,
1007,
1063,
1002,
8756,
2099,
1027,
2047,
13675,
7856,
11140,
3512,
1006,
1007,
1025,
1002,
8756,
2099,
1011,
1028,
4487,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/controllers/ThemeOptions.php | ThemeOptions.formExtendFields | public function formExtendFields($form)
{
$model = $form->model;
$theme = $this->findThemeObject($model->theme);
$config = $theme->getFormConfig();
if ($fields = array_get($config, 'fields')) {
$form->addFields($fields);
}
if ($fields = array_get($config, 'tabs.fields')) {
$form->addTabFields($fields);
}
if ($fields = array_get($config, 'secondaryTabs.fields')) {
$form->addSecondaryTabFields($fields);
}
} | php | public function formExtendFields($form)
{
$model = $form->model;
$theme = $this->findThemeObject($model->theme);
$config = $theme->getFormConfig();
if ($fields = array_get($config, 'fields')) {
$form->addFields($fields);
}
if ($fields = array_get($config, 'tabs.fields')) {
$form->addTabFields($fields);
}
if ($fields = array_get($config, 'secondaryTabs.fields')) {
$form->addSecondaryTabFields($fields);
}
} | [
"public",
"function",
"formExtendFields",
"(",
"$",
"form",
")",
"{",
"$",
"model",
"=",
"$",
"form",
"->",
"model",
";",
"$",
"theme",
"=",
"$",
"this",
"->",
"findThemeObject",
"(",
"$",
"model",
"->",
"theme",
")",
";",
"$",
"config",
"=",
"$",
... | Add form fields defined in theme.yaml | [
"Add",
"form",
"fields",
"defined",
"in",
"theme",
".",
"yaml"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/controllers/ThemeOptions.php#L84-L101 | train | Extend form fields with the theme s form config | [
30522,
2270,
3853,
2433,
10288,
6528,
20952,
12891,
2015,
1006,
1002,
2433,
1007,
1063,
1002,
2944,
1027,
1002,
2433,
1011,
1028,
2944,
1025,
1002,
4323,
1027,
1002,
2023,
1011,
1028,
2424,
10760,
26247,
2497,
20614,
1006,
1002,
2944,
1011,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Helper/ProgressBar.php | ProgressBar.setFormatDefinition | public static function setFormatDefinition(string $name, string $format): void
{
if (!self::$formats) {
self::$formats = self::initFormats();
}
self::$formats[$name] = $format;
} | php | public static function setFormatDefinition(string $name, string $format): void
{
if (!self::$formats) {
self::$formats = self::initFormats();
}
self::$formats[$name] = $format;
} | [
"public",
"static",
"function",
"setFormatDefinition",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"format",
")",
":",
"void",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"formats",
")",
"{",
"self",
"::",
"$",
"formats",
"=",
"self",
"::",
"initFormat... | Sets a format for a given name.
This method also allow you to override an existing format.
@param string $name The format name
@param string $format A format string | [
"Sets",
"a",
"format",
"for",
"a",
"given",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/ProgressBar.php#L116-L123 | train | Set the format definition for the given name | [
30522,
2270,
10763,
3853,
2275,
14192,
4017,
3207,
16294,
22753,
1006,
5164,
1002,
2171,
1010,
5164,
1002,
4289,
1007,
1024,
11675,
1063,
2065,
1006,
999,
2969,
1024,
1024,
1002,
11630,
1007,
1063,
2969,
1024,
1024,
1002,
11630,
1027,
2969,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.isFirst | public function isFirst()
{
$parent = $this->parent();
$collection = $parent ? $parent->collection('content', false) : null;
if ($collection instanceof Collection) {
return $collection->isFirst($this->path());
}
return true;
} | php | public function isFirst()
{
$parent = $this->parent();
$collection = $parent ? $parent->collection('content', false) : null;
if ($collection instanceof Collection) {
return $collection->isFirst($this->path());
}
return true;
} | [
"public",
"function",
"isFirst",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"parent",
"(",
")",
";",
"$",
"collection",
"=",
"$",
"parent",
"?",
"$",
"parent",
"->",
"collection",
"(",
"'content'",
",",
"false",
")",
":",
"null",
";",
"i... | Check to see if this item is the first in an array of sub-pages.
@return bool True if item is first. | [
"Check",
"to",
"see",
"if",
"this",
"item",
"is",
"the",
"first",
"in",
"an",
"array",
"of",
"sub",
"-",
"pages",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L2424-L2433 | train | return true if this is the first item in the tree | [
30522,
2270,
3853,
2003,
8873,
12096,
1006,
1007,
1063,
1002,
6687,
1027,
1002,
2023,
1011,
1028,
6687,
1006,
1007,
1025,
1002,
3074,
1027,
1002,
6687,
1029,
1002,
6687,
1011,
1028,
3074,
1006,
1005,
4180,
1005,
1010,
6270,
1007,
1024,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cache/TaggedCache.php | TaggedCache.increment | public function increment($key, $value = 1)
{
$this->store->increment($this->itemKey($key), $value);
} | php | public function increment($key, $value = 1)
{
$this->store->increment($this->itemKey($key), $value);
} | [
"public",
"function",
"increment",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"store",
"->",
"increment",
"(",
"$",
"this",
"->",
"itemKey",
"(",
"$",
"key",
")",
",",
"$",
"value",
")",
";",
"}"
] | Increment the value of an item in the cache.
@param string $key
@param mixed $value
@return void | [
"Increment",
"the",
"value",
"of",
"an",
"item",
"in",
"the",
"cache",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/TaggedCache.php#L57-L60 | train | Increment the value of an integer key in the recordset | [
30522,
2270,
3853,
4297,
28578,
4765,
1006,
1002,
3145,
1010,
1002,
3643,
1027,
1015,
1007,
1063,
1002,
2023,
1011,
1028,
3573,
1011,
1028,
4297,
28578,
4765,
1006,
1002,
2023,
1011,
1028,
8875,
14839,
1006,
1002,
3145,
1007,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php | PersistentTokenBasedRememberMeServices.cancelCookie | protected function cancelCookie(Request $request)
{
// Delete cookie on the client
parent::cancelCookie($request);
// Delete cookie from the tokenProvider
if (null !== ($cookie = $request->cookies->get($this->options['name']))
&& 2 === \count($parts = $this->decodeCookie($cookie))
) {
list($series) = $parts;
$this->tokenProvider->deleteTokenBySeries($series);
}
} | php | protected function cancelCookie(Request $request)
{
// Delete cookie on the client
parent::cancelCookie($request);
// Delete cookie from the tokenProvider
if (null !== ($cookie = $request->cookies->get($this->options['name']))
&& 2 === \count($parts = $this->decodeCookie($cookie))
) {
list($series) = $parts;
$this->tokenProvider->deleteTokenBySeries($series);
}
} | [
"protected",
"function",
"cancelCookie",
"(",
"Request",
"$",
"request",
")",
"{",
"// Delete cookie on the client",
"parent",
"::",
"cancelCookie",
"(",
"$",
"request",
")",
";",
"// Delete cookie from the tokenProvider",
"if",
"(",
"null",
"!==",
"(",
"$",
"cookie... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php#L43-L55 | train | Cancel cookie. | [
30522,
5123,
3853,
17542,
3597,
23212,
2063,
1006,
5227,
1002,
5227,
1007,
1063,
1013,
1013,
3972,
12870,
17387,
2006,
1996,
7396,
6687,
1024,
1024,
17542,
3597,
23212,
2063,
1006,
1002,
5227,
1007,
1025,
1013,
1013,
3972,
12870,
17387,
201... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/EmailAddress.php | Zend_Validate_EmailAddress._toIp | private function _toIp($binary)
{
$ip = array();
$tmp = explode(".", chunk_split($binary, 8, "."));
for ($i = 0; $i < 4 ; $i++) {
$ip[$i] = bindec($tmp[$i]);
}
return $ip;
} | php | private function _toIp($binary)
{
$ip = array();
$tmp = explode(".", chunk_split($binary, 8, "."));
for ($i = 0; $i < 4 ; $i++) {
$ip[$i] = bindec($tmp[$i]);
}
return $ip;
} | [
"private",
"function",
"_toIp",
"(",
"$",
"binary",
")",
"{",
"$",
"ip",
"=",
"array",
"(",
")",
";",
"$",
"tmp",
"=",
"explode",
"(",
"\".\"",
",",
"chunk_split",
"(",
"$",
"binary",
",",
"8",
",",
"\".\"",
")",
")",
";",
"for",
"(",
"$",
"i",... | Converts a binary string to an IP address
@param string $binary
@return mixed | [
"Converts",
"a",
"binary",
"string",
"to",
"an",
"IP",
"address"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/EmailAddress.php#L389-L398 | train | Convert binary to ip | [
30522,
2797,
3853,
1035,
2000,
11514,
1006,
1002,
12441,
1007,
1063,
1002,
12997,
1027,
9140,
1006,
1007,
1025,
1002,
1056,
8737,
1027,
15044,
1006,
1000,
1012,
1000,
1010,
20000,
1035,
3975,
1006,
1002,
12441,
1010,
1022,
1010,
1000,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Config/Writer/Xml.php | Zend_Config_Writer_Xml._addBranch | protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
{
$branchType = null;
foreach ($config as $key => $value) {
if ($branchType === null) {
if (is_numeric($key)) {
$branchType = 'numeric';
$branchName = $xml->getName();
$xml = $parent;
unset($parent->{$branchName});
} else {
$branchType = 'string';
}
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
// require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
}
if ($branchType === 'numeric') {
if ($value instanceof Zend_Config) {
$child = $parent->addChild($branchName);
$this->_addBranch($value, $child, $parent);
} else {
$parent->addChild($branchName, (string) $value);
}
} else {
if ($value instanceof Zend_Config) {
$child = $xml->addChild($key);
$this->_addBranch($value, $child, $xml);
} else {
$xml->addChild($key, (string) $value);
}
}
}
} | php | protected function _addBranch(Zend_Config $config, SimpleXMLElement $xml, SimpleXMLElement $parent)
{
$branchType = null;
foreach ($config as $key => $value) {
if ($branchType === null) {
if (is_numeric($key)) {
$branchType = 'numeric';
$branchName = $xml->getName();
$xml = $parent;
unset($parent->{$branchName});
} else {
$branchType = 'string';
}
} else if ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
// require_once 'Zend/Config/Exception.php';
throw new Zend_Config_Exception('Mixing of string and numeric keys is not allowed');
}
if ($branchType === 'numeric') {
if ($value instanceof Zend_Config) {
$child = $parent->addChild($branchName);
$this->_addBranch($value, $child, $parent);
} else {
$parent->addChild($branchName, (string) $value);
}
} else {
if ($value instanceof Zend_Config) {
$child = $xml->addChild($key);
$this->_addBranch($value, $child, $xml);
} else {
$xml->addChild($key, (string) $value);
}
}
}
} | [
"protected",
"function",
"_addBranch",
"(",
"Zend_Config",
"$",
"config",
",",
"SimpleXMLElement",
"$",
"xml",
",",
"SimpleXMLElement",
"$",
"parent",
")",
"{",
"$",
"branchType",
"=",
"null",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$"... | Add a branch to an XML object recursively
@param Zend_Config $config
@param SimpleXMLElement $xml
@param SimpleXMLElement $parent
@return void | [
"Add",
"a",
"branch",
"to",
"an",
"XML",
"object",
"recursively"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer/Xml.php#L88-L126 | train | Add branch to XML | [
30522,
5123,
3853,
1035,
5587,
10024,
12680,
30524,
12260,
3672,
1002,
20950,
1010,
3722,
2595,
19968,
12260,
3672,
1002,
6687,
1007,
1063,
1002,
3589,
13874,
1027,
19701,
1025,
18921,
6776,
1006,
1002,
9530,
8873,
2290,
2004,
1002,
3145,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/classes/Controller.php | Controller.setComponentPropertiesFromParams | protected function setComponentPropertiesFromParams($component, $parameters = [])
{
$properties = $component->getProperties();
$routerParameters = $this->router->getParameters();
foreach ($properties as $propertyName => $propertyValue) {
if (is_array($propertyValue)) {
continue;
}
$matches = [];
if (preg_match('/^\{\{([^\}]+)\}\}$/', $propertyValue, $matches)) {
$paramName = trim($matches[1]);
if (substr($paramName, 0, 1) == ':') {
$routeParamName = substr($paramName, 1);
$newPropertyValue = $routerParameters[$routeParamName] ?? null;
}
else {
$newPropertyValue = $parameters[$paramName] ?? null;
}
$component->setProperty($propertyName, $newPropertyValue);
$component->setExternalPropertyName($propertyName, $paramName);
}
}
} | php | protected function setComponentPropertiesFromParams($component, $parameters = [])
{
$properties = $component->getProperties();
$routerParameters = $this->router->getParameters();
foreach ($properties as $propertyName => $propertyValue) {
if (is_array($propertyValue)) {
continue;
}
$matches = [];
if (preg_match('/^\{\{([^\}]+)\}\}$/', $propertyValue, $matches)) {
$paramName = trim($matches[1]);
if (substr($paramName, 0, 1) == ':') {
$routeParamName = substr($paramName, 1);
$newPropertyValue = $routerParameters[$routeParamName] ?? null;
}
else {
$newPropertyValue = $parameters[$paramName] ?? null;
}
$component->setProperty($propertyName, $newPropertyValue);
$component->setExternalPropertyName($propertyName, $paramName);
}
}
} | [
"protected",
"function",
"setComponentPropertiesFromParams",
"(",
"$",
"component",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"properties",
"=",
"$",
"component",
"->",
"getProperties",
"(",
")",
";",
"$",
"routerParameters",
"=",
"$",
"this",
"-... | Sets component property values from partial parameters.
The property values should be defined as {{ param }}.
@param ComponentBase $component The component object.
@param array $parameters Specifies the partial parameters. | [
"Sets",
"component",
"property",
"values",
"from",
"partial",
"parameters",
".",
"The",
"property",
"values",
"should",
"be",
"defined",
"as",
"{{",
"param",
"}}",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/classes/Controller.php#L1551-L1577 | train | Set the component properties from the parameters | [
30522,
5123,
3853,
2275,
9006,
29513,
3372,
21572,
4842,
7368,
19699,
25377,
5400,
5244,
1006,
1002,
6922,
1010,
1002,
11709,
1027,
30524,
2023,
1011,
1028,
2799,
2099,
1011,
1028,
2131,
28689,
22828,
2015,
1006,
1007,
1025,
18921,
6776,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Controllers/AuthController.php | AuthController.postLogin | public function postLogin(Request $request)
{
$this->loginValidator($request->all())->validate();
$credentials = $request->only([$this->username(), 'password']);
$remember = $request->get('remember', false);
if ($this->guard()->attempt($credentials, $remember)) {
return $this->sendLoginResponse($request);
}
return back()->withInput()->withErrors([
$this->username() => $this->getFailedLoginMessage(),
]);
} | php | public function postLogin(Request $request)
{
$this->loginValidator($request->all())->validate();
$credentials = $request->only([$this->username(), 'password']);
$remember = $request->get('remember', false);
if ($this->guard()->attempt($credentials, $remember)) {
return $this->sendLoginResponse($request);
}
return back()->withInput()->withErrors([
$this->username() => $this->getFailedLoginMessage(),
]);
} | [
"public",
"function",
"postLogin",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"loginValidator",
"(",
"$",
"request",
"->",
"all",
"(",
")",
")",
"->",
"validate",
"(",
")",
";",
"$",
"credentials",
"=",
"$",
"request",
"->",
"only",
... | Handle a login request.
@param Request $request
@return mixed | [
"Handle",
"a",
"login",
"request",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Controllers/AuthController.php#L43-L57 | train | Post Login Action | [
30522,
2270,
3853,
2695,
21197,
2378,
1006,
5227,
1002,
5227,
1007,
1063,
1002,
2023,
1011,
1028,
8833,
2378,
10175,
8524,
4263,
1006,
1002,
5227,
1011,
1028,
2035,
1006,
1007,
1007,
1011,
1028,
9398,
3686,
1006,
1007,
1025,
1002,
22496,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FrameReflower/AbstractFrameReflower.php | AbstractFrameReflower._set_content | protected function _set_content()
{
$frame = $this->_frame;
$style = $frame->get_style();
// if the element was pushed to a new page use the saved counter value, otherwise use the CSS reset value
if ($style->counter_reset && ($reset = $style->counter_reset) !== "none") {
$vars = preg_split('/\s+/', trim($reset), 2);
$frame->reset_counter($vars[0], (isset($frame->_counters['__' . $vars[0]]) ? $frame->_counters['__' . $vars[0]] : (isset($vars[1]) ? $vars[1] : 0)));
}
if ($style->counter_increment && ($increment = $style->counter_increment) !== "none") {
$frame->increment_counters($increment);
}
if ($style->content && $frame->get_node()->nodeName === "dompdf_generated") {
$content = $this->_parse_content();
// add generated content to the font subset
// FIXME: This is currently too late because the font subset has already been generated.
// See notes in issue #750.
if ($frame->get_dompdf()->getOptions()->getIsFontSubsettingEnabled() && $frame->get_dompdf()->get_canvas() instanceof CPDF) {
$frame->get_dompdf()->get_canvas()->register_string_subset($style->font_family, $content);
}
$node = $frame->get_node()->ownerDocument->createTextNode($content);
$new_style = $style->get_stylesheet()->create_style();
$new_style->inherit($style);
$new_frame = new Frame($node);
$new_frame->set_style($new_style);
Factory::decorate_frame($new_frame, $frame->get_dompdf(), $frame->get_root());
$frame->append_child($new_frame);
}
} | php | protected function _set_content()
{
$frame = $this->_frame;
$style = $frame->get_style();
// if the element was pushed to a new page use the saved counter value, otherwise use the CSS reset value
if ($style->counter_reset && ($reset = $style->counter_reset) !== "none") {
$vars = preg_split('/\s+/', trim($reset), 2);
$frame->reset_counter($vars[0], (isset($frame->_counters['__' . $vars[0]]) ? $frame->_counters['__' . $vars[0]] : (isset($vars[1]) ? $vars[1] : 0)));
}
if ($style->counter_increment && ($increment = $style->counter_increment) !== "none") {
$frame->increment_counters($increment);
}
if ($style->content && $frame->get_node()->nodeName === "dompdf_generated") {
$content = $this->_parse_content();
// add generated content to the font subset
// FIXME: This is currently too late because the font subset has already been generated.
// See notes in issue #750.
if ($frame->get_dompdf()->getOptions()->getIsFontSubsettingEnabled() && $frame->get_dompdf()->get_canvas() instanceof CPDF) {
$frame->get_dompdf()->get_canvas()->register_string_subset($style->font_family, $content);
}
$node = $frame->get_node()->ownerDocument->createTextNode($content);
$new_style = $style->get_stylesheet()->create_style();
$new_style->inherit($style);
$new_frame = new Frame($node);
$new_frame->set_style($new_style);
Factory::decorate_frame($new_frame, $frame->get_dompdf(), $frame->get_root());
$frame->append_child($new_frame);
}
} | [
"protected",
"function",
"_set_content",
"(",
")",
"{",
"$",
"frame",
"=",
"$",
"this",
"->",
"_frame",
";",
"$",
"style",
"=",
"$",
"frame",
"->",
"get_style",
"(",
")",
";",
"// if the element was pushed to a new page use the saved counter value, otherwise use the C... | Sets the generated content of a generated frame | [
"Sets",
"the",
"generated",
"content",
"of",
"a",
"generated",
"frame"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/FrameReflower/AbstractFrameReflower.php#L483-L518 | train | Set the content of the frame | [
30522,
5123,
3853,
1035,
2275,
1035,
4180,
1006,
1007,
1063,
1002,
4853,
1027,
1002,
2023,
1011,
1028,
1035,
4853,
1025,
1002,
2806,
1027,
1002,
4853,
1011,
1028,
2131,
1035,
2806,
1006,
1007,
1025,
1013,
1013,
2065,
1996,
5783,
2001,
372... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Db2.php | Zend_Db_Adapter_Db2._commit | protected function _commit()
{
if (!db2_commit($this->_connection)) {
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception(
db2_conn_errormsg($this->_connection),
db2_conn_error($this->_connection));
}
$this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
} | php | protected function _commit()
{
if (!db2_commit($this->_connection)) {
/**
* @see Zend_Db_Adapter_Db2_Exception
*/
// require_once 'Zend/Db/Adapter/Db2/Exception.php';
throw new Zend_Db_Adapter_Db2_Exception(
db2_conn_errormsg($this->_connection),
db2_conn_error($this->_connection));
}
$this->_setExecuteMode(DB2_AUTOCOMMIT_ON);
} | [
"protected",
"function",
"_commit",
"(",
")",
"{",
"if",
"(",
"!",
"db2_commit",
"(",
"$",
"this",
"->",
"_connection",
")",
")",
"{",
"/**\n * @see Zend_Db_Adapter_Db2_Exception\n */",
"// require_once 'Zend/Db/Adapter/Db2/Exception.php';",
"throw",
... | Commit a transaction.
@return void | [
"Commit",
"a",
"transaction",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Db2.php#L588-L601 | train | Commit the current transaction | [
30522,
5123,
3853,
1035,
10797,
1006,
1007,
1063,
2065,
1006,
999,
16962,
2475,
1035,
10797,
1006,
1002,
2023,
1011,
1028,
1035,
4434,
1007,
1007,
1063,
1013,
1008,
1008,
1008,
1030,
2156,
16729,
2094,
1035,
16962,
1035,
15581,
2121,
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... |
dompdf/dompdf | src/Dompdf.php | Dompdf.output | public function output($options = array())
{
$this->saveLocale();
$canvas = $this->getCanvas();
if (is_null($canvas)) {
return null;
}
$output = $canvas->output($options);
$this->restoreLocale();
return $output;
} | php | public function output($options = array())
{
$this->saveLocale();
$canvas = $this->getCanvas();
if (is_null($canvas)) {
return null;
}
$output = $canvas->output($options);
$this->restoreLocale();
return $output;
} | [
"public",
"function",
"output",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"saveLocale",
"(",
")",
";",
"$",
"canvas",
"=",
"$",
"this",
"->",
"getCanvas",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"canvas",
")... | Returns the PDF as a string.
The options parameter controls the output. Accepted options are:
'compress' = > 1 or 0 - apply content stream compression, this is
on (1) by default
@param array $options options (see above)
@return string|null | [
"Returns",
"the",
"PDF",
"as",
"a",
"string",
"."
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Dompdf.php#L955-L969 | train | Outputs the image | [
30522,
2270,
3853,
6434,
1006,
1002,
7047,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
3828,
4135,
9289,
2063,
1006,
1007,
1025,
1002,
10683,
1027,
1002,
2023,
1011,
1028,
2131,
9336,
12044,
1006,
1007,
1025,
2065,
1006,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Http/UploadedFile.php | UploadedFile.storeAs | public function storeAs($path, $name, $options = [])
{
$options = $this->parseOptions($options);
$disk = Arr::pull($options, 'disk');
return Container::getInstance()->make(FilesystemFactory::class)->disk($disk)->putFileAs(
$path, $this, $name, $options
);
} | php | public function storeAs($path, $name, $options = [])
{
$options = $this->parseOptions($options);
$disk = Arr::pull($options, 'disk');
return Container::getInstance()->make(FilesystemFactory::class)->disk($disk)->putFileAs(
$path, $this, $name, $options
);
} | [
"public",
"function",
"storeAs",
"(",
"$",
"path",
",",
"$",
"name",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"parseOptions",
"(",
"$",
"options",
")",
";",
"$",
"disk",
"=",
"Arr",
"::",
"pull",
"(",
... | Store the uploaded file on a filesystem disk.
@param string $path
@param string $name
@param array|string $options
@return string|false | [
"Store",
"the",
"uploaded",
"file",
"on",
"a",
"filesystem",
"disk",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/UploadedFile.php#L79-L88 | train | Store the file to the specified path and name. | [
30522,
2270,
3853,
3573,
3022,
1006,
1002,
4130,
1010,
1002,
2171,
1010,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
1002,
7047,
1027,
1002,
2023,
1011,
1028,
11968,
3366,
7361,
9285,
1006,
1002,
7047,
1007,
1025,
1002,
9785,
1027,
12098,
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/Form/Extension/Core/Type/MoneyType.php | MoneyType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->addViewTransformer(new MoneyToLocalizedStringTransformer(
$options['scale'],
$options['grouping'],
$options['rounding_mode'],
$options['divisor']
))
;
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->addViewTransformer(new MoneyToLocalizedStringTransformer(
$options['scale'],
$options['grouping'],
$options['rounding_mode'],
$options['divisor']
))
;
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"addViewTransformer",
"(",
"new",
"MoneyToLocalizedStringTransformer",
"(",
"$",
"options",
"[",
"'scale'",
"]",
",",
"$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/MoneyType.php#L29-L39 | train | Adds the view transformers to the form builder | [
30522,
2270,
3853,
3857,
14192,
1006,
2433,
8569,
23891,
6657,
3334,
12172,
1002,
12508,
1010,
9140,
1002,
7047,
1007,
1063,
1002,
12508,
1011,
1028,
5587,
8584,
6494,
3619,
14192,
2121,
1006,
2047,
2769,
3406,
4135,
9289,
3550,
3367,
4892,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/twig/Loader.php | Loader.getFilename | public function getFilename($name)
{
if (!$this->validateCmsObject($name)) {
return parent::getFilename($name);
}
return $this->obj->getFilePath();
} | php | public function getFilename($name)
{
if (!$this->validateCmsObject($name)) {
return parent::getFilename($name);
}
return $this->obj->getFilePath();
} | [
"public",
"function",
"getFilename",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateCmsObject",
"(",
"$",
"name",
")",
")",
"{",
"return",
"parent",
"::",
"getFilename",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",... | Returns the file name of the loaded template. | [
"Returns",
"the",
"file",
"name",
"of",
"the",
"loaded",
"template",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/twig/Loader.php#L93-L100 | train | Returns the filename of the file | [
30522,
2270,
3853,
2131,
8873,
20844,
4168,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
9398,
3686,
27487,
6499,
2497,
20614,
1006,
1002,
2171,
1007,
1007,
1063,
2709,
6687,
1024,
1024,
2131,
8873,
20844,
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... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select.limit | public function limit($count = null, $offset = null)
{
$this->_parts[self::LIMIT_COUNT] = (int) $count;
$this->_parts[self::LIMIT_OFFSET] = (int) $offset;
return $this;
} | php | public function limit($count = null, $offset = null)
{
$this->_parts[self::LIMIT_COUNT] = (int) $count;
$this->_parts[self::LIMIT_OFFSET] = (int) $offset;
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"count",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_parts",
"[",
"self",
"::",
"LIMIT_COUNT",
"]",
"=",
"(",
"int",
")",
"$",
"count",
";",
"$",
"this",
"->",
"_parts",
"[... | Sets a limit count and offset to the query.
@param int $count OPTIONAL The number of rows to return.
@param int $offset OPTIONAL Start returning after this many rows.
@return Zend_Db_Select This Zend_Db_Select object. | [
"Sets",
"a",
"limit",
"count",
"and",
"offset",
"to",
"the",
"query",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L621-L626 | train | Limit the result set | [
30522,
2270,
3853,
5787,
1006,
1002,
4175,
1027,
19701,
1010,
1002,
16396,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
3033,
1031,
2969,
1024,
1024,
5787,
1035,
4175,
1033,
1027,
1006,
20014,
1007,
1002,
4175,
1025,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Installation/ServerFilesGenerator.php | ServerFilesGenerator.createWebConfigFiles | protected static function createWebConfigFiles()
{
if (!SettingsServer::isIIS()) {
return;
}
@file_put_contents(PIWIK_INCLUDE_PATH . '/web.config',
'<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="config" />
<add segment="core" />
<add segment="lang" />
<add segment="tmp" />
</hiddenSegments>
<fileExtensions>
<add fileExtension=".tpl" allowed="false" />
<add fileExtension=".twig" allowed="false" />
<add fileExtension=".php4" allowed="false" />
<add fileExtension=".php5" allowed="false" />
<add fileExtension=".inc" allowed="false" />
<add fileExtension=".in" allowed="false" />
<add fileExtension=".csv" allowed="false" />
<add fileExtension=".pdf" allowed="false" />
<add fileExtension=".log" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<remove value="index.php" />
<add value="index.php" />
</files>
</defaultDocument>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
</configuration>');
// deny direct access to .php files
$directoriesToProtect = array(
'/libs',
'/vendor',
'/plugins',
);
foreach ($directoriesToProtect as $directoryToProtect) {
@file_put_contents(PIWIK_INCLUDE_PATH . $directoryToProtect . '/web.config',
'<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence=".php" />
</denyUrlSequences>
</requestFiltering>
</security>
</system.webServer>
</configuration>');
}
} | php | protected static function createWebConfigFiles()
{
if (!SettingsServer::isIIS()) {
return;
}
@file_put_contents(PIWIK_INCLUDE_PATH . '/web.config',
'<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="config" />
<add segment="core" />
<add segment="lang" />
<add segment="tmp" />
</hiddenSegments>
<fileExtensions>
<add fileExtension=".tpl" allowed="false" />
<add fileExtension=".twig" allowed="false" />
<add fileExtension=".php4" allowed="false" />
<add fileExtension=".php5" allowed="false" />
<add fileExtension=".inc" allowed="false" />
<add fileExtension=".in" allowed="false" />
<add fileExtension=".csv" allowed="false" />
<add fileExtension=".pdf" allowed="false" />
<add fileExtension=".log" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<remove value="index.php" />
<add value="index.php" />
</files>
</defaultDocument>
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
</configuration>');
// deny direct access to .php files
$directoriesToProtect = array(
'/libs',
'/vendor',
'/plugins',
);
foreach ($directoriesToProtect as $directoryToProtect) {
@file_put_contents(PIWIK_INCLUDE_PATH . $directoryToProtect . '/web.config',
'<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<denyUrlSequences>
<add sequence=".php" />
</denyUrlSequences>
</requestFiltering>
</security>
</system.webServer>
</configuration>');
}
} | [
"protected",
"static",
"function",
"createWebConfigFiles",
"(",
")",
"{",
"if",
"(",
"!",
"SettingsServer",
"::",
"isIIS",
"(",
")",
")",
"{",
"return",
";",
"}",
"@",
"file_put_contents",
"(",
"PIWIK_INCLUDE_PATH",
".",
"'/web.config'",
",",
"'<?xml version=\"1... | Generate IIS web.config files to restrict access
Note: for IIS 7 and above | [
"Generate",
"IIS",
"web",
".",
"config",
"files",
"to",
"restrict",
"access"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/ServerFilesGenerator.php#L111-L178 | train | Create the web. config files | [
30522,
5123,
10763,
3853,
3443,
8545,
9818,
2239,
8873,
25708,
9463,
2015,
1006,
1007,
1063,
2065,
1006,
999,
10906,
8043,
6299,
1024,
1024,
2003,
6137,
2015,
1006,
1007,
1007,
1063,
2709,
1025,
1065,
1030,
5371,
1035,
2404,
1035,
8417,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/EventDispatcher/EventDispatcher.php | EventDispatcher.getListeners | public function getListeners($eventName = null)
{
if (null !== $eventName) {
if (empty($this->listeners[$eventName])) {
return [];
}
if (!isset($this->sorted[$eventName])) {
$this->sortListeners($eventName);
}
return $this->sorted[$eventName];
}
foreach ($this->listeners as $eventName => $eventListeners) {
if (!isset($this->sorted[$eventName])) {
$this->sortListeners($eventName);
}
}
return array_filter($this->sorted);
} | php | public function getListeners($eventName = null)
{
if (null !== $eventName) {
if (empty($this->listeners[$eventName])) {
return [];
}
if (!isset($this->sorted[$eventName])) {
$this->sortListeners($eventName);
}
return $this->sorted[$eventName];
}
foreach ($this->listeners as $eventName => $eventListeners) {
if (!isset($this->sorted[$eventName])) {
$this->sortListeners($eventName);
}
}
return array_filter($this->sorted);
} | [
"public",
"function",
"getListeners",
"(",
"$",
"eventName",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"eventName",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"eventName",
"]",
")",
")",
"{",
"return",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/EventDispatcher/EventDispatcher.php#L84-L105 | train | Get all listeners for an event | [
30522,
2270,
3853,
2131,
9863,
24454,
2015,
1006,
1002,
2724,
18442,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2724,
18442,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
2023,
1011,
1028,
13810,
1031,
1002,
2724,
18442,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Auth/Access/Gate.php | Gate.parameterAllowsGuests | protected function parameterAllowsGuests($parameter)
{
return ($parameter->getClass() && $parameter->allowsNull()) ||
($parameter->isDefaultValueAvailable() && is_null($parameter->getDefaultValue()));
} | php | protected function parameterAllowsGuests($parameter)
{
return ($parameter->getClass() && $parameter->allowsNull()) ||
($parameter->isDefaultValueAvailable() && is_null($parameter->getDefaultValue()));
} | [
"protected",
"function",
"parameterAllowsGuests",
"(",
"$",
"parameter",
")",
"{",
"return",
"(",
"$",
"parameter",
"->",
"getClass",
"(",
")",
"&&",
"$",
"parameter",
"->",
"allowsNull",
"(",
")",
")",
"||",
"(",
"$",
"parameter",
"->",
"isDefaultValueAvail... | Determine if the given parameter allows guests.
@param \ReflectionParameter $parameter
@return bool | [
"Determine",
"if",
"the",
"given",
"parameter",
"allows",
"guests",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Access/Gate.php#L434-L438 | train | Returns true if the parameter allows guests | [
30522,
5123,
3853,
16381,
8095,
15568,
22967,
3215,
1006,
1002,
16381,
1007,
1063,
2709,
1006,
1002,
16381,
1011,
1028,
2131,
26266,
1006,
1007,
1004,
1004,
1002,
16381,
1011,
1028,
4473,
11231,
3363,
1006,
1007,
1007,
1064,
1064,
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... |
symfony/symfony | src/Symfony/Component/Cache/Traits/ArrayTrait.php | ArrayTrait.deleteItem | public function deleteItem($key)
{
if (!\is_string($key) || !isset($this->expiries[$key])) {
CacheItem::validateKey($key);
}
unset($this->values[$key], $this->expiries[$key]);
return true;
} | php | public function deleteItem($key)
{
if (!\is_string($key) || !isset($this->expiries[$key])) {
CacheItem::validateKey($key);
}
unset($this->values[$key], $this->expiries[$key]);
return true;
} | [
"public",
"function",
"deleteItem",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"key",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"expiries",
"[",
"$",
"key",
"]",
")",
")",
"{",
"CacheItem",
"::",
"validateKey",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/ArrayTrait.php#L80-L88 | train | Delete an item from the cache | [
30522,
2270,
3853,
3972,
12870,
4221,
2213,
1006,
1002,
3145,
1007,
1063,
2065,
1006,
999,
1032,
2003,
1035,
5164,
1006,
1002,
3145,
1007,
1064,
1064,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
4654,
8197,
5134,
1031,
1002,
3145,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Model.php | Model.newFromBuilder | public function newFromBuilder($attributes = [], $connection = null)
{
$model = $this->newInstance([], true);
$model->setRawAttributes((array) $attributes, true);
$model->setConnection($connection ?: $this->getConnectionName());
$model->fireModelEvent('retrieved', false);
return $model;
} | php | public function newFromBuilder($attributes = [], $connection = null)
{
$model = $this->newInstance([], true);
$model->setRawAttributes((array) $attributes, true);
$model->setConnection($connection ?: $this->getConnectionName());
$model->fireModelEvent('retrieved', false);
return $model;
} | [
"public",
"function",
"newFromBuilder",
"(",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"connection",
"=",
"null",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"newInstance",
"(",
"[",
"]",
",",
"true",
")",
";",
"$",
"model",
"->",
"setRawAttrib... | Create a new model instance that is existing.
@param array $attributes
@param string|null $connection
@return static | [
"Create",
"a",
"new",
"model",
"instance",
"that",
"is",
"existing",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Model.php#L408-L419 | train | Create a new model from the builder | [
30522,
2270,
3853,
2047,
19699,
5358,
8569,
23891,
2099,
1006,
1002,
12332,
1027,
1031,
1033,
1010,
1002,
4434,
1027,
19701,
1007,
1063,
1002,
2944,
1027,
1002,
2023,
1011,
1028,
2047,
7076,
26897,
1006,
1031,
1033,
1010,
2995,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php | PhpBundleWriter.write | public function write($path, $locale, $data)
{
$template = <<<'TEMPLATE'
<?php
return %s;
TEMPLATE;
if ($data instanceof \Traversable) {
$data = iterator_to_array($data);
}
array_walk_recursive($data, function (&$value) {
if ($value instanceof \Traversable) {
$value = iterator_to_array($value);
}
});
$data = var_export($data, true);
$data = preg_replace('/array \(/', '[', $data);
$data = preg_replace('/\n {1,10}\[/', '[', $data);
$data = preg_replace('/ /', ' ', $data);
$data = preg_replace('/\),$/m', '],', $data);
$data = preg_replace('/\)$/', ']', $data);
$data = sprintf($template, $data);
file_put_contents($path.'/'.$locale.'.php', $data);
} | php | public function write($path, $locale, $data)
{
$template = <<<'TEMPLATE'
<?php
return %s;
TEMPLATE;
if ($data instanceof \Traversable) {
$data = iterator_to_array($data);
}
array_walk_recursive($data, function (&$value) {
if ($value instanceof \Traversable) {
$value = iterator_to_array($value);
}
});
$data = var_export($data, true);
$data = preg_replace('/array \(/', '[', $data);
$data = preg_replace('/\n {1,10}\[/', '[', $data);
$data = preg_replace('/ /', ' ', $data);
$data = preg_replace('/\),$/m', '],', $data);
$data = preg_replace('/\)$/', ']', $data);
$data = sprintf($template, $data);
file_put_contents($path.'/'.$locale.'.php', $data);
} | [
"public",
"function",
"write",
"(",
"$",
"path",
",",
"$",
"locale",
",",
"$",
"data",
")",
"{",
"$",
"template",
"=",
" <<<'TEMPLATE'\n<?php\n\nreturn %s;\n\nTEMPLATE",
";",
"if",
"(",
"$",
"data",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"data",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php#L26-L54 | train | Write the language data to the file | [
30522,
2270,
3853,
4339,
1006,
1002,
4130,
1010,
1002,
2334,
2063,
1010,
1002,
2951,
1007,
1063,
1002,
23561,
1027,
1026,
1026,
1026,
1005,
23561,
1005,
1026,
1029,
25718,
2709,
1003,
1055,
1025,
23561,
1025,
2065,
1006,
1002,
2951,
6013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.whereYear | public function whereYear($column, $operator, $value = null, $boolean = 'and')
{
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
if ($value instanceof DateTimeInterface) {
$value = $value->format('Y');
}
return $this->addDateBasedWhere('Year', $column, $operator, $value, $boolean);
} | php | public function whereYear($column, $operator, $value = null, $boolean = 'and')
{
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);
if ($value instanceof DateTimeInterface) {
$value = $value->format('Y');
}
return $this->addDateBasedWhere('Year', $column, $operator, $value, $boolean);
} | [
"public",
"function",
"whereYear",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
",",
"$",
"boolean",
"=",
"'and'",
")",
"{",
"[",
"$",
"value",
",",
"$",
"operator",
"]",
"=",
"$",
"this",
"->",
"prepareValueAndOperator",
... | Add a "where year" statement to the query.
@param string $column
@param string $operator
@param \DateTimeInterface|string|int $value
@param string $boolean
@return \Illuminate\Database\Query\Builder|static | [
"Add",
"a",
"where",
"year",
"statement",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L1273-L1284 | train | Add a where year statement to the query. | [
30522,
2270,
3853,
2073,
29100,
1006,
1002,
5930,
1010,
1002,
6872,
1010,
1002,
3643,
1027,
19701,
1010,
1002,
22017,
20898,
1027,
1005,
1998,
1005,
1007,
1063,
1031,
1002,
3643,
1010,
1002,
6872,
1033,
1027,
1002,
2023,
1011,
1028,
7374,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/XliffFileLoader.php | XliffFileLoader.extractXliff1 | private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, string $domain)
{
$xml = simplexml_import_dom($dom);
$encoding = strtoupper($dom->encoding);
$namespace = 'urn:oasis:names:tc:xliff:document:1.2';
$xml->registerXPathNamespace('xliff', $namespace);
foreach ($xml->xpath('//xliff:file') as $file) {
$fileAttributes = $file->attributes();
$file->registerXPathNamespace('xliff', $namespace);
foreach ($file->xpath('.//xliff:trans-unit') as $translation) {
$attributes = $translation->attributes();
if (!(isset($attributes['resname']) || isset($translation->source))) {
continue;
}
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
// If the xlf file has another encoding specified, try to convert it because
// simple_xml will always return utf-8 encoded values
$target = $this->utf8ToCharset((string) ($translation->target ?? $translation->source), $encoding);
$catalogue->set((string) $source, $target, $domain);
$metadata = [
'source' => (string) $translation->source,
'file' => [
'original' => (string) $fileAttributes['original'],
],
];
if ($notes = $this->parseNotesMetadata($translation->note, $encoding)) {
$metadata['notes'] = $notes;
}
if (isset($translation->target) && $translation->target->attributes()) {
$metadata['target-attributes'] = [];
foreach ($translation->target->attributes() as $key => $value) {
$metadata['target-attributes'][$key] = (string) $value;
}
}
if (isset($attributes['id'])) {
$metadata['id'] = (string) $attributes['id'];
}
$catalogue->setMetadata((string) $source, $metadata, $domain);
}
}
} | php | private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, string $domain)
{
$xml = simplexml_import_dom($dom);
$encoding = strtoupper($dom->encoding);
$namespace = 'urn:oasis:names:tc:xliff:document:1.2';
$xml->registerXPathNamespace('xliff', $namespace);
foreach ($xml->xpath('//xliff:file') as $file) {
$fileAttributes = $file->attributes();
$file->registerXPathNamespace('xliff', $namespace);
foreach ($file->xpath('.//xliff:trans-unit') as $translation) {
$attributes = $translation->attributes();
if (!(isset($attributes['resname']) || isset($translation->source))) {
continue;
}
$source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
// If the xlf file has another encoding specified, try to convert it because
// simple_xml will always return utf-8 encoded values
$target = $this->utf8ToCharset((string) ($translation->target ?? $translation->source), $encoding);
$catalogue->set((string) $source, $target, $domain);
$metadata = [
'source' => (string) $translation->source,
'file' => [
'original' => (string) $fileAttributes['original'],
],
];
if ($notes = $this->parseNotesMetadata($translation->note, $encoding)) {
$metadata['notes'] = $notes;
}
if (isset($translation->target) && $translation->target->attributes()) {
$metadata['target-attributes'] = [];
foreach ($translation->target->attributes() as $key => $value) {
$metadata['target-attributes'][$key] = (string) $value;
}
}
if (isset($attributes['id'])) {
$metadata['id'] = (string) $attributes['id'];
}
$catalogue->setMetadata((string) $source, $metadata, $domain);
}
}
} | [
"private",
"function",
"extractXliff1",
"(",
"\\",
"DOMDocument",
"$",
"dom",
",",
"MessageCatalogue",
"$",
"catalogue",
",",
"string",
"$",
"domain",
")",
"{",
"$",
"xml",
"=",
"simplexml_import_dom",
"(",
"$",
"dom",
")",
";",
"$",
"encoding",
"=",
"strt... | Extract messages and metadata from DOMDocument into a MessageCatalogue.
@param \DOMDocument $dom Source to extract messages and metadata
@param MessageCatalogue $catalogue Catalogue where we'll collect messages and metadata
@param string $domain The domain | [
"Extract",
"messages",
"and",
"metadata",
"from",
"DOMDocument",
"into",
"a",
"MessageCatalogue",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Loader/XliffFileLoader.php#L80-L131 | train | Extract Xliff1 - MessageCatalogue | [
30522,
2797,
3853,
14817,
2595,
3669,
4246,
2487,
1006,
1032,
14383,
3527,
24894,
4765,
1002,
14383,
1010,
4471,
11266,
23067,
9077,
1002,
10161,
1010,
5164,
1002,
5884,
1007,
1063,
1002,
20950,
1027,
3722,
2595,
19968,
1035,
12324,
1035,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php | ClassResolverTrait.getClass | private function getClass($value)
{
if (\is_string($value)) {
if (!class_exists($value) && !interface_exists($value, false)) {
throw new InvalidArgumentException(sprintf('The class or interface "%s" does not exist.', $value));
}
return ltrim($value, '\\');
}
if (!\is_object($value)) {
throw new InvalidArgumentException(sprintf('Cannot create metadata for non-objects. Got: "%s"', \gettype($value)));
}
return \get_class($value);
} | php | private function getClass($value)
{
if (\is_string($value)) {
if (!class_exists($value) && !interface_exists($value, false)) {
throw new InvalidArgumentException(sprintf('The class or interface "%s" does not exist.', $value));
}
return ltrim($value, '\\');
}
if (!\is_object($value)) {
throw new InvalidArgumentException(sprintf('Cannot create metadata for non-objects. Got: "%s"', \gettype($value)));
}
return \get_class($value);
} | [
"private",
"function",
"getClass",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"value",
")",
"&&",
"!",
"interface_exists",
"(",
"$",
"value",
",",
"false",
... | Gets a class name for a given class or instance.
@param mixed $value
@return string
@throws InvalidArgumentException If the class does not exists | [
"Gets",
"a",
"class",
"name",
"for",
"a",
"given",
"class",
"or",
"instance",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Mapping/Factory/ClassResolverTrait.php#L34-L49 | train | Get the class name of the object | [
30522,
2797,
3853,
2131,
26266,
1006,
1002,
3643,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
5164,
1006,
1002,
3643,
1007,
1007,
1063,
2065,
1006,
999,
2465,
1035,
6526,
1006,
1002,
3643,
1007,
1004,
1004,
999,
8278,
1035,
6526,
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... |
octobercms/october | modules/backend/widgets/Form.php | Form.addFields | public function addFields(array $fields, $addToArea = null)
{
foreach ($fields as $name => $config) {
$fieldObj = $this->makeFormField($name, $config);
$fieldTab = is_array($config) ? array_get($config, 'tab') : null;
/*
* Check that the form field matches the active context
*/
if ($fieldObj->context !== null) {
$context = is_array($fieldObj->context) ? $fieldObj->context : [$fieldObj->context];
if (!in_array($this->getContext(), $context)) {
continue;
}
}
$this->allFields[$name] = $fieldObj;
switch (strtolower($addToArea)) {
case FormTabs::SECTION_PRIMARY:
$this->allTabs->primary->addField($name, $fieldObj, $fieldTab);
break;
case FormTabs::SECTION_SECONDARY:
$this->allTabs->secondary->addField($name, $fieldObj, $fieldTab);
break;
default:
$this->allTabs->outside->addField($name, $fieldObj);
break;
}
}
} | php | public function addFields(array $fields, $addToArea = null)
{
foreach ($fields as $name => $config) {
$fieldObj = $this->makeFormField($name, $config);
$fieldTab = is_array($config) ? array_get($config, 'tab') : null;
/*
* Check that the form field matches the active context
*/
if ($fieldObj->context !== null) {
$context = is_array($fieldObj->context) ? $fieldObj->context : [$fieldObj->context];
if (!in_array($this->getContext(), $context)) {
continue;
}
}
$this->allFields[$name] = $fieldObj;
switch (strtolower($addToArea)) {
case FormTabs::SECTION_PRIMARY:
$this->allTabs->primary->addField($name, $fieldObj, $fieldTab);
break;
case FormTabs::SECTION_SECONDARY:
$this->allTabs->secondary->addField($name, $fieldObj, $fieldTab);
break;
default:
$this->allTabs->outside->addField($name, $fieldObj);
break;
}
}
} | [
"public",
"function",
"addFields",
"(",
"array",
"$",
"fields",
",",
"$",
"addToArea",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"name",
"=>",
"$",
"config",
")",
"{",
"$",
"fieldObj",
"=",
"$",
"this",
"->",
"makeFormField",
"... | Programatically add fields, used internally and for extensibility.
@param array $fields
@param string $addToArea
@return void | [
"Programatically",
"add",
"fields",
"used",
"internally",
"and",
"for",
"extensibility",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Form.php#L679-L710 | train | Add form fields to the form | [
30522,
2270,
3853,
5587,
15155,
1006,
9140,
1002,
4249,
1010,
1002,
5587,
3406,
12069,
2050,
30524,
4249,
2004,
1002,
2171,
1027,
1028,
1002,
9530,
8873,
2290,
1007,
1063,
1002,
2492,
16429,
3501,
1027,
1002,
2023,
1011,
1028,
2191,
14192,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Data/Validation.php | Validation.typeUrl | public static function typeUrl($value, array $params, array $field)
{
return self::typeText($value, $params, $field) && filter_var($value, FILTER_VALIDATE_URL);
} | php | public static function typeUrl($value, array $params, array $field)
{
return self::typeText($value, $params, $field) && filter_var($value, FILTER_VALIDATE_URL);
} | [
"public",
"static",
"function",
"typeUrl",
"(",
"$",
"value",
",",
"array",
"$",
"params",
",",
"array",
"$",
"field",
")",
"{",
"return",
"self",
"::",
"typeText",
"(",
"$",
"value",
",",
"$",
"params",
",",
"$",
"field",
")",
"&&",
"filter_var",
"(... | HTML5 input: url
@param mixed $value Value to be validated.
@param array $params Validation parameters.
@param array $field Blueprint for the field.
@return bool True if validation succeeded. | [
"HTML5",
"input",
":",
"url"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Data/Validation.php#L434-L437 | train | Type a value to a URL | [
30522,
2270,
10763,
3853,
2828,
3126,
2140,
1006,
1002,
3643,
1010,
9140,
1002,
11498,
5244,
1010,
9140,
1002,
2492,
1007,
1063,
2709,
2969,
1024,
1024,
2828,
18209,
1006,
1002,
3643,
1010,
1002,
11498,
5244,
1010,
1002,
2492,
1007,
1004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Handlers/AbstractError.php | AbstractError.writeToErrorLog | protected function writeToErrorLog($throwable)
{
if ($this->displayErrorDetails) {
return;
}
$message = 'Slim Application Error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
while ($throwable = $throwable->getPrevious()) {
$message .= PHP_EOL . 'Previous error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
}
$message .= PHP_EOL . 'View in rendered output by enabling the "displayErrorDetails" setting.' . PHP_EOL;
$this->logError($message);
} | php | protected function writeToErrorLog($throwable)
{
if ($this->displayErrorDetails) {
return;
}
$message = 'Slim Application Error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
while ($throwable = $throwable->getPrevious()) {
$message .= PHP_EOL . 'Previous error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
}
$message .= PHP_EOL . 'View in rendered output by enabling the "displayErrorDetails" setting.' . PHP_EOL;
$this->logError($message);
} | [
"protected",
"function",
"writeToErrorLog",
"(",
"$",
"throwable",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"displayErrorDetails",
")",
"{",
"return",
";",
"}",
"$",
"message",
"=",
"'Slim Application Error:'",
".",
"PHP_EOL",
";",
"$",
"message",
".=",
"$",
... | Write to the error log if displayErrorDetails is false
@param Exception|Throwable $throwable
@return void | [
"Write",
"to",
"the",
"error",
"log",
"if",
"displayErrorDetails",
"is",
"false"
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Handlers/AbstractError.php#L35-L51 | train | Write the throwable to the error log | [
30522,
5123,
3853,
4339,
3406,
2121,
29165,
21197,
1006,
1002,
5466,
3085,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
4653,
2121,
29165,
3207,
22081,
1007,
1063,
2709,
1025,
1065,
1002,
4471,
1027,
1005,
11754,
4646,
7561,
1024,
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/Serializer/Encoder/ChainDecoder.php | ChainDecoder.decode | final public function decode($data, $format, array $context = [])
{
return $this->getDecoder($format, $context)->decode($data, $format, $context);
} | php | final public function decode($data, $format, array $context = [])
{
return $this->getDecoder($format, $context)->decode($data, $format, $context);
} | [
"final",
"public",
"function",
"decode",
"(",
"$",
"data",
",",
"$",
"format",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getDecoder",
"(",
"$",
"format",
",",
"$",
"context",
")",
"->",
"decode",
"(",
"$",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php#L38-L41 | train | Decodes the data into a DOMDocument | [
30522,
2345,
2270,
3853,
21933,
3207,
1006,
1002,
2951,
1010,
1002,
4289,
1010,
9140,
1002,
6123,
1027,
1031,
1033,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2131,
3207,
16044,
2099,
1006,
1002,
4289,
1010,
1002,
6123,
1007,
1011,
1028,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Console/Scheduling/CacheEventMutex.php | CacheEventMutex.create | public function create(Event $event)
{
return $this->cache->store($this->store)->add(
$event->mutexName(), true, $event->expiresAt * 60
);
} | php | public function create(Event $event)
{
return $this->cache->store($this->store)->add(
$event->mutexName(), true, $event->expiresAt * 60
);
} | [
"public",
"function",
"create",
"(",
"Event",
"$",
"event",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"->",
"store",
"(",
"$",
"this",
"->",
"store",
")",
"->",
"add",
"(",
"$",
"event",
"->",
"mutexName",
"(",
")",
",",
"true",
",",
"$",
"... | Attempt to obtain an event mutex for the given event.
@param \Illuminate\Console\Scheduling\Event $event
@return bool | [
"Attempt",
"to",
"obtain",
"an",
"event",
"mutex",
"for",
"the",
"given",
"event",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Console/Scheduling/CacheEventMutex.php#L40-L45 | train | Create a new entry in the cache | [
30522,
2270,
3853,
3443,
1006,
2724,
1002,
2724,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
17053,
1011,
1028,
3573,
1006,
1002,
2023,
1011,
1028,
3573,
1007,
1011,
1028,
5587,
1006,
1002,
2724,
1011,
1028,
20101,
2595,
18442,
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... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Extension/Extension.php | Extension.getConfiguration | public function getConfiguration(array $config, ContainerBuilder $container)
{
$class = \get_class($this);
$class = substr_replace($class, '\Configuration', strrpos($class, '\\'));
$class = $container->getReflectionClass($class);
if (!$class) {
return null;
}
if (!$class->implementsInterface(ConfigurationInterface::class)) {
@trigger_error(sprintf('Not implementing "%s" in the extension configuration class "%s" is deprecated since Symfony 4.1.', ConfigurationInterface::class, $class->getName()), E_USER_DEPRECATED);
//throw new LogicException(sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class));
return null;
}
if (!($constructor = $class->getConstructor()) || !$constructor->getNumberOfRequiredParameters()) {
return $class->newInstance();
}
return null;
} | php | public function getConfiguration(array $config, ContainerBuilder $container)
{
$class = \get_class($this);
$class = substr_replace($class, '\Configuration', strrpos($class, '\\'));
$class = $container->getReflectionClass($class);
if (!$class) {
return null;
}
if (!$class->implementsInterface(ConfigurationInterface::class)) {
@trigger_error(sprintf('Not implementing "%s" in the extension configuration class "%s" is deprecated since Symfony 4.1.', ConfigurationInterface::class, $class->getName()), E_USER_DEPRECATED);
//throw new LogicException(sprintf('The extension configuration class "%s" must implement "%s".', $class->getName(), ConfigurationInterface::class));
return null;
}
if (!($constructor = $class->getConstructor()) || !$constructor->getNumberOfRequiredParameters()) {
return $class->newInstance();
}
return null;
} | [
"public",
"function",
"getConfiguration",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"class",
"=",
"\\",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"class",
"=",
"substr_replace",
"(",
"$",
"class",
",",
"'\... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Extension/Extension.php#L80-L102 | train | Returns the configuration for the extension. | [
30522,
2270,
3853,
2131,
8663,
8873,
27390,
3370,
1006,
9140,
1002,
9530,
8873,
2290,
1010,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
1002,
2465,
1027,
1032,
2131,
1035,
2465,
1006,
1002,
2023,
1007,
1025,
1002,
2465,
1027,
4942,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Select.php | Zend_Db_Select._getQuotedSchema | protected function _getQuotedSchema($schema = null)
{
if ($schema === null) {
return null;
}
return $this->_adapter->quoteIdentifier($schema, true) . '.';
} | php | protected function _getQuotedSchema($schema = null)
{
if ($schema === null) {
return null;
}
return $this->_adapter->quoteIdentifier($schema, true) . '.';
} | [
"protected",
"function",
"_getQuotedSchema",
"(",
"$",
"schema",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"schema",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"_adapter",
"->",
"quoteIdentifier",
"(",
"$",
"schema",
... | Return a quoted schema name
@param string $schema The schema name OPTIONAL
@return string|null | [
"Return",
"a",
"quoted",
"schema",
"name"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Select.php#L1029-L1035 | train | Returns a quoted version of a schema identifier | [
30522,
5123,
3853,
1035,
2131,
28940,
27428,
22842,
2863,
1006,
1002,
8040,
28433,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
8040,
28433,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
19701,
1025,
1065,
2709,
1002,
2023,
1011,
1028,
1035,
155... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Application.php | Application.renderException | public function renderException(\Exception $e, OutputInterface $output)
{
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
$this->doRenderException($e, $output);
if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
}
} | php | public function renderException(\Exception $e, OutputInterface $output)
{
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
$this->doRenderException($e, $output);
if (null !== $this->runningCommand) {
$output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
}
} | [
"public",
"function",
"renderException",
"(",
"\\",
"Exception",
"$",
"e",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"''",
",",
"OutputInterface",
"::",
"VERBOSITY_QUIET",
")",
";",
"$",
"this",
"->",
"doRenderExce... | Renders a caught exception. | [
"Renders",
"a",
"caught",
"exception",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Application.php#L750-L760 | train | Render exception to output | [
30522,
2270,
3853,
17552,
10288,
24422,
1006,
1032,
6453,
1002,
1041,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
1002,
6434,
1011,
1028,
4339,
19666,
1006,
1005,
1005,
1010,
6434,
18447,
2121,
12172,
1024,
1024,
12034,
25949,
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/Session.php | Zend_Session.rememberUntil | public static function rememberUntil($seconds = 0)
{
if (self::$_unitTestEnabled) {
self::regenerateId();
return;
}
$cookieParams = session_get_cookie_params();
session_set_cookie_params(
$seconds,
$cookieParams['path'],
$cookieParams['domain'],
$cookieParams['secure']
);
// normally "rememberMe()" represents a security context change, so should use new session id
self::regenerateId();
} | php | public static function rememberUntil($seconds = 0)
{
if (self::$_unitTestEnabled) {
self::regenerateId();
return;
}
$cookieParams = session_get_cookie_params();
session_set_cookie_params(
$seconds,
$cookieParams['path'],
$cookieParams['domain'],
$cookieParams['secure']
);
// normally "rememberMe()" represents a security context change, so should use new session id
self::regenerateId();
} | [
"public",
"static",
"function",
"rememberUntil",
"(",
"$",
"seconds",
"=",
"0",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_unitTestEnabled",
")",
"{",
"self",
"::",
"regenerateId",
"(",
")",
";",
"return",
";",
"}",
"$",
"cookieParams",
"=",
"session_get_... | rememberUntil() - This method does the work of changing the state of the session cookie and making
sure that it gets resent to the browser via regenerateId()
@param int $seconds
@return void | [
"rememberUntil",
"()",
"-",
"This",
"method",
"does",
"the",
"work",
"of",
"changing",
"the",
"state",
"of",
"the",
"session",
"cookie",
"and",
"making",
"sure",
"that",
"it",
"gets",
"resent",
"to",
"the",
"browser",
"via",
"regenerateId",
"()"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Session.php#L358-L376 | train | rememberUntil - Sets the session cookie to the current time | [
30522,
2270,
10763,
3853,
3342,
16671,
4014,
1006,
1002,
3823,
1027,
1014,
1007,
1063,
2065,
1006,
2969,
1024,
1024,
1002,
1035,
3131,
22199,
8189,
23242,
1007,
1063,
2969,
1024,
1024,
19723,
24454,
3686,
3593,
1006,
1007,
1025,
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... |
matomo-org/matomo | libs/Zend/Db/Table/Select.php | Zend_Db_Table_Select.from | public function from($name, $cols = self::SQL_WILDCARD, $schema = null)
{
if ($name instanceof Zend_Db_Table_Abstract) {
$info = $name->info();
$name = $info[Zend_Db_Table_Abstract::NAME];
if (isset($info[Zend_Db_Table_Abstract::SCHEMA])) {
$schema = $info[Zend_Db_Table_Abstract::SCHEMA];
}
}
return $this->joinInner($name, null, $cols, $schema);
} | php | public function from($name, $cols = self::SQL_WILDCARD, $schema = null)
{
if ($name instanceof Zend_Db_Table_Abstract) {
$info = $name->info();
$name = $info[Zend_Db_Table_Abstract::NAME];
if (isset($info[Zend_Db_Table_Abstract::SCHEMA])) {
$schema = $info[Zend_Db_Table_Abstract::SCHEMA];
}
}
return $this->joinInner($name, null, $cols, $schema);
} | [
"public",
"function",
"from",
"(",
"$",
"name",
",",
"$",
"cols",
"=",
"self",
"::",
"SQL_WILDCARD",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"instanceof",
"Zend_Db_Table_Abstract",
")",
"{",
"$",
"info",
"=",
"$",
"name",
"... | Adds a FROM table and optional columns to the query.
The table name can be expressed
@param array|string|Zend_Db_Expr|Zend_Db_Table_Abstract $name The table name or an
associative array relating
table name to correlation
name.
@param array|string|Zend_Db_Expr $cols The columns to select from this table.
@param string $schema The schema name to specify, if any.
@return Zend_Db_Table_Select This Zend_Db_Table_Select object. | [
"Adds",
"a",
"FROM",
"table",
"and",
"optional",
"columns",
"to",
"the",
"query",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Select.php#L171-L182 | train | Create a JOIN statement from a Zend_Db_Table_Abstract object | [
30522,
2270,
3853,
2013,
1006,
1002,
2171,
1010,
1002,
8902,
2015,
1027,
2969,
1024,
1024,
29296,
1035,
3748,
11522,
1010,
1002,
8040,
28433,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2171,
6013,
11253,
16729,
2094,
1035,
16962,
1035,
2795... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.whereInExistingQuery | protected function whereInExistingQuery($column, $query, $boolean, $not)
{
$type = $not ? 'NotInSub' : 'InSub';
$this->wheres[] = compact('type', 'column', 'query', 'boolean');
$this->addBinding($query->getBindings(), 'where');
return $this;
} | php | protected function whereInExistingQuery($column, $query, $boolean, $not)
{
$type = $not ? 'NotInSub' : 'InSub';
$this->wheres[] = compact('type', 'column', 'query', 'boolean');
$this->addBinding($query->getBindings(), 'where');
return $this;
} | [
"protected",
"function",
"whereInExistingQuery",
"(",
"$",
"column",
",",
"$",
"query",
",",
"$",
"boolean",
",",
"$",
"not",
")",
"{",
"$",
"type",
"=",
"$",
"not",
"?",
"'NotInSub'",
":",
"'InSub'",
";",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
... | Add an external sub-select to the query.
@param string $column
@param \Illuminate\Database\Query\Builder|static $query
@param string $boolean
@param bool $not
@return $this | [
"Add",
"an",
"external",
"sub",
"-",
"select",
"to",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L946-L955 | train | Adds a where in existing query to the list of where clauses | [
30522,
5123,
3853,
16726,
10288,
2923,
2075,
4226,
2854,
1006,
1002,
5930,
1010,
1002,
23032,
1010,
1002,
22017,
20898,
1010,
1002,
2025,
30524,
1005,
1007,
1025,
1002,
2023,
1011,
1028,
5587,
8428,
4667,
1006,
1002,
23032,
1011,
1028,
2131... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php | AbstractDoctrineExtension.registerMappingDrivers | protected function registerMappingDrivers($objectManager, ContainerBuilder $container)
{
// configure metadata driver for each bundle based on the type of mapping files found
if ($container->hasDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'))) {
$chainDriverDef = $container->getDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'));
} else {
$chainDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.driver_chain.class%'));
$chainDriverDef->setPublic(false);
}
foreach ($this->drivers as $driverType => $driverPaths) {
$mappingService = $this->getObjectManagerElementName($objectManager['name'].'_'.$driverType.'_metadata_driver');
if ($container->hasDefinition($mappingService)) {
$mappingDriverDef = $container->getDefinition($mappingService);
$args = $mappingDriverDef->getArguments();
if ('annotation' == $driverType) {
$args[1] = array_merge(array_values($driverPaths), $args[1]);
} else {
$args[0] = array_merge(array_values($driverPaths), $args[0]);
}
$mappingDriverDef->setArguments($args);
} elseif ('annotation' == $driverType) {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
array_values($driverPaths),
]);
} else {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
array_values($driverPaths),
]);
}
$mappingDriverDef->setPublic(false);
if (false !== strpos($mappingDriverDef->getClass(), 'yml') || false !== strpos($mappingDriverDef->getClass(), 'xml')) {
$mappingDriverDef->setArguments([array_flip($driverPaths)]);
$mappingDriverDef->addMethodCall('setGlobalBasename', ['mapping']);
}
$container->setDefinition($mappingService, $mappingDriverDef);
foreach ($driverPaths as $prefix => $driverPath) {
$chainDriverDef->addMethodCall('addDriver', [new Reference($mappingService), $prefix]);
}
}
$container->setDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'), $chainDriverDef);
} | php | protected function registerMappingDrivers($objectManager, ContainerBuilder $container)
{
// configure metadata driver for each bundle based on the type of mapping files found
if ($container->hasDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'))) {
$chainDriverDef = $container->getDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'));
} else {
$chainDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.driver_chain.class%'));
$chainDriverDef->setPublic(false);
}
foreach ($this->drivers as $driverType => $driverPaths) {
$mappingService = $this->getObjectManagerElementName($objectManager['name'].'_'.$driverType.'_metadata_driver');
if ($container->hasDefinition($mappingService)) {
$mappingDriverDef = $container->getDefinition($mappingService);
$args = $mappingDriverDef->getArguments();
if ('annotation' == $driverType) {
$args[1] = array_merge(array_values($driverPaths), $args[1]);
} else {
$args[0] = array_merge(array_values($driverPaths), $args[0]);
}
$mappingDriverDef->setArguments($args);
} elseif ('annotation' == $driverType) {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
new Reference($this->getObjectManagerElementName('metadata.annotation_reader')),
array_values($driverPaths),
]);
} else {
$mappingDriverDef = new Definition('%'.$this->getObjectManagerElementName('metadata.'.$driverType.'.class%'), [
array_values($driverPaths),
]);
}
$mappingDriverDef->setPublic(false);
if (false !== strpos($mappingDriverDef->getClass(), 'yml') || false !== strpos($mappingDriverDef->getClass(), 'xml')) {
$mappingDriverDef->setArguments([array_flip($driverPaths)]);
$mappingDriverDef->addMethodCall('setGlobalBasename', ['mapping']);
}
$container->setDefinition($mappingService, $mappingDriverDef);
foreach ($driverPaths as $prefix => $driverPath) {
$chainDriverDef->addMethodCall('addDriver', [new Reference($mappingService), $prefix]);
}
}
$container->setDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'), $chainDriverDef);
} | [
"protected",
"function",
"registerMappingDrivers",
"(",
"$",
"objectManager",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"// configure metadata driver for each bundle based on the type of mapping files found",
"if",
"(",
"$",
"container",
"->",
"hasDefinition",
"(",
... | Register all the collected mapping information with the object manager by registering the appropriate mapping drivers.
@param array $objectManager
@param ContainerBuilder $container A ContainerBuilder instance | [
"Register",
"all",
"the",
"collected",
"mapping",
"information",
"with",
"the",
"object",
"manager",
"by",
"registering",
"the",
"appropriate",
"mapping",
"drivers",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php#L178-L223 | train | Registers mapping drivers for the object managers | [
30522,
5123,
3853,
4236,
2863,
14853,
23663,
2869,
1006,
1002,
4874,
24805,
4590,
1010,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
1013,
1013,
9530,
8873,
27390,
2063,
27425,
4062,
2005,
2169,
14012,
2241,
2006,
1996,
2828,
1997,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Notifications/Messages/SimpleMessage.php | SimpleMessage.with | public function with($line)
{
if ($line instanceof Action) {
$this->action($line->text, $line->url);
} elseif (! $this->actionText) {
$this->introLines[] = $this->formatLine($line);
} else {
$this->outroLines[] = $this->formatLine($line);
}
return $this;
} | php | public function with($line)
{
if ($line instanceof Action) {
$this->action($line->text, $line->url);
} elseif (! $this->actionText) {
$this->introLines[] = $this->formatLine($line);
} else {
$this->outroLines[] = $this->formatLine($line);
}
return $this;
} | [
"public",
"function",
"with",
"(",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"line",
"instanceof",
"Action",
")",
"{",
"$",
"this",
"->",
"action",
"(",
"$",
"line",
"->",
"text",
",",
"$",
"line",
"->",
"url",
")",
";",
"}",
"elseif",
"(",
"!",
"... | Add a line of text to the notification.
@param mixed $line
@return $this | [
"Add",
"a",
"line",
"of",
"text",
"to",
"the",
"notification",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Notifications/Messages/SimpleMessage.php#L159-L170 | train | Add a new line to the intro and outro lines | [
30522,
2270,
3853,
2007,
1006,
1002,
2240,
1007,
1063,
2065,
1006,
1002,
2240,
6013,
11253,
2895,
1007,
1063,
1002,
2023,
1011,
1028,
2895,
1006,
1002,
2240,
1011,
1028,
3793,
1010,
1002,
2240,
1011,
1028,
24471,
2140,
1007,
1025,
1065,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Application.php | Application.get | public function get($name)
{
$this->init();
if (!$this->has($name)) {
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
}
$command = $this->commands[$name];
if ($this->wantHelps) {
$this->wantHelps = false;
$helpCommand = $this->get('help');
$helpCommand->setCommand($command);
return $helpCommand;
}
return $command;
} | php | public function get($name)
{
$this->init();
if (!$this->has($name)) {
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
}
$command = $this->commands[$name];
if ($this->wantHelps) {
$this->wantHelps = false;
$helpCommand = $this->get('help');
$helpCommand->setCommand($command);
return $helpCommand;
}
return $command;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"init",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"CommandNotFoundException",
"(",
"sprintf",
"(",
"'The com... | Returns a registered command by name or alias.
@param string $name The command name or alias
@return Command A Command object
@throws CommandNotFoundException When given command name does not exist | [
"Returns",
"a",
"registered",
"command",
"by",
"name",
"or",
"alias",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Application.php#L504-L524 | train | Get the command by name | [
30522,
2270,
3853,
2131,
1006,
1002,
2171,
1007,
1063,
1002,
2023,
1011,
1028,
1999,
4183,
1006,
1007,
1025,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2038,
1006,
1002,
2171,
1007,
1007,
1063,
5466,
2047,
3094,
17048,
14876,
8630,
10288,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
barryvdh/laravel-debugbar | src/LaravelDebugbar.php | LaravelDebugbar.collect | public function collect()
{
/** @var Request $request */
$request = $this->app['request'];
$this->data = [
'__meta' => [
'id' => $this->getCurrentRequestId(),
'datetime' => date('Y-m-d H:i:s'),
'utime' => microtime(true),
'method' => $request->getMethod(),
'uri' => $request->getRequestUri(),
'ip' => $request->getClientIp()
]
];
foreach ($this->collectors as $name => $collector) {
$this->data[$name] = $collector->collect();
}
// Remove all invalid (non UTF-8) characters
array_walk_recursive(
$this->data,
function (&$item) {
if (is_string($item) && !mb_check_encoding($item, 'UTF-8')) {
$item = mb_convert_encoding($item, 'UTF-8', 'UTF-8');
}
}
);
if ($this->storage !== null) {
$this->storage->save($this->getCurrentRequestId(), $this->data);
}
return $this->data;
} | php | public function collect()
{
/** @var Request $request */
$request = $this->app['request'];
$this->data = [
'__meta' => [
'id' => $this->getCurrentRequestId(),
'datetime' => date('Y-m-d H:i:s'),
'utime' => microtime(true),
'method' => $request->getMethod(),
'uri' => $request->getRequestUri(),
'ip' => $request->getClientIp()
]
];
foreach ($this->collectors as $name => $collector) {
$this->data[$name] = $collector->collect();
}
// Remove all invalid (non UTF-8) characters
array_walk_recursive(
$this->data,
function (&$item) {
if (is_string($item) && !mb_check_encoding($item, 'UTF-8')) {
$item = mb_convert_encoding($item, 'UTF-8', 'UTF-8');
}
}
);
if ($this->storage !== null) {
$this->storage->save($this->getCurrentRequestId(), $this->data);
}
return $this->data;
} | [
"public",
"function",
"collect",
"(",
")",
"{",
"/** @var Request $request */",
"$",
"request",
"=",
"$",
"this",
"->",
"app",
"[",
"'request'",
"]",
";",
"$",
"this",
"->",
"data",
"=",
"[",
"'__meta'",
"=>",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"get... | Collects the data from the collectors
@return array | [
"Collects",
"the",
"data",
"from",
"the",
"collectors"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/LaravelDebugbar.php#L798-L833 | train | Collect all data from the collector | [
30522,
2270,
3853,
8145,
1006,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
5227,
1002,
5227,
1008,
1013,
1002,
5227,
1027,
1002,
2023,
1011,
1028,
10439,
1031,
1005,
5227,
1005,
1033,
1025,
1002,
2023,
1011,
1028,
2951,
1027,
1031,
1005,
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/DependencyInjection/Argument/BoundArgument.php | BoundArgument.getValues | public function getValues()
{
return [$this->value, $this->identifier, $this->used, $this->type, $this->file];
} | php | public function getValues()
{
return [$this->value, $this->identifier, $this->used, $this->type, $this->file];
} | [
"public",
"function",
"getValues",
"(",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"value",
",",
"$",
"this",
"->",
"identifier",
",",
"$",
"this",
"->",
"used",
",",
"$",
"this",
"->",
"type",
",",
"$",
"this",
"->",
"file",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php#L46-L49 | train | Get all the values of the field as an array. | [
30522,
2270,
3853,
2131,
10175,
15808,
1006,
1007,
1063,
2709,
1031,
1002,
2023,
1011,
1028,
3643,
1010,
1002,
2023,
1011,
1028,
8909,
4765,
18095,
1010,
1002,
2023,
1011,
1028,
2109,
1010,
1002,
2023,
1011,
1028,
2828,
1010,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/Lists.php | Lists.validateTree | public function validateTree()
{
if (!$this->showTree) {
return;
}
$this->showSorting = $this->showPagination = false;
if (!$this->model->methodExists('getChildren')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildren"'
);
}
if (!$this->model->methodExists('getChildCount')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildCount"'
);
}
} | php | public function validateTree()
{
if (!$this->showTree) {
return;
}
$this->showSorting = $this->showPagination = false;
if (!$this->model->methodExists('getChildren')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildren"'
);
}
if (!$this->model->methodExists('getChildCount')) {
throw new ApplicationException(
'To display list as a tree, the specified model must have a method "getChildCount"'
);
}
} | [
"public",
"function",
"validateTree",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"showTree",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"showSorting",
"=",
"$",
"this",
"->",
"showPagination",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"t... | Validates the model and settings if showTree is used
@return void | [
"Validates",
"the",
"model",
"and",
"settings",
"if",
"showTree",
"is",
"used"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L1636-L1655 | train | Validate tree. | [
30522,
2270,
3853,
9398,
3686,
13334,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2265,
13334,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
3065,
11589,
2075,
1027,
1002,
2023,
1011,
1028,
2265,
4502,
20876,
3508,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php | HasManyThrough.performJoin | protected function performJoin(Builder $query = null)
{
$query = $query ?: $this->query;
$farKey = $this->getQualifiedFarKeyName();
$query->join($this->throughParent->getTable(), $this->getQualifiedParentKeyName(), '=', $farKey);
if ($this->throughParentSoftDeletes()) {
$query->whereNull($this->throughParent->getQualifiedDeletedAtColumn());
}
} | php | protected function performJoin(Builder $query = null)
{
$query = $query ?: $this->query;
$farKey = $this->getQualifiedFarKeyName();
$query->join($this->throughParent->getTable(), $this->getQualifiedParentKeyName(), '=', $farKey);
if ($this->throughParentSoftDeletes()) {
$query->whereNull($this->throughParent->getQualifiedDeletedAtColumn());
}
} | [
"protected",
"function",
"performJoin",
"(",
"Builder",
"$",
"query",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"$",
"query",
"?",
":",
"$",
"this",
"->",
"query",
";",
"$",
"farKey",
"=",
"$",
"this",
"->",
"getQualifiedFarKeyName",
"(",
")",
";",
"... | Set the join clause on the query.
@param \Illuminate\Database\Eloquent\Builder|null $query
@return void | [
"Set",
"the",
"join",
"clause",
"on",
"the",
"query",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php#L108-L119 | train | Perform a join on the table and the through parent table | [
30522,
5123,
3853,
4685,
5558,
2378,
1006,
12508,
1002,
23032,
1027,
19701,
1007,
1063,
1002,
23032,
1027,
1002,
23032,
1029,
1024,
1002,
2023,
1011,
1028,
23032,
1025,
1002,
2521,
14839,
1027,
1002,
2023,
1011,
1028,
2131,
26426,
7810,
149... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Login/Auth.php | Auth.setPasswordHash | public function setPasswordHash($passwordHash)
{
if ($passwordHash === null) {
$this->hashedPassword = null;
return;
}
// check that the password hash is valid (sanity check)
UsersManager::checkPasswordHash($passwordHash, Piwik::translate('Login_ExceptionPasswordMD5HashExpected'));
$this->hashedPassword = $passwordHash;
} | php | public function setPasswordHash($passwordHash)
{
if ($passwordHash === null) {
$this->hashedPassword = null;
return;
}
// check that the password hash is valid (sanity check)
UsersManager::checkPasswordHash($passwordHash, Piwik::translate('Login_ExceptionPasswordMD5HashExpected'));
$this->hashedPassword = $passwordHash;
} | [
"public",
"function",
"setPasswordHash",
"(",
"$",
"passwordHash",
")",
"{",
"if",
"(",
"$",
"passwordHash",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"hashedPassword",
"=",
"null",
";",
"return",
";",
"}",
"// check that the password hash is valid (sanity check... | Sets the password hash to use when authentication.
@param string $passwordHash The password hash. | [
"Sets",
"the",
"password",
"hash",
"to",
"use",
"when",
"authentication",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/Auth.php#L183-L194 | train | Set the password hash | [
30522,
2270,
3853,
2275,
15194,
18351,
14949,
2232,
1006,
1002,
20786,
14949,
2232,
1007,
1063,
2065,
1006,
1002,
20786,
14949,
2232,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
30524,
1996,
20786,
23325,
2003,
9398,
1006,
20039,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/models/RequestLog.php | RequestLog.add | public static function add($statusCode = 404)
{
if (!App::hasDatabase()) {
return;
}
if (!LogSetting::get('log_requests')) {
return;
}
$record = static::firstOrNew([
'url' => substr(Request::fullUrl(), 0, 255),
'status_code' => $statusCode,
]);
if ($referer = Request::header('referer')) {
$referers = (array) $record->referer ?: [];
$referers[] = $referer;
$record->referer = $referers;
}
if (!$record->exists) {
$record->count = 1;
$record->save();
}
else {
$record->increment('count');
}
return $record;
} | php | public static function add($statusCode = 404)
{
if (!App::hasDatabase()) {
return;
}
if (!LogSetting::get('log_requests')) {
return;
}
$record = static::firstOrNew([
'url' => substr(Request::fullUrl(), 0, 255),
'status_code' => $statusCode,
]);
if ($referer = Request::header('referer')) {
$referers = (array) $record->referer ?: [];
$referers[] = $referer;
$record->referer = $referers;
}
if (!$record->exists) {
$record->count = 1;
$record->save();
}
else {
$record->increment('count');
}
return $record;
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"statusCode",
"=",
"404",
")",
"{",
"if",
"(",
"!",
"App",
"::",
"hasDatabase",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"LogSetting",
"::",
"get",
"(",
"'log_requests'",
")",
")",
"{"... | Creates a log record
@return self | [
"Creates",
"a",
"log",
"record"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/models/RequestLog.php#L34-L64 | train | Add a record to the database | [
30522,
2270,
10763,
3853,
5587,
1006,
1002,
3570,
16044,
1027,
24837,
1007,
1063,
2065,
1006,
999,
10439,
1024,
1024,
2038,
2850,
2696,
30524,
1027,
10763,
1024,
1024,
2034,
23846,
2860,
1006,
1031,
1005,
24471,
2140,
1005,
1027,
1028,
4942... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DataCollector/LoggerDataCollector.php | LoggerDataCollector.lateCollect | public function lateCollect()
{
if (null !== $this->logger) {
$containerDeprecationLogs = $this->getContainerDeprecationLogs();
$this->data = $this->computeErrorsCount($containerDeprecationLogs);
// get compiler logs later (only when they are needed) to improve performance
$this->data['compiler_logs'] = [];
$this->data['compiler_logs_filepath'] = $this->containerPathPrefix.'Compiler.log';
$this->data['logs'] = $this->sanitizeLogs(array_merge($this->logger->getLogs($this->currentRequest), $containerDeprecationLogs));
$this->data = $this->cloneVar($this->data);
}
$this->currentRequest = null;
} | php | public function lateCollect()
{
if (null !== $this->logger) {
$containerDeprecationLogs = $this->getContainerDeprecationLogs();
$this->data = $this->computeErrorsCount($containerDeprecationLogs);
// get compiler logs later (only when they are needed) to improve performance
$this->data['compiler_logs'] = [];
$this->data['compiler_logs_filepath'] = $this->containerPathPrefix.'Compiler.log';
$this->data['logs'] = $this->sanitizeLogs(array_merge($this->logger->getLogs($this->currentRequest), $containerDeprecationLogs));
$this->data = $this->cloneVar($this->data);
}
$this->currentRequest = null;
} | [
"public",
"function",
"lateCollect",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"containerDeprecationLogs",
"=",
"$",
"this",
"->",
"getContainerDeprecationLogs",
"(",
")",
";",
"$",
"this",
"->",
"data",
"=",
"$... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php#L64-L76 | train | Late collect the data from the logger | [
30522,
2270,
3853,
2397,
26895,
22471,
1006,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
8833,
4590,
1007,
1063,
1002,
11661,
3207,
28139,
10719,
21197,
2015,
1027,
1002,
2023,
1011,
1028,
2131,
8663,
18249,
2121... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bundle/FrameworkBundle/Console/Application.php | Application.getLongVersion | public function getLongVersion()
{
return parent::getLongVersion().sprintf(' (env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
} | php | public function getLongVersion()
{
return parent::getLongVersion().sprintf(' (env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
} | [
"public",
"function",
"getLongVersion",
"(",
")",
"{",
"return",
"parent",
"::",
"getLongVersion",
"(",
")",
".",
"sprintf",
"(",
"' (env: <comment>%s</>, debug: <comment>%s</>)'",
",",
"$",
"this",
"->",
"kernel",
"->",
"getEnvironment",
"(",
")",
",",
"$",
"th... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/Console/Application.php#L139-L142 | train | Returns the long version of the class | [
30522,
2270,
3853,
2131,
10052,
27774,
1006,
1007,
1063,
2709,
6687,
1024,
1024,
2131,
10052,
27774,
1006,
1007,
1012,
9043,
2546,
1006,
1005,
1006,
4372,
2615,
1024,
1026,
7615,
1028,
1003,
1055,
1026,
1013,
1028,
1010,
2139,
8569,
2290,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Statement.php | Zend_Db_Statement.fetchObject | public function fetchObject($class = 'stdClass', array $config = array())
{
$obj = new $class($config);
$row = $this->fetch(Zend_Db::FETCH_ASSOC);
if (!is_array($row)) {
return false;
}
foreach ($row as $key => $val) {
$obj->$key = $val;
}
return $obj;
} | php | public function fetchObject($class = 'stdClass', array $config = array())
{
$obj = new $class($config);
$row = $this->fetch(Zend_Db::FETCH_ASSOC);
if (!is_array($row)) {
return false;
}
foreach ($row as $key => $val) {
$obj->$key = $val;
}
return $obj;
} | [
"public",
"function",
"fetchObject",
"(",
"$",
"class",
"=",
"'stdClass'",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"obj",
"=",
"new",
"$",
"class",
"(",
"$",
"config",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"fet... | Fetches the next row and returns it as an object.
@param string $class OPTIONAL Name of the class to create.
@param array $config OPTIONAL Constructor arguments for the class.
@return mixed One object instance of the specified class, or false. | [
"Fetches",
"the",
"next",
"row",
"and",
"returns",
"it",
"as",
"an",
"object",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement.php#L376-L387 | train | Fetch the next result as an object | [
30522,
2270,
3853,
18584,
16429,
20614,
1006,
1002,
2465,
1027,
1005,
2358,
16409,
27102,
1005,
1010,
9140,
1002,
9530,
8873,
2290,
1027,
9140,
1006,
1007,
1007,
1063,
1002,
27885,
3501,
1027,
2047,
1002,
2465,
1006,
1002,
9530,
8873,
2290,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/FormRegistry.php | FormRegistry.hasType | public function hasType($name)
{
if (isset($this->types[$name])) {
return true;
}
try {
$this->getType($name);
} catch (ExceptionInterface $e) {
return false;
}
return true;
} | php | public function hasType($name)
{
if (isset($this->types[$name])) {
return true;
}
try {
$this->getType($name);
} catch (ExceptionInterface $e) {
return false;
}
return true;
} | [
"public",
"function",
"hasType",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"types",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"getType",
"(",
"$",
"name",
")",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormRegistry.php#L143-L156 | train | Check if a type exists | [
30522,
2270,
3853,
27151,
5051,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
4127,
1031,
1002,
2171,
1033,
1007,
1007,
1063,
2709,
2995,
1025,
1065,
3046,
1063,
1002,
2023,
1011,
1028,
2131,
13874,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php | CheckCircularReferencesPass.checkOutEdges | private function checkOutEdges(array $edges)
{
foreach ($edges as $edge) {
$node = $edge->getDestNode();
$id = $node->getId();
if (empty($this->checkedNodes[$id])) {
// Don't check circular references for lazy edges
if (!$node->getValue() || (!$edge->isLazy() && !$edge->isWeak())) {
$searchKey = array_search($id, $this->currentPath);
$this->currentPath[] = $id;
if (false !== $searchKey) {
throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey));
}
$this->checkOutEdges($node->getOutEdges());
}
$this->checkedNodes[$id] = true;
array_pop($this->currentPath);
}
}
} | php | private function checkOutEdges(array $edges)
{
foreach ($edges as $edge) {
$node = $edge->getDestNode();
$id = $node->getId();
if (empty($this->checkedNodes[$id])) {
// Don't check circular references for lazy edges
if (!$node->getValue() || (!$edge->isLazy() && !$edge->isWeak())) {
$searchKey = array_search($id, $this->currentPath);
$this->currentPath[] = $id;
if (false !== $searchKey) {
throw new ServiceCircularReferenceException($id, \array_slice($this->currentPath, $searchKey));
}
$this->checkOutEdges($node->getOutEdges());
}
$this->checkedNodes[$id] = true;
array_pop($this->currentPath);
}
}
} | [
"private",
"function",
"checkOutEdges",
"(",
"array",
"$",
"edges",
")",
"{",
"foreach",
"(",
"$",
"edges",
"as",
"$",
"edge",
")",
"{",
"$",
"node",
"=",
"$",
"edge",
"->",
"getDestNode",
"(",
")",
";",
"$",
"id",
"=",
"$",
"node",
"->",
"getId",
... | Checks for circular references.
@param ServiceReferenceGraphEdge[] $edges An array of Edges
@throws ServiceCircularReferenceException when a circular reference is found | [
"Checks",
"for",
"circular",
"references",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php#L54-L77 | train | Check out all edges | [
30522,
2797,
3853,
4638,
5833,
24225,
2015,
1006,
9140,
1002,
7926,
1007,
1063,
18921,
6776,
1006,
1002,
7926,
2004,
1002,
3341,
1007,
1063,
1002,
13045,
1027,
1002,
3341,
1011,
1028,
2131,
6155,
2102,
3630,
3207,
1006,
1007,
1025,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Controller.php | HTML_QuickForm2_Controller.run | public function run()
{
list($page, $action) = $this->getActionName();
return $this->pages[$page]->handle($action);
} | php | public function run()
{
list($page, $action) = $this->getActionName();
return $this->pages[$page]->handle($action);
} | [
"public",
"function",
"run",
"(",
")",
"{",
"list",
"(",
"$",
"page",
",",
"$",
"action",
")",
"=",
"$",
"this",
"->",
"getActionName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"pages",
"[",
"$",
"page",
"]",
"->",
"handle",
"(",
"$",
"action"... | Processes the request
This finds the page, the action to perform with it and passes the action
to the page's handle() method.
@throws HTML_QuickForm2_Exception | [
"Processes",
"the",
"request"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Controller.php#L264-L268 | train | Runs the page action | [
30522,
2270,
3853,
2448,
1006,
1007,
1063,
2862,
1006,
1002,
3931,
1010,
1002,
2895,
1007,
1027,
1002,
2023,
1011,
1028,
2131,
18908,
3258,
18442,
1006,
30524,
1011,
1028,
5047,
1006,
1002,
2895,
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... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MiniProgram/Auth/ServiceProvider.php | ServiceProvider.register | public function register(Container $app)
{
!isset($app['access_token']) && $app['access_token'] = function ($app) {
return new AccessToken($app);
};
!isset($app['auth']) && $app['auth'] = function ($app) {
return new Client($app);
};
} | php | public function register(Container $app)
{
!isset($app['access_token']) && $app['access_token'] = function ($app) {
return new AccessToken($app);
};
!isset($app['auth']) && $app['auth'] = function ($app) {
return new Client($app);
};
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"app",
")",
"{",
"!",
"isset",
"(",
"$",
"app",
"[",
"'access_token'",
"]",
")",
"&&",
"$",
"app",
"[",
"'access_token'",
"]",
"=",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Acce... | {@inheritdoc}. | [
"{"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/MiniProgram/Auth/ServiceProvider.php#L22-L31 | train | Register the access token and auth methods | [
30522,
2270,
3853,
4236,
1006,
11661,
1002,
10439,
1007,
1063,
999,
26354,
3388,
1006,
1002,
10439,
1031,
1005,
3229,
1035,
19204,
1005,
1033,
1007,
1004,
1004,
1002,
10439,
1031,
1005,
3229,
1035,
19204,
1005,
1033,
1027,
3853,
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... |
octobercms/october | modules/cms/traits/UrlMaker.php | UrlMaker.makeUrl | protected function makeUrl()
{
$controller = Controller::getController() ?: new Controller;
return $controller->pageUrl($this->getUrlPageName(), $this->getUrlParams());
} | php | protected function makeUrl()
{
$controller = Controller::getController() ?: new Controller;
return $controller->pageUrl($this->getUrlPageName(), $this->getUrlParams());
} | [
"protected",
"function",
"makeUrl",
"(",
")",
"{",
"$",
"controller",
"=",
"Controller",
"::",
"getController",
"(",
")",
"?",
":",
"new",
"Controller",
";",
"return",
"$",
"controller",
"->",
"pageUrl",
"(",
"$",
"this",
"->",
"getUrlPageName",
"(",
")",
... | Generates a real URL based on the page, detected by the primary component.
The CMS Controller is used for this process passing the declared params.
@return string | [
"Generates",
"a",
"real",
"URL",
"based",
"on",
"the",
"page",
"detected",
"by",
"the",
"primary",
"component",
".",
"The",
"CMS",
"Controller",
"is",
"used",
"for",
"this",
"process",
"passing",
"the",
"declared",
"params",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/traits/UrlMaker.php#L203-L208 | train | Make URL to current page | [
30522,
5123,
3853,
2191,
3126,
2140,
1006,
1007,
1063,
1002,
11486,
1027,
11486,
1024,
1024,
2131,
8663,
13181,
10820,
1006,
1007,
1029,
1024,
2047,
11486,
1025,
2709,
1002,
11486,
1011,
1028,
3931,
3126,
2140,
1006,
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... |
symfony/symfony | src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php | ResolvedTypeFactoryDataCollectorProxy.createResolvedType | public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null)
{
return new ResolvedTypeDataCollectorProxy(
$this->proxiedFactory->createResolvedType($type, $typeExtensions, $parent),
$this->dataCollector
);
} | php | public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null)
{
return new ResolvedTypeDataCollectorProxy(
$this->proxiedFactory->createResolvedType($type, $typeExtensions, $parent),
$this->dataCollector
);
} | [
"public",
"function",
"createResolvedType",
"(",
"FormTypeInterface",
"$",
"type",
",",
"array",
"$",
"typeExtensions",
",",
"ResolvedFormTypeInterface",
"$",
"parent",
"=",
"null",
")",
"{",
"return",
"new",
"ResolvedTypeDataCollectorProxy",
"(",
"$",
"this",
"->",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php#L39-L45 | train | Create a ResolvedTypeDataCollectorProxy for the given type and type extensions | [
30522,
2270,
3853,
3443,
6072,
16116,
13874,
1006,
2433,
13874,
18447,
2121,
12172,
1002,
2828,
1010,
9140,
1002,
2828,
10288,
29048,
2015,
1010,
10395,
14192,
13874,
18447,
2121,
12172,
1002,
6687,
1027,
19701,
1007,
1063,
2709,
2047,
10395,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/models/EditorSetting.php | EditorSetting.getConfiguredStyles | public static function getConfiguredStyles($key, $default = null)
{
$instance = static::instance();
$value = $instance->get($key);
$defaultValue = $instance->getDefaultValue($key);
if (is_array($value)) {
$value = array_build($value, function ($key, $value) {
return [array_get($value, 'class_name'), array_get($value, 'class_label')];
});
}
return $value != $defaultValue ? $value : $default;
} | php | public static function getConfiguredStyles($key, $default = null)
{
$instance = static::instance();
$value = $instance->get($key);
$defaultValue = $instance->getDefaultValue($key);
if (is_array($value)) {
$value = array_build($value, function ($key, $value) {
return [array_get($value, 'class_name'), array_get($value, 'class_label')];
});
}
return $value != $defaultValue ? $value : $default;
} | [
"public",
"static",
"function",
"getConfiguredStyles",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"instance",
"=",
"static",
"::",
"instance",
"(",
")",
";",
"$",
"value",
"=",
"$",
"instance",
"->",
"get",
"(",
"$",
"key",
")"... | Same as getConfigured but uses special style structure.
@return mixed | [
"Same",
"as",
"getConfigured",
"but",
"uses",
"special",
"style",
"structure",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/models/EditorSetting.php#L122-L137 | train | Get the list of all the configured styles | [
30522,
2270,
10763,
3853,
2131,
8663,
8873,
27390,
2098,
21756,
4244,
1006,
1002,
3145,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
1002,
6013,
1027,
10763,
1024,
1024,
6013,
1006,
1007,
1025,
1002,
3643,
1027,
1002,
6013,
1011,
1028,
2131,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Pages.php | Pages.inherited | public function inherited($route, $field = null)
{
if ($field !== null) {
$page = $this->dispatch($route, true);
$parent = $page ? $page->parent() : null;
if ($parent && $parent->value('header.' . $field) !== null) {
return $parent;
}
if ($parent && !$parent->root()) {
return $this->inherited($parent->route(), $field);
}
}
return null;
} | php | public function inherited($route, $field = null)
{
if ($field !== null) {
$page = $this->dispatch($route, true);
$parent = $page ? $page->parent() : null;
if ($parent && $parent->value('header.' . $field) !== null) {
return $parent;
}
if ($parent && !$parent->root()) {
return $this->inherited($parent->route(), $field);
}
}
return null;
} | [
"public",
"function",
"inherited",
"(",
"$",
"route",
",",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"field",
"!==",
"null",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"route",
",",
"true",
")",
";",
"$",
"p... | Get a page ancestor trait.
@param string $route The relative route of the page
@param string $field The field name of the ancestor to query for
@return PageInterface|null | [
"Get",
"a",
"page",
"ancestor",
"trait",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L445-L461 | train | Get parent page | [
30522,
2270,
3853,
7900,
1006,
1002,
2799,
1010,
1002,
2492,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2492,
999,
1027,
1027,
19701,
1007,
1063,
1002,
3931,
1027,
1002,
2023,
1011,
1028,
18365,
1006,
1002,
2799,
1010,
2995,
1007,
1025,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormField.php | FormField.getDefaultFromData | public function getDefaultFromData($data)
{
if ($this->defaultFrom) {
return $this->getFieldNameFromData($this->defaultFrom, $data);
}
if ($this->defaults !== '') {
return $this->defaults;
}
return null;
} | php | public function getDefaultFromData($data)
{
if ($this->defaultFrom) {
return $this->getFieldNameFromData($this->defaultFrom, $data);
}
if ($this->defaults !== '') {
return $this->defaults;
}
return null;
} | [
"public",
"function",
"getDefaultFromData",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"defaultFrom",
")",
"{",
"return",
"$",
"this",
"->",
"getFieldNameFromData",
"(",
"$",
"this",
"->",
"defaultFrom",
",",
"$",
"data",
")",
";",
"}",
... | Returns the default value for this field, the supplied data is used
to source data when defaultFrom is specified.
@param mixed $data
@return mixed | [
"Returns",
"the",
"default",
"value",
"for",
"this",
"field",
"the",
"supplied",
"data",
"is",
"used",
"to",
"source",
"data",
"when",
"defaultFrom",
"is",
"specified",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L632-L643 | train | Get the default from field name from the data | [
30522,
2270,
3853,
2131,
3207,
7011,
11314,
19699,
5358,
2850,
2696,
1006,
1002,
2951,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
12398,
19699,
5358,
1007,
1063,
2709,
1002,
2023,
30524,
999,
1027,
1027,
1005,
1005,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Rule/Each.php | HTML_QuickForm2_Rule_Each.setOwner | public function setOwner(HTML_QuickForm2_Node $owner)
{
if (!$owner instanceof HTML_QuickForm2_Container) {
throw new HTML_QuickForm2_InvalidArgumentException(
'Each Rule can only validate Containers, '.
get_class($owner) . ' given'
);
}
parent::setOwner($owner);
} | php | public function setOwner(HTML_QuickForm2_Node $owner)
{
if (!$owner instanceof HTML_QuickForm2_Container) {
throw new HTML_QuickForm2_InvalidArgumentException(
'Each Rule can only validate Containers, '.
get_class($owner) . ' given'
);
}
parent::setOwner($owner);
} | [
"public",
"function",
"setOwner",
"(",
"HTML_QuickForm2_Node",
"$",
"owner",
")",
"{",
"if",
"(",
"!",
"$",
"owner",
"instanceof",
"HTML_QuickForm2_Container",
")",
"{",
"throw",
"new",
"HTML_QuickForm2_InvalidArgumentException",
"(",
"'Each Rule can only validate Contain... | Sets the element that will be validated by this rule
@param HTML_QuickForm2_Container Container to validate
@throws HTML_QuickForm2_InvalidArgumentException if trying to use
this Rule on something that isn't a Container | [
"Sets",
"the",
"element",
"that",
"will",
"be",
"validated",
"by",
"this",
"rule"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Rule/Each.php#L126-L135 | train | Sets the owner of the Rule | [
30522,
2270,
3853,
2275,
12384,
2121,
1006,
16129,
1035,
4248,
14192,
2475,
1035,
13045,
1002,
3954,
1007,
1063,
2065,
1006,
999,
1002,
3954,
6013,
11253,
16129,
1035,
4248,
14192,
2475,
1035,
11661,
1007,
1063,
5466,
2047,
16129,
1035,
424... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.