repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
matomo-org/matomo | core/ReportRenderer.php | ReportRenderer.getOutputPath | protected static function getOutputPath($filename)
{
$outputFilename = StaticContainer::get('path.tmp') . '/assets/' . $filename;
@chmod($outputFilename, 0600);
if(file_exists($outputFilename)){
@unlink($outputFilename);
}
return $outputFilename;
} | php | protected static function getOutputPath($filename)
{
$outputFilename = StaticContainer::get('path.tmp') . '/assets/' . $filename;
@chmod($outputFilename, 0600);
if(file_exists($outputFilename)){
@unlink($outputFilename);
}
return $outputFilename;
} | [
"protected",
"static",
"function",
"getOutputPath",
"(",
"$",
"filename",
")",
"{",
"$",
"outputFilename",
"=",
"StaticContainer",
"::",
"get",
"(",
"'path.tmp'",
")",
".",
"'/assets/'",
".",
"$",
"filename",
";",
"@",
"chmod",
"(",
"$",
"outputFilename",
",... | Return $filename with temp directory and delete file
@static
@param $filename
@return string path of file in temp directory | [
"Return",
"$filename",
"with",
"temp",
"directory",
"and",
"delete",
"file"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ReportRenderer.php#L168-L179 | train | Get output path | [
30522,
5123,
10763,
3853,
2131,
5833,
18780,
15069,
1006,
1002,
5371,
18442,
1007,
1063,
1002,
6434,
8873,
20844,
4168,
1027,
10763,
8663,
18249,
2121,
1024,
1024,
2131,
1006,
1005,
4130,
1012,
1056,
8737,
1005,
1007,
1012,
1005,
1013,
7045... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php | XmlFileLoader.loadClassMetadata | public function loadClassMetadata(ClassMetadataInterface $classMetadata)
{
if (null === $this->classes) {
$this->classes = $this->getClassesFromXml();
}
if (!$this->classes) {
return false;
}
$attributesMetadata = $classMetadata->getAttributesMetadata();
if (isset($this->classes[$classMetadata->getName()])) {
$xml = $this->classes[$classMetadata->getName()];
foreach ($xml->attribute as $attribute) {
$attributeName = (string) $attribute['name'];
if (isset($attributesMetadata[$attributeName])) {
$attributeMetadata = $attributesMetadata[$attributeName];
} else {
$attributeMetadata = new AttributeMetadata($attributeName);
$classMetadata->addAttributeMetadata($attributeMetadata);
}
foreach ($attribute->group as $group) {
$attributeMetadata->addGroup((string) $group);
}
if (isset($attribute['max-depth'])) {
$attributeMetadata->setMaxDepth((int) $attribute['max-depth']);
}
if (isset($attribute['serialized-name'])) {
$attributeMetadata->setSerializedName((string) $attribute['serialized-name']);
}
}
if (isset($xml->{'discriminator-map'})) {
$mapping = [];
foreach ($xml->{'discriminator-map'}->mapping as $element) {
$elementAttributes = $element->attributes();
$mapping[(string) $elementAttributes->type] = (string) $elementAttributes->class;
}
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
(string) $xml->{'discriminator-map'}->attributes()->{'type-property'},
$mapping
));
}
return true;
}
return false;
} | php | public function loadClassMetadata(ClassMetadataInterface $classMetadata)
{
if (null === $this->classes) {
$this->classes = $this->getClassesFromXml();
}
if (!$this->classes) {
return false;
}
$attributesMetadata = $classMetadata->getAttributesMetadata();
if (isset($this->classes[$classMetadata->getName()])) {
$xml = $this->classes[$classMetadata->getName()];
foreach ($xml->attribute as $attribute) {
$attributeName = (string) $attribute['name'];
if (isset($attributesMetadata[$attributeName])) {
$attributeMetadata = $attributesMetadata[$attributeName];
} else {
$attributeMetadata = new AttributeMetadata($attributeName);
$classMetadata->addAttributeMetadata($attributeMetadata);
}
foreach ($attribute->group as $group) {
$attributeMetadata->addGroup((string) $group);
}
if (isset($attribute['max-depth'])) {
$attributeMetadata->setMaxDepth((int) $attribute['max-depth']);
}
if (isset($attribute['serialized-name'])) {
$attributeMetadata->setSerializedName((string) $attribute['serialized-name']);
}
}
if (isset($xml->{'discriminator-map'})) {
$mapping = [];
foreach ($xml->{'discriminator-map'}->mapping as $element) {
$elementAttributes = $element->attributes();
$mapping[(string) $elementAttributes->type] = (string) $elementAttributes->class;
}
$classMetadata->setClassDiscriminatorMapping(new ClassDiscriminatorMapping(
(string) $xml->{'discriminator-map'}->attributes()->{'type-property'},
$mapping
));
}
return true;
}
return false;
} | [
"public",
"function",
"loadClassMetadata",
"(",
"ClassMetadataInterface",
"$",
"classMetadata",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"classes",
")",
"{",
"$",
"this",
"->",
"classes",
"=",
"$",
"this",
"->",
"getClassesFromXml",
"(",
")",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Mapping/Loader/XmlFileLoader.php#L37-L92 | train | Load Class Metadata | [
30522,
2270,
3853,
7170,
26266,
11368,
8447,
2696,
1006,
2465,
11368,
8447,
18249,
3334,
12172,
1002,
2465,
11368,
8447,
2696,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
4280,
1007,
1063,
1002,
2023,
1011,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/Router.php | Router.prependMiddlewareToGroup | public function prependMiddlewareToGroup($group, $middleware)
{
if (isset($this->middlewareGroups[$group]) && ! in_array($middleware, $this->middlewareGroups[$group])) {
array_unshift($this->middlewareGroups[$group], $middleware);
}
return $this;
} | php | public function prependMiddlewareToGroup($group, $middleware)
{
if (isset($this->middlewareGroups[$group]) && ! in_array($middleware, $this->middlewareGroups[$group])) {
array_unshift($this->middlewareGroups[$group], $middleware);
}
return $this;
} | [
"public",
"function",
"prependMiddlewareToGroup",
"(",
"$",
"group",
",",
"$",
"middleware",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"middlewareGroups",
"[",
"$",
"group",
"]",
")",
"&&",
"!",
"in_array",
"(",
"$",
"middleware",
",",
"$",
... | Add a middleware to the beginning of a middleware group.
If the middleware is already in the group, it will not be added again.
@param string $group
@param string $middleware
@return $this | [
"Add",
"a",
"middleware",
"to",
"the",
"beginning",
"of",
"a",
"middleware",
"group",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Router.php#L884-L891 | train | Prepends a middleware to a group | [
30522,
2270,
3853,
17463,
10497,
4328,
20338,
8059,
3406,
17058,
1006,
1002,
2177,
1010,
1002,
2690,
8059,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
2690,
8059,
17058,
2015,
1031,
1002,
2177,
1033,
1007,
1004,
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... |
matomo-org/matomo | libs/Zend/Db/Statement/Pdo/Ibm.php | Zend_Db_Statement_Pdo_Ibm._bindParam | public function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
try {
if (($type === null) && ($length === null) && ($options === null)) {
return $this->_stmt->bindParam($parameter, $variable);
} else {
return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
}
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | php | public function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
{
try {
if (($type === null) && ($length === null) && ($options === null)) {
return $this->_stmt->bindParam($parameter, $variable);
} else {
return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
}
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"_bindParam",
"(",
"$",
"parameter",
",",
"&",
"$",
"variable",
",",
"$",
"type",
"=",
"null",
",",
"$",
"length",
"=",
"null",
",",
"$",
"options",
"=",
"null",
")",
"{",
"try",
"{",
"if",
"(",
"(",
"$",
"type",
"===",
"nul... | Binds a parameter to the specified variable name.
@param mixed $parameter Name the parameter, either integer or string.
@param mixed $variable Reference to PHP variable containing the value.
@param mixed $type OPTIONAL Datatype of SQL parameter.
@param mixed $length OPTIONAL Length of SQL parameter.
@param mixed $options OPTIONAL Other options.
@return bool
@throws Zend_Db_Statement_Exception | [
"Binds",
"a",
"parameter",
"to",
"the",
"specified",
"variable",
"name",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Pdo/Ibm.php#L80-L92 | train | Bind a parameter to a variable | [
30522,
2270,
3853,
1035,
14187,
28689,
2213,
1006,
1002,
16381,
1010,
1004,
1002,
8023,
1010,
1002,
2828,
1027,
19701,
1010,
1002,
3091,
1027,
19701,
1010,
1002,
7047,
1027,
19701,
1007,
1063,
3046,
1063,
2065,
1006,
1006,
1002,
2828,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Application.php | Application.configureIO | protected function configureIO(InputInterface $input, OutputInterface $output)
{
if (true === $input->hasParameterOption(['--ansi'], true)) {
$output->setDecorated(true);
} elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
$output->setDecorated(false);
}
if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
$input->setInteractive(false);
} elseif (\function_exists('posix_isatty')) {
$inputStream = null;
if ($input instanceof StreamableInputInterface) {
$inputStream = $input->getStream();
}
if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
$input->setInteractive(false);
}
}
switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break;
case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break;
case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break;
case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break;
default: $shellVerbosity = 0; break;
}
if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$shellVerbosity = -1;
} else {
if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
$shellVerbosity = 3;
} elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
$shellVerbosity = 2;
} elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
$shellVerbosity = 1;
}
}
if (-1 === $shellVerbosity) {
$input->setInteractive(false);
}
putenv('SHELL_VERBOSITY='.$shellVerbosity);
$_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
$_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
} | php | protected function configureIO(InputInterface $input, OutputInterface $output)
{
if (true === $input->hasParameterOption(['--ansi'], true)) {
$output->setDecorated(true);
} elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
$output->setDecorated(false);
}
if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
$input->setInteractive(false);
} elseif (\function_exists('posix_isatty')) {
$inputStream = null;
if ($input instanceof StreamableInputInterface) {
$inputStream = $input->getStream();
}
if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
$input->setInteractive(false);
}
}
switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
case -1: $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); break;
case 1: $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); break;
case 2: $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); break;
case 3: $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); break;
default: $shellVerbosity = 0; break;
}
if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$shellVerbosity = -1;
} else {
if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || 3 === $input->getParameterOption('--verbose', false, true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
$shellVerbosity = 3;
} elseif ($input->hasParameterOption('-vv', true) || $input->hasParameterOption('--verbose=2', true) || 2 === $input->getParameterOption('--verbose', false, true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
$shellVerbosity = 2;
} elseif ($input->hasParameterOption('-v', true) || $input->hasParameterOption('--verbose=1', true) || $input->hasParameterOption('--verbose', true) || $input->getParameterOption('--verbose', false, true)) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
$shellVerbosity = 1;
}
}
if (-1 === $shellVerbosity) {
$input->setInteractive(false);
}
putenv('SHELL_VERBOSITY='.$shellVerbosity);
$_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
$_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
} | [
"protected",
"function",
"configureIO",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"input",
"->",
"hasParameterOption",
"(",
"[",
"'--ansi'",
"]",
",",
"true",
")",
")",
"{",
"$",
... | Configures the input and output instances based on the user arguments and options. | [
"Configures",
"the",
"input",
"and",
"output",
"instances",
"based",
"on",
"the",
"user",
"arguments",
"and",
"options",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Application.php#L840-L893 | train | Configure the IO | [
30522,
5123,
3853,
9530,
8873,
27390,
7416,
2080,
1006,
7953,
18447,
2121,
12172,
1002,
7953,
1010,
6434,
18447,
2121,
12172,
1002,
6434,
1007,
1063,
2065,
1006,
2995,
1027,
1027,
1027,
1002,
7953,
1011,
1028,
2038,
28689,
22828,
7361,
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... |
overtrue/wechat | src/MiniProgram/UniformMessage/Client.php | Client.formatWeappMessage | protected function formatWeappMessage(array $data = [])
{
$params = $this->baseFormat($data, $this->weappMessage);
$params['data'] = $this->formatData($params['data'] ?? []);
return $params;
} | php | protected function formatWeappMessage(array $data = [])
{
$params = $this->baseFormat($data, $this->weappMessage);
$params['data'] = $this->formatData($params['data'] ?? []);
return $params;
} | [
"protected",
"function",
"formatWeappMessage",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"baseFormat",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"weappMessage",
")",
";",
"$",
"params",
"[",
"'data'",
... | @param array $data
@return array | [
"@param",
"array",
"$data"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/MiniProgram/UniformMessage/Client.php#L94-L101 | train | Format the message for the weapp message | [
30522,
5123,
3853,
4289,
8545,
29098,
7834,
3736,
3351,
1006,
9140,
1002,
2951,
1027,
1031,
1033,
1007,
1063,
1002,
11498,
5244,
1027,
1002,
2023,
1011,
1028,
2918,
14192,
4017,
1006,
1002,
2951,
1010,
1002,
2023,
1011,
1028,
2057,
29098,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Oracle.php | Zend_Db_Adapter_Oracle.getServerVersion | public function getServerVersion()
{
$this->_connect();
$version = oci_server_version($this->_connection);
if ($version !== false) {
$matches = null;
if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
return $matches[1];
} else {
return null;
}
} else {
return null;
}
} | php | public function getServerVersion()
{
$this->_connect();
$version = oci_server_version($this->_connection);
if ($version !== false) {
$matches = null;
if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
return $matches[1];
} else {
return null;
}
} else {
return null;
}
} | [
"public",
"function",
"getServerVersion",
"(",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"$",
"version",
"=",
"oci_server_version",
"(",
"$",
"this",
"->",
"_connection",
")",
";",
"if",
"(",
"$",
"version",
"!==",
"false",
")",
"{",
"$",... | Retrieve server version in PHP style
@return string | [
"Retrieve",
"server",
"version",
"in",
"PHP",
"style"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Oracle.php#L628-L642 | train | Get the server version | [
30522,
2270,
3853,
4152,
2121,
6299,
27774,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
1002,
2544,
1027,
1051,
6895,
1035,
8241,
1035,
2544,
1006,
1002,
2023,
1011,
1028,
1035,
4434,
1007,
1025,
2065,
1006,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Serializer/Encoder/XmlEncoder.php | XmlEncoder.setRootNodeName | public function setRootNodeName($name)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), E_USER_DEPRECATED);
$this->defaultContext[self::ROOT_NODE_NAME] = $name;
} | php | public function setRootNodeName($name)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), E_USER_DEPRECATED);
$this->defaultContext[self::ROOT_NODE_NAME] = $name;
} | [
"public",
"function",
"setRootNodeName",
"(",
"$",
"name",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'The \"%s()\" method is deprecated since Symfony 4.2, use the context instead.'",
",",
"__METHOD__",
")",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
"this",
"-... | Sets the root node name.
@deprecated since Symfony 4.2
@param string $name Root node name | [
"Sets",
"the",
"root",
"node",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php#L213-L218 | train | Sets the root node name of the node | [
30522,
2270,
3853,
2275,
3217,
4140,
3630,
4181,
14074,
1006,
1002,
2171,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
1996,
1000,
1003,
1055,
1006,
1007,
1000,
4118,
2003,
2139,
28139,
12921,
2144,
25353,
2213,
14876,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Console/ListFailedCommand.php | ListFailedCommand.handle | public function handle()
{
if (count($jobs = $this->getFailedJobs()) === 0) {
return $this->info('No failed jobs!');
}
$this->displayFailedJobs($jobs);
} | php | public function handle()
{
if (count($jobs = $this->getFailedJobs()) === 0) {
return $this->info('No failed jobs!');
}
$this->displayFailedJobs($jobs);
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"jobs",
"=",
"$",
"this",
"->",
"getFailedJobs",
"(",
")",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"info",
"(",
"'No failed jobs!'",
")",
";",
"}",
"$",
... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Console/ListFailedCommand.php#L36-L43 | train | Handle failed jobs | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
2065,
1006,
4175,
1006,
1002,
5841,
1027,
1002,
2023,
1011,
1028,
2131,
7011,
18450,
5558,
5910,
1006,
1007,
1007,
1027,
1027,
1027,
1014,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
18558,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Request.php | Request.getEncodings | public function getEncodings()
{
if (null !== $this->encodings) {
return $this->encodings;
}
return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all());
} | php | public function getEncodings()
{
if (null !== $this->encodings) {
return $this->encodings;
}
return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all());
} | [
"public",
"function",
"getEncodings",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"encodings",
")",
"{",
"return",
"$",
"this",
"->",
"encodings",
";",
"}",
"return",
"$",
"this",
"->",
"encodings",
"=",
"array_keys",
"(",
"AcceptHeader",... | Gets a list of encodings acceptable by the client browser.
@return array List of encodings in preferable order | [
"Gets",
"a",
"list",
"of",
"encodings",
"acceptable",
"by",
"the",
"client",
"browser",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Request.php#L1659-L1666 | train | Get all languages that are supported by the client | [
30522,
2270,
3853,
2131,
2368,
3597,
4667,
2015,
1006,
1007,
1063,
2065,
1006,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
17181,
2015,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
17181,
2015,
1025,
1065,
2709,
1002,
2023,
1011,
1028,
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/API/DataTableManipulator/ReportTotalsCalculator.php | ReportTotalsCalculator.manipulateDataTable | protected function manipulateDataTable($dataTable)
{
if (!empty($this->report) && !$this->report->getDimension() && !$this->isAllMetricsReport()) {
// we currently do not calculate the total value for reports having no dimension
return $dataTable;
}
if (1 != Common::getRequestVar('totals', 1, 'integer', $this->request)) {
return $dataTable;
}
$firstLevelTable = $this->makeSureToWorkOnFirstLevelDataTable($dataTable);
if (!$firstLevelTable->getRowsCount()
|| $dataTable->getTotalsRow()
|| $dataTable->getMetadata('totals')
) {
return $dataTable;
}
// keeping queued filters would not only add various metadata but also break the totals calculator for some reports
// eg when needed metadata is missing to get site information (multisites.getall) etc
$clone = $firstLevelTable->getEmptyClone($keepFilters = false);
foreach ($firstLevelTable->getQueuedFilters() as $queuedFilter) {
if (is_array($queuedFilter) && 'ReplaceColumnNames' === $queuedFilter['className']) {
$clone->queueFilter($queuedFilter['className'], $queuedFilter['parameters']);
}
}
$tableMeta = $firstLevelTable->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
/** @var DataTable\Row $totalRow */
$totalRow = null;
foreach ($firstLevelTable->getRows() as $row) {
if (!isset($totalRow)) {
$columns = $row->getColumns();
$columns['label'] = DataTable::LABEL_TOTALS_ROW;
$totalRow = new DataTable\Row(array(DataTable\Row::COLUMNS => $columns));
} else {
$totalRow->sumRow($row, $copyMetadata = false, $tableMeta);
}
}
$clone->addRow($totalRow);
if ($this->report
&& $this->report->getProcessedMetrics()
&& array_keys($this->report->getProcessedMetrics()) === array('nb_actions_per_visit', 'avg_time_on_site', 'bounce_rate', 'conversion_rate')) {
// hack for AllColumns table or default processed metrics
$clone->filter('AddColumnsProcessedMetrics', array($deleteRowsWithNoVisit = false));
}
$processor = new DataTablePostProcessor($this->apiModule, $this->apiMethod, $this->request);
$processor->applyComputeProcessedMetrics($clone);
$clone = $processor->applyQueuedFilters($clone);
$clone = $processor->applyMetricsFormatting($clone);
$totalRow = null;
foreach ($clone->getRows() as $row) {
/** * @var DataTable\Row $row */
if ($row->getColumn('label') === DataTable::LABEL_TOTALS_ROW) {
$totalRow = $row;
break;
}
}
if (!isset($totalRow) && $clone->getRowsCount() === 1) {
// if for some reason the processor renamed the totals row,
$totalRow = $clone->getFirstRow();
}
if (isset($totalRow)) {
$totals = $row->getColumns();
unset($totals['label']);
$dataTable->setMetadata('totals', $totals);
if (1 === Common::getRequestVar('keep_totals_row', 0, 'integer', $this->request)) {
$row->deleteMetadata(false);
$row->setColumn('label', Piwik::translate('General_Totals'));
$dataTable->setTotalsRow($row);
}
}
return $dataTable;
} | php | protected function manipulateDataTable($dataTable)
{
if (!empty($this->report) && !$this->report->getDimension() && !$this->isAllMetricsReport()) {
// we currently do not calculate the total value for reports having no dimension
return $dataTable;
}
if (1 != Common::getRequestVar('totals', 1, 'integer', $this->request)) {
return $dataTable;
}
$firstLevelTable = $this->makeSureToWorkOnFirstLevelDataTable($dataTable);
if (!$firstLevelTable->getRowsCount()
|| $dataTable->getTotalsRow()
|| $dataTable->getMetadata('totals')
) {
return $dataTable;
}
// keeping queued filters would not only add various metadata but also break the totals calculator for some reports
// eg when needed metadata is missing to get site information (multisites.getall) etc
$clone = $firstLevelTable->getEmptyClone($keepFilters = false);
foreach ($firstLevelTable->getQueuedFilters() as $queuedFilter) {
if (is_array($queuedFilter) && 'ReplaceColumnNames' === $queuedFilter['className']) {
$clone->queueFilter($queuedFilter['className'], $queuedFilter['parameters']);
}
}
$tableMeta = $firstLevelTable->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
/** @var DataTable\Row $totalRow */
$totalRow = null;
foreach ($firstLevelTable->getRows() as $row) {
if (!isset($totalRow)) {
$columns = $row->getColumns();
$columns['label'] = DataTable::LABEL_TOTALS_ROW;
$totalRow = new DataTable\Row(array(DataTable\Row::COLUMNS => $columns));
} else {
$totalRow->sumRow($row, $copyMetadata = false, $tableMeta);
}
}
$clone->addRow($totalRow);
if ($this->report
&& $this->report->getProcessedMetrics()
&& array_keys($this->report->getProcessedMetrics()) === array('nb_actions_per_visit', 'avg_time_on_site', 'bounce_rate', 'conversion_rate')) {
// hack for AllColumns table or default processed metrics
$clone->filter('AddColumnsProcessedMetrics', array($deleteRowsWithNoVisit = false));
}
$processor = new DataTablePostProcessor($this->apiModule, $this->apiMethod, $this->request);
$processor->applyComputeProcessedMetrics($clone);
$clone = $processor->applyQueuedFilters($clone);
$clone = $processor->applyMetricsFormatting($clone);
$totalRow = null;
foreach ($clone->getRows() as $row) {
/** * @var DataTable\Row $row */
if ($row->getColumn('label') === DataTable::LABEL_TOTALS_ROW) {
$totalRow = $row;
break;
}
}
if (!isset($totalRow) && $clone->getRowsCount() === 1) {
// if for some reason the processor renamed the totals row,
$totalRow = $clone->getFirstRow();
}
if (isset($totalRow)) {
$totals = $row->getColumns();
unset($totals['label']);
$dataTable->setMetadata('totals', $totals);
if (1 === Common::getRequestVar('keep_totals_row', 0, 'integer', $this->request)) {
$row->deleteMetadata(false);
$row->setColumn('label', Piwik::translate('General_Totals'));
$dataTable->setTotalsRow($row);
}
}
return $dataTable;
} | [
"protected",
"function",
"manipulateDataTable",
"(",
"$",
"dataTable",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"report",
")",
"&&",
"!",
"$",
"this",
"->",
"report",
"->",
"getDimension",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"is... | Adds ratio metrics if possible.
@param DataTable $dataTable
@return DataTable | [
"Adds",
"ratio",
"metrics",
"if",
"possible",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/API/DataTableManipulator/ReportTotalsCalculator.php#L76-L158 | train | Manually manipulate the data table with totals row and columns | [
30522,
5123,
3853,
20063,
6790,
10880,
1006,
1002,
2951,
10880,
1007,
1063,
2065,
1006,
999,
4064,
1006,
1002,
2023,
1011,
1028,
3189,
1007,
1004,
1004,
999,
1002,
2023,
1011,
1028,
3189,
1011,
1028,
2131,
22172,
6132,
3258,
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... |
octobercms/october | modules/system/classes/UpdateManager.php | UpdateManager.note | protected function note($message)
{
if ($this->notesOutput !== null) {
$this->notesOutput->writeln($message);
}
else {
$this->notes[] = $message;
}
return $this;
} | php | protected function note($message)
{
if ($this->notesOutput !== null) {
$this->notesOutput->writeln($message);
}
else {
$this->notes[] = $message;
}
return $this;
} | [
"protected",
"function",
"note",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"notesOutput",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"notesOutput",
"->",
"writeln",
"(",
"$",
"message",
")",
";",
"}",
"else",
"{",
"$",
"this",
"... | Raise a note event for the migrator.
@param string $message
@return self | [
"Raise",
"a",
"note",
"event",
"for",
"the",
"migrator",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/UpdateManager.php#L760-L770 | train | Write a note to the output | [
30522,
5123,
3853,
3602,
1006,
1002,
4471,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3964,
5833,
18780,
999,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
3964,
5833,
18780,
1011,
1028,
4339,
19666,
1006,
1002,
4471,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/classes/FormField.php | FormField.getAttributes | public function getAttributes($position = 'field', $htmlBuild = true)
{
$result = array_get($this->attributes, $position, []);
$result = $this->filterAttributes($result, $position);
return $htmlBuild ? Html::attributes($result) : $result;
} | php | public function getAttributes($position = 'field', $htmlBuild = true)
{
$result = array_get($this->attributes, $position, []);
$result = $this->filterAttributes($result, $position);
return $htmlBuild ? Html::attributes($result) : $result;
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"position",
"=",
"'field'",
",",
"$",
"htmlBuild",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"array_get",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"position",
",",
"[",
"]",
")",
";",
"$",
"res... | Returns the attributes for this field at a given position.
@param string $position
@return array | [
"Returns",
"the",
"attributes",
"for",
"this",
"field",
"at",
"a",
"given",
"position",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L423-L429 | train | Get attributes of field | [
30522,
2270,
3853,
2131,
19321,
3089,
8569,
4570,
1006,
1002,
2597,
1027,
1005,
2492,
1005,
1010,
1002,
16129,
8569,
4014,
2094,
1027,
2995,
1007,
1063,
1002,
2765,
1027,
9140,
1035,
2131,
1006,
1002,
2023,
1011,
1028,
12332,
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/EventDispatcher/Debug/TraceableEventDispatcher.php | TraceableEventDispatcher.afterDispatch | protected function afterDispatch(string $eventName, $event)
{
$this->postDispatch($eventName, $event instanceof Event ? $event : new LegacyEventProxy($event));
} | php | protected function afterDispatch(string $eventName, $event)
{
$this->postDispatch($eventName, $event instanceof Event ? $event : new LegacyEventProxy($event));
} | [
"protected",
"function",
"afterDispatch",
"(",
"string",
"$",
"eventName",
",",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"postDispatch",
"(",
"$",
"eventName",
",",
"$",
"event",
"instanceof",
"Event",
"?",
"$",
"event",
":",
"new",
"LegacyEventProxy",
"... | Called after dispatching the event.
@param object $event | [
"Called",
"after",
"dispatching",
"the",
"event",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php#L307-L310 | train | Post dispatch for legacy events | [
30522,
5123,
3853,
30524,
18442,
1010,
1002,
2724,
6013,
11253,
2724,
1029,
1002,
2724,
1024,
2047,
8027,
18697,
3372,
21572,
18037,
1006,
1002,
2724,
1007,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php | HtmlDumper.getDumpHeader | protected function getDumpHeader()
{
$this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
if (null !== $this->dumpHeader) {
return $this->dumpHeader;
}
$line = str_replace('{$options}', json_encode($this->displayOptions, JSON_FORCE_OBJECT), <<<'EOHTML'
<script>
Sfdump = window.Sfdump || (function (doc) {
var refStyle = doc.createElement('style'),
rxEsc = /([.*+?^${}()|\[\]\/\\])/g,
idRx = /\bsf-dump-\d+-ref[012]\w+\b/,
keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl',
addEventListener = function (e, n, cb) {
e.addEventListener(n, cb, false);
};
(doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle);
if (!doc.addEventListener) {
addEventListener = function (element, eventName, callback) {
element.attachEvent('on' + eventName, function (e) {
e.preventDefault = function () {e.returnValue = false;};
e.target = e.srcElement;
callback(e);
});
};
}
function toggle(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass;
if (/\bsf-dump-compact\b/.test(oldClass)) {
arrow = '▼';
newClass = 'sf-dump-expanded';
} else if (/\bsf-dump-expanded\b/.test(oldClass)) {
arrow = '▶';
newClass = 'sf-dump-compact';
} else {
return false;
}
if (doc.createEvent && s.dispatchEvent) {
var event = doc.createEvent('Event');
event.initEvent('sf-dump-expanded' === newClass ? 'sfbeforedumpexpand' : 'sfbeforedumpcollapse', true, false);
s.dispatchEvent(event);
}
a.lastChild.innerHTML = arrow;
s.className = s.className.replace(/\bsf-dump-(compact|expanded)\b/, newClass);
if (recursive) {
try {
a = s.querySelectorAll('.'+oldClass);
for (s = 0; s < a.length; ++s) {
if (-1 == a[s].className.indexOf(newClass)) {
a[s].className = newClass;
a[s].previousSibling.lastChild.innerHTML = arrow;
}
}
} catch (e) {
}
}
return true;
};
function collapse(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className;
if (/\bsf-dump-expanded\b/.test(oldClass)) {
toggle(a, recursive);
return true;
}
return false;
};
function expand(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className;
if (/\bsf-dump-compact\b/.test(oldClass)) {
toggle(a, recursive);
return true;
}
return false;
};
function collapseAll(root) {
var a = root.querySelector('a.sf-dump-toggle');
if (a) {
collapse(a, true);
expand(a);
return true;
}
return false;
}
function reveal(node) {
var previous, parents = [];
while ((node = node.parentNode || {}) && (previous = node.previousSibling) && 'A' === previous.tagName) {
parents.push(previous);
}
if (0 !== parents.length) {
parents.forEach(function (parent) {
expand(parent);
});
return true;
}
return false;
}
function highlight(root, activeNode, nodes) {
resetHighlightedNodes(root);
Array.from(nodes||[]).forEach(function (node) {
if (!/\bsf-dump-highlight\b/.test(node.className)) {
node.className = node.className + ' sf-dump-highlight';
}
});
if (!/\bsf-dump-highlight-active\b/.test(activeNode.className)) {
activeNode.className = activeNode.className + ' sf-dump-highlight-active';
}
}
function resetHighlightedNodes(root) {
Array.from(root.querySelectorAll('.sf-dump-str, .sf-dump-key, .sf-dump-public, .sf-dump-protected, .sf-dump-private')).forEach(function (strNode) {
strNode.className = strNode.className.replace(/\bsf-dump-highlight\b/, '');
strNode.className = strNode.className.replace(/\bsf-dump-highlight-active\b/, '');
});
}
return function (root, x) {
root = doc.getElementById(root);
var indentRx = new RegExp('^('+(root.getAttribute('data-indent-pad') || ' ').replace(rxEsc, '\\$1')+')+', 'm'),
options = {$options},
elt = root.getElementsByTagName('A'),
len = elt.length,
i = 0, s, h,
t = [];
while (i < len) t.push(elt[i++]);
for (i in x) {
options[i] = x[i];
}
function a(e, f) {
addEventListener(root, e, function (e, n) {
if ('A' == e.target.tagName) {
f(e.target, e);
} else if ('A' == e.target.parentNode.tagName) {
f(e.target.parentNode, e);
} else if ((n = e.target.nextElementSibling) && 'A' == n.tagName) {
if (!/\bsf-dump-toggle\b/.test(n.className)) {
n = n.nextElementSibling;
}
f(n, e, true);
}
});
};
function isCtrlKey(e) {
return e.ctrlKey || e.metaKey;
}
function xpathString(str) {
var parts = str.match(/[^'"]+|['"]/g).map(function (part) {
if ("'" == part) {
return '"\'"';
}
if ('"' == part) {
return "'\"'";
}
return "'" + part + "'";
});
return "concat(" + parts.join(",") + ", '')";
}
function xpathHasClass(className) {
return "contains(concat(' ', normalize-space(@class), ' '), ' " + className +" ')";
}
addEventListener(root, 'mouseover', function (e) {
if ('' != refStyle.innerHTML) {
refStyle.innerHTML = '';
}
});
a('mouseover', function (a, e, c) {
if (c) {
e.target.style.cursor = "pointer";
} else if (a = idRx.exec(a.className)) {
try {
refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}';
} catch (e) {
}
}
});
a('click', function (a, e, c) {
if (/\bsf-dump-toggle\b/.test(a.className)) {
e.preventDefault();
if (!toggle(a, isCtrlKey(e))) {
var r = doc.getElementById(a.getAttribute('href').substr(1)),
s = r.previousSibling,
f = r.parentNode,
t = a.parentNode;
t.replaceChild(r, a);
f.replaceChild(a, s);
t.insertBefore(s, r);
f = f.firstChild.nodeValue.match(indentRx);
t = t.firstChild.nodeValue.match(indentRx);
if (f && t && f[0] !== t[0]) {
r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\\$1'), 'mg'), t[0]);
}
if (/\bsf-dump-compact\b/.test(r.className)) {
toggle(s, isCtrlKey(e));
}
}
if (c) {
} else if (doc.getSelection) {
try {
doc.getSelection().removeAllRanges();
} catch (e) {
doc.getSelection().empty();
}
} else {
doc.selection.empty();
}
} else if (/\bsf-dump-str-toggle\b/.test(a.className)) {
e.preventDefault();
e = a.parentNode.parentNode;
e.className = e.className.replace(/\bsf-dump-str-(expand|collapse)\b/, a.parentNode.className);
}
});
elt = root.getElementsByTagName('SAMP');
len = elt.length;
i = 0;
while (i < len) t.push(elt[i++]);
len = t.length;
for (i = 0; i < len; ++i) {
elt = t[i];
if ('SAMP' == elt.tagName) {
a = elt.previousSibling || {};
if ('A' != a.tagName) {
a = doc.createElement('A');
a.className = 'sf-dump-ref';
elt.parentNode.insertBefore(a, elt);
} else {
a.innerHTML += ' ';
}
a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children';
a.innerHTML += '<span>▼</span>';
a.className += ' sf-dump-toggle';
x = 1;
if ('sf-dump' != elt.parentNode.className) {
x += elt.parentNode.getAttribute('data-depth')/1;
}
elt.setAttribute('data-depth', x);
var className = elt.className;
elt.className = 'sf-dump-expanded';
if (className ? 'sf-dump-expanded' !== className : (x > options.maxDepth)) {
toggle(a);
}
} else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) {
a = a.substr(1);
elt.className += ' '+a;
if (/[\[{]$/.test(elt.previousSibling.nodeValue)) {
a = a != elt.nextSibling.id && doc.getElementById(a);
try {
s = a.nextSibling;
elt.appendChild(a);
s.parentNode.insertBefore(a, s);
if (/^[@#]/.test(elt.innerHTML)) {
elt.innerHTML += ' <span>▶</span>';
} else {
elt.innerHTML = '<span>▶</span>';
elt.className = 'sf-dump-ref';
}
elt.className += ' sf-dump-toggle';
} catch (e) {
if ('&' == elt.innerHTML.charAt(0)) {
elt.innerHTML = '…';
elt.className = 'sf-dump-ref';
}
}
}
}
}
if (doc.evaluate && Array.from && root.children.length > 1) {
root.setAttribute('tabindex', 0);
SearchState = function () {
this.nodes = [];
this.idx = 0;
};
SearchState.prototype = {
next: function () {
if (this.isEmpty()) {
return this.current();
}
this.idx = this.idx < (this.nodes.length - 1) ? this.idx + 1 : 0;
return this.current();
},
previous: function () {
if (this.isEmpty()) {
return this.current();
}
this.idx = this.idx > 0 ? this.idx - 1 : (this.nodes.length - 1);
return this.current();
},
isEmpty: function () {
return 0 === this.count();
},
current: function () {
if (this.isEmpty()) {
return null;
}
return this.nodes[this.idx];
},
reset: function () {
this.nodes = [];
this.idx = 0;
},
count: function () {
return this.nodes.length;
},
};
function showCurrent(state)
{
var currentNode = state.current(), currentRect, searchRect;
if (currentNode) {
reveal(currentNode);
highlight(root, currentNode, state.nodes);
if ('scrollIntoView' in currentNode) {
currentNode.scrollIntoView(true);
currentRect = currentNode.getBoundingClientRect();
searchRect = search.getBoundingClientRect();
if (currentRect.top < (searchRect.top + searchRect.height)) {
window.scrollBy(0, -(searchRect.top + searchRect.height + 5));
}
}
}
counter.textContent = (state.isEmpty() ? 0 : state.idx + 1) + ' of ' + state.count();
}
var search = doc.createElement('div');
search.className = 'sf-dump-search-wrapper sf-dump-search-hidden';
search.innerHTML = '
<input type="text" class="sf-dump-search-input">
<span class="sf-dump-search-count">0 of 0<\/span>
<button type="button" class="sf-dump-search-input-previous" tabindex="-1">
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1683 1331l-166 165q-19 19-45 19t-45-19L896 965l-531 531q-19 19-45 19t-45-19l-166-165q-19-19-19-45.5t19-45.5l742-741q19-19 45-19t45 19l742 741q19 19 19 45.5t-19 45.5z"\/><\/svg>
<\/button>
<button type="button" class="sf-dump-search-input-next" tabindex="-1">
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1683 808l-742 741q-19 19-45 19t-45-19L109 808q-19-19-19-45.5t19-45.5l166-165q19-19 45-19t45 19l531 531 531-531q19-19 45-19t45 19l166 165q19 19 19 45.5t-19 45.5z"\/><\/svg>
<\/button>
';
root.insertBefore(search, root.firstChild);
var state = new SearchState();
var searchInput = search.querySelector('.sf-dump-search-input');
var counter = search.querySelector('.sf-dump-search-count');
var searchInputTimer = 0;
var previousSearchQuery = '';
addEventListener(searchInput, 'keyup', function (e) {
var searchQuery = e.target.value;
/* Don't perform anything if the pressed key didn't change the query */
if (searchQuery === previousSearchQuery) {
return;
}
previousSearchQuery = searchQuery;
clearTimeout(searchInputTimer);
searchInputTimer = setTimeout(function () {
state.reset();
collapseAll(root);
resetHighlightedNodes(root);
if ('' === searchQuery) {
counter.textContent = '0 of 0';
return;
}
var classMatches = [
"sf-dump-str",
"sf-dump-key",
"sf-dump-public",
"sf-dump-protected",
"sf-dump-private",
].map(xpathHasClass).join(' or ');
var xpathResult = doc.evaluate('.//span[' + classMatches + '][contains(translate(child::text(), ' + xpathString(searchQuery.toUpperCase()) + ', ' + xpathString(searchQuery.toLowerCase()) + '), ' + xpathString(searchQuery.toLowerCase()) + ')]', root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
while (node = xpathResult.iterateNext()) state.nodes.push(node);
showCurrent(state);
}, 400);
});
Array.from(search.querySelectorAll('.sf-dump-search-input-next, .sf-dump-search-input-previous')).forEach(function (btn) {
addEventListener(btn, 'click', function (e) {
e.preventDefault();
-1 !== e.target.className.indexOf('next') ? state.next() : state.previous();
searchInput.focus();
collapseAll(root);
showCurrent(state);
})
});
addEventListener(root, 'keydown', function (e) {
var isSearchActive = !/\bsf-dump-search-hidden\b/.test(search.className);
if ((114 === e.keyCode && !isSearchActive) || (isCtrlKey(e) && 70 === e.keyCode)) {
/* F3 or CMD/CTRL + F */
e.preventDefault();
search.className = search.className.replace(/\bsf-dump-search-hidden\b/, '');
searchInput.focus();
} else if (isSearchActive) {
if (27 === e.keyCode) {
/* ESC key */
search.className += ' sf-dump-search-hidden';
e.preventDefault();
resetHighlightedNodes(root);
searchInput.value = '';
} else if (
(isCtrlKey(e) && 71 === e.keyCode) /* CMD/CTRL + G */
|| 13 === e.keyCode /* Enter */
|| 114 === e.keyCode /* F3 */
) {
e.preventDefault();
e.shiftKey ? state.previous() : state.next();
collapseAll(root);
showCurrent(state);
}
}
});
}
if (0 >= options.maxStringLength) {
return;
}
try {
elt = root.querySelectorAll('.sf-dump-str');
len = elt.length;
i = 0;
t = [];
while (i < len) t.push(elt[i++]);
len = t.length;
for (i = 0; i < len; ++i) {
elt = t[i];
s = elt.innerText || elt.textContent;
x = s.length - options.maxStringLength;
if (0 < x) {
h = elt.innerHTML;
elt[elt.innerText ? 'innerText' : 'textContent'] = s.substring(0, options.maxStringLength);
elt.className += ' sf-dump-str-collapse';
elt.innerHTML = '<span class=sf-dump-str-collapse>'+h+'<a class="sf-dump-ref sf-dump-str-toggle" title="Collapse"> ◀</a></span>'+
'<span class=sf-dump-str-expand>'+elt.innerHTML+'<a class="sf-dump-ref sf-dump-str-toggle" title="'+x+' remaining characters"> ▶</a></span>';
}
}
} catch (e) {
}
};
})(document);
</script><style>
pre.sf-dump {
display: block;
white-space: pre;
padding: 5px;
overflow: initial !important;
}
pre.sf-dump:after {
content: "";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
pre.sf-dump span {
display: inline;
}
pre.sf-dump .sf-dump-compact {
display: none;
}
pre.sf-dump abbr {
text-decoration: none;
border: none;
cursor: help;
}
pre.sf-dump a {
text-decoration: none;
cursor: pointer;
border: 0;
outline: none;
color: inherit;
}
pre.sf-dump .sf-dump-ellipsis {
display: inline-block;
overflow: visible;
text-overflow: ellipsis;
max-width: 5em;
white-space: nowrap;
overflow: hidden;
vertical-align: top;
}
pre.sf-dump .sf-dump-ellipsis+.sf-dump-ellipsis {
max-width: none;
}
pre.sf-dump code {
display:inline;
padding:0;
background:none;
}
.sf-dump-str-collapse .sf-dump-str-collapse {
display: none;
}
.sf-dump-str-expand .sf-dump-str-expand {
display: none;
}
.sf-dump-public.sf-dump-highlight,
.sf-dump-protected.sf-dump-highlight,
.sf-dump-private.sf-dump-highlight,
.sf-dump-str.sf-dump-highlight,
.sf-dump-key.sf-dump-highlight {
background: rgba(111, 172, 204, 0.3);
border: 1px solid #7DA0B1;
border-radius: 3px;
}
.sf-dump-public.sf-dump-highlight-active,
.sf-dump-protected.sf-dump-highlight-active,
.sf-dump-private.sf-dump-highlight-active,
.sf-dump-str.sf-dump-highlight-active,
.sf-dump-key.sf-dump-highlight-active {
background: rgba(253, 175, 0, 0.4);
border: 1px solid #ffa500;
border-radius: 3px;
}
pre.sf-dump .sf-dump-search-hidden {
display: none !important;
}
pre.sf-dump .sf-dump-search-wrapper {
font-size: 0;
white-space: nowrap;
margin-bottom: 5px;
display: flex;
position: -webkit-sticky;
position: sticky;
top: 5px;
}
pre.sf-dump .sf-dump-search-wrapper > * {
vertical-align: top;
box-sizing: border-box;
height: 21px;
font-weight: normal;
border-radius: 0;
background: #FFF;
color: #757575;
border: 1px solid #BBB;
}
pre.sf-dump .sf-dump-search-wrapper > input.sf-dump-search-input {
padding: 3px;
height: 21px;
font-size: 12px;
border-right: none;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
color: #000;
min-width: 15px;
width: 100%;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next,
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-previous {
background: #F2F2F2;
outline: none;
border-left: none;
font-size: 0;
line-height: 0;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next > svg,
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-previous > svg {
pointer-events: none;
width: 12px;
height: 12px;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-count {
display: inline-block;
padding: 0 5px;
margin: 0;
border-left: none;
line-height: 21px;
font-size: 12px;
}
EOHTML
);
foreach ($this->styles as $class => $style) {
$line .= 'pre.sf-dump'.('default' === $class ? ', pre.sf-dump' : '').' .sf-dump-'.$class.'{'.$style.'}';
}
return $this->dumpHeader = preg_replace('/\s+/', ' ', $line).'</style>'.$this->dumpHeader;
} | php | protected function getDumpHeader()
{
$this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
if (null !== $this->dumpHeader) {
return $this->dumpHeader;
}
$line = str_replace('{$options}', json_encode($this->displayOptions, JSON_FORCE_OBJECT), <<<'EOHTML'
<script>
Sfdump = window.Sfdump || (function (doc) {
var refStyle = doc.createElement('style'),
rxEsc = /([.*+?^${}()|\[\]\/\\])/g,
idRx = /\bsf-dump-\d+-ref[012]\w+\b/,
keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl',
addEventListener = function (e, n, cb) {
e.addEventListener(n, cb, false);
};
(doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle);
if (!doc.addEventListener) {
addEventListener = function (element, eventName, callback) {
element.attachEvent('on' + eventName, function (e) {
e.preventDefault = function () {e.returnValue = false;};
e.target = e.srcElement;
callback(e);
});
};
}
function toggle(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass;
if (/\bsf-dump-compact\b/.test(oldClass)) {
arrow = '▼';
newClass = 'sf-dump-expanded';
} else if (/\bsf-dump-expanded\b/.test(oldClass)) {
arrow = '▶';
newClass = 'sf-dump-compact';
} else {
return false;
}
if (doc.createEvent && s.dispatchEvent) {
var event = doc.createEvent('Event');
event.initEvent('sf-dump-expanded' === newClass ? 'sfbeforedumpexpand' : 'sfbeforedumpcollapse', true, false);
s.dispatchEvent(event);
}
a.lastChild.innerHTML = arrow;
s.className = s.className.replace(/\bsf-dump-(compact|expanded)\b/, newClass);
if (recursive) {
try {
a = s.querySelectorAll('.'+oldClass);
for (s = 0; s < a.length; ++s) {
if (-1 == a[s].className.indexOf(newClass)) {
a[s].className = newClass;
a[s].previousSibling.lastChild.innerHTML = arrow;
}
}
} catch (e) {
}
}
return true;
};
function collapse(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className;
if (/\bsf-dump-expanded\b/.test(oldClass)) {
toggle(a, recursive);
return true;
}
return false;
};
function expand(a, recursive) {
var s = a.nextSibling || {}, oldClass = s.className;
if (/\bsf-dump-compact\b/.test(oldClass)) {
toggle(a, recursive);
return true;
}
return false;
};
function collapseAll(root) {
var a = root.querySelector('a.sf-dump-toggle');
if (a) {
collapse(a, true);
expand(a);
return true;
}
return false;
}
function reveal(node) {
var previous, parents = [];
while ((node = node.parentNode || {}) && (previous = node.previousSibling) && 'A' === previous.tagName) {
parents.push(previous);
}
if (0 !== parents.length) {
parents.forEach(function (parent) {
expand(parent);
});
return true;
}
return false;
}
function highlight(root, activeNode, nodes) {
resetHighlightedNodes(root);
Array.from(nodes||[]).forEach(function (node) {
if (!/\bsf-dump-highlight\b/.test(node.className)) {
node.className = node.className + ' sf-dump-highlight';
}
});
if (!/\bsf-dump-highlight-active\b/.test(activeNode.className)) {
activeNode.className = activeNode.className + ' sf-dump-highlight-active';
}
}
function resetHighlightedNodes(root) {
Array.from(root.querySelectorAll('.sf-dump-str, .sf-dump-key, .sf-dump-public, .sf-dump-protected, .sf-dump-private')).forEach(function (strNode) {
strNode.className = strNode.className.replace(/\bsf-dump-highlight\b/, '');
strNode.className = strNode.className.replace(/\bsf-dump-highlight-active\b/, '');
});
}
return function (root, x) {
root = doc.getElementById(root);
var indentRx = new RegExp('^('+(root.getAttribute('data-indent-pad') || ' ').replace(rxEsc, '\\$1')+')+', 'm'),
options = {$options},
elt = root.getElementsByTagName('A'),
len = elt.length,
i = 0, s, h,
t = [];
while (i < len) t.push(elt[i++]);
for (i in x) {
options[i] = x[i];
}
function a(e, f) {
addEventListener(root, e, function (e, n) {
if ('A' == e.target.tagName) {
f(e.target, e);
} else if ('A' == e.target.parentNode.tagName) {
f(e.target.parentNode, e);
} else if ((n = e.target.nextElementSibling) && 'A' == n.tagName) {
if (!/\bsf-dump-toggle\b/.test(n.className)) {
n = n.nextElementSibling;
}
f(n, e, true);
}
});
};
function isCtrlKey(e) {
return e.ctrlKey || e.metaKey;
}
function xpathString(str) {
var parts = str.match(/[^'"]+|['"]/g).map(function (part) {
if ("'" == part) {
return '"\'"';
}
if ('"' == part) {
return "'\"'";
}
return "'" + part + "'";
});
return "concat(" + parts.join(",") + ", '')";
}
function xpathHasClass(className) {
return "contains(concat(' ', normalize-space(@class), ' '), ' " + className +" ')";
}
addEventListener(root, 'mouseover', function (e) {
if ('' != refStyle.innerHTML) {
refStyle.innerHTML = '';
}
});
a('mouseover', function (a, e, c) {
if (c) {
e.target.style.cursor = "pointer";
} else if (a = idRx.exec(a.className)) {
try {
refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}';
} catch (e) {
}
}
});
a('click', function (a, e, c) {
if (/\bsf-dump-toggle\b/.test(a.className)) {
e.preventDefault();
if (!toggle(a, isCtrlKey(e))) {
var r = doc.getElementById(a.getAttribute('href').substr(1)),
s = r.previousSibling,
f = r.parentNode,
t = a.parentNode;
t.replaceChild(r, a);
f.replaceChild(a, s);
t.insertBefore(s, r);
f = f.firstChild.nodeValue.match(indentRx);
t = t.firstChild.nodeValue.match(indentRx);
if (f && t && f[0] !== t[0]) {
r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\\$1'), 'mg'), t[0]);
}
if (/\bsf-dump-compact\b/.test(r.className)) {
toggle(s, isCtrlKey(e));
}
}
if (c) {
} else if (doc.getSelection) {
try {
doc.getSelection().removeAllRanges();
} catch (e) {
doc.getSelection().empty();
}
} else {
doc.selection.empty();
}
} else if (/\bsf-dump-str-toggle\b/.test(a.className)) {
e.preventDefault();
e = a.parentNode.parentNode;
e.className = e.className.replace(/\bsf-dump-str-(expand|collapse)\b/, a.parentNode.className);
}
});
elt = root.getElementsByTagName('SAMP');
len = elt.length;
i = 0;
while (i < len) t.push(elt[i++]);
len = t.length;
for (i = 0; i < len; ++i) {
elt = t[i];
if ('SAMP' == elt.tagName) {
a = elt.previousSibling || {};
if ('A' != a.tagName) {
a = doc.createElement('A');
a.className = 'sf-dump-ref';
elt.parentNode.insertBefore(a, elt);
} else {
a.innerHTML += ' ';
}
a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children';
a.innerHTML += '<span>▼</span>';
a.className += ' sf-dump-toggle';
x = 1;
if ('sf-dump' != elt.parentNode.className) {
x += elt.parentNode.getAttribute('data-depth')/1;
}
elt.setAttribute('data-depth', x);
var className = elt.className;
elt.className = 'sf-dump-expanded';
if (className ? 'sf-dump-expanded' !== className : (x > options.maxDepth)) {
toggle(a);
}
} else if (/\bsf-dump-ref\b/.test(elt.className) && (a = elt.getAttribute('href'))) {
a = a.substr(1);
elt.className += ' '+a;
if (/[\[{]$/.test(elt.previousSibling.nodeValue)) {
a = a != elt.nextSibling.id && doc.getElementById(a);
try {
s = a.nextSibling;
elt.appendChild(a);
s.parentNode.insertBefore(a, s);
if (/^[@#]/.test(elt.innerHTML)) {
elt.innerHTML += ' <span>▶</span>';
} else {
elt.innerHTML = '<span>▶</span>';
elt.className = 'sf-dump-ref';
}
elt.className += ' sf-dump-toggle';
} catch (e) {
if ('&' == elt.innerHTML.charAt(0)) {
elt.innerHTML = '…';
elt.className = 'sf-dump-ref';
}
}
}
}
}
if (doc.evaluate && Array.from && root.children.length > 1) {
root.setAttribute('tabindex', 0);
SearchState = function () {
this.nodes = [];
this.idx = 0;
};
SearchState.prototype = {
next: function () {
if (this.isEmpty()) {
return this.current();
}
this.idx = this.idx < (this.nodes.length - 1) ? this.idx + 1 : 0;
return this.current();
},
previous: function () {
if (this.isEmpty()) {
return this.current();
}
this.idx = this.idx > 0 ? this.idx - 1 : (this.nodes.length - 1);
return this.current();
},
isEmpty: function () {
return 0 === this.count();
},
current: function () {
if (this.isEmpty()) {
return null;
}
return this.nodes[this.idx];
},
reset: function () {
this.nodes = [];
this.idx = 0;
},
count: function () {
return this.nodes.length;
},
};
function showCurrent(state)
{
var currentNode = state.current(), currentRect, searchRect;
if (currentNode) {
reveal(currentNode);
highlight(root, currentNode, state.nodes);
if ('scrollIntoView' in currentNode) {
currentNode.scrollIntoView(true);
currentRect = currentNode.getBoundingClientRect();
searchRect = search.getBoundingClientRect();
if (currentRect.top < (searchRect.top + searchRect.height)) {
window.scrollBy(0, -(searchRect.top + searchRect.height + 5));
}
}
}
counter.textContent = (state.isEmpty() ? 0 : state.idx + 1) + ' of ' + state.count();
}
var search = doc.createElement('div');
search.className = 'sf-dump-search-wrapper sf-dump-search-hidden';
search.innerHTML = '
<input type="text" class="sf-dump-search-input">
<span class="sf-dump-search-count">0 of 0<\/span>
<button type="button" class="sf-dump-search-input-previous" tabindex="-1">
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1683 1331l-166 165q-19 19-45 19t-45-19L896 965l-531 531q-19 19-45 19t-45-19l-166-165q-19-19-19-45.5t19-45.5l742-741q19-19 45-19t45 19l742 741q19 19 19 45.5t-19 45.5z"\/><\/svg>
<\/button>
<button type="button" class="sf-dump-search-input-next" tabindex="-1">
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1683 808l-742 741q-19 19-45 19t-45-19L109 808q-19-19-19-45.5t19-45.5l166-165q19-19 45-19t45 19l531 531 531-531q19-19 45-19t45 19l166 165q19 19 19 45.5t-19 45.5z"\/><\/svg>
<\/button>
';
root.insertBefore(search, root.firstChild);
var state = new SearchState();
var searchInput = search.querySelector('.sf-dump-search-input');
var counter = search.querySelector('.sf-dump-search-count');
var searchInputTimer = 0;
var previousSearchQuery = '';
addEventListener(searchInput, 'keyup', function (e) {
var searchQuery = e.target.value;
/* Don't perform anything if the pressed key didn't change the query */
if (searchQuery === previousSearchQuery) {
return;
}
previousSearchQuery = searchQuery;
clearTimeout(searchInputTimer);
searchInputTimer = setTimeout(function () {
state.reset();
collapseAll(root);
resetHighlightedNodes(root);
if ('' === searchQuery) {
counter.textContent = '0 of 0';
return;
}
var classMatches = [
"sf-dump-str",
"sf-dump-key",
"sf-dump-public",
"sf-dump-protected",
"sf-dump-private",
].map(xpathHasClass).join(' or ');
var xpathResult = doc.evaluate('.//span[' + classMatches + '][contains(translate(child::text(), ' + xpathString(searchQuery.toUpperCase()) + ', ' + xpathString(searchQuery.toLowerCase()) + '), ' + xpathString(searchQuery.toLowerCase()) + ')]', root, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
while (node = xpathResult.iterateNext()) state.nodes.push(node);
showCurrent(state);
}, 400);
});
Array.from(search.querySelectorAll('.sf-dump-search-input-next, .sf-dump-search-input-previous')).forEach(function (btn) {
addEventListener(btn, 'click', function (e) {
e.preventDefault();
-1 !== e.target.className.indexOf('next') ? state.next() : state.previous();
searchInput.focus();
collapseAll(root);
showCurrent(state);
})
});
addEventListener(root, 'keydown', function (e) {
var isSearchActive = !/\bsf-dump-search-hidden\b/.test(search.className);
if ((114 === e.keyCode && !isSearchActive) || (isCtrlKey(e) && 70 === e.keyCode)) {
/* F3 or CMD/CTRL + F */
e.preventDefault();
search.className = search.className.replace(/\bsf-dump-search-hidden\b/, '');
searchInput.focus();
} else if (isSearchActive) {
if (27 === e.keyCode) {
/* ESC key */
search.className += ' sf-dump-search-hidden';
e.preventDefault();
resetHighlightedNodes(root);
searchInput.value = '';
} else if (
(isCtrlKey(e) && 71 === e.keyCode) /* CMD/CTRL + G */
|| 13 === e.keyCode /* Enter */
|| 114 === e.keyCode /* F3 */
) {
e.preventDefault();
e.shiftKey ? state.previous() : state.next();
collapseAll(root);
showCurrent(state);
}
}
});
}
if (0 >= options.maxStringLength) {
return;
}
try {
elt = root.querySelectorAll('.sf-dump-str');
len = elt.length;
i = 0;
t = [];
while (i < len) t.push(elt[i++]);
len = t.length;
for (i = 0; i < len; ++i) {
elt = t[i];
s = elt.innerText || elt.textContent;
x = s.length - options.maxStringLength;
if (0 < x) {
h = elt.innerHTML;
elt[elt.innerText ? 'innerText' : 'textContent'] = s.substring(0, options.maxStringLength);
elt.className += ' sf-dump-str-collapse';
elt.innerHTML = '<span class=sf-dump-str-collapse>'+h+'<a class="sf-dump-ref sf-dump-str-toggle" title="Collapse"> ◀</a></span>'+
'<span class=sf-dump-str-expand>'+elt.innerHTML+'<a class="sf-dump-ref sf-dump-str-toggle" title="'+x+' remaining characters"> ▶</a></span>';
}
}
} catch (e) {
}
};
})(document);
</script><style>
pre.sf-dump {
display: block;
white-space: pre;
padding: 5px;
overflow: initial !important;
}
pre.sf-dump:after {
content: "";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
pre.sf-dump span {
display: inline;
}
pre.sf-dump .sf-dump-compact {
display: none;
}
pre.sf-dump abbr {
text-decoration: none;
border: none;
cursor: help;
}
pre.sf-dump a {
text-decoration: none;
cursor: pointer;
border: 0;
outline: none;
color: inherit;
}
pre.sf-dump .sf-dump-ellipsis {
display: inline-block;
overflow: visible;
text-overflow: ellipsis;
max-width: 5em;
white-space: nowrap;
overflow: hidden;
vertical-align: top;
}
pre.sf-dump .sf-dump-ellipsis+.sf-dump-ellipsis {
max-width: none;
}
pre.sf-dump code {
display:inline;
padding:0;
background:none;
}
.sf-dump-str-collapse .sf-dump-str-collapse {
display: none;
}
.sf-dump-str-expand .sf-dump-str-expand {
display: none;
}
.sf-dump-public.sf-dump-highlight,
.sf-dump-protected.sf-dump-highlight,
.sf-dump-private.sf-dump-highlight,
.sf-dump-str.sf-dump-highlight,
.sf-dump-key.sf-dump-highlight {
background: rgba(111, 172, 204, 0.3);
border: 1px solid #7DA0B1;
border-radius: 3px;
}
.sf-dump-public.sf-dump-highlight-active,
.sf-dump-protected.sf-dump-highlight-active,
.sf-dump-private.sf-dump-highlight-active,
.sf-dump-str.sf-dump-highlight-active,
.sf-dump-key.sf-dump-highlight-active {
background: rgba(253, 175, 0, 0.4);
border: 1px solid #ffa500;
border-radius: 3px;
}
pre.sf-dump .sf-dump-search-hidden {
display: none !important;
}
pre.sf-dump .sf-dump-search-wrapper {
font-size: 0;
white-space: nowrap;
margin-bottom: 5px;
display: flex;
position: -webkit-sticky;
position: sticky;
top: 5px;
}
pre.sf-dump .sf-dump-search-wrapper > * {
vertical-align: top;
box-sizing: border-box;
height: 21px;
font-weight: normal;
border-radius: 0;
background: #FFF;
color: #757575;
border: 1px solid #BBB;
}
pre.sf-dump .sf-dump-search-wrapper > input.sf-dump-search-input {
padding: 3px;
height: 21px;
font-size: 12px;
border-right: none;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
color: #000;
min-width: 15px;
width: 100%;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next,
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-previous {
background: #F2F2F2;
outline: none;
border-left: none;
font-size: 0;
line-height: 0;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-next > svg,
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-input-previous > svg {
pointer-events: none;
width: 12px;
height: 12px;
}
pre.sf-dump .sf-dump-search-wrapper > .sf-dump-search-count {
display: inline-block;
padding: 0 5px;
margin: 0;
border-left: none;
line-height: 21px;
font-size: 12px;
}
EOHTML
);
foreach ($this->styles as $class => $style) {
$line .= 'pre.sf-dump'.('default' === $class ? ', pre.sf-dump' : '').' .sf-dump-'.$class.'{'.$style.'}';
}
return $this->dumpHeader = preg_replace('/\s+/', ' ', $line).'</style>'.$this->dumpHeader;
} | [
"protected",
"function",
"getDumpHeader",
"(",
")",
"{",
"$",
"this",
"->",
"headerIsDumped",
"=",
"null",
"!==",
"$",
"this",
"->",
"outputStream",
"?",
"$",
"this",
"->",
"outputStream",
":",
"$",
"this",
"->",
"lineDumper",
";",
"if",
"(",
"null",
"!=... | Dumps the HTML header. | [
"Dumps",
"the",
"HTML",
"header",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L154-L784 | train | Get dump header | [
30522,
5123,
3853,
2131,
8566,
8737,
4974,
2121,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
20346,
2483,
8566,
8737,
2098,
1027,
19701,
999,
1027,
1027,
1002,
2023,
1011,
1028,
27852,
25379,
1029,
1002,
2023,
1011,
1028,
27852,
25379,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Scheduler/Schedule/Schedule.php | Schedule.adjustHour | protected function adjustHour($rescheduledTime)
{
if ($this->hour !== null) {
// Reset the number of minutes and set the scheduled hour to the one specified with setHour()
$rescheduledTime = mktime($this->hour,
0,
date('s', $rescheduledTime),
date('n', $rescheduledTime),
date('j', $rescheduledTime),
date('Y', $rescheduledTime)
);
}
return $rescheduledTime;
} | php | protected function adjustHour($rescheduledTime)
{
if ($this->hour !== null) {
// Reset the number of minutes and set the scheduled hour to the one specified with setHour()
$rescheduledTime = mktime($this->hour,
0,
date('s', $rescheduledTime),
date('n', $rescheduledTime),
date('j', $rescheduledTime),
date('Y', $rescheduledTime)
);
}
return $rescheduledTime;
} | [
"protected",
"function",
"adjustHour",
"(",
"$",
"rescheduledTime",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hour",
"!==",
"null",
")",
"{",
"// Reset the number of minutes and set the scheduled hour to the one specified with setHour()",
"$",
"rescheduledTime",
"=",
"mkti... | Computes the delta in seconds needed to adjust the rescheduled time to the required hour.
@param int $rescheduledTime The rescheduled time to be adjusted
@return int adjusted rescheduled time | [
"Computes",
"the",
"delta",
"in",
"seconds",
"needed",
"to",
"adjust",
"the",
"rescheduled",
"time",
"to",
"the",
"required",
"hour",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Scheduler/Schedule/Schedule.php#L163-L176 | train | Adjusts the scheduled time to the specified hour | [
30522,
5123,
3853,
14171,
6806,
3126,
1006,
1002,
24501,
7690,
18696,
7292,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3178,
999,
1027,
1027,
19701,
1007,
1063,
1013,
1013,
25141,
1996,
2193,
1997,
2781,
1998,
2275,
1996,
5115,
3178,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/PageUrl.php | PageUrl.reencodeParameters | public static function reencodeParameters(&$queryParameters, $encoding = false)
{
if (function_exists('mb_check_encoding')) {
// if query params are encoded w/ non-utf8 characters (due to browser bug or whatever),
// encode to UTF-8.
if (strtolower($encoding) != 'utf-8'
&& $encoding != false
) {
Common::printDebug("Encoding page URL query parameters to $encoding.");
$queryParameters = PageUrl::reencodeParametersArray($queryParameters, $encoding);
}
} else {
Common::printDebug("Page charset supplied in tracking request, but mbstring extension is not available.");
}
return $queryParameters;
} | php | public static function reencodeParameters(&$queryParameters, $encoding = false)
{
if (function_exists('mb_check_encoding')) {
// if query params are encoded w/ non-utf8 characters (due to browser bug or whatever),
// encode to UTF-8.
if (strtolower($encoding) != 'utf-8'
&& $encoding != false
) {
Common::printDebug("Encoding page URL query parameters to $encoding.");
$queryParameters = PageUrl::reencodeParametersArray($queryParameters, $encoding);
}
} else {
Common::printDebug("Page charset supplied in tracking request, but mbstring extension is not available.");
}
return $queryParameters;
} | [
"public",
"static",
"function",
"reencodeParameters",
"(",
"&",
"$",
"queryParameters",
",",
"$",
"encoding",
"=",
"false",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_check_encoding'",
")",
")",
"{",
"// if query params are encoded w/ non-utf8 characters (due to ... | Checks if query parameters are of a non-UTF-8 encoding and converts the values
from the specified encoding to UTF-8.
This method is used to workaround browser/webapp bugs (see #3450). When
browsers fail to encode query parameters in UTF-8, the tracker will send the
charset of the page viewed and we can sometimes work around invalid data
being stored.
@param array $queryParameters Name/value mapping of query parameters.
@param bool|string $encoding of the HTML page the URL is for. Used to workaround
browser bugs & mis-coded webapps. See #3450.
@return array | [
"Checks",
"if",
"query",
"parameters",
"are",
"of",
"a",
"non",
"-",
"UTF",
"-",
"8",
"encoding",
"and",
"converts",
"the",
"values",
"from",
"the",
"specified",
"encoding",
"to",
"UTF",
"-",
"8",
".",
"This",
"method",
"is",
"used",
"to",
"workaround",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/PageUrl.php#L275-L292 | train | Reencoding query parameters to UTF - 8 | [
30522,
2270,
10763,
3853,
2128,
2368,
16044,
28689,
22828,
2015,
1006,
1004,
1002,
23032,
28689,
22828,
2015,
1010,
1002,
17181,
1027,
6270,
1007,
1063,
2065,
1006,
3853,
1035,
6526,
1006,
1005,
16914,
1035,
4638,
1035,
17181,
1005,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Cache/Traits/AbstractTrait.php | AbstractTrait.enableVersioning | public function enableVersioning($enable = true)
{
$wasEnabled = $this->versioningIsEnabled;
$this->versioningIsEnabled = (bool) $enable;
$this->namespaceVersion = '';
$this->ids = [];
return $wasEnabled;
} | php | public function enableVersioning($enable = true)
{
$wasEnabled = $this->versioningIsEnabled;
$this->versioningIsEnabled = (bool) $enable;
$this->namespaceVersion = '';
$this->ids = [];
return $wasEnabled;
} | [
"public",
"function",
"enableVersioning",
"(",
"$",
"enable",
"=",
"true",
")",
"{",
"$",
"wasEnabled",
"=",
"$",
"this",
"->",
"versioningIsEnabled",
";",
"$",
"this",
"->",
"versioningIsEnabled",
"=",
"(",
"bool",
")",
"$",
"enable",
";",
"$",
"this",
... | Enables/disables versioning of items.
When versioning is enabled, clearing the cache is atomic and doesn't require listing existing keys to proceed,
but old keys may need garbage collection and extra round-trips to the back-end are required.
Calling this method also clears the memoized namespace version and thus forces a resynchonization of it.
@param bool $enable
@return bool the previous state of versioning | [
"Enables",
"/",
"disables",
"versioning",
"of",
"items",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Cache/Traits/AbstractTrait.php#L188-L196 | train | Enable versioning of the namespace | [
30522,
2270,
3853,
9585,
27774,
2075,
1006,
1002,
9585,
1027,
2995,
1007,
1063,
1002,
2001,
8189,
23242,
1027,
1002,
2023,
1011,
1028,
2544,
2075,
28992,
3085,
2094,
1025,
1002,
2023,
1011,
1028,
2544,
2075,
30524,
8189,
23242,
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... |
matomo-org/matomo | libs/Zend/Cache/Frontend/Class.php | Zend_Cache_Frontend_Class.setCachedEntity | public function setCachedEntity($cachedEntity)
{
if (!is_string($cachedEntity) && !is_object($cachedEntity)) {
Zend_Cache::throwException('cached_entity must be an object or a class name');
}
$this->_cachedEntity = $cachedEntity;
$this->_specificOptions['cached_entity'] = $cachedEntity;
if (is_string($this->_cachedEntity)){
$this->_cachedEntityLabel = $this->_cachedEntity;
} else {
$ro = new ReflectionObject($this->_cachedEntity);
$this->_cachedEntityLabel = $ro->getName();
}
} | php | public function setCachedEntity($cachedEntity)
{
if (!is_string($cachedEntity) && !is_object($cachedEntity)) {
Zend_Cache::throwException('cached_entity must be an object or a class name');
}
$this->_cachedEntity = $cachedEntity;
$this->_specificOptions['cached_entity'] = $cachedEntity;
if (is_string($this->_cachedEntity)){
$this->_cachedEntityLabel = $this->_cachedEntity;
} else {
$ro = new ReflectionObject($this->_cachedEntity);
$this->_cachedEntityLabel = $ro->getName();
}
} | [
"public",
"function",
"setCachedEntity",
"(",
"$",
"cachedEntity",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"cachedEntity",
")",
"&&",
"!",
"is_object",
"(",
"$",
"cachedEntity",
")",
")",
"{",
"Zend_Cache",
"::",
"throwException",
"(",
"'cached_enti... | Specific method to set the cachedEntity
if set to a class name, we will cache an abstract class and will use only static calls
if set to an object, we will cache this object methods
@param mixed $cachedEntity | [
"Specific",
"method",
"to",
"set",
"the",
"cachedEntity"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Cache/Frontend/Class.php#L168-L181 | train | Set the cached entity | [
30522,
2270,
3853,
2275,
3540,
7690,
4765,
3012,
1006,
1002,
17053,
16454,
3012,
1007,
1063,
2065,
1006,
999,
2003,
1035,
5164,
1006,
1002,
17053,
16454,
3012,
1007,
1004,
1004,
999,
2003,
1035,
4874,
1006,
1002,
17053,
16454,
3012,
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/Support/Collection.php | Collection.groupBy | public function groupBy($groupBy, $preserveKeys = false)
{
if (is_array($groupBy)) {
$nextGroups = $groupBy;
$groupBy = array_shift($nextGroups);
}
$groupBy = $this->valueRetriever($groupBy);
$results = [];
foreach ($this->items as $key => $value) {
$groupKeys = $groupBy($value, $key);
if (! is_array($groupKeys)) {
$groupKeys = [$groupKeys];
}
foreach ($groupKeys as $groupKey) {
$groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
if (! array_key_exists($groupKey, $results)) {
$results[$groupKey] = new static;
}
$results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
}
}
$result = new static($results);
if (! empty($nextGroups)) {
return $result->map->groupBy($nextGroups, $preserveKeys);
}
return $result;
} | php | public function groupBy($groupBy, $preserveKeys = false)
{
if (is_array($groupBy)) {
$nextGroups = $groupBy;
$groupBy = array_shift($nextGroups);
}
$groupBy = $this->valueRetriever($groupBy);
$results = [];
foreach ($this->items as $key => $value) {
$groupKeys = $groupBy($value, $key);
if (! is_array($groupKeys)) {
$groupKeys = [$groupKeys];
}
foreach ($groupKeys as $groupKey) {
$groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey;
if (! array_key_exists($groupKey, $results)) {
$results[$groupKey] = new static;
}
$results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value);
}
}
$result = new static($results);
if (! empty($nextGroups)) {
return $result->map->groupBy($nextGroups, $preserveKeys);
}
return $result;
} | [
"public",
"function",
"groupBy",
"(",
"$",
"groupBy",
",",
"$",
"preserveKeys",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"groupBy",
")",
")",
"{",
"$",
"nextGroups",
"=",
"$",
"groupBy",
";",
"$",
"groupBy",
"=",
"array_shift",
"(",
"... | Group an associative array by a field or using a callback.
@param array|callable|string $groupBy
@param bool $preserveKeys
@return static | [
"Group",
"an",
"associative",
"array",
"by",
"a",
"field",
"or",
"using",
"a",
"callback",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Collection.php#L890-L927 | train | Group by method. | [
30522,
2270,
3853,
2177,
3762,
1006,
1002,
2177,
3762,
1010,
1002,
7969,
14839,
2015,
1027,
6270,
1007,
1063,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
2177,
3762,
1007,
1007,
1063,
1002,
2279,
17058,
2015,
1027,
1002,
2177,
3762,
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/widgets/Lists.php | Lists.init | public function init()
{
$this->fillFromConfig([
'columns',
'model',
'recordUrl',
'recordOnClick',
'noRecordsMessage',
'showPageNumbers',
'recordsPerPage',
'showSorting',
'defaultSort',
'showCheckboxes',
'showSetup',
'showTree',
'treeExpanded',
'showPagination',
'customViewPath',
]);
/*
* Configure the list widget
*/
$this->recordsPerPage = $this->getSession('per_page', $this->recordsPerPage);
if ($this->showPagination == 'auto') {
$this->showPagination = $this->recordsPerPage && $this->recordsPerPage > 0;
}
if ($this->customViewPath) {
$this->addViewPath($this->customViewPath);
}
$this->validateModel();
$this->validateTree();
} | php | public function init()
{
$this->fillFromConfig([
'columns',
'model',
'recordUrl',
'recordOnClick',
'noRecordsMessage',
'showPageNumbers',
'recordsPerPage',
'showSorting',
'defaultSort',
'showCheckboxes',
'showSetup',
'showTree',
'treeExpanded',
'showPagination',
'customViewPath',
]);
/*
* Configure the list widget
*/
$this->recordsPerPage = $this->getSession('per_page', $this->recordsPerPage);
if ($this->showPagination == 'auto') {
$this->showPagination = $this->recordsPerPage && $this->recordsPerPage > 0;
}
if ($this->customViewPath) {
$this->addViewPath($this->customViewPath);
}
$this->validateModel();
$this->validateTree();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"fillFromConfig",
"(",
"[",
"'columns'",
",",
"'model'",
",",
"'recordUrl'",
",",
"'recordOnClick'",
",",
"'noRecordsMessage'",
",",
"'showPageNumbers'",
",",
"'recordsPerPage'",
",",
"'showSorting'",... | Initialize the widget, called by the constructor and free from its parameters. | [
"Initialize",
"the",
"widget",
"called",
"by",
"the",
"constructor",
"and",
"free",
"from",
"its",
"parameters",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Lists.php#L187-L222 | train | Initializes the list widget | [
30522,
2270,
3853,
1999,
4183,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
6039,
19699,
5358,
8663,
8873,
2290,
1006,
1031,
1005,
7753,
1005,
1010,
1005,
2944,
1005,
1010,
1005,
2501,
3126,
2140,
1005,
1010,
1005,
2501,
2239,
20464,
6799,
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... |
walkor/Workerman | Worker.php | Worker.safeEcho | public static function safeEcho($msg, $decorated = false)
{
$stream = static::outputStream();
if (!$stream) {
return false;
}
if (!$decorated) {
$line = $white = $green = $end = '';
if (static::$_outputDecorated) {
$line = "\033[1A\n\033[K";
$white = "\033[47;30m";
$green = "\033[32;40m";
$end = "\033[0m";
}
$msg = str_replace(array('<n>', '<w>', '<g>'), array($line, $white, $green), $msg);
$msg = str_replace(array('</n>', '</w>', '</g>'), $end, $msg);
} elseif (!static::$_outputDecorated) {
return false;
}
fwrite($stream, $msg);
fflush($stream);
return true;
} | php | public static function safeEcho($msg, $decorated = false)
{
$stream = static::outputStream();
if (!$stream) {
return false;
}
if (!$decorated) {
$line = $white = $green = $end = '';
if (static::$_outputDecorated) {
$line = "\033[1A\n\033[K";
$white = "\033[47;30m";
$green = "\033[32;40m";
$end = "\033[0m";
}
$msg = str_replace(array('<n>', '<w>', '<g>'), array($line, $white, $green), $msg);
$msg = str_replace(array('</n>', '</w>', '</g>'), $end, $msg);
} elseif (!static::$_outputDecorated) {
return false;
}
fwrite($stream, $msg);
fflush($stream);
return true;
} | [
"public",
"static",
"function",
"safeEcho",
"(",
"$",
"msg",
",",
"$",
"decorated",
"=",
"false",
")",
"{",
"$",
"stream",
"=",
"static",
"::",
"outputStream",
"(",
")",
";",
"if",
"(",
"!",
"$",
"stream",
")",
"{",
"return",
"false",
";",
"}",
"if... | Safe Echo.
@param $msg
@param bool $decorated
@return bool | [
"Safe",
"Echo",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L2090-L2112 | train | Echoes a message to the screen | [
30522,
2270,
10763,
3853,
3647,
15937,
2080,
1006,
1002,
5796,
2290,
1010,
1002,
7429,
1027,
6270,
1007,
1063,
1002,
5460,
1027,
10763,
1024,
1024,
27852,
25379,
1006,
1007,
1025,
2065,
1006,
999,
1002,
5460,
1007,
1063,
2709,
6270,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Login/Login.php | Login.noAccess | public function noAccess(Exception $exception)
{
$frontController = FrontController::getInstance();
if (Common::isXmlHttpRequest()) {
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'ajaxNoAccess', array($exception->getMessage()));
return;
}
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'login', array($exception->getMessage()));
} | php | public function noAccess(Exception $exception)
{
$frontController = FrontController::getInstance();
if (Common::isXmlHttpRequest()) {
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'ajaxNoAccess', array($exception->getMessage()));
return;
}
echo $frontController->dispatch(Piwik::getLoginPluginName(), 'login', array($exception->getMessage()));
} | [
"public",
"function",
"noAccess",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"frontController",
"=",
"FrontController",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"Common",
"::",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"echo",
"$",
"frontControll... | Redirects to Login form with error message.
Listens to User.isNotAuthorized hook. | [
"Redirects",
"to",
"Login",
"form",
"with",
"error",
"message",
".",
"Listens",
"to",
"User",
".",
"isNotAuthorized",
"hook",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Login/Login.php#L159-L169 | train | This method is called by Piwik to display a message to the user that is not allowed to access the user. | [
30522,
2270,
3853,
2053,
6305,
9623,
2015,
1006,
6453,
1002,
6453,
1007,
1063,
1002,
2392,
8663,
13181,
10820,
1027,
2392,
8663,
13181,
10820,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1025,
2065,
1006,
2691,
1024,
1024,
2003,
2595,
19968,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.getMetadata | public function getMetadata($name = null)
{
if (is_null($name)) {
return $this->metadata;
}
if (!isset($this->metadata[$name])) {
return false;
}
return $this->metadata[$name];
} | php | public function getMetadata($name = null)
{
if (is_null($name)) {
return $this->metadata;
}
if (!isset($this->metadata[$name])) {
return false;
}
return $this->metadata[$name];
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"metadata",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"... | Returns the array of all metadata, or one requested metadata value.
@param string|null $name The name of the metadata to return or null to return all metadata.
@return mixed | [
"Returns",
"the",
"array",
"of",
"all",
"metadata",
"or",
"one",
"requested",
"metadata",
"value",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Row.php#L197-L206 | train | Get metadata of the current language | [
30522,
2270,
3853,
2131,
11368,
8447,
2696,
1006,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
2171,
1007,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
27425,
1025,
1065,
2065,
1006,
999,
26354,
3388,
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... |
matomo-org/matomo | plugins/Proxy/Controller.php | Controller.redirect | public function redirect()
{
$url = Common::getRequestVar('url', '', 'string', $_GET);
if (!UrlHelper::isLookLikeUrl($url)) {
die('Please check the &url= parameter: it should to be a valid URL');
}
// validate referrer
$referrer = Url::getReferrer();
if (empty($referrer) || !Url::isLocalUrl($referrer)) {
die('Invalid Referrer detected - This means that your web browser is not sending the "Referrer URL" which is
required to proceed with the redirect. Verify your browser settings and add-ons, to check why your browser
is not sending this referrer.
<br/><br/>You can access the page at: ' . $url);
}
// mask visits to *.piwik.org
if (!self::isPiwikUrl($url)) {
Piwik::checkUserHasSomeViewAccess();
}
Common::sendHeader('Content-Type: text/html; charset=utf-8');
echo '<html><head><meta http-equiv="refresh" content="0;url=' . $url . '" /></head></html>';
exit;
} | php | public function redirect()
{
$url = Common::getRequestVar('url', '', 'string', $_GET);
if (!UrlHelper::isLookLikeUrl($url)) {
die('Please check the &url= parameter: it should to be a valid URL');
}
// validate referrer
$referrer = Url::getReferrer();
if (empty($referrer) || !Url::isLocalUrl($referrer)) {
die('Invalid Referrer detected - This means that your web browser is not sending the "Referrer URL" which is
required to proceed with the redirect. Verify your browser settings and add-ons, to check why your browser
is not sending this referrer.
<br/><br/>You can access the page at: ' . $url);
}
// mask visits to *.piwik.org
if (!self::isPiwikUrl($url)) {
Piwik::checkUserHasSomeViewAccess();
}
Common::sendHeader('Content-Type: text/html; charset=utf-8');
echo '<html><head><meta http-equiv="refresh" content="0;url=' . $url . '" /></head></html>';
exit;
} | [
"public",
"function",
"redirect",
"(",
")",
"{",
"$",
"url",
"=",
"Common",
"::",
"getRequestVar",
"(",
"'url'",
",",
"''",
",",
"'string'",
",",
"$",
"_GET",
")",
";",
"if",
"(",
"!",
"UrlHelper",
"::",
"isLookLikeUrl",
"(",
"$",
"url",
")",
")",
... | Output redirection page instead of linking directly to avoid
exposing the referrer on the Piwik demo.
@internal param string $url (via $_GET)
@deprecated @since 3.6.0 | [
"Output",
"redirection",
"page",
"instead",
"of",
"linking",
"directly",
"to",
"avoid",
"exposing",
"the",
"referrer",
"on",
"the",
"Piwik",
"demo",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Proxy/Controller.php#L79-L103 | train | Redirects to the referrer URL | [
30522,
2270,
3853,
2417,
7442,
6593,
1006,
1007,
1063,
1002,
24471,
2140,
1027,
2691,
1024,
1024,
2131,
2890,
15500,
10755,
1006,
1005,
24471,
2140,
1005,
1010,
1005,
1005,
1010,
1005,
5164,
1005,
1010,
1002,
1035,
2131,
1007,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/traits/ConfigMaker.php | ConfigMaker.makeConfigFromArray | public function makeConfigFromArray($configArray = [])
{
$object = new stdClass;
if (!is_array($configArray)) {
return $object;
}
foreach ($configArray as $name => $value) {
$_name = camel_case($name);
$object->{$name} = $object->{$_name} = $value;
}
return $object;
} | php | public function makeConfigFromArray($configArray = [])
{
$object = new stdClass;
if (!is_array($configArray)) {
return $object;
}
foreach ($configArray as $name => $value) {
$_name = camel_case($name);
$object->{$name} = $object->{$_name} = $value;
}
return $object;
} | [
"public",
"function",
"makeConfigFromArray",
"(",
"$",
"configArray",
"=",
"[",
"]",
")",
"{",
"$",
"object",
"=",
"new",
"stdClass",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"configArray",
")",
")",
"{",
"return",
"$",
"object",
";",
"}",
"foreach",... | Makes a config object from an array, making the first level keys properties a new object.
Property values are converted to camelCase and are not set if one already exists.
@param array $configArray Config array.
@return stdClass The config object | [
"Makes",
"a",
"config",
"object",
"from",
"an",
"array",
"making",
"the",
"first",
"level",
"keys",
"properties",
"a",
"new",
"object",
".",
"Property",
"values",
"are",
"converted",
"to",
"camelCase",
"and",
"are",
"not",
"set",
"if",
"one",
"already",
"e... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/traits/ConfigMaker.php#L108-L122 | train | Make config from array | [
30522,
2270,
3853,
2191,
8663,
8873,
25708,
21716,
2906,
9447,
1006,
1002,
9530,
8873,
6843,
9447,
1027,
1031,
1033,
1007,
1063,
1002,
4874,
1027,
2047,
2358,
16409,
27102,
1025,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
9530,
8873,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Factory.php | Factory.extendImplicit | public function extendImplicit($rule, $extension, $message = null)
{
$this->implicitExtensions[$rule] = $extension;
if ($message) {
$this->fallbackMessages[Str::snake($rule)] = $message;
}
} | php | public function extendImplicit($rule, $extension, $message = null)
{
$this->implicitExtensions[$rule] = $extension;
if ($message) {
$this->fallbackMessages[Str::snake($rule)] = $message;
}
} | [
"public",
"function",
"extendImplicit",
"(",
"$",
"rule",
",",
"$",
"extension",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"implicitExtensions",
"[",
"$",
"rule",
"]",
"=",
"$",
"extension",
";",
"if",
"(",
"$",
"message",
")",
"... | Register a custom implicit validator extension.
@param string $rule
@param \Closure|string $extension
@param string $message
@return void | [
"Register",
"a",
"custom",
"implicit",
"validator",
"extension",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Factory.php#L204-L211 | train | Extend implicit rules with a specific extension | [
30522,
2270,
3853,
7949,
5714,
24759,
30524,
2015,
1031,
1002,
3627,
1033,
1027,
1002,
5331,
1025,
2065,
1006,
1002,
4471,
1007,
1063,
1002,
2023,
1011,
1028,
2991,
5963,
7834,
3736,
8449,
1031,
2358,
2099,
1024,
1024,
7488,
1006,
1002,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Renderer/Default.php | HTML_QuickForm2_Renderer_Default.prepareTemplate | public function prepareTemplate($elTpl, HTML_QuickForm2_Node $element)
{
// if element is required
$elTpl = $this->markRequired($elTpl, $element->isRequired());
$elTpl = $this->outputError($elTpl, $element->getError());
return $this->outputLabel($elTpl, $element->getLabel());
} | php | public function prepareTemplate($elTpl, HTML_QuickForm2_Node $element)
{
// if element is required
$elTpl = $this->markRequired($elTpl, $element->isRequired());
$elTpl = $this->outputError($elTpl, $element->getError());
return $this->outputLabel($elTpl, $element->getLabel());
} | [
"public",
"function",
"prepareTemplate",
"(",
"$",
"elTpl",
",",
"HTML_QuickForm2_Node",
"$",
"element",
")",
"{",
"// if element is required",
"$",
"elTpl",
"=",
"$",
"this",
"->",
"markRequired",
"(",
"$",
"elTpl",
",",
"$",
"element",
"->",
"isRequired",
"(... | Processes the element's template, adding label(s), required note and error message
@param string Element template
@param HTML_QuickForm2_Node Element being rendered
@return string Template with some substitutions done | [
"Processes",
"the",
"element",
"s",
"template",
"adding",
"label",
"(",
"s",
")",
"required",
"note",
"and",
"error",
"message"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Default.php#L519-L525 | train | prepare template for validation | [
30522,
2270,
3853,
7374,
18532,
15725,
1006,
1002,
3449,
25856,
2140,
1010,
16129,
1035,
4248,
14192,
2475,
1035,
13045,
1002,
5783,
1007,
1063,
1013,
1013,
2065,
5783,
2003,
3223,
1002,
3449,
25856,
2140,
1027,
1002,
2023,
1011,
1028,
2928... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/SitesManager/API.php | API.getDefaultCurrency | public function getDefaultCurrency()
{
Piwik::checkUserHasSomeAdminAccess();
$defaultCurrency = Option::get(self::OPTION_DEFAULT_CURRENCY);
if ($defaultCurrency) {
return $defaultCurrency;
}
return 'USD';
} | php | public function getDefaultCurrency()
{
Piwik::checkUserHasSomeAdminAccess();
$defaultCurrency = Option::get(self::OPTION_DEFAULT_CURRENCY);
if ($defaultCurrency) {
return $defaultCurrency;
}
return 'USD';
} | [
"public",
"function",
"getDefaultCurrency",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeAdminAccess",
"(",
")",
";",
"$",
"defaultCurrency",
"=",
"Option",
"::",
"get",
"(",
"self",
"::",
"OPTION_DEFAULT_CURRENCY",
")",
";",
"if",
"(",
"$",
"defaultCurrency",... | Returns the default currency that will be set when creating a website through the API.
@return string Currency ID eg. 'USD' | [
"Returns",
"the",
"default",
"currency",
"that",
"will",
"be",
"set",
"when",
"creating",
"a",
"website",
"through",
"the",
"API",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/SitesManager/API.php#L1154-L1162 | train | Returns the default currency | [
30522,
2270,
3853,
2131,
3207,
7011,
11314,
10841,
14343,
9407,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
4215,
22311,
9468,
7971,
1006,
1007,
1025,
1002,
12398,
10841,
14343,
9407,
1027,
5724,
1024,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Filesystem/Filesystem.php | Filesystem.get | public function get($path, $lock = false)
{
if ($this->isFile($path)) {
return $lock ? $this->sharedGet($path) : file_get_contents($path);
}
throw new FileNotFoundException("File does not exist at path {$path}");
} | php | public function get($path, $lock = false)
{
if ($this->isFile($path)) {
return $lock ? $this->sharedGet($path) : file_get_contents($path);
}
throw new FileNotFoundException("File does not exist at path {$path}");
} | [
"public",
"function",
"get",
"(",
"$",
"path",
",",
"$",
"lock",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"lock",
"?",
"$",
"this",
"->",
"sharedGet",
"(",
"$",
"path",
")",... | Get the contents of a file.
@param string $path
@param bool $lock
@return string
@throws \Illuminate\Contracts\Filesystem\FileNotFoundException | [
"Get",
"the",
"contents",
"of",
"a",
"file",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Filesystem/Filesystem.php#L35-L42 | train | Get the content of a file | [
30522,
2270,
3853,
2131,
1006,
1002,
4130,
1010,
1002,
5843,
1027,
6270,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
8873,
2571,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
1002,
5843,
1029,
1002,
2023,
1011,
1028,
4207,
18150,
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/DependencyInjection/Definition.php | Definition.setFactory | public function setFactory($factory)
{
$this->changes['factory'] = true;
if (\is_string($factory) && false !== strpos($factory, '::')) {
$factory = explode('::', $factory, 2);
} elseif ($factory instanceof Reference) {
$factory = [$factory, '__invoke'];
}
$this->factory = $factory;
return $this;
} | php | public function setFactory($factory)
{
$this->changes['factory'] = true;
if (\is_string($factory) && false !== strpos($factory, '::')) {
$factory = explode('::', $factory, 2);
} elseif ($factory instanceof Reference) {
$factory = [$factory, '__invoke'];
}
$this->factory = $factory;
return $this;
} | [
"public",
"function",
"setFactory",
"(",
"$",
"factory",
")",
"{",
"$",
"this",
"->",
"changes",
"[",
"'factory'",
"]",
"=",
"true",
";",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"factory",
")",
"&&",
"false",
"!==",
"strpos",
"(",
"$",
"factory",
","... | Sets a factory.
@param string|array|Reference $factory A PHP function, reference or an array containing a class/Reference and a method to call
@return $this | [
"Sets",
"a",
"factory",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Definition.php#L102-L115 | train | Set factory. | [
30522,
2270,
3853,
2275,
21450,
1006,
1002,
4713,
1007,
1063,
1002,
2023,
1011,
1028,
3431,
1031,
1005,
4713,
1005,
1033,
1027,
2995,
1025,
2065,
1006,
1032,
2003,
1035,
5164,
1006,
1002,
4713,
1007,
1004,
1004,
6270,
999,
1027,
1027,
235... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/LocationProvider/GeoIp/Pecl.php | Pecl.getLocation | public function getLocation($info)
{
$ip = $this->getIpFromInfo($info);
$result = array();
// get location data
if (self::isCityDatabaseAvailable()) {
// Must hide errors because missing IPV6:
$location = @geoip_record_by_name($ip);
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location['country_code'];
$result[self::REGION_CODE_KEY] = $location['region'];
$result[self::CITY_NAME_KEY] = utf8_encode($location['city']);
$result[self::AREA_CODE_KEY] = $location['area_code'];
$result[self::LATITUDE_KEY] = $location['latitude'];
$result[self::LONGITUDE_KEY] = $location['longitude'];
$result[self::POSTAL_CODE_KEY] = $location['postal_code'];
}
} else if (self::isRegionDatabaseAvailable()) {
$location = @geoip_region_by_name($ip);
if (!empty($location)) {
$result[self::REGION_CODE_KEY] = $location['region'];
$result[self::COUNTRY_CODE_KEY] = $location['country_code'];
}
} else {
$result[self::COUNTRY_CODE_KEY] = @geoip_country_code_by_name($ip);
}
// get organization data if the org database is available
if (self::isOrgDatabaseAvailable()) {
$org = @geoip_org_by_name($ip);
if ($org !== false) {
$result[self::ORG_KEY] = utf8_encode($org);
}
}
// get isp data if the isp database is available
if (self::isISPDatabaseAvailable()) {
$isp = @geoip_isp_by_name($ip);
if ($isp !== false) {
$result[self::ISP_KEY] = utf8_encode($isp);
}
}
if (empty($result)) {
return false;
}
$this->completeLocationResult($result);
return $result;
} | php | public function getLocation($info)
{
$ip = $this->getIpFromInfo($info);
$result = array();
// get location data
if (self::isCityDatabaseAvailable()) {
// Must hide errors because missing IPV6:
$location = @geoip_record_by_name($ip);
if (!empty($location)) {
$result[self::COUNTRY_CODE_KEY] = $location['country_code'];
$result[self::REGION_CODE_KEY] = $location['region'];
$result[self::CITY_NAME_KEY] = utf8_encode($location['city']);
$result[self::AREA_CODE_KEY] = $location['area_code'];
$result[self::LATITUDE_KEY] = $location['latitude'];
$result[self::LONGITUDE_KEY] = $location['longitude'];
$result[self::POSTAL_CODE_KEY] = $location['postal_code'];
}
} else if (self::isRegionDatabaseAvailable()) {
$location = @geoip_region_by_name($ip);
if (!empty($location)) {
$result[self::REGION_CODE_KEY] = $location['region'];
$result[self::COUNTRY_CODE_KEY] = $location['country_code'];
}
} else {
$result[self::COUNTRY_CODE_KEY] = @geoip_country_code_by_name($ip);
}
// get organization data if the org database is available
if (self::isOrgDatabaseAvailable()) {
$org = @geoip_org_by_name($ip);
if ($org !== false) {
$result[self::ORG_KEY] = utf8_encode($org);
}
}
// get isp data if the isp database is available
if (self::isISPDatabaseAvailable()) {
$isp = @geoip_isp_by_name($ip);
if ($isp !== false) {
$result[self::ISP_KEY] = utf8_encode($isp);
}
}
if (empty($result)) {
return false;
}
$this->completeLocationResult($result);
return $result;
} | [
"public",
"function",
"getLocation",
"(",
"$",
"info",
")",
"{",
"$",
"ip",
"=",
"$",
"this",
"->",
"getIpFromInfo",
"(",
"$",
"info",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// get location data",
"if",
"(",
"self",
"::",
"isCityDatabas... | Uses the GeoIP PECL module to get a visitor's location based on their IP address.
This function will return different results based on the data available. If a city
database can be detected by the PECL module, it may return the country code,
region code, city name, area code, latitude, longitude and postal code of the visitor.
Alternatively, if only the country database can be detected, only the country code
will be returned.
The GeoIP PECL module will detect the following filenames:
- GeoIP.dat
- GeoIPCity.dat
- GeoIPISP.dat
- GeoIPOrg.dat
Note how GeoLiteCity.dat, the name for the GeoLite city database, is not detected
by the PECL module.
@param array $info Must have an 'ip' field.
@return array | [
"Uses",
"the",
"GeoIP",
"PECL",
"module",
"to",
"get",
"a",
"visitor",
"s",
"location",
"based",
"on",
"their",
"IP",
"address",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php#L53-L104 | train | Get location data | [
30522,
2270,
3853,
2131,
4135,
10719,
1006,
1002,
18558,
1007,
1063,
1002,
12997,
1027,
1002,
2023,
1011,
1028,
2131,
11514,
19699,
20936,
2078,
14876,
1006,
1002,
18558,
1007,
1025,
1002,
2765,
1027,
9140,
1006,
1007,
1025,
1013,
1013,
213... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php | WorkflowExtension.getMarkedPlaces | public function getMarkedPlaces($subject, $placesNameOnly = true, $name = null)
{
$places = $this->workflowRegistry->get($subject, $name)->getMarking($subject)->getPlaces();
if ($placesNameOnly) {
return array_keys($places);
}
return $places;
} | php | public function getMarkedPlaces($subject, $placesNameOnly = true, $name = null)
{
$places = $this->workflowRegistry->get($subject, $name)->getMarking($subject)->getPlaces();
if ($placesNameOnly) {
return array_keys($places);
}
return $places;
} | [
"public",
"function",
"getMarkedPlaces",
"(",
"$",
"subject",
",",
"$",
"placesNameOnly",
"=",
"true",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"places",
"=",
"$",
"this",
"->",
"workflowRegistry",
"->",
"get",
"(",
"$",
"subject",
",",
"$",
"name... | Returns marked places.
@param object $subject A subject
@param bool $placesNameOnly If true, returns only places name. If false returns the raw representation
@param string $name A workflow name
@return string[]|int[] | [
"Returns",
"marked",
"places",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php#L96-L105 | train | Get the places marked by a subject | [
30522,
2270,
3853,
2131,
10665,
2098,
24759,
10732,
2015,
1006,
1002,
3395,
1010,
1002,
3182,
18442,
2239,
2135,
1027,
2995,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
1002,
3182,
1027,
1002,
2023,
1011,
1028,
2147,
12314,
2890,
24063,
2854... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Worker.php | Worker.writeStatisticsToStatusFile | protected static function writeStatisticsToStatusFile()
{
// For master process.
if (static::$_masterPid === posix_getpid()) {
$all_worker_info = array();
foreach(static::$_pidMap as $worker_id => $pid_array) {
/** @var /Workerman/Worker $worker */
$worker = static::$_workers[$worker_id];
foreach($pid_array as $pid) {
$all_worker_info[$pid] = array('name' => $worker->name, 'listen' => $worker->getSocketName());
}
}
file_put_contents(static::$_statisticsFile, json_encode($all_worker_info)."\n", FILE_APPEND);
$loadavg = function_exists('sys_getloadavg') ? array_map('round', sys_getloadavg(), array(2)) : array('-', '-', '-');
file_put_contents(static::$_statisticsFile,
"----------------------------------------------GLOBAL STATUS----------------------------------------------------\n", FILE_APPEND);
file_put_contents(static::$_statisticsFile,
'Workerman version:' . static::VERSION . " PHP version:" . PHP_VERSION . "\n", FILE_APPEND);
file_put_contents(static::$_statisticsFile, 'start time:' . date('Y-m-d H:i:s',
static::$_globalStatistics['start_timestamp']) . ' run ' . floor((time() - static::$_globalStatistics['start_timestamp']) / (24 * 60 * 60)) . ' days ' . floor(((time() - static::$_globalStatistics['start_timestamp']) % (24 * 60 * 60)) / (60 * 60)) . " hours \n",
FILE_APPEND);
$load_str = 'load average: ' . implode(", ", $loadavg);
file_put_contents(static::$_statisticsFile,
str_pad($load_str, 33) . 'event-loop:' . static::getEventLoopName() . "\n", FILE_APPEND);
file_put_contents(static::$_statisticsFile,
count(static::$_pidMap) . ' workers ' . count(static::getAllWorkerPids()) . " processes\n",
FILE_APPEND);
file_put_contents(static::$_statisticsFile,
str_pad('worker_name', static::$_maxWorkerNameLength) . " exit_status exit_count\n", FILE_APPEND);
foreach (static::$_pidMap as $worker_id => $worker_pid_array) {
$worker = static::$_workers[$worker_id];
if (isset(static::$_globalStatistics['worker_exit_info'][$worker_id])) {
foreach (static::$_globalStatistics['worker_exit_info'][$worker_id] as $worker_exit_status => $worker_exit_count) {
file_put_contents(static::$_statisticsFile,
str_pad($worker->name, static::$_maxWorkerNameLength) . " " . str_pad($worker_exit_status,
16) . " $worker_exit_count\n", FILE_APPEND);
}
} else {
file_put_contents(static::$_statisticsFile,
str_pad($worker->name, static::$_maxWorkerNameLength) . " " . str_pad(0, 16) . " 0\n",
FILE_APPEND);
}
}
file_put_contents(static::$_statisticsFile,
"----------------------------------------------PROCESS STATUS---------------------------------------------------\n",
FILE_APPEND);
file_put_contents(static::$_statisticsFile,
"pid\tmemory " . str_pad('listening', static::$_maxSocketNameLength) . " " . str_pad('worker_name',
static::$_maxWorkerNameLength) . " connections " . str_pad('send_fail', 9) . " "
. str_pad('timers', 8) . str_pad('total_request', 13) ." qps status\n", FILE_APPEND);
chmod(static::$_statisticsFile, 0722);
foreach (static::getAllWorkerPids() as $worker_pid) {
posix_kill($worker_pid, SIGUSR2);
}
return;
}
// For child processes.
reset(static::$_workers);
/** @var \Workerman\Worker $worker */
$worker = current(static::$_workers);
$worker_status_str = posix_getpid() . "\t" . str_pad(round(memory_get_usage(true) / (1024 * 1024), 2) . "M", 7)
. " " . str_pad($worker->getSocketName(), static::$_maxSocketNameLength) . " "
. str_pad(($worker->name === $worker->getSocketName() ? 'none' : $worker->name), static::$_maxWorkerNameLength)
. " ";
$worker_status_str .= str_pad(ConnectionInterface::$statistics['connection_count'], 11)
. " " . str_pad(ConnectionInterface::$statistics['send_fail'], 9)
. " " . str_pad(static::$globalEvent->getTimerCount(), 7)
. " " . str_pad(ConnectionInterface::$statistics['total_request'], 13) . "\n";
file_put_contents(static::$_statisticsFile, $worker_status_str, FILE_APPEND);
} | php | protected static function writeStatisticsToStatusFile()
{
// For master process.
if (static::$_masterPid === posix_getpid()) {
$all_worker_info = array();
foreach(static::$_pidMap as $worker_id => $pid_array) {
/** @var /Workerman/Worker $worker */
$worker = static::$_workers[$worker_id];
foreach($pid_array as $pid) {
$all_worker_info[$pid] = array('name' => $worker->name, 'listen' => $worker->getSocketName());
}
}
file_put_contents(static::$_statisticsFile, json_encode($all_worker_info)."\n", FILE_APPEND);
$loadavg = function_exists('sys_getloadavg') ? array_map('round', sys_getloadavg(), array(2)) : array('-', '-', '-');
file_put_contents(static::$_statisticsFile,
"----------------------------------------------GLOBAL STATUS----------------------------------------------------\n", FILE_APPEND);
file_put_contents(static::$_statisticsFile,
'Workerman version:' . static::VERSION . " PHP version:" . PHP_VERSION . "\n", FILE_APPEND);
file_put_contents(static::$_statisticsFile, 'start time:' . date('Y-m-d H:i:s',
static::$_globalStatistics['start_timestamp']) . ' run ' . floor((time() - static::$_globalStatistics['start_timestamp']) / (24 * 60 * 60)) . ' days ' . floor(((time() - static::$_globalStatistics['start_timestamp']) % (24 * 60 * 60)) / (60 * 60)) . " hours \n",
FILE_APPEND);
$load_str = 'load average: ' . implode(", ", $loadavg);
file_put_contents(static::$_statisticsFile,
str_pad($load_str, 33) . 'event-loop:' . static::getEventLoopName() . "\n", FILE_APPEND);
file_put_contents(static::$_statisticsFile,
count(static::$_pidMap) . ' workers ' . count(static::getAllWorkerPids()) . " processes\n",
FILE_APPEND);
file_put_contents(static::$_statisticsFile,
str_pad('worker_name', static::$_maxWorkerNameLength) . " exit_status exit_count\n", FILE_APPEND);
foreach (static::$_pidMap as $worker_id => $worker_pid_array) {
$worker = static::$_workers[$worker_id];
if (isset(static::$_globalStatistics['worker_exit_info'][$worker_id])) {
foreach (static::$_globalStatistics['worker_exit_info'][$worker_id] as $worker_exit_status => $worker_exit_count) {
file_put_contents(static::$_statisticsFile,
str_pad($worker->name, static::$_maxWorkerNameLength) . " " . str_pad($worker_exit_status,
16) . " $worker_exit_count\n", FILE_APPEND);
}
} else {
file_put_contents(static::$_statisticsFile,
str_pad($worker->name, static::$_maxWorkerNameLength) . " " . str_pad(0, 16) . " 0\n",
FILE_APPEND);
}
}
file_put_contents(static::$_statisticsFile,
"----------------------------------------------PROCESS STATUS---------------------------------------------------\n",
FILE_APPEND);
file_put_contents(static::$_statisticsFile,
"pid\tmemory " . str_pad('listening', static::$_maxSocketNameLength) . " " . str_pad('worker_name',
static::$_maxWorkerNameLength) . " connections " . str_pad('send_fail', 9) . " "
. str_pad('timers', 8) . str_pad('total_request', 13) ." qps status\n", FILE_APPEND);
chmod(static::$_statisticsFile, 0722);
foreach (static::getAllWorkerPids() as $worker_pid) {
posix_kill($worker_pid, SIGUSR2);
}
return;
}
// For child processes.
reset(static::$_workers);
/** @var \Workerman\Worker $worker */
$worker = current(static::$_workers);
$worker_status_str = posix_getpid() . "\t" . str_pad(round(memory_get_usage(true) / (1024 * 1024), 2) . "M", 7)
. " " . str_pad($worker->getSocketName(), static::$_maxSocketNameLength) . " "
. str_pad(($worker->name === $worker->getSocketName() ? 'none' : $worker->name), static::$_maxWorkerNameLength)
. " ";
$worker_status_str .= str_pad(ConnectionInterface::$statistics['connection_count'], 11)
. " " . str_pad(ConnectionInterface::$statistics['send_fail'], 9)
. " " . str_pad(static::$globalEvent->getTimerCount(), 7)
. " " . str_pad(ConnectionInterface::$statistics['total_request'], 13) . "\n";
file_put_contents(static::$_statisticsFile, $worker_status_str, FILE_APPEND);
} | [
"protected",
"static",
"function",
"writeStatisticsToStatusFile",
"(",
")",
"{",
"// For master process.",
"if",
"(",
"static",
"::",
"$",
"_masterPid",
"===",
"posix_getpid",
"(",
")",
")",
"{",
"$",
"all_worker_info",
"=",
"array",
"(",
")",
";",
"foreach",
... | Write statistics data to disk.
@return void | [
"Write",
"statistics",
"data",
"to",
"disk",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L1850-L1923 | train | Write statistics to status file | [
30522,
5123,
10763,
3853,
7009,
29336,
6553,
16033,
9153,
5809,
8873,
2571,
1006,
1007,
1063,
1013,
1013,
2005,
3040,
2832,
1012,
2065,
1006,
10763,
1024,
1024,
1002,
1035,
3040,
23267,
1027,
1027,
1027,
13433,
5332,
2595,
1035,
2131,
23267... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/ProfessionalServices/Advertising.php | Advertising.addPromoCampaignParametersToUrl | public function addPromoCampaignParametersToUrl($url, $campaignName, $campaignMedium, $campaignContent = '')
{
if (empty($url)) {
return '';
}
if (strpos($url, '?') === false) {
$url .= '?';
} else {
$url .= '&';
}
$url .= $this->getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent);
return $url;
} | php | public function addPromoCampaignParametersToUrl($url, $campaignName, $campaignMedium, $campaignContent = '')
{
if (empty($url)) {
return '';
}
if (strpos($url, '?') === false) {
$url .= '?';
} else {
$url .= '&';
}
$url .= $this->getCampaignParametersForPromoUrl($campaignName, $campaignMedium, $campaignContent);
return $url;
} | [
"public",
"function",
"addPromoCampaignParametersToUrl",
"(",
"$",
"url",
",",
"$",
"campaignName",
",",
"$",
"campaignMedium",
",",
"$",
"campaignContent",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"return",
"''",
";",
"}"... | Appends campaign parameters to the given URL for promoting any Professional Support for Piwik service.
@param string $url
@param string $campaignName
@param string $campaignMedium
@param string $campaignContent
@return string | [
"Appends",
"campaign",
"parameters",
"to",
"the",
"given",
"URL",
"for",
"promoting",
"any",
"Professional",
"Support",
"for",
"Piwik",
"service",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/ProfessionalServices/Advertising.php#L78-L93 | train | Add campaign parameters to promo url | [
30522,
2270,
3853,
5587,
21572,
5302,
26468,
4886,
16206,
28689,
22828,
16033,
3126,
2140,
1006,
1002,
24471,
2140,
1010,
1002,
3049,
18442,
1010,
1002,
3049,
7583,
5007,
1010,
1002,
3049,
8663,
6528,
2102,
1027,
1005,
1005,
30524,
1063,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Mime/Header/IdentificationHeader.php | IdentificationHeader.setIds | public function setIds(array $ids)
{
$this->ids = [];
$this->idsAsAddresses = [];
foreach ($ids as $id) {
$this->idsAsAddresses[] = new Address($id);
$this->ids[] = $id;
}
} | php | public function setIds(array $ids)
{
$this->ids = [];
$this->idsAsAddresses = [];
foreach ($ids as $id) {
$this->idsAsAddresses[] = new Address($id);
$this->ids[] = $id;
}
} | [
"public",
"function",
"setIds",
"(",
"array",
"$",
"ids",
")",
"{",
"$",
"this",
"->",
"ids",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"idsAsAddresses",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"$",
"this",
"->",... | Set a collection of IDs to use in the value of this Header.
@param string[] $ids
@throws RfcComplianceException | [
"Set",
"a",
"collection",
"of",
"IDs",
"to",
"use",
"in",
"the",
"value",
"of",
"this",
"Header",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Mime/Header/IdentificationHeader.php#L86-L94 | train | Set the list of address ids | [
30522,
2270,
3853,
2275,
9821,
1006,
9140,
1002,
8909,
2015,
1007,
1063,
1002,
2023,
1011,
1028,
8909,
2015,
1027,
1031,
1033,
1025,
1002,
2023,
1011,
1028,
8909,
20939,
4215,
16200,
11393,
2015,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php | PropertyAccessDecorator.createListFromChoices | public function createListFromChoices($choices, $value = null)
{
if (\is_string($value)) {
$value = new PropertyPath($value);
}
if ($value instanceof PropertyPath) {
$accessor = $this->propertyAccessor;
$value = function ($choice) use ($accessor, $value) {
// The callable may be invoked with a non-object/array value
// when such values are passed to
// ChoiceListInterface::getValuesForChoices(). Handle this case
// so that the call to getValue() doesn't break.
if (\is_object($choice) || \is_array($choice)) {
return $accessor->getValue($choice, $value);
}
};
}
return $this->decoratedFactory->createListFromChoices($choices, $value);
} | php | public function createListFromChoices($choices, $value = null)
{
if (\is_string($value)) {
$value = new PropertyPath($value);
}
if ($value instanceof PropertyPath) {
$accessor = $this->propertyAccessor;
$value = function ($choice) use ($accessor, $value) {
// The callable may be invoked with a non-object/array value
// when such values are passed to
// ChoiceListInterface::getValuesForChoices(). Handle this case
// so that the call to getValue() doesn't break.
if (\is_object($choice) || \is_array($choice)) {
return $accessor->getValue($choice, $value);
}
};
}
return $this->decoratedFactory->createListFromChoices($choices, $value);
} | [
"public",
"function",
"createListFromChoices",
"(",
"$",
"choices",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"new",
"PropertyPath",
"(",
"$",
"value",
")",
";",
"}",
... | {@inheritdoc}
@param iterable $choices The choices
@param callable|string|PropertyPath|null $value The callable or path for
generating the choice values
@return ChoiceListInterface The choice list | [
"{",
"@inheritdoc",
"}"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/ChoiceList/Factory/PropertyAccessDecorator.php#L68-L88 | train | Create a list from choices | [
30522,
2270,
3853,
3443,
9863,
19699,
5358,
9905,
23522,
1006,
1002,
9804,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
1032,
2003,
1035,
5164,
1006,
1002,
3643,
1007,
1007,
1063,
1002,
3643,
1027,
2047,
3200,
15069,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Application.php | Application.registerCoreContainerAliases | public function registerCoreContainerAliases()
{
foreach ([
'app' => [\Illuminate\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class],
'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class],
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class],
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class],
'config' => [\Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class],
'cookie' => [\Illuminate\Cookie\CookieJar::class, \Illuminate\Contracts\Cookie\Factory::class, \Illuminate\Contracts\Cookie\QueueingFactory::class],
'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class],
'db' => [\Illuminate\Database\DatabaseManager::class],
'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class],
'events' => [\Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
'files' => [\Illuminate\Filesystem\Filesystem::class],
'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class],
'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class],
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
'hash' => [\Illuminate\Hashing\HashManager::class],
'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class],
'translator' => [\Illuminate\Translation\Translator::class, \Illuminate\Contracts\Translation\Translator::class],
'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
'auth.password' => [\Illuminate\Auth\Passwords\PasswordBrokerManager::class, \Illuminate\Contracts\Auth\PasswordBrokerFactory::class],
'auth.password.broker' => [\Illuminate\Auth\Passwords\PasswordBroker::class, \Illuminate\Contracts\Auth\PasswordBroker::class],
'queue' => [\Illuminate\Queue\QueueManager::class, \Illuminate\Contracts\Queue\Factory::class, \Illuminate\Contracts\Queue\Monitor::class],
'queue.connection' => [\Illuminate\Contracts\Queue\Queue::class],
'queue.failer' => [\Illuminate\Queue\Failed\FailedJobProviderInterface::class],
'redirect' => [\Illuminate\Routing\Redirector::class],
'redis' => [\Illuminate\Redis\RedisManager::class, \Illuminate\Contracts\Redis\Factory::class],
'request' => [\Illuminate\Http\Request::class, \Symfony\Component\HttpFoundation\Request::class],
'router' => [\Illuminate\Routing\Router::class, \Illuminate\Contracts\Routing\Registrar::class, \Illuminate\Contracts\Routing\BindingRegistrar::class],
'session' => [\Illuminate\Session\SessionManager::class],
'session.store' => [\Illuminate\Session\Store::class, \Illuminate\Contracts\Session\Session::class],
'url' => [\Illuminate\Routing\UrlGenerator::class, \Illuminate\Contracts\Routing\UrlGenerator::class],
'validator' => [\Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class],
'view' => [\Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class],
] as $key => $aliases) {
foreach ($aliases as $alias) {
$this->alias($key, $alias);
}
}
} | php | public function registerCoreContainerAliases()
{
foreach ([
'app' => [\Illuminate\Foundation\Application::class, \Illuminate\Contracts\Container\Container::class, \Illuminate\Contracts\Foundation\Application::class, \Psr\Container\ContainerInterface::class],
'auth' => [\Illuminate\Auth\AuthManager::class, \Illuminate\Contracts\Auth\Factory::class],
'auth.driver' => [\Illuminate\Contracts\Auth\Guard::class],
'blade.compiler' => [\Illuminate\View\Compilers\BladeCompiler::class],
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class],
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class],
'config' => [\Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class],
'cookie' => [\Illuminate\Cookie\CookieJar::class, \Illuminate\Contracts\Cookie\Factory::class, \Illuminate\Contracts\Cookie\QueueingFactory::class],
'encrypter' => [\Illuminate\Encryption\Encrypter::class, \Illuminate\Contracts\Encryption\Encrypter::class],
'db' => [\Illuminate\Database\DatabaseManager::class],
'db.connection' => [\Illuminate\Database\Connection::class, \Illuminate\Database\ConnectionInterface::class],
'events' => [\Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class],
'files' => [\Illuminate\Filesystem\Filesystem::class],
'filesystem' => [\Illuminate\Filesystem\FilesystemManager::class, \Illuminate\Contracts\Filesystem\Factory::class],
'filesystem.disk' => [\Illuminate\Contracts\Filesystem\Filesystem::class],
'filesystem.cloud' => [\Illuminate\Contracts\Filesystem\Cloud::class],
'hash' => [\Illuminate\Hashing\HashManager::class],
'hash.driver' => [\Illuminate\Contracts\Hashing\Hasher::class],
'translator' => [\Illuminate\Translation\Translator::class, \Illuminate\Contracts\Translation\Translator::class],
'log' => [\Illuminate\Log\LogManager::class, \Psr\Log\LoggerInterface::class],
'mailer' => [\Illuminate\Mail\Mailer::class, \Illuminate\Contracts\Mail\Mailer::class, \Illuminate\Contracts\Mail\MailQueue::class],
'auth.password' => [\Illuminate\Auth\Passwords\PasswordBrokerManager::class, \Illuminate\Contracts\Auth\PasswordBrokerFactory::class],
'auth.password.broker' => [\Illuminate\Auth\Passwords\PasswordBroker::class, \Illuminate\Contracts\Auth\PasswordBroker::class],
'queue' => [\Illuminate\Queue\QueueManager::class, \Illuminate\Contracts\Queue\Factory::class, \Illuminate\Contracts\Queue\Monitor::class],
'queue.connection' => [\Illuminate\Contracts\Queue\Queue::class],
'queue.failer' => [\Illuminate\Queue\Failed\FailedJobProviderInterface::class],
'redirect' => [\Illuminate\Routing\Redirector::class],
'redis' => [\Illuminate\Redis\RedisManager::class, \Illuminate\Contracts\Redis\Factory::class],
'request' => [\Illuminate\Http\Request::class, \Symfony\Component\HttpFoundation\Request::class],
'router' => [\Illuminate\Routing\Router::class, \Illuminate\Contracts\Routing\Registrar::class, \Illuminate\Contracts\Routing\BindingRegistrar::class],
'session' => [\Illuminate\Session\SessionManager::class],
'session.store' => [\Illuminate\Session\Store::class, \Illuminate\Contracts\Session\Session::class],
'url' => [\Illuminate\Routing\UrlGenerator::class, \Illuminate\Contracts\Routing\UrlGenerator::class],
'validator' => [\Illuminate\Validation\Factory::class, \Illuminate\Contracts\Validation\Factory::class],
'view' => [\Illuminate\View\Factory::class, \Illuminate\Contracts\View\Factory::class],
] as $key => $aliases) {
foreach ($aliases as $alias) {
$this->alias($key, $alias);
}
}
} | [
"public",
"function",
"registerCoreContainerAliases",
"(",
")",
"{",
"foreach",
"(",
"[",
"'app'",
"=>",
"[",
"\\",
"Illuminate",
"\\",
"Foundation",
"\\",
"Application",
"::",
"class",
",",
"\\",
"Illuminate",
"\\",
"Contracts",
"\\",
"Container",
"\\",
"Cont... | Register the core class aliases in the container.
@return void | [
"Register",
"the",
"core",
"class",
"aliases",
"in",
"the",
"container",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Application.php#L1118-L1161 | train | Register core container aliases | [
30522,
2270,
3853,
4236,
17345,
8663,
18249,
21673,
7951,
2229,
1006,
1007,
1063,
18921,
6776,
1006,
1031,
1005,
10439,
1005,
1027,
1028,
1031,
1032,
5665,
12717,
12556,
1032,
3192,
1032,
4646,
1024,
1024,
2465,
1010,
1032,
5665,
12717,
125... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Abstract.php | Zend_Db_Adapter_Abstract.fetchRow | public function fetchRow($sql, $bind = array(), $fetchMode = null)
{
if ($fetchMode === null) {
$fetchMode = $this->_fetchMode;
}
$stmt = $this->query($sql, $bind);
$result = $stmt->fetch($fetchMode);
return $result;
} | php | public function fetchRow($sql, $bind = array(), $fetchMode = null)
{
if ($fetchMode === null) {
$fetchMode = $this->_fetchMode;
}
$stmt = $this->query($sql, $bind);
$result = $stmt->fetch($fetchMode);
return $result;
} | [
"public",
"function",
"fetchRow",
"(",
"$",
"sql",
",",
"$",
"bind",
"=",
"array",
"(",
")",
",",
"$",
"fetchMode",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"fetchMode",
"===",
"null",
")",
"{",
"$",
"fetchMode",
"=",
"$",
"this",
"->",
"_fetchMode",... | Fetches the first row of the SQL result.
Uses the current fetchMode for the adapter.
@param string|Zend_Db_Select $sql An SQL SELECT statement.
@param mixed $bind Data to bind into SELECT placeholders.
@param mixed $fetchMode Override current fetch mode.
@return array | [
"Fetches",
"the",
"first",
"row",
"of",
"the",
"SQL",
"result",
".",
"Uses",
"the",
"current",
"fetchMode",
"for",
"the",
"adapter",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Abstract.php#L750-L758 | train | Returns the first row of the result set of a query | [
30522,
2270,
3853,
18584,
10524,
1006,
1002,
29296,
1010,
1002,
14187,
1027,
9140,
1006,
1007,
1010,
1002,
18584,
5302,
3207,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
18584,
5302,
3207,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
18584,
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/DomCrawler/FormFieldRegistry.php | FormFieldRegistry.create | private static function create($base, array $values)
{
$registry = new static();
$registry->base = $base;
$registry->fields = $values;
return $registry;
} | php | private static function create($base, array $values)
{
$registry = new static();
$registry->base = $base;
$registry->fields = $values;
return $registry;
} | [
"private",
"static",
"function",
"create",
"(",
"$",
"base",
",",
"array",
"$",
"values",
")",
"{",
"$",
"registry",
"=",
"new",
"static",
"(",
")",
";",
"$",
"registry",
"->",
"base",
"=",
"$",
"base",
";",
"$",
"registry",
"->",
"fields",
"=",
"$... | Creates an instance of the class.
This function is made private because it allows overriding the $base and
the $values properties without any type checking.
@param string $base The fully qualified name of the base field
@param array $values The values of the fields
@return static | [
"Creates",
"an",
"instance",
"of",
"the",
"class",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/FormFieldRegistry.php#L154-L161 | train | Create a new instance of the class | [
30522,
2797,
10763,
3853,
3443,
1006,
1002,
2918,
1010,
9140,
1002,
5300,
1007,
1063,
1002,
15584,
1027,
2047,
10763,
1006,
1007,
1025,
1002,
15584,
1011,
1028,
2918,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php | IdReader.getIdValue | public function getIdValue($object)
{
if (!$object) {
return;
}
if (!$this->om->contains($object)) {
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', \get_class($object)));
}
$this->om->initializeObject($object);
$idValue = current($this->classMetadata->getIdentifierValues($object));
if ($this->associationIdReader) {
$idValue = $this->associationIdReader->getIdValue($idValue);
}
return $idValue;
} | php | public function getIdValue($object)
{
if (!$object) {
return;
}
if (!$this->om->contains($object)) {
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', \get_class($object)));
}
$this->om->initializeObject($object);
$idValue = current($this->classMetadata->getIdentifierValues($object));
if ($this->associationIdReader) {
$idValue = $this->associationIdReader->getIdValue($idValue);
}
return $idValue;
} | [
"public",
"function",
"getIdValue",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"$",
"object",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"om",
"->",
"contains",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"RuntimeE... | Returns the ID value for an object.
This method assumes that the object has a single-column ID.
@param object $object The object
@return mixed The ID value | [
"Returns",
"the",
"ID",
"value",
"for",
"an",
"object",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php#L91-L110 | train | Returns the id value of the object | [
30522,
2270,
3853,
2131,
3593,
10175,
5657,
1006,
1002,
4874,
1007,
1063,
2065,
1006,
999,
1002,
4874,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
999,
1002,
2023,
1011,
1028,
18168,
1011,
1028,
3397,
1006,
1002,
4874,
1007,
1007,
1063,
546... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/InlineServiceDefinitionsPass.php | InlineServiceDefinitionsPass.setRepeatedPass | public function setRepeatedPass(RepeatedPass $repeatedPass)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
$this->repeatedPass = $repeatedPass;
} | php | public function setRepeatedPass(RepeatedPass $repeatedPass)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
$this->repeatedPass = $repeatedPass;
} | [
"public",
"function",
"setRepeatedPass",
"(",
"RepeatedPass",
"$",
"repeatedPass",
")",
"{",
"@",
"trigger_error",
"(",
"sprintf",
"(",
"'The \"%s()\" method is deprecated since Symfony 4.2.'",
",",
"__METHOD__",
")",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
"this",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php#L43-L47 | train | Sets the repeated pass | [
30522,
2270,
3853,
2275,
2890,
5051,
4383,
15194,
1006,
5567,
15194,
1002,
5567,
15194,
1007,
1063,
1030,
9495,
1035,
7561,
1006,
9043,
2546,
1006,
1005,
1996,
1000,
1003,
1055,
1006,
1007,
1000,
4118,
2003,
2139,
28139,
12921,
2144,
25353,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Intl/Data/Provider/DateTimeFormatProvider.php | DateTimeFormatProvider.getFormatPattern | public function getFormatPattern($format)
{
switch ($format) {
case self::DATETIME_FORMAT_LONG:
return 'EEEE, MMMM d, y HH:mm:ss';
case self::DATETIME_FORMAT_SHORT:
return 'MMM d, y HH:mm:ss';
case self::DATE_FORMAT_LONG:
return 'EEEE, MMMM d, y';
case self::DATE_FORMAT_DAY_MONTH:
return 'E, MMM d';
case self::DATE_FORMAT_SHORT:
return 'MMM d, y';
case self::DATE_FORMAT_MONTH_SHORT:
return 'MMM y';
case self::DATE_FORMAT_MONTH_LONG:
return 'MMMM y';
case self::DATE_FORMAT_YEAR:
return 'y';
case self::TIME_FORMAT:
return 'HH:mm:ss';
}
return $format;
} | php | public function getFormatPattern($format)
{
switch ($format) {
case self::DATETIME_FORMAT_LONG:
return 'EEEE, MMMM d, y HH:mm:ss';
case self::DATETIME_FORMAT_SHORT:
return 'MMM d, y HH:mm:ss';
case self::DATE_FORMAT_LONG:
return 'EEEE, MMMM d, y';
case self::DATE_FORMAT_DAY_MONTH:
return 'E, MMM d';
case self::DATE_FORMAT_SHORT:
return 'MMM d, y';
case self::DATE_FORMAT_MONTH_SHORT:
return 'MMM y';
case self::DATE_FORMAT_MONTH_LONG:
return 'MMMM y';
case self::DATE_FORMAT_YEAR:
return 'y';
case self::TIME_FORMAT:
return 'HH:mm:ss';
}
return $format;
} | [
"public",
"function",
"getFormatPattern",
"(",
"$",
"format",
")",
"{",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"self",
"::",
"DATETIME_FORMAT_LONG",
":",
"return",
"'EEEE, MMMM d, y HH:mm:ss'",
";",
"case",
"self",
"::",
"DATETIME_FORMAT_SHORT",
":",
"r... | Returns the format pattern for the given format type
@param int $format one of the format constants
@return string | [
"Returns",
"the",
"format",
"pattern",
"for",
"the",
"given",
"format",
"type"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Intl/Data/Provider/DateTimeFormatProvider.php#L33-L65 | train | Return the format pattern | [
30522,
2270,
3853,
2131,
14192,
4017,
4502,
12079,
2078,
1006,
1002,
4289,
1007,
1063,
6942,
1006,
1002,
4289,
1007,
1063,
2553,
2969,
1024,
1024,
3058,
7292,
1035,
4289,
1035,
2146,
1024,
2709,
1005,
25212,
4402,
1010,
25391,
2213,
1040,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/MorphTo.php | MorphTo.matchToMorphParents | protected function matchToMorphParents($type, Collection $results)
{
foreach ($results as $result) {
$ownerKey = ! is_null($this->ownerKey) ? $result->{$this->ownerKey} : $result->getKey();
if (isset($this->dictionary[$type][$ownerKey])) {
foreach ($this->dictionary[$type][$ownerKey] as $model) {
$model->setRelation($this->relationName, $result);
}
}
}
} | php | protected function matchToMorphParents($type, Collection $results)
{
foreach ($results as $result) {
$ownerKey = ! is_null($this->ownerKey) ? $result->{$this->ownerKey} : $result->getKey();
if (isset($this->dictionary[$type][$ownerKey])) {
foreach ($this->dictionary[$type][$ownerKey] as $model) {
$model->setRelation($this->relationName, $result);
}
}
}
} | [
"protected",
"function",
"matchToMorphParents",
"(",
"$",
"type",
",",
"Collection",
"$",
"results",
")",
"{",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"ownerKey",
"=",
"!",
"is_null",
"(",
"$",
"this",
"->",
"ownerKey",
")",
... | Match the results for a given type to their parents.
@param string $type
@param \Illuminate\Database\Eloquent\Collection $results
@return void | [
"Match",
"the",
"results",
"for",
"a",
"given",
"type",
"to",
"their",
"parents",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/MorphTo.php#L167-L178 | train | Match to morph parents | [
30522,
5123,
3853,
2674,
20389,
2953,
8458,
19362,
11187,
1006,
1002,
2828,
1010,
3074,
1002,
3463,
1007,
1063,
18921,
6776,
1006,
1002,
3463,
2004,
1002,
2765,
1007,
1063,
1002,
3954,
14839,
1027,
999,
2003,
1035,
19701,
1006,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php | AbstractSurrogate.hasSurrogateCapability | public function hasSurrogateCapability(Request $request)
{
if (null === $value = $request->headers->get('Surrogate-Capability')) {
return false;
}
return false !== strpos($value, sprintf('%s/1.0', strtoupper($this->getName())));
} | php | public function hasSurrogateCapability(Request $request)
{
if (null === $value = $request->headers->get('Surrogate-Capability')) {
return false;
}
return false !== strpos($value, sprintf('%s/1.0', strtoupper($this->getName())));
} | [
"public",
"function",
"hasSurrogateCapability",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'Surrogate-Capability'",
")",
")",
"{",
"return",
"false",
";",
"}",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php#L54-L61 | train | Returns true if the request has the surrogate capability | [
30522,
2270,
3853,
2038,
26210,
21799,
17695,
8010,
1006,
5227,
1002,
5227,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
3643,
1027,
1002,
5227,
1011,
1028,
20346,
2015,
1011,
1028,
2131,
1006,
1005,
7505,
21799,
1011,
10673,
1005... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.routable | public function routable($var = null)
{
if ($var !== null) {
$this->routable = (bool)$var;
}
return $this->routable && $this->published();
} | php | public function routable($var = null)
{
if ($var !== null) {
$this->routable = (bool)$var;
}
return $this->routable && $this->published();
} | [
"public",
"function",
"routable",
"(",
"$",
"var",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"var",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"routable",
"=",
"(",
"bool",
")",
"$",
"var",
";",
"}",
"return",
"$",
"this",
"->",
"routable",
"&&",
... | Gets and Sets whether or not this Page is routable, ie you can reach it
via a URL.
The page must be *routable* and *published*
@param bool $var true if the page is routable
@return bool true if the page is routable | [
"Gets",
"and",
"Sets",
"whether",
"or",
"not",
"this",
"Page",
"is",
"routable",
"ie",
"you",
"can",
"reach",
"it",
"via",
"a",
"URL",
".",
"The",
"page",
"must",
"be",
"*",
"routable",
"*",
"and",
"*",
"published",
"*"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L1619-L1626 | train | Check if this page is routable | [
30522,
2270,
3853,
20996,
23056,
1006,
1002,
13075,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
13075,
999,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
20996,
23056,
1027,
1006,
22017,
2140,
1007,
1002,
13075,
1025,
1065,
2709,
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/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php | AbstractServiceConfigurator.load | final public function load(string $namespace, string $resource): PrototypeConfigurator
{
$this->__destruct();
return $this->parent->load($namespace, $resource);
} | php | final public function load(string $namespace, string $resource): PrototypeConfigurator
{
$this->__destruct();
return $this->parent->load($namespace, $resource);
} | [
"final",
"public",
"function",
"load",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"resource",
")",
":",
"PrototypeConfigurator",
"{",
"$",
"this",
"->",
"__destruct",
"(",
")",
";",
"return",
"$",
"this",
"->",
"parent",
"->",
"load",
"(",
"$",... | Registers a PSR-4 namespace using a glob pattern. | [
"Registers",
"a",
"PSR",
"-",
"4",
"namespace",
"using",
"a",
"glob",
"pattern",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractServiceConfigurator.php#L65-L70 | train | Loads a namespace and resource | [
30522,
2345,
2270,
3853,
7170,
1006,
5164,
1002,
3415,
15327,
1010,
5164,
1002,
7692,
1007,
1024,
8773,
8663,
8873,
27390,
8844,
1063,
1002,
2023,
1011,
1028,
1035,
1035,
4078,
18300,
1006,
1007,
1025,
2709,
1002,
2023,
1011,
1028,
6687,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php | BoundArgument.setValues | public function setValues(array $values)
{
if (5 === \count($values)) {
list($this->value, $this->identifier, $this->used, $this->type, $this->file) = $values;
} else {
list($this->value, $this->identifier, $this->used) = $values;
}
} | php | public function setValues(array $values)
{
if (5 === \count($values)) {
list($this->value, $this->identifier, $this->used, $this->type, $this->file) = $values;
} else {
list($this->value, $this->identifier, $this->used) = $values;
}
} | [
"public",
"function",
"setValues",
"(",
"array",
"$",
"values",
")",
"{",
"if",
"(",
"5",
"===",
"\\",
"count",
"(",
"$",
"values",
")",
")",
"{",
"list",
"(",
"$",
"this",
"->",
"value",
",",
"$",
"this",
"->",
"identifier",
",",
"$",
"this",
"-... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Argument/BoundArgument.php#L54-L61 | train | setValues - Set the values of the attribute | [
30522,
2270,
3853,
2275,
10175,
15808,
1006,
9140,
1002,
5300,
1007,
1063,
2065,
1006,
1019,
1027,
1027,
1027,
1032,
4175,
1006,
1002,
5300,
1007,
1007,
1063,
2862,
1006,
1002,
2023,
1011,
1028,
3643,
1010,
1002,
2023,
1011,
1028,
8909,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/MobileMessaging/API.php | API.deleteSMSAPICredential | public function deleteSMSAPICredential()
{
$this->checkCredentialManagementRights();
$settings = $this->getCredentialManagerSettings();
$settings[MobileMessaging::API_KEY_OPTION] = null;
$this->setCredentialManagerSettings($settings);
return true;
} | php | public function deleteSMSAPICredential()
{
$this->checkCredentialManagementRights();
$settings = $this->getCredentialManagerSettings();
$settings[MobileMessaging::API_KEY_OPTION] = null;
$this->setCredentialManagerSettings($settings);
return true;
} | [
"public",
"function",
"deleteSMSAPICredential",
"(",
")",
"{",
"$",
"this",
"->",
"checkCredentialManagementRights",
"(",
")",
";",
"$",
"settings",
"=",
"$",
"this",
"->",
"getCredentialManagerSettings",
"(",
")",
";",
"$",
"settings",
"[",
"MobileMessaging",
"... | delete the SMS API credential
@return bool true | [
"delete",
"the",
"SMS",
"API",
"credential"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/MobileMessaging/API.php#L346-L357 | train | Delete SMS API Credential | [
30522,
30524,
10906,
1027,
1002,
2023,
1011,
1028,
2131,
16748,
16454,
4818,
24805,
15776,
18319,
3070,
2015,
1006,
1007,
1025,
1002,
10906,
1031,
4684,
7834,
3736,
4726,
1024,
1024,
17928,
1035,
3145,
1035,
5724,
1033,
1027,
19701,
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... |
symfony/symfony | src/Symfony/Component/Translation/LoggingTranslator.php | LoggingTranslator.log | private function log($id, $domain, $locale)
{
if (null === $domain) {
$domain = 'messages';
}
$id = (string) $id;
$catalogue = $this->translator->getCatalogue($locale);
if ($catalogue->defines($id, $domain)) {
return;
}
if ($catalogue->has($id, $domain)) {
$this->logger->debug('Translation use fallback catalogue.', ['id' => $id, 'domain' => $domain, 'locale' => $catalogue->getLocale()]);
} else {
$this->logger->warning('Translation not found.', ['id' => $id, 'domain' => $domain, 'locale' => $catalogue->getLocale()]);
}
} | php | private function log($id, $domain, $locale)
{
if (null === $domain) {
$domain = 'messages';
}
$id = (string) $id;
$catalogue = $this->translator->getCatalogue($locale);
if ($catalogue->defines($id, $domain)) {
return;
}
if ($catalogue->has($id, $domain)) {
$this->logger->debug('Translation use fallback catalogue.', ['id' => $id, 'domain' => $domain, 'locale' => $catalogue->getLocale()]);
} else {
$this->logger->warning('Translation not found.', ['id' => $id, 'domain' => $domain, 'locale' => $catalogue->getLocale()]);
}
} | [
"private",
"function",
"log",
"(",
"$",
"id",
",",
"$",
"domain",
",",
"$",
"locale",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"domain",
")",
"{",
"$",
"domain",
"=",
"'messages'",
";",
"}",
"$",
"id",
"=",
"(",
"string",
")",
"$",
"id",
";",
... | Logs for missing translations.
@param string $id
@param string|null $domain
@param string|null $locale | [
"Logs",
"for",
"missing",
"translations",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/LoggingTranslator.php#L135-L152 | train | Log translation. | [
30522,
2797,
3853,
8833,
1006,
1002,
8909,
1010,
1002,
5884,
1010,
1002,
2334,
2063,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
5884,
1007,
1063,
1002,
5884,
1027,
1005,
7696,
1005,
1025,
1065,
1002,
8909,
1027,
1006,
5164,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Tracker/Db/Pdo/Mysql.php | Mysql.fetchCol | public function fetchCol($sql, $bind = array())
{
try {
$sth = $this->query($sql, $bind);
if ($sth === false) {
return false;
}
$result = $sth->fetchAll(PDO::FETCH_COLUMN, 0);
return $result;
} catch (PDOException $e) {
throw new DbException("Error query: " . $e->getMessage());
}
} | php | public function fetchCol($sql, $bind = array())
{
try {
$sth = $this->query($sql, $bind);
if ($sth === false) {
return false;
}
$result = $sth->fetchAll(PDO::FETCH_COLUMN, 0);
return $result;
} catch (PDOException $e) {
throw new DbException("Error query: " . $e->getMessage());
}
} | [
"public",
"function",
"fetchCol",
"(",
"$",
"sql",
",",
"$",
"bind",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"$",
"sth",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"sql",
",",
"$",
"bind",
")",
";",
"if",
"(",
"$",
"sth",
"===",
"false"... | Fetches the first column of all SQL result rows as an array.
@param string $sql An SQL SELECT statement.
@param mixed $bind Data to bind into SELECT placeholders.
@throws \Piwik\Tracker\Db\DbException
@return string | [
"Fetches",
"the",
"first",
"column",
"of",
"all",
"SQL",
"result",
"rows",
"as",
"an",
"array",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Tracker/Db/Pdo/Mysql.php#L172-L184 | train | Fetch a single column from the result set | [
30522,
2270,
3853,
18584,
25778,
1006,
1002,
29296,
1010,
1002,
14187,
1027,
9140,
1006,
1007,
1007,
1063,
3046,
1063,
1002,
2358,
2232,
1027,
1002,
2023,
1011,
1028,
23032,
1006,
1002,
29296,
1010,
1002,
14187,
1007,
1025,
2065,
1006,
1002... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/API/API.php | API.getSuggestedValuesForSegment | public function getSuggestedValuesForSegment($segmentName, $idSite)
{
if (empty(Config::getInstance()->General['enable_segment_suggested_values'])) {
return array();
}
Piwik::checkUserHasViewAccess($idSite);
$maxSuggestionsToReturn = 30;
$segment = $this->findSegment($segmentName, $idSite);
// if segment has suggested values callback then return result from it instead
$suggestedValuesCallbackRequiresTable = false;
if (isset($segment['suggestedValuesCallback'])) {
$suggestedValuesCallbackRequiresTable = $this->doesSuggestedValuesCallbackNeedData(
$segment['suggestedValuesCallback']);
if (!$suggestedValuesCallbackRequiresTable) {
return call_user_func($segment['suggestedValuesCallback'], $idSite, $maxSuggestionsToReturn);
}
}
// if period=range is disabled, do not proceed
if (!Period\Factory::isPeriodEnabledForAPI('range')) {
return array();
}
if (!empty($segment['unionOfSegments'])) {
$values = array();
foreach ($segment['unionOfSegments'] as $unionSegmentName) {
$unionSegment = $this->findSegment($unionSegmentName, $idSite);
try {
$result = $this->getSuggestedValuesForSegmentName($idSite, $unionSegment, $maxSuggestionsToReturn);
if (!empty($result)) {
$values = array_merge($result, $values);
}
} catch (\Exception $e) {
// we ignore if there was no data found for $unionSegmentName
}
}
if (empty($values)) {
throw new \Exception("There was no data to suggest for $segmentName");
}
} else {
$values = $this->getSuggestedValuesForSegmentName($idSite, $segment, $maxSuggestionsToReturn);
}
$values = $this->getMostFrequentValues($values);
$values = array_slice($values, 0, $maxSuggestionsToReturn);
$values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values);
return $values;
} | php | public function getSuggestedValuesForSegment($segmentName, $idSite)
{
if (empty(Config::getInstance()->General['enable_segment_suggested_values'])) {
return array();
}
Piwik::checkUserHasViewAccess($idSite);
$maxSuggestionsToReturn = 30;
$segment = $this->findSegment($segmentName, $idSite);
// if segment has suggested values callback then return result from it instead
$suggestedValuesCallbackRequiresTable = false;
if (isset($segment['suggestedValuesCallback'])) {
$suggestedValuesCallbackRequiresTable = $this->doesSuggestedValuesCallbackNeedData(
$segment['suggestedValuesCallback']);
if (!$suggestedValuesCallbackRequiresTable) {
return call_user_func($segment['suggestedValuesCallback'], $idSite, $maxSuggestionsToReturn);
}
}
// if period=range is disabled, do not proceed
if (!Period\Factory::isPeriodEnabledForAPI('range')) {
return array();
}
if (!empty($segment['unionOfSegments'])) {
$values = array();
foreach ($segment['unionOfSegments'] as $unionSegmentName) {
$unionSegment = $this->findSegment($unionSegmentName, $idSite);
try {
$result = $this->getSuggestedValuesForSegmentName($idSite, $unionSegment, $maxSuggestionsToReturn);
if (!empty($result)) {
$values = array_merge($result, $values);
}
} catch (\Exception $e) {
// we ignore if there was no data found for $unionSegmentName
}
}
if (empty($values)) {
throw new \Exception("There was no data to suggest for $segmentName");
}
} else {
$values = $this->getSuggestedValuesForSegmentName($idSite, $segment, $maxSuggestionsToReturn);
}
$values = $this->getMostFrequentValues($values);
$values = array_slice($values, 0, $maxSuggestionsToReturn);
$values = array_map(array('Piwik\Common', 'unsanitizeInputValue'), $values);
return $values;
} | [
"public",
"function",
"getSuggestedValuesForSegment",
"(",
"$",
"segmentName",
",",
"$",
"idSite",
")",
"{",
"if",
"(",
"empty",
"(",
"Config",
"::",
"getInstance",
"(",
")",
"->",
"General",
"[",
"'enable_segment_suggested_values'",
"]",
")",
")",
"{",
"retur... | Given a segment, will return a list of the most used values for this particular segment.
@param $segmentName
@param $idSite
@throws \Exception
@return array | [
"Given",
"a",
"segment",
"will",
"return",
"a",
"list",
"of",
"the",
"most",
"used",
"values",
"for",
"this",
"particular",
"segment",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/API.php#L566-L621 | train | Returns the suggested values for the given site | [
30522,
2270,
3853,
4152,
15916,
8449,
3064,
10175,
15808,
29278,
3366,
21693,
4765,
1006,
1002,
6903,
18442,
1010,
1002,
8909,
28032,
2063,
1007,
1063,
2065,
1006,
4064,
1006,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Validation/Concerns/ReplacesAttributes.php | ReplacesAttributes.replaceBeforeOrEqual | protected function replaceBeforeOrEqual($message, $attribute, $rule, $parameters)
{
return $this->replaceBefore($message, $attribute, $rule, $parameters);
} | php | protected function replaceBeforeOrEqual($message, $attribute, $rule, $parameters)
{
return $this->replaceBefore($message, $attribute, $rule, $parameters);
} | [
"protected",
"function",
"replaceBeforeOrEqual",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"replaceBefore",
"(",
"$",
"message",
",",
"$",
"attribute",
",",
"$",
"rule",
"... | Replace all place-holders for the before_or_equal rule.
@param string $message
@param string $attribute
@param string $rule
@param array $parameters
@return string | [
"Replace",
"all",
"place",
"-",
"holders",
"for",
"the",
"before_or_equal",
"rule",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ReplacesAttributes.php#L404-L407 | train | Replace all place - holders for the before_or_equal rule. | [
30522,
5123,
3853,
5672,
4783,
29278,
8780,
2890,
26426,
1006,
1002,
4471,
1010,
1002,
17961,
1010,
1002,
3627,
1010,
1002,
11709,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
5672,
4783,
29278,
2063,
1006,
1002,
4471,
1010,
1002,
17961,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Query/Builder.php | Builder.truncate | public function truncate()
{
foreach ($this->grammar->compileTruncate($this) as $sql => $bindings) {
$this->connection->statement($sql, $bindings);
}
} | php | public function truncate()
{
foreach ($this->grammar->compileTruncate($this) as $sql => $bindings) {
$this->connection->statement($sql, $bindings);
}
} | [
"public",
"function",
"truncate",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"grammar",
"->",
"compileTruncate",
"(",
"$",
"this",
")",
"as",
"$",
"sql",
"=>",
"$",
"bindings",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"statement",
"(",
... | Run a truncate statement on the table.
@return void | [
"Run",
"a",
"truncate",
"statement",
"on",
"the",
"table",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Query/Builder.php#L2781-L2786 | train | Truncate the table | [
30522,
2270,
3853,
19817,
4609,
16280,
1006,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
8035,
1011,
1028,
4012,
22090,
16344,
4609,
16280,
1006,
1002,
2023,
1007,
2004,
1002,
29296,
1027,
1028,
1002,
8031,
2015,
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... |
z-song/laravel-admin | src/Console/MakeCommand.php | MakeCommand.getNameInput | protected function getNameInput()
{
$name = trim($this->argument('name'));
$this->type = $this->qualifyClass($name);
return $name;
} | php | protected function getNameInput()
{
$name = trim($this->argument('name'));
$this->type = $this->qualifyClass($name);
return $name;
} | [
"protected",
"function",
"getNameInput",
"(",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"this",
"->",
"qualifyClass",
"(",
"$",
"name",
")",
";",
"retu... | Get the desired class name from the input.
@return string | [
"Get",
"the",
"desired",
"class",
"name",
"from",
"the",
"input",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/MakeCommand.php#L170-L177 | train | Get name input | [
30522,
5123,
3853,
2131,
18442,
2378,
18780,
1006,
1007,
1063,
1002,
2171,
1027,
12241,
1006,
1002,
2023,
1011,
1028,
6685,
1006,
1005,
2171,
1005,
1007,
1007,
1025,
1002,
2023,
1011,
1028,
2828,
1027,
1002,
2023,
1011,
1028,
7515,
26266,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Http/UploadedFile.php | UploadedFile.parseUploadedFiles | private static function parseUploadedFiles(array $uploadedFiles)
{
$parsed = [];
foreach ($uploadedFiles as $field => $uploadedFile) {
if (!isset($uploadedFile['error'])) {
if (is_array($uploadedFile)) {
$parsed[$field] = static::parseUploadedFiles($uploadedFile);
}
continue;
}
$parsed[$field] = [];
if (!is_array($uploadedFile['error'])) {
$parsed[$field] = new static(
$uploadedFile['tmp_name'],
isset($uploadedFile['name']) ? $uploadedFile['name'] : null,
isset($uploadedFile['type']) ? $uploadedFile['type'] : null,
isset($uploadedFile['size']) ? $uploadedFile['size'] : null,
$uploadedFile['error'],
true
);
} else {
$subArray = [];
foreach ($uploadedFile['error'] as $fileIdx => $error) {
// normalise subarray and re-parse to move the input's keyname up a level
$subArray[$fileIdx]['name'] = $uploadedFile['name'][$fileIdx];
$subArray[$fileIdx]['type'] = $uploadedFile['type'][$fileIdx];
$subArray[$fileIdx]['tmp_name'] = $uploadedFile['tmp_name'][$fileIdx];
$subArray[$fileIdx]['error'] = $uploadedFile['error'][$fileIdx];
$subArray[$fileIdx]['size'] = $uploadedFile['size'][$fileIdx];
$parsed[$field] = static::parseUploadedFiles($subArray);
}
}
}
return $parsed;
} | php | private static function parseUploadedFiles(array $uploadedFiles)
{
$parsed = [];
foreach ($uploadedFiles as $field => $uploadedFile) {
if (!isset($uploadedFile['error'])) {
if (is_array($uploadedFile)) {
$parsed[$field] = static::parseUploadedFiles($uploadedFile);
}
continue;
}
$parsed[$field] = [];
if (!is_array($uploadedFile['error'])) {
$parsed[$field] = new static(
$uploadedFile['tmp_name'],
isset($uploadedFile['name']) ? $uploadedFile['name'] : null,
isset($uploadedFile['type']) ? $uploadedFile['type'] : null,
isset($uploadedFile['size']) ? $uploadedFile['size'] : null,
$uploadedFile['error'],
true
);
} else {
$subArray = [];
foreach ($uploadedFile['error'] as $fileIdx => $error) {
// normalise subarray and re-parse to move the input's keyname up a level
$subArray[$fileIdx]['name'] = $uploadedFile['name'][$fileIdx];
$subArray[$fileIdx]['type'] = $uploadedFile['type'][$fileIdx];
$subArray[$fileIdx]['tmp_name'] = $uploadedFile['tmp_name'][$fileIdx];
$subArray[$fileIdx]['error'] = $uploadedFile['error'][$fileIdx];
$subArray[$fileIdx]['size'] = $uploadedFile['size'][$fileIdx];
$parsed[$field] = static::parseUploadedFiles($subArray);
}
}
}
return $parsed;
} | [
"private",
"static",
"function",
"parseUploadedFiles",
"(",
"array",
"$",
"uploadedFiles",
")",
"{",
"$",
"parsed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"uploadedFiles",
"as",
"$",
"field",
"=>",
"$",
"uploadedFile",
")",
"{",
"if",
"(",
"!",
"isset"... | Parse a non-normalized, i.e. $_FILES superglobal, tree of uploaded file data.
Returns a normalized tree of UploadedFile instances.
@param array $uploadedFiles The non-normalized tree of uploaded file data.
@return array | [
"Parse",
"a",
"non",
"-",
"normalized",
"i",
".",
"e",
".",
"$_FILES",
"superglobal",
"tree",
"of",
"uploaded",
"file",
"data",
"."
] | ccef5f7d8bcd469d59cbe64f6210d83764f91543 | https://github.com/slimphp/Slim/blob/ccef5f7d8bcd469d59cbe64f6210d83764f91543/Slim/Http/UploadedFile.php#L110-L147 | train | Parses uploaded files into an array of File objects | [
30522,
2797,
10763,
3853,
11968,
3366,
6279,
17468,
8873,
4244,
1006,
9140,
1002,
21345,
8873,
4244,
1007,
1063,
1002,
11968,
6924,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
21345,
8873,
4244,
2004,
1002,
2492,
1027,
1028,
1002,
2134... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Routing/RouteUrlGenerator.php | RouteUrlGenerator.getRouteDomain | protected function getRouteDomain($route, &$parameters)
{
return $route->getDomain() ? $this->formatDomain($route, $parameters) : null;
} | php | protected function getRouteDomain($route, &$parameters)
{
return $route->getDomain() ? $this->formatDomain($route, $parameters) : null;
} | [
"protected",
"function",
"getRouteDomain",
"(",
"$",
"route",
",",
"&",
"$",
"parameters",
")",
"{",
"return",
"$",
"route",
"->",
"getDomain",
"(",
")",
"?",
"$",
"this",
"->",
"formatDomain",
"(",
"$",
"route",
",",
"$",
"parameters",
")",
":",
"null... | Get the formatted domain for a given route.
@param \Illuminate\Routing\Route $route
@param array $parameters
@return string | [
"Get",
"the",
"formatted",
"domain",
"for",
"a",
"given",
"route",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/RouteUrlGenerator.php#L119-L122 | train | Get domain of route | [
30522,
5123,
3853,
2131,
25849,
9626,
2378,
1006,
1002,
2799,
1010,
1004,
1002,
11709,
1007,
1063,
2709,
1002,
2799,
1011,
1028,
2131,
9527,
8113,
1006,
1007,
1029,
1002,
2023,
1011,
1028,
4289,
9527,
8113,
1006,
1002,
2799,
1010,
1002,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Concerns/BuildsQueries.php | BuildsQueries.paginator | protected function paginator($items, $total, $perPage, $currentPage, $options)
{
return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
'items', 'total', 'perPage', 'currentPage', 'options'
));
} | php | protected function paginator($items, $total, $perPage, $currentPage, $options)
{
return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
'items', 'total', 'perPage', 'currentPage', 'options'
));
} | [
"protected",
"function",
"paginator",
"(",
"$",
"items",
",",
"$",
"total",
",",
"$",
"perPage",
",",
"$",
"currentPage",
",",
"$",
"options",
")",
"{",
"return",
"Container",
"::",
"getInstance",
"(",
")",
"->",
"makeWith",
"(",
"LengthAwarePaginator",
":... | Create a new length-aware paginator instance.
@param \Illuminate\Support\Collection $items
@param int $total
@param int $perPage
@param int $currentPage
@param array $options
@return \Illuminate\Pagination\LengthAwarePaginator | [
"Create",
"a",
"new",
"length",
"-",
"aware",
"paginator",
"instance",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Concerns/BuildsQueries.php#L139-L144 | train | Create a paginator for the items | [
30522,
5123,
3853,
6643,
20876,
4263,
1006,
1002,
5167,
1010,
1002,
2561,
1010,
1002,
2566,
13704,
1010,
1002,
2783,
13704,
1010,
1002,
7047,
1007,
1063,
2709,
11661,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1011,
1028,
2191,
24415,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Validator/Constraints/IssnValidator.php | IssnValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Issn) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Issn');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
$canonical = $value;
// 1234-567X
// ^
if (isset($canonical[4]) && '-' === $canonical[4]) {
// remove hyphen
$canonical = substr($canonical, 0, 4).substr($canonical, 5);
} elseif ($constraint->requireHyphen) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::MISSING_HYPHEN_ERROR)
->addViolation();
return;
}
$length = \strlen($canonical);
if ($length < 8) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::TOO_SHORT_ERROR)
->addViolation();
return;
}
if ($length > 8) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::TOO_LONG_ERROR)
->addViolation();
return;
}
// 1234567X
// ^^^^^^^ digits only
if (!ctype_digit(substr($canonical, 0, 7))) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
// 1234567X
// ^ digit, x or X
if (!ctype_digit($canonical[7]) && 'x' !== $canonical[7] && 'X' !== $canonical[7]) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
// 1234567X
// ^ case-sensitive?
if ($constraint->caseSensitive && 'x' === $canonical[7]) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::INVALID_CASE_ERROR)
->addViolation();
return;
}
// Calculate a checksum. "X" equals 10.
$checkSum = 'X' === $canonical[7]
|| 'x' === $canonical[7]
? 10
: $canonical[7];
for ($i = 0; $i < 7; ++$i) {
// Multiply the first digit by 8, the second by 7, etc.
$checkSum += (8 - $i) * $canonical[$i];
}
if (0 !== $checkSum % 11) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::CHECKSUM_FAILED_ERROR)
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof Issn) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Issn');
}
if (null === $value || '' === $value) {
return;
}
if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
$canonical = $value;
// 1234-567X
// ^
if (isset($canonical[4]) && '-' === $canonical[4]) {
// remove hyphen
$canonical = substr($canonical, 0, 4).substr($canonical, 5);
} elseif ($constraint->requireHyphen) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::MISSING_HYPHEN_ERROR)
->addViolation();
return;
}
$length = \strlen($canonical);
if ($length < 8) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::TOO_SHORT_ERROR)
->addViolation();
return;
}
if ($length > 8) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::TOO_LONG_ERROR)
->addViolation();
return;
}
// 1234567X
// ^^^^^^^ digits only
if (!ctype_digit(substr($canonical, 0, 7))) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
// 1234567X
// ^ digit, x or X
if (!ctype_digit($canonical[7]) && 'x' !== $canonical[7] && 'X' !== $canonical[7]) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::INVALID_CHARACTERS_ERROR)
->addViolation();
return;
}
// 1234567X
// ^ case-sensitive?
if ($constraint->caseSensitive && 'x' === $canonical[7]) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::INVALID_CASE_ERROR)
->addViolation();
return;
}
// Calculate a checksum. "X" equals 10.
$checkSum = 'X' === $canonical[7]
|| 'x' === $canonical[7]
? 10
: $canonical[7];
for ($i = 0; $i < 7; ++$i) {
// Multiply the first digit by 8, the second by 7, etc.
$checkSum += (8 - $i) * $canonical[$i];
}
if (0 !== $checkSum % 11) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Issn::CHECKSUM_FAILED_ERROR)
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"Issn",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAMESPACE__",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/IssnValidator.php#L32-L133 | train | Validate the value | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
23486,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
1035,
3415,
15327,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/LocationProvider/DefaultProvider.php | DefaultProvider.getSupportedLocationInfo | public function getSupportedLocationInfo()
{
return array(self::CONTINENT_CODE_KEY => true,
self::CONTINENT_NAME_KEY => true,
self::COUNTRY_CODE_KEY => true,
self::COUNTRY_NAME_KEY => true);
} | php | public function getSupportedLocationInfo()
{
return array(self::CONTINENT_CODE_KEY => true,
self::CONTINENT_NAME_KEY => true,
self::COUNTRY_CODE_KEY => true,
self::COUNTRY_NAME_KEY => true);
} | [
"public",
"function",
"getSupportedLocationInfo",
"(",
")",
"{",
"return",
"array",
"(",
"self",
"::",
"CONTINENT_CODE_KEY",
"=>",
"true",
",",
"self",
"::",
"CONTINENT_NAME_KEY",
"=>",
"true",
",",
"self",
"::",
"COUNTRY_CODE_KEY",
"=>",
"true",
",",
"self",
... | Returns an array describing the types of location information this provider will
return.
This provider supports the following types of location info:
- continent code
- continent name
- country code
- country name
@return array | [
"Returns",
"an",
"array",
"describing",
"the",
"types",
"of",
"location",
"information",
"this",
"provider",
"will",
"return",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/LocationProvider/DefaultProvider.php#L83-L89 | train | Get supported location info | [
30522,
2270,
3853,
4152,
6279,
6442,
2098,
4135,
10719,
2378,
14876,
1006,
1007,
1063,
2709,
9140,
1006,
2969,
1024,
1024,
9983,
1035,
3642,
1035,
3145,
1027,
1028,
2995,
1010,
2969,
1024,
1024,
9983,
1035,
2171,
1035,
3145,
1027,
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/Queue/Listener.php | Listener.makeProcess | public function makeProcess($connection, $queue, ListenerOptions $options)
{
$command = $this->createCommand(
$connection,
$queue,
$options
);
// If the environment is set, we will append it to the command array so the
// workers will run under the specified environment. Otherwise, they will
// just run under the production environment which is not always right.
if (isset($options->environment)) {
$command = $this->addEnvironment($command, $options);
}
return new Process(
$command,
$this->commandPath,
null,
null,
$options->timeout
);
} | php | public function makeProcess($connection, $queue, ListenerOptions $options)
{
$command = $this->createCommand(
$connection,
$queue,
$options
);
// If the environment is set, we will append it to the command array so the
// workers will run under the specified environment. Otherwise, they will
// just run under the production environment which is not always right.
if (isset($options->environment)) {
$command = $this->addEnvironment($command, $options);
}
return new Process(
$command,
$this->commandPath,
null,
null,
$options->timeout
);
} | [
"public",
"function",
"makeProcess",
"(",
"$",
"connection",
",",
"$",
"queue",
",",
"ListenerOptions",
"$",
"options",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"createCommand",
"(",
"$",
"connection",
",",
"$",
"queue",
",",
"$",
"options",
")"... | Create a new Symfony process for the worker.
@param string $connection
@param string $queue
@param \Illuminate\Queue\ListenerOptions $options
@return \Symfony\Component\Process\Process | [
"Create",
"a",
"new",
"Symfony",
"process",
"for",
"the",
"worker",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Listener.php#L102-L124 | train | Creates a process for the given connection and queue | [
30522,
2270,
3853,
2191,
21572,
9623,
2015,
1006,
1002,
4434,
1010,
1002,
24240,
1010,
19373,
7361,
9285,
1002,
7047,
1007,
1063,
1002,
3094,
1027,
1002,
2023,
1011,
1028,
3443,
9006,
2386,
2094,
1006,
1002,
4434,
1010,
1002,
24240,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.copyBrokenImage | protected function copyBrokenImage($path)
{
try {
$thumbnailDir = dirname($path);
if (!File::isDirectory($thumbnailDir) && File::makeDirectory($thumbnailDir, 0777, true) === false) {
return;
}
File::copy($this->getBrokenImagePath(), $path);
}
catch (Exception $ex) {
traceLog($ex->getMessage());
}
} | php | protected function copyBrokenImage($path)
{
try {
$thumbnailDir = dirname($path);
if (!File::isDirectory($thumbnailDir) && File::makeDirectory($thumbnailDir, 0777, true) === false) {
return;
}
File::copy($this->getBrokenImagePath(), $path);
}
catch (Exception $ex) {
traceLog($ex->getMessage());
}
} | [
"protected",
"function",
"copyBrokenImage",
"(",
"$",
"path",
")",
"{",
"try",
"{",
"$",
"thumbnailDir",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"File",
"::",
"isDirectory",
"(",
"$",
"thumbnailDir",
")",
"&&",
"File",
"::",
"makeDi... | Copy broken image to destination
@param string $path
@return void | [
"Copy",
"broken",
"image",
"to",
"destination"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L1431-L1444 | train | Copy broken image to destination path | [
30522,
5123,
3853,
6100,
29162,
9581,
3351,
1006,
1002,
4130,
1007,
1063,
3046,
1063,
1002,
7639,
25464,
4305,
2099,
1027,
16101,
18442,
1006,
1002,
4130,
1007,
1025,
2065,
1006,
999,
5371,
1024,
1024,
2003,
4305,
2890,
16761,
2100,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php | MockFileSessionStorage.save | public function save()
{
if (!$this->started) {
throw new \RuntimeException('Trying to save a session that was not started yet or was already closed');
}
$data = $this->data;
foreach ($this->bags as $bag) {
if (empty($data[$key = $bag->getStorageKey()])) {
unset($data[$key]);
}
}
if ([$key = $this->metadataBag->getStorageKey()] === array_keys($data)) {
unset($data[$key]);
}
try {
if ($data) {
file_put_contents($this->getFilePath(), serialize($data));
} else {
$this->destroy();
}
} finally {
$this->data = $data;
}
// this is needed for Silex, where the session object is re-used across requests
// in functional tests. In Symfony, the container is rebooted, so we don't have
// this issue
$this->started = false;
} | php | public function save()
{
if (!$this->started) {
throw new \RuntimeException('Trying to save a session that was not started yet or was already closed');
}
$data = $this->data;
foreach ($this->bags as $bag) {
if (empty($data[$key = $bag->getStorageKey()])) {
unset($data[$key]);
}
}
if ([$key = $this->metadataBag->getStorageKey()] === array_keys($data)) {
unset($data[$key]);
}
try {
if ($data) {
file_put_contents($this->getFilePath(), serialize($data));
} else {
$this->destroy();
}
} finally {
$this->data = $data;
}
// this is needed for Silex, where the session object is re-used across requests
// in functional tests. In Symfony, the container is rebooted, so we don't have
// this issue
$this->started = false;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Trying to save a session that was not started yet or was already closed'",
")",
";",
"}",
"$",
"data",
"=",
"$",... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php#L88-L119 | train | Save session data | [
30522,
2270,
3853,
3828,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2318,
1007,
1063,
5466,
2047,
1032,
2448,
7292,
10288,
24422,
1006,
1005,
2667,
2000,
3828,
1037,
5219,
2008,
2001,
2025,
2318,
2664,
2030,
2001,
2525,
27... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Grid/Column.php | Column.callSupportDisplayer | protected function callSupportDisplayer($abstract, $arguments)
{
return $this->display(function ($value) use ($abstract, $arguments) {
if (is_array($value) || $value instanceof Arrayable) {
return call_user_func_array([collect($value), $abstract], $arguments);
}
if (is_string($value)) {
return call_user_func_array([Str::class, $abstract], array_merge([$value], $arguments));
}
return $value;
});
} | php | protected function callSupportDisplayer($abstract, $arguments)
{
return $this->display(function ($value) use ($abstract, $arguments) {
if (is_array($value) || $value instanceof Arrayable) {
return call_user_func_array([collect($value), $abstract], $arguments);
}
if (is_string($value)) {
return call_user_func_array([Str::class, $abstract], array_merge([$value], $arguments));
}
return $value;
});
} | [
"protected",
"function",
"callSupportDisplayer",
"(",
"$",
"abstract",
",",
"$",
"arguments",
")",
"{",
"return",
"$",
"this",
"->",
"display",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"abstract",
",",
"$",
"arguments",
")",
"{",
"if",
... | Call Illuminate/Support displayer.
@param string $abstract
@param array $arguments
@return Column | [
"Call",
"Illuminate",
"/",
"Support",
"displayer",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Grid/Column.php#L626-L639 | train | Calls the displayer of the current language | [
30522,
5123,
3853,
4455,
6279,
6442,
10521,
13068,
2121,
1006,
1002,
10061,
1010,
1002,
9918,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
4653,
1006,
3853,
1006,
1002,
3643,
1007,
2224,
1006,
1002,
10061,
1010,
1002,
9918,
1007,
1063,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Console/Style/SymfonyStyle.php | SymfonyStyle.ask | public function ask($question, $default = null, $validator = null)
{
$question = new Question($question, $default);
$question->setValidator($validator);
return $this->askQuestion($question);
} | php | public function ask($question, $default = null, $validator = null)
{
$question = new Question($question, $default);
$question->setValidator($validator);
return $this->askQuestion($question);
} | [
"public",
"function",
"ask",
"(",
"$",
"question",
",",
"$",
"default",
"=",
"null",
",",
"$",
"validator",
"=",
"null",
")",
"{",
"$",
"question",
"=",
"new",
"Question",
"(",
"$",
"question",
",",
"$",
"default",
")",
";",
"$",
"question",
"->",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Style/SymfonyStyle.php#L196-L202 | train | Asks a question to the user. | [
30522,
2270,
3853,
3198,
1006,
1002,
3160,
1010,
1002,
12398,
1027,
19701,
1010,
1002,
9398,
8844,
1027,
19701,
1007,
1063,
1002,
3160,
1027,
2047,
3160,
1006,
1002,
3160,
1010,
1002,
12398,
1007,
1025,
1002,
3160,
1011,
1028,
2275,
10175,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Debugger.php | Debugger.startTimer | public function startTimer($name, $description = null)
{
if (strpos($name, '_') === 0 || $this->enabled()) {
$this->debugbar['time']->startMeasure($name, $description);
$this->timers[] = $name;
}
return $this;
} | php | public function startTimer($name, $description = null)
{
if (strpos($name, '_') === 0 || $this->enabled()) {
$this->debugbar['time']->startMeasure($name, $description);
$this->timers[] = $name;
}
return $this;
} | [
"public",
"function",
"startTimer",
"(",
"$",
"name",
",",
"$",
"description",
"=",
"null",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'_'",
")",
"===",
"0",
"||",
"$",
"this",
"->",
"enabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
... | Start a timer with an associated name and description
@param string $name
@param string|null $description
@return $this | [
"Start",
"a",
"timer",
"with",
"an",
"associated",
"name",
"and",
"description"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Debugger.php#L275-L283 | train | Start a timer | [
30522,
2270,
3853,
2707,
7292,
2099,
1006,
1002,
2171,
1010,
1002,
6412,
1027,
19701,
1007,
1063,
2065,
1006,
2358,
14536,
2891,
1006,
1002,
2171,
1010,
1005,
1035,
1005,
1007,
1027,
1027,
1027,
1014,
1064,
1064,
1002,
2023,
1011,
1028,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Foundation/Console/ViewCacheCommand.php | ViewCacheCommand.paths | protected function paths()
{
$finder = $this->laravel['view']->getFinder();
return collect($finder->getPaths())->merge(
collect($finder->getHints())->flatten()
);
} | php | protected function paths()
{
$finder = $this->laravel['view']->getFinder();
return collect($finder->getPaths())->merge(
collect($finder->getHints())->flatten()
);
} | [
"protected",
"function",
"paths",
"(",
")",
"{",
"$",
"finder",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'view'",
"]",
"->",
"getFinder",
"(",
")",
";",
"return",
"collect",
"(",
"$",
"finder",
"->",
"getPaths",
"(",
")",
")",
"->",
"merge",
"(",
"... | Get all of the possible view paths.
@return \Illuminate\Support\Collection | [
"Get",
"all",
"of",
"the",
"possible",
"view",
"paths",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/ViewCacheCommand.php#L79-L86 | train | Get all paths from the finder | [
30522,
5123,
3853,
10425,
1006,
1007,
1063,
1002,
2424,
2121,
1027,
1002,
2023,
1011,
1028,
13679,
15985,
1031,
1005,
3193,
1005,
1033,
1011,
1028,
2131,
23695,
1006,
1007,
1025,
2709,
8145,
1006,
1002,
2424,
2121,
1011,
1028,
2131,
15069,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/VarDumper/Dumper/CliDumper.php | CliDumper.dumpEllipsis | protected function dumpEllipsis(Cursor $cursor, $hasChild, $cut)
{
if ($cut) {
$this->line .= ' …';
if (0 < $cut) {
$this->line .= $cut;
}
if ($hasChild) {
$this->dumpLine($cursor->depth + 1);
}
}
} | php | protected function dumpEllipsis(Cursor $cursor, $hasChild, $cut)
{
if ($cut) {
$this->line .= ' …';
if (0 < $cut) {
$this->line .= $cut;
}
if ($hasChild) {
$this->dumpLine($cursor->depth + 1);
}
}
} | [
"protected",
"function",
"dumpEllipsis",
"(",
"Cursor",
"$",
"cursor",
",",
"$",
"hasChild",
",",
"$",
"cut",
")",
"{",
"if",
"(",
"$",
"cut",
")",
"{",
"$",
"this",
"->",
"line",
".=",
"' …';",
"",
"if",
"(",
"0",
"<",
"$",
"cut",
")",
"{",
"$... | Dumps an ellipsis for cut children.
@param Cursor $cursor The Cursor position in the dump
@param bool $hasChild When the dump of the hash has child item
@param int $cut The number of items the hash has been cut by | [
"Dumps",
"an",
"ellipsis",
"for",
"cut",
"children",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/VarDumper/Dumper/CliDumper.php#L325-L336 | train | Dump ellipsis line | [
30522,
5123,
3853,
15653,
13348,
18409,
1006,
12731,
25301,
2099,
1002,
12731,
25301,
2099,
1010,
1002,
2038,
19339,
1010,
1002,
3013,
1007,
1063,
2065,
1006,
1002,
3013,
1007,
1063,
1002,
2023,
1011,
1028,
2240,
1012,
1027,
1005,
1529,
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/Console/Application.php | Application.extractNamespace | public function extractNamespace($name, $limit = null)
{
$parts = explode(':', $name);
array_pop($parts);
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
} | php | public function extractNamespace($name, $limit = null)
{
$parts = explode(':', $name);
array_pop($parts);
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
} | [
"public",
"function",
"extractNamespace",
"(",
"$",
"name",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"name",
")",
";",
"array_pop",
"(",
"$",
"parts",
")",
";",
"return",
"implode",
"(",
"':'",
"... | Returns the namespace part of the command name.
This method is not part of public API and should not be used directly.
@param string $name The full name of the command
@param string $limit The maximum number of parts of the namespace
@return string The namespace of the command | [
"Returns",
"the",
"namespace",
"part",
"of",
"the",
"command",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Application.php#L1031-L1037 | train | Extract namespace from name | [
30522,
2270,
3853,
14817,
18442,
23058,
1006,
1002,
2171,
1010,
1002,
5787,
1027,
19701,
1007,
1063,
1002,
3033,
1027,
15044,
1006,
1005,
1024,
1005,
1010,
1002,
2171,
1007,
1025,
9140,
1035,
3769,
1006,
1002,
3033,
1007,
1025,
2709,
17727,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Pdo/Abstract.php | Zend_Db_Adapter_Pdo_Abstract.getServerVersion | public function getServerVersion()
{
$this->_connect();
try {
$version = $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
} catch (PDOException $e) {
// In case of the driver doesn't support getting attributes
return null;
}
$matches = null;
if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
return $matches[1];
} else {
return null;
}
} | php | public function getServerVersion()
{
$this->_connect();
try {
$version = $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
} catch (PDOException $e) {
// In case of the driver doesn't support getting attributes
return null;
}
$matches = null;
if (preg_match('/((?:[0-9]{1,2}\.){1,3}[0-9]{1,2})/', $version, $matches)) {
return $matches[1];
} else {
return null;
}
} | [
"public",
"function",
"getServerVersion",
"(",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"try",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"_connection",
"->",
"getAttribute",
"(",
"PDO",
"::",
"ATTR_SERVER_VERSION",
")",
";",
"}",
"catch... | Retrieve server version in PHP style
@return string | [
"Retrieve",
"server",
"version",
"in",
"PHP",
"style"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Pdo/Abstract.php#L384-L399 | train | Get the server version | [
30522,
2270,
3853,
4152,
2121,
6299,
27774,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
3046,
1063,
1002,
2544,
1027,
1002,
2023,
1011,
1028,
1035,
4434,
1011,
1028,
2131,
19321,
3089,
8569,
2618,
1006,
22851,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/AssetManager.php | AssetManager.getAssetDirectory | public function getAssetDirectory()
{
$mergedFileDirectory = StaticContainer::get('path.tmp') . '/assets';
if (!is_dir($mergedFileDirectory)) {
Filesystem::mkdir($mergedFileDirectory);
}
if (!is_writable($mergedFileDirectory)) {
throw new Exception("Directory " . $mergedFileDirectory . " has to be writable.");
}
return $mergedFileDirectory;
} | php | public function getAssetDirectory()
{
$mergedFileDirectory = StaticContainer::get('path.tmp') . '/assets';
if (!is_dir($mergedFileDirectory)) {
Filesystem::mkdir($mergedFileDirectory);
}
if (!is_writable($mergedFileDirectory)) {
throw new Exception("Directory " . $mergedFileDirectory . " has to be writable.");
}
return $mergedFileDirectory;
} | [
"public",
"function",
"getAssetDirectory",
"(",
")",
"{",
"$",
"mergedFileDirectory",
"=",
"StaticContainer",
"::",
"get",
"(",
"'path.tmp'",
")",
".",
"'/assets'",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"mergedFileDirectory",
")",
")",
"{",
"Filesystem",
... | Check if the merged file directory exists and is writable.
@return string The directory location
@throws Exception if directory is not writable. | [
"Check",
"if",
"the",
"merged",
"file",
"directory",
"exists",
"and",
"is",
"writable",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/AssetManager.php#L242-L255 | train | Get merged file directory | [
30522,
2270,
3853,
2131,
27241,
2102,
4305,
2890,
16761,
2100,
1006,
1007,
1063,
1002,
5314,
8873,
3709,
7442,
16761,
2100,
1027,
10763,
8663,
18249,
2121,
1024,
1024,
2131,
1006,
1005,
4130,
1012,
1056,
30524,
16101,
1006,
1002,
5314,
8873... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/system/classes/PluginBase.php | PluginBase.pluginDetails | public function pluginDetails()
{
$thisClass = get_class($this);
$configuration = $this->getConfigurationFromYaml(sprintf('Plugin configuration file plugin.yaml is not '.
'found for the plugin class %s. Create the file or override pluginDetails() '.
'method in the plugin class.', $thisClass));
if (!array_key_exists('plugin', $configuration)) {
throw new SystemException(sprintf(
'The plugin configuration file plugin.yaml should contain the "plugin" section: %s.', $thisClass)
);
}
return $configuration['plugin'];
} | php | public function pluginDetails()
{
$thisClass = get_class($this);
$configuration = $this->getConfigurationFromYaml(sprintf('Plugin configuration file plugin.yaml is not '.
'found for the plugin class %s. Create the file or override pluginDetails() '.
'method in the plugin class.', $thisClass));
if (!array_key_exists('plugin', $configuration)) {
throw new SystemException(sprintf(
'The plugin configuration file plugin.yaml should contain the "plugin" section: %s.', $thisClass)
);
}
return $configuration['plugin'];
} | [
"public",
"function",
"pluginDetails",
"(",
")",
"{",
"$",
"thisClass",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"configuration",
"=",
"$",
"this",
"->",
"getConfigurationFromYaml",
"(",
"sprintf",
"(",
"'Plugin configuration file plugin.yaml is not '",
... | Returns information about this plugin, including plugin name and developer name.
@return array
@throws SystemException | [
"Returns",
"information",
"about",
"this",
"plugin",
"including",
"plugin",
"name",
"and",
"developer",
"name",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/PluginBase.php#L43-L58 | train | Returns the plugin details from the plugin. yaml file | [
30522,
2270,
3853,
13354,
22254,
12928,
12146,
1006,
1007,
1063,
1002,
2023,
26266,
1027,
2131,
1035,
2465,
1006,
1002,
2023,
1007,
1025,
1002,
9563,
1027,
1002,
2023,
1011,
1028,
2131,
8663,
8873,
27390,
3370,
19699,
16940,
3286,
2140,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Cookie/CookieJar.php | CookieJar.getPathAndDomain | protected function getPathAndDomain($path, $domain, $secure = null, $sameSite = null)
{
return [$path ?: $this->path, $domain ?: $this->domain, is_bool($secure) ? $secure : $this->secure, $sameSite ?: $this->sameSite];
} | php | protected function getPathAndDomain($path, $domain, $secure = null, $sameSite = null)
{
return [$path ?: $this->path, $domain ?: $this->domain, is_bool($secure) ? $secure : $this->secure, $sameSite ?: $this->sameSite];
} | [
"protected",
"function",
"getPathAndDomain",
"(",
"$",
"path",
",",
"$",
"domain",
",",
"$",
"secure",
"=",
"null",
",",
"$",
"sameSite",
"=",
"null",
")",
"{",
"return",
"[",
"$",
"path",
"?",
":",
"$",
"this",
"->",
"path",
",",
"$",
"domain",
"?... | Get the path and domain, or the default values.
@param string $path
@param string $domain
@param bool|null $secure
@param string $sameSite
@return array | [
"Get",
"the",
"path",
"and",
"domain",
"or",
"the",
"default",
"values",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cookie/CookieJar.php#L164-L167 | train | Returns path domain secure and sameSite | [
30522,
5123,
3853,
2131,
15069,
5685,
9527,
8113,
1006,
1002,
4130,
1010,
1002,
5884,
1010,
1002,
5851,
1027,
19701,
1010,
1002,
2168,
28032,
2063,
1027,
19701,
1007,
1063,
2709,
1031,
1002,
4130,
1029,
1024,
1002,
2023,
1011,
1028,
4130,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Broadcasting/Broadcasters/UsePusherChannelConventions.php | UsePusherChannelConventions.normalizeChannelName | public function normalizeChannelName($channel)
{
if ($this->isGuardedChannel($channel)) {
return Str::startsWith($channel, 'private-')
? Str::replaceFirst('private-', '', $channel)
: Str::replaceFirst('presence-', '', $channel);
}
return $channel;
} | php | public function normalizeChannelName($channel)
{
if ($this->isGuardedChannel($channel)) {
return Str::startsWith($channel, 'private-')
? Str::replaceFirst('private-', '', $channel)
: Str::replaceFirst('presence-', '', $channel);
}
return $channel;
} | [
"public",
"function",
"normalizeChannelName",
"(",
"$",
"channel",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isGuardedChannel",
"(",
"$",
"channel",
")",
")",
"{",
"return",
"Str",
"::",
"startsWith",
"(",
"$",
"channel",
",",
"'private-'",
")",
"?",
"Str... | Remove prefix from channel name.
@param string $channel
@return string | [
"Remove",
"prefix",
"from",
"channel",
"name",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Broadcasting/Broadcasters/UsePusherChannelConventions.php#L26-L35 | train | Normalize channel name | [
30522,
2270,
3853,
3671,
4697,
26058,
18442,
1006,
1002,
3149,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
18405,
2098,
26058,
1006,
1002,
3149,
1007,
1007,
1063,
2709,
2358,
2099,
1024,
1024,
4627,
24415,
1006,
1002,
3149,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Plugin.php | Plugin.parseLinks | protected function parseLinks($content, $function, $internal_regex = '(.*)')
{
$regex = '/\[plugin:(?:' . $this->name . ')\]\(' . $internal_regex . '\)/i';
return preg_replace_callback($regex, $function, $content);
} | php | protected function parseLinks($content, $function, $internal_regex = '(.*)')
{
$regex = '/\[plugin:(?:' . $this->name . ')\]\(' . $internal_regex . '\)/i';
return preg_replace_callback($regex, $function, $content);
} | [
"protected",
"function",
"parseLinks",
"(",
"$",
"content",
",",
"$",
"function",
",",
"$",
"internal_regex",
"=",
"'(.*)'",
")",
"{",
"$",
"regex",
"=",
"'/\\[plugin:(?:'",
".",
"$",
"this",
"->",
"name",
".",
"')\\]\\('",
".",
"$",
"internal_regex",
".",... | This function will search a string for markdown links in a specific format. The link value can be
optionally compared against via the $internal_regex and operated on by the callback $function
provided.
format: [plugin:myplugin_name](function_data)
@param string $content The string to perform operations upon
@param callable $function The anonymous callback function
@param string $internal_regex Optional internal regex to extra data from
@return string | [
"This",
"function",
"will",
"search",
"a",
"string",
"for",
"markdown",
"links",
"in",
"a",
"specific",
"format",
".",
"The",
"link",
"value",
"can",
"be",
"optionally",
"compared",
"against",
"via",
"the",
"$internal_regex",
"and",
"operated",
"on",
"by",
"... | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Plugin.php#L252-L257 | train | Parse links in the content | [
30522,
5123,
3853,
11968,
11246,
19839,
2015,
1006,
1002,
4180,
1010,
1002,
3853,
1010,
1002,
4722,
1035,
19723,
10288,
1027,
1005,
1006,
1012,
1008,
1007,
1005,
1007,
1063,
1002,
19723,
10288,
1027,
1005,
1013,
1032,
1031,
13354,
2378,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/Controller.php | Controller.updateGeoIPLinks | public function updateGeoIPLinks()
{
$this->dieIfGeolocationAdminIsDisabled();
Piwik::checkUserHasSuperUserAccess();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
Json::sendHeaderJSON();
try {
$this->checkTokenInUrl();
if ($this->isGeoIp2Enabled()) {
GeoIP2AutoUpdater::setUpdaterOptionsFromUrl();
} else {
GeoIPAutoUpdater::setUpdaterOptionsFromUrl();
}
// if there is a updater URL for a database, but its missing from the misc dir, tell
// the browser so it can download it next
$info = $this->getNextMissingDbUrlInfo();
if ($info !== false) {
return json_encode($info);
} else {
$view = new View("@UserCountry/_updaterNextRunTime");
if ($this->isGeoIp2Enabled()) {
$view->nextRunTime = GeoIP2AutoUpdater::getNextRunTime();
} else {
$view->nextRunTime = GeoIPAutoUpdater::getNextRunTime();
}
$nextRunTimeHtml = $view->render();
return json_encode(array('nextRunTime' => $nextRunTimeHtml));
}
} catch (Exception $ex) {
return json_encode(array('error' => $ex->getMessage()));
}
}
} | php | public function updateGeoIPLinks()
{
$this->dieIfGeolocationAdminIsDisabled();
Piwik::checkUserHasSuperUserAccess();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
Json::sendHeaderJSON();
try {
$this->checkTokenInUrl();
if ($this->isGeoIp2Enabled()) {
GeoIP2AutoUpdater::setUpdaterOptionsFromUrl();
} else {
GeoIPAutoUpdater::setUpdaterOptionsFromUrl();
}
// if there is a updater URL for a database, but its missing from the misc dir, tell
// the browser so it can download it next
$info = $this->getNextMissingDbUrlInfo();
if ($info !== false) {
return json_encode($info);
} else {
$view = new View("@UserCountry/_updaterNextRunTime");
if ($this->isGeoIp2Enabled()) {
$view->nextRunTime = GeoIP2AutoUpdater::getNextRunTime();
} else {
$view->nextRunTime = GeoIPAutoUpdater::getNextRunTime();
}
$nextRunTimeHtml = $view->render();
return json_encode(array('nextRunTime' => $nextRunTimeHtml));
}
} catch (Exception $ex) {
return json_encode(array('error' => $ex->getMessage()));
}
}
} | [
"public",
"function",
"updateGeoIPLinks",
"(",
")",
"{",
"$",
"this",
"->",
"dieIfGeolocationAdminIsDisabled",
"(",
")",
";",
"Piwik",
"::",
"checkUserHasSuperUserAccess",
"(",
")",
";",
"if",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_METHOD\"",
"]",
"==",
"\"POST\""... | Sets the URLs used to download new versions of the installed GeoIP databases.
Input (query params):
'loc_db' - URL for a GeoIP location database.
'isp_db' - URL for a GeoIP ISP database (optional).
'org_db' - URL for a GeoIP Org database (optional).
'period' - 'weekly' or 'monthly'. Determines how often update is run.
Output (json):
'error' - if an error occurs its message is set as the resulting JSON object's
'error' property. | [
"Sets",
"the",
"URLs",
"used",
"to",
"download",
"new",
"versions",
"of",
"the",
"installed",
"GeoIP",
"databases",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/Controller.php#L278-L312 | train | Returns the HTML for the next run time link | [
30522,
2270,
3853,
10651,
3351,
10448,
28296,
5705,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
3280,
10128,
3351,
12898,
10719,
4215,
25300,
16150,
14268,
23242,
1006,
1007,
1025,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
6342,
4842,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php | TextBundleWriter.writeIntVector | private function writeIntVector($file, array $value, $indentation)
{
fwrite($file, ":intvector{\n");
foreach ($value as $int) {
fprintf($file, "%s%d,\n", str_repeat(' ', $indentation + 1), $int);
}
fprintf($file, '%s}', str_repeat(' ', $indentation));
} | php | private function writeIntVector($file, array $value, $indentation)
{
fwrite($file, ":intvector{\n");
foreach ($value as $int) {
fprintf($file, "%s%d,\n", str_repeat(' ', $indentation + 1), $int);
}
fprintf($file, '%s}', str_repeat(' ', $indentation));
} | [
"private",
"function",
"writeIntVector",
"(",
"$",
"file",
",",
"array",
"$",
"value",
",",
"$",
"indentation",
")",
"{",
"fwrite",
"(",
"$",
"file",
",",
"\":intvector{\\n\"",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"int",
")",
"{",
"fprint... | Writes an "intvector" node.
@param resource $file The file handle to write to
@param array $value The value of the node
@param int $indentation The number of levels to indent
@see http://source.icu-project.org/repos/icu/icuhtml/trunk/design/bnf_rb.txt | [
"Writes",
"an",
"intvector",
"node",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/Data/Bundle/Writer/TextBundleWriter.php#L139-L148 | train | Write a intvector | [
30522,
2797,
3853,
4339,
18447,
3726,
16761,
1006,
1002,
5371,
1010,
9140,
1002,
3643,
1010,
1002,
27427,
19304,
1007,
1063,
1042,
26373,
1006,
1002,
5371,
1010,
1000,
1024,
20014,
3726,
16761,
1063,
1032,
1050,
1000,
1007,
1025,
18921,
677... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/Filter.php | Filter.defineFilterScopes | protected function defineFilterScopes()
{
if ($this->scopesDefined) {
return;
}
/**
* @event backend.filter.extendScopesBefore
* Provides an opportunity to interact with the Filter widget before defining the filter scopes
*
* Example usage:
*
* Event::listen('backend.filter.extendScopesBefore', function((\Backend\Widgets\Filter) $filterWidget) {
* // Just in case you really had to do something before scopes are defined
* });
*
* Or
*
* $listWidget->bindEvent('filter.extendScopesBefore', function () use ((\Backend\Widgets\Filter) $filterWidget) {
* // Just in case you really had to do something before scopes are defined
* });
*
*/
$this->fireSystemEvent('backend.filter.extendScopesBefore');
/*
* All scopes
*/
if (!isset($this->scopes) || !is_array($this->scopes)) {
$this->scopes = [];
}
$this->addScopes($this->scopes);
/**
* @event backend.filter.extendScopes
* Provides an opportunity to interact with the Filter widget & its scopes after the filter scopes have been initialized
*
* Example usage:
*
* Event::listen('backend.filter.extendScopes', function((\Backend\Widgets\Filter) $filterWidget) {
* $filterWidget->addScopes([
* 'my_scope' => [
* 'label' => 'My Filter Scope'
* ]
* ]);
* });
*
* Or
*
* $listWidget->bindEvent('filter.extendScopes', function () use ((\Backend\Widgets\Filter) $filterWidget) {
* $filterWidget->removeScope('my_scope');
* });
*
*/
$this->fireSystemEvent('backend.filter.extendScopes');
$this->scopesDefined = true;
} | php | protected function defineFilterScopes()
{
if ($this->scopesDefined) {
return;
}
/**
* @event backend.filter.extendScopesBefore
* Provides an opportunity to interact with the Filter widget before defining the filter scopes
*
* Example usage:
*
* Event::listen('backend.filter.extendScopesBefore', function((\Backend\Widgets\Filter) $filterWidget) {
* // Just in case you really had to do something before scopes are defined
* });
*
* Or
*
* $listWidget->bindEvent('filter.extendScopesBefore', function () use ((\Backend\Widgets\Filter) $filterWidget) {
* // Just in case you really had to do something before scopes are defined
* });
*
*/
$this->fireSystemEvent('backend.filter.extendScopesBefore');
/*
* All scopes
*/
if (!isset($this->scopes) || !is_array($this->scopes)) {
$this->scopes = [];
}
$this->addScopes($this->scopes);
/**
* @event backend.filter.extendScopes
* Provides an opportunity to interact with the Filter widget & its scopes after the filter scopes have been initialized
*
* Example usage:
*
* Event::listen('backend.filter.extendScopes', function((\Backend\Widgets\Filter) $filterWidget) {
* $filterWidget->addScopes([
* 'my_scope' => [
* 'label' => 'My Filter Scope'
* ]
* ]);
* });
*
* Or
*
* $listWidget->bindEvent('filter.extendScopes', function () use ((\Backend\Widgets\Filter) $filterWidget) {
* $filterWidget->removeScope('my_scope');
* });
*
*/
$this->fireSystemEvent('backend.filter.extendScopes');
$this->scopesDefined = true;
} | [
"protected",
"function",
"defineFilterScopes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"scopesDefined",
")",
"{",
"return",
";",
"}",
"/**\n * @event backend.filter.extendScopesBefore\n * Provides an opportunity to interact with the Filter widget before definin... | Creates a flat array of filter scopes from the configuration. | [
"Creates",
"a",
"flat",
"array",
"of",
"filter",
"scopes",
"from",
"the",
"configuration",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/Filter.php#L504-L562 | train | Define the filter scopes | [
30522,
5123,
3853,
9375,
8873,
21928,
26127,
2015,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
9531,
16150,
28344,
1007,
30524,
9531,
2015,
1008,
1008,
2742,
8192,
1024,
1008,
1008,
2724,
1024,
1024,
4952,
1006,
1005,
2067,
10497,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
octobercms/october | modules/cms/controllers/Index.php | Index.upgradeSettings | protected function upgradeSettings($settings)
{
/*
* Handle component usage
*/
$componentProperties = post('component_properties');
$componentNames = post('component_names');
$componentAliases = post('component_aliases');
if ($componentProperties !== null) {
if ($componentNames === null || $componentAliases === null) {
throw new ApplicationException(trans('cms::lang.component.invalid_request'));
}
$count = count($componentProperties);
if (count($componentNames) != $count || count($componentAliases) != $count) {
throw new ApplicationException(trans('cms::lang.component.invalid_request'));
}
for ($index = 0; $index < $count; $index++) {
$componentName = $componentNames[$index];
$componentAlias = $componentAliases[$index];
$section = $componentName;
if ($componentAlias != $componentName) {
$section .= ' '.$componentAlias;
}
$properties = json_decode($componentProperties[$index], true);
unset($properties['oc.alias'], $properties['inspectorProperty'], $properties['inspectorClassName']);
$settings[$section] = $properties;
}
}
/*
* Handle view bag
*/
$viewBag = post('viewBag');
if ($viewBag !== null) {
$settings['viewBag'] = $viewBag;
}
/**
* @event cms.template.processSettingsBeforeSave
* Fires before a CMS template (page|partial|layout|content|asset) is saved and provides an opportunity to interact with the settings data. `$dataHolder` = {settings: array()}
*
* Example usage:
*
* Event::listen('cms.template.processSettingsBeforeSave', function ((\Cms\Controllers\Index) $controller, (object) $dataHolder) {
* // Make some modifications to the $dataHolder object
* });
*
* Or
*
* $CmsIndexController->bindEvent('template.processSettingsBeforeSave', function ((object) $dataHolder) {
* // Make some modifications to the $dataHolder object
* });
*
*/
$dataHolder = (object) ['settings' => $settings];
$this->fireSystemEvent('cms.template.processSettingsBeforeSave', [$dataHolder]);
return $dataHolder->settings;
} | php | protected function upgradeSettings($settings)
{
/*
* Handle component usage
*/
$componentProperties = post('component_properties');
$componentNames = post('component_names');
$componentAliases = post('component_aliases');
if ($componentProperties !== null) {
if ($componentNames === null || $componentAliases === null) {
throw new ApplicationException(trans('cms::lang.component.invalid_request'));
}
$count = count($componentProperties);
if (count($componentNames) != $count || count($componentAliases) != $count) {
throw new ApplicationException(trans('cms::lang.component.invalid_request'));
}
for ($index = 0; $index < $count; $index++) {
$componentName = $componentNames[$index];
$componentAlias = $componentAliases[$index];
$section = $componentName;
if ($componentAlias != $componentName) {
$section .= ' '.$componentAlias;
}
$properties = json_decode($componentProperties[$index], true);
unset($properties['oc.alias'], $properties['inspectorProperty'], $properties['inspectorClassName']);
$settings[$section] = $properties;
}
}
/*
* Handle view bag
*/
$viewBag = post('viewBag');
if ($viewBag !== null) {
$settings['viewBag'] = $viewBag;
}
/**
* @event cms.template.processSettingsBeforeSave
* Fires before a CMS template (page|partial|layout|content|asset) is saved and provides an opportunity to interact with the settings data. `$dataHolder` = {settings: array()}
*
* Example usage:
*
* Event::listen('cms.template.processSettingsBeforeSave', function ((\Cms\Controllers\Index) $controller, (object) $dataHolder) {
* // Make some modifications to the $dataHolder object
* });
*
* Or
*
* $CmsIndexController->bindEvent('template.processSettingsBeforeSave', function ((object) $dataHolder) {
* // Make some modifications to the $dataHolder object
* });
*
*/
$dataHolder = (object) ['settings' => $settings];
$this->fireSystemEvent('cms.template.processSettingsBeforeSave', [$dataHolder]);
return $dataHolder->settings;
} | [
"protected",
"function",
"upgradeSettings",
"(",
"$",
"settings",
")",
"{",
"/*\n * Handle component usage\n */",
"$",
"componentProperties",
"=",
"post",
"(",
"'component_properties'",
")",
";",
"$",
"componentNames",
"=",
"post",
"(",
"'component_names'"... | Processes the component settings so they are ready to be saved
@param array $settings
@return array | [
"Processes",
"the",
"component",
"settings",
"so",
"they",
"are",
"ready",
"to",
"be",
"saved"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/cms/controllers/Index.php#L551-L614 | train | Upgrade settings from post to post array | [
30522,
5123,
3853,
18739,
18319,
3070,
2015,
1006,
1002,
10906,
1007,
1063,
1013,
1008,
1008,
5047,
6922,
8192,
1008,
1013,
1002,
6922,
21572,
4842,
7368,
1027,
2695,
1006,
1005,
6922,
1035,
5144,
1005,
1007,
1025,
1002,
6922,
18442,
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... |
laravel/framework | src/Illuminate/Routing/Middleware/ThrottleRequestsWithRedis.php | ThrottleRequestsWithRedis.tooManyAttempts | protected function tooManyAttempts($key, $maxAttempts, $decayMinutes)
{
$limiter = new DurationLimiter(
$this->redis, $key, $maxAttempts, $decayMinutes * 60
);
return tap(! $limiter->acquire(), function () use ($limiter) {
[$this->decaysAt, $this->remaining] = [
$limiter->decaysAt, $limiter->remaining,
];
});
} | php | protected function tooManyAttempts($key, $maxAttempts, $decayMinutes)
{
$limiter = new DurationLimiter(
$this->redis, $key, $maxAttempts, $decayMinutes * 60
);
return tap(! $limiter->acquire(), function () use ($limiter) {
[$this->decaysAt, $this->remaining] = [
$limiter->decaysAt, $limiter->remaining,
];
});
} | [
"protected",
"function",
"tooManyAttempts",
"(",
"$",
"key",
",",
"$",
"maxAttempts",
",",
"$",
"decayMinutes",
")",
"{",
"$",
"limiter",
"=",
"new",
"DurationLimiter",
"(",
"$",
"this",
"->",
"redis",
",",
"$",
"key",
",",
"$",
"maxAttempts",
",",
"$",
... | Determine if the given key has been "accessed" too many times.
@param string $key
@param int $maxAttempts
@param int $decayMinutes
@return mixed | [
"Determine",
"if",
"the",
"given",
"key",
"has",
"been",
"accessed",
"too",
"many",
"times",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Middleware/ThrottleRequestsWithRedis.php#L80-L91 | train | Ensures that the key exists in the cache and adds the remaining delays to the array. | [
30522,
5123,
3853,
2205,
2386,
26139,
18532,
22798,
1006,
1002,
3145,
1010,
1002,
4098,
19321,
6633,
22798,
1010,
1002,
13121,
10020,
10421,
2015,
1007,
1063,
1002,
5787,
2121,
1027,
2047,
9367,
17960,
21646,
1006,
1002,
2023,
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... |
getgrav/grav | system/src/Grav/Common/Utils.php | Utils.arrayFlattenDotNotation | public static function arrayFlattenDotNotation($array, $prepend = '')
{
$results = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
$results = array_merge($results, static::arrayFlattenDotNotation($value, $prepend.$key.'.'));
} else {
$results[$prepend.$key] = $value;
}
}
return $results;
} | php | public static function arrayFlattenDotNotation($array, $prepend = '')
{
$results = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
$results = array_merge($results, static::arrayFlattenDotNotation($value, $prepend.$key.'.'));
} else {
$results[$prepend.$key] = $value;
}
}
return $results;
} | [
"public",
"static",
"function",
"arrayFlattenDotNotation",
"(",
"$",
"array",
",",
"$",
"prepend",
"=",
"''",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
... | Flatten a multi-dimensional associative array into dot notation
@param array $array
@param string $prepend
@return array | [
"Flatten",
"a",
"multi",
"-",
"dimensional",
"associative",
"array",
"into",
"dot",
"notation"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Utils.php#L929-L941 | train | Flatten a dot notation array into a single level | [
30522,
2270,
10763,
3853,
9140,
10258,
19321,
10497,
4140,
17048,
3370,
1006,
1002,
9140,
1010,
1002,
17463,
10497,
1027,
1005,
1005,
1007,
1063,
1002,
3463,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
9140,
2004,
1002,
3145,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php | DataCollectorListener.postSetData | public function postSetData(FormEvent $event)
{
if ($event->getForm()->isRoot()) {
// Collect basic information about each form
$this->dataCollector->collectConfiguration($event->getForm());
// Collect the default data
$this->dataCollector->collectDefaultData($event->getForm());
}
} | php | public function postSetData(FormEvent $event)
{
if ($event->getForm()->isRoot()) {
// Collect basic information about each form
$this->dataCollector->collectConfiguration($event->getForm());
// Collect the default data
$this->dataCollector->collectDefaultData($event->getForm());
}
} | [
"public",
"function",
"postSetData",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getForm",
"(",
")",
"->",
"isRoot",
"(",
")",
")",
"{",
"// Collect basic information about each form",
"$",
"this",
"->",
"dataCollector",
"->",
"... | Listener for the {@link FormEvents::POST_SET_DATA} event. | [
"Listener",
"for",
"the",
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php#L50-L59 | train | Post Set Data event | [
30522,
2270,
3853,
8466,
3388,
2850,
2696,
1006,
2433,
18697,
3372,
1002,
2724,
1007,
1063,
2065,
1006,
1002,
2724,
1011,
1028,
2131,
14192,
1006,
1007,
1011,
1028,
2003,
3217,
4140,
1006,
1007,
1007,
1063,
1013,
1013,
8145,
3937,
2592,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.value | public function value($name, $default = null)
{
if ($name === 'content') {
return $this->raw_content;
}
if ($name === 'route') {
$parent = $this->parent();
return $parent ? $parent->rawRoute() : '';
}
if ($name === 'order') {
$order = $this->order();
return $order ? (int)$this->order() : '';
}
if ($name === 'ordering') {
return (bool)$this->order();
}
if ($name === 'folder') {
return preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder);
}
if ($name === 'slug') {
return $this->slug();
}
if ($name === 'name') {
$language = $this->language() ? '.' . $this->language() : '';
$name_val = str_replace($language . '.md', '', $this->name());
if ($this->modular()) {
return 'modular/' . $name_val;
}
return $name_val;
}
if ($name === 'media') {
return $this->media()->all();
}
if ($name === 'media.file') {
return $this->media()->files();
}
if ($name === 'media.video') {
return $this->media()->videos();
}
if ($name === 'media.image') {
return $this->media()->images();
}
if ($name === 'media.audio') {
return $this->media()->audios();
}
$path = explode('.', $name);
$scope = array_shift($path);
if ($name === 'frontmatter') {
return $this->frontmatter;
}
if ($scope === 'header') {
$current = $this->header();
foreach ($path as $field) {
if (is_object($current) && isset($current->{$field})) {
$current = $current->{$field};
} elseif (is_array($current) && isset($current[$field])) {
$current = $current[$field];
} else {
return $default;
}
}
return $current;
}
return $default;
} | php | public function value($name, $default = null)
{
if ($name === 'content') {
return $this->raw_content;
}
if ($name === 'route') {
$parent = $this->parent();
return $parent ? $parent->rawRoute() : '';
}
if ($name === 'order') {
$order = $this->order();
return $order ? (int)$this->order() : '';
}
if ($name === 'ordering') {
return (bool)$this->order();
}
if ($name === 'folder') {
return preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder);
}
if ($name === 'slug') {
return $this->slug();
}
if ($name === 'name') {
$language = $this->language() ? '.' . $this->language() : '';
$name_val = str_replace($language . '.md', '', $this->name());
if ($this->modular()) {
return 'modular/' . $name_val;
}
return $name_val;
}
if ($name === 'media') {
return $this->media()->all();
}
if ($name === 'media.file') {
return $this->media()->files();
}
if ($name === 'media.video') {
return $this->media()->videos();
}
if ($name === 'media.image') {
return $this->media()->images();
}
if ($name === 'media.audio') {
return $this->media()->audios();
}
$path = explode('.', $name);
$scope = array_shift($path);
if ($name === 'frontmatter') {
return $this->frontmatter;
}
if ($scope === 'header') {
$current = $this->header();
foreach ($path as $field) {
if (is_object($current) && isset($current->{$field})) {
$current = $current->{$field};
} elseif (is_array($current) && isset($current[$field])) {
$current = $current[$field];
} else {
return $default;
}
}
return $current;
}
return $default;
} | [
"public",
"function",
"value",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'content'",
")",
"{",
"return",
"$",
"this",
"->",
"raw_content",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"'route'",
")",
... | Get value from a page variable (used mostly for creating edit forms).
@param string $name Variable name.
@param mixed $default
@return mixed | [
"Get",
"value",
"from",
"a",
"page",
"variable",
"(",
"used",
"mostly",
"for",
"creating",
"edit",
"forms",
")",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L892-L964 | train | Return the value of the field | [
30522,
2270,
3853,
3643,
1006,
1002,
2171,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2171,
1027,
1027,
1027,
1005,
4180,
1005,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
6315,
1035,
4180,
1025,
1065,
2065,
1006,
1002,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/CssSelector/Parser/TokenStream.php | TokenStream.getNext | public function getNext()
{
if ($this->peeking) {
$this->peeking = false;
$this->used[] = $this->peeked;
return $this->peeked;
}
if (!isset($this->tokens[$this->cursor])) {
throw new InternalErrorException('Unexpected token stream end.');
}
return $this->tokens[$this->cursor++];
} | php | public function getNext()
{
if ($this->peeking) {
$this->peeking = false;
$this->used[] = $this->peeked;
return $this->peeked;
}
if (!isset($this->tokens[$this->cursor])) {
throw new InternalErrorException('Unexpected token stream end.');
}
return $this->tokens[$this->cursor++];
} | [
"public",
"function",
"getNext",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"peeking",
")",
"{",
"$",
"this",
"->",
"peeking",
"=",
"false",
";",
"$",
"this",
"->",
"used",
"[",
"]",
"=",
"$",
"this",
"->",
"peeked",
";",
"return",
"$",
"this",... | Returns next token.
@return Token
@throws InternalErrorException If there is no more token | [
"Returns",
"next",
"token",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/CssSelector/Parser/TokenStream.php#L83-L97 | train | Returns the next token from the token stream. | [
30522,
2270,
3853,
2131,
2638,
18413,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
28222,
1007,
1063,
1002,
2023,
1011,
1028,
28222,
1027,
6270,
1025,
1002,
2023,
1011,
1028,
2109,
1031,
1033,
1027,
1002,
2023,
1011,
1028,
18652,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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/DataCollector/LogsCollector.php | LogsCollector.getStorageLogs | public function getStorageLogs($path)
{
if (!file_exists($path)) {
return;
}
//Load the latest lines, guessing about 15x the number of log entries (for stack traces etc)
$file = implode("", $this->tailFile($path, $this->lines));
foreach ($this->getLogs($file) as $log) {
$this->addMessage($log['header'] . $log['stack'], $log['level'], false);
}
} | php | public function getStorageLogs($path)
{
if (!file_exists($path)) {
return;
}
//Load the latest lines, guessing about 15x the number of log entries (for stack traces etc)
$file = implode("", $this->tailFile($path, $this->lines));
foreach ($this->getLogs($file) as $log) {
$this->addMessage($log['header'] . $log['stack'], $log['level'], false);
}
} | [
"public",
"function",
"getStorageLogs",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"return",
";",
"}",
"//Load the latest lines, guessing about 15x the number of log entries (for stack traces etc)",
"$",
"file",
"=",
... | get logs apache in app/storage/logs
only 24 last of current day
@param string $path
@return array | [
"get",
"logs",
"apache",
"in",
"app",
"/",
"storage",
"/",
"logs",
"only",
"24",
"last",
"of",
"current",
"day"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/LogsCollector.php#L46-L58 | train | Get logs from the file | [
30522,
2270,
3853,
4152,
4263,
4270,
21197,
2015,
1006,
1002,
4130,
1007,
1063,
2065,
1006,
999,
5371,
1035,
6526,
1006,
1002,
4130,
1007,
1007,
1063,
2709,
1025,
1065,
1013,
1013,
7170,
1996,
6745,
3210,
1010,
16986,
2055,
2321,
2595,
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/Database/Eloquent/Concerns/HasRelationships.php | HasRelationships.morphToMany | public function morphToMany($related, $name, $table = null, $foreignPivotKey = null,
$relatedPivotKey = null, $parentKey = null,
$relatedKey = null, $inverse = false)
{
$caller = $this->guessBelongsToManyRelation();
// First, we will need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we will make the query
// instances, as well as the relationship instances we need for these.
$instance = $this->newRelatedInstance($related);
$foreignPivotKey = $foreignPivotKey ?: $name.'_id';
$relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey();
// Now we're ready to create a new query builder for this related model and
// the relationship instances for this relation. This relations will set
// appropriate query constraints then entirely manages the hydrations.
if (! $table) {
$words = preg_split('/(_)/u', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
$lastWord = array_pop($words);
$table = implode('', $words).Str::plural($lastWord);
}
return $this->newMorphToMany(
$instance->newQuery(), $this, $name, $table,
$foreignPivotKey, $relatedPivotKey, $parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(), $caller, $inverse
);
} | php | public function morphToMany($related, $name, $table = null, $foreignPivotKey = null,
$relatedPivotKey = null, $parentKey = null,
$relatedKey = null, $inverse = false)
{
$caller = $this->guessBelongsToManyRelation();
// First, we will need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we will make the query
// instances, as well as the relationship instances we need for these.
$instance = $this->newRelatedInstance($related);
$foreignPivotKey = $foreignPivotKey ?: $name.'_id';
$relatedPivotKey = $relatedPivotKey ?: $instance->getForeignKey();
// Now we're ready to create a new query builder for this related model and
// the relationship instances for this relation. This relations will set
// appropriate query constraints then entirely manages the hydrations.
if (! $table) {
$words = preg_split('/(_)/u', $name, -1, PREG_SPLIT_DELIM_CAPTURE);
$lastWord = array_pop($words);
$table = implode('', $words).Str::plural($lastWord);
}
return $this->newMorphToMany(
$instance->newQuery(), $this, $name, $table,
$foreignPivotKey, $relatedPivotKey, $parentKey ?: $this->getKeyName(),
$relatedKey ?: $instance->getKeyName(), $caller, $inverse
);
} | [
"public",
"function",
"morphToMany",
"(",
"$",
"related",
",",
"$",
"name",
",",
"$",
"table",
"=",
"null",
",",
"$",
"foreignPivotKey",
"=",
"null",
",",
"$",
"relatedPivotKey",
"=",
"null",
",",
"$",
"parentKey",
"=",
"null",
",",
"$",
"relatedKey",
... | Define a polymorphic many-to-many relationship.
@param string $related
@param string $name
@param string $table
@param string $foreignPivotKey
@param string $relatedPivotKey
@param string $parentKey
@param string $relatedKey
@param bool $inverse
@return \Illuminate\Database\Eloquent\Relations\MorphToMany | [
"Define",
"a",
"polymorphic",
"many",
"-",
"to",
"-",
"many",
"relationship",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php#L513-L544 | train | Create a new query builder for a morphToMany relation | [
30522,
2270,
3853,
22822,
8458,
20389,
19092,
1006,
1002,
3141,
1010,
1002,
2171,
1010,
1002,
2795,
1027,
19701,
1010,
1002,
3097,
8197,
22994,
14839,
1027,
19701,
1010,
1002,
3141,
8197,
22994,
14839,
1027,
19701,
1010,
1002,
6687,
14839,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Auth/Database/HasPermissions.php | HasPermissions.can | public function can($ability, $arguments = []) : bool
{
if ($this->isAdministrator()) {
return true;
}
if ($this->permissions->pluck('slug')->contains($ability)) {
return true;
}
return $this->roles->pluck('permissions')->flatten()->pluck('slug')->contains($ability);
} | php | public function can($ability, $arguments = []) : bool
{
if ($this->isAdministrator()) {
return true;
}
if ($this->permissions->pluck('slug')->contains($ability)) {
return true;
}
return $this->roles->pluck('permissions')->flatten()->pluck('slug')->contains($ability);
} | [
"public",
"function",
"can",
"(",
"$",
"ability",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"isAdministrator",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"permiss... | Check if user has permission.
@param $ability
@param array $arguments
@return bool | [
"Check",
"if",
"user",
"has",
"permission",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Auth/Database/HasPermissions.php#L27-L38 | train | Can user access to this role | [
30522,
2270,
3853,
2064,
1006,
1002,
3754,
1010,
1002,
9918,
1027,
1031,
1033,
1007,
1024,
22017,
2140,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
18061,
22117,
5498,
20528,
4263,
1006,
1007,
1007,
1063,
2709,
2995,
1025,
1065,
2065,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/LanguagesManager/Commands/Update.php | Update.getPluginsInCore | public static function getPluginsInCore()
{
static $pluginsInCore;
if (!empty($pluginsInCore)) {
return $pluginsInCore;
}
$submodules = shell_exec('git submodule status');
preg_match_all('/plugins\/([a-zA-z]+) /', $submodules, $matches);
$submodulePlugins = $matches[1];
// ignore complete new plugins as well
$changes = shell_exec('git status');
preg_match_all('/plugins\/([a-zA-z]+)\/\n/', $changes, $matches);
$newPlugins = $matches[1];
$pluginsNotInCore = array_merge($submodulePlugins, $newPlugins);
$pluginsWithTranslations = array();
foreach (Manager::getPluginsDirectories() as $pluginsDir) {
$pluginsWithTranslations = array_merge($pluginsWithTranslations, glob(sprintf('%s*/lang/en.json', $pluginsDir)));
}
$pluginsWithTranslations = array_map(function ($elem) {
$replace = Manager::getPluginsDirectories();
$replace[] = '/lang/en.json';
return str_replace($replace, '', $elem);
}, $pluginsWithTranslations);
$pluginsInCore = array_diff($pluginsWithTranslations, $pluginsNotInCore);
return $pluginsInCore;
} | php | public static function getPluginsInCore()
{
static $pluginsInCore;
if (!empty($pluginsInCore)) {
return $pluginsInCore;
}
$submodules = shell_exec('git submodule status');
preg_match_all('/plugins\/([a-zA-z]+) /', $submodules, $matches);
$submodulePlugins = $matches[1];
// ignore complete new plugins as well
$changes = shell_exec('git status');
preg_match_all('/plugins\/([a-zA-z]+)\/\n/', $changes, $matches);
$newPlugins = $matches[1];
$pluginsNotInCore = array_merge($submodulePlugins, $newPlugins);
$pluginsWithTranslations = array();
foreach (Manager::getPluginsDirectories() as $pluginsDir) {
$pluginsWithTranslations = array_merge($pluginsWithTranslations, glob(sprintf('%s*/lang/en.json', $pluginsDir)));
}
$pluginsWithTranslations = array_map(function ($elem) {
$replace = Manager::getPluginsDirectories();
$replace[] = '/lang/en.json';
return str_replace($replace, '', $elem);
}, $pluginsWithTranslations);
$pluginsInCore = array_diff($pluginsWithTranslations, $pluginsNotInCore);
return $pluginsInCore;
} | [
"public",
"static",
"function",
"getPluginsInCore",
"(",
")",
"{",
"static",
"$",
"pluginsInCore",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pluginsInCore",
")",
")",
"{",
"return",
"$",
"pluginsInCore",
";",
"}",
"$",
"submodules",
"=",
"shell_exec",
"(",
... | Returns all plugins having their own translations that are bundled in core
@return array | [
"Returns",
"all",
"plugins",
"having",
"their",
"own",
"translations",
"that",
"are",
"bundled",
"in",
"core"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/LanguagesManager/Commands/Update.php#L178-L209 | train | Get all plugins in core | [
30522,
2270,
10763,
3853,
2131,
24759,
15916,
7076,
2378,
17345,
1006,
1007,
1063,
10763,
1002,
13354,
30524,
1035,
2674,
1035,
2035,
1006,
1005,
1013,
13354,
7076,
1032,
1013,
1006,
1031,
1037,
1011,
23564,
1011,
1062,
1033,
1009,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Controller.php | HTML_QuickForm2_Controller.isValid | public function isValid(HTML_QuickForm2_Controller_Page $reference = null)
{
$container = $this->getSessionContainer();
foreach ($this->pages as $id => $page) {
if ($reference === $page) {
return true;
}
if (!$container->getValidationStatus($id)) {
// We should handle the possible situation when the user has never
// seen a page of a non-modal multipage form
if (!$this->isWizard()
&& null === $container->getValidationStatus($id)
) {
// Empty Session datasource makes the form look submitted
$page->getForm()->setDatasources(array_merge(
$container->getDatasources(),
array(new HTML_QuickForm2_DataSource_Session(array()))
));
// This will store the "submitted" values in session and
// return validation status
if ($page->storeValues()) {
continue;
}
}
return false;
}
}
return true;
} | php | public function isValid(HTML_QuickForm2_Controller_Page $reference = null)
{
$container = $this->getSessionContainer();
foreach ($this->pages as $id => $page) {
if ($reference === $page) {
return true;
}
if (!$container->getValidationStatus($id)) {
// We should handle the possible situation when the user has never
// seen a page of a non-modal multipage form
if (!$this->isWizard()
&& null === $container->getValidationStatus($id)
) {
// Empty Session datasource makes the form look submitted
$page->getForm()->setDatasources(array_merge(
$container->getDatasources(),
array(new HTML_QuickForm2_DataSource_Session(array()))
));
// This will store the "submitted" values in session and
// return validation status
if ($page->storeValues()) {
continue;
}
}
return false;
}
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"HTML_QuickForm2_Controller_Page",
"$",
"reference",
"=",
"null",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"getSessionContainer",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"pages",
"as",
"$",
"id",
"... | Checks whether the pages of the controller are valid
@param HTML_QuickForm2_Controller_Page If given, check only the pages
before (not including) that page
@return bool | [
"Checks",
"whether",
"the",
"pages",
"of",
"the",
"controller",
"are",
"valid"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Controller.php#L391-L419 | train | Returns true if the page is valid | [
30522,
2270,
3853,
2003,
10175,
3593,
1006,
16129,
1035,
4248,
14192,
2475,
1035,
11486,
1035,
3931,
1002,
4431,
1027,
19701,
1007,
1063,
1002,
11661,
1027,
1002,
2023,
1011,
1028,
4152,
7971,
3258,
8663,
18249,
2121,
1006,
1007,
1025,
1892... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
walkor/Workerman | Protocols/Text.php | Text.input | public static function input($buffer, TcpConnection $connection)
{
// Judge whether the package length exceeds the limit.
if (strlen($buffer) >= $connection->maxPackageSize) {
$connection->close();
return 0;
}
// Find the position of "\n".
$pos = strpos($buffer, "\n");
// No "\n", packet length is unknown, continue to wait for the data so return 0.
if ($pos === false) {
return 0;
}
// Return the current package length.
return $pos + 1;
} | php | public static function input($buffer, TcpConnection $connection)
{
// Judge whether the package length exceeds the limit.
if (strlen($buffer) >= $connection->maxPackageSize) {
$connection->close();
return 0;
}
// Find the position of "\n".
$pos = strpos($buffer, "\n");
// No "\n", packet length is unknown, continue to wait for the data so return 0.
if ($pos === false) {
return 0;
}
// Return the current package length.
return $pos + 1;
} | [
"public",
"static",
"function",
"input",
"(",
"$",
"buffer",
",",
"TcpConnection",
"$",
"connection",
")",
"{",
"// Judge whether the package length exceeds the limit.",
"if",
"(",
"strlen",
"(",
"$",
"buffer",
")",
">=",
"$",
"connection",
"->",
"maxPackageSize",
... | Check the integrity of the package.
@param string $buffer
@param TcpConnection $connection
@return int | [
"Check",
"the",
"integrity",
"of",
"the",
"package",
"."
] | 13649907f05014fcfffcfccaef01e63ad3339351 | https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Text.php#L30-L45 | train | This method is used to determine the package length. | [
30522,
2270,
10763,
3853,
7953,
1006,
1002,
17698,
1010,
22975,
15042,
18256,
7542,
1002,
4434,
1007,
1063,
1013,
1013,
3648,
3251,
1996,
7427,
3091,
23651,
1996,
5787,
1012,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
17698,
1007,
1028,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/Metric.php | Metric.getActualMetricColumn | public static function getActualMetricColumn(DataTable $table, $columnName, $mappingNameToId = null)
{
$firstRow = $table->getFirstRow();
if (!empty($firstRow) && $firstRow->hasColumn($columnName) === false) {
if (empty($mappingIdToName)) {
$mappingNameToId = Metrics::getMappingFromNameToId();
}
if (array_key_exists($columnName, $mappingNameToId)) {
$columnName = $mappingNameToId[$columnName];
}
}
return $columnName;
} | php | public static function getActualMetricColumn(DataTable $table, $columnName, $mappingNameToId = null)
{
$firstRow = $table->getFirstRow();
if (!empty($firstRow) && $firstRow->hasColumn($columnName) === false) {
if (empty($mappingIdToName)) {
$mappingNameToId = Metrics::getMappingFromNameToId();
}
if (array_key_exists($columnName, $mappingNameToId)) {
$columnName = $mappingNameToId[$columnName];
}
}
return $columnName;
} | [
"public",
"static",
"function",
"getActualMetricColumn",
"(",
"DataTable",
"$",
"table",
",",
"$",
"columnName",
",",
"$",
"mappingNameToId",
"=",
"null",
")",
"{",
"$",
"firstRow",
"=",
"$",
"table",
"->",
"getFirstRow",
"(",
")",
";",
"if",
"(",
"!",
"... | Helper method that determines the actual column for a metric in a {@link Piwik\DataTable}.
@param DataTable $table
@param string $columnName
@param int[]|null $mappingNameToId A custom mapping of metric names to special index values. By
default {@link Metrics::getMappingFromNameToId()} is used.
@return string | [
"Helper",
"method",
"that",
"determines",
"the",
"actual",
"column",
"for",
"a",
"metric",
"in",
"a",
"{",
"@link",
"Piwik",
"\\",
"DataTable",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Metric.php#L185-L201 | train | Returns actual metric column name | [
30522,
2270,
10763,
3853,
2131,
18908,
8787,
12589,
25778,
2819,
2078,
1006,
2951,
10880,
1002,
2795,
1010,
1002,
5930,
18442,
1010,
1002,
12375,
18442,
3406,
3593,
1027,
19701,
1007,
1063,
1002,
2034,
10524,
1027,
1002,
2795,
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... |
octobercms/october | modules/system/classes/VersionManager.php | VersionManager.getDatabaseVersion | protected function getDatabaseVersion($code)
{
if ($this->databaseVersions === null) {
$this->databaseVersions = Db::table('system_plugin_versions')->lists('version', 'code');
}
if (!isset($this->databaseVersions[$code])) {
$this->databaseVersions[$code] = Db::table('system_plugin_versions')
->where('code', $code)
->value('version')
;
}
return $this->databaseVersions[$code] ?? self::NO_VERSION_VALUE;
} | php | protected function getDatabaseVersion($code)
{
if ($this->databaseVersions === null) {
$this->databaseVersions = Db::table('system_plugin_versions')->lists('version', 'code');
}
if (!isset($this->databaseVersions[$code])) {
$this->databaseVersions[$code] = Db::table('system_plugin_versions')
->where('code', $code)
->value('version')
;
}
return $this->databaseVersions[$code] ?? self::NO_VERSION_VALUE;
} | [
"protected",
"function",
"getDatabaseVersion",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"databaseVersions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"databaseVersions",
"=",
"Db",
"::",
"table",
"(",
"'system_plugin_versions'",
")",
"->",... | Returns the latest version of a plugin from the database. | [
"Returns",
"the",
"latest",
"version",
"of",
"a",
"plugin",
"from",
"the",
"database",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/VersionManager.php#L315-L329 | train | Get database version by code | [
30522,
5123,
3853,
2131,
2850,
2696,
15058,
27774,
1006,
1002,
3642,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
7809,
27774,
2015,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
7809,
27774,
2015,
1027,
16962,
1024,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php | CollectionConfigurator.collection | final public function collection($name = '')
{
return new self($this->collection, $this->name.$name, $this, $this->prefixes);
} | php | final public function collection($name = '')
{
return new self($this->collection, $this->name.$name, $this, $this->prefixes);
} | [
"final",
"public",
"function",
"collection",
"(",
"$",
"name",
"=",
"''",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"collection",
",",
"$",
"this",
"->",
"name",
".",
"$",
"name",
",",
"$",
"this",
",",
"$",
"this",
"->",
"prefixes... | Creates a sub-collection.
@return self | [
"Creates",
"a",
"sub",
"-",
"collection",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php#L53-L56 | train | Create a new PageCollection | [
30522,
2345,
2270,
3853,
3074,
1006,
1002,
2171,
1027,
1005,
1005,
1007,
1063,
2709,
2047,
2969,
1006,
1002,
2023,
30524,
1011,
1028,
2171,
1012,
1002,
2171,
1010,
1002,
2023,
1010,
1002,
2023,
1011,
1028,
17576,
2229,
1007,
1025,
1065,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php | ExpressionFunction.fromPhp | public static function fromPhp($phpFunctionName, $expressionFunctionName = null)
{
$phpFunctionName = ltrim($phpFunctionName, '\\');
if (!\function_exists($phpFunctionName)) {
throw new \InvalidArgumentException(sprintf('PHP function "%s" does not exist.', $phpFunctionName));
}
$parts = explode('\\', $phpFunctionName);
if (!$expressionFunctionName && \count($parts) > 1) {
throw new \InvalidArgumentException(sprintf('An expression function name must be defined when PHP function "%s" is namespaced.', $phpFunctionName));
}
$compiler = function () use ($phpFunctionName) {
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', \func_get_args()));
};
$evaluator = function () use ($phpFunctionName) {
return $phpFunctionName(...\array_slice(\func_get_args(), 1));
};
return new self($expressionFunctionName ?: end($parts), $compiler, $evaluator);
} | php | public static function fromPhp($phpFunctionName, $expressionFunctionName = null)
{
$phpFunctionName = ltrim($phpFunctionName, '\\');
if (!\function_exists($phpFunctionName)) {
throw new \InvalidArgumentException(sprintf('PHP function "%s" does not exist.', $phpFunctionName));
}
$parts = explode('\\', $phpFunctionName);
if (!$expressionFunctionName && \count($parts) > 1) {
throw new \InvalidArgumentException(sprintf('An expression function name must be defined when PHP function "%s" is namespaced.', $phpFunctionName));
}
$compiler = function () use ($phpFunctionName) {
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', \func_get_args()));
};
$evaluator = function () use ($phpFunctionName) {
return $phpFunctionName(...\array_slice(\func_get_args(), 1));
};
return new self($expressionFunctionName ?: end($parts), $compiler, $evaluator);
} | [
"public",
"static",
"function",
"fromPhp",
"(",
"$",
"phpFunctionName",
",",
"$",
"expressionFunctionName",
"=",
"null",
")",
"{",
"$",
"phpFunctionName",
"=",
"ltrim",
"(",
"$",
"phpFunctionName",
",",
"'\\\\'",
")",
";",
"if",
"(",
"!",
"\\",
"function_exi... | Creates an ExpressionFunction from a PHP function name.
@param string $phpFunctionName The PHP function name
@param string|null $expressionFunctionName The expression function name (default: same than the PHP function name)
@return self
@throws \InvalidArgumentException if given PHP function name does not exist
@throws \InvalidArgumentException if given PHP function name is in namespace
and expression function name is not defined | [
"Creates",
"an",
"ExpressionFunction",
"from",
"a",
"PHP",
"function",
"name",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php#L76-L97 | train | Create a new instance from a PHP function name and an expression function name. | [
30522,
2270,
10763,
3853,
2013,
8458,
2361,
1006,
1002,
25718,
11263,
27989,
18442,
1010,
1002,
3670,
11263,
27989,
18442,
1027,
19701,
1007,
1063,
1002,
25718,
11263,
27989,
18442,
1027,
8318,
20026,
1006,
1002,
25718,
11263,
27989,
18442,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/HTML/QuickForm2/Renderer/Smarty.php | HTML_QuickForm2_Renderer_Smarty.buildCommonFields | public function buildCommonFields(HTML_QuickForm2_Node $element)
{
$keyn = $this->options['key_id'] ? 'id' : 'name';
$ary = array(
'id' => $element->getId(),
'frozen' => $element->toggleFrozen(),
'name' => $element->getName(),
);
// Key that we use for putting into arrays so that smarty can extract them.
// Note that the name may be empty.
$key_val = $ary[$keyn];
if($key_val == '')
$key_val = $ary['id'];
if ($labels = $element->getLabel()) {
if (!is_array($labels) || !$this->options['static_labels']) {
$ary['label'] = $labels;
} else {
foreach ($labels as $key => $label) {
$key = is_int($key)? $key + 1: $key;
if (1 === $key) {
$ary['label'] = $label;
} else {
$ary['label_' . $key] = $label;
}
}
}
}
// Smarty: group_errors under 'name' or 'id' depending on key_id option:
if (($error = $element->getError()) && $this->options['group_errors']) {
$this->array['errors'][$key_val] = $error;
} elseif ($error) {
$ary['error'] = $error;
}
if (isset($this->styles[$key_val])) {
$ary['style'] = $this->styles[$key_val];
}
if (!$element instanceof HTML_QuickForm2_Container) {
$ary['html'] = $element->__toString();
} else {
$ary['elements'] = array();
$ary['attributes'] = $element->getAttributes(true);
}
return $ary;
} | php | public function buildCommonFields(HTML_QuickForm2_Node $element)
{
$keyn = $this->options['key_id'] ? 'id' : 'name';
$ary = array(
'id' => $element->getId(),
'frozen' => $element->toggleFrozen(),
'name' => $element->getName(),
);
// Key that we use for putting into arrays so that smarty can extract them.
// Note that the name may be empty.
$key_val = $ary[$keyn];
if($key_val == '')
$key_val = $ary['id'];
if ($labels = $element->getLabel()) {
if (!is_array($labels) || !$this->options['static_labels']) {
$ary['label'] = $labels;
} else {
foreach ($labels as $key => $label) {
$key = is_int($key)? $key + 1: $key;
if (1 === $key) {
$ary['label'] = $label;
} else {
$ary['label_' . $key] = $label;
}
}
}
}
// Smarty: group_errors under 'name' or 'id' depending on key_id option:
if (($error = $element->getError()) && $this->options['group_errors']) {
$this->array['errors'][$key_val] = $error;
} elseif ($error) {
$ary['error'] = $error;
}
if (isset($this->styles[$key_val])) {
$ary['style'] = $this->styles[$key_val];
}
if (!$element instanceof HTML_QuickForm2_Container) {
$ary['html'] = $element->__toString();
} else {
$ary['elements'] = array();
$ary['attributes'] = $element->getAttributes(true);
}
return $ary;
} | [
"public",
"function",
"buildCommonFields",
"(",
"HTML_QuickForm2_Node",
"$",
"element",
")",
"{",
"$",
"keyn",
"=",
"$",
"this",
"->",
"options",
"[",
"'key_id'",
"]",
"?",
"'id'",
":",
"'name'",
";",
"$",
"ary",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"... | Creates an array with fields that are common to all elements
@param HTML_QuickForm2_Node Element being rendered
@return array | [
"Creates",
"an",
"array",
"with",
"fields",
"that",
"are",
"common",
"to",
"all",
"elements"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/QuickForm2/Renderer/Smarty.php#L169-L216 | train | Build the common fields array | [
30522,
2270,
3853,
3857,
9006,
8202,
15155,
1006,
16129,
1035,
4248,
14192,
2475,
1035,
13045,
1002,
5783,
1007,
1063,
1002,
3145,
2078,
1027,
1002,
2023,
1011,
1028,
7047,
1031,
1005,
3145,
1035,
8909,
1005,
1033,
1029,
1005,
8909,
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... |
z-song/laravel-admin | src/Form/Tab.php | Tab.collectFields | protected function collectFields(\Closure $content)
{
call_user_func($content, $this->form);
$fields = clone $this->form->builder()->fields();
$all = $fields->toArray();
foreach ($this->form->rows as $row) {
$rowFields = array_map(function ($field) {
return $field['element'];
}, $row->getFields());
$match = false;
foreach ($rowFields as $field) {
if (($index = array_search($field, $all)) !== false) {
if (!$match) {
$fields->put($index, $row);
} else {
$fields->pull($index);
}
$match = true;
}
}
}
$fields = $fields->slice($this->offset);
$this->offset += $fields->count();
return $fields;
} | php | protected function collectFields(\Closure $content)
{
call_user_func($content, $this->form);
$fields = clone $this->form->builder()->fields();
$all = $fields->toArray();
foreach ($this->form->rows as $row) {
$rowFields = array_map(function ($field) {
return $field['element'];
}, $row->getFields());
$match = false;
foreach ($rowFields as $field) {
if (($index = array_search($field, $all)) !== false) {
if (!$match) {
$fields->put($index, $row);
} else {
$fields->pull($index);
}
$match = true;
}
}
}
$fields = $fields->slice($this->offset);
$this->offset += $fields->count();
return $fields;
} | [
"protected",
"function",
"collectFields",
"(",
"\\",
"Closure",
"$",
"content",
")",
"{",
"call_user_func",
"(",
"$",
"content",
",",
"$",
"this",
"->",
"form",
")",
";",
"$",
"fields",
"=",
"clone",
"$",
"this",
"->",
"form",
"->",
"builder",
"(",
")"... | Collect fields under current tab.
@param \Closure $content
@return Collection | [
"Collect",
"fields",
"under",
"current",
"tab",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Form/Tab.php#L64-L97 | train | Collect fields from form | [
30522,
5123,
3853,
8145,
15155,
1006,
1032,
8503,
1002,
4180,
1007,
1063,
2655,
1035,
5310,
1035,
4569,
2278,
1006,
1002,
4180,
1010,
1002,
2023,
1011,
1028,
2433,
1007,
1025,
1002,
4249,
1027,
17598,
1002,
2023,
1011,
1028,
2433,
1011,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php | ExprBuilder.buildExpressions | public static function buildExpressions(array $expressions)
{
foreach ($expressions as $k => $expr) {
if ($expr instanceof self) {
$if = $expr->ifPart;
$then = $expr->thenPart;
$expressions[$k] = function ($v) use ($if, $then) {
return $if($v) ? $then($v) : $v;
};
}
}
return $expressions;
} | php | public static function buildExpressions(array $expressions)
{
foreach ($expressions as $k => $expr) {
if ($expr instanceof self) {
$if = $expr->ifPart;
$then = $expr->thenPart;
$expressions[$k] = function ($v) use ($if, $then) {
return $if($v) ? $then($v) : $v;
};
}
}
return $expressions;
} | [
"public",
"static",
"function",
"buildExpressions",
"(",
"array",
"$",
"expressions",
")",
"{",
"foreach",
"(",
"$",
"expressions",
"as",
"$",
"k",
"=>",
"$",
"expr",
")",
"{",
"if",
"(",
"$",
"expr",
"instanceof",
"self",
")",
"{",
"$",
"if",
"=",
"... | Builds the expressions.
@param ExprBuilder[] $expressions An array of ExprBuilder instances to build
@return array | [
"Builds",
"the",
"expressions",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php#L234-L247 | train | Build expressions to be used in the code | [
30522,
2270,
10763,
3853,
3857,
10288,
20110,
8496,
1006,
9140,
1002,
11423,
1007,
1063,
18921,
6776,
1006,
1002,
11423,
2004,
1002,
1047,
1027,
1028,
1002,
4654,
18098,
1007,
1063,
2065,
1006,
1002,
4654,
18098,
6013,
11253,
2969,
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... |
octobercms/october | modules/backend/widgets/MediaManager.php | MediaManager.setViewMode | protected function setViewMode($viewMode)
{
if (!in_array($viewMode, [
self::VIEW_MODE_GRID,
self::VIEW_MODE_LIST,
self::VIEW_MODE_TILES
])) {
throw new ApplicationException('Invalid input data');
}
$this->putSession('view_mode', $viewMode);
} | php | protected function setViewMode($viewMode)
{
if (!in_array($viewMode, [
self::VIEW_MODE_GRID,
self::VIEW_MODE_LIST,
self::VIEW_MODE_TILES
])) {
throw new ApplicationException('Invalid input data');
}
$this->putSession('view_mode', $viewMode);
} | [
"protected",
"function",
"setViewMode",
"(",
"$",
"viewMode",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"viewMode",
",",
"[",
"self",
"::",
"VIEW_MODE_GRID",
",",
"self",
"::",
"VIEW_MODE_LIST",
",",
"self",
"::",
"VIEW_MODE_TILES",
"]",
")",
")",
... | Stores a view mode in the session
@param string $viewMode
@return void | [
"Stores",
"a",
"view",
"mode",
"in",
"the",
"session"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/widgets/MediaManager.php#L1129-L1140 | train | Set view mode | [
30522,
5123,
3853,
2275,
8584,
5302,
3207,
1006,
1002,
3193,
5302,
3207,
1007,
1063,
2065,
1006,
999,
1999,
1035,
9140,
1006,
1002,
3193,
5302,
3207,
1010,
1031,
2969,
1024,
1024,
3193,
1035,
5549,
1035,
8370,
1010,
2969,
1024,
1024,
3193... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
z-song/laravel-admin | src/Middleware/Pjax.php | Pjax.fetchContents | protected function fetchContents($crawler, $container)
{
$content = $crawler->filter($container);
if (!$content->count()) {
abort(422);
}
return $this->decodeUtf8HtmlEntities($content->html());
} | php | protected function fetchContents($crawler, $container)
{
$content = $crawler->filter($container);
if (!$content->count()) {
abort(422);
}
return $this->decodeUtf8HtmlEntities($content->html());
} | [
"protected",
"function",
"fetchContents",
"(",
"$",
"crawler",
",",
"$",
"container",
")",
"{",
"$",
"content",
"=",
"$",
"crawler",
"->",
"filter",
"(",
"$",
"container",
")",
";",
"if",
"(",
"!",
"$",
"content",
"->",
"count",
"(",
")",
")",
"{",
... | Fetch the PJAX-specific HTML from the response.
@param Crawler $crawler
@param string $container
@return string | [
"Fetch",
"the",
"PJAX",
"-",
"specific",
"HTML",
"from",
"the",
"response",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Middleware/Pjax.php#L122-L131 | train | Fetch the content of a given container | [
30522,
5123,
3853,
18584,
8663,
6528,
3215,
1006,
1002,
13529,
2121,
1010,
1002,
11661,
1007,
1063,
1002,
4180,
1027,
1002,
13529,
2121,
1011,
1028,
11307,
1006,
1002,
11661,
1007,
1025,
2065,
1006,
999,
1002,
4180,
1011,
1028,
4175,
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... |
matomo-org/matomo | libs/Zend/Db/Statement/Sqlsrv.php | Zend_Db_Statement_Sqlsrv._prepare | protected function _prepare($sql)
{
$connection = $this->_adapter->getConnection();
$this->_stmt = sqlsrv_prepare($connection, $sql);
if (!$this->_stmt) {
// require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
}
$this->_originalSQL = $sql;
} | php | protected function _prepare($sql)
{
$connection = $this->_adapter->getConnection();
$this->_stmt = sqlsrv_prepare($connection, $sql);
if (!$this->_stmt) {
// require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
}
$this->_originalSQL = $sql;
} | [
"protected",
"function",
"_prepare",
"(",
"$",
"sql",
")",
"{",
"$",
"connection",
"=",
"$",
"this",
"->",
"_adapter",
"->",
"getConnection",
"(",
")",
";",
"$",
"this",
"->",
"_stmt",
"=",
"sqlsrv_prepare",
"(",
"$",
"connection",
",",
"$",
"sql",
")"... | Prepares statement handle
@param string $sql
@return void
@throws Zend_Db_Statement_Sqlsrv_Exception | [
"Prepares",
"statement",
"handle"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Sqlsrv.php#L62-L74 | train | Prepare the statement | [
30522,
5123,
3853,
1035,
7374,
1006,
1002,
29296,
1007,
1063,
1002,
4434,
1027,
1002,
2023,
1011,
1028,
1035,
15581,
2121,
1011,
1028,
2131,
8663,
2638,
7542,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1027,
29296,
21338,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-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.