repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
mainio/c5pkg_symfony_forms | src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/DateSelectorType.php | DateSelectorType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$dh = \Core::make('helper/date');
$tz = $dh->getTimezone('user')->getName();
$apptz = $dh->getTimezone('system')->getName();
$dtTransformer = new DateTimeToStringTransformer(
$apptz,
$tz,
'Y-m-d'
);
$builder->addViewTransformer($dtTransformer);
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$dh = \Core::make('helper/date');
$tz = $dh->getTimezone('user')->getName();
$apptz = $dh->getTimezone('system')->getName();
$dtTransformer = new DateTimeToStringTransformer(
$apptz,
$tz,
'Y-m-d'
);
$builder->addViewTransformer($dtTransformer);
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"dh",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'helper/date'",
")",
";",
"$",
"tz",
"=",
"$",
"dh",
"->",
"getTimezone",
"(",
"'user'",
")",
"->",
"getName",
"(",
")",
";",
"$",
"apptz",
"=",
"$",
"dh",
"->",
"getTimezone",
"(",
"'system'",
")",
"->",
"getName",
"(",
")",
";",
"$",
"dtTransformer",
"=",
"new",
"DateTimeToStringTransformer",
"(",
"$",
"apptz",
",",
"$",
"tz",
",",
"'Y-m-d'",
")",
";",
"$",
"builder",
"->",
"addViewTransformer",
"(",
"$",
"dtTransformer",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/DateSelectorType.php#L17-L29 |
mainio/c5pkg_symfony_forms | src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/DateSelectorType.php | DateSelectorType.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
$dh = \Core::make('helper/form/date_time');
$view->vars = array_replace($view->vars, array(
'selector' => $dh->date($view->vars["full_name"], $view->vars["value"]),
));
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
$dh = \Core::make('helper/form/date_time');
$view->vars = array_replace($view->vars, array(
'selector' => $dh->date($view->vars["full_name"], $view->vars["value"]),
));
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"$",
"dh",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'helper/form/date_time'",
")",
";",
"$",
"view",
"->",
"vars",
"=",
"array_replace",
"(",
"$",
"view",
"->",
"vars",
",",
"array",
"(",
"'selector'",
"=>",
"$",
"dh",
"->",
"date",
"(",
"$",
"view",
"->",
"vars",
"[",
"\"full_name\"",
"]",
",",
"$",
"view",
"->",
"vars",
"[",
"\"value\"",
"]",
")",
",",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/DateSelectorType.php#L34-L40 |
gbprod/doctrine-specification-bundle | src/DoctrineSpecificationBundle/DependencyInjection/Compiler/QueryFactoryPass.php | QueryFactoryPass.process | public function process(ContainerBuilder $container)
{
if (!$container->has('gbprod.doctrine_specification_handler')) {
throw new \Exception('Missing gbprod.doctrine_specification_handler definition');
}
$handler = $container
->findDefinition('gbprod.doctrine_specification_handler')
;
$builders = $container->findTaggedServiceIds('doctrine.query_factory');
foreach ($builders as $id => $tags) {
foreach ($tags as $attributes) {
if (!isset($attributes['specification'])) {
throw new \Exception('The doctrine.query_factory tag must always have a "specification" attribute');
}
$handler->addMethodCall(
'registerFactory',
[$attributes['specification'], new Reference($id)]
);
}
}
} | php | public function process(ContainerBuilder $container)
{
if (!$container->has('gbprod.doctrine_specification_handler')) {
throw new \Exception('Missing gbprod.doctrine_specification_handler definition');
}
$handler = $container
->findDefinition('gbprod.doctrine_specification_handler')
;
$builders = $container->findTaggedServiceIds('doctrine.query_factory');
foreach ($builders as $id => $tags) {
foreach ($tags as $attributes) {
if (!isset($attributes['specification'])) {
throw new \Exception('The doctrine.query_factory tag must always have a "specification" attribute');
}
$handler->addMethodCall(
'registerFactory',
[$attributes['specification'], new Reference($id)]
);
}
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"'gbprod.doctrine_specification_handler'",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Missing gbprod.doctrine_specification_handler definition'",
")",
";",
"}",
"$",
"handler",
"=",
"$",
"container",
"->",
"findDefinition",
"(",
"'gbprod.doctrine_specification_handler'",
")",
";",
"$",
"builders",
"=",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"'doctrine.query_factory'",
")",
";",
"foreach",
"(",
"$",
"builders",
"as",
"$",
"id",
"=>",
"$",
"tags",
")",
"{",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"attributes",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'specification'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The doctrine.query_factory tag must always have a \"specification\" attribute'",
")",
";",
"}",
"$",
"handler",
"->",
"addMethodCall",
"(",
"'registerFactory'",
",",
"[",
"$",
"attributes",
"[",
"'specification'",
"]",
",",
"new",
"Reference",
"(",
"$",
"id",
")",
"]",
")",
";",
"}",
"}",
"}"
] | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/gbprod/doctrine-specification-bundle/blob/205c1db4efe12b17b8d911c91a688f2596d0b35c/src/DoctrineSpecificationBundle/DependencyInjection/Compiler/QueryFactoryPass.php#L19-L43 |
mainio/c5pkg_symfony_forms | src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/FileSelectorType.php | FileSelectorType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$em = $options['entity_manager'];
if ($em instanceof EntityManager) {
$builder->addViewTransformer(new FileToIntegerTransformer($em));
} else {
parent::buildForm($builder, $options);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$em = $options['entity_manager'];
if ($em instanceof EntityManager) {
$builder->addViewTransformer(new FileToIntegerTransformer($em));
} else {
parent::buildForm($builder, $options);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"$",
"em",
"=",
"$",
"options",
"[",
"'entity_manager'",
"]",
";",
"if",
"(",
"$",
"em",
"instanceof",
"EntityManager",
")",
"{",
"$",
"builder",
"->",
"addViewTransformer",
"(",
"new",
"FileToIntegerTransformer",
"(",
"$",
"em",
")",
")",
";",
"}",
"else",
"{",
"parent",
"::",
"buildForm",
"(",
"$",
"builder",
",",
"$",
"options",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/FileSelectorType.php#L18-L26 |
mainio/c5pkg_symfony_forms | src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/FileSelectorType.php | FileSelectorType.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
// TODO: Through configurations variables, we should allow the defining
// the file type for the selector (e.g. $fm->image(...), $fm->doc(...))
$fm = \Core::make('helper/concrete/file_manager');
if (is_object($view->vars["value"])) {
$bf = $view->vars["value"];
} elseif (strlen($view->vars["value"])) {
$bf = File::getByID($view->vars["value"]);
}
$view->vars = array_replace($view->vars, array(
'selector' => $fm->file($view->vars["id"], $view->vars["full_name"], t("Choose File"), $bf),
));
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
// TODO: Through configurations variables, we should allow the defining
// the file type for the selector (e.g. $fm->image(...), $fm->doc(...))
$fm = \Core::make('helper/concrete/file_manager');
if (is_object($view->vars["value"])) {
$bf = $view->vars["value"];
} elseif (strlen($view->vars["value"])) {
$bf = File::getByID($view->vars["value"]);
}
$view->vars = array_replace($view->vars, array(
'selector' => $fm->file($view->vars["id"], $view->vars["full_name"], t("Choose File"), $bf),
));
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"// TODO: Through configurations variables, we should allow the defining",
"// the file type for the selector (e.g. $fm->image(...), $fm->doc(...))",
"$",
"fm",
"=",
"\\",
"Core",
"::",
"make",
"(",
"'helper/concrete/file_manager'",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"view",
"->",
"vars",
"[",
"\"value\"",
"]",
")",
")",
"{",
"$",
"bf",
"=",
"$",
"view",
"->",
"vars",
"[",
"\"value\"",
"]",
";",
"}",
"elseif",
"(",
"strlen",
"(",
"$",
"view",
"->",
"vars",
"[",
"\"value\"",
"]",
")",
")",
"{",
"$",
"bf",
"=",
"File",
"::",
"getByID",
"(",
"$",
"view",
"->",
"vars",
"[",
"\"value\"",
"]",
")",
";",
"}",
"$",
"view",
"->",
"vars",
"=",
"array_replace",
"(",
"$",
"view",
"->",
"vars",
",",
"array",
"(",
"'selector'",
"=>",
"$",
"fm",
"->",
"file",
"(",
"$",
"view",
"->",
"vars",
"[",
"\"id\"",
"]",
",",
"$",
"view",
"->",
"vars",
"[",
"\"full_name\"",
"]",
",",
"t",
"(",
"\"Choose File\"",
")",
",",
"$",
"bf",
")",
",",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/Type/FileSelectorType.php#L31-L44 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php | ezcMailFileSet.hasData | public function hasData()
{
if ( count( $this->files ) >= 1 )
{
if ( $this->files[0] === 'php://stdin' || filesize( $this->files[0] ) > 0 )
{
return true;
}
}
return false;
} | php | public function hasData()
{
if ( count( $this->files ) >= 1 )
{
if ( $this->files[0] === 'php://stdin' || filesize( $this->files[0] ) > 0 )
{
return true;
}
}
return false;
} | [
"public",
"function",
"hasData",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"files",
")",
">=",
"1",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"[",
"0",
"]",
"===",
"'php://stdin'",
"||",
"filesize",
"(",
"$",
"this",
"->",
"files",
"[",
"0",
"]",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns whether the file set contains files
@return bool | [
"Returns",
"whether",
"the",
"file",
"set",
"contains",
"files"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php#L90-L100 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php | ezcMailFileSet.getNextLine | public function getNextLine()
{
if ( $this->hasMoreMailData === false )
{
$this->nextMail();
}
// finished?
if ( $this->fp == null || feof( $this->fp ) )
{
if ( $this->fp != null )
{
fclose( $this->fp );
$this->fp = null;
}
return null;
}
// get one line
$next = fgets( $this->fp );
if ( $next == "" && feof( $this->fp ) )
{
return null;
}
return $next;
} | php | public function getNextLine()
{
if ( $this->hasMoreMailData === false )
{
$this->nextMail();
}
// finished?
if ( $this->fp == null || feof( $this->fp ) )
{
if ( $this->fp != null )
{
fclose( $this->fp );
$this->fp = null;
}
return null;
}
// get one line
$next = fgets( $this->fp );
if ( $next == "" && feof( $this->fp ) )
{
return null;
}
return $next;
} | [
"public",
"function",
"getNextLine",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMoreMailData",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"nextMail",
"(",
")",
";",
"}",
"// finished?",
"if",
"(",
"$",
"this",
"->",
"fp",
"==",
"null",
"||",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"fp",
"!=",
"null",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"null",
";",
"}",
"return",
"null",
";",
"}",
"// get one line",
"$",
"next",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"if",
"(",
"$",
"next",
"==",
"\"\"",
"&&",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"next",
";",
"}"
] | Returns one line of data from the current mail in the set.
Null is returned if there is no current mail in the set or
the end of the mail is reached,
@return string | [
"Returns",
"one",
"line",
"of",
"data",
"from",
"the",
"current",
"mail",
"in",
"the",
"set",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php#L110-L134 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php | ezcMailFileSet.nextMail | public function nextMail()
{
if ( $this->hasMoreMailData === false )
{
$this->hasMoreMailData = true;
return $this->openFile( true );
}
return $this->openFile();
} | php | public function nextMail()
{
if ( $this->hasMoreMailData === false )
{
$this->hasMoreMailData = true;
return $this->openFile( true );
}
return $this->openFile();
} | [
"public",
"function",
"nextMail",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMoreMailData",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"hasMoreMailData",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"openFile",
"(",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"openFile",
"(",
")",
";",
"}"
] | Moves the set to the next mail and returns true upon success.
False is returned if there are no more mail in the set.
@return bool | [
"Moves",
"the",
"set",
"to",
"the",
"next",
"mail",
"and",
"returns",
"true",
"upon",
"success",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php#L143-L151 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php | ezcMailFileSet.openFile | private function openFile( $isFirst = false )
{
// cleanup file pointer if needed
if ( $this->fp != null )
{
fclose( $this->fp );
$this->fp = null;
}
// open the new file
$file = $isFirst ? current( $this->files ) : next( $this->files );
// loop until we can open a file.
while ( $this->fp == null && $file !== false )
{
if ( $file === 'php://stdin' || file_exists( $file ) )
{
$fp = fopen( $file, 'r' );
if ( $fp !== false )
{
$this->fp = $fp;
return true;
}
}
$file = next( $this->files );
}
return false;
} | php | private function openFile( $isFirst = false )
{
// cleanup file pointer if needed
if ( $this->fp != null )
{
fclose( $this->fp );
$this->fp = null;
}
// open the new file
$file = $isFirst ? current( $this->files ) : next( $this->files );
// loop until we can open a file.
while ( $this->fp == null && $file !== false )
{
if ( $file === 'php://stdin' || file_exists( $file ) )
{
$fp = fopen( $file, 'r' );
if ( $fp !== false )
{
$this->fp = $fp;
return true;
}
}
$file = next( $this->files );
}
return false;
} | [
"private",
"function",
"openFile",
"(",
"$",
"isFirst",
"=",
"false",
")",
"{",
"// cleanup file pointer if needed",
"if",
"(",
"$",
"this",
"->",
"fp",
"!=",
"null",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"null",
";",
"}",
"// open the new file",
"$",
"file",
"=",
"$",
"isFirst",
"?",
"current",
"(",
"$",
"this",
"->",
"files",
")",
":",
"next",
"(",
"$",
"this",
"->",
"files",
")",
";",
"// loop until we can open a file.",
"while",
"(",
"$",
"this",
"->",
"fp",
"==",
"null",
"&&",
"$",
"file",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"file",
"===",
"'php://stdin'",
"||",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"file",
",",
"'r'",
")",
";",
"if",
"(",
"$",
"fp",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"fp",
"=",
"$",
"fp",
";",
"return",
"true",
";",
"}",
"}",
"$",
"file",
"=",
"next",
"(",
"$",
"this",
"->",
"files",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Opens the next file in the set and returns true on success.
@param bool $isFirst
@return bool | [
"Opens",
"the",
"next",
"file",
"in",
"the",
"set",
"and",
"returns",
"true",
"on",
"success",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/file/file_set.php#L159-L186 |
joni-jones/yii2-heroku-logger | HerokuTarget.php | HerokuTarget.export | public function export()
{
$messages = implode("\n", array_map([$this, 'formatMessage'], $this->messages))."\n";
$stdout = fopen('php://stdout', 'w');
if ($stdout === false) {
throw new InvalidConfigException('Unable to open stdout stream');
}
fwrite($stdout, $messages);
fclose($stdout);
} | php | public function export()
{
$messages = implode("\n", array_map([$this, 'formatMessage'], $this->messages))."\n";
$stdout = fopen('php://stdout', 'w');
if ($stdout === false) {
throw new InvalidConfigException('Unable to open stdout stream');
}
fwrite($stdout, $messages);
fclose($stdout);
} | [
"public",
"function",
"export",
"(",
")",
"{",
"$",
"messages",
"=",
"implode",
"(",
"\"\\n\"",
",",
"array_map",
"(",
"[",
"$",
"this",
",",
"'formatMessage'",
"]",
",",
"$",
"this",
"->",
"messages",
")",
")",
".",
"\"\\n\"",
";",
"$",
"stdout",
"=",
"fopen",
"(",
"'php://stdout'",
",",
"'w'",
")",
";",
"if",
"(",
"$",
"stdout",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'Unable to open stdout stream'",
")",
";",
"}",
"fwrite",
"(",
"$",
"stdout",
",",
"$",
"messages",
")",
";",
"fclose",
"(",
"$",
"stdout",
")",
";",
"}"
] | Write yii logs to stdout
@access public
@return void | [
"Write",
"yii",
"logs",
"to",
"stdout"
] | train | https://github.com/joni-jones/yii2-heroku-logger/blob/0a648cdd52941caae49c0e54ae65b8a7fc6b2db9/HerokuTarget.php#L15-L24 |
zicht/z | src/Zicht/Tool/Debug.php | Debug.enterScope | public static function enterScope($scope)
{
if (!is_scalar($scope)) {
throw new \InvalidArgumentException("Only scalars allowed as scope identifiers");
}
array_push(self::$scope, $scope);
list($call) = debug_backtrace(0);
array_push(self::$scopeChange, $call);
} | php | public static function enterScope($scope)
{
if (!is_scalar($scope)) {
throw new \InvalidArgumentException("Only scalars allowed as scope identifiers");
}
array_push(self::$scope, $scope);
list($call) = debug_backtrace(0);
array_push(self::$scopeChange, $call);
} | [
"public",
"static",
"function",
"enterScope",
"(",
"$",
"scope",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"scope",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Only scalars allowed as scope identifiers\"",
")",
";",
"}",
"array_push",
"(",
"self",
"::",
"$",
"scope",
",",
"$",
"scope",
")",
";",
"list",
"(",
"$",
"call",
")",
"=",
"debug_backtrace",
"(",
"0",
")",
";",
"array_push",
"(",
"self",
"::",
"$",
"scopeChange",
",",
"$",
"call",
")",
";",
"}"
] | Keeps track of scope
@param string $scope
@return void | [
"Keeps",
"track",
"of",
"scope"
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Debug.php#L31-L39 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Translation/src/filters/bork_filter.php | ezcTranslationBorkFilter.borkify | static private function borkify( $text )
{
$textBlocks = preg_split( '/(%[^ ]+)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE );
$newTextBlocks = array();
foreach ( $textBlocks as $text )
{
if ( strlen( $text ) && $text[0] == '%' )
{
$newTextBlocks[] = (string) $text;
continue;
}
$orgtext = $text;
$searchMap = array(
'/au/', '/\Bu/', '/\Btion/', '/an/', '/a\B/', '/en\b/',
'/\Bew/', '/\Bf/', '/\Bir/', '/\Bi/', '/\bo/', '/ow/', '/ph/',
'/th\b/', '/\bU/', '/y\b/', '/v/', '/w/', '/ooo/',
);
$replaceMap = array(
'oo', 'oo', 'shun', 'un', 'e', 'ee',
'oo', 'ff', 'ur', 'ee', 'oo', 'oo', 'f',
't', 'Oo', 'ai', 'f', 'v', 'oo',
);
$text = preg_replace( $searchMap, $replaceMap, $text );
if ( $orgtext == $text && count( $newTextBlocks ) )
{
$text .= '-a';
}
$newTextBlocks[] = (string) $text;
}
$text = implode( '', $newTextBlocks );
$text = preg_replace( '/([:.?!])(.*)/', '\\2\\1', $text );
return "[$text]";
} | php | static private function borkify( $text )
{
$textBlocks = preg_split( '/(%[^ ]+)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE );
$newTextBlocks = array();
foreach ( $textBlocks as $text )
{
if ( strlen( $text ) && $text[0] == '%' )
{
$newTextBlocks[] = (string) $text;
continue;
}
$orgtext = $text;
$searchMap = array(
'/au/', '/\Bu/', '/\Btion/', '/an/', '/a\B/', '/en\b/',
'/\Bew/', '/\Bf/', '/\Bir/', '/\Bi/', '/\bo/', '/ow/', '/ph/',
'/th\b/', '/\bU/', '/y\b/', '/v/', '/w/', '/ooo/',
);
$replaceMap = array(
'oo', 'oo', 'shun', 'un', 'e', 'ee',
'oo', 'ff', 'ur', 'ee', 'oo', 'oo', 'f',
't', 'Oo', 'ai', 'f', 'v', 'oo',
);
$text = preg_replace( $searchMap, $replaceMap, $text );
if ( $orgtext == $text && count( $newTextBlocks ) )
{
$text .= '-a';
}
$newTextBlocks[] = (string) $text;
}
$text = implode( '', $newTextBlocks );
$text = preg_replace( '/([:.?!])(.*)/', '\\2\\1', $text );
return "[$text]";
} | [
"static",
"private",
"function",
"borkify",
"(",
"$",
"text",
")",
"{",
"$",
"textBlocks",
"=",
"preg_split",
"(",
"'/(%[^ ]+)/'",
",",
"$",
"text",
",",
"-",
"1",
",",
"PREG_SPLIT_DELIM_CAPTURE",
")",
";",
"$",
"newTextBlocks",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"textBlocks",
"as",
"$",
"text",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"text",
")",
"&&",
"$",
"text",
"[",
"0",
"]",
"==",
"'%'",
")",
"{",
"$",
"newTextBlocks",
"[",
"]",
"=",
"(",
"string",
")",
"$",
"text",
";",
"continue",
";",
"}",
"$",
"orgtext",
"=",
"$",
"text",
";",
"$",
"searchMap",
"=",
"array",
"(",
"'/au/'",
",",
"'/\\Bu/'",
",",
"'/\\Btion/'",
",",
"'/an/'",
",",
"'/a\\B/'",
",",
"'/en\\b/'",
",",
"'/\\Bew/'",
",",
"'/\\Bf/'",
",",
"'/\\Bir/'",
",",
"'/\\Bi/'",
",",
"'/\\bo/'",
",",
"'/ow/'",
",",
"'/ph/'",
",",
"'/th\\b/'",
",",
"'/\\bU/'",
",",
"'/y\\b/'",
",",
"'/v/'",
",",
"'/w/'",
",",
"'/ooo/'",
",",
")",
";",
"$",
"replaceMap",
"=",
"array",
"(",
"'oo'",
",",
"'oo'",
",",
"'shun'",
",",
"'un'",
",",
"'e'",
",",
"'ee'",
",",
"'oo'",
",",
"'ff'",
",",
"'ur'",
",",
"'ee'",
",",
"'oo'",
",",
"'oo'",
",",
"'f'",
",",
"'t'",
",",
"'Oo'",
",",
"'ai'",
",",
"'f'",
",",
"'v'",
",",
"'oo'",
",",
")",
";",
"$",
"text",
"=",
"preg_replace",
"(",
"$",
"searchMap",
",",
"$",
"replaceMap",
",",
"$",
"text",
")",
";",
"if",
"(",
"$",
"orgtext",
"==",
"$",
"text",
"&&",
"count",
"(",
"$",
"newTextBlocks",
")",
")",
"{",
"$",
"text",
".=",
"'-a'",
";",
"}",
"$",
"newTextBlocks",
"[",
"]",
"=",
"(",
"string",
")",
"$",
"text",
";",
"}",
"$",
"text",
"=",
"implode",
"(",
"''",
",",
"$",
"newTextBlocks",
")",
";",
"$",
"text",
"=",
"preg_replace",
"(",
"'/([:.?!])(.*)/'",
",",
"'\\\\2\\\\1'",
",",
"$",
"text",
")",
";",
"return",
"\"[$text]\"",
";",
"}"
] | This "borkifies" the $text.
@param string $text
@return string | [
"This",
"borkifies",
"the",
"$text",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/filters/bork_filter.php#L55-L90 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Translation/src/filters/bork_filter.php | ezcTranslationBorkFilter.runFilter | public function runFilter( array $context )
{
foreach ( $context as $element )
{
if ( $element->status !== ezcTranslationData::TRANSLATED )
{
$element->translation = self::borkify( $element->original );
}
}
} | php | public function runFilter( array $context )
{
foreach ( $context as $element )
{
if ( $element->status !== ezcTranslationData::TRANSLATED )
{
$element->translation = self::borkify( $element->original );
}
}
} | [
"public",
"function",
"runFilter",
"(",
"array",
"$",
"context",
")",
"{",
"foreach",
"(",
"$",
"context",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"status",
"!==",
"ezcTranslationData",
"::",
"TRANSLATED",
")",
"{",
"$",
"element",
"->",
"translation",
"=",
"self",
"::",
"borkify",
"(",
"$",
"element",
"->",
"original",
")",
";",
"}",
"}",
"}"
] | Filters a context
Applies the "bork" filter on the given context. The bork filter mangles
non-finished or non-translated text so that it is obvious which text is
translatable, but not yet translated.
@param array(ezcTranslationData) $context
@return void | [
"Filters",
"a",
"context"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/filters/bork_filter.php#L102-L111 |
zicht/z | src/Zicht/Tool/Script/Parser.php | Parser.parse | public function parse(TokenStream $input)
{
$exprParser = new Parser\Expression($this);
$ret = new Node\Script();
if ($input->valid()) {
do {
$hasMatch = false;
if ($input->match(Token::EXPR_START, '@(')) {
$input->next();
$type = $input->expect(Token::IDENTIFIER)->value;
switch ($type) {
case 'sh':
$ret->append(new Node\Script\Shell($exprParser->parse($input)));
break;
case 'for':
$key = null;
$name = $input->expect(Token::IDENTIFIER)->value;
if ($input->match(',')) {
$input->next();
$key = $name;
$name = $input->expect(Token::IDENTIFIER)->value;
}
$input->expect(Token::KEYWORD, 'in');
$ret->append(new Node\Script\ForIn($exprParser->parse($input), $key, $name));
break;
case 'each':
$ret->append(new Node\Script\ForIn($exprParser->parse($input), null, null));
break;
case 'with':
$expr = $exprParser->parse($input);
$input->expect(Token::KEYWORD, 'as');
$name = $input->expect(Token::IDENTIFIER)->value;
$ret->append(new Node\Script\With($expr, $name));
break;
case 'if':
$ret->append(new Node\Script\Conditional($exprParser->parse($input)));
break;
default:
throw new \UnexpectedValueException("Unknown EXPR_START token at this point: {$type}");
}
$input->expect(Token::EXPR_END);
$hasMatch = true;
}
while ($input->match(Token::DATA) && preg_match('/^\s+$/', $input->current()->value)) {
$input->next();
}
} while ($hasMatch && $input->valid());
}
while ($input->valid()) {
$cur = $input->current();
if ($cur->match(Token::EXPR_START, '$(')) {
$input->next();
$ret->append(new Node\Expr\Expr($exprParser->parse($input)));
$input->expect(Token::EXPR_END);
} elseif ($cur->match(Token::DATA)) {
$ret->append(new Node\Expr\Data($cur->value));
$input->next();
} else {
throw new InvalidArgumentException("Unxpected token: " . $input->current()->type);
}
}
return $ret;
} | php | public function parse(TokenStream $input)
{
$exprParser = new Parser\Expression($this);
$ret = new Node\Script();
if ($input->valid()) {
do {
$hasMatch = false;
if ($input->match(Token::EXPR_START, '@(')) {
$input->next();
$type = $input->expect(Token::IDENTIFIER)->value;
switch ($type) {
case 'sh':
$ret->append(new Node\Script\Shell($exprParser->parse($input)));
break;
case 'for':
$key = null;
$name = $input->expect(Token::IDENTIFIER)->value;
if ($input->match(',')) {
$input->next();
$key = $name;
$name = $input->expect(Token::IDENTIFIER)->value;
}
$input->expect(Token::KEYWORD, 'in');
$ret->append(new Node\Script\ForIn($exprParser->parse($input), $key, $name));
break;
case 'each':
$ret->append(new Node\Script\ForIn($exprParser->parse($input), null, null));
break;
case 'with':
$expr = $exprParser->parse($input);
$input->expect(Token::KEYWORD, 'as');
$name = $input->expect(Token::IDENTIFIER)->value;
$ret->append(new Node\Script\With($expr, $name));
break;
case 'if':
$ret->append(new Node\Script\Conditional($exprParser->parse($input)));
break;
default:
throw new \UnexpectedValueException("Unknown EXPR_START token at this point: {$type}");
}
$input->expect(Token::EXPR_END);
$hasMatch = true;
}
while ($input->match(Token::DATA) && preg_match('/^\s+$/', $input->current()->value)) {
$input->next();
}
} while ($hasMatch && $input->valid());
}
while ($input->valid()) {
$cur = $input->current();
if ($cur->match(Token::EXPR_START, '$(')) {
$input->next();
$ret->append(new Node\Expr\Expr($exprParser->parse($input)));
$input->expect(Token::EXPR_END);
} elseif ($cur->match(Token::DATA)) {
$ret->append(new Node\Expr\Data($cur->value));
$input->next();
} else {
throw new InvalidArgumentException("Unxpected token: " . $input->current()->type);
}
}
return $ret;
} | [
"public",
"function",
"parse",
"(",
"TokenStream",
"$",
"input",
")",
"{",
"$",
"exprParser",
"=",
"new",
"Parser",
"\\",
"Expression",
"(",
"$",
"this",
")",
";",
"$",
"ret",
"=",
"new",
"Node",
"\\",
"Script",
"(",
")",
";",
"if",
"(",
"$",
"input",
"->",
"valid",
"(",
")",
")",
"{",
"do",
"{",
"$",
"hasMatch",
"=",
"false",
";",
"if",
"(",
"$",
"input",
"->",
"match",
"(",
"Token",
"::",
"EXPR_START",
",",
"'@('",
")",
")",
"{",
"$",
"input",
"->",
"next",
"(",
")",
";",
"$",
"type",
"=",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"IDENTIFIER",
")",
"->",
"value",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'sh'",
":",
"$",
"ret",
"->",
"append",
"(",
"new",
"Node",
"\\",
"Script",
"\\",
"Shell",
"(",
"$",
"exprParser",
"->",
"parse",
"(",
"$",
"input",
")",
")",
")",
";",
"break",
";",
"case",
"'for'",
":",
"$",
"key",
"=",
"null",
";",
"$",
"name",
"=",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"IDENTIFIER",
")",
"->",
"value",
";",
"if",
"(",
"$",
"input",
"->",
"match",
"(",
"','",
")",
")",
"{",
"$",
"input",
"->",
"next",
"(",
")",
";",
"$",
"key",
"=",
"$",
"name",
";",
"$",
"name",
"=",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"IDENTIFIER",
")",
"->",
"value",
";",
"}",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"KEYWORD",
",",
"'in'",
")",
";",
"$",
"ret",
"->",
"append",
"(",
"new",
"Node",
"\\",
"Script",
"\\",
"ForIn",
"(",
"$",
"exprParser",
"->",
"parse",
"(",
"$",
"input",
")",
",",
"$",
"key",
",",
"$",
"name",
")",
")",
";",
"break",
";",
"case",
"'each'",
":",
"$",
"ret",
"->",
"append",
"(",
"new",
"Node",
"\\",
"Script",
"\\",
"ForIn",
"(",
"$",
"exprParser",
"->",
"parse",
"(",
"$",
"input",
")",
",",
"null",
",",
"null",
")",
")",
";",
"break",
";",
"case",
"'with'",
":",
"$",
"expr",
"=",
"$",
"exprParser",
"->",
"parse",
"(",
"$",
"input",
")",
";",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"KEYWORD",
",",
"'as'",
")",
";",
"$",
"name",
"=",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"IDENTIFIER",
")",
"->",
"value",
";",
"$",
"ret",
"->",
"append",
"(",
"new",
"Node",
"\\",
"Script",
"\\",
"With",
"(",
"$",
"expr",
",",
"$",
"name",
")",
")",
";",
"break",
";",
"case",
"'if'",
":",
"$",
"ret",
"->",
"append",
"(",
"new",
"Node",
"\\",
"Script",
"\\",
"Conditional",
"(",
"$",
"exprParser",
"->",
"parse",
"(",
"$",
"input",
")",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Unknown EXPR_START token at this point: {$type}\"",
")",
";",
"}",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"EXPR_END",
")",
";",
"$",
"hasMatch",
"=",
"true",
";",
"}",
"while",
"(",
"$",
"input",
"->",
"match",
"(",
"Token",
"::",
"DATA",
")",
"&&",
"preg_match",
"(",
"'/^\\s+$/'",
",",
"$",
"input",
"->",
"current",
"(",
")",
"->",
"value",
")",
")",
"{",
"$",
"input",
"->",
"next",
"(",
")",
";",
"}",
"}",
"while",
"(",
"$",
"hasMatch",
"&&",
"$",
"input",
"->",
"valid",
"(",
")",
")",
";",
"}",
"while",
"(",
"$",
"input",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"cur",
"=",
"$",
"input",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"cur",
"->",
"match",
"(",
"Token",
"::",
"EXPR_START",
",",
"'$('",
")",
")",
"{",
"$",
"input",
"->",
"next",
"(",
")",
";",
"$",
"ret",
"->",
"append",
"(",
"new",
"Node",
"\\",
"Expr",
"\\",
"Expr",
"(",
"$",
"exprParser",
"->",
"parse",
"(",
"$",
"input",
")",
")",
")",
";",
"$",
"input",
"->",
"expect",
"(",
"Token",
"::",
"EXPR_END",
")",
";",
"}",
"elseif",
"(",
"$",
"cur",
"->",
"match",
"(",
"Token",
"::",
"DATA",
")",
")",
"{",
"$",
"ret",
"->",
"append",
"(",
"new",
"Node",
"\\",
"Expr",
"\\",
"Data",
"(",
"$",
"cur",
"->",
"value",
")",
")",
";",
"$",
"input",
"->",
"next",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unxpected token: \"",
".",
"$",
"input",
"->",
"current",
"(",
")",
"->",
"type",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Parses the input tokenstream and returns a Script node
@param TokenStream $input
@return Node\Script
@throws \Symfony\Component\Process\Exception\InvalidArgumentException
@throws \UnexpectedValueException | [
"Parses",
"the",
"input",
"tokenstream",
"and",
"returns",
"a",
"Script",
"node"
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Parser.php#L27-L91 |
fdisotto/cac-api | src/fdisotto/CACApi.php | CACApi.getConsoleUrl | public function getConsoleUrl($sid = '') {
$data = $this->_data;
$data['sid'] = $sid;
$this->_make_request(self::CONSOLE_URL, $data, 'POST');
return $this->_response['console'];
} | php | public function getConsoleUrl($sid = '') {
$data = $this->_data;
$data['sid'] = $sid;
$this->_make_request(self::CONSOLE_URL, $data, 'POST');
return $this->_response['console'];
} | [
"public",
"function",
"getConsoleUrl",
"(",
"$",
"sid",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_data",
";",
"$",
"data",
"[",
"'sid'",
"]",
"=",
"$",
"sid",
";",
"$",
"this",
"->",
"_make_request",
"(",
"self",
"::",
"CONSOLE_URL",
",",
"$",
"data",
",",
"'POST'",
")",
";",
"return",
"$",
"this",
"->",
"_response",
"[",
"'console'",
"]",
";",
"}"
] | Return the URL to the web console for the server specified.
https://github.com/cloudatcost/api#power-operations
@param int $sid Server ID
@return string Console url | [
"Return",
"the",
"URL",
"to",
"the",
"web",
"console",
"for",
"the",
"server",
"specified",
".",
"https",
":",
"//",
"github",
".",
"com",
"/",
"cloudatcost",
"/",
"api#power",
"-",
"operations"
] | train | https://github.com/fdisotto/cac-api/blob/c5c7fce1a00dd35584d5ce7e78a41d54188163cc/src/fdisotto/CACApi.php#L186-L192 |
fdisotto/cac-api | src/fdisotto/CACApi.php | CACApi.renameServer | public function renameServer($sid = '', $name = '') {
$data = $this->_data;
$data['sid'] = $sid;
$data['name'] = $name;
$this->_make_request(self::RENAME_SRV_URL, $data, 'POST');
return array_key_exists('result', $this->_response) ? $this->_response['result'] : false;
} | php | public function renameServer($sid = '', $name = '') {
$data = $this->_data;
$data['sid'] = $sid;
$data['name'] = $name;
$this->_make_request(self::RENAME_SRV_URL, $data, 'POST');
return array_key_exists('result', $this->_response) ? $this->_response['result'] : false;
} | [
"public",
"function",
"renameServer",
"(",
"$",
"sid",
"=",
"''",
",",
"$",
"name",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_data",
";",
"$",
"data",
"[",
"'sid'",
"]",
"=",
"$",
"sid",
";",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"_make_request",
"(",
"self",
"::",
"RENAME_SRV_URL",
",",
"$",
"data",
",",
"'POST'",
")",
";",
"return",
"array_key_exists",
"(",
"'result'",
",",
"$",
"this",
"->",
"_response",
")",
"?",
"$",
"this",
"->",
"_response",
"[",
"'result'",
"]",
":",
"false",
";",
"}"
] | Rename the server label
https://github.com/cloudatcost/api#rename-server
@param int $sid Server ID
@param string $name Name
@return bool|string false or "success" if success | [
"Rename",
"the",
"server",
"label",
"https",
":",
"//",
"github",
".",
"com",
"/",
"cloudatcost",
"/",
"api#rename",
"-",
"server"
] | train | https://github.com/fdisotto/cac-api/blob/c5c7fce1a00dd35584d5ce7e78a41d54188163cc/src/fdisotto/CACApi.php#L202-L209 |
fdisotto/cac-api | src/fdisotto/CACApi.php | CACApi.reverseDNS | public function reverseDNS($sid = '', $hostname = '') {
$data = $this->_data;
$data['sid'] = $sid;
$data['hostname'] = $hostname;
$this->_make_request(self::R_DNS_URL, $data, 'POST');
return array_key_exists('result', $this->_response) ? $this->_response['result'] : false;
} | php | public function reverseDNS($sid = '', $hostname = '') {
$data = $this->_data;
$data['sid'] = $sid;
$data['hostname'] = $hostname;
$this->_make_request(self::R_DNS_URL, $data, 'POST');
return array_key_exists('result', $this->_response) ? $this->_response['result'] : false;
} | [
"public",
"function",
"reverseDNS",
"(",
"$",
"sid",
"=",
"''",
",",
"$",
"hostname",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_data",
";",
"$",
"data",
"[",
"'sid'",
"]",
"=",
"$",
"sid",
";",
"$",
"data",
"[",
"'hostname'",
"]",
"=",
"$",
"hostname",
";",
"$",
"this",
"->",
"_make_request",
"(",
"self",
"::",
"R_DNS_URL",
",",
"$",
"data",
",",
"'POST'",
")",
";",
"return",
"array_key_exists",
"(",
"'result'",
",",
"$",
"this",
"->",
"_response",
")",
"?",
"$",
"this",
"->",
"_response",
"[",
"'result'",
"]",
":",
"false",
";",
"}"
] | Modify the reverse DNS & hostname of the VPS
https://github.com/cloudatcost/api#modify-reverse-dns
@param int $sid Server ID
@param string $hostname Hostname
@return bool|string false or "success" if success | [
"Modify",
"the",
"reverse",
"DNS",
"&",
"hostname",
"of",
"the",
"VPS",
"https",
":",
"//",
"github",
".",
"com",
"/",
"cloudatcost",
"/",
"api#modify",
"-",
"reverse",
"-",
"dns"
] | train | https://github.com/fdisotto/cac-api/blob/c5c7fce1a00dd35584d5ce7e78a41d54188163cc/src/fdisotto/CACApi.php#L219-L226 |
fdisotto/cac-api | src/fdisotto/CACApi.php | CACApi.runMode | public function runMode($sid = '', $mode = '') {
$data = $this->_data;
$data['sid'] = $sid;
$data['mode'] = $mode;
$this->_make_request(self::RUN_MODE_URL, $data, 'POST');
return array_key_exists('result', $this->_response) ? $this->_response['result'] : false;
} | php | public function runMode($sid = '', $mode = '') {
$data = $this->_data;
$data['sid'] = $sid;
$data['mode'] = $mode;
$this->_make_request(self::RUN_MODE_URL, $data, 'POST');
return array_key_exists('result', $this->_response) ? $this->_response['result'] : false;
} | [
"public",
"function",
"runMode",
"(",
"$",
"sid",
"=",
"''",
",",
"$",
"mode",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_data",
";",
"$",
"data",
"[",
"'sid'",
"]",
"=",
"$",
"sid",
";",
"$",
"data",
"[",
"'mode'",
"]",
"=",
"$",
"mode",
";",
"$",
"this",
"->",
"_make_request",
"(",
"self",
"::",
"RUN_MODE_URL",
",",
"$",
"data",
",",
"'POST'",
")",
";",
"return",
"array_key_exists",
"(",
"'result'",
",",
"$",
"this",
"->",
"_response",
")",
"?",
"$",
"this",
"->",
"_response",
"[",
"'result'",
"]",
":",
"false",
";",
"}"
] | Set the run mode of the server to either 'normal' or 'safe'.
Safe automatically turns off the server after 7 days of idle usage.
Normal keeps it on indefinitely.
https://github.com/cloudatcost/api#run-mode
@param int $sid Server ID
@param string $mode Run mode: 'normal' or 'safe'
@return bool|string false or "success" if success | [
"Set",
"the",
"run",
"mode",
"of",
"the",
"server",
"to",
"either",
"normal",
"or",
"safe",
".",
"Safe",
"automatically",
"turns",
"off",
"the",
"server",
"after",
"7",
"days",
"of",
"idle",
"usage",
".",
"Normal",
"keeps",
"it",
"on",
"indefinitely",
".",
"https",
":",
"//",
"github",
".",
"com",
"/",
"cloudatcost",
"/",
"api#run",
"-",
"mode"
] | train | https://github.com/fdisotto/cac-api/blob/c5c7fce1a00dd35584d5ce7e78a41d54188163cc/src/fdisotto/CACApi.php#L238-L245 |
fdisotto/cac-api | src/fdisotto/CACApi.php | CACApi._make_request | private function _make_request($where, $data, $type = 'GET') {
if ($type == 'GET') {
try {
$this->get(self::BASE_URL . self::API_VERSION . $where, $data);
$this->_response = json_decode($this->response, true);
if ($this->_response['status'] === 'ok') {
if (array_key_exists('data', $this->_response)) {
$this->_response = $this->_response['data'];
}
return true;
} else {
$this->_response = $this->_response;
return false;
}
} catch (\Exception $e) {
throw new \Exception('Something gone wrong', 0, $e);
}
} elseif ($type == 'POST') {
try {
$this->post(self::BASE_URL . self::API_VERSION . $where, $data);
$this->_response = json_decode($this->response, true);
if ($this->_response['status'] === 'ok') {
if (array_key_exists('data', $this->_response)) {
$this->_response = $this->_response['data'];
}
return true;
} else {
$this->_response = $this->_response;
return false;
}
} catch (\Exception $e) {
throw new \Exception('Something gone wrong', 0, $e);
}
} else {
throw new \Exception('Invalid Request Type', 0);
}
$this->close();
return false;
} | php | private function _make_request($where, $data, $type = 'GET') {
if ($type == 'GET') {
try {
$this->get(self::BASE_URL . self::API_VERSION . $where, $data);
$this->_response = json_decode($this->response, true);
if ($this->_response['status'] === 'ok') {
if (array_key_exists('data', $this->_response)) {
$this->_response = $this->_response['data'];
}
return true;
} else {
$this->_response = $this->_response;
return false;
}
} catch (\Exception $e) {
throw new \Exception('Something gone wrong', 0, $e);
}
} elseif ($type == 'POST') {
try {
$this->post(self::BASE_URL . self::API_VERSION . $where, $data);
$this->_response = json_decode($this->response, true);
if ($this->_response['status'] === 'ok') {
if (array_key_exists('data', $this->_response)) {
$this->_response = $this->_response['data'];
}
return true;
} else {
$this->_response = $this->_response;
return false;
}
} catch (\Exception $e) {
throw new \Exception('Something gone wrong', 0, $e);
}
} else {
throw new \Exception('Invalid Request Type', 0);
}
$this->close();
return false;
} | [
"private",
"function",
"_make_request",
"(",
"$",
"where",
",",
"$",
"data",
",",
"$",
"type",
"=",
"'GET'",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'GET'",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"get",
"(",
"self",
"::",
"BASE_URL",
".",
"self",
"::",
"API_VERSION",
".",
"$",
"where",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"_response",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"response",
",",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_response",
"[",
"'status'",
"]",
"===",
"'ok'",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'data'",
",",
"$",
"this",
"->",
"_response",
")",
")",
"{",
"$",
"this",
"->",
"_response",
"=",
"$",
"this",
"->",
"_response",
"[",
"'data'",
"]",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_response",
"=",
"$",
"this",
"->",
"_response",
";",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Something gone wrong'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'POST'",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"post",
"(",
"self",
"::",
"BASE_URL",
".",
"self",
"::",
"API_VERSION",
".",
"$",
"where",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"_response",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"response",
",",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_response",
"[",
"'status'",
"]",
"===",
"'ok'",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'data'",
",",
"$",
"this",
"->",
"_response",
")",
")",
"{",
"$",
"this",
"->",
"_response",
"=",
"$",
"this",
"->",
"_response",
"[",
"'data'",
"]",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_response",
"=",
"$",
"this",
"->",
"_response",
";",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Something gone wrong'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Invalid Request Type'",
",",
"0",
")",
";",
"}",
"$",
"this",
"->",
"close",
"(",
")",
";",
"return",
"false",
";",
"}"
] | Perform the web request to the C@C API
@param string $where The endpont of the url
@param array $data Options for the web request
@param string $type GET or POST web request
@return bool | [
"Perform",
"the",
"web",
"request",
"to",
"the",
"C@C",
"API"
] | train | https://github.com/fdisotto/cac-api/blob/c5c7fce1a00dd35584d5ce7e78a41d54188163cc/src/fdisotto/CACApi.php#L255-L295 |
fdisotto/cac-api | src/fdisotto/CACApi.php | CACApi._make_power_operation | private function _make_power_operation($sid, $action) {
$data = $this->_data;
$data['sid'] = $sid;
$data['action'] = $action;
try {
return $this->_make_request(self::POWER_OP_URL, $data, 'POST');
} catch (\Exception $e) {
throw new \Exception('Something gone wrong', 0, $e);
}
return true;
} | php | private function _make_power_operation($sid, $action) {
$data = $this->_data;
$data['sid'] = $sid;
$data['action'] = $action;
try {
return $this->_make_request(self::POWER_OP_URL, $data, 'POST');
} catch (\Exception $e) {
throw new \Exception('Something gone wrong', 0, $e);
}
return true;
} | [
"private",
"function",
"_make_power_operation",
"(",
"$",
"sid",
",",
"$",
"action",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_data",
";",
"$",
"data",
"[",
"'sid'",
"]",
"=",
"$",
"sid",
";",
"$",
"data",
"[",
"'action'",
"]",
"=",
"$",
"action",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"_make_request",
"(",
"self",
"::",
"POWER_OP_URL",
",",
"$",
"data",
",",
"'POST'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Something gone wrong'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Perform the power operation on the server
@param int $sid Server ID
@param string $action poweron, poweroff, reset request
@return bool | [
"Perform",
"the",
"power",
"operation",
"on",
"the",
"server"
] | train | https://github.com/fdisotto/cac-api/blob/c5c7fce1a00dd35584d5ce7e78a41d54188163cc/src/fdisotto/CACApi.php#L304-L317 |
mothership-ec/composer | src/Composer/Util/StreamContextFactory.php | StreamContextFactory.fixHttpHeaderField | private static function fixHttpHeaderField($header)
{
if (!is_array($header)) {
$header = explode("\r\n", $header);
}
uasort($header, function ($el) {
return preg_match('{^content-type}i', $el) ? 1 : -1;
});
return $header;
} | php | private static function fixHttpHeaderField($header)
{
if (!is_array($header)) {
$header = explode("\r\n", $header);
}
uasort($header, function ($el) {
return preg_match('{^content-type}i', $el) ? 1 : -1;
});
return $header;
} | [
"private",
"static",
"function",
"fixHttpHeaderField",
"(",
"$",
"header",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"header",
")",
")",
"{",
"$",
"header",
"=",
"explode",
"(",
"\"\\r\\n\"",
",",
"$",
"header",
")",
";",
"}",
"uasort",
"(",
"$",
"header",
",",
"function",
"(",
"$",
"el",
")",
"{",
"return",
"preg_match",
"(",
"'{^content-type}i'",
",",
"$",
"el",
")",
"?",
"1",
":",
"-",
"1",
";",
"}",
")",
";",
"return",
"$",
"header",
";",
"}"
] | A bug in PHP prevents the headers from correctly being sent when a content-type header is present and
NOT at the end of the array
This method fixes the array by moving the content-type header to the end
@link https://bugs.php.net/bug.php?id=61548
@param $header
@return array | [
"A",
"bug",
"in",
"PHP",
"prevents",
"the",
"headers",
"from",
"correctly",
"being",
"sent",
"when",
"a",
"content",
"-",
"type",
"header",
"is",
"present",
"and",
"NOT",
"at",
"the",
"end",
"of",
"the",
"array"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Util/StreamContextFactory.php#L143-L153 |
tequila/mongodb-odm | src/DocumentsCollection.php | DocumentsCollection.rewind | public function rewind()
{
if ($this->iterationStarted) {
throw new LogicException(sprintf('%s cannot yield multiple iterators', get_class($this)));
}
$this->iterationStarted = true;
} | php | public function rewind()
{
if ($this->iterationStarted) {
throw new LogicException(sprintf('%s cannot yield multiple iterators', get_class($this)));
}
$this->iterationStarted = true;
} | [
"public",
"function",
"rewind",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"iterationStarted",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'%s cannot yield multiple iterators'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"iterationStarted",
"=",
"true",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/DocumentsCollection.php#L100-L106 |
nabab/bbn | src/bbn/appui/tasks.php | tasks.stop_track | public function stop_track($id_task, $message = false, $id_user = false){
$ok = false;
$now = time();
if (
($active_track = $this->get_active_track($id_user)) &&
($active_track['id_task'] === $id_task)
){
$ok = true;
if (
!empty($message) &&
!($id_note = $this->comment($id_task, [
'title' => _('Report tracker').' '.date('d M Y H:i', strtotime($active_track['start'])).' - '.date('d M Y H:i', $now),
'text' => $message
]))
){
$ok = false;
}
if ( $ok ){
$ok = $this->db->update('bbn_tasks_sessions', [
'length' => $now - strtotime($active_track['start']),
'id_note' => $id_note ?: NULL
], [
'id' => $active_track['id']
]);
}
}
return (bool)$ok;
} | php | public function stop_track($id_task, $message = false, $id_user = false){
$ok = false;
$now = time();
if (
($active_track = $this->get_active_track($id_user)) &&
($active_track['id_task'] === $id_task)
){
$ok = true;
if (
!empty($message) &&
!($id_note = $this->comment($id_task, [
'title' => _('Report tracker').' '.date('d M Y H:i', strtotime($active_track['start'])).' - '.date('d M Y H:i', $now),
'text' => $message
]))
){
$ok = false;
}
if ( $ok ){
$ok = $this->db->update('bbn_tasks_sessions', [
'length' => $now - strtotime($active_track['start']),
'id_note' => $id_note ?: NULL
], [
'id' => $active_track['id']
]);
}
}
return (bool)$ok;
} | [
"public",
"function",
"stop_track",
"(",
"$",
"id_task",
",",
"$",
"message",
"=",
"false",
",",
"$",
"id_user",
"=",
"false",
")",
"{",
"$",
"ok",
"=",
"false",
";",
"$",
"now",
"=",
"time",
"(",
")",
";",
"if",
"(",
"(",
"$",
"active_track",
"=",
"$",
"this",
"->",
"get_active_track",
"(",
"$",
"id_user",
")",
")",
"&&",
"(",
"$",
"active_track",
"[",
"'id_task'",
"]",
"===",
"$",
"id_task",
")",
")",
"{",
"$",
"ok",
"=",
"true",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"message",
")",
"&&",
"!",
"(",
"$",
"id_note",
"=",
"$",
"this",
"->",
"comment",
"(",
"$",
"id_task",
",",
"[",
"'title'",
"=>",
"_",
"(",
"'Report tracker'",
")",
".",
"' '",
".",
"date",
"(",
"'d M Y H:i'",
",",
"strtotime",
"(",
"$",
"active_track",
"[",
"'start'",
"]",
")",
")",
".",
"' - '",
".",
"date",
"(",
"'d M Y H:i'",
",",
"$",
"now",
")",
",",
"'text'",
"=>",
"$",
"message",
"]",
")",
")",
")",
"{",
"$",
"ok",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"ok",
")",
"{",
"$",
"ok",
"=",
"$",
"this",
"->",
"db",
"->",
"update",
"(",
"'bbn_tasks_sessions'",
",",
"[",
"'length'",
"=>",
"$",
"now",
"-",
"strtotime",
"(",
"$",
"active_track",
"[",
"'start'",
"]",
")",
",",
"'id_note'",
"=>",
"$",
"id_note",
"?",
":",
"NULL",
"]",
",",
"[",
"'id'",
"=>",
"$",
"active_track",
"[",
"'id'",
"]",
"]",
")",
";",
"}",
"}",
"return",
"(",
"bool",
")",
"$",
"ok",
";",
"}"
] | Stops a track.
@param string $id_task The task's ID
@param boolean|string $message The message to attach to track (optional)
@param boolean|string $id_user The track's user. If you give 'false', it will use the current user
@return boolean | [
"Stops",
"a",
"track",
"."
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/tasks.php#L1113-L1140 |
inhere/php-librarys | src/Collections/ActiveData.php | ActiveData.load | public function load($data, $recursive = false)
{
foreach ($data as $name => $value) {
$name = trim($name);
if (is_numeric($name)) {
continue;
}
$this->$name = $recursive && \is_array($value) ? static::create($value, $recursive) : $value;
}
return $this;
} | php | public function load($data, $recursive = false)
{
foreach ($data as $name => $value) {
$name = trim($name);
if (is_numeric($name)) {
continue;
}
$this->$name = $recursive && \is_array($value) ? static::create($value, $recursive) : $value;
}
return $this;
} | [
"public",
"function",
"load",
"(",
"$",
"data",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"name",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"$",
"name",
"=",
"$",
"recursive",
"&&",
"\\",
"is_array",
"(",
"$",
"value",
")",
"?",
"static",
"::",
"create",
"(",
"$",
"value",
",",
"$",
"recursive",
")",
":",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 初始化,载入数据
@param array $data
@param bool $recursive
@return $this | [
"初始化,载入数据"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Collections/ActiveData.php#L47-L60 |
inhere/php-librarys | src/Collections/ActiveData.php | ActiveData.get | public function get($name)
{
if (strpos($name, '.')) {
$names = explode('.', $name);
$node = $this;
foreach ($names as $n) {
if ($node instanceof self && property_exists($node, $n)) {
$node = $node->$n;
} else {
if ($this->isStrict()) {
exit("Stored data don't exists node '$n'\n");
}
$node = null;
break;
}
}
return $node;
}
return property_exists($this, $name) ? $this->$name : null;
} | php | public function get($name)
{
if (strpos($name, '.')) {
$names = explode('.', $name);
$node = $this;
foreach ($names as $n) {
if ($node instanceof self && property_exists($node, $n)) {
$node = $node->$n;
} else {
if ($this->isStrict()) {
exit("Stored data don't exists node '$n'\n");
}
$node = null;
break;
}
}
return $node;
}
return property_exists($this, $name) ? $this->$name : null;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'.'",
")",
")",
"{",
"$",
"names",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
")",
";",
"$",
"node",
"=",
"$",
"this",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"self",
"&&",
"property_exists",
"(",
"$",
"node",
",",
"$",
"n",
")",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"$",
"n",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"isStrict",
"(",
")",
")",
"{",
"exit",
"(",
"\"Stored data don't exists node '$n'\\n\"",
")",
";",
"}",
"$",
"node",
"=",
"null",
";",
"break",
";",
"}",
"}",
"return",
"$",
"node",
";",
"}",
"return",
"property_exists",
"(",
"$",
"this",
",",
"$",
"name",
")",
"?",
"$",
"this",
"->",
"$",
"name",
":",
"null",
";",
"}"
] | 以点连接 快速获取子级节点的值
@param string $name
@return ActiveData|null | [
"以点连接",
"快速获取子级节点的值"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Collections/ActiveData.php#L92-L115 |
ClementIV/yii-rest-rbac2.0 | models/LoginForm.php | LoginForm.login | public function login()
{
if ($this->validate()) {
$this->trigger(self::GET_ACCESS_TOKEN);
if($this->_user != null) {
$this ->_user = User::findByUsername($this->username);
}
return $this->_user;
} else {
return null;
}
} | php | public function login()
{
if ($this->validate()) {
$this->trigger(self::GET_ACCESS_TOKEN);
if($this->_user != null) {
$this ->_user = User::findByUsername($this->username);
}
return $this->_user;
} else {
return null;
}
} | [
"public",
"function",
"login",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"GET_ACCESS_TOKEN",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_user",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_user",
"=",
"User",
"::",
"findByUsername",
"(",
"$",
"this",
"->",
"username",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_user",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Logs in a user using the provided username and password.
@return boolean whether the user is logged in successfully | [
"Logs",
"in",
"a",
"user",
"using",
"the",
"provided",
"username",
"and",
"password",
"."
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/models/LoginForm.php#L63-L74 |
ClementIV/yii-rest-rbac2.0 | models/LoginForm.php | LoginForm.onGenerateAccessToken | public function onGenerateAccessToken()
{
if (!User::isAccessTokenValid($this->_user->access_token)) {
$this->_user->generateAccessToken();
$this->_user->save(false);
}
} | php | public function onGenerateAccessToken()
{
if (!User::isAccessTokenValid($this->_user->access_token)) {
$this->_user->generateAccessToken();
$this->_user->save(false);
}
} | [
"public",
"function",
"onGenerateAccessToken",
"(",
")",
"{",
"if",
"(",
"!",
"User",
"::",
"isAccessTokenValid",
"(",
"$",
"this",
"->",
"_user",
"->",
"access_token",
")",
")",
"{",
"$",
"this",
"->",
"_user",
"->",
"generateAccessToken",
"(",
")",
";",
"$",
"this",
"->",
"_user",
"->",
"save",
"(",
"false",
")",
";",
"}",
"}"
] | 登录校验成功后,为用户生成新的token
如果token失效,则重新生成token | [
"登录校验成功后,为用户生成新的token",
"如果token失效,则重新生成token"
] | train | https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/models/LoginForm.php#L94-L100 |
getuisdk/getui-php-sdk | src/Base128Varint.php | Base128Varint.getValue | public function getValue($string)
{
// now just drop the msb and reorder it + parse it in own string
$valuestring = '';
$string_length = strlen($string);
$i = 1;
while ($string_length > $i) {
// unset msb string and reorder it
$valuestring = substr($string, $i, 7) . $valuestring;
$i += 8;
}
// now interprete it
return bindec($valuestring);
} | php | public function getValue($string)
{
// now just drop the msb and reorder it + parse it in own string
$valuestring = '';
$string_length = strlen($string);
$i = 1;
while ($string_length > $i) {
// unset msb string and reorder it
$valuestring = substr($string, $i, 7) . $valuestring;
$i += 8;
}
// now interprete it
return bindec($valuestring);
} | [
"public",
"function",
"getValue",
"(",
"$",
"string",
")",
"{",
"// now just drop the msb and reorder it + parse it in own string\r",
"$",
"valuestring",
"=",
"''",
";",
"$",
"string_length",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"$",
"i",
"=",
"1",
";",
"while",
"(",
"$",
"string_length",
">",
"$",
"i",
")",
"{",
"// unset msb string and reorder it\r",
"$",
"valuestring",
"=",
"substr",
"(",
"$",
"string",
",",
"$",
"i",
",",
"7",
")",
".",
"$",
"valuestring",
";",
"$",
"i",
"+=",
"8",
";",
"}",
"// now interprete it\r",
"return",
"bindec",
"(",
"$",
"valuestring",
")",
";",
"}"
] | Returns the dec value of an base128
@param string $string bstring
@return mixed | [
"Returns",
"the",
"dec",
"value",
"of",
"an",
"base128"
] | train | https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/Base128Varint.php#L77-L93 |
getuisdk/getui-php-sdk | src/Base128Varint.php | Base128Varint.hexToStr | public function hexToStr($hex)
{
$str = '';
$hl = strlen($hex);
for ($i = 0; $i < $hl; $i += 2) {
$str .= chr(intval(substr($hex, $i, 2), 16));
}
return $str;
} | php | public function hexToStr($hex)
{
$str = '';
$hl = strlen($hex);
for ($i = 0; $i < $hl; $i += 2) {
$str .= chr(intval(substr($hex, $i, 2), 16));
}
return $str;
} | [
"public",
"function",
"hexToStr",
"(",
"$",
"hex",
")",
"{",
"$",
"str",
"=",
"''",
";",
"$",
"hl",
"=",
"strlen",
"(",
"$",
"hex",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"hl",
";",
"$",
"i",
"+=",
"2",
")",
"{",
"$",
"str",
".=",
"chr",
"(",
"intval",
"(",
"substr",
"(",
"$",
"hex",
",",
"$",
"i",
",",
"2",
")",
",",
"16",
")",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Converts hex 2 ascii
@param String $hex - the hex string
@return mixed | [
"Converts",
"hex",
"2",
"ascii"
] | train | https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/Base128Varint.php#L100-L108 |
oroinc/OroLayoutComponent | HierarchyCollection.php | HierarchyCollection.getRootId | public function getRootId()
{
if (empty($this->hierarchy)) {
throw new Exception\LogicException('The root item does not exist.');
}
reset($this->hierarchy);
$id = key($this->hierarchy);
return $id;
} | php | public function getRootId()
{
if (empty($this->hierarchy)) {
throw new Exception\LogicException('The root item does not exist.');
}
reset($this->hierarchy);
$id = key($this->hierarchy);
return $id;
} | [
"public",
"function",
"getRootId",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"hierarchy",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"'The root item does not exist.'",
")",
";",
"}",
"reset",
"(",
"$",
"this",
"->",
"hierarchy",
")",
";",
"$",
"id",
"=",
"key",
"(",
"$",
"this",
"->",
"hierarchy",
")",
";",
"return",
"$",
"id",
";",
"}"
] | Returns the identifier of the root item
@return string
@throws Exception\LogicException if the root item does not exist | [
"Returns",
"the",
"identifier",
"of",
"the",
"root",
"item"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/HierarchyCollection.php#L41-L51 |
oroinc/OroLayoutComponent | HierarchyCollection.php | HierarchyCollection.get | public function get(array $path)
{
$current = &$this->hierarchy;
foreach ($path as $childId) {
if (!isset($current[$childId])) {
return [];
}
$current = &$current[$childId];
}
return $current;
} | php | public function get(array $path)
{
$current = &$this->hierarchy;
foreach ($path as $childId) {
if (!isset($current[$childId])) {
return [];
}
$current = &$current[$childId];
}
return $current;
} | [
"public",
"function",
"get",
"(",
"array",
"$",
"path",
")",
"{",
"$",
"current",
"=",
"&",
"$",
"this",
"->",
"hierarchy",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"childId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"current",
"[",
"$",
"childId",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"current",
"=",
"&",
"$",
"current",
"[",
"$",
"childId",
"]",
";",
"}",
"return",
"$",
"current",
";",
"}"
] | Gets hierarchy by the path
@param string[] $path
@return array | [
"Gets",
"hierarchy",
"by",
"the",
"path"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/HierarchyCollection.php#L60-L71 |
oroinc/OroLayoutComponent | HierarchyCollection.php | HierarchyCollection.add | public function add(array $parentPath, $id, $siblingId = null, $prepend = null, array $children = [])
{
$current = &$this->hierarchy;
$parentPathLength = count($parentPath);
$key = null;
for ($i = 0; $i < $parentPathLength; $i++) {
if (!isset($current[$parentPath[$i]])) {
if ($i === 0) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because "%s" root item does not exist.',
$id,
implode('/', $parentPath),
$parentPath[$i]
)
);
} else {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because "%s" item does not have "%s" child.',
$id,
implode('/', $parentPath),
$parentPath[$i - 1],
$parentPath[$i]
)
);
}
}
$key = $parentPath[$i];
$current = &$current[$key];
}
if (isset($current[$id])) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because such item already exists.',
$id,
implode('/', $parentPath)
)
);
}
if (!$siblingId) {
if ($prepend && !empty($current)) {
$current = array_merge([$id => $children], $current);
} elseif ($prepend === false) {
$current[$id] = $children;
if (!array_key_exists($key, $this->offsets)) {
$this->offsets[$key] = 0;
}
$this->offsets[$key]--;
} else {
if (array_key_exists($key, $this->offsets)) {
$offset = $this->offsets[$key];
$firstPart = array_slice($current, 0, count($current) + $offset, true);
$lastPart = array_slice($current, $offset, null, true);
$current = array_merge($firstPart, [$id => $children], $lastPart);
}
$current[$id] = $children;
}
} elseif (!isset($current[$siblingId])) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because "%s" sibling item does not exist.',
$id,
implode('/', $parentPath),
$siblingId
)
);
} else {
$new = [];
foreach ($current as $key => $value) {
if ($key === $siblingId) {
if ($prepend) {
$new[$id] = $children;
$new[$key] = $value;
} else {
$new[$key] = $value;
$new[$id] = $children;
}
} else {
$new[$key] = $value;
}
}
$current = $new;
}
} | php | public function add(array $parentPath, $id, $siblingId = null, $prepend = null, array $children = [])
{
$current = &$this->hierarchy;
$parentPathLength = count($parentPath);
$key = null;
for ($i = 0; $i < $parentPathLength; $i++) {
if (!isset($current[$parentPath[$i]])) {
if ($i === 0) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because "%s" root item does not exist.',
$id,
implode('/', $parentPath),
$parentPath[$i]
)
);
} else {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because "%s" item does not have "%s" child.',
$id,
implode('/', $parentPath),
$parentPath[$i - 1],
$parentPath[$i]
)
);
}
}
$key = $parentPath[$i];
$current = &$current[$key];
}
if (isset($current[$id])) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because such item already exists.',
$id,
implode('/', $parentPath)
)
);
}
if (!$siblingId) {
if ($prepend && !empty($current)) {
$current = array_merge([$id => $children], $current);
} elseif ($prepend === false) {
$current[$id] = $children;
if (!array_key_exists($key, $this->offsets)) {
$this->offsets[$key] = 0;
}
$this->offsets[$key]--;
} else {
if (array_key_exists($key, $this->offsets)) {
$offset = $this->offsets[$key];
$firstPart = array_slice($current, 0, count($current) + $offset, true);
$lastPart = array_slice($current, $offset, null, true);
$current = array_merge($firstPart, [$id => $children], $lastPart);
}
$current[$id] = $children;
}
} elseif (!isset($current[$siblingId])) {
throw new Exception\LogicException(
sprintf(
'Cannot add "%s" item to "%s" because "%s" sibling item does not exist.',
$id,
implode('/', $parentPath),
$siblingId
)
);
} else {
$new = [];
foreach ($current as $key => $value) {
if ($key === $siblingId) {
if ($prepend) {
$new[$id] = $children;
$new[$key] = $value;
} else {
$new[$key] = $value;
$new[$id] = $children;
}
} else {
$new[$key] = $value;
}
}
$current = $new;
}
} | [
"public",
"function",
"add",
"(",
"array",
"$",
"parentPath",
",",
"$",
"id",
",",
"$",
"siblingId",
"=",
"null",
",",
"$",
"prepend",
"=",
"null",
",",
"array",
"$",
"children",
"=",
"[",
"]",
")",
"{",
"$",
"current",
"=",
"&",
"$",
"this",
"->",
"hierarchy",
";",
"$",
"parentPathLength",
"=",
"count",
"(",
"$",
"parentPath",
")",
";",
"$",
"key",
"=",
"null",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"parentPathLength",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"current",
"[",
"$",
"parentPath",
"[",
"$",
"i",
"]",
"]",
")",
")",
"{",
"if",
"(",
"$",
"i",
"===",
"0",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot add \"%s\" item to \"%s\" because \"%s\" root item does not exist.'",
",",
"$",
"id",
",",
"implode",
"(",
"'/'",
",",
"$",
"parentPath",
")",
",",
"$",
"parentPath",
"[",
"$",
"i",
"]",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot add \"%s\" item to \"%s\" because \"%s\" item does not have \"%s\" child.'",
",",
"$",
"id",
",",
"implode",
"(",
"'/'",
",",
"$",
"parentPath",
")",
",",
"$",
"parentPath",
"[",
"$",
"i",
"-",
"1",
"]",
",",
"$",
"parentPath",
"[",
"$",
"i",
"]",
")",
")",
";",
"}",
"}",
"$",
"key",
"=",
"$",
"parentPath",
"[",
"$",
"i",
"]",
";",
"$",
"current",
"=",
"&",
"$",
"current",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"current",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot add \"%s\" item to \"%s\" because such item already exists.'",
",",
"$",
"id",
",",
"implode",
"(",
"'/'",
",",
"$",
"parentPath",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"siblingId",
")",
"{",
"if",
"(",
"$",
"prepend",
"&&",
"!",
"empty",
"(",
"$",
"current",
")",
")",
"{",
"$",
"current",
"=",
"array_merge",
"(",
"[",
"$",
"id",
"=>",
"$",
"children",
"]",
",",
"$",
"current",
")",
";",
"}",
"elseif",
"(",
"$",
"prepend",
"===",
"false",
")",
"{",
"$",
"current",
"[",
"$",
"id",
"]",
"=",
"$",
"children",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"offsets",
")",
")",
"{",
"$",
"this",
"->",
"offsets",
"[",
"$",
"key",
"]",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"offsets",
"[",
"$",
"key",
"]",
"--",
";",
"}",
"else",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"offsets",
")",
")",
"{",
"$",
"offset",
"=",
"$",
"this",
"->",
"offsets",
"[",
"$",
"key",
"]",
";",
"$",
"firstPart",
"=",
"array_slice",
"(",
"$",
"current",
",",
"0",
",",
"count",
"(",
"$",
"current",
")",
"+",
"$",
"offset",
",",
"true",
")",
";",
"$",
"lastPart",
"=",
"array_slice",
"(",
"$",
"current",
",",
"$",
"offset",
",",
"null",
",",
"true",
")",
";",
"$",
"current",
"=",
"array_merge",
"(",
"$",
"firstPart",
",",
"[",
"$",
"id",
"=>",
"$",
"children",
"]",
",",
"$",
"lastPart",
")",
";",
"}",
"$",
"current",
"[",
"$",
"id",
"]",
"=",
"$",
"children",
";",
"}",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"current",
"[",
"$",
"siblingId",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Cannot add \"%s\" item to \"%s\" because \"%s\" sibling item does not exist.'",
",",
"$",
"id",
",",
"implode",
"(",
"'/'",
",",
"$",
"parentPath",
")",
",",
"$",
"siblingId",
")",
")",
";",
"}",
"else",
"{",
"$",
"new",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"current",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"$",
"siblingId",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"$",
"new",
"[",
"$",
"id",
"]",
"=",
"$",
"children",
";",
"$",
"new",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"new",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"new",
"[",
"$",
"id",
"]",
"=",
"$",
"children",
";",
"}",
"}",
"else",
"{",
"$",
"new",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"current",
"=",
"$",
"new",
";",
"}",
"}"
] | Adds a new item to the hierarchy
@param string[] $parentPath
@param string $id
@param string|null $siblingId The id of nearest neighbor item
@param bool $prepend Determines whether the item should be added before or after
the specified sibling item
If the sibling item is not specified and $prepend is true than
the item is added to the begin of the parent hierarchy
@param array $children The child hierarchy
@throws Exception\LogicException if the operation failed
@SuppressWarnings(PHPMD.CyclomaticComplexity) | [
"Adds",
"a",
"new",
"item",
"to",
"the",
"hierarchy"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/HierarchyCollection.php#L89-L173 |
oroinc/OroLayoutComponent | HierarchyCollection.php | HierarchyCollection.remove | public function remove(array $path)
{
$current = &$this->hierarchy;
$pathLength = count($path);
for ($i = 0; $i < $pathLength; $i++) {
if (!isset($current[$path[$i]])) {
break;
}
if ($i === $pathLength - 1) {
unset($current[$path[$i]]);
break;
}
$current = &$current[$path[$i]];
}
} | php | public function remove(array $path)
{
$current = &$this->hierarchy;
$pathLength = count($path);
for ($i = 0; $i < $pathLength; $i++) {
if (!isset($current[$path[$i]])) {
break;
}
if ($i === $pathLength - 1) {
unset($current[$path[$i]]);
break;
}
$current = &$current[$path[$i]];
}
} | [
"public",
"function",
"remove",
"(",
"array",
"$",
"path",
")",
"{",
"$",
"current",
"=",
"&",
"$",
"this",
"->",
"hierarchy",
";",
"$",
"pathLength",
"=",
"count",
"(",
"$",
"path",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"pathLength",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"current",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"$",
"i",
"===",
"$",
"pathLength",
"-",
"1",
")",
"{",
"unset",
"(",
"$",
"current",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
")",
";",
"break",
";",
"}",
"$",
"current",
"=",
"&",
"$",
"current",
"[",
"$",
"path",
"[",
"$",
"i",
"]",
"]",
";",
"}",
"}"
] | Removes the item from the hierarchy
@param string[] $path | [
"Removes",
"the",
"item",
"from",
"the",
"hierarchy"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/HierarchyCollection.php#L180-L194 |
bpolaszek/simple-dbal | src/Model/Adapter/PDO/Result.php | Result.shouldResetResultset | private function shouldResetResultset(): bool
{
return !empty($this->storage['row']) || !empty($this->storage['value']) || !empty($this->storage['list']) || !empty($this->storage['yield']);
} | php | private function shouldResetResultset(): bool
{
return !empty($this->storage['row']) || !empty($this->storage['value']) || !empty($this->storage['list']) || !empty($this->storage['yield']);
} | [
"private",
"function",
"shouldResetResultset",
"(",
")",
":",
"bool",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"storage",
"[",
"'row'",
"]",
")",
"||",
"!",
"empty",
"(",
"$",
"this",
"->",
"storage",
"[",
"'value'",
"]",
")",
"||",
"!",
"empty",
"(",
"$",
"this",
"->",
"storage",
"[",
"'list'",
"]",
")",
"||",
"!",
"empty",
"(",
"$",
"this",
"->",
"storage",
"[",
"'yield'",
"]",
")",
";",
"}"
] | If asRow(), asList() or asValue() was called earlier, the iterator may be incomplete.
In such case we need to rewind the iterator by executing the statement a second time.
You should avoid to call getIterator() and asRow(), etc. with the same resultset.
@return bool | [
"If",
"asRow",
"()",
"asList",
"()",
"or",
"asValue",
"()",
"was",
"called",
"earlier",
"the",
"iterator",
"may",
"be",
"incomplete",
".",
"In",
"such",
"case",
"we",
"need",
"to",
"rewind",
"the",
"iterator",
"by",
"executing",
"the",
"statement",
"a",
"second",
"time",
".",
"You",
"should",
"avoid",
"to",
"call",
"getIterator",
"()",
"and",
"asRow",
"()",
"etc",
".",
"with",
"the",
"same",
"resultset",
"."
] | train | https://github.com/bpolaszek/simple-dbal/blob/52cb50d326ba5854191814b470f5e84950ebb6e6/src/Model/Adapter/PDO/Result.php#L218-L221 |
frdl/webfan | .ApplicationComposer/lib/frdl/webfan/App.php | App.setAliasMap | public function setAliasMap($aliasing = null){
$this->wrap['aliasing'] = (is_array($aliasing)) ? $aliasing
: array(
'schema' => array(
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.1' => array('name' => 'Autoloader', 'alias' => self::LOADER, 'default' => &$this->LoaderClass,
'abstract_parent' => 'frdl\webfan\Autoloading\SourceLoader',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.2' => array('name' => 'Application Main Controller', 'alias' => 'webfan\App','default' => 'frdl\webfan\App',
'abstract_parent' => 'frdl\webfan\App',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.3' => array('name' => 'cmd parser', 'alias' => 'webfan\Terminal','default' =>'frdl\aSQL\Engines\Terminal\Test',
'abstract_parent' => 'frdl\aSQL\Engines\Terminal\CLI',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.4' => array('name' => 'BootLoader', 'alias' => 'frdl\AC','default' => 'frdl\ApplicationComposer\ApplicationComposerBootstrap',
'abstract_parent' => 'frdl\ApplicationComposer\ApplicationComposerBootstrap',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.5' => array('name' => 'API REST CLient', 'alias' => 'frdl\Client\RESTapi', 'default' => 'webdof\Webfan\APIClient',
'abstract' => null,
'interfaces' => array() ),
),
);
return $this;
} | php | public function setAliasMap($aliasing = null){
$this->wrap['aliasing'] = (is_array($aliasing)) ? $aliasing
: array(
'schema' => array(
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.1' => array('name' => 'Autoloader', 'alias' => self::LOADER, 'default' => &$this->LoaderClass,
'abstract_parent' => 'frdl\webfan\Autoloading\SourceLoader',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.2' => array('name' => 'Application Main Controller', 'alias' => 'webfan\App','default' => 'frdl\webfan\App',
'abstract_parent' => 'frdl\webfan\App',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.3' => array('name' => 'cmd parser', 'alias' => 'webfan\Terminal','default' =>'frdl\aSQL\Engines\Terminal\Test',
'abstract_parent' => 'frdl\aSQL\Engines\Terminal\CLI',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.4' => array('name' => 'BootLoader', 'alias' => 'frdl\AC','default' => 'frdl\ApplicationComposer\ApplicationComposerBootstrap',
'abstract_parent' => 'frdl\ApplicationComposer\ApplicationComposerBootstrap',
'interfaces' => array() ),
'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.5' => array('name' => 'API REST CLient', 'alias' => 'frdl\Client\RESTapi', 'default' => 'webdof\Webfan\APIClient',
'abstract' => null,
'interfaces' => array() ),
),
);
return $this;
} | [
"public",
"function",
"setAliasMap",
"(",
"$",
"aliasing",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"wrap",
"[",
"'aliasing'",
"]",
"=",
"(",
"is_array",
"(",
"$",
"aliasing",
")",
")",
"?",
"$",
"aliasing",
":",
"array",
"(",
"'schema'",
"=>",
"array",
"(",
"'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.1'",
"=>",
"array",
"(",
"'name'",
"=>",
"'Autoloader'",
",",
"'alias'",
"=>",
"self",
"::",
"LOADER",
",",
"'default'",
"=>",
"&",
"$",
"this",
"->",
"LoaderClass",
",",
"'abstract_parent'",
"=>",
"'frdl\\webfan\\Autoloading\\SourceLoader'",
",",
"'interfaces'",
"=>",
"array",
"(",
")",
")",
",",
"'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.2'",
"=>",
"array",
"(",
"'name'",
"=>",
"'Application Main Controller'",
",",
"'alias'",
"=>",
"'webfan\\App'",
",",
"'default'",
"=>",
"'frdl\\webfan\\App'",
",",
"'abstract_parent'",
"=>",
"'frdl\\webfan\\App'",
",",
"'interfaces'",
"=>",
"array",
"(",
")",
")",
",",
"'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.3'",
"=>",
"array",
"(",
"'name'",
"=>",
"'cmd parser'",
",",
"'alias'",
"=>",
"'webfan\\Terminal'",
",",
"'default'",
"=>",
"'frdl\\aSQL\\Engines\\Terminal\\Test'",
",",
"'abstract_parent'",
"=>",
"'frdl\\aSQL\\Engines\\Terminal\\CLI'",
",",
"'interfaces'",
"=>",
"array",
"(",
")",
")",
",",
"'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.4'",
"=>",
"array",
"(",
"'name'",
"=>",
"'BootLoader'",
",",
"'alias'",
"=>",
"'frdl\\AC'",
",",
"'default'",
"=>",
"'frdl\\ApplicationComposer\\ApplicationComposerBootstrap'",
",",
"'abstract_parent'",
"=>",
"'frdl\\ApplicationComposer\\ApplicationComposerBootstrap'",
",",
"'interfaces'",
"=>",
"array",
"(",
")",
")",
",",
"'1.3.6.1.4.1.37553.8.1.8.8.5.65.8.1.5'",
"=>",
"array",
"(",
"'name'",
"=>",
"'API REST CLient'",
",",
"'alias'",
"=>",
"'frdl\\Client\\RESTapi'",
",",
"'default'",
"=>",
"'webdof\\Webfan\\APIClient'",
",",
"'abstract'",
"=>",
"null",
",",
"'interfaces'",
"=>",
"array",
"(",
")",
")",
",",
")",
",",
")",
";",
"return",
"$",
"this",
";",
"}"
] | todo : compinent registry | [
"todo",
":",
"compinent",
"registry"
] | train | https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/webfan/App.php#L177-L200 |
frdl/webfan | .ApplicationComposer/lib/frdl/webfan/App.php | App.stream_open | public function stream_open($url, $mode, $options = STREAM_REPORT_ERRORS, &$opened_path = null){
$u = parse_url($url);
$c = explode('.',$u['host']);
$c = array_reverse($c);
$this->Controller = null;
$cN = (isset(self::God()->wrappers[$u['scheme']]['tld'][$c[0]]))
?self::God()->wrappers[$u['scheme']]['tld'][$c[0]]
:false;
if(false!==$cN){
try{
$this->Controller = new $cN;
}catch(Exception $e){
trigger_error($e->getMessage(), E_USER_NOTICE);
return false;
}
}else{
trigger_error('Stream handler for '.$url.' not found.', E_USER_NOTICE);
return false;
}
return call_user_func(array($this->Controller, __FUNCTION__),$url, $mode, $options );
} | php | public function stream_open($url, $mode, $options = STREAM_REPORT_ERRORS, &$opened_path = null){
$u = parse_url($url);
$c = explode('.',$u['host']);
$c = array_reverse($c);
$this->Controller = null;
$cN = (isset(self::God()->wrappers[$u['scheme']]['tld'][$c[0]]))
?self::God()->wrappers[$u['scheme']]['tld'][$c[0]]
:false;
if(false!==$cN){
try{
$this->Controller = new $cN;
}catch(Exception $e){
trigger_error($e->getMessage(), E_USER_NOTICE);
return false;
}
}else{
trigger_error('Stream handler for '.$url.' not found.', E_USER_NOTICE);
return false;
}
return call_user_func(array($this->Controller, __FUNCTION__),$url, $mode, $options );
} | [
"public",
"function",
"stream_open",
"(",
"$",
"url",
",",
"$",
"mode",
",",
"$",
"options",
"=",
"STREAM_REPORT_ERRORS",
",",
"&",
"$",
"opened_path",
"=",
"null",
")",
"{",
"$",
"u",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"c",
"=",
"explode",
"(",
"'.'",
",",
"$",
"u",
"[",
"'host'",
"]",
")",
";",
"$",
"c",
"=",
"array_reverse",
"(",
"$",
"c",
")",
";",
"$",
"this",
"->",
"Controller",
"=",
"null",
";",
"$",
"cN",
"=",
"(",
"isset",
"(",
"self",
"::",
"God",
"(",
")",
"->",
"wrappers",
"[",
"$",
"u",
"[",
"'scheme'",
"]",
"]",
"[",
"'tld'",
"]",
"[",
"$",
"c",
"[",
"0",
"]",
"]",
")",
")",
"?",
"self",
"::",
"God",
"(",
")",
"->",
"wrappers",
"[",
"$",
"u",
"[",
"'scheme'",
"]",
"]",
"[",
"'tld'",
"]",
"[",
"$",
"c",
"[",
"0",
"]",
"]",
":",
"false",
";",
"if",
"(",
"false",
"!==",
"$",
"cN",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"Controller",
"=",
"new",
"$",
"cN",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"E_USER_NOTICE",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"trigger_error",
"(",
"'Stream handler for '",
".",
"$",
"url",
".",
"' not found.'",
",",
"E_USER_NOTICE",
")",
";",
"return",
"false",
";",
"}",
"return",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"Controller",
",",
"__FUNCTION__",
")",
",",
"$",
"url",
",",
"$",
"mode",
",",
"$",
"options",
")",
";",
"}"
] | Streaming Methods | [
"Streaming",
"Methods"
] | train | https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/webfan/App.php#L441-L464 |
jnaxo/country-codes | database/seeds/ChileanAdministrativeAreasSeeder.php | ChileanAdministrativeAreasSeeder.run | public function run()
{
DB::table('ctrystore_administrative_areas')->delete();
$today = date('Y-m-d H:i:s');
$data = [
['name' => 'Tarapacá', 'code' => 'TA', 'tag' => 'I'],
['name' => 'Antofagasta', 'code' => 'AN', 'tag' => 'II'],
['name' => 'Atacama', 'code' => 'AT', 'tag' => 'III'],
['name' => 'Coquimbo', 'code' => 'CO', 'tag' => 'IV'],
['name' => 'Valparaíso', 'code' => 'VS', 'tag' => 'V'],
[
'name' => "Libertador Gral. Bernardo O'higgins",
'code' => 'LI',
'tag' => 'VI'
],
['name' => 'Maule', 'code' => 'ML', 'tag' => 'VII'],
['name' => 'BioBio', 'code' => 'BI', 'tag' => 'VIII'],
['name' => 'Araucania', 'code' => 'AR', 'tag' => 'IX'],
['name' => 'Los Lagos', 'code' => 'LL', 'tag' => 'X'],
[
'name' => 'Aysén del Gral. Carlos Ibáñez del Campo',
'code' => 'AI',
'tag' => 'XI'
],
['name' => 'Magallanes', 'code' => 'MA', 'tag' => 'XII'],
['name' => 'Metropolitana', 'code' => 'RM', 'tag' => 'XIII'],
['name' => 'Los Ríos', 'code' => 'LR', 'tag' => 'XIV'],
['name' => 'Arica y Parinacota', 'code' => 'AP', 'tag' => 'XV'],
['name' => 'Ñuble', 'code' => '', 'tag' => 'XVI']
];
foreach ($data as $i => $ad) {
DB::table('ctrystore_administrative_areas')->insert([
'id' => $i + 1,
'country_id' => 152,
'name' => $ad['name'],
'code' => $ad['code'],
'tag' => $ad['tag'],
'admin_division_id' => 1,
'created_at' => $today,
'updated_at' => $today,
]);
}
} | php | public function run()
{
DB::table('ctrystore_administrative_areas')->delete();
$today = date('Y-m-d H:i:s');
$data = [
['name' => 'Tarapacá', 'code' => 'TA', 'tag' => 'I'],
['name' => 'Antofagasta', 'code' => 'AN', 'tag' => 'II'],
['name' => 'Atacama', 'code' => 'AT', 'tag' => 'III'],
['name' => 'Coquimbo', 'code' => 'CO', 'tag' => 'IV'],
['name' => 'Valparaíso', 'code' => 'VS', 'tag' => 'V'],
[
'name' => "Libertador Gral. Bernardo O'higgins",
'code' => 'LI',
'tag' => 'VI'
],
['name' => 'Maule', 'code' => 'ML', 'tag' => 'VII'],
['name' => 'BioBio', 'code' => 'BI', 'tag' => 'VIII'],
['name' => 'Araucania', 'code' => 'AR', 'tag' => 'IX'],
['name' => 'Los Lagos', 'code' => 'LL', 'tag' => 'X'],
[
'name' => 'Aysén del Gral. Carlos Ibáñez del Campo',
'code' => 'AI',
'tag' => 'XI'
],
['name' => 'Magallanes', 'code' => 'MA', 'tag' => 'XII'],
['name' => 'Metropolitana', 'code' => 'RM', 'tag' => 'XIII'],
['name' => 'Los Ríos', 'code' => 'LR', 'tag' => 'XIV'],
['name' => 'Arica y Parinacota', 'code' => 'AP', 'tag' => 'XV'],
['name' => 'Ñuble', 'code' => '', 'tag' => 'XVI']
];
foreach ($data as $i => $ad) {
DB::table('ctrystore_administrative_areas')->insert([
'id' => $i + 1,
'country_id' => 152,
'name' => $ad['name'],
'code' => $ad['code'],
'tag' => $ad['tag'],
'admin_division_id' => 1,
'created_at' => $today,
'updated_at' => $today,
]);
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"DB",
"::",
"table",
"(",
"'ctrystore_administrative_areas'",
")",
"->",
"delete",
"(",
")",
";",
"$",
"today",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"data",
"=",
"[",
"[",
"'name'",
"=>",
"'Tarapacá',",
" ",
"code' ",
"> ",
"TA',",
" ",
"tag' ",
"> ",
"I']",
",",
"",
"[",
"'name'",
"=>",
"'Antofagasta'",
",",
"'code'",
"=>",
"'AN'",
",",
"'tag'",
"=>",
"'II'",
"]",
",",
"[",
"'name'",
"=>",
"'Atacama'",
",",
"'code'",
"=>",
"'AT'",
",",
"'tag'",
"=>",
"'III'",
"]",
",",
"[",
"'name'",
"=>",
"'Coquimbo'",
",",
"'code'",
"=>",
"'CO'",
",",
"'tag'",
"=>",
"'IV'",
"]",
",",
"[",
"'name'",
"=>",
"'Valparaíso',",
" ",
"code' ",
"> ",
"VS',",
" ",
"tag' ",
"> ",
"V']",
",",
"",
"[",
"'name'",
"=>",
"\"Libertador Gral. Bernardo O'higgins\"",
",",
"'code'",
"=>",
"'LI'",
",",
"'tag'",
"=>",
"'VI'",
"]",
",",
"[",
"'name'",
"=>",
"'Maule'",
",",
"'code'",
"=>",
"'ML'",
",",
"'tag'",
"=>",
"'VII'",
"]",
",",
"[",
"'name'",
"=>",
"'BioBio'",
",",
"'code'",
"=>",
"'BI'",
",",
"'tag'",
"=>",
"'VIII'",
"]",
",",
"[",
"'name'",
"=>",
"'Araucania'",
",",
"'code'",
"=>",
"'AR'",
",",
"'tag'",
"=>",
"'IX'",
"]",
",",
"[",
"'name'",
"=>",
"'Los Lagos'",
",",
"'code'",
"=>",
"'LL'",
",",
"'tag'",
"=>",
"'X'",
"]",
",",
"[",
"'name'",
"=>",
"'Aysén del Gral. Carlos Ibáñez del Campo',",
"",
"'code'",
"=>",
"'AI'",
",",
"'tag'",
"=>",
"'XI'",
"]",
",",
"[",
"'name'",
"=>",
"'Magallanes'",
",",
"'code'",
"=>",
"'MA'",
",",
"'tag'",
"=>",
"'XII'",
"]",
",",
"[",
"'name'",
"=>",
"'Metropolitana'",
",",
"'code'",
"=>",
"'RM'",
",",
"'tag'",
"=>",
"'XIII'",
"]",
",",
"[",
"'name'",
"=>",
"'Los Ríos',",
" ",
"code' ",
"> ",
"LR',",
" ",
"tag' ",
"> ",
"XIV']",
",",
"",
"[",
"'name'",
"=>",
"'Arica y Parinacota'",
",",
"'code'",
"=>",
"'AP'",
",",
"'tag'",
"=>",
"'XV'",
"]",
",",
"[",
"'name'",
"=>",
"'Ñuble',",
" ",
"code' ",
"> ",
"',",
" ",
"tag' ",
"> ",
"XVI']",
"",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"i",
"=>",
"$",
"ad",
")",
"{",
"DB",
"::",
"table",
"(",
"'ctrystore_administrative_areas'",
")",
"->",
"insert",
"(",
"[",
"'id'",
"=>",
"$",
"i",
"+",
"1",
",",
"'country_id'",
"=>",
"152",
",",
"'name'",
"=>",
"$",
"ad",
"[",
"'name'",
"]",
",",
"'code'",
"=>",
"$",
"ad",
"[",
"'code'",
"]",
",",
"'tag'",
"=>",
"$",
"ad",
"[",
"'tag'",
"]",
",",
"'admin_division_id'",
"=>",
"1",
",",
"'created_at'",
"=>",
"$",
"today",
",",
"'updated_at'",
"=>",
"$",
"today",
",",
"]",
")",
";",
"}",
"}"
] | Run the database seeds. | [
"Run",
"the",
"database",
"seeds",
"."
] | train | https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/database/seeds/ChileanAdministrativeAreasSeeder.php#L10-L54 |
SporkCode/Spork | src/View/Helper/Dojo.php | Dojo.createService | public function createService(ServiceLocatorInterface $viewHelperManager)
{
$serviceLocator = $viewHelperManager->getServiceLocator();
$config = $serviceLocator->has('config') ? $serviceLocator->get('config') : array();
if (isset($config['dojo'])) {
$this->config($config['dojo']);
}
$application = $serviceLocator->get('application');
$debug = $application->getRequest()->getQuery('debug');
if ($debug !== null) {
$this->setDebug($debug == 'true');
}
return $this;
} | php | public function createService(ServiceLocatorInterface $viewHelperManager)
{
$serviceLocator = $viewHelperManager->getServiceLocator();
$config = $serviceLocator->has('config') ? $serviceLocator->get('config') : array();
if (isset($config['dojo'])) {
$this->config($config['dojo']);
}
$application = $serviceLocator->get('application');
$debug = $application->getRequest()->getQuery('debug');
if ($debug !== null) {
$this->setDebug($debug == 'true');
}
return $this;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"viewHelperManager",
")",
"{",
"$",
"serviceLocator",
"=",
"$",
"viewHelperManager",
"->",
"getServiceLocator",
"(",
")",
";",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"has",
"(",
"'config'",
")",
"?",
"$",
"serviceLocator",
"->",
"get",
"(",
"'config'",
")",
":",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'dojo'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"(",
"$",
"config",
"[",
"'dojo'",
"]",
")",
";",
"}",
"$",
"application",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'application'",
")",
";",
"$",
"debug",
"=",
"$",
"application",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
"'debug'",
")",
";",
"if",
"(",
"$",
"debug",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setDebug",
"(",
"$",
"debug",
"==",
"'true'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Create and configure service
@see \Zend\ServiceManager\FactoryInterface::createService()
@param ServiceLocatorInterface $viewHelperManager
@return \Spork\View\Helper\Dojo | [
"Create",
"and",
"configure",
"service"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L118-L133 |
SporkCode/Spork | src/View/Helper/Dojo.php | Dojo.setDebug | public function setDebug($flag = true)
{
$this->debug = $this->getSession()->debug = (bool) $flag;
if (true == $this->debug) {
if (isset($this->options['debugOptions'])
&& is_array($this->options['debugOptions'])) {
$this->initializeOptions($this->options['debugOptions']);
}
} else {
$this->initializeOptions($this->options);
}
} | php | public function setDebug($flag = true)
{
$this->debug = $this->getSession()->debug = (bool) $flag;
if (true == $this->debug) {
if (isset($this->options['debugOptions'])
&& is_array($this->options['debugOptions'])) {
$this->initializeOptions($this->options['debugOptions']);
}
} else {
$this->initializeOptions($this->options);
}
} | [
"public",
"function",
"setDebug",
"(",
"$",
"flag",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"debug",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"debug",
"=",
"(",
"bool",
")",
"$",
"flag",
";",
"if",
"(",
"true",
"==",
"$",
"this",
"->",
"debug",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'debugOptions'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"options",
"[",
"'debugOptions'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"initializeOptions",
"(",
"$",
"this",
"->",
"options",
"[",
"'debugOptions'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"initializeOptions",
"(",
"$",
"this",
"->",
"options",
")",
";",
"}",
"}"
] | Set debug flag
@param string $flag | [
"Set",
"debug",
"flag"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L170-L181 |
SporkCode/Spork | src/View/Helper/Dojo.php | Dojo.setPackages | public function setPackages(array $packages)
{
foreach ($packages as $name => $location) {
if (is_array($location)) {
if (array_key_exists('name', $location)
&& array_key_exists('location', $location)) {
$name = $location['name'];
$location = $location['location'];
} else {
list($name, $location) = $location;
}
}
$this->addPackage($name, $location);
}
} | php | public function setPackages(array $packages)
{
foreach ($packages as $name => $location) {
if (is_array($location)) {
if (array_key_exists('name', $location)
&& array_key_exists('location', $location)) {
$name = $location['name'];
$location = $location['location'];
} else {
list($name, $location) = $location;
}
}
$this->addPackage($name, $location);
}
} | [
"public",
"function",
"setPackages",
"(",
"array",
"$",
"packages",
")",
"{",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"name",
"=>",
"$",
"location",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"location",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'name'",
",",
"$",
"location",
")",
"&&",
"array_key_exists",
"(",
"'location'",
",",
"$",
"location",
")",
")",
"{",
"$",
"name",
"=",
"$",
"location",
"[",
"'name'",
"]",
";",
"$",
"location",
"=",
"$",
"location",
"[",
"'location'",
"]",
";",
"}",
"else",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"location",
")",
"=",
"$",
"location",
";",
"}",
"}",
"$",
"this",
"->",
"addPackage",
"(",
"$",
"name",
",",
"$",
"location",
")",
";",
"}",
"}"
] | Set package
@param array $packages | [
"Set",
"package"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L244-L258 |
SporkCode/Spork | src/View/Helper/Dojo.php | Dojo.config | public function config(array $options)
{
$this->options = $options;
$this->initializeOptions($options);
if ($this->getSession()->debug == true) {
$this->setDebug(true);
}
} | php | public function config(array $options)
{
$this->options = $options;
$this->initializeOptions($options);
if ($this->getSession()->debug == true) {
$this->setDebug(true);
}
} | [
"public",
"function",
"config",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"options",
";",
"$",
"this",
"->",
"initializeOptions",
"(",
"$",
"options",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"debug",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"setDebug",
"(",
"true",
")",
";",
"}",
"}"
] | Configure object
@param array $options | [
"Configure",
"object"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L316-L325 |
SporkCode/Spork | src/View/Helper/Dojo.php | Dojo.initialize | public function initialize()
{
if (true == $this->initialized) {
return;
}
$this->initialized = true;
if ($this->isEnabled()) {
$headScript = $this->getView()->plugin('headScript');
$headScript->prependFile($this->src);
$options = array();
foreach (array('async', 'parseOnLoad') as $property) {
if (null !== $this->$property) {
$options[$property] = $this->$property;
}
}
if (!empty($this->packages)) {
$options['packages'] = array_values($this->packages);
}
if (!empty($options)) {
$headScript->prependScript("dojoConfig=" . json_encode($options) . ";");
}
if (!empty($this->modules)) {
$require = 'require(["' . implode('", "', $this->modules) . '"]);';
$headScript->appendScript($require);
}
}
} | php | public function initialize()
{
if (true == $this->initialized) {
return;
}
$this->initialized = true;
if ($this->isEnabled()) {
$headScript = $this->getView()->plugin('headScript');
$headScript->prependFile($this->src);
$options = array();
foreach (array('async', 'parseOnLoad') as $property) {
if (null !== $this->$property) {
$options[$property] = $this->$property;
}
}
if (!empty($this->packages)) {
$options['packages'] = array_values($this->packages);
}
if (!empty($options)) {
$headScript->prependScript("dojoConfig=" . json_encode($options) . ";");
}
if (!empty($this->modules)) {
$require = 'require(["' . implode('", "', $this->modules) . '"]);';
$headScript->appendScript($require);
}
}
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"true",
"==",
"$",
"this",
"->",
"initialized",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"initialized",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"$",
"headScript",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"plugin",
"(",
"'headScript'",
")",
";",
"$",
"headScript",
"->",
"prependFile",
"(",
"$",
"this",
"->",
"src",
")",
";",
"$",
"options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array",
"(",
"'async'",
",",
"'parseOnLoad'",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"$",
"property",
")",
"{",
"$",
"options",
"[",
"$",
"property",
"]",
"=",
"$",
"this",
"->",
"$",
"property",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"packages",
")",
")",
"{",
"$",
"options",
"[",
"'packages'",
"]",
"=",
"array_values",
"(",
"$",
"this",
"->",
"packages",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"headScript",
"->",
"prependScript",
"(",
"\"dojoConfig=\"",
".",
"json_encode",
"(",
"$",
"options",
")",
".",
"\";\"",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"modules",
")",
")",
"{",
"$",
"require",
"=",
"'require([\"'",
".",
"implode",
"(",
"'\", \"'",
",",
"$",
"this",
"->",
"modules",
")",
".",
"'\"]);'",
";",
"$",
"headScript",
"->",
"appendScript",
"(",
"$",
"require",
")",
";",
"}",
"}",
"}"
] | Add Dojo configuration to HeadScript. Should only be called once. | [
"Add",
"Dojo",
"configuration",
"to",
"HeadScript",
".",
"Should",
"only",
"be",
"called",
"once",
"."
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L330-L360 |
SporkCode/Spork | src/View/Helper/Dojo.php | Dojo.initializeOptions | protected function initializeOptions(array $options)
{
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
call_user_func(array($this, $method), $value);
}
}
} | php | protected function initializeOptions(array $options)
{
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
call_user_func(array($this, $method), $value);
}
}
} | [
"protected",
"function",
"initializeOptions",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
")",
",",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | Initialize options
@param array $options | [
"Initialize",
"options"
] | train | https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/View/Helper/Dojo.php#L377-L385 |
jasny/controller | src/Controller/View/PHP.php | PHP.getViewer | public function getViewer()
{
if (!isset($this->viewer)) {
$this->viewer = $this->createPHPView(['path' => $this->getViewPath()]);
}
return $this->viewer;
} | php | public function getViewer()
{
if (!isset($this->viewer)) {
$this->viewer = $this->createPHPView(['path' => $this->getViewPath()]);
}
return $this->viewer;
} | [
"public",
"function",
"getViewer",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"viewer",
")",
")",
"{",
"$",
"this",
"->",
"viewer",
"=",
"$",
"this",
"->",
"createPHPView",
"(",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"getViewPath",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"viewer",
";",
"}"
] | Get the template engine abstraction
@return PHPView | [
"Get",
"the",
"template",
"engine",
"abstraction"
] | train | https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/View/PHP.php#L20-L27 |
AbuseIO/parser-copyrightcompliance | src/Copyrightcompliance.php | Copyrightcompliance.parse | public function parse()
{
// ACNS: Automated Copyright Notice System
$foundAcnsFile = false;
foreach ($this->parsedMail->getAttachments() as $attachment) {
// Only use the Copyrightcompliance formatted reports, skip all others
if (preg_match(config("{$this->configBase}.parser.report_file"), $attachment->filename) &&
$attachment->contentType == 'application/xml'
) {
$foundAcnsFile = true;
$xmlReport = $attachment->getContent();
$this->saveIncidents($xmlReport);
}
}
// Sadly their report is not consistantly an attachment and might end up
// in the body so we need to fallback to a body XML search if there was
// nothing found in attachments.
if ($foundAcnsFile === false) {
if (preg_match(
'/- - ---Start ACNS XML\n(.*)- - ---End ACNS XML/si',
$this->parsedMail->getMessageBody(),
$match
)
) {
$xmlReport = trim($match[1]);
$xmlReport = preg_replace("/&(?!#?[a-z0-9]+;)/", "&", $xmlReport);
$this->saveIncident($xmlReport);
} elseif (preg_match(
"/(<\?xml[^>]*>.*?<\/Infringement>)/is",
$this->parsedMail->getMessageBody(),
$match
)
) {
$xmlReport = trim($match[1]);
$xmlReport = preg_replace("/&(?!#?[a-z0-9]+;)/", "&", $xmlReport);
$this->saveIncident($xmlReport);
} else {
$this->warningCount++;
}
}
return $this->success();
} | php | public function parse()
{
// ACNS: Automated Copyright Notice System
$foundAcnsFile = false;
foreach ($this->parsedMail->getAttachments() as $attachment) {
// Only use the Copyrightcompliance formatted reports, skip all others
if (preg_match(config("{$this->configBase}.parser.report_file"), $attachment->filename) &&
$attachment->contentType == 'application/xml'
) {
$foundAcnsFile = true;
$xmlReport = $attachment->getContent();
$this->saveIncidents($xmlReport);
}
}
// Sadly their report is not consistantly an attachment and might end up
// in the body so we need to fallback to a body XML search if there was
// nothing found in attachments.
if ($foundAcnsFile === false) {
if (preg_match(
'/- - ---Start ACNS XML\n(.*)- - ---End ACNS XML/si',
$this->parsedMail->getMessageBody(),
$match
)
) {
$xmlReport = trim($match[1]);
$xmlReport = preg_replace("/&(?!#?[a-z0-9]+;)/", "&", $xmlReport);
$this->saveIncident($xmlReport);
} elseif (preg_match(
"/(<\?xml[^>]*>.*?<\/Infringement>)/is",
$this->parsedMail->getMessageBody(),
$match
)
) {
$xmlReport = trim($match[1]);
$xmlReport = preg_replace("/&(?!#?[a-z0-9]+;)/", "&", $xmlReport);
$this->saveIncident($xmlReport);
} else {
$this->warningCount++;
}
}
return $this->success();
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"// ACNS: Automated Copyright Notice System",
"$",
"foundAcnsFile",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"parsedMail",
"->",
"getAttachments",
"(",
")",
"as",
"$",
"attachment",
")",
"{",
"// Only use the Copyrightcompliance formatted reports, skip all others",
"if",
"(",
"preg_match",
"(",
"config",
"(",
"\"{$this->configBase}.parser.report_file\"",
")",
",",
"$",
"attachment",
"->",
"filename",
")",
"&&",
"$",
"attachment",
"->",
"contentType",
"==",
"'application/xml'",
")",
"{",
"$",
"foundAcnsFile",
"=",
"true",
";",
"$",
"xmlReport",
"=",
"$",
"attachment",
"->",
"getContent",
"(",
")",
";",
"$",
"this",
"->",
"saveIncidents",
"(",
"$",
"xmlReport",
")",
";",
"}",
"}",
"// Sadly their report is not consistantly an attachment and might end up",
"// in the body so we need to fallback to a body XML search if there was",
"// nothing found in attachments.",
"if",
"(",
"$",
"foundAcnsFile",
"===",
"false",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/- - ---Start ACNS XML\\n(.*)- - ---End ACNS XML/si'",
",",
"$",
"this",
"->",
"parsedMail",
"->",
"getMessageBody",
"(",
")",
",",
"$",
"match",
")",
")",
"{",
"$",
"xmlReport",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"xmlReport",
"=",
"preg_replace",
"(",
"\"/&(?!#?[a-z0-9]+;)/\"",
",",
"\"&\"",
",",
"$",
"xmlReport",
")",
";",
"$",
"this",
"->",
"saveIncident",
"(",
"$",
"xmlReport",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"\"/(<\\?xml[^>]*>.*?<\\/Infringement>)/is\"",
",",
"$",
"this",
"->",
"parsedMail",
"->",
"getMessageBody",
"(",
")",
",",
"$",
"match",
")",
")",
"{",
"$",
"xmlReport",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"xmlReport",
"=",
"preg_replace",
"(",
"\"/&(?!#?[a-z0-9]+;)/\"",
",",
"\"&\"",
",",
"$",
"xmlReport",
")",
";",
"$",
"this",
"->",
"saveIncident",
"(",
"$",
"xmlReport",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warningCount",
"++",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"success",
"(",
")",
";",
"}"
] | Parse attachments
@return array Returns array with failed or success data
(See parser-common/src/Parser.php) for more info. | [
"Parse",
"attachments"
] | train | https://github.com/AbuseIO/parser-copyrightcompliance/blob/1f8ef247ae3a1f8e5dfc0f7dd97bba63a76b606a/src/Copyrightcompliance.php#L30-L81 |
mothership-ec/composer | src/Composer/Downloader/ArchiveDownloader.php | ArchiveDownloader.processUrl | protected function processUrl(PackageInterface $package, $url)
{
if ($package->getDistReference() && strpos($url, 'github.com')) {
if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
// update legacy github archives to API calls with the proper reference
$url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference();
} elseif ($package->getDistReference() && preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
// update current github web archives to API calls with the proper reference
$url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference();
} elseif ($package->getDistReference() && preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
// update api archives to the proper reference
$url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference();
}
}
if (!extension_loaded('openssl') && (0 === strpos($url, 'https:') || 0 === strpos($url, 'http://github.com'))) {
throw new \RuntimeException('You must enable the openssl extension to download files via https');
}
return parent::processUrl($package, $url);
} | php | protected function processUrl(PackageInterface $package, $url)
{
if ($package->getDistReference() && strpos($url, 'github.com')) {
if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
// update legacy github archives to API calls with the proper reference
$url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference();
} elseif ($package->getDistReference() && preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
// update current github web archives to API calls with the proper reference
$url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference();
} elseif ($package->getDistReference() && preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
// update api archives to the proper reference
$url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $package->getDistReference();
}
}
if (!extension_loaded('openssl') && (0 === strpos($url, 'https:') || 0 === strpos($url, 'http://github.com'))) {
throw new \RuntimeException('You must enable the openssl extension to download files via https');
}
return parent::processUrl($package, $url);
} | [
"protected",
"function",
"processUrl",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"package",
"->",
"getDistReference",
"(",
")",
"&&",
"strpos",
"(",
"$",
"url",
",",
"'github.com'",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'{^https?://(?:www\\.)?github\\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i'",
",",
"$",
"url",
",",
"$",
"match",
")",
")",
"{",
"// update legacy github archives to API calls with the proper reference",
"$",
"url",
"=",
"'https://api.github.com/repos/'",
".",
"$",
"match",
"[",
"1",
"]",
".",
"'/'",
".",
"$",
"match",
"[",
"2",
"]",
".",
"'/'",
".",
"$",
"match",
"[",
"3",
"]",
".",
"'ball/'",
".",
"$",
"package",
"->",
"getDistReference",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"package",
"->",
"getDistReference",
"(",
")",
"&&",
"preg_match",
"(",
"'{^https?://(?:www\\.)?github\\.com/([^/]+)/([^/]+)/archive/.+\\.(zip|tar)(?:\\.gz)?$}i'",
",",
"$",
"url",
",",
"$",
"match",
")",
")",
"{",
"// update current github web archives to API calls with the proper reference",
"$",
"url",
"=",
"'https://api.github.com/repos/'",
".",
"$",
"match",
"[",
"1",
"]",
".",
"'/'",
".",
"$",
"match",
"[",
"2",
"]",
".",
"'/'",
".",
"$",
"match",
"[",
"3",
"]",
".",
"'ball/'",
".",
"$",
"package",
"->",
"getDistReference",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"package",
"->",
"getDistReference",
"(",
")",
"&&",
"preg_match",
"(",
"'{^https?://api\\.github\\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i'",
",",
"$",
"url",
",",
"$",
"match",
")",
")",
"{",
"// update api archives to the proper reference",
"$",
"url",
"=",
"'https://api.github.com/repos/'",
".",
"$",
"match",
"[",
"1",
"]",
".",
"'/'",
".",
"$",
"match",
"[",
"2",
"]",
".",
"'/'",
".",
"$",
"match",
"[",
"3",
"]",
".",
"'ball/'",
".",
"$",
"package",
"->",
"getDistReference",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"extension_loaded",
"(",
"'openssl'",
")",
"&&",
"(",
"0",
"===",
"strpos",
"(",
"$",
"url",
",",
"'https:'",
")",
"||",
"0",
"===",
"strpos",
"(",
"$",
"url",
",",
"'http://github.com'",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You must enable the openssl extension to download files via https'",
")",
";",
"}",
"return",
"parent",
"::",
"processUrl",
"(",
"$",
"package",
",",
"$",
"url",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/ArchiveDownloader.php#L105-L125 |
mothership-ec/composer | src/Composer/Downloader/ArchiveDownloader.php | ArchiveDownloader.getFolderContent | private function getFolderContent($dir)
{
$finder = Finder::create()
->ignoreVCS(false)
->ignoreDotFiles(false)
->depth(0)
->in($dir);
return iterator_to_array($finder);
} | php | private function getFolderContent($dir)
{
$finder = Finder::create()
->ignoreVCS(false)
->ignoreDotFiles(false)
->depth(0)
->in($dir);
return iterator_to_array($finder);
} | [
"private",
"function",
"getFolderContent",
"(",
"$",
"dir",
")",
"{",
"$",
"finder",
"=",
"Finder",
"::",
"create",
"(",
")",
"->",
"ignoreVCS",
"(",
"false",
")",
"->",
"ignoreDotFiles",
"(",
"false",
")",
"->",
"depth",
"(",
"0",
")",
"->",
"in",
"(",
"$",
"dir",
")",
";",
"return",
"iterator_to_array",
"(",
"$",
"finder",
")",
";",
"}"
] | Returns the folder content, excluding dotfiles
@param string $dir Directory
@return \SplFileInfo[] | [
"Returns",
"the",
"folder",
"content",
"excluding",
"dotfiles"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/ArchiveDownloader.php#L143-L152 |
99designs/ergo-http | src/NullRequest.php | NullRequest.copy | public function copy($headers = false, $body = false, $url = false, $method = false)
{
return clone $this;
} | php | public function copy($headers = false, $body = false, $url = false, $method = false)
{
return clone $this;
} | [
"public",
"function",
"copy",
"(",
"$",
"headers",
"=",
"false",
",",
"$",
"body",
"=",
"false",
",",
"$",
"url",
"=",
"false",
",",
"$",
"method",
"=",
"false",
")",
"{",
"return",
"clone",
"$",
"this",
";",
"}"
] | Creates a new Request object with the parameters specified, or uses
the current object's parameters
@return object | [
"Creates",
"a",
"new",
"Request",
"object",
"with",
"the",
"parameters",
"specified",
"or",
"uses",
"the",
"current",
"object",
"s",
"parameters"
] | train | https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/NullRequest.php#L70-L73 |
HaaseIT/HCSF | src/Controller/CLI/Itemdata.php | Itemdata.removeDataWhere | public function removeDataWhere($field, $needle, $fieldtoremove)
{
foreach ($this->items as $key => $item) {
if (!empty($item['itm_data']->$field)) {
if ($needle) {
if ($item['itm_data']->$field == $needle && isset($item['itm_data']->$fieldtoremove)) {
unset($this->items[$key]['itm_data']->$fieldtoremove);
$this->itemschanged[$key] = true;
}
} else {
if (isset($item['itm_data']->$fieldtoremove)) {
unset($this->items[$key]['itm_data']->$fieldtoremove);
$this->itemschanged[$key] = true;
}
}
}
}
} | php | public function removeDataWhere($field, $needle, $fieldtoremove)
{
foreach ($this->items as $key => $item) {
if (!empty($item['itm_data']->$field)) {
if ($needle) {
if ($item['itm_data']->$field == $needle && isset($item['itm_data']->$fieldtoremove)) {
unset($this->items[$key]['itm_data']->$fieldtoremove);
$this->itemschanged[$key] = true;
}
} else {
if (isset($item['itm_data']->$fieldtoremove)) {
unset($this->items[$key]['itm_data']->$fieldtoremove);
$this->itemschanged[$key] = true;
}
}
}
}
} | [
"public",
"function",
"removeDataWhere",
"(",
"$",
"field",
",",
"$",
"needle",
",",
"$",
"fieldtoremove",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'itm_data'",
"]",
"->",
"$",
"field",
")",
")",
"{",
"if",
"(",
"$",
"needle",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"'itm_data'",
"]",
"->",
"$",
"field",
"==",
"$",
"needle",
"&&",
"isset",
"(",
"$",
"item",
"[",
"'itm_data'",
"]",
"->",
"$",
"fieldtoremove",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
"[",
"'itm_data'",
"]",
"->",
"$",
"fieldtoremove",
")",
";",
"$",
"this",
"->",
"itemschanged",
"[",
"$",
"key",
"]",
"=",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'itm_data'",
"]",
"->",
"$",
"fieldtoremove",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
"[",
"'itm_data'",
"]",
"->",
"$",
"fieldtoremove",
")",
";",
"$",
"this",
"->",
"itemschanged",
"[",
"$",
"key",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"}"
] | if $needls is set to false, existence of the field is enough to trigger removal | [
"if",
"$needls",
"is",
"set",
"to",
"false",
"existence",
"of",
"the",
"field",
"is",
"enough",
"to",
"trigger",
"removal"
] | train | https://github.com/HaaseIT/HCSF/blob/8c8f33e8230f1d8b225a9b92707a951565fce25d/src/Controller/CLI/Itemdata.php#L97-L114 |
inhere/php-librarys | src/Helpers/Sys.php | Sys.runCommand | public static function runCommand($command, $returnStatus = true)
{
$return_var = 1;
//system
if (\function_exists('system')) {
ob_start();
system($command, $return_var);
$output = ob_get_contents();
ob_end_clean();
// passthru
} elseif (\function_exists('passthru')) {
ob_start();
passthru($command, $return_var);
$output = ob_get_contents();
ob_end_clean();
//exec
} else {
if (\function_exists('exec')) {
exec($command, $output, $return_var);
$output = implode("\n", $output);
//shell_exec
} else {
if (\function_exists('shell_exec')) {
$output = shell_exec($command);
} else {
$output = 'Command execution not possible on this system';
$return_var = 0;
}
}
}
if ($returnStatus) {
return ['output' => trim($output), 'status' => $return_var];
}
return trim($output);
} | php | public static function runCommand($command, $returnStatus = true)
{
$return_var = 1;
//system
if (\function_exists('system')) {
ob_start();
system($command, $return_var);
$output = ob_get_contents();
ob_end_clean();
// passthru
} elseif (\function_exists('passthru')) {
ob_start();
passthru($command, $return_var);
$output = ob_get_contents();
ob_end_clean();
//exec
} else {
if (\function_exists('exec')) {
exec($command, $output, $return_var);
$output = implode("\n", $output);
//shell_exec
} else {
if (\function_exists('shell_exec')) {
$output = shell_exec($command);
} else {
$output = 'Command execution not possible on this system';
$return_var = 0;
}
}
}
if ($returnStatus) {
return ['output' => trim($output), 'status' => $return_var];
}
return trim($output);
} | [
"public",
"static",
"function",
"runCommand",
"(",
"$",
"command",
",",
"$",
"returnStatus",
"=",
"true",
")",
"{",
"$",
"return_var",
"=",
"1",
";",
"//system",
"if",
"(",
"\\",
"function_exists",
"(",
"'system'",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"system",
"(",
"$",
"command",
",",
"$",
"return_var",
")",
";",
"$",
"output",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"// passthru",
"}",
"elseif",
"(",
"\\",
"function_exists",
"(",
"'passthru'",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"passthru",
"(",
"$",
"command",
",",
"$",
"return_var",
")",
";",
"$",
"output",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"//exec",
"}",
"else",
"{",
"if",
"(",
"\\",
"function_exists",
"(",
"'exec'",
")",
")",
"{",
"exec",
"(",
"$",
"command",
",",
"$",
"output",
",",
"$",
"return_var",
")",
";",
"$",
"output",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"output",
")",
";",
"//shell_exec",
"}",
"else",
"{",
"if",
"(",
"\\",
"function_exists",
"(",
"'shell_exec'",
")",
")",
"{",
"$",
"output",
"=",
"shell_exec",
"(",
"$",
"command",
")",
";",
"}",
"else",
"{",
"$",
"output",
"=",
"'Command execution not possible on this system'",
";",
"$",
"return_var",
"=",
"0",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"returnStatus",
")",
"{",
"return",
"[",
"'output'",
"=>",
"trim",
"(",
"$",
"output",
")",
",",
"'status'",
"=>",
"$",
"return_var",
"]",
";",
"}",
"return",
"trim",
"(",
"$",
"output",
")",
";",
"}"
] | Method to execute a command in the sys
Uses :
1. system
2. passthru
3. exec
4. shell_exec
@param $command
@param bool $returnStatus
@return array | [
"Method",
"to",
"execute",
"a",
"command",
"in",
"the",
"sys",
"Uses",
":",
"1",
".",
"system",
"2",
".",
"passthru",
"3",
".",
"exec",
"4",
".",
"shell_exec"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Sys.php#L70-L109 |
inhere/php-librarys | src/Helpers/Sys.php | Sys.getHostIP | public static function getHostIP(string $default = '127.0.0.1'): string
{
static $ip;
if ($ip) {
return $ip;
}
$host= gethostname();
$maybe = gethostbyname($host);
if ($host !== $maybe) {
$ip = $maybe;
return $ip;
}
if (Helper::isUnix()) {
list($code, $output) = ProcessUtil::run('ip addr | grep eth0');
if ($code === 0 && $output && preg_match('#inet (.*)\/#', $output, $ms)) {
$ip = $ms[1];
return $ip;
}
}
return $default;
} | php | public static function getHostIP(string $default = '127.0.0.1'): string
{
static $ip;
if ($ip) {
return $ip;
}
$host= gethostname();
$maybe = gethostbyname($host);
if ($host !== $maybe) {
$ip = $maybe;
return $ip;
}
if (Helper::isUnix()) {
list($code, $output) = ProcessUtil::run('ip addr | grep eth0');
if ($code === 0 && $output && preg_match('#inet (.*)\/#', $output, $ms)) {
$ip = $ms[1];
return $ip;
}
}
return $default;
} | [
"public",
"static",
"function",
"getHostIP",
"(",
"string",
"$",
"default",
"=",
"'127.0.0.1'",
")",
":",
"string",
"{",
"static",
"$",
"ip",
";",
"if",
"(",
"$",
"ip",
")",
"{",
"return",
"$",
"ip",
";",
"}",
"$",
"host",
"=",
"gethostname",
"(",
")",
";",
"$",
"maybe",
"=",
"gethostbyname",
"(",
"$",
"host",
")",
";",
"if",
"(",
"$",
"host",
"!==",
"$",
"maybe",
")",
"{",
"$",
"ip",
"=",
"$",
"maybe",
";",
"return",
"$",
"ip",
";",
"}",
"if",
"(",
"Helper",
"::",
"isUnix",
"(",
")",
")",
"{",
"list",
"(",
"$",
"code",
",",
"$",
"output",
")",
"=",
"ProcessUtil",
"::",
"run",
"(",
"'ip addr | grep eth0'",
")",
";",
"if",
"(",
"$",
"code",
"===",
"0",
"&&",
"$",
"output",
"&&",
"preg_match",
"(",
"'#inet (.*)\\/#'",
",",
"$",
"output",
",",
"$",
"ms",
")",
")",
"{",
"$",
"ip",
"=",
"$",
"ms",
"[",
"1",
"]",
";",
"return",
"$",
"ip",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] | 当前主机的外网IP
@param string $default
@return string | [
"当前主机的外网IP"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Sys.php#L138-L166 |
inhere/php-librarys | src/Helpers/Sys.php | Sys.gitCheck | public static function gitCheck()
{
if (PHP_SAPI === 'cli') {
$_GET = getopt('d::', ['dir::']);
}
// 获取要查看的目录,没有则检测当前目录
$dir = $_GET['d'] ?? ($_GET['dir'] ?? __DIR__);
if (!is_dir($dir)) {
trigger_error($dir);
}
ob_start();
system("cd $dir && git branch -v");
$c = ob_get_clean();
$result = preg_match('#\* (?<brName>[\S]+)(?:\s+)(?<logNum>[0-9a-z]{7})(?<ciText>.*)#i', $c, $data);
$data['projectName'] = basename($dir);
// var_dump($c,$result, $data);
return ($result === 1) ? $data : null;
} | php | public static function gitCheck()
{
if (PHP_SAPI === 'cli') {
$_GET = getopt('d::', ['dir::']);
}
// 获取要查看的目录,没有则检测当前目录
$dir = $_GET['d'] ?? ($_GET['dir'] ?? __DIR__);
if (!is_dir($dir)) {
trigger_error($dir);
}
ob_start();
system("cd $dir && git branch -v");
$c = ob_get_clean();
$result = preg_match('#\* (?<brName>[\S]+)(?:\s+)(?<logNum>[0-9a-z]{7})(?<ciText>.*)#i', $c, $data);
$data['projectName'] = basename($dir);
// var_dump($c,$result, $data);
return ($result === 1) ? $data : null;
} | [
"public",
"static",
"function",
"gitCheck",
"(",
")",
"{",
"if",
"(",
"PHP_SAPI",
"===",
"'cli'",
")",
"{",
"$",
"_GET",
"=",
"getopt",
"(",
"'d::'",
",",
"[",
"'dir::'",
"]",
")",
";",
"}",
"// 获取要查看的目录,没有则检测当前目录",
"$",
"dir",
"=",
"$",
"_GET",
"[",
"'d'",
"]",
"??",
"(",
"$",
"_GET",
"[",
"'dir'",
"]",
"??",
"__DIR__",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"trigger_error",
"(",
"$",
"dir",
")",
";",
"}",
"ob_start",
"(",
")",
";",
"system",
"(",
"\"cd $dir && git branch -v\"",
")",
";",
"$",
"c",
"=",
"ob_get_clean",
"(",
")",
";",
"$",
"result",
"=",
"preg_match",
"(",
"'#\\* (?<brName>[\\S]+)(?:\\s+)(?<logNum>[0-9a-z]{7})(?<ciText>.*)#i'",
",",
"$",
"c",
",",
"$",
"data",
")",
";",
"$",
"data",
"[",
"'projectName'",
"]",
"=",
"basename",
"(",
"$",
"dir",
")",
";",
"// var_dump($c,$result, $data);",
"return",
"(",
"$",
"result",
"===",
"1",
")",
"?",
"$",
"data",
":",
"null",
";",
"}"
] | 支持查看指定目录,默认当前目录
CLI:
php test.php -d=path
php test.php --dir=path
WEB:
/test.php?dir=path | [
"支持查看指定目录,默认当前目录",
"CLI",
":",
"php",
"test",
".",
"php",
"-",
"d",
"=",
"path",
"php",
"test",
".",
"php",
"--",
"dir",
"=",
"path",
"WEB",
":",
"/",
"test",
".",
"php?dir",
"=",
"path"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/Sys.php#L207-L229 |
c5labs/block-boilerplate | controller.php | Controller.validate | public function validate($data)
{
$errors = new \Concrete\Core\Error\Error();
/**
* if ('Oliver' !== $data['name']) {
* $errors['name'] = "You input the incorrect name.";
* }.
*/
if ($errors->has()) {
return $errors;
}
return true;
} | php | public function validate($data)
{
$errors = new \Concrete\Core\Error\Error();
/**
* if ('Oliver' !== $data['name']) {
* $errors['name'] = "You input the incorrect name.";
* }.
*/
if ($errors->has()) {
return $errors;
}
return true;
} | [
"public",
"function",
"validate",
"(",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"new",
"\\",
"Concrete",
"\\",
"Core",
"\\",
"Error",
"\\",
"Error",
"(",
")",
";",
"/**\n * if ('Oliver' !== $data['name']) {\n * $errors['name'] = \"You input the incorrect name.\";\n * }.\n */",
"if",
"(",
"$",
"errors",
"->",
"has",
"(",
")",
")",
"{",
"return",
"$",
"errors",
";",
"}",
"return",
"true",
";",
"}"
] | Run when the add or edit forms are submitted. This should return true if
validation is successful or a Concrete\Core\Error\Error() object if it fails.
@param $data
@return bool|Error | [
"Run",
"when",
"the",
"add",
"or",
"edit",
"forms",
"are",
"submitted",
".",
"This",
"should",
"return",
"true",
"if",
"validation",
"is",
"successful",
"or",
"a",
"Concrete",
"\\",
"Core",
"\\",
"Error",
"\\",
"Error",
"()",
"object",
"if",
"it",
"fails",
"."
] | train | https://github.com/c5labs/block-boilerplate/blob/ed011364db67d8e219fdb3e18ff3d3e87027b565/controller.php#L281-L295 |
c5labs/block-boilerplate | controller.php | Controller.import | public function import($page, $areaHandle, SimpleXMLElement $blockNode)
{
parent::import($page, $areaHandle, $blockNode);
} | php | public function import($page, $areaHandle, SimpleXMLElement $blockNode)
{
parent::import($page, $areaHandle, $blockNode);
} | [
"public",
"function",
"import",
"(",
"$",
"page",
",",
"$",
"areaHandle",
",",
"SimpleXMLElement",
"$",
"blockNode",
")",
"{",
"parent",
"::",
"import",
"(",
"$",
"page",
",",
"$",
"areaHandle",
",",
"$",
"blockNode",
")",
";",
"}"
] | Runs when a block is being imported.
@param Page $page
@param string $areaHandle
@param SimpleXMLElement $blockNode
@return void | [
"Runs",
"when",
"a",
"block",
"is",
"being",
"imported",
"."
] | train | https://github.com/c5labs/block-boilerplate/blob/ed011364db67d8e219fdb3e18ff3d3e87027b565/controller.php#L371-L374 |
phootwork/lang | src/ArrayObject.php | ArrayObject.add | public function add($element, $index = null) {
if ($index === null) {
$this->array[$this->count()] = $element;
} else {
array_splice($this->array, $index, 0, $element);
}
return $this;
} | php | public function add($element, $index = null) {
if ($index === null) {
$this->array[$this->count()] = $element;
} else {
array_splice($this->array, $index, 0, $element);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"element",
",",
"$",
"index",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"index",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"array",
"[",
"$",
"this",
"->",
"count",
"(",
")",
"]",
"=",
"$",
"element",
";",
"}",
"else",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"array",
",",
"$",
"index",
",",
"0",
",",
"$",
"element",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds an element to that array
@param mixed $element
@param int $index
@return $this | [
"Adds",
"an",
"element",
"to",
"that",
"array"
] | train | https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L100-L108 |
phootwork/lang | src/ArrayObject.php | ArrayObject.splice | public function splice($offset, $length = null, $replacement = []) {
$length = $length === null ? $this->count() : $length;
array_splice($this->array, $offset, $length, $replacement);
return $this;
} | php | public function splice($offset, $length = null, $replacement = []) {
$length = $length === null ? $this->count() : $length;
array_splice($this->array, $offset, $length, $replacement);
return $this;
} | [
"public",
"function",
"splice",
"(",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
",",
"$",
"replacement",
"=",
"[",
"]",
")",
"{",
"$",
"length",
"=",
"$",
"length",
"===",
"null",
"?",
"$",
"this",
"->",
"count",
"(",
")",
":",
"$",
"length",
";",
"array_splice",
"(",
"$",
"this",
"->",
"array",
",",
"$",
"offset",
",",
"$",
"length",
",",
"$",
"replacement",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Remove a portion of the array and replace it with something else
@param int $offset If offset is positive then the start of removed portion is at that offset from the beginning of the input array. If offset is negative then it starts that far from the end of the input array.
@param int $length If length is omitted, removes everything from offset to the end of the array. If length is specified and is positive, then that many elements will be removed. If length is specified and is negative then the end of the removed portion will be that many elements from the end of the array. If length is specified and is zero, no elements will be removed.
@param array $replacement If replacement array is specified, then the removed elements are replaced with elements from this array. If offset and length are such that nothing is removed, then the elements from the replacement array are inserted in the place specified by the offset. Note that keys in replacement array are not preserved. If replacement is just one element it is not necessary to put array() around it, unless the element is an array itself, an object or NULL.
@return $this | [
"Remove",
"a",
"portion",
"of",
"the",
"array",
"and",
"replace",
"it",
"with",
"something",
"else"
] | train | https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L208-L212 |
phootwork/lang | src/ArrayObject.php | ArrayObject.doSort | protected function doSort(&$array, $cmp, callable $usort, callable $sort) {
if (is_callable($cmp)) {
$usort($array, $cmp);
} else if ($cmp instanceof Comparator) {
$usort($array, function ($a, $b) use ($cmp) {
return $cmp->compare($a, $b);
});
} else {
$sort($array);
}
} | php | protected function doSort(&$array, $cmp, callable $usort, callable $sort) {
if (is_callable($cmp)) {
$usort($array, $cmp);
} else if ($cmp instanceof Comparator) {
$usort($array, function ($a, $b) use ($cmp) {
return $cmp->compare($a, $b);
});
} else {
$sort($array);
}
} | [
"protected",
"function",
"doSort",
"(",
"&",
"$",
"array",
",",
"$",
"cmp",
",",
"callable",
"$",
"usort",
",",
"callable",
"$",
"sort",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"cmp",
")",
")",
"{",
"$",
"usort",
"(",
"$",
"array",
",",
"$",
"cmp",
")",
";",
"}",
"else",
"if",
"(",
"$",
"cmp",
"instanceof",
"Comparator",
")",
"{",
"$",
"usort",
"(",
"$",
"array",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"cmp",
")",
"{",
"return",
"$",
"cmp",
"->",
"compare",
"(",
"$",
"a",
",",
"$",
"b",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"sort",
"(",
"$",
"array",
")",
";",
"}",
"}"
] | Internal sort function
@param array $array the array on which is operated on
@param Comparator|callable $cmp the compare function
@param callable $usort the sort function for user passed $cmd
@param callable $sort the default sort function | [
"Internal",
"sort",
"function"
] | train | https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L264-L274 |
phootwork/lang | src/ArrayObject.php | ArrayObject.find | public function find() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
foreach ($this->array as $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
return $element;
}
}
return null;
} | php | public function find() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
foreach ($this->array as $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
return $element;
}
}
return null;
} | [
"public",
"function",
"find",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"array",
"as",
"$",
"element",
")",
"{",
"$",
"return",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"callback",
"(",
"$",
"element",
")",
":",
"$",
"callback",
"(",
"$",
"element",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"element",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Searches the array with a given callback and returns the first element if found.
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query OPTIONAL the provided query
@param callable $callback the callback function
@return mixed|null the found element or null if it hasn't been found | [
"Searches",
"the",
"array",
"with",
"a",
"given",
"callback",
"and",
"returns",
"the",
"first",
"element",
"if",
"found",
"."
] | train | https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L382-L399 |
phootwork/lang | src/ArrayObject.php | ArrayObject.findLast | public function findLast() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$reverse = array_reverse($this->array, true);
foreach ($reverse as $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
return $element;
}
}
return null;
} | php | public function findLast() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$reverse = array_reverse($this->array, true);
foreach ($reverse as $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
return $element;
}
}
return null;
} | [
"public",
"function",
"findLast",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"$",
"reverse",
"=",
"array_reverse",
"(",
"$",
"this",
"->",
"array",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"reverse",
"as",
"$",
"element",
")",
"{",
"$",
"return",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"callback",
"(",
"$",
"element",
")",
":",
"$",
"callback",
"(",
"$",
"element",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"element",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Searches the array with a given callback and returns the last element if found.
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query OPTIONAL the provided query
@param callable $callback the callback function
@return mixed|null the found element or null if it hasn't been found | [
"Searches",
"the",
"array",
"with",
"a",
"given",
"callback",
"and",
"returns",
"the",
"last",
"element",
"if",
"found",
"."
] | train | https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L414-L432 |
phootwork/lang | src/ArrayObject.php | ArrayObject.findAll | public function findAll() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$array = [];
foreach ($this->array as $k => $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
$array[$k] = $element;
}
}
return new static($array);
} | php | public function findAll() {
if (func_num_args() == 1) {
$callback = func_get_arg(0);
} else {
$query = func_get_arg(0);
$callback = func_get_arg(1);
}
$array = [];
foreach ($this->array as $k => $element) {
$return = func_num_args() == 1 ? $callback($element) : $callback($element, $query);
if ($return) {
$array[$k] = $element;
}
}
return new static($array);
} | [
"public",
"function",
"findAll",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"==",
"1",
")",
"{",
"$",
"callback",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"else",
"{",
"$",
"query",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"$",
"callback",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"array",
"as",
"$",
"k",
"=>",
"$",
"element",
")",
"{",
"$",
"return",
"=",
"func_num_args",
"(",
")",
"==",
"1",
"?",
"$",
"callback",
"(",
"$",
"element",
")",
":",
"$",
"callback",
"(",
"$",
"element",
",",
"$",
"query",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"$",
"array",
"[",
"$",
"k",
"]",
"=",
"$",
"element",
";",
"}",
"}",
"return",
"new",
"static",
"(",
"$",
"array",
")",
";",
"}"
] | Searches the array with a given callback and returns all matching elements.
The callback function takes one or two parameters:
function ($element [, $query]) {}
The callback must return a boolean
@param mixed $query OPTIONAL the provided query
@param callable $callback the callback function
@return mixed|null the found element or null if it hasn't been found | [
"Searches",
"the",
"array",
"with",
"a",
"given",
"callback",
"and",
"returns",
"all",
"matching",
"elements",
"."
] | train | https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/ArrayObject.php#L447-L465 |
sleeping-owl/route-priority | src/SleepingOwl/RoutePriority/RouteCollection.php | RouteCollection.addToCollections | protected function addToCollections($route)
{
$domainAndUri = $route->domain() . $route->getUri();
foreach ($route->methods() as $method)
{
$this->routes[$method][$domainAndUri] = $route;
}
$this->allRoutes[$method . $domainAndUri] = $route;
} | php | protected function addToCollections($route)
{
$domainAndUri = $route->domain() . $route->getUri();
foreach ($route->methods() as $method)
{
$this->routes[$method][$domainAndUri] = $route;
}
$this->allRoutes[$method . $domainAndUri] = $route;
} | [
"protected",
"function",
"addToCollections",
"(",
"$",
"route",
")",
"{",
"$",
"domainAndUri",
"=",
"$",
"route",
"->",
"domain",
"(",
")",
".",
"$",
"route",
"->",
"getUri",
"(",
")",
";",
"foreach",
"(",
"$",
"route",
"->",
"methods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"$",
"method",
"]",
"[",
"$",
"domainAndUri",
"]",
"=",
"$",
"route",
";",
"}",
"$",
"this",
"->",
"allRoutes",
"[",
"$",
"method",
".",
"$",
"domainAndUri",
"]",
"=",
"$",
"route",
";",
"}"
] | Add the given route to the arrays of routes.
@param \Illuminate\Routing\Route $route
@return void | [
"Add",
"the",
"given",
"route",
"to",
"the",
"arrays",
"of",
"routes",
"."
] | train | https://github.com/sleeping-owl/route-priority/blob/fd311e5cdb2135e3aa34e9ef37c8f4f02c635089/src/SleepingOwl/RoutePriority/RouteCollection.php#L35-L45 |
php-lug/lug | src/Bundle/ResourceBundle/EventSubscriber/Doctrine/ORM/ResolveTargetEntitySubscriber.php | ResolveTargetEntitySubscriber.addResolveTargetEntity | public function addResolveTargetEntity($originalEntity, $newEntity, array $mapping)
{
$mapping['targetEntity'] = ltrim($newEntity, '\\\\');
$this->resolveTargetEntities[ltrim($originalEntity, '\\\\')] = $mapping;
parent::addResolveTargetEntity($originalEntity, $newEntity, $mapping);
} | php | public function addResolveTargetEntity($originalEntity, $newEntity, array $mapping)
{
$mapping['targetEntity'] = ltrim($newEntity, '\\\\');
$this->resolveTargetEntities[ltrim($originalEntity, '\\\\')] = $mapping;
parent::addResolveTargetEntity($originalEntity, $newEntity, $mapping);
} | [
"public",
"function",
"addResolveTargetEntity",
"(",
"$",
"originalEntity",
",",
"$",
"newEntity",
",",
"array",
"$",
"mapping",
")",
"{",
"$",
"mapping",
"[",
"'targetEntity'",
"]",
"=",
"ltrim",
"(",
"$",
"newEntity",
",",
"'\\\\\\\\'",
")",
";",
"$",
"this",
"->",
"resolveTargetEntities",
"[",
"ltrim",
"(",
"$",
"originalEntity",
",",
"'\\\\\\\\'",
")",
"]",
"=",
"$",
"mapping",
";",
"parent",
"::",
"addResolveTargetEntity",
"(",
"$",
"originalEntity",
",",
"$",
"newEntity",
",",
"$",
"mapping",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/EventSubscriber/Doctrine/ORM/ResolveTargetEntitySubscriber.php#L39-L45 |
php-lug/lug | src/Bundle/ResourceBundle/EventSubscriber/Doctrine/ORM/ResolveTargetEntitySubscriber.php | ResolveTargetEntitySubscriber.loadClassMetadata | public function loadClassMetadata(LoadClassMetadataEventArgs $event)
{
$map = [];
$metadata = $event->getClassMetadata();
foreach ($metadata->discriminatorMap as $discriminatorName => $discriminatorClass) {
if (isset($this->resolveTargetEntities[$discriminatorClass])) {
$map[$discriminatorName] = $this->resolveTargetEntities[$discriminatorClass]['targetEntity'];
}
}
$metadata->setDiscriminatorMap($map);
parent::loadClassMetadata($event);
} | php | public function loadClassMetadata(LoadClassMetadataEventArgs $event)
{
$map = [];
$metadata = $event->getClassMetadata();
foreach ($metadata->discriminatorMap as $discriminatorName => $discriminatorClass) {
if (isset($this->resolveTargetEntities[$discriminatorClass])) {
$map[$discriminatorName] = $this->resolveTargetEntities[$discriminatorClass]['targetEntity'];
}
}
$metadata->setDiscriminatorMap($map);
parent::loadClassMetadata($event);
} | [
"public",
"function",
"loadClassMetadata",
"(",
"LoadClassMetadataEventArgs",
"$",
"event",
")",
"{",
"$",
"map",
"=",
"[",
"]",
";",
"$",
"metadata",
"=",
"$",
"event",
"->",
"getClassMetadata",
"(",
")",
";",
"foreach",
"(",
"$",
"metadata",
"->",
"discriminatorMap",
"as",
"$",
"discriminatorName",
"=>",
"$",
"discriminatorClass",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"resolveTargetEntities",
"[",
"$",
"discriminatorClass",
"]",
")",
")",
"{",
"$",
"map",
"[",
"$",
"discriminatorName",
"]",
"=",
"$",
"this",
"->",
"resolveTargetEntities",
"[",
"$",
"discriminatorClass",
"]",
"[",
"'targetEntity'",
"]",
";",
"}",
"}",
"$",
"metadata",
"->",
"setDiscriminatorMap",
"(",
"$",
"map",
")",
";",
"parent",
"::",
"loadClassMetadata",
"(",
"$",
"event",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/EventSubscriber/Doctrine/ORM/ResolveTargetEntitySubscriber.php#L50-L64 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Translation/src/translation_manager.php | ezcTranslationManager.getFromCache | private function getFromCache( $locale, $context )
{
if ( isset( $this->contextCache[$locale][$context] ) )
{
return $this->contextCache[$locale][$context];
}
return null;
} | php | private function getFromCache( $locale, $context )
{
if ( isset( $this->contextCache[$locale][$context] ) )
{
return $this->contextCache[$locale][$context];
}
return null;
} | [
"private",
"function",
"getFromCache",
"(",
"$",
"locale",
",",
"$",
"context",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"contextCache",
"[",
"$",
"locale",
"]",
"[",
"$",
"context",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"contextCache",
"[",
"$",
"locale",
"]",
"[",
"$",
"context",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the translation for the context $context with the locale $locale.
Null is returned if no such context exists.
@param string $locale
@param string $context
@return ezcTranslation | [
"Returns",
"the",
"translation",
"for",
"the",
"context",
"$context",
"with",
"the",
"locale",
"$locale",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/translation_manager.php#L103-L110 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Translation/src/translation_manager.php | ezcTranslationManager.putToCache | private function putToCache( $locale, $contextName, ezcTranslation $contextData )
{
$this->contextCache[$locale][$contextName] = $contextData;
} | php | private function putToCache( $locale, $contextName, ezcTranslation $contextData )
{
$this->contextCache[$locale][$contextName] = $contextData;
} | [
"private",
"function",
"putToCache",
"(",
"$",
"locale",
",",
"$",
"contextName",
",",
"ezcTranslation",
"$",
"contextData",
")",
"{",
"$",
"this",
"->",
"contextCache",
"[",
"$",
"locale",
"]",
"[",
"$",
"contextName",
"]",
"=",
"$",
"contextData",
";",
"}"
] | Stores $contextData with the name $contextName and locale $locale
to the context cache
@param string $locale
@param string $contextName
@param ezcTranslation $contextData
@return void | [
"Stores",
"$contextData",
"with",
"the",
"name",
"$contextName",
"and",
"locale",
"$locale",
"to",
"the",
"context",
"cache"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/translation_manager.php#L121-L124 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Translation/src/translation_manager.php | ezcTranslationManager.getContext | public function getContext( $locale, $context )
{
// Try to find the context in the cache
if ( ( $translationContext = $this->getFromCache( $locale, $context) ) !== null )
{
return $translationContext;
}
// Retrieve the context through the backend and apply filters
$translationContext = $this->backend->getContext( $locale, $context );
foreach ( $this->filters as $filter )
{
$filter->runFilter( $translationContext );
}
// Create the object, put it in the cache and return it
$returnContext = new ezcTranslation( $translationContext );
$this->putToCache( $locale, $context, $returnContext );
return $returnContext;
} | php | public function getContext( $locale, $context )
{
// Try to find the context in the cache
if ( ( $translationContext = $this->getFromCache( $locale, $context) ) !== null )
{
return $translationContext;
}
// Retrieve the context through the backend and apply filters
$translationContext = $this->backend->getContext( $locale, $context );
foreach ( $this->filters as $filter )
{
$filter->runFilter( $translationContext );
}
// Create the object, put it in the cache and return it
$returnContext = new ezcTranslation( $translationContext );
$this->putToCache( $locale, $context, $returnContext );
return $returnContext;
} | [
"public",
"function",
"getContext",
"(",
"$",
"locale",
",",
"$",
"context",
")",
"{",
"// Try to find the context in the cache",
"if",
"(",
"(",
"$",
"translationContext",
"=",
"$",
"this",
"->",
"getFromCache",
"(",
"$",
"locale",
",",
"$",
"context",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"translationContext",
";",
"}",
"// Retrieve the context through the backend and apply filters",
"$",
"translationContext",
"=",
"$",
"this",
"->",
"backend",
"->",
"getContext",
"(",
"$",
"locale",
",",
"$",
"context",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"filter",
")",
"{",
"$",
"filter",
"->",
"runFilter",
"(",
"$",
"translationContext",
")",
";",
"}",
"// Create the object, put it in the cache and return it",
"$",
"returnContext",
"=",
"new",
"ezcTranslation",
"(",
"$",
"translationContext",
")",
";",
"$",
"this",
"->",
"putToCache",
"(",
"$",
"locale",
",",
"$",
"context",
",",
"$",
"returnContext",
")",
";",
"return",
"$",
"returnContext",
";",
"}"
] | Returns the translations for the $context context and the locale $locale.
This methods reads the context data from the backend and applies the
filters before returning the translation map as part of the
ezcTranslation object that it returns.
@param string $locale
@param string $context
@return ezcTranslation | [
"Returns",
"the",
"translations",
"for",
"the",
"$context",
"context",
"and",
"the",
"locale",
"$locale",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Translation/src/translation_manager.php#L137-L154 |
WScore/Validation | src/Rules.php | Rules.offsetGet | public function offsetGet($offset)
{
return array_key_exists($offset, $this->filter) ? $this->filter[$offset] : null;
} | php | public function offsetGet($offset)
{
return array_key_exists($offset, $this->filter) ? $this->filter[$offset] : null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"filter",
")",
"?",
"$",
"this",
"->",
"filter",
"[",
"$",
"offset",
"]",
":",
"null",
";",
"}"
] | Offset to retrieve
@param mixed $offset The offset to retrieve.
@return mixed Can return all value types. | [
"Offset",
"to",
"retrieve"
] | train | https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Rules.php#L342-L345 |
inhere/php-librarys | src/Traits/TraitUseAlias.php | TraitUseAlias.alias | public function alias($alias, $value = '')
{
// set
if ($alias && $value) {
$this->aliasAndValueCheck($alias, $value);
$this->aliases[$alias] = trim($value);
// get
} else {
return $this->resolveAlias($alias);
}
return $this;
} | php | public function alias($alias, $value = '')
{
// set
if ($alias && $value) {
$this->aliasAndValueCheck($alias, $value);
$this->aliases[$alias] = trim($value);
// get
} else {
return $this->resolveAlias($alias);
}
return $this;
} | [
"public",
"function",
"alias",
"(",
"$",
"alias",
",",
"$",
"value",
"=",
"''",
")",
"{",
"// set",
"if",
"(",
"$",
"alias",
"&&",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"aliasAndValueCheck",
"(",
"$",
"alias",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"// get",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"resolveAlias",
"(",
"$",
"alias",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 设置/获取别名
@param string $alias 别名
@param string $value 真实的值. 为空用于获取
@throws \RuntimeException
@return mixed | [
"设置",
"/",
"获取别名"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/TraitUseAlias.php#L30-L43 |
inhere/php-librarys | src/Traits/TraitUseAlias.php | TraitUseAlias.loadAliases | public function loadAliases(array $aliases)
{
foreach ($aliases as $alias => $path) {
$this->alias($alias, $path);
}
return $this;
} | php | public function loadAliases(array $aliases)
{
foreach ($aliases as $alias => $path) {
$this->alias($alias, $path);
}
return $this;
} | [
"public",
"function",
"loadAliases",
"(",
"array",
"$",
"aliases",
")",
"{",
"foreach",
"(",
"$",
"aliases",
"as",
"$",
"alias",
"=>",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"alias",
"(",
"$",
"alias",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 载入别名设置
@param array $aliases
@return $this
@throws \RuntimeException | [
"载入别名设置"
] | train | https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/TraitUseAlias.php#L103-L110 |
nonzod/yii2-foundation | Widget.php | Widget.init | public function init() {
parent::init();
if (empty($this->options['id'])) {
$this->options['id'] = $this->getId();
}
} | php | public function init() {
parent::init();
if (empty($this->options['id'])) {
$this->options['id'] = $this->getId();
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"}",
"}"
] | Initialize the widget | [
"Initialize",
"the",
"widget"
] | train | https://github.com/nonzod/yii2-foundation/blob/5df93b8a39a73a7fade2f3189693fdb6625205d2/Widget.php#L39-L44 |
nonzod/yii2-foundation | Widget.php | Widget.registerPlugin | protected function registerPlugin($name = '') {
$view = $this->getView();
//$id = $this->options['id'];
if ($this->clientOptions !== false) {
$options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
$js = "$(document).foundation({ '$name' : { $options } });";
$view->registerJs($js);
}
if (!empty($this->clientFireMethods)) {
$js = [];
foreach ($this->clientFireMethods as $method) {
$js[] = "$(document).foundation('$name', '$method');";
}
$view->registerJs(implode("\n", $js));
}
} | php | protected function registerPlugin($name = '') {
$view = $this->getView();
//$id = $this->options['id'];
if ($this->clientOptions !== false) {
$options = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions);
$js = "$(document).foundation({ '$name' : { $options } });";
$view->registerJs($js);
}
if (!empty($this->clientFireMethods)) {
$js = [];
foreach ($this->clientFireMethods as $method) {
$js[] = "$(document).foundation('$name', '$method');";
}
$view->registerJs(implode("\n", $js));
}
} | [
"protected",
"function",
"registerPlugin",
"(",
"$",
"name",
"=",
"''",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"//$id = $this->options['id'];",
"if",
"(",
"$",
"this",
"->",
"clientOptions",
"!==",
"false",
")",
"{",
"$",
"options",
"=",
"empty",
"(",
"$",
"this",
"->",
"clientOptions",
")",
"?",
"''",
":",
"Json",
"::",
"encode",
"(",
"$",
"this",
"->",
"clientOptions",
")",
";",
"$",
"js",
"=",
"\"$(document).foundation({ '$name' : { $options } });\"",
";",
"$",
"view",
"->",
"registerJs",
"(",
"$",
"js",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"clientFireMethods",
")",
")",
"{",
"$",
"js",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"clientFireMethods",
"as",
"$",
"method",
")",
"{",
"$",
"js",
"[",
"]",
"=",
"\"$(document).foundation('$name', '$method');\"",
";",
"}",
"$",
"view",
"->",
"registerJs",
"(",
"implode",
"(",
"\"\\n\"",
",",
"$",
"js",
")",
")",
";",
"}",
"}"
] | Registers a specific Foundation plugin and call related methods
@param string $name the name of the Foundation plugin
@todo far caricare solo i js dei plugin in uso | [
"Registers",
"a",
"specific",
"Foundation",
"plugin",
"and",
"call",
"related",
"methods"
] | train | https://github.com/nonzod/yii2-foundation/blob/5df93b8a39a73a7fade2f3189693fdb6625205d2/Widget.php#L51-L69 |
oroinc/OroLayoutComponent | BlockOptionsResolver.php | BlockOptionsResolver.resolveOptions | public function resolveOptions($blockType, array $options = [])
{
$resolver = $this->getOptionResolver($blockType);
return $resolver->resolve($options);
} | php | public function resolveOptions($blockType, array $options = [])
{
$resolver = $this->getOptionResolver($blockType);
return $resolver->resolve($options);
} | [
"public",
"function",
"resolveOptions",
"(",
"$",
"blockType",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"resolver",
"=",
"$",
"this",
"->",
"getOptionResolver",
"(",
"$",
"blockType",
")",
";",
"return",
"$",
"resolver",
"->",
"resolve",
"(",
"$",
"options",
")",
";",
"}"
] | Returns the combination of the default options for the given block type and the passed options
@param string|BlockTypeInterface $blockType The block type name or instance of BlockTypeInterface
@param array $options The options
@return array A list of options and their values
@throws InvalidOptionsException if any given option is not applicable to the given block type | [
"Returns",
"the",
"combination",
"of",
"the",
"default",
"options",
"for",
"the",
"given",
"block",
"type",
"and",
"the",
"passed",
"options"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockOptionsResolver.php#L34-L39 |
oroinc/OroLayoutComponent | BlockOptionsResolver.php | BlockOptionsResolver.getOptionResolver | protected function getOptionResolver($blockType)
{
if ($blockType instanceof BlockTypeInterface) {
$name = $blockType->getName();
$type = $blockType;
} else {
$name = $blockType;
$type = null;
}
if (!isset($this->resolvers[$name])) {
if (!$type) {
$type = $this->registry->getType($name);
}
$parentName = $type->getParent();
$optionsResolver = $parentName
? clone $this->getOptionResolver($parentName)
: new OptionsResolver();
$type->configureOptions($optionsResolver);
$this->registry->configureOptions($name, $optionsResolver);
$this->resolvers[$name] = $optionsResolver;
}
return $this->resolvers[$name];
} | php | protected function getOptionResolver($blockType)
{
if ($blockType instanceof BlockTypeInterface) {
$name = $blockType->getName();
$type = $blockType;
} else {
$name = $blockType;
$type = null;
}
if (!isset($this->resolvers[$name])) {
if (!$type) {
$type = $this->registry->getType($name);
}
$parentName = $type->getParent();
$optionsResolver = $parentName
? clone $this->getOptionResolver($parentName)
: new OptionsResolver();
$type->configureOptions($optionsResolver);
$this->registry->configureOptions($name, $optionsResolver);
$this->resolvers[$name] = $optionsResolver;
}
return $this->resolvers[$name];
} | [
"protected",
"function",
"getOptionResolver",
"(",
"$",
"blockType",
")",
"{",
"if",
"(",
"$",
"blockType",
"instanceof",
"BlockTypeInterface",
")",
"{",
"$",
"name",
"=",
"$",
"blockType",
"->",
"getName",
"(",
")",
";",
"$",
"type",
"=",
"$",
"blockType",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"blockType",
";",
"$",
"type",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resolvers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"registry",
"->",
"getType",
"(",
"$",
"name",
")",
";",
"}",
"$",
"parentName",
"=",
"$",
"type",
"->",
"getParent",
"(",
")",
";",
"$",
"optionsResolver",
"=",
"$",
"parentName",
"?",
"clone",
"$",
"this",
"->",
"getOptionResolver",
"(",
"$",
"parentName",
")",
":",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"type",
"->",
"configureOptions",
"(",
"$",
"optionsResolver",
")",
";",
"$",
"this",
"->",
"registry",
"->",
"configureOptions",
"(",
"$",
"name",
",",
"$",
"optionsResolver",
")",
";",
"$",
"this",
"->",
"resolvers",
"[",
"$",
"name",
"]",
"=",
"$",
"optionsResolver",
";",
"}",
"return",
"$",
"this",
"->",
"resolvers",
"[",
"$",
"name",
"]",
";",
"}"
] | @param string|BlockTypeInterface $blockType
@return OptionsResolver | [
"@param",
"string|BlockTypeInterface",
"$blockType"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockOptionsResolver.php#L46-L73 |
zhouyl/mellivora | Mellivora/Http/HttpServiceProvider.php | HttpServiceProvider.registerCookiesProvider | public function registerCookiesProvider()
{
$this->container['cookies'] = function ($container) {
$config = $container['config']->get('session.cookies');
$cookies = new Cookies($config->toArray());
// 数据需要加密处理
if ($config->encrypt) {
$cookies->setEncryption($container['crypt']);
}
return $cookies;
};
} | php | public function registerCookiesProvider()
{
$this->container['cookies'] = function ($container) {
$config = $container['config']->get('session.cookies');
$cookies = new Cookies($config->toArray());
// 数据需要加密处理
if ($config->encrypt) {
$cookies->setEncryption($container['crypt']);
}
return $cookies;
};
} | [
"public",
"function",
"registerCookiesProvider",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'cookies'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"$",
"config",
"=",
"$",
"container",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'session.cookies'",
")",
";",
"$",
"cookies",
"=",
"new",
"Cookies",
"(",
"$",
"config",
"->",
"toArray",
"(",
")",
")",
";",
"// 数据需要加密处理",
"if",
"(",
"$",
"config",
"->",
"encrypt",
")",
"{",
"$",
"cookies",
"->",
"setEncryption",
"(",
"$",
"container",
"[",
"'crypt'",
"]",
")",
";",
"}",
"return",
"$",
"cookies",
";",
"}",
";",
"}"
] | 注册 Cookies 服务 | [
"注册",
"Cookies",
"服务"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Http/HttpServiceProvider.php#L25-L39 |
zhouyl/mellivora | Mellivora/Http/HttpServiceProvider.php | HttpServiceProvider.registerResponseProvider | public function registerResponseProvider()
{
$this->container['response'] = function ($container) {
$headers = new Headers(['Content-Type' => 'text/html; charset=UTF-8']);
$response = new Response(200, $headers);
return $response->withProtocolVersion($container['settings']['httpVersion']);
};
} | php | public function registerResponseProvider()
{
$this->container['response'] = function ($container) {
$headers = new Headers(['Content-Type' => 'text/html; charset=UTF-8']);
$response = new Response(200, $headers);
return $response->withProtocolVersion($container['settings']['httpVersion']);
};
} | [
"public",
"function",
"registerResponseProvider",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'response'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"$",
"headers",
"=",
"new",
"Headers",
"(",
"[",
"'Content-Type'",
"=>",
"'text/html; charset=UTF-8'",
"]",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"200",
",",
"$",
"headers",
")",
";",
"return",
"$",
"response",
"->",
"withProtocolVersion",
"(",
"$",
"container",
"[",
"'settings'",
"]",
"[",
"'httpVersion'",
"]",
")",
";",
"}",
";",
"}"
] | 注册 Http Response 服务 | [
"注册",
"Http",
"Response",
"服务"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Http/HttpServiceProvider.php#L54-L62 |
j-d/draggy | src/Draggy/Autocode/CPPEntity.php | CPPEntity.shouldRender | public function shouldRender($templateName)
{
switch ($templateName) {
case 'entity':
return true;
case 'entity-header':
return true;
case 'entity-base':
return $this->getProject()->getAutocodeProperty('base');
case 'entity-base-header':
return $this->getProject()->getAutocodeProperty('base');
}
return false;
} | php | public function shouldRender($templateName)
{
switch ($templateName) {
case 'entity':
return true;
case 'entity-header':
return true;
case 'entity-base':
return $this->getProject()->getAutocodeProperty('base');
case 'entity-base-header':
return $this->getProject()->getAutocodeProperty('base');
}
return false;
} | [
"public",
"function",
"shouldRender",
"(",
"$",
"templateName",
")",
"{",
"switch",
"(",
"$",
"templateName",
")",
"{",
"case",
"'entity'",
":",
"return",
"true",
";",
"case",
"'entity-header'",
":",
"return",
"true",
";",
"case",
"'entity-base'",
":",
"return",
"$",
"this",
"->",
"getProject",
"(",
")",
"->",
"getAutocodeProperty",
"(",
"'base'",
")",
";",
"case",
"'entity-base-header'",
":",
"return",
"$",
"this",
"->",
"getProject",
"(",
")",
"->",
"getAutocodeProperty",
"(",
"'base'",
")",
";",
"}",
"return",
"false",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/CPPEntity.php#L10-L24 |
mothership-ec/composer | src/Composer/Repository/FilesystemRepository.php | FilesystemRepository.initialize | protected function initialize()
{
parent::initialize();
if (!$this->file->exists()) {
return;
}
try {
$packages = $this->file->read();
if (!is_array($packages)) {
throw new \UnexpectedValueException('Could not parse package list from the repository');
}
} catch (\Exception $e) {
throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
}
$loader = new ArrayLoader(null, true);
foreach ($packages as $packageData) {
$package = $loader->load($packageData);
$this->addPackage($package);
}
} | php | protected function initialize()
{
parent::initialize();
if (!$this->file->exists()) {
return;
}
try {
$packages = $this->file->read();
if (!is_array($packages)) {
throw new \UnexpectedValueException('Could not parse package list from the repository');
}
} catch (\Exception $e) {
throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
}
$loader = new ArrayLoader(null, true);
foreach ($packages as $packageData) {
$package = $loader->load($packageData);
$this->addPackage($package);
}
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"parent",
"::",
"initialize",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"file",
"->",
"exists",
"(",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"packages",
"=",
"$",
"this",
"->",
"file",
"->",
"read",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"packages",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Could not parse package list from the repository'",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidRepositoryException",
"(",
"'Invalid repository data in '",
".",
"$",
"this",
"->",
"file",
"->",
"getPath",
"(",
")",
".",
"', packages could not be loaded: ['",
".",
"get_class",
"(",
"$",
"e",
")",
".",
"'] '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"loader",
"=",
"new",
"ArrayLoader",
"(",
"null",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"packageData",
")",
"{",
"$",
"package",
"=",
"$",
"loader",
"->",
"load",
"(",
"$",
"packageData",
")",
";",
"$",
"this",
"->",
"addPackage",
"(",
"$",
"package",
")",
";",
"}",
"}"
] | Initializes repository (reads file, or remote address). | [
"Initializes",
"repository",
"(",
"reads",
"file",
"or",
"remote",
"address",
")",
"."
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/FilesystemRepository.php#L42-L65 |
mothership-ec/composer | src/Composer/Repository/FilesystemRepository.php | FilesystemRepository.write | public function write()
{
$data = array();
$dumper = new ArrayDumper();
foreach ($this->getCanonicalPackages() as $package) {
$data[] = $dumper->dump($package);
}
$this->file->write($data);
} | php | public function write()
{
$data = array();
$dumper = new ArrayDumper();
foreach ($this->getCanonicalPackages() as $package) {
$data[] = $dumper->dump($package);
}
$this->file->write($data);
} | [
"public",
"function",
"write",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"dumper",
"=",
"new",
"ArrayDumper",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCanonicalPackages",
"(",
")",
"as",
"$",
"package",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"dumper",
"->",
"dump",
"(",
"$",
"package",
")",
";",
"}",
"$",
"this",
"->",
"file",
"->",
"write",
"(",
"$",
"data",
")",
";",
"}"
] | Writes writable repository. | [
"Writes",
"writable",
"repository",
"."
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/FilesystemRepository.php#L76-L86 |
phPoirot/psr7 | HttpResponse.php | HttpResponse.getReasonPhrase | function getReasonPhrase()
{
if (!$this->reasonPhrase)
$this->reasonPhrase = \Poirot\Psr7\Response\getStatReasonFromCode($this->getStatusCode());
return $this->reasonPhrase;
} | php | function getReasonPhrase()
{
if (!$this->reasonPhrase)
$this->reasonPhrase = \Poirot\Psr7\Response\getStatReasonFromCode($this->getStatusCode());
return $this->reasonPhrase;
} | [
"function",
"getReasonPhrase",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"reasonPhrase",
")",
"$",
"this",
"->",
"reasonPhrase",
"=",
"\\",
"Poirot",
"\\",
"Psr7",
"\\",
"Response",
"\\",
"getStatReasonFromCode",
"(",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"reasonPhrase",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/HttpResponse.php#L66-L72 |
phPoirot/psr7 | HttpResponse.php | HttpResponse.withStatus | function withStatus($code, $reasonPhrase = '')
{
$this->_assertValidateStatus($code);
$new = clone $this;
$new->statusCode = (int) $code;
$new->reasonPhrase = $reasonPhrase;
return $new;
} | php | function withStatus($code, $reasonPhrase = '')
{
$this->_assertValidateStatus($code);
$new = clone $this;
$new->statusCode = (int) $code;
$new->reasonPhrase = $reasonPhrase;
return $new;
} | [
"function",
"withStatus",
"(",
"$",
"code",
",",
"$",
"reasonPhrase",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"_assertValidateStatus",
"(",
"$",
"code",
")",
";",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"statusCode",
"=",
"(",
"int",
")",
"$",
"code",
";",
"$",
"new",
"->",
"reasonPhrase",
"=",
"$",
"reasonPhrase",
";",
"return",
"$",
"new",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/HttpResponse.php#L77-L85 |
phPoirot/psr7 | HttpResponse.php | HttpResponse._assertValidateStatus | protected function _assertValidateStatus($code)
{
if (! is_numeric($code)
|| is_float($code)
|| $code < 100
|| $code >= 600
)
throw new \InvalidArgumentException(sprintf(
'Invalid status code "%s"; must be an integer between 100 and 599, inclusive',
(is_scalar($code) ? $code : gettype($code))
));
} | php | protected function _assertValidateStatus($code)
{
if (! is_numeric($code)
|| is_float($code)
|| $code < 100
|| $code >= 600
)
throw new \InvalidArgumentException(sprintf(
'Invalid status code "%s"; must be an integer between 100 and 599, inclusive',
(is_scalar($code) ? $code : gettype($code))
));
} | [
"protected",
"function",
"_assertValidateStatus",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"code",
")",
"||",
"is_float",
"(",
"$",
"code",
")",
"||",
"$",
"code",
"<",
"100",
"||",
"$",
"code",
">=",
"600",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid status code \"%s\"; must be an integer between 100 and 599, inclusive'",
",",
"(",
"is_scalar",
"(",
"$",
"code",
")",
"?",
"$",
"code",
":",
"gettype",
"(",
"$",
"code",
")",
")",
")",
")",
";",
"}"
] | Validate a status code.
@param int|string $code
@throws \InvalidArgumentException on an invalid status code. | [
"Validate",
"a",
"status",
"code",
"."
] | train | https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/HttpResponse.php#L93-L104 |
m4grio/bangkok-insurance-php | src/Client/ModelClient.php | ModelClient.call | public function call($method, Array $params = [])
{
$rawResult = parent::call($method, $params);
switch ($method) {
case 'GetCarBrandAndModel':
$result = $rawResult->GetCarBrandAndModelReturn->MakeModelBean;
break;
case 'GetCarBrand':
$result = $rawResult->GetCarBrandReturn->x_car_brand->string;
}
return $result;
} | php | public function call($method, Array $params = [])
{
$rawResult = parent::call($method, $params);
switch ($method) {
case 'GetCarBrandAndModel':
$result = $rawResult->GetCarBrandAndModelReturn->MakeModelBean;
break;
case 'GetCarBrand':
$result = $rawResult->GetCarBrandReturn->x_car_brand->string;
}
return $result;
} | [
"public",
"function",
"call",
"(",
"$",
"method",
",",
"Array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"rawResult",
"=",
"parent",
"::",
"call",
"(",
"$",
"method",
",",
"$",
"params",
")",
";",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"'GetCarBrandAndModel'",
":",
"$",
"result",
"=",
"$",
"rawResult",
"->",
"GetCarBrandAndModelReturn",
"->",
"MakeModelBean",
";",
"break",
";",
"case",
"'GetCarBrand'",
":",
"$",
"result",
"=",
"$",
"rawResult",
"->",
"GetCarBrandReturn",
"->",
"x_car_brand",
"->",
"string",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | @param $method
@param array $params
@return mixed
@throws \Exception
@throws \SoapFault | [
"@param",
"$method",
"@param",
"array",
"$params"
] | train | https://github.com/m4grio/bangkok-insurance-php/blob/400266d043abe6b7cacb9da36064cbb169149c2a/src/Client/ModelClient.php#L29-L43 |
leprephp/http-server | src/Server.php | Server.append | public function append($middleware, $priority = 0): Server
{
return $this->appendOnCondition(
$middleware,
$this->buildAlwaysTrue(),
$priority
);
} | php | public function append($middleware, $priority = 0): Server
{
return $this->appendOnCondition(
$middleware,
$this->buildAlwaysTrue(),
$priority
);
} | [
"public",
"function",
"append",
"(",
"$",
"middleware",
",",
"$",
"priority",
"=",
"0",
")",
":",
"Server",
"{",
"return",
"$",
"this",
"->",
"appendOnCondition",
"(",
"$",
"middleware",
",",
"$",
"this",
"->",
"buildAlwaysTrue",
"(",
")",
",",
"$",
"priority",
")",
";",
"}"
] | Always adds a middleware to the stack.
The middleware will run in any case.
@param MiddlewareInterface|callable|array $middleware
@param int $priority
@return Server | [
"Always",
"adds",
"a",
"middleware",
"to",
"the",
"stack",
"."
] | train | https://github.com/leprephp/http-server/blob/2e307c80986456f7c53248b792771cb13bb4234d/src/Server.php#L63-L70 |
leprephp/http-server | src/Server.php | Server.appendOnPath | public function appendOnPath($middleware, string $path, $priority = 0): Server
{
return $this->appendOnCondition(
$middleware,
$this->buildPathCondition($path),
$priority
);
} | php | public function appendOnPath($middleware, string $path, $priority = 0): Server
{
return $this->appendOnCondition(
$middleware,
$this->buildPathCondition($path),
$priority
);
} | [
"public",
"function",
"appendOnPath",
"(",
"$",
"middleware",
",",
"string",
"$",
"path",
",",
"$",
"priority",
"=",
"0",
")",
":",
"Server",
"{",
"return",
"$",
"this",
"->",
"appendOnCondition",
"(",
"$",
"middleware",
",",
"$",
"this",
"->",
"buildPathCondition",
"(",
"$",
"path",
")",
",",
"$",
"priority",
")",
";",
"}"
] | Adds a middleware to the stack only if the request path matches.
The path must match exactly. If the "*" character is present, a comparison will be
made via regex. For example: the path '/api' matches only with request path '/api'.
But the path '/api/*' matches with all request paths that start with '/api/'.
The only position supported for the "*" character is at the end of the path. Other
positions may work today, but may no longer work in the future.
The path '*' (or '/*') matches with all request path. For performance reasons, in
this case you can consider using the `append()` method instead.
@param MiddlewareInterface|callable|array $middleware
@param string $path
@param int $priority
@return Server | [
"Adds",
"a",
"middleware",
"to",
"the",
"stack",
"only",
"if",
"the",
"request",
"path",
"matches",
"."
] | train | https://github.com/leprephp/http-server/blob/2e307c80986456f7c53248b792771cb13bb4234d/src/Server.php#L90-L97 |
leprephp/http-server | src/Server.php | Server.appendOnCondition | public function appendOnCondition($middleware, callable $condition, $priority = 0): Server
{
if (!is_array($middleware)) {
$middleware = [$middleware];
}
foreach ($middleware as $mw) {
$this->stack[$priority][] = [$condition, $mw];
}
return $this;
} | php | public function appendOnCondition($middleware, callable $condition, $priority = 0): Server
{
if (!is_array($middleware)) {
$middleware = [$middleware];
}
foreach ($middleware as $mw) {
$this->stack[$priority][] = [$condition, $mw];
}
return $this;
} | [
"public",
"function",
"appendOnCondition",
"(",
"$",
"middleware",
",",
"callable",
"$",
"condition",
",",
"$",
"priority",
"=",
"0",
")",
":",
"Server",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"middleware",
")",
")",
"{",
"$",
"middleware",
"=",
"[",
"$",
"middleware",
"]",
";",
"}",
"foreach",
"(",
"$",
"middleware",
"as",
"$",
"mw",
")",
"{",
"$",
"this",
"->",
"stack",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"[",
"$",
"condition",
",",
"$",
"mw",
"]",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds a middleware to the stack only if the condition returns true.
The `$condition` parameter must be a callable and it will be called with the
`ServerRequestInterface` object as argument.
@param MiddlewareInterface|callable|array $middleware
@param callable $condition
@param int $priority
@return $this | [
"Adds",
"a",
"middleware",
"to",
"the",
"stack",
"only",
"if",
"the",
"condition",
"returns",
"true",
"."
] | train | https://github.com/leprephp/http-server/blob/2e307c80986456f7c53248b792771cb13bb4234d/src/Server.php#L110-L121 |
ComposePress/core | src/Traits/Component.php | Component.get_plugin | public function get_plugin() {
if ( null === $this->plugin ) {
$parent = $this;
while ( $parent->has_parent() ) {
$parent = $parent->parent;
}
$this->plugin = $parent;
}
if ( $this->plugin === $this && ! ( $this instanceof Plugin ) ) {
throw new \Exception( 'Plugin property is equal to self. Did you forget to set the parent or create a getter?' );
}
return $this->plugin;
} | php | public function get_plugin() {
if ( null === $this->plugin ) {
$parent = $this;
while ( $parent->has_parent() ) {
$parent = $parent->parent;
}
$this->plugin = $parent;
}
if ( $this->plugin === $this && ! ( $this instanceof Plugin ) ) {
throw new \Exception( 'Plugin property is equal to self. Did you forget to set the parent or create a getter?' );
}
return $this->plugin;
} | [
"public",
"function",
"get_plugin",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"plugin",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
";",
"while",
"(",
"$",
"parent",
"->",
"has_parent",
"(",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"parent",
"->",
"parent",
";",
"}",
"$",
"this",
"->",
"plugin",
"=",
"$",
"parent",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"plugin",
"===",
"$",
"this",
"&&",
"!",
"(",
"$",
"this",
"instanceof",
"Plugin",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Plugin property is equal to self. Did you forget to set the parent or create a getter?'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"plugin",
";",
"}"
] | Magical utility method that will walk up the reference chain to get the master Plugin instance and cache it in $plugin
@return Plugin | [
"Magical",
"utility",
"method",
"that",
"will",
"walk",
"up",
"the",
"reference",
"chain",
"to",
"get",
"the",
"master",
"Plugin",
"instance",
"and",
"cache",
"it",
"in",
"$plugin"
] | train | https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L51-L65 |
ComposePress/core | src/Traits/Component.php | Component.setup_components | protected function setup_components() {
$this->load_components();
$components = $this->get_components();
$this->set_component_parents( $components );
/** @var \ComposePress\Core\Abstracts\Component[] $components */
foreach ( $components as $component ) {
if ( method_exists( $component, 'init' ) ) {
$component->init();
}
}
} | php | protected function setup_components() {
$this->load_components();
$components = $this->get_components();
$this->set_component_parents( $components );
/** @var \ComposePress\Core\Abstracts\Component[] $components */
foreach ( $components as $component ) {
if ( method_exists( $component, 'init' ) ) {
$component->init();
}
}
} | [
"protected",
"function",
"setup_components",
"(",
")",
"{",
"$",
"this",
"->",
"load_components",
"(",
")",
";",
"$",
"components",
"=",
"$",
"this",
"->",
"get_components",
"(",
")",
";",
"$",
"this",
"->",
"set_component_parents",
"(",
"$",
"components",
")",
";",
"/** @var \\ComposePress\\Core\\Abstracts\\Component[] $components */",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"component",
",",
"'init'",
")",
")",
"{",
"$",
"component",
"->",
"init",
"(",
")",
";",
"}",
"}",
"}"
] | Setup components and run init | [
"Setup",
"components",
"and",
"run",
"init"
] | train | https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L86-L97 |
ComposePress/core | src/Traits/Component.php | Component.get_components | protected function get_components() {
$components = ( new \ReflectionClass( $this ) )->getProperties();
$components = array_map(
/**
* @param \ReflectionProperty $property
*
* @return string
*/
function ( $property ) {
return $property->name;
}, $components );
$components = array_filter( $components, [ $this, 'is_component' ] );
$components = array_map(
/**
* @param \ReflectionProperty $component
*
* @return Component
*/
function ( $component ) {
$getter = "get_{$component}";
return $this->$getter();
}, $components );
return $components;
} | php | protected function get_components() {
$components = ( new \ReflectionClass( $this ) )->getProperties();
$components = array_map(
/**
* @param \ReflectionProperty $property
*
* @return string
*/
function ( $property ) {
return $property->name;
}, $components );
$components = array_filter( $components, [ $this, 'is_component' ] );
$components = array_map(
/**
* @param \ReflectionProperty $component
*
* @return Component
*/
function ( $component ) {
$getter = "get_{$component}";
return $this->$getter();
}, $components );
return $components;
} | [
"protected",
"function",
"get_components",
"(",
")",
"{",
"$",
"components",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getProperties",
"(",
")",
";",
"$",
"components",
"=",
"array_map",
"(",
"/**\n\t\t * @param \\ReflectionProperty $property\n\t\t *\n\t\t * @return string\n\t\t */",
"function",
"(",
"$",
"property",
")",
"{",
"return",
"$",
"property",
"->",
"name",
";",
"}",
",",
"$",
"components",
")",
";",
"$",
"components",
"=",
"array_filter",
"(",
"$",
"components",
",",
"[",
"$",
"this",
",",
"'is_component'",
"]",
")",
";",
"$",
"components",
"=",
"array_map",
"(",
"/**\n\t\t * @param \\ReflectionProperty $component\n\t\t *\n\t\t * @return Component\n\t\t */",
"function",
"(",
"$",
"component",
")",
"{",
"$",
"getter",
"=",
"\"get_{$component}\"",
";",
"return",
"$",
"this",
"->",
"$",
"getter",
"(",
")",
";",
"}",
",",
"$",
"components",
")",
";",
"return",
"$",
"components",
";",
"}"
] | Get all components with a getter and that uses the Component trait
@return array|\ReflectionProperty[] | [
"Get",
"all",
"components",
"with",
"a",
"getter",
"and",
"that",
"uses",
"the",
"Component",
"trait"
] | train | https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L104-L129 |
ComposePress/core | src/Traits/Component.php | Component.load | protected function load( $component, $args = [] ) {
$args = (array) $args;
if ( ! property_exists( $this, $component ) ) {
return false;
}
$class = $this->$component;
if ( ! is_string( $class ) ) {
return false;
}
if ( ! class_exists( $class ) ) {
throw new \Exception( sprintf( 'Can not find class "%s" for Component "%s" in parent Component "%s"', $class, $component, __CLASS__ ) );
}
$this->$component = $this->container->create( $class, $args );
return true;
} | php | protected function load( $component, $args = [] ) {
$args = (array) $args;
if ( ! property_exists( $this, $component ) ) {
return false;
}
$class = $this->$component;
if ( ! is_string( $class ) ) {
return false;
}
if ( ! class_exists( $class ) ) {
throw new \Exception( sprintf( 'Can not find class "%s" for Component "%s" in parent Component "%s"', $class, $component, __CLASS__ ) );
}
$this->$component = $this->container->create( $class, $args );
return true;
} | [
"protected",
"function",
"load",
"(",
"$",
"component",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"args",
"=",
"(",
"array",
")",
"$",
"args",
";",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"this",
",",
"$",
"component",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"class",
"=",
"$",
"this",
"->",
"$",
"component",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"class",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Can not find class \"%s\" for Component \"%s\" in parent Component \"%s\"'",
",",
"$",
"class",
",",
"$",
"component",
",",
"__CLASS__",
")",
")",
";",
"}",
"$",
"this",
"->",
"$",
"component",
"=",
"$",
"this",
"->",
"container",
"->",
"create",
"(",
"$",
"class",
",",
"$",
"args",
")",
";",
"return",
"true",
";",
"}"
] | Load any property on the current component based on its string value as the class via the container
@param $component
@return bool
@throws \Exception | [
"Load",
"any",
"property",
"on",
"the",
"current",
"component",
"based",
"on",
"its",
"string",
"value",
"as",
"the",
"class",
"via",
"the",
"container"
] | train | https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L139-L157 |
ComposePress/core | src/Traits/Component.php | Component.is_loaded | protected function is_loaded( $component ) {
if ( ! property_exists( $this, $component ) ) {
return false;
}
$property = $this->$component;
if ( ! is_object( $property ) ) {
return false;
}
if ( $property instanceof \stdClass ) {
return false;
}
return true;
} | php | protected function is_loaded( $component ) {
if ( ! property_exists( $this, $component ) ) {
return false;
}
$property = $this->$component;
if ( ! is_object( $property ) ) {
return false;
}
if ( $property instanceof \stdClass ) {
return false;
}
return true;
} | [
"protected",
"function",
"is_loaded",
"(",
"$",
"component",
")",
"{",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"this",
",",
"$",
"component",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"property",
"=",
"$",
"this",
"->",
"$",
"component",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"property",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"property",
"instanceof",
"\\",
"stdClass",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | @param string $component
@return bool | [
"@param",
"string",
"$component"
] | train | https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L164-L180 |
ComposePress/core | src/Traits/Component.php | Component.is_component | protected function is_component( $component, $use_cache = true ) {
static $cache = [];
if ( ! is_object( $component ) ) {
if ( ! is_string( $component ) ) {
return false;
}
$getter = 'get_' . $component;
if ( ! ( method_exists( $this, $getter ) && ( new \ReflectionMethod( $this, $getter ) )->isPublic() ) ) {
return false;
}
$component = $this->$getter();
}
if ( ! is_object( $component ) ) {
return false;
}
if ( $component instanceof \stdClass ) {
return false;
}
$hash = spl_object_hash( $component );
if ( $use_cache && isset( $cache[ $hash ] ) ) {
return $cache[ $hash ];
}
$trait = __TRAIT__;
$used = class_uses( $component );
if ( ! isset( $used[ $trait ] ) ) {
$parents = class_parents( $component );
while ( ! isset( $used[ $trait ] ) && $parents ) {
//get trait used by parents
$used = class_uses( array_pop( $parents ) );
}
}
$used = array_flip( $used );
$cache[ $hash ] = isset( $used[ $trait ] );
return $cache[ $hash ];
} | php | protected function is_component( $component, $use_cache = true ) {
static $cache = [];
if ( ! is_object( $component ) ) {
if ( ! is_string( $component ) ) {
return false;
}
$getter = 'get_' . $component;
if ( ! ( method_exists( $this, $getter ) && ( new \ReflectionMethod( $this, $getter ) )->isPublic() ) ) {
return false;
}
$component = $this->$getter();
}
if ( ! is_object( $component ) ) {
return false;
}
if ( $component instanceof \stdClass ) {
return false;
}
$hash = spl_object_hash( $component );
if ( $use_cache && isset( $cache[ $hash ] ) ) {
return $cache[ $hash ];
}
$trait = __TRAIT__;
$used = class_uses( $component );
if ( ! isset( $used[ $trait ] ) ) {
$parents = class_parents( $component );
while ( ! isset( $used[ $trait ] ) && $parents ) {
//get trait used by parents
$used = class_uses( array_pop( $parents ) );
}
}
$used = array_flip( $used );
$cache[ $hash ] = isset( $used[ $trait ] );
return $cache[ $hash ];
} | [
"protected",
"function",
"is_component",
"(",
"$",
"component",
",",
"$",
"use_cache",
"=",
"true",
")",
"{",
"static",
"$",
"cache",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"component",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"component",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"getter",
"=",
"'get_'",
".",
"$",
"component",
";",
"if",
"(",
"!",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"getter",
")",
"&&",
"(",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"this",
",",
"$",
"getter",
")",
")",
"->",
"isPublic",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"component",
"=",
"$",
"this",
"->",
"$",
"getter",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$",
"component",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"component",
"instanceof",
"\\",
"stdClass",
")",
"{",
"return",
"false",
";",
"}",
"$",
"hash",
"=",
"spl_object_hash",
"(",
"$",
"component",
")",
";",
"if",
"(",
"$",
"use_cache",
"&&",
"isset",
"(",
"$",
"cache",
"[",
"$",
"hash",
"]",
")",
")",
"{",
"return",
"$",
"cache",
"[",
"$",
"hash",
"]",
";",
"}",
"$",
"trait",
"=",
"__TRAIT__",
";",
"$",
"used",
"=",
"class_uses",
"(",
"$",
"component",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"used",
"[",
"$",
"trait",
"]",
")",
")",
"{",
"$",
"parents",
"=",
"class_parents",
"(",
"$",
"component",
")",
";",
"while",
"(",
"!",
"isset",
"(",
"$",
"used",
"[",
"$",
"trait",
"]",
")",
"&&",
"$",
"parents",
")",
"{",
"//get trait used by parents",
"$",
"used",
"=",
"class_uses",
"(",
"array_pop",
"(",
"$",
"parents",
")",
")",
";",
"}",
"}",
"$",
"used",
"=",
"array_flip",
"(",
"$",
"used",
")",
";",
"$",
"cache",
"[",
"$",
"hash",
"]",
"=",
"isset",
"(",
"$",
"used",
"[",
"$",
"trait",
"]",
")",
";",
"return",
"$",
"cache",
"[",
"$",
"hash",
"]",
";",
"}"
] | @param string|object $component
@param bool $use_cache
@return bool|mixed
@throws \ReflectionException | [
"@param",
"string|object",
"$component",
"@param",
"bool",
"$use_cache"
] | train | https://github.com/ComposePress/core/blob/f403f81d06a1e43017cb23c19c980fe3ef3bb6f7/src/Traits/Component.php#L189-L233 |
mustardandrew/muan-laravel-acl | src/AclServiceProvider.php | AclServiceProvider.boot | public function boot()
{
$this->initMigrations();
$this->initPermissions();
$this->initMiddlewares();
$this->initDirectives();
$this->initUserObserver();
$this->initCommands();
} | php | public function boot()
{
$this->initMigrations();
$this->initPermissions();
$this->initMiddlewares();
$this->initDirectives();
$this->initUserObserver();
$this->initCommands();
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"initMigrations",
"(",
")",
";",
"$",
"this",
"->",
"initPermissions",
"(",
")",
";",
"$",
"this",
"->",
"initMiddlewares",
"(",
")",
";",
"$",
"this",
"->",
"initDirectives",
"(",
")",
";",
"$",
"this",
"->",
"initUserObserver",
"(",
")",
";",
"$",
"this",
"->",
"initCommands",
"(",
")",
";",
"}"
] | Boot
@return void | [
"Boot"
] | train | https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/AclServiceProvider.php#L54-L62 |
mustardandrew/muan-laravel-acl | src/AclServiceProvider.php | AclServiceProvider.initPermissions | protected function initPermissions()
{
if ($this->app->runningInConsole()) {
return;
}
Permission::get()->map(function(Permission $permission) {
Gate::define($permission->name, function ($user) use ($permission) {
return $user->hasPermission($permission);
});
});
} | php | protected function initPermissions()
{
if ($this->app->runningInConsole()) {
return;
}
Permission::get()->map(function(Permission $permission) {
Gate::define($permission->name, function ($user) use ($permission) {
return $user->hasPermission($permission);
});
});
} | [
"protected",
"function",
"initPermissions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"runningInConsole",
"(",
")",
")",
"{",
"return",
";",
"}",
"Permission",
"::",
"get",
"(",
")",
"->",
"map",
"(",
"function",
"(",
"Permission",
"$",
"permission",
")",
"{",
"Gate",
"::",
"define",
"(",
"$",
"permission",
"->",
"name",
",",
"function",
"(",
"$",
"user",
")",
"use",
"(",
"$",
"permission",
")",
"{",
"return",
"$",
"user",
"->",
"hasPermission",
"(",
"$",
"permission",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Initialization permissions
@return void | [
"Initialization",
"permissions"
] | train | https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/AclServiceProvider.php#L79-L90 |
flowcode/AmulenUserBundle | src/Flowcode/UserBundle/Entity/User.php | User.addUserGroup | public function addUserGroup(\Amulen\UserBundle\Entity\UserGroup $userGroup)
{
$this->groups[] = $userGroup;
return $this;
} | php | public function addUserGroup(\Amulen\UserBundle\Entity\UserGroup $userGroup)
{
$this->groups[] = $userGroup;
return $this;
} | [
"public",
"function",
"addUserGroup",
"(",
"\\",
"Amulen",
"\\",
"UserBundle",
"\\",
"Entity",
"\\",
"UserGroup",
"$",
"userGroup",
")",
"{",
"$",
"this",
"->",
"groups",
"[",
"]",
"=",
"$",
"userGroup",
";",
"return",
"$",
"this",
";",
"}"
] | @param \Amulen\UserBundle\Entity\UserGroup $userGroup
@return User | [
"@param",
"\\",
"Amulen",
"\\",
"UserBundle",
"\\",
"Entity",
"\\",
"UserGroup",
"$userGroup"
] | train | https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Entity/User.php#L489-L494 |
simbiosis-group/yii2-helper | actions/ImportAction.php | ImportAction.run | public function run($defaultValuesJson = '')
{
$modelName = $this->formModelName;
$model = new $modelName;
if ('' != $defaultValuesJson) {
$this->defaultValues = $this->getDefaultValuesFromJson($defaultValuesJson);
}
if ($model->load(Yii::$app->request->post())) {
$file = UploadedFile::getInstance($model, 'file');
if ($this->import($this->getArrayFromExcel($file->tempName), $this->importModelName)) {
Yii::$app->getSession()->setFlash('success', 'You have imported the excel!');
return $this->controller->goBack();
};
Yii::$app->getSession()->setFlash('error', "You have failed to import the excel!\n{$this->msg}");
return $this->controller->goBack();
}
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && isset($_POST['ajax'])) {
Yii::$app->response->format = Response::FORMAT_JSON;
return \yii\widgets\ActiveForm::validate($model);
}
return $this->controller->renderAjax($this->importFormViewPath, [
'model'=>$model,
'importSafeAttributes' => $this->attributes
]);
} | php | public function run($defaultValuesJson = '')
{
$modelName = $this->formModelName;
$model = new $modelName;
if ('' != $defaultValuesJson) {
$this->defaultValues = $this->getDefaultValuesFromJson($defaultValuesJson);
}
if ($model->load(Yii::$app->request->post())) {
$file = UploadedFile::getInstance($model, 'file');
if ($this->import($this->getArrayFromExcel($file->tempName), $this->importModelName)) {
Yii::$app->getSession()->setFlash('success', 'You have imported the excel!');
return $this->controller->goBack();
};
Yii::$app->getSession()->setFlash('error', "You have failed to import the excel!\n{$this->msg}");
return $this->controller->goBack();
}
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && isset($_POST['ajax'])) {
Yii::$app->response->format = Response::FORMAT_JSON;
return \yii\widgets\ActiveForm::validate($model);
}
return $this->controller->renderAjax($this->importFormViewPath, [
'model'=>$model,
'importSafeAttributes' => $this->attributes
]);
} | [
"public",
"function",
"run",
"(",
"$",
"defaultValuesJson",
"=",
"''",
")",
"{",
"$",
"modelName",
"=",
"$",
"this",
"->",
"formModelName",
";",
"$",
"model",
"=",
"new",
"$",
"modelName",
";",
"if",
"(",
"''",
"!=",
"$",
"defaultValuesJson",
")",
"{",
"$",
"this",
"->",
"defaultValues",
"=",
"$",
"this",
"->",
"getDefaultValuesFromJson",
"(",
"$",
"defaultValuesJson",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"$",
"file",
"=",
"UploadedFile",
"::",
"getInstance",
"(",
"$",
"model",
",",
"'file'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"import",
"(",
"$",
"this",
"->",
"getArrayFromExcel",
"(",
"$",
"file",
"->",
"tempName",
")",
",",
"$",
"this",
"->",
"importModelName",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'success'",
",",
"'You have imported the excel!'",
")",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"goBack",
"(",
")",
";",
"}",
";",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'error'",
",",
"\"You have failed to import the excel!\\n{$this->msg}\"",
")",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"goBack",
"(",
")",
";",
"}",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
"&&",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"isset",
"(",
"$",
"_POST",
"[",
"'ajax'",
"]",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"\\",
"yii",
"\\",
"widgets",
"\\",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"return",
"$",
"this",
"->",
"controller",
"->",
"renderAjax",
"(",
"$",
"this",
"->",
"importFormViewPath",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'importSafeAttributes'",
"=>",
"$",
"this",
"->",
"attributes",
"]",
")",
";",
"}"
] | Runs the action
@param string $defaultValuesJson The default values in JSON format
@return string result content | [
"Runs",
"the",
"action"
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/actions/ImportAction.php#L103-L134 |
zhouyl/mellivora | Mellivora/Database/Schema/Blueprint.php | Blueprint.toSql | public function toSql(Connection $connection, Grammar $grammar)
{
$this->addImpliedCommands();
$statements = [];
// Each type of command has a corresponding compiler function on the schema
// grammar which is used to build the necessary SQL statements to build
// the blueprint element, so we'll just call that compilers function.
foreach ($this->commands as $command) {
$method = 'compile' . ucfirst($command->name);
if (method_exists($grammar, $method)) {
if (!is_null($sql = $grammar->{$method}($this, $command, $connection))) {
$statements = array_merge($statements, (array) $sql);
}
}
}
return $statements;
} | php | public function toSql(Connection $connection, Grammar $grammar)
{
$this->addImpliedCommands();
$statements = [];
// Each type of command has a corresponding compiler function on the schema
// grammar which is used to build the necessary SQL statements to build
// the blueprint element, so we'll just call that compilers function.
foreach ($this->commands as $command) {
$method = 'compile' . ucfirst($command->name);
if (method_exists($grammar, $method)) {
if (!is_null($sql = $grammar->{$method}($this, $command, $connection))) {
$statements = array_merge($statements, (array) $sql);
}
}
}
return $statements;
} | [
"public",
"function",
"toSql",
"(",
"Connection",
"$",
"connection",
",",
"Grammar",
"$",
"grammar",
")",
"{",
"$",
"this",
"->",
"addImpliedCommands",
"(",
")",
";",
"$",
"statements",
"=",
"[",
"]",
";",
"// Each type of command has a corresponding compiler function on the schema",
"// grammar which is used to build the necessary SQL statements to build",
"// the blueprint element, so we'll just call that compilers function.",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"command",
")",
"{",
"$",
"method",
"=",
"'compile'",
".",
"ucfirst",
"(",
"$",
"command",
"->",
"name",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"grammar",
",",
"$",
"method",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"sql",
"=",
"$",
"grammar",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"this",
",",
"$",
"command",
",",
"$",
"connection",
")",
")",
")",
"{",
"$",
"statements",
"=",
"array_merge",
"(",
"$",
"statements",
",",
"(",
"array",
")",
"$",
"sql",
")",
";",
"}",
"}",
"}",
"return",
"$",
"statements",
";",
"}"
] | Get the raw SQL statements for the blueprint.
@param \Mellivora\Database\Connection $connection
@param \Mellivora\Database\Schema\Grammars\Grammar $grammar
@return array | [
"Get",
"the",
"raw",
"SQL",
"statements",
"for",
"the",
"blueprint",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Schema/Blueprint.php#L98-L118 |
zhouyl/mellivora | Mellivora/Database/Schema/Blueprint.php | Blueprint.addImpliedCommands | protected function addImpliedCommands()
{
if (count($this->getAddedColumns()) > 0 && !$this->creating()) {
array_unshift($this->commands, $this->createCommand('add'));
}
if (count($this->getChangedColumns()) > 0 && !$this->creating()) {
array_unshift($this->commands, $this->createCommand('change'));
}
$this->addFluentIndexes();
} | php | protected function addImpliedCommands()
{
if (count($this->getAddedColumns()) > 0 && !$this->creating()) {
array_unshift($this->commands, $this->createCommand('add'));
}
if (count($this->getChangedColumns()) > 0 && !$this->creating()) {
array_unshift($this->commands, $this->createCommand('change'));
}
$this->addFluentIndexes();
} | [
"protected",
"function",
"addImpliedCommands",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"getAddedColumns",
"(",
")",
")",
">",
"0",
"&&",
"!",
"$",
"this",
"->",
"creating",
"(",
")",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"commands",
",",
"$",
"this",
"->",
"createCommand",
"(",
"'add'",
")",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"getChangedColumns",
"(",
")",
")",
">",
"0",
"&&",
"!",
"$",
"this",
"->",
"creating",
"(",
")",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"commands",
",",
"$",
"this",
"->",
"createCommand",
"(",
"'change'",
")",
")",
";",
"}",
"$",
"this",
"->",
"addFluentIndexes",
"(",
")",
";",
"}"
] | Add the commands that are implied by the blueprint's state.
@return void | [
"Add",
"the",
"commands",
"that",
"are",
"implied",
"by",
"the",
"blueprint",
"s",
"state",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Schema/Blueprint.php#L125-L136 |
zhouyl/mellivora | Mellivora/Database/Schema/Blueprint.php | Blueprint.createIndexName | protected function createIndexName($type, array $columns)
{
$index = strtolower($type . '_' . implode('_', $columns));
return str_replace(['-', '.'], '_', $index);
} | php | protected function createIndexName($type, array $columns)
{
$index = strtolower($type . '_' . implode('_', $columns));
return str_replace(['-', '.'], '_', $index);
} | [
"protected",
"function",
"createIndexName",
"(",
"$",
"type",
",",
"array",
"$",
"columns",
")",
"{",
"$",
"index",
"=",
"strtolower",
"(",
"$",
"type",
".",
"'_'",
".",
"implode",
"(",
"'_'",
",",
"$",
"columns",
")",
")",
";",
"return",
"str_replace",
"(",
"[",
"'-'",
",",
"'.'",
"]",
",",
"'_'",
",",
"$",
"index",
")",
";",
"}"
] | Create a default index name for the table.
@param string $type
@param array $columns
@return string | [
"Create",
"a",
"default",
"index",
"name",
"for",
"the",
"table",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Schema/Blueprint.php#L1063-L1068 |
ShaoZeMing/laravel-merchant | src/Layout/Content.php | Content.render | public function render()
{
$items = [
'header' => $this->header,
'description' => $this->description,
'breadcrumb' => $this->breadcrumb,
'content' => $this->build(),
];
return view('merchant::content', $items)->render();
} | php | public function render()
{
$items = [
'header' => $this->header,
'description' => $this->description,
'breadcrumb' => $this->breadcrumb,
'content' => $this->build(),
];
return view('merchant::content', $items)->render();
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"items",
"=",
"[",
"'header'",
"=>",
"$",
"this",
"->",
"header",
",",
"'description'",
"=>",
"$",
"this",
"->",
"description",
",",
"'breadcrumb'",
"=>",
"$",
"this",
"->",
"breadcrumb",
",",
"'content'",
"=>",
"$",
"this",
"->",
"build",
"(",
")",
",",
"]",
";",
"return",
"view",
"(",
"'merchant::content'",
",",
"$",
"items",
")",
"->",
"render",
"(",
")",
";",
"}"
] | Render this content.
@return string | [
"Render",
"this",
"content",
"."
] | train | https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Layout/Content.php#L197-L207 |
simbiosis-group/yii2-helper | models/ExcelImportForm.php | ExcelImportForm.getToolTipTemplate | public function getToolTipTemplate($field)
{
if (array_key_exists($field, $this->toolTips())) {
$toolTip = Html::tag('span', "{label}", [
'data-content'=> $this->toolTips()[$field],
'data-toggle'=>'popover',
'data-trigger'=>'hover',
'style'=>'cursor:help; border-bottom: 1px dashed #888'
]);
return "$toolTip \n{input}\n{hint}\n{error}";
}
return "{label}\n{input}\n{hint}\n{error}";
} | php | public function getToolTipTemplate($field)
{
if (array_key_exists($field, $this->toolTips())) {
$toolTip = Html::tag('span', "{label}", [
'data-content'=> $this->toolTips()[$field],
'data-toggle'=>'popover',
'data-trigger'=>'hover',
'style'=>'cursor:help; border-bottom: 1px dashed #888'
]);
return "$toolTip \n{input}\n{hint}\n{error}";
}
return "{label}\n{input}\n{hint}\n{error}";
} | [
"public",
"function",
"getToolTipTemplate",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"toolTips",
"(",
")",
")",
")",
"{",
"$",
"toolTip",
"=",
"Html",
"::",
"tag",
"(",
"'span'",
",",
"\"{label}\"",
",",
"[",
"'data-content'",
"=>",
"$",
"this",
"->",
"toolTips",
"(",
")",
"[",
"$",
"field",
"]",
",",
"'data-toggle'",
"=>",
"'popover'",
",",
"'data-trigger'",
"=>",
"'hover'",
",",
"'style'",
"=>",
"'cursor:help; border-bottom: 1px dashed #888'",
"]",
")",
";",
"return",
"\"$toolTip \\n{input}\\n{hint}\\n{error}\"",
";",
"}",
"return",
"\"{label}\\n{input}\\n{hint}\\n{error}\"",
";",
"}"
] | Generate the tool tip template to use in form.
@param string $field The table field name.
@return string Return the tool tip template. | [
"Generate",
"the",
"tool",
"tip",
"template",
"to",
"use",
"in",
"form",
"."
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/models/ExcelImportForm.php#L86-L100 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.